diff --git a/packages/fast-usdc/src/cli.js b/packages/fast-usdc/src/cli.js index 24846841cb7..6aa27166bea 100755 --- a/packages/fast-usdc/src/cli.js +++ b/packages/fast-usdc/src/cli.js @@ -35,4 +35,23 @@ program // TODO: Implement withdraw logic }); +program + .command('transfer') + .description('Transfer USDC from Ethereum/L2 to Cosmos via Fast USDC') + .argument('amount', 'Amount to transfer denominated in uusdc') + .argument('dest', 'Destination address in Cosmos') + .action((/** @type {string} */ amount, /** @type {string} */ destination) => { + const start = Date.now(); + console.error( + `TODO actually kick off USDC transfer. Amount: ${amount}uusdc Destination: ${destination}`, + ); + console.info(`Finished in ${Date.now() - start}ms`); + // TODO: Implement transfer logic + // 1. Look up agoric Fast USDC contract address + // 2. Append destination address to agoric address + // 3. Compute noble forwarding address from result + // 4. Tell watcher to watch for transfers to computer address + // 5. Sign and broadcast CCTP transfer to noble forwarding address + }); + program.parse(); diff --git a/packages/fast-usdc/test/cli.test.ts b/packages/fast-usdc/test/cli.test.ts index f14e70fa161..26f75cf962b 100644 --- a/packages/fast-usdc/test/cli.test.ts +++ b/packages/fast-usdc/test/cli.test.ts @@ -22,3 +22,20 @@ test('CLI shows help when run without arguments', async t => { t.snapshot(output); }); + +test('CLI shows help for transfer command', async t => { + const output = await new Promise(resolve => { + const child = spawn('node', [CLI_PATH, 'transfer', '-h']); + let stdout = ''; + + child.stdout.on('data', data => { + stdout += data.toString(); + }); + + child.on('close', () => { + resolve(stdout); + }); + }); + + t.snapshot(output); +}); diff --git a/packages/fast-usdc/test/snapshots/cli.test.ts.md b/packages/fast-usdc/test/snapshots/cli.test.ts.md index f99a1fe5746..70a55b346e5 100644 --- a/packages/fast-usdc/test/snapshots/cli.test.ts.md +++ b/packages/fast-usdc/test/snapshots/cli.test.ts.md @@ -13,11 +13,29 @@ Generated by [AVA](https://avajs.dev). CLI to interact with Fast USDC liquidity pool␊ ␊ Options:␊ - -V, --version output the version number␊ - -h, --help display help for command␊ + -V, --version output the version number␊ + -h, --help display help for command␊ ␊ Commands:␊ - deposit Offer assets to the liquidity pool␊ - withdraw Withdraw assets from the liquidity pool␊ - help [command] display help for command␊ + deposit Offer assets to the liquidity pool␊ + withdraw Withdraw assets from the liquidity pool␊ + transfer Transfer USDC from Ethereum/L2 to Cosmos via Fast␊ + USDC␊ + help [command] display help for command␊ + ` + +## CLI shows help for transfer command + +> Snapshot 1 + + `Usage: fast-usdc transfer [options] ␊ + ␊ + Transfer USDC from Ethereum/L2 to Cosmos via Fast USDC␊ + ␊ + Arguments:␊ + amount Amount to transfer denominated in uusdc␊ + dest Destination address in Cosmos␊ + ␊ + Options:␊ + -h, --help display help for command␊ ` diff --git a/packages/fast-usdc/test/snapshots/cli.test.ts.snap b/packages/fast-usdc/test/snapshots/cli.test.ts.snap index 7fb4649fe87..02af5899cc5 100644 Binary files a/packages/fast-usdc/test/snapshots/cli.test.ts.snap and b/packages/fast-usdc/test/snapshots/cli.test.ts.snap differ