diff --git a/client-config.json b/client-config.json index 6f0add4..a8a3223 100644 --- a/client-config.json +++ b/client-config.json @@ -94,19 +94,25 @@ "minters": { "BOB-sepolia": "", "BOB2USDC-goerli": "", + "WETH-goerli": "", + "USDC-goerli": "", "BOB-op-goerli": "" }, "cloudApi": { "BOB-sepolia": "http://45.77.217.163:8701", "BOB2USDC-goerli": "", + "WETH-goerli": "", + "USDC-goerli": "", "BOB-op-goerli": "" }, "redemptionUrls": { "BOB-sepolia": "https://staging--zkbob.netlify.app", - "BOB2USDC-goerli": "", - "BOB-op-goerli": "" + "BOB2USDC-goerli": "https://staging--zkbob.netlify.app", + "WETH-goerli": "https://staging--zkbob.netlify.app", + "USDC-goerli": "https://staging--zkbob.netlify.app", + "BOB-op-goerli": "https://staging--zkbob.netlify.app" }, "migrations": { diff --git a/src/account.ts b/src/account.ts index 1b25c40..ee0773c 100644 --- a/src/account.ts +++ b/src/account.ts @@ -739,17 +739,7 @@ export class Account { } public async giftCardBalance(giftCard: GiftCardProperties): Promise { - const proverMode = this.config.pools[this.getCurrentPool()].delegatedProverUrls.length > 0 ? - ProverMode.DelegatedWithFallback : - ProverMode.Local; - - const giftCardAccountConfig: AccountConfig = { - sk: giftCard.sk, - pool: this.getZpClient().currentPool(), - birthindex: giftCard.birthIndex, - proverMode, - } - return await this.getZpClient().giftCardBalance(giftCardAccountConfig); + return await this.getZpClient().giftCardBalance(giftCard); } public async redeemGiftCard(giftCard: GiftCardProperties): Promise<{jobId: string, txHash: string}> { @@ -757,15 +747,8 @@ export class Account { ProverMode.DelegatedWithFallback : ProverMode.Local; - const giftCardAccountConfig: AccountConfig = { - sk: giftCard.sk, - pool: this.getZpClient().currentPool(), - birthindex: giftCard.birthIndex, - proverMode, - } - console.log('Redeeming gift-card...'); - const jobId: string = await this.getZpClient().redeemGiftCard(giftCardAccountConfig); + const jobId: string = await this.getZpClient().redeemGiftCard(giftCard, proverMode); console.log(`Please wait relayer provide txHash for job ${jobId}...`); return {jobId, txHash: (await this.getZpClient().waitJobTxHash(jobId))}; diff --git a/src/commands.ts b/src/commands.ts index 95008fd..a053c57 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1344,13 +1344,18 @@ export async function generateGiftCardLocal(amount: string, quantity: string){ const cardBalance = await this.account.humanToShielded(amount); const poolAlias = this.account.getCurrentPool(); + this.echo(`[[;green;]You can add extra funds to cover the relayer fee. Otherwise the user won't receive exactly specified token amount during redemption]`); + this.resume(); + const val = await this.read(`Specify extra funds for the ${qty > 1 ? 'EACH ' : ''}gift-card or press ENTER to leave it zero: `); + const extraFundsForFee = await this.account.humanToShielded(val ?? '0'); + this.pause(); // check is account has enough funds to deposit gift-card this.echo('Checking available funds...'); await this.account.syncState(); const availableFunds = await this.account.getMaxAvailableTransfer(TxType.Transfer); - if (availableFunds >= cardBalance * BigInt(qty) ) { + if (availableFunds >= (cardBalance + extraFundsForFee) * BigInt(qty) ) { this.update(-1, 'Checking available funds... [[;green;]OK]'); let transferRequests:TransferRequest[] = []; @@ -1363,7 +1368,7 @@ export async function generateGiftCardLocal(amount: string, quantity: string){ const receivingAddress = await this.account.genShieldedAddressForSeed(sk) transferRequests.push( { destination: receivingAddress, - amountGwei: cardBalance + amountGwei: cardBalance + extraFundsForFee }); this.update(-1,`Creating burner wallets... ${index+1}/${qty}`); const giftCardProps: GiftCardProperties = { sk, birthIndex, balance: cardBalance, poolAlias }; diff --git a/src/index.ts b/src/index.ts index bd7a603..a4d0152 100644 --- a/src/index.ts +++ b/src/index.ts @@ -73,7 +73,7 @@ const COMMANDS: { [key: string]: [(...args) => void, string, string] } = { 'account-id': [c.getAccountId, '', 'get the client account id (indexed DB name)'], 'support-id': [c.getSupportId, '', 'get the client support id'], 'version': [ c.getVersion, '', 'get console and relayer versions'], - 'gift-card-generate':[c.generateGiftCardLocal, '', 'creates a single burner wallet with specified balance and returns redemption url and qr code'], + 'gift-card-generate':[c.generateGiftCardLocal, ' [quantity]', 'generates a bunch of gift cards from the local account'], 'gift-card-generate-cloud':[c.generateGiftCards,' ','generate gift cards via cloud (you should provide cloud access token)'], 'gift-card-balance': [c.giftCardBalance, ' [code_or_redemption_url2 code_or_redemption_url3 ...]', 'retrieve gift cards balances'], 'gift-card-redeem': [c.redeemGiftCard, '', 'redeem gift card to the current account'],