-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fast-usdc): operator attest cli command (#10610)
closes: #10567 ## Description Fill in the operator `attest` action and test it. ### Security Considerations none; it writes to stdout ### Scaling / Upgrade Considerations none ### Documentation Considerations ``` $ yarn fast-usdc operator attest --help Usage: fast-usdc operator attest [options] Attest to an observed Fast USDC transfer Options: --previousOfferId <string> Offer id --forwardingChannel <string> Channel id --recipientAddress <string> bech32 address --blockHash <0xhex> hex hash --blockNumber <number> number --blockTimestamp <number> number --chainId <string> chain id --amount <number> number --forwardingAddress <string> bech32 address --txHash <0xhexo> hex hash --offerId <string> Offer id (default: "operatorAttest-1733212600270") -h, --help display help for command ``` It's quite minimalistic. It requires a `--previousOfferId` without providing a `find-continuing-id` sub-command. It doesn't handle sign/broadcast nor reporting the outcome of the offer. I suppose `agops perf satisfaction` is available for that; I just hope don't end up relying on `agops` in production use. ### Testing Considerations One happy-path test, using injected io, to check that the bridgeAction that it writes is as expected. ``` ✔ fast-usdc operator attest sub-command ℹ node fast-usdc operator attest --previousOfferId 123 --forwardingChannel channel-21 --recipientAddress agoric16kv2g7snfc4q24vg3pjdlnnqgngtjpwtetd2h689nz09lcklvh5s8u37ek?EUD=dydx183dejcnmkka5dzcu9xw6mywq0p2m5peks28men --amount 300000000 --forwardingAddress noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelktz --blockHash 0x80d7343e04f8160892e94f02d6a9b9f255663ed0ac34caca98544c8143fee699 --blockNumber 21037669 --blockTimestamp 1730762099 --txHash 0xd81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761799 --chainId 1 ```
- Loading branch information
Showing
11 changed files
with
280 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { makeMarshal } from '@endo/marshal'; | ||
import test from 'ava'; | ||
import { Command } from 'commander'; | ||
import { addOperatorCommands } from '../../src/cli/operator-commands.js'; | ||
import { flags } from '../../tools/cli-tools.js'; | ||
import { mockStream } from '../../tools/mock-io.js'; | ||
import { MockCctpTxEvidences } from '../fixtures.js'; | ||
|
||
const marshalData = makeMarshal(_v => assert.fail('data only')); | ||
|
||
test('fast-usdc operator attest sub-command', async t => { | ||
const evidence = harden(MockCctpTxEvidences.AGORIC_PLUS_DYDX()); | ||
const { aux, tx, ...flat } = evidence; | ||
const argv = [ | ||
...`node fast-usdc operator attest`.split(' '), | ||
...flags({ previousOfferId: 123, ...aux, ...tx, ...flat }), | ||
]; | ||
t.log(...argv); | ||
const program = new Command(); | ||
program.exitOverride(); | ||
const out = [] as string[]; | ||
const err = [] as string[]; | ||
|
||
addOperatorCommands(program, { | ||
fetch: null as unknown as Window['fetch'], | ||
stdout: mockStream<typeof process.stdout>(out), | ||
stderr: mockStream<typeof process.stderr>(err), | ||
env: {}, | ||
now: () => 1234, | ||
}); | ||
|
||
await program.parseAsync(argv); | ||
|
||
const action = marshalData.fromCapData(JSON.parse(out.join(''))); | ||
t.deepEqual(action, { | ||
method: 'executeOffer', | ||
offer: { | ||
id: 'operatorAttest-1234', | ||
invitationSpec: { | ||
invitationArgs: [evidence], | ||
invitationMakerName: 'SubmitEvidence', | ||
previousOffer: '123', | ||
source: 'continuing', | ||
}, | ||
proposal: {}, | ||
}, | ||
}); | ||
|
||
t.is( | ||
err.join(''), | ||
'Now use `agoric wallet send ...` to sign and broadcast the offer.\n', | ||
); | ||
}); |
Oops, something went wrong.