Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify ExtraInvitationMaker #10044

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* actions with an ICA account.
*/
import { AmountShape } from '@agoric/ertp';
import { VowShape } from '@agoric/vow';
import { M } from '@endo/patterns';
import { prepareCombineInvitationMakers } from '../exos/combine-invitation-makers.js';
import { CosmosOrchestrationInvitationMakersInterface } from '../exos/cosmos-orchestration-account.js';
Expand Down Expand Up @@ -50,15 +49,10 @@ const emptyOfferShape = harden({
* @param {Zone} zone
* @param {OrchestrationTools} tools
*/
const contract = async (
zcf,
privateArgs,
zone,
{ orchestrateAll, vowTools },
) => {
const contract = async (zcf, privateArgs, zone, { orchestrateAll }) => {
const ExtraInvitationMakerInterface = M.interface('', {
DepositAndDelegate: M.call(M.array()).returns(VowShape),
UndelegateAndTransfer: M.call(M.array()).returns(VowShape),
DepositAndDelegate: M.call(M.array()).returns(M.promise()),
UndelegateAndTransfer: M.call(M.array()).returns(M.promise()),
});
/** @type {any} XXX async membrane */
const makeExtraInvitationMaker = zone.exoClass(
Expand All @@ -72,7 +66,7 @@ const contract = async (
DepositAndDelegate() {
const { account } = this.state;

const invP = zcf.makeInvitation(
return zcf.makeInvitation(
(seat, validatorAddr, amountArg) =>
// eslint-disable-next-line no-use-before-define -- defined by orchestrateAll, necessarily after this
orchFns.depositAndDelegate(account, seat, validatorAddr, amountArg),
Expand All @@ -84,24 +78,20 @@ const contract = async (
},
},
);

return vowTools.watch(invP);
},
/**
* @param {Omit<Delegation, 'delegatorAddress'>[]} delegations
*/
UndelegateAndTransfer(delegations) {
const { account } = this.state;

const invP = zcf.makeInvitation(
return zcf.makeInvitation(
// eslint-disable-next-line no-use-before-define -- defined by orchestrateAll, necessarily after this
() => orchFns.undelegateAndTransfer(account, delegations),
'Undelegate and transfer',
undefined,
emptyOfferShape,
);

return vowTools.watch(invP);
},
},
);
Expand Down
Loading