Skip to content

Commit

Permalink
feat(chain-account-kit): use asVow helper
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Jun 24, 2024
1 parent d406d0d commit f072fcd
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions packages/orchestration/src/exos/chain-account-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ChainAccountI = M.interface('ChainAccount', {
* @param {Zone} zone
* @param {VowTools} vowTools
*/
export const prepareChainAccountKit = (zone, { watch }) =>
export const prepareChainAccountKit = (zone, { watch, asVow }) =>
zone.exoClassKit(
'ChainAccountKit',
{
Expand Down Expand Up @@ -138,25 +138,29 @@ export const prepareChainAccountKit = (zone, { watch }) =>
* @throws {Error} if packet fails to send or an error is returned
*/
executeEncodedTx(msgs, opts) {
const { connection } = this.state;
// TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
/// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
if (!connection) throw Fail`connection not available`;
return watch(
E(connection).send(makeTxPacket(msgs, opts)),
this.facets.parseTxPacketWatcher,
);
return asVow(() => {
const { connection } = this.state;
// TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
/// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
if (!connection) throw Fail`connection not available`;
return watch(
E(connection).send(makeTxPacket(msgs, opts)),
this.facets.parseTxPacketWatcher,
);
});
},
/** Close the remote account */
close() {
/// TODO #9192 what should the behavior be here? and `onClose`?
// - retrieve assets?
// - revoke the port?
const { connection } = this.state;
// TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
/// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
if (!connection) throw Fail`connection not available`;
return watch(E(connection).close());
return asVow(() => {
/// TODO #9192 what should the behavior be here? and `onClose`?
// - retrieve assets?
// - revoke the port?
const { connection } = this.state;
// TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
/// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
if (!connection) throw Fail`connection not available`;
return watch(E(connection).close());
});
},
/**
* get Purse for a brand to .withdraw() a Payment from the account
Expand Down

0 comments on commit f072fcd

Please sign in to comment.