Skip to content

Commit 6bf6362

Browse files
authored
fix: allow unhardened arg to sendBridgeAction (#11992)
_incidental_ ## Description ymax-planner hit an error, ``` Error in main: (Error#2) Error#2: Cannot pass non-frozen objects like { method: 'invokeEntry', message: { targetName: 'planner', method: 'submit', args: [ 0, [Array], 1, 0 ] } } . Use harden() at Object.sendBridgeAction (packages/client-utils/dist/signing-smart-wallet-kit.js:32:56) at startEngine (file:///Users/luqi/github/Agoric/agoric-sdk/services/ymax-planner/src/engine.ts:675:50) at async main (file:///Users/luqi/github/Agoric/agoric-sdk/services/ymax-planner/src/main.ts:99:3) ``` I thought it was caused by #11986 but that `toCapData` call in `sendBridgeAction` wasn't changed. The function always required a hardened `action` param. However I think that's unnecessary and worse ergonomically. The argument is almost always a literal, so the `harden()` is just clutter. This makes the function harden the arg itself. It could copy the arg to a new hardened one to pass to `toCapData` but I think it's reasonable to expect that the caller is okay with the hardening, and in most cases it won't matter at all because it's a literal. ### Security Considerations If the caller doesn't trust `sendBridgeAction` they can opt into hardening before the call. ### Scaling Considerations n/a ### Documentation Considerations none ### Testing Considerations updated tests ### Upgrade Considerations none
2 parents 5af168a + ba3e847 commit 6bf6362

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/client-utils/src/signing-smart-wallet-kit.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export const makeSigningSmartWalletKit = async (
6565
memo: string = '',
6666
signerData?: SignerData,
6767
): Promise<DeliverTxResponse> => {
68+
// The caller should do this but it's more ergonomic to allow an object
69+
// literal, and in that case this hardening does not create an external
70+
// side-effect.
71+
harden(action);
72+
6873
const msgSpend = MsgWalletSpendAction.fromPartial({
6974
owner: toAccAddress(address),
7075
spendAction: JSON.stringify(swk.marshaller.toCapData(action)),

packages/client-utils/test/signing-smart-wallet-kit.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ test('sendBridgeAction handles simple action', async t => {
7676
mnemonic,
7777
);
7878

79-
const actual = await signing.sendBridgeAction(
80-
harden({ method: 'tryExitOffer', offerId: 'bid-1' }),
81-
);
79+
const actual = await signing.sendBridgeAction({
80+
method: 'tryExitOffer',
81+
offerId: 'bid-1',
82+
});
8283
t.deepEqual(actual, { code: 42 });
8384
t.is(calls.length, 1);
8485
t.like(calls[0], {
@@ -117,7 +118,7 @@ test('sendBridgeAction supports fee param', async t => {
117118
amount: [{ denom: 'ubld', amount: '123' }],
118119
};
119120
const actual = await signing.sendBridgeAction(
120-
harden({ method: 'tryExitOffer', offerId: 'bid-1' }),
121+
{ method: 'tryExitOffer', offerId: 'bid-1' },
121122
moar,
122123
);
123124
t.deepEqual(actual, { code: 42 });
@@ -147,7 +148,7 @@ test('sendBridgeAction uses explicit signing when signerData provided', async t
147148
};
148149

149150
const actual = await signing.sendBridgeAction(
150-
harden({ method: 'tryExitOffer', offerId: 'bid-1' }),
151+
{ method: 'tryExitOffer', offerId: 'bid-1' },
151152
undefined, // use default fee
152153
'test memo',
153154
signerData,

0 commit comments

Comments
 (0)