Skip to content

Commit

Permalink
feat(fast-usdc): stub transfer cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Oct 29, 2024
1 parent acbd3ae commit 46e6e9e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
19 changes: 19 additions & 0 deletions packages/fast-usdc/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
17 changes: 17 additions & 0 deletions packages/fast-usdc/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
28 changes: 23 additions & 5 deletions packages/fast-usdc/test/snapshots/cli.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <amount> <dest> 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] <amount> <dest>␊
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␊
`
Binary file modified packages/fast-usdc/test/snapshots/cli.test.ts.snap
Binary file not shown.

0 comments on commit 46e6e9e

Please sign in to comment.