@agoric/orchestration 0.1.1-calypso-dev-84eb287.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +5 -0
- package/index.d.ts +4 -0
- package/index.js +7 -0
- package/package.json +95 -0
- package/src/chain-info.d.ts +2318 -0
- package/src/chain-info.d.ts.map +1 -0
- package/src/chain-info.js +114 -0
- package/src/cosmos-api.d.ts +174 -0
- package/src/cosmos-api.d.ts.map +1 -0
- package/src/cosmos-api.ts +231 -0
- package/src/ethereum-api.d.ts +8 -0
- package/src/ethereum-api.d.ts.map +1 -0
- package/src/ethereum-api.ts +7 -0
- package/src/examples/sendAnywhere.contract.d.ts +31 -0
- package/src/examples/sendAnywhere.contract.d.ts.map +1 -0
- package/src/examples/sendAnywhere.contract.js +171 -0
- package/src/examples/stakeBld.contract.d.ts +121 -0
- package/src/examples/stakeBld.contract.d.ts.map +1 -0
- package/src/examples/stakeBld.contract.js +133 -0
- package/src/examples/stakeIca.contract.d.ts +93 -0
- package/src/examples/stakeIca.contract.d.ts.map +1 -0
- package/src/examples/stakeIca.contract.js +143 -0
- package/src/examples/swapExample.contract.d.ts +34 -0
- package/src/examples/swapExample.contract.d.ts.map +1 -0
- package/src/examples/swapExample.contract.js +155 -0
- package/src/examples/unbondExample.contract.d.ts +21 -0
- package/src/examples/unbondExample.contract.d.ts.map +1 -0
- package/src/examples/unbondExample.contract.js +105 -0
- package/src/exos/README.md +56 -0
- package/src/exos/agoric-names-tools.d.ts +27 -0
- package/src/exos/agoric-names-tools.d.ts.map +1 -0
- package/src/exos/agoric-names-tools.js +109 -0
- package/src/exos/chain-account-kit.d.ts +88 -0
- package/src/exos/chain-account-kit.d.ts.map +1 -0
- package/src/exos/chain-account-kit.js +210 -0
- package/src/exos/chain-hub.d.ts +77 -0
- package/src/exos/chain-hub.d.ts.map +1 -0
- package/src/exos/chain-hub.js +214 -0
- package/src/exos/cosmos-orchestration-account.d.ts +207 -0
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -0
- package/src/exos/cosmos-orchestration-account.js +536 -0
- package/src/exos/icq-connection-kit.d.ts +50 -0
- package/src/exos/icq-connection-kit.d.ts.map +1 -0
- package/src/exos/icq-connection-kit.js +135 -0
- package/src/exos/local-chain-facade.d.ts +81 -0
- package/src/exos/local-chain-facade.d.ts.map +1 -0
- package/src/exos/local-chain-facade.js +113 -0
- package/src/exos/local-orchestration-account.d.ts +176 -0
- package/src/exos/local-orchestration-account.d.ts.map +1 -0
- package/src/exos/local-orchestration-account.js +446 -0
- package/src/exos/orchestrator.d.ts +91 -0
- package/src/exos/orchestrator.d.ts.map +1 -0
- package/src/exos/orchestrator.js +141 -0
- package/src/exos/remote-chain-facade.d.ts +144 -0
- package/src/exos/remote-chain-facade.d.ts.map +1 -0
- package/src/exos/remote-chain-facade.js +145 -0
- package/src/facade.d.ts +57 -0
- package/src/facade.d.ts.map +1 -0
- package/src/facade.js +132 -0
- package/src/fetched-chain-info.d.ts +2311 -0
- package/src/fetched-chain-info.d.ts.map +1 -0
- package/src/fetched-chain-info.js +2288 -0
- package/src/internal.d.ts +13 -0
- package/src/internal.d.ts.map +1 -0
- package/src/internal.ts +20 -0
- package/src/orchestration-api.d.ts +158 -0
- package/src/orchestration-api.d.ts.map +1 -0
- package/src/orchestration-api.ts +201 -0
- package/src/proposals/orchestration-proposal.d.ts +53 -0
- package/src/proposals/orchestration-proposal.d.ts.map +1 -0
- package/src/proposals/orchestration-proposal.js +179 -0
- package/src/proposals/revise-chain-info.d.ts +21 -0
- package/src/proposals/revise-chain-info.d.ts.map +1 -0
- package/src/proposals/revise-chain-info.js +44 -0
- package/src/proposals/start-stakeAtom.d.ts +109 -0
- package/src/proposals/start-stakeAtom.d.ts.map +1 -0
- package/src/proposals/start-stakeAtom.js +105 -0
- package/src/proposals/start-stakeBld.d.ts +154 -0
- package/src/proposals/start-stakeBld.d.ts.map +1 -0
- package/src/proposals/start-stakeBld.js +103 -0
- package/src/proposals/start-stakeOsmo.d.ts +108 -0
- package/src/proposals/start-stakeOsmo.d.ts.map +1 -0
- package/src/proposals/start-stakeOsmo.js +106 -0
- package/src/service.d.ts +97 -0
- package/src/service.d.ts.map +1 -0
- package/src/service.js +259 -0
- package/src/typeGuards.d.ts +55 -0
- package/src/typeGuards.d.ts.map +1 -0
- package/src/typeGuards.js +104 -0
- package/src/types.d.ts +11 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +11 -0
- package/src/utils/address.d.ts +14 -0
- package/src/utils/address.d.ts.map +1 -0
- package/src/utils/address.js +79 -0
- package/src/utils/cosmos.d.ts +9 -0
- package/src/utils/cosmos.d.ts.map +1 -0
- package/src/utils/cosmos.js +36 -0
- package/src/utils/orc.d.ts +17 -0
- package/src/utils/orc.d.ts.map +1 -0
- package/src/utils/orc.js +38 -0
- package/src/utils/orchestrationAccount.d.ts +10 -0
- package/src/utils/orchestrationAccount.d.ts.map +1 -0
- package/src/utils/orchestrationAccount.js +22 -0
- package/src/utils/packet.d.ts +57 -0
- package/src/utils/packet.d.ts.map +1 -0
- package/src/utils/packet.js +112 -0
- package/src/utils/registry.d.ts +13 -0
- package/src/utils/registry.d.ts.map +1 -0
- package/src/utils/registry.js +131 -0
- package/src/utils/start-helper.d.ts +51 -0
- package/src/utils/start-helper.d.ts.map +1 -0
- package/src/utils/start-helper.js +109 -0
- package/src/utils/time.d.ts +31 -0
- package/src/utils/time.d.ts.map +1 -0
- package/src/utils/time.js +63 -0
- package/src/vat-orchestration.d.ts +58 -0
- package/src/vat-orchestration.d.ts.map +1 -0
- package/src/vat-orchestration.js +24 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
|
|
2
|
+
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
3
|
+
import { M, mustMatch } from '@endo/patterns';
|
|
4
|
+
import { E } from '@endo/far';
|
|
5
|
+
import { heapVowE } from '@agoric/vow/vat.js';
|
|
6
|
+
import { makeStateRecord } from '@agoric/async-flow';
|
|
7
|
+
import { AmountShape } from '@agoric/ertp';
|
|
8
|
+
import { CosmosChainInfoShape } from '../typeGuards.js';
|
|
9
|
+
import { provideOrchestration } from '../utils/start-helper.js';
|
|
10
|
+
import { makeResumableAgoricNamesHack } from '../exos/agoric-names-tools.js';
|
|
11
|
+
|
|
12
|
+
const { entries } = Object;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
16
|
+
* @import {TimerService} from '@agoric/time';
|
|
17
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
18
|
+
* @import {NameHub} from '@agoric/vats';
|
|
19
|
+
* @import {Remote} from '@agoric/vow';
|
|
20
|
+
* @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
|
|
21
|
+
* @import {OrchestrationService} from '../service.js';
|
|
22
|
+
* @import {Orchestrator} from '../types.js'
|
|
23
|
+
* @import {OrchestrationAccount} from '../orchestration-api.js'
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {{
|
|
28
|
+
* localchain: Remote<LocalChain>;
|
|
29
|
+
* orchestrationService: Remote<OrchestrationService>;
|
|
30
|
+
* storageNode: Remote<StorageNode>;
|
|
31
|
+
* timerService: Remote<TimerService>;
|
|
32
|
+
* agoricNames: Remote<NameHub>;
|
|
33
|
+
* }} OrchestrationPowers
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {Orchestrator} orch
|
|
38
|
+
* @param {object} ctx
|
|
39
|
+
* @param {ZCF} ctx.zcf
|
|
40
|
+
* @param {any} ctx.agoricNamesTools TODO Give this a better type
|
|
41
|
+
* @param {{ account: OrchestrationAccount<any> }} ctx.contractState
|
|
42
|
+
* @param {ZCFSeat} seat
|
|
43
|
+
* @param {object} offerArgs
|
|
44
|
+
* @param {string} offerArgs.chainName
|
|
45
|
+
* @param {string} offerArgs.destAddr
|
|
46
|
+
*/
|
|
47
|
+
const sendItFn = async (
|
|
48
|
+
orch,
|
|
49
|
+
{ zcf, agoricNamesTools, contractState },
|
|
50
|
+
seat,
|
|
51
|
+
offerArgs,
|
|
52
|
+
) => {
|
|
53
|
+
mustMatch(offerArgs, harden({ chainName: M.scalar(), destAddr: M.string() }));
|
|
54
|
+
const { chainName, destAddr } = offerArgs;
|
|
55
|
+
const { give } = seat.getProposal();
|
|
56
|
+
const [[kw, amt]] = entries(give);
|
|
57
|
+
const { denom } = await agoricNamesTools.findBrandInVBank(amt.brand);
|
|
58
|
+
const chain = await orch.getChain(chainName);
|
|
59
|
+
|
|
60
|
+
if (!contractState.account) {
|
|
61
|
+
const agoricChain = await orch.getChain('agoric');
|
|
62
|
+
contractState.account = await agoricChain.makeAccount();
|
|
63
|
+
console.log('contractState.account', contractState.account);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const info = await chain.getChainInfo();
|
|
67
|
+
console.log('info', info);
|
|
68
|
+
const { chainId } = info;
|
|
69
|
+
assert(typeof chainId === 'string', 'bad chainId');
|
|
70
|
+
const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
|
|
71
|
+
await E.when(pmtP, pmt => contractState.account.deposit(pmt));
|
|
72
|
+
await contractState.account.transfer(
|
|
73
|
+
{ denom, value: amt.value },
|
|
74
|
+
{
|
|
75
|
+
address: destAddr,
|
|
76
|
+
addressEncoding: 'bech32',
|
|
77
|
+
chainId,
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const SingleAmountRecord = M.and(
|
|
83
|
+
M.recordOf(M.string(), AmountShape, {
|
|
84
|
+
numPropertiesLimit: 1,
|
|
85
|
+
}),
|
|
86
|
+
M.not(harden({})),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {ZCF} zcf
|
|
91
|
+
* @param {OrchestrationPowers & {
|
|
92
|
+
* marshaller: Marshaller;
|
|
93
|
+
* }} privateArgs
|
|
94
|
+
* @param {Baggage} baggage
|
|
95
|
+
*/
|
|
96
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
97
|
+
const { chainHub, orchestrate, vowTools, zone } = provideOrchestration(
|
|
98
|
+
zcf,
|
|
99
|
+
baggage,
|
|
100
|
+
privateArgs,
|
|
101
|
+
privateArgs.marshaller,
|
|
102
|
+
);
|
|
103
|
+
const agoricNamesTools = makeResumableAgoricNamesHack(zone, {
|
|
104
|
+
agoricNames: privateArgs.agoricNames,
|
|
105
|
+
vowTools,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const contractState = makeStateRecord(
|
|
109
|
+
/** @type {{ account: OrchestrationAccount<any> | undefined }} */ {
|
|
110
|
+
account: undefined,
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/** @type {OfferHandler} */
|
|
115
|
+
const sendIt = orchestrate(
|
|
116
|
+
'sendIt',
|
|
117
|
+
{ zcf, agoricNamesTools, contractState },
|
|
118
|
+
sendItFn,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const publicFacet = zone.exo(
|
|
122
|
+
'Send PF',
|
|
123
|
+
M.interface('Send PF', {
|
|
124
|
+
makeSendInvitation: M.callWhen().returns(InvitationShape),
|
|
125
|
+
}),
|
|
126
|
+
{
|
|
127
|
+
makeSendInvitation() {
|
|
128
|
+
return zcf.makeInvitation(
|
|
129
|
+
sendIt,
|
|
130
|
+
'send',
|
|
131
|
+
undefined,
|
|
132
|
+
M.splitRecord({ give: SingleAmountRecord }),
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
let nonce = 0n;
|
|
139
|
+
const ConnectionInfoShape = M.record(); // TODO
|
|
140
|
+
const creatorFacet = zone.exo(
|
|
141
|
+
'Send CF',
|
|
142
|
+
M.interface('Send CF', {
|
|
143
|
+
addChain: M.callWhen(CosmosChainInfoShape, ConnectionInfoShape).returns(
|
|
144
|
+
M.scalar(),
|
|
145
|
+
),
|
|
146
|
+
}),
|
|
147
|
+
{
|
|
148
|
+
/**
|
|
149
|
+
* @param {CosmosChainInfo} chainInfo
|
|
150
|
+
* @param {IBCConnectionInfo} connectionInfo
|
|
151
|
+
*/
|
|
152
|
+
async addChain(chainInfo, connectionInfo) {
|
|
153
|
+
const chainKey = `${chainInfo.chainId}-${(nonce += 1n)}`;
|
|
154
|
+
// when() because chainHub methods return vows. If this were inside
|
|
155
|
+
// orchestrate() the membrane would wrap/unwrap automatically.
|
|
156
|
+
const agoricChainInfo = await heapVowE.when(
|
|
157
|
+
chainHub.getChainInfo('agoric'),
|
|
158
|
+
);
|
|
159
|
+
chainHub.registerChain(chainKey, chainInfo);
|
|
160
|
+
chainHub.registerConnection(
|
|
161
|
+
agoricChainInfo.chainId,
|
|
162
|
+
chainInfo.chainId,
|
|
163
|
+
connectionInfo,
|
|
164
|
+
);
|
|
165
|
+
return chainKey;
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return { publicFacet, creatorFacet };
|
|
171
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export function start(zcf: ZCF, privateArgs: {
|
|
2
|
+
agoricNames: Remote<NameHub>;
|
|
3
|
+
localchain: Remote<LocalChain>;
|
|
4
|
+
marshaller: Marshaller;
|
|
5
|
+
storageNode: StorageNode;
|
|
6
|
+
timerService: TimerService;
|
|
7
|
+
}, baggage: import("@agoric/vat-data").Baggage): Promise<{
|
|
8
|
+
publicFacet: import("@endo/exo").Guarded<{
|
|
9
|
+
/**
|
|
10
|
+
* Invitation to make an account, initialized with the give's BLD
|
|
11
|
+
*/
|
|
12
|
+
makeStakeBldInvitation(): Promise<Invitation<{
|
|
13
|
+
publicSubscribers: {
|
|
14
|
+
account: {
|
|
15
|
+
description: string;
|
|
16
|
+
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
17
|
+
storagePath: Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
21
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/vow").Vow<Record<unknown, unknown>>, undefined>>;
|
|
22
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/time").TimestampRecord>, undefined>>;
|
|
23
|
+
CloseAccount(): never;
|
|
24
|
+
}>;
|
|
25
|
+
account: import("@endo/exo").Guarded<{
|
|
26
|
+
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
27
|
+
getBalances(): import("@agoric/vow").Vow<never>;
|
|
28
|
+
getPublicTopics(): {
|
|
29
|
+
account: {
|
|
30
|
+
description: string;
|
|
31
|
+
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
32
|
+
storagePath: Promise<string>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
|
|
36
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
|
|
37
|
+
deposit(payment: globalThis.Payment<"nat">): import("@agoric/vow").Vow<void>;
|
|
38
|
+
withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): import("@agoric/vow").Vow<globalThis.Payment<"nat"> | import("@agoric/vow").Vow<globalThis.Payment<"nat">>>;
|
|
39
|
+
executeTx(messages: {
|
|
40
|
+
'@type': string;
|
|
41
|
+
}[]): import("@agoric/vow").Vow<import("@agoric/cosmic-proto").JsonSafe<{
|
|
42
|
+
'@type': string;
|
|
43
|
+
}>[]>;
|
|
44
|
+
getAddress(): import("../orchestration-api.js").ChainAddress;
|
|
45
|
+
send(toAccount: any, amount: any): import("@agoric/vow").Vow<never>;
|
|
46
|
+
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): import("@agoric/vow").Vow<void>;
|
|
47
|
+
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void>;
|
|
48
|
+
}>;
|
|
49
|
+
}, undefined>>;
|
|
50
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
51
|
+
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
52
|
+
getBalances(): import("@agoric/vow").Vow<never>;
|
|
53
|
+
getPublicTopics(): {
|
|
54
|
+
account: {
|
|
55
|
+
description: string;
|
|
56
|
+
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
57
|
+
storagePath: Promise<string>;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
|
|
61
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
|
|
62
|
+
deposit(payment: globalThis.Payment<"nat">): import("@agoric/vow").Vow<void>;
|
|
63
|
+
withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): import("@agoric/vow").Vow<globalThis.Payment<"nat"> | import("@agoric/vow").Vow<globalThis.Payment<"nat">>>;
|
|
64
|
+
executeTx(messages: {
|
|
65
|
+
'@type': string;
|
|
66
|
+
}[]): import("@agoric/vow").Vow<import("@agoric/cosmic-proto").JsonSafe<{
|
|
67
|
+
'@type': string;
|
|
68
|
+
}>[]>;
|
|
69
|
+
getAddress(): import("../orchestration-api.js").ChainAddress;
|
|
70
|
+
send(toAccount: any, amount: any): import("@agoric/vow").Vow<never>;
|
|
71
|
+
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): import("@agoric/vow").Vow<void>;
|
|
72
|
+
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void>;
|
|
73
|
+
}>>;
|
|
74
|
+
/**
|
|
75
|
+
* Invitation to make an account, without any funds
|
|
76
|
+
*/
|
|
77
|
+
makeAccountInvitationMaker(): Promise<Invitation<{
|
|
78
|
+
publicSubscribers: {
|
|
79
|
+
account: {
|
|
80
|
+
description: string;
|
|
81
|
+
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
82
|
+
storagePath: Promise<string>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
86
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/vow").Vow<Record<unknown, unknown>>, undefined>>;
|
|
87
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/time").TimestampRecord>, undefined>>;
|
|
88
|
+
CloseAccount(): never;
|
|
89
|
+
}>;
|
|
90
|
+
account: import("@endo/exo").Guarded<{
|
|
91
|
+
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
92
|
+
getBalances(): import("@agoric/vow").Vow<never>;
|
|
93
|
+
getPublicTopics(): {
|
|
94
|
+
account: {
|
|
95
|
+
description: string;
|
|
96
|
+
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
97
|
+
storagePath: Promise<string>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
|
|
101
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
|
|
102
|
+
deposit(payment: globalThis.Payment<"nat">): import("@agoric/vow").Vow<void>;
|
|
103
|
+
withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): import("@agoric/vow").Vow<globalThis.Payment<"nat"> | import("@agoric/vow").Vow<globalThis.Payment<"nat">>>;
|
|
104
|
+
executeTx(messages: {
|
|
105
|
+
'@type': string;
|
|
106
|
+
}[]): import("@agoric/vow").Vow<import("@agoric/cosmic-proto").JsonSafe<{
|
|
107
|
+
'@type': string;
|
|
108
|
+
}>[]>;
|
|
109
|
+
getAddress(): import("../orchestration-api.js").ChainAddress;
|
|
110
|
+
send(toAccount: any, amount: any): import("@agoric/vow").Vow<never>;
|
|
111
|
+
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): import("@agoric/vow").Vow<void>;
|
|
112
|
+
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void>;
|
|
113
|
+
}>;
|
|
114
|
+
}, undefined>>;
|
|
115
|
+
}>;
|
|
116
|
+
}>;
|
|
117
|
+
import type { NameHub } from '@agoric/vats';
|
|
118
|
+
import type { Remote } from '@agoric/internal';
|
|
119
|
+
import type { LocalChain } from '@agoric/vats/src/localchain.js';
|
|
120
|
+
import type { TimerService } from '@agoric/time';
|
|
121
|
+
//# sourceMappingURL=stakeBld.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"AAkCO,2BAVI,GAAG,eACH;IACV,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;IACjC,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,UAAc,EAAE,UAAU,CAAC;IAC3B,WAAe,EAAE,WAAW,CAAC;IAC7B,YAAgB,EAAE,YAAY,CAAC;CAC5B,WACO,OAAO,kBAAkB,EAAE,OAAO;;QAiDvC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8BH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBR;6BArHyB,cAAc;4BACf,kBAAkB;gCAEd,gCAAgC;kCAD9B,cAAc"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Stake BLD contract
|
|
3
|
+
*/
|
|
4
|
+
import { makeTracer } from '@agoric/internal';
|
|
5
|
+
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
6
|
+
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
|
|
7
|
+
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
8
|
+
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
9
|
+
import { prepareVowTools, heapVowE as E } from '@agoric/vow/vat.js';
|
|
10
|
+
import { deeplyFulfilled } from '@endo/marshal';
|
|
11
|
+
import { M } from '@endo/patterns';
|
|
12
|
+
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
|
|
13
|
+
import { makeChainHub } from '../exos/chain-hub.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @import {NameHub} from '@agoric/vats';
|
|
17
|
+
* @import {Remote} from '@agoric/internal';
|
|
18
|
+
* @import {TimerService} from '@agoric/time';
|
|
19
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const trace = makeTracer('StakeBld');
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {ZCF} zcf
|
|
26
|
+
* @param {{
|
|
27
|
+
* agoricNames: Remote<NameHub>;
|
|
28
|
+
* localchain: Remote<LocalChain>;
|
|
29
|
+
* marshaller: Marshaller;
|
|
30
|
+
* storageNode: StorageNode;
|
|
31
|
+
* timerService: TimerService;
|
|
32
|
+
* }} privateArgs
|
|
33
|
+
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
34
|
+
*/
|
|
35
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
36
|
+
const zone = makeDurableZone(baggage);
|
|
37
|
+
|
|
38
|
+
const { makeRecorderKit } = prepareRecorderKitMakers(
|
|
39
|
+
baggage,
|
|
40
|
+
privateArgs.marshaller,
|
|
41
|
+
);
|
|
42
|
+
const vowTools = prepareVowTools(zone.subZone('vows'));
|
|
43
|
+
|
|
44
|
+
const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
|
|
45
|
+
zone,
|
|
46
|
+
makeRecorderKit,
|
|
47
|
+
zcf,
|
|
48
|
+
privateArgs.timerService,
|
|
49
|
+
vowTools,
|
|
50
|
+
makeChainHub(privateArgs.agoricNames),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// ----------------
|
|
54
|
+
// All `prepare*` calls should go above this line.
|
|
55
|
+
|
|
56
|
+
const BLD = zcf.getTerms().brands.In;
|
|
57
|
+
const bldAmountShape = await E(BLD).getAmountShape();
|
|
58
|
+
|
|
59
|
+
async function makeLocalAccountKit() {
|
|
60
|
+
const account = await E(privateArgs.localchain).makeAccount();
|
|
61
|
+
const address = await E(account).getAddress();
|
|
62
|
+
// FIXME 'address' is implied by 'account'; use an async maker that get the value itself
|
|
63
|
+
return makeLocalOrchestrationAccountKit({
|
|
64
|
+
account,
|
|
65
|
+
address: harden({
|
|
66
|
+
address,
|
|
67
|
+
addressEncoding: 'bech32',
|
|
68
|
+
chainId: 'local',
|
|
69
|
+
}),
|
|
70
|
+
storageNode: privateArgs.storageNode,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const publicFacet = zone.exo(
|
|
75
|
+
'StakeBld',
|
|
76
|
+
M.interface('StakeBldI', {
|
|
77
|
+
makeAccount: M.callWhen().returns(M.remotable('LocalChainAccountHolder')),
|
|
78
|
+
makeAccountInvitationMaker: M.callWhen().returns(InvitationShape),
|
|
79
|
+
makeStakeBldInvitation: M.callWhen().returns(InvitationShape),
|
|
80
|
+
}),
|
|
81
|
+
{
|
|
82
|
+
/**
|
|
83
|
+
* Invitation to make an account, initialized with the give's BLD
|
|
84
|
+
*/
|
|
85
|
+
makeStakeBldInvitation() {
|
|
86
|
+
return zcf.makeInvitation(
|
|
87
|
+
async seat => {
|
|
88
|
+
const { give } = seat.getProposal();
|
|
89
|
+
trace('makeStakeBldInvitation', give);
|
|
90
|
+
const { holder, invitationMakers } = await makeLocalAccountKit();
|
|
91
|
+
const { In } = await deeplyFulfilled(
|
|
92
|
+
withdrawFromSeat(zcf, seat, give),
|
|
93
|
+
);
|
|
94
|
+
await E(holder).deposit(In);
|
|
95
|
+
seat.exit();
|
|
96
|
+
return harden({
|
|
97
|
+
publicSubscribers: holder.getPublicTopics(),
|
|
98
|
+
invitationMakers,
|
|
99
|
+
account: holder,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
'wantStake',
|
|
103
|
+
undefined,
|
|
104
|
+
M.splitRecord({
|
|
105
|
+
give: { In: bldAmountShape },
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
async makeAccount() {
|
|
110
|
+
trace('makeAccount');
|
|
111
|
+
const { holder } = await makeLocalAccountKit();
|
|
112
|
+
return holder;
|
|
113
|
+
},
|
|
114
|
+
/**
|
|
115
|
+
* Invitation to make an account, without any funds
|
|
116
|
+
*/
|
|
117
|
+
makeAccountInvitationMaker() {
|
|
118
|
+
trace('makeCreateAccountInvitation');
|
|
119
|
+
return zcf.makeInvitation(async seat => {
|
|
120
|
+
seat.exit();
|
|
121
|
+
const { holder, invitationMakers } = await makeLocalAccountKit();
|
|
122
|
+
return harden({
|
|
123
|
+
publicSubscribers: holder.getPublicTopics(),
|
|
124
|
+
invitationMakers,
|
|
125
|
+
account: holder,
|
|
126
|
+
});
|
|
127
|
+
}, 'wantLocalChainAccount');
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return { publicFacet };
|
|
133
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
3
|
+
* @import {IBCConnectionID} from '@agoric/vats';
|
|
4
|
+
* @import {TimerService} from '@agoric/time';
|
|
5
|
+
* @import {ICQConnection, OrchestrationService} from '../types.js';
|
|
6
|
+
*/
|
|
7
|
+
/** @type {ContractMeta<typeof start>} */
|
|
8
|
+
export const meta: ContractMeta<typeof start>;
|
|
9
|
+
export const privateArgsShape: {
|
|
10
|
+
orchestration: globalThis.Pattern;
|
|
11
|
+
storageNode: globalThis.Pattern;
|
|
12
|
+
marshaller: globalThis.Pattern;
|
|
13
|
+
timer: globalThis.Pattern;
|
|
14
|
+
} | undefined;
|
|
15
|
+
export function start(zcf: ZCF<StakeIcaTerms>, privateArgs: {
|
|
16
|
+
orchestration: OrchestrationService;
|
|
17
|
+
storageNode: StorageNode;
|
|
18
|
+
marshaller: Marshaller;
|
|
19
|
+
timer: TimerService;
|
|
20
|
+
}, baggage: Baggage): Promise<{
|
|
21
|
+
publicFacet: import("@endo/exo").Guarded<{
|
|
22
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
23
|
+
asContinuingOffer(): {
|
|
24
|
+
publicSubscribers: {
|
|
25
|
+
account: {
|
|
26
|
+
description: string;
|
|
27
|
+
subscriber: globalThis.Subscriber<import("../exos/cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
28
|
+
storagePath: Promise<string>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
32
|
+
Delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<import("@agoric/vow").Vow<undefined>, undefined>>;
|
|
33
|
+
Redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<import("@agoric/vow").Vow<undefined>, undefined>>;
|
|
34
|
+
WithdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Promise<Invitation<import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount[]>, undefined>>;
|
|
35
|
+
Undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Promise<Invitation<import("@agoric/vow").Vow<undefined>, undefined>>;
|
|
36
|
+
CloseAccount(): never;
|
|
37
|
+
TransferAccount(): never;
|
|
38
|
+
}>;
|
|
39
|
+
holder: import("@endo/exo").Guarded<any>;
|
|
40
|
+
};
|
|
41
|
+
getPublicTopics(): {
|
|
42
|
+
account: {
|
|
43
|
+
description: string;
|
|
44
|
+
subscriber: globalThis.Subscriber<import("../exos/cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
45
|
+
storagePath: Promise<string>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
getAddress(): import("../orchestration-api.js").ChainAddress;
|
|
49
|
+
delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): import("@agoric/vow").Vow<undefined>;
|
|
50
|
+
deposit(payment: any): void;
|
|
51
|
+
getBalances(): import("@agoric/vow").Vow<never>;
|
|
52
|
+
redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): import("@agoric/vow").Vow<undefined>;
|
|
53
|
+
withdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount[]>;
|
|
54
|
+
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
55
|
+
send(toAccount: any, amount: any): import("@agoric/vow").Vow<never>;
|
|
56
|
+
transfer(amount: any, msg: any): import("@agoric/vow").Vow<never>;
|
|
57
|
+
transferSteps(amount: any, msg: any): import("@agoric/vow").Vow<never>;
|
|
58
|
+
withdrawRewards(): import("@agoric/vow").Vow<never>;
|
|
59
|
+
undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): import("@agoric/vow").Vow<undefined>;
|
|
60
|
+
}>>;
|
|
61
|
+
makeAccountInvitationMaker(): Promise<Invitation<{
|
|
62
|
+
publicSubscribers: {
|
|
63
|
+
account: {
|
|
64
|
+
description: string;
|
|
65
|
+
subscriber: globalThis.Subscriber<import("../exos/cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
66
|
+
storagePath: Promise<string>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
70
|
+
Delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<import("@agoric/vow").Vow<undefined>, undefined>>;
|
|
71
|
+
Redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<import("@agoric/vow").Vow<undefined>, undefined>>;
|
|
72
|
+
WithdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Promise<Invitation<import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount[]>, undefined>>;
|
|
73
|
+
Undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Promise<Invitation<import("@agoric/vow").Vow<undefined>, undefined>>;
|
|
74
|
+
CloseAccount(): never;
|
|
75
|
+
TransferAccount(): never;
|
|
76
|
+
}>;
|
|
77
|
+
holder: import("@endo/exo").Guarded<any>;
|
|
78
|
+
}, undefined>>;
|
|
79
|
+
}>;
|
|
80
|
+
}>;
|
|
81
|
+
export type StakeIcaTerms = {
|
|
82
|
+
chainId: string;
|
|
83
|
+
hostConnectionId: IBCConnectionID;
|
|
84
|
+
controllerConnectionId: IBCConnectionID;
|
|
85
|
+
bondDenom: string;
|
|
86
|
+
icqEnabled: boolean;
|
|
87
|
+
};
|
|
88
|
+
export type StakeIcaSF = typeof start;
|
|
89
|
+
import type { OrchestrationService } from '../types.js';
|
|
90
|
+
import type { TimerService } from '@agoric/time';
|
|
91
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
92
|
+
import type { IBCConnectionID } from '@agoric/vats';
|
|
93
|
+
//# sourceMappingURL=stakeIca.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stakeIca.contract.d.ts","sourceRoot":"","sources":["stakeIca.contract.js"],"names":[],"mappings":"AAeA;;;;;GAKG;AAEH,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAelC;AACH;;;;;cAAsD;AAsB/C,2BATI,GAAG,CAAC,aAAa,CAAC,eAClB;IACV,aAAiB,EAAE,oBAAoB,CAAC;IACxC,WAAe,EAAE,WAAW,CAAC;IAC7B,UAAc,EAAE,UAAU,CAAC;IAC3B,KAAS,EAAE,YAAY,CAAC;CACrB,WACO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFjB;4BAnGY;IACZ,OAAW,EAAE,MAAM,CAAC;IACpB,gBAAoB,EAAE,eAAe,CAAC;IACtC,sBAA0B,EAAE,eAAe,CAAC;IAC5C,SAAa,EAAE,MAAM,CAAC;IACtB,UAAc,EAAE,OAAO,CAAC;CACrB;yBA+FU,OAAO,KAAK;0CA3H4B,aAAa;kCADpC,cAAc;6BAFnB,kBAAkB;qCACV,cAAc"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/** @file Example contract that uses orchestration */
|
|
2
|
+
|
|
3
|
+
import { makeTracer, StorageNodeShape } from '@agoric/internal';
|
|
4
|
+
import { TimerServiceShape } from '@agoric/time';
|
|
5
|
+
import { heapVowE as E, prepareVowTools } from '@agoric/vow/vat.js';
|
|
6
|
+
import {
|
|
7
|
+
prepareRecorderKitMakers,
|
|
8
|
+
provideAll,
|
|
9
|
+
} from '@agoric/zoe/src/contractSupport';
|
|
10
|
+
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
11
|
+
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
12
|
+
import { M } from '@endo/patterns';
|
|
13
|
+
import { prepareCosmosOrchestrationAccount } from '../exos/cosmos-orchestration-account.js';
|
|
14
|
+
|
|
15
|
+
const trace = makeTracer('StakeIca');
|
|
16
|
+
/**
|
|
17
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
18
|
+
* @import {IBCConnectionID} from '@agoric/vats';
|
|
19
|
+
* @import {TimerService} from '@agoric/time';
|
|
20
|
+
* @import {ICQConnection, OrchestrationService} from '../types.js';
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** @type {ContractMeta<typeof start>} */
|
|
24
|
+
export const meta = harden({
|
|
25
|
+
customTermsShape: {
|
|
26
|
+
chainId: M.string(),
|
|
27
|
+
hostConnectionId: M.string(),
|
|
28
|
+
controllerConnectionId: M.string(),
|
|
29
|
+
bondDenom: M.string(),
|
|
30
|
+
icqEnabled: M.boolean(),
|
|
31
|
+
},
|
|
32
|
+
privateArgsShape: {
|
|
33
|
+
orchestration: M.remotable('orchestration'),
|
|
34
|
+
storageNode: StorageNodeShape,
|
|
35
|
+
marshaller: M.remotable('marshaller'),
|
|
36
|
+
timer: TimerServiceShape,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export const privateArgsShape = meta.privateArgsShape;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {{
|
|
43
|
+
* chainId: string;
|
|
44
|
+
* hostConnectionId: IBCConnectionID;
|
|
45
|
+
* controllerConnectionId: IBCConnectionID;
|
|
46
|
+
* bondDenom: string;
|
|
47
|
+
* icqEnabled: boolean;
|
|
48
|
+
* }} StakeIcaTerms
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {ZCF<StakeIcaTerms>} zcf
|
|
53
|
+
* @param {{
|
|
54
|
+
* orchestration: OrchestrationService;
|
|
55
|
+
* storageNode: StorageNode;
|
|
56
|
+
* marshaller: Marshaller;
|
|
57
|
+
* timer: TimerService;
|
|
58
|
+
* }} privateArgs
|
|
59
|
+
* @param {Baggage} baggage
|
|
60
|
+
*/
|
|
61
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
62
|
+
const {
|
|
63
|
+
chainId,
|
|
64
|
+
hostConnectionId,
|
|
65
|
+
controllerConnectionId,
|
|
66
|
+
bondDenom,
|
|
67
|
+
icqEnabled,
|
|
68
|
+
} = zcf.getTerms();
|
|
69
|
+
const { orchestration, marshaller, storageNode, timer } = privateArgs;
|
|
70
|
+
|
|
71
|
+
const zone = makeDurableZone(baggage);
|
|
72
|
+
|
|
73
|
+
const { accountsStorageNode } = await provideAll(baggage, {
|
|
74
|
+
accountsStorageNode: () => E(storageNode).makeChildNode('accounts'),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
|
|
78
|
+
|
|
79
|
+
const vowTools = prepareVowTools(zone.subZone('vows'));
|
|
80
|
+
|
|
81
|
+
const makeCosmosOrchestrationAccount = prepareCosmosOrchestrationAccount(
|
|
82
|
+
zone,
|
|
83
|
+
makeRecorderKit,
|
|
84
|
+
vowTools,
|
|
85
|
+
zcf,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
async function makeAccountKit() {
|
|
89
|
+
const account = await E(orchestration).makeAccount(
|
|
90
|
+
chainId,
|
|
91
|
+
hostConnectionId,
|
|
92
|
+
controllerConnectionId,
|
|
93
|
+
);
|
|
94
|
+
// TODO permissionless queries https://github.com/Agoric/agoric-sdk/issues/9326
|
|
95
|
+
const icqConnection = icqEnabled
|
|
96
|
+
? await E(orchestration).provideICQConnection(controllerConnectionId)
|
|
97
|
+
: undefined;
|
|
98
|
+
|
|
99
|
+
const accountAddress = await E(account).getAddress();
|
|
100
|
+
trace('account address', accountAddress);
|
|
101
|
+
const accountNode = await E(accountsStorageNode).makeChildNode(
|
|
102
|
+
accountAddress.address,
|
|
103
|
+
);
|
|
104
|
+
const holder = makeCosmosOrchestrationAccount(accountAddress, bondDenom, {
|
|
105
|
+
account,
|
|
106
|
+
storageNode: accountNode,
|
|
107
|
+
icqConnection,
|
|
108
|
+
timer,
|
|
109
|
+
});
|
|
110
|
+
return holder;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const publicFacet = zone.exo(
|
|
114
|
+
'StakeAtom',
|
|
115
|
+
M.interface('StakeAtomI', {
|
|
116
|
+
makeAccount: M.callWhen().returns(M.remotable('ChainAccount')),
|
|
117
|
+
makeAccountInvitationMaker: M.callWhen().returns(InvitationShape),
|
|
118
|
+
}),
|
|
119
|
+
{
|
|
120
|
+
async makeAccount() {
|
|
121
|
+
trace('makeAccount');
|
|
122
|
+
return makeAccountKit();
|
|
123
|
+
},
|
|
124
|
+
makeAccountInvitationMaker() {
|
|
125
|
+
trace('makeCreateAccountInvitation');
|
|
126
|
+
return zcf.makeInvitation(
|
|
127
|
+
async seat => {
|
|
128
|
+
seat.exit();
|
|
129
|
+
const holder = await makeAccountKit();
|
|
130
|
+
return holder.asContinuingOffer();
|
|
131
|
+
},
|
|
132
|
+
'wantStakingAccount',
|
|
133
|
+
undefined,
|
|
134
|
+
undefined,
|
|
135
|
+
);
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
return { publicFacet };
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** @typedef {typeof start} StakeIcaSF */
|