Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion services/ymax-planner/src/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Fail, q } from '@endo/errors';
import type { SigningSmartWalletKit, WalletStore } from '@agoric/client-utils';
import type { OfferSpec } from '@agoric/smart-wallet/src/offers';
import type { TxStatus } from '@aglocal/portfolio-contract/src/resolver/constants.js';
import type { TxId } from '@aglocal/portfolio-contract/src/resolver/types';
import type { ResolverKit } from '@aglocal/portfolio-contract/src/resolver/resolver.exo.js';

type ResolveTxParams = {
signingSmartWalletKit: SigningSmartWalletKit;
Expand All @@ -26,7 +28,7 @@ const getInvitationMakers = async (wallet: SigningSmartWalletKit) => {
};
};

export const resolvePendingTx = async ({
export const resolvePendingTxByInvitation = async ({
signingSmartWalletKit,
txId,
status,
Expand All @@ -53,3 +55,24 @@ export const resolvePendingTx = async ({
// An offer error will result in a throw
await signingSmartWalletKit.executeOffer(action);
};

export const resolvePendingTxByInvocation = async ({
walletStore,
txId,
status,
proposal,
}: ResolveTxParams) => {
!proposal || Fail`Unexpected proposal ${q(proposal)}`;

const offerArgs = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offerArgs seems like an odd name. There's no offer. might as well inline this record.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the type is still TransactionSettlementOfferArgs for this, which is awkward, but I didn't change that part of the "code".

Happy to rename.

status,
txId,
};

const resolver = walletStore.get<ResolverKit['service']>('resolver');

// An invocation error will result in a throw
await resolver.settleTransaction(offerArgs);
};

export const resolvePendingTx = resolvePendingTxByInvitation;
Loading