Skip to content

Commit

Permalink
feat: include 'sender' in CctpTxEvidence
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 13, 2024
1 parent 5731f20 commit 3607cf6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/fast-usdc/src/cli/operator-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const addOperatorCommands = (
.requiredOption('--chainId <string>', 'chain id', Number)
.requiredOption('--amount <number>', 'number', parseNat)
.requiredOption('--forwardingAddress <string>', 'bech32 address', String)
.requiredOption('--sender <string>', 'Ethereum address initiating', String)
.requiredOption('--txHash <0xhexo>', 'hex hash', parseHex)
.option('--offerId <string>', 'Offer id', String, `operatorAttest-${now()}`)
.action(async opts => {
Expand All @@ -109,12 +110,13 @@ export const addOperatorCommands = (
recipientAddress,
amount,
forwardingAddress,
sender,
...flat
} = opts;

const evidence = harden({
aux: { forwardingChannel, recipientAddress },
tx: { amount, forwardingAddress },
tx: { amount, forwardingAddress, sender },
...flat,
});
mustMatch(evidence, CctpTxEvidenceShape);
Expand Down
11 changes: 9 additions & 2 deletions packages/fast-usdc/src/type-guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PendingTxStatus } from './constants.js';
* @import {TypedPattern} from '@agoric/internal';
* @import {FastUsdcTerms} from './fast-usdc.contract.js';
* @import {USDCProposalShapes} from './pool-share-math.js';
* @import {CctpTxEvidence, FeeConfig, PendingTx, PoolMetrics, ChainPolicy, FeedPolicy, AddressHook} from './types.js';
* @import {CctpTxEvidence, FeeConfig, PendingTx, PoolMetrics, ChainPolicy, FeedPolicy, AddressHook, EvmAddress, EvmHash} from './types.js';
*/

/**
Expand Down Expand Up @@ -36,7 +36,13 @@ export const FastUSDCTermsShape = harden({
usdcDenom: M.string(),
});

/** @type {TypedPattern<string>} */
/** @type {TypedPattern<EvmAddress>} */
export const EvmAddressShape = M.string({
stringLengthLimit: 40,
});
harden(EvmAddressShape);

/** @type {TypedPattern<EvmHash>} */
export const EvmHashShape = M.string({
stringLengthLimit: 66,
});
Expand All @@ -54,6 +60,7 @@ export const CctpTxEvidenceShape = {
tx: {
amount: M.nat(),
forwardingAddress: M.string(),
sender: EvmAddressShape,
},
txHash: EvmHashShape,
};
Expand Down
2 changes: 2 additions & 0 deletions packages/fast-usdc/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { PendingTxStatus } from './constants.js';
import type { FastUsdcTerms } from './fast-usdc.contract.js';

export type EvmHash = `0x${string}`;
export type EvmAddress = `0x${string & { length: 40 }}`;
export type NobleAddress = `noble1${string}`;
export type EvmChainID = number;
export type EvmChainName = string;
Expand All @@ -28,6 +29,7 @@ export interface CctpTxEvidence {
tx: {
amount: bigint;
forwardingAddress: NobleAddress;
sender: EvmAddress;
};
txHash: EvmHash;
}
Expand Down
10 changes: 9 additions & 1 deletion packages/fast-usdc/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js';
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
import type { ChainAddress } from '@agoric/orchestration';
import type { VTransferIBCEvent } from '@agoric/vats';
import type { CctpTxEvidence } from '../src/types.js';
import type { CctpTxEvidence, EvmAddress } from '../src/types.js';

const mockScenarios = [
'AGORIC_PLUS_OSMO',
Expand All @@ -14,6 +14,10 @@ const mockScenarios = [

type MockScenario = (typeof mockScenarios)[number];

export const Senders = {
default: '0xDefaultFakeEthereumAddress',
} as unknown as Record<string, EvmAddress>;

export const MockCctpTxEvidences: Record<
MockScenario,
(receiverAddress?: string) => CctpTxEvidence
Expand All @@ -27,6 +31,7 @@ export const MockCctpTxEvidences: Record<
tx: {
amount: 150000000n,
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd',
sender: Senders.default,
},
aux: {
forwardingChannel: 'channel-21',
Expand All @@ -48,6 +53,7 @@ export const MockCctpTxEvidences: Record<
tx: {
amount: 300000000n,
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelktz',
sender: Senders.default,
},
aux: {
forwardingChannel: 'channel-21',
Expand All @@ -69,6 +75,7 @@ export const MockCctpTxEvidences: Record<
tx: {
amount: 200000000n,
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelyyy',
sender: Senders.default,
},
aux: {
forwardingChannel: 'channel-21',
Expand All @@ -87,6 +94,7 @@ export const MockCctpTxEvidences: Record<
tx: {
amount: 200000000n,
forwardingAddress: 'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelyyy',
sender: Senders.default,
},
aux: {
forwardingChannel: 'channel-21',
Expand Down

0 comments on commit 3607cf6

Please sign in to comment.