Skip to content

Commit

Permalink
chore: production
Browse files Browse the repository at this point in the history
  • Loading branch information
ohdcthang committed Aug 14, 2024
1 parent 64f6a3e commit 8a7ead6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
11 changes: 5 additions & 6 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { URL_REQUEST } from "../constants";
import { CODE, URL_REQUEST } from "../constants";
import { GetInsertedSlotParams } from "../types";

interface InsertedSlotParams extends GetInsertedSlotParams{
code: string,
isDev: boolean
}

export const getInsertedSlotReward = async (params: InsertedSlotParams): Promise<number> => {
const { recipientAddress, giftContractAddress, isDev, code} = params
const { recipientAddress, giftContractAddress, isDev} = params
const url = URL_REQUEST(isDev)
try {
const request = await fetch(`${url}/${giftContractAddress}/inserted-slot/${recipientAddress}`,{
headers: {
apiKey: code
apiKey: CODE(isDev)
}
})

Expand All @@ -24,12 +23,12 @@ export const getInsertedSlotReward = async (params: InsertedSlotParams): Promise
}
}

export const getGiftReward = async (giftContractAddress: string, code: string, isDev: boolean): Promise<number> => {
export const getGiftReward = async (giftContractAddress: string, isDev: boolean): Promise<number> => {
const url = URL_REQUEST(isDev)
try {
const request = await fetch(`${url}/${giftContractAddress}/config`,{
headers: {
apiKey: code
apiKey: CODE(isDev)
}
})

Expand Down
4 changes: 4 additions & 0 deletions src/constants/url.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const URL_REQUEST = (isDev: boolean) => {
return isDev ? 'https://superwallet-chat-api-stg.coin98.tech/adapters/lucky-gift' : ''
}

export const CODE = (isDev: boolean) => {
return isDev ? 'dev_adapter9898' : ''
}
6 changes: 2 additions & 4 deletions src/packages/giftFactoy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { GiftCore } from "./giftCore";

export class GiftFactory extends GiftCore{
static instance: GiftFactory
private code?: string
private isDev?: boolean
sponsorGasContract?: GasSponsor

Expand All @@ -20,7 +19,6 @@ export class GiftFactory extends GiftCore{

super(CONTRACT_NAME.COIN98_GIFT_FACTORY_CONTRACT_ADDRESS, params?.privateKey, params.isDev)

this.code = params.code
this.isDev = params.isDev
this.sponsorGasContract = new GasSponsor(params?.privateKey ,params.isDev)

Expand Down Expand Up @@ -121,7 +119,7 @@ export class GiftFactory extends GiftCore{
async claimGift(params: ClaimRewardParams): Promise<ClaimRewardRespone>{
const { wallet, giftContractAddress } = params

const reward = await getInsertedSlotReward({giftContractAddress,recipientAddress: wallet?.address, code: this.code as string, isDev: this.isDev as boolean })
const reward = await getInsertedSlotReward({giftContractAddress,recipientAddress: wallet?.address, isDev: this.isDev as boolean })


const response = await this.sponsorGasContract?.claimReward(params)
Expand All @@ -136,7 +134,7 @@ export class GiftFactory extends GiftCore{
}

async withdrawRemainingReward(params: WithdrawRewardParams): Promise<WithdrawGiftRespone>{
const giftReward = await getGiftReward(params.giftContractAddress, this.code as string, this.isDev as boolean)
const giftReward = await getGiftReward(params.giftContractAddress, this.isDev as boolean)

const response = await this.sponsorGasContract?.withdrawRemainingReward(params)

Expand Down
1 change: 0 additions & 1 deletion src/types/engine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export interface GiftFactoryEngine {
privateKey?: string,
code?: string
isDev: boolean
}

0 comments on commit 8a7ead6

Please sign in to comment.