Skip to content

Commit

Permalink
chore: get config + inserted slot
Browse files Browse the repository at this point in the history
  • Loading branch information
ohdcthang committed Aug 6, 2024
1 parent 89a1148 commit e2c8532
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/packages/giftFactoy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Contract, ethers } from "ethers";
import { CONTRACT_NAME, ERC20ABI, GIFT_ABI } from '../constants'
import { ClaimRewardParams, ClaimRewardRespone, CreateGiftRespone, CreateGiftsParams, SetFee, WithdrawGiftRespone, WithdrawRewardParams } from "../types";
import { ClaimRewardParams, ClaimRewardRespone, CreateGiftRespone, CreateGiftsParams, GetInsertedSlotParams, SetFee, WithdrawGiftRespone, WithdrawRewardParams } from "../types";
import { convertBalanceToWei } from "../utils";
import { GasSponsor } from "./gasSponsor";
import { GiftCore } from "./giftCore";
Expand Down Expand Up @@ -144,6 +144,27 @@ export class GiftFactory extends GiftCore{
}
}

async getGiftConfig(giftContractAddress: string){
try {
const giftContract = new ethers.Contract(giftContractAddress , GIFT_ABI['COIN98_GIFT_CONTRACT_ADDRESS'], this.signer)
const giftConfig = await giftContract.connect(this.signer).getGiftConfig()
return giftConfig
} catch (error) {
throw new Error(error as unknown as string)
}
}

async getInsertedSlot(params: GetInsertedSlotParams){
const { giftContractAddress, recipientAddress } = params
try {
const giftContract = new ethers.Contract(giftContractAddress , GIFT_ABI['COIN98_GIFT_CONTRACT_ADDRESS'], this.signer)
const giftConfig = await giftContract.connect(this.signer).getInsertedSlot(recipientAddress)
return giftConfig
} catch (error) {
throw new Error(error as unknown as string)
}
}

async unlockFunction(functionName: string): Promise<string>{
try {
const nonce = await this.getNonceAccount(this.signer.address)
Expand All @@ -156,7 +177,7 @@ export class GiftFactory extends GiftCore{

return transactionHash
} catch (error) {
throw new Error(error as unknown as string)
throw new Error(error as unknown as string)
}
}
}
5 changes: 5 additions & 0 deletions src/types/gifts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,9 @@ export interface CreateGiftRespone extends BaseRewardRespone{

export interface WithdrawGiftRespone extends BaseRewardRespone{
amount: number
}

export interface GetInsertedSlotParams{
giftContractAddress: string,
recipientAddress: string
}

0 comments on commit e2c8532

Please sign in to comment.