Skip to content

Commit

Permalink
feat: publish CctpTxEvidence
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 17, 2024
1 parent 1637c1d commit 2916c8f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
16 changes: 15 additions & 1 deletion packages/fast-usdc/src/exos/status-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { M } from '@endo/patterns';
import { Fail, makeError, q } from '@endo/errors';
import { appendToStoredArray } from '@agoric/store/src/stores/store-utils.js';
import { E } from '@endo/eventual-send';
import { makeTracer } from '@agoric/internal';
import { makeTracer, pureDataMarshaller } from '@agoric/internal';
import {
CctpTxEvidenceShape,
EvmHashShape,
Expand Down Expand Up @@ -83,6 +83,19 @@ export const prepareStatusManager = (
keyShape: M.string(),
});

/**
* @param {CctpTxEvidence['txHash']} hash
* @param {CctpTxEvidence} evidence
*/
const publishEvidence = (hash, evidence) => {
const txNode = E(transactionsNode).makeChildNode(hash);
// Don't await, just writing to vstorage.
void E(txNode).setValue(
// @ts-expect-error XXX CopyRecordI expects an index signature
JSON.stringify(pureDataMarshaller.toCapData(evidence)),
);
};

/**
* @param {CctpTxEvidence['txHash']} hash
* @param {TxStatus} status
Expand Down Expand Up @@ -114,6 +127,7 @@ export const prepareStatusManager = (
pendingTxKeyOf(evidence),
harden({ ...evidence, status }),
);
publishEvidence(txHash, evidence);
publishStatus(txHash, status);
};

Expand Down
19 changes: 10 additions & 9 deletions packages/fast-usdc/test/exos/advancer.test.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import type { TestFn } from 'ava';
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import {
decodeAddressHook,
encodeAddressHook,
} from '@agoric/cosmic-proto/address-hooks.js';
import type { NatAmount } from '@agoric/ertp';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { denomHash } from '@agoric/orchestration';
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
import { Far } from '@endo/pass-style';
import type { NatAmount } from '@agoric/ertp';
import { type ZoeTools } from '@agoric/orchestration/src/utils/zoe-tools.js';
import { q } from '@endo/errors';
import {
decodeAddressHook,
encodeAddressHook,
} from '@agoric/cosmic-proto/address-hooks.js';
import { Far } from '@endo/pass-style';
import type { TestFn } from 'ava';
import { PendingTxStatus } from '../../src/constants.js';
import { prepareAdvancer } from '../../src/exos/advancer.js';
import type { SettlerKit } from '../../src/exos/settler.js';
import { prepareStatusManager } from '../../src/exos/status-manager.js';
import type { LiquidityPoolKit } from '../../src/types.js';
import { makeFeeTools } from '../../src/utils/fees.js';
import { commonSetup } from '../supports.js';
import { MockCctpTxEvidences, intermediateRecipient } from '../fixtures.js';
import {
makeTestFeeConfig,
makeTestLogger,
prepareMockOrchAccounts,
} from '../mocks.js';
import type { LiquidityPoolKit } from '../../src/types.js';
import { commonSetup } from '../supports.js';

const LOCAL_DENOM = `ibc/${denomHash({
denom: 'uusdc',
Expand Down

0 comments on commit 2916c8f

Please sign in to comment.