From 46e6e9e2866cd70aac21503c495e61b16aaef0db Mon Sep 17 00:00:00 2001 From: samsiegart Date: Mon, 28 Oct 2024 23:38:25 -0700 Subject: [PATCH] feat(fast-usdc): stub transfer cli command --- packages/fast-usdc/src/cli.js | 19 ++++++++++++ packages/fast-usdc/test/cli.test.ts | 17 +++++++++++ .../fast-usdc/test/snapshots/cli.test.ts.md | 28 ++++++++++++++---- .../fast-usdc/test/snapshots/cli.test.ts.snap | Bin 330 -> 481 bytes 4 files changed, 59 insertions(+), 5 deletions(-) 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 7fb4649fe87e9fd1505e4d5dac5209a001aefcdb..02af5899cc5845a49212d9720fdc4cc520afb401 100644 GIT binary patch literal 481 zcmV<70UrKARzV>b-jR)m6ib8~Ob}>a?MsyYrLJAT=)qYHC_o z))XM7086JeCk2ex$x~2q60nt;Res%Di;CwPW^=MN$u)g5+1~gwJrlg9eW*}$mc%aL zf?IVQ^%m1X-sBR1{ahfF0^BUPbdm!UykR{xF5+`r+3gYH^!V6h?3N`qBE($+Hoc>*L@1pA|wC*}sgT5rbr|1N5AN9>Reo(L;c*{ZHpzhwxEr zij@4`$%nkuoW--it;5b_^Ma0{GKhiV$8fQKa;(qOyHTEU&#?Wfc|A$foo7jUyPl*0 z<1tbrFO2zbFN$7s)JHsDyMPw8N9CO_+e2Fl>|H=53oby)%XJx%At1*jnmcj`(b`BN XxwUXV&-0UHzUu5>8@Y8gvjYGCj{E3t literal 330 zcmV-Q0k!@?RzV;Vb4KFb|ic_8ly$O6#jg6IqOwi%&yK}ixumgouk$)WoA=hO;J1r-e6r(+v;F8 zO7)3C@Ih?Sl?+L^(=1p$-Y(Gi_w0?AJt9$~)N*`cu7L9C24(qS6MG5(C`-%&aTe1s zn_jB;8G> c=jnd()rs1_ode9z*Zc$d4aVxI9Jm1h0P91Z+W-In