Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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
17 changes: 12 additions & 5 deletions packages/client-utils/src/signing-smart-wallet-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,21 @@ export const makeSigningSmartWalletKit = async (
return client.broadcastTx(txBytes);
};

const executeOffer = async (offer: OfferSpec): Promise<OfferStatus> => {
const executeOffer = async (
offer: OfferSpec,
fee?: StdFee,
memo?: string,
signerData?: SignerData,
): Promise<OfferStatus> => {
const offerP = swk.pollOffer(address, offer.id);

// Await for rejection handling
await sendBridgeAction({
method: 'executeOffer',
offer,
});
await sendBridgeAction(
{ method: 'executeOffer', offer },
fee,
memo,
signerData,
);

return offerP;
};
Expand Down
8 changes: 7 additions & 1 deletion services/ymax-planner/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type SigningSmartWalletKit } 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 { StdFee } from '@cosmjs/stargate';

type ResolveTxParams = {
signingSmartWalletKit: SigningSmartWalletKit;
Expand All @@ -10,6 +11,11 @@ type ResolveTxParams = {
proposal?: object;
};

const smartWalletFee: StdFee = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

question

Is there a better file to put this constant in so both planner and resolver can use it?

Copy link
Member

Choose a reason for hiding this comment

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

I expect the planner and resolver to become less integrated, not more. So this is fine.

amount: [{ denom: 'ubld', amount: '15000' }], // 0.015 BLD
gas: '19700000',
};

const getInvitationMakers = async (wallet: SigningSmartWalletKit) => {
const getCurrentWalletRecord = await wallet.query.getCurrentWalletRecord();
const invitation = getCurrentWalletRecord.offerToUsedInvitation
Expand Down Expand Up @@ -49,6 +55,6 @@ export const resolvePendingTx = async ({
proposal,
});

const result = await signingSmartWalletKit.executeOffer(action);
const result = await signingSmartWalletKit.executeOffer(action, smartWalletFee);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

question

I only found the place where we're using executeOffer in resolver, but I was not able to find where we're using executeOffer under services/ymax-planner folder

Copy link
Member

Choose a reason for hiding this comment

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

ymax-planner uses invokeEntry, wrapped in reflectWalletStore:

const planner = walletStore.get<PortfolioPlanner>('planner', {
sendOnly: true,
});
const { tx, id } = await planner.resolvePlan(
portfolioId,
flowId,
steps,
policyVersion,
rebalanceCount,
);

The fee could either be passed in to reflectWalletStore:

const walletStore = reflectWalletStore(signingSmartWalletKit, {
setTimeout,
makeNonce: () => new Date(now()).toISOString(),
});

Or another idea would be to add a signingSmartWalletKit.withFee(fee) method, much like cmdRunner.withEnv(...)

withEnv: env =>

Copy link
Member

Choose a reason for hiding this comment

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

@LuqiPan I pushed a couple of commits; f6d30c8 extending wallet store reflection to support specifying a fee and f92e699 taking advantage of it in ymax-planner (but limited the extension to just fee while @dckc and I work out #12055 (comment) ). But feel free to tweak further as needed.

return result;
};
Loading