@agoric/orchestration 0.1.1-dev-0006934.0 → 0.1.1-dev-12ce494.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/package.json +16 -16
- package/src/examples/basic-flows.contract.d.ts +11 -0
- package/src/examples/basic-flows.contract.d.ts.map +1 -0
- package/src/examples/basic-flows.contract.js +72 -0
- package/src/examples/sendAnywhere.contract.d.ts +20 -1
- package/src/examples/sendAnywhere.contract.d.ts.map +1 -1
- package/src/examples/sendAnywhere.contract.js +25 -67
- package/src/examples/sendAnywhereFlows.d.ts +24 -0
- package/src/examples/sendAnywhereFlows.d.ts.map +1 -0
- package/src/examples/sendAnywhereFlows.js +59 -0
- package/src/examples/stakeBld.contract.d.ts +20 -17
- package/src/examples/stakeBld.contract.d.ts.map +1 -1
- package/src/examples/stakeBld.contract.js +4 -12
- package/src/examples/stakeIca.contract.d.ts +9 -9
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/swapExample.contract.js +13 -15
- package/src/exos/cosmos-orchestration-account.d.ts +9 -9
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
- package/src/exos/cosmos-orchestration-account.js +27 -21
- package/src/exos/local-chain-facade.d.ts +71 -5
- package/src/exos/local-chain-facade.d.ts.map +1 -1
- package/src/exos/local-chain-facade.js +26 -2
- package/src/exos/local-orchestration-account.d.ts +27 -4
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +31 -10
- package/src/exos/orchestrator.d.ts +5 -0
- package/src/exos/orchestrator.d.ts.map +1 -1
- package/src/exos/orchestrator.js +8 -0
- package/src/exos/remote-chain-facade.d.ts +66 -19
- package/src/exos/remote-chain-facade.d.ts.map +1 -1
- package/src/exos/remote-chain-facade.js +46 -13
- package/src/facade.d.ts +9 -32
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +59 -72
- package/src/orchestration-api.d.ts +15 -0
- package/src/orchestration-api.d.ts.map +1 -1
- package/src/orchestration-api.ts +18 -6
- package/src/proposals/start-basic-flows.d.ts +40 -0
- package/src/proposals/start-basic-flows.d.ts.map +1 -0
- package/src/proposals/start-basic-flows.js +97 -0
- package/src/proposals/start-stakeAtom.d.ts +9 -9
- package/src/proposals/start-stakeBld.d.ts +20 -17
- package/src/proposals/start-stakeBld.d.ts.map +1 -1
- package/src/proposals/start-stakeOsmo.d.ts +9 -9
- package/src/utils/orchestrationAccount.d.ts +2 -0
- package/src/utils/orchestrationAccount.js +9 -0
- package/src/utils/start-helper.d.ts +48 -2
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +35 -9
- package/src/utils/zoe-tools.d.ts +48 -0
- package/src/utils/zoe-tools.d.ts.map +1 -0
- package/src/utils/zoe-tools.js +64 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/orchestration",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-12ce494.0+12ce494",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@agoric/async-flow": "0.1.1-dev-
|
|
37
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
38
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
39
|
-
"@agoric/internal": "0.3.3-dev-
|
|
40
|
-
"@agoric/network": "0.1.1-dev-
|
|
41
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
42
|
-
"@agoric/store": "0.9.3-dev-
|
|
43
|
-
"@agoric/time": "0.3.3-dev-
|
|
44
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
45
|
-
"@agoric/vats": "0.15.2-dev-
|
|
46
|
-
"@agoric/vow": "0.1.1-dev-
|
|
47
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
48
|
-
"@agoric/zone": "0.2.3-dev-
|
|
36
|
+
"@agoric/async-flow": "0.1.1-dev-12ce494.0+12ce494",
|
|
37
|
+
"@agoric/cosmic-proto": "0.4.1-dev-12ce494.0+12ce494",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-12ce494.0+12ce494",
|
|
39
|
+
"@agoric/internal": "0.3.3-dev-12ce494.0+12ce494",
|
|
40
|
+
"@agoric/network": "0.1.1-dev-12ce494.0+12ce494",
|
|
41
|
+
"@agoric/notifier": "0.6.3-dev-12ce494.0+12ce494",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-12ce494.0+12ce494",
|
|
43
|
+
"@agoric/time": "0.3.3-dev-12ce494.0+12ce494",
|
|
44
|
+
"@agoric/vat-data": "0.5.3-dev-12ce494.0+12ce494",
|
|
45
|
+
"@agoric/vats": "0.15.2-dev-12ce494.0+12ce494",
|
|
46
|
+
"@agoric/vow": "0.1.1-dev-12ce494.0+12ce494",
|
|
47
|
+
"@agoric/zoe": "0.26.3-dev-12ce494.0+12ce494",
|
|
48
|
+
"@agoric/zone": "0.2.3-dev-12ce494.0+12ce494",
|
|
49
49
|
"@endo/base64": "^1.0.5",
|
|
50
50
|
"@endo/errors": "^1.2.2",
|
|
51
51
|
"@endo/far": "^1.1.2",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@endo/patterns": "^1.4.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
56
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-12ce494.0+12ce494",
|
|
57
57
|
"@chain-registry/client": "^1.47.4",
|
|
58
58
|
"@cosmjs/amino": "^0.32.3",
|
|
59
59
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"typeCoverage": {
|
|
92
92
|
"atLeast": 97.1
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "12ce49423c9afe6eb2396e7cac79b7f2f003cbb0"
|
|
95
95
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function start(zcf: ZCF, privateArgs: OrchestrationPowers & {
|
|
2
|
+
marshaller: Marshaller;
|
|
3
|
+
}, baggage: Baggage): Promise<{
|
|
4
|
+
publicFacet: import("@endo/exo").Guarded<{
|
|
5
|
+
makeOrchAccountInvitation(): Promise<Invitation<unknown, never>>;
|
|
6
|
+
}>;
|
|
7
|
+
}>;
|
|
8
|
+
export type BasicFlowsSF = typeof start;
|
|
9
|
+
import type { OrchestrationPowers } from '../utils/start-helper.js';
|
|
10
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
11
|
+
//# sourceMappingURL=basic-flows.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-flows.contract.d.ts","sourceRoot":"","sources":["basic-flows.contract.js"],"names":[],"mappings":"AAsCO,2BANI,GAAG,eACH,mBAAmB,GAAG;IAChC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;GAiCjB;2BAEa,OAAO,KAAK;yCA5DY,0BAA0B;6BAFtC,kBAAkB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Primarily a testing fixture, but also serves as an example of how to
|
|
3
|
+
* leverage basic functionality of the Orchestration API with async-flow.
|
|
4
|
+
*/
|
|
5
|
+
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
6
|
+
import { M, mustMatch } from '@endo/patterns';
|
|
7
|
+
import { provideOrchestration } from '../utils/start-helper.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
11
|
+
* @import {Orchestrator} from '@agoric/orchestration';
|
|
12
|
+
* @import {OrchestrationPowers} from '../utils/start-helper.js';
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create an account on a Cosmos chain and return a continuing offer with
|
|
17
|
+
* invitations makers for Delegate, WithdrawRewards, Transfer, etc.
|
|
18
|
+
*
|
|
19
|
+
* @param {Orchestrator} orch
|
|
20
|
+
* @param {undefined} _ctx
|
|
21
|
+
* @param {ZCFSeat} seat
|
|
22
|
+
* @param {{ chainName: string }} offerArgs
|
|
23
|
+
*/
|
|
24
|
+
const makeOrchAccountHandler = async (orch, _ctx, seat, { chainName }) => {
|
|
25
|
+
seat.exit(); // no funds exchanged
|
|
26
|
+
mustMatch(chainName, M.string());
|
|
27
|
+
const remoteChain = await orch.getChain(chainName);
|
|
28
|
+
const cosmosAccount = await remoteChain.makeAccount();
|
|
29
|
+
return cosmosAccount.asContinuingOffer();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {ZCF} zcf
|
|
34
|
+
* @param {OrchestrationPowers & {
|
|
35
|
+
* marshaller: Marshaller;
|
|
36
|
+
* }} privateArgs
|
|
37
|
+
* @param {Baggage} baggage
|
|
38
|
+
*/
|
|
39
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
40
|
+
const { orchestrate, zone } = provideOrchestration(
|
|
41
|
+
zcf,
|
|
42
|
+
baggage,
|
|
43
|
+
privateArgs,
|
|
44
|
+
privateArgs.marshaller,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
/** @type {OfferHandler} */
|
|
48
|
+
const makeOrchAccount = orchestrate(
|
|
49
|
+
'makeOrchAccount',
|
|
50
|
+
undefined,
|
|
51
|
+
makeOrchAccountHandler,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const publicFacet = zone.exo(
|
|
55
|
+
'Basic Flows Public Facet',
|
|
56
|
+
M.interface('Basic Flows PF', {
|
|
57
|
+
makeOrchAccountInvitation: M.callWhen().returns(InvitationShape),
|
|
58
|
+
}),
|
|
59
|
+
{
|
|
60
|
+
makeOrchAccountInvitation() {
|
|
61
|
+
return zcf.makeInvitation(
|
|
62
|
+
makeOrchAccount,
|
|
63
|
+
'Make an Orchestration Account',
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return { publicFacet };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** @typedef {typeof start} BasicFlowsSF */
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {TimerService} from '@agoric/time';
|
|
3
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
4
|
+
* @import {NameHub} from '@agoric/vats';
|
|
5
|
+
* @import {Remote} from '@agoric/vow';
|
|
6
|
+
* @import {Zone} from '@agoric/zone';
|
|
7
|
+
* @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
|
|
8
|
+
* @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
|
|
9
|
+
* @import {OrchestrationTools} from '../utils/start-helper.js';
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {{
|
|
13
|
+
* localchain: Remote<LocalChain>;
|
|
14
|
+
* orchestrationService: Remote<CosmosInterchainService>;
|
|
15
|
+
* storageNode: Remote<StorageNode>;
|
|
16
|
+
* timerService: Remote<TimerService>;
|
|
17
|
+
* agoricNames: Remote<NameHub>;
|
|
18
|
+
* }} OrchestrationPowers
|
|
19
|
+
*/
|
|
1
20
|
export const SingleAmountRecord: import("@endo/patterns").Matcher;
|
|
2
21
|
export const start: (zcf: ZCF<Record<string, unknown>>, privateArgs: OrchestrationPowers & {
|
|
3
22
|
marshaller: Marshaller;
|
|
4
23
|
}, baggage: import("@agoric/vat-data").Baggage) => Promise<{
|
|
5
24
|
publicFacet: import("@endo/exo").Guarded<{
|
|
6
|
-
makeSendInvitation(): Promise<Invitation<
|
|
25
|
+
makeSendInvitation(): Promise<Invitation<any, any>>;
|
|
7
26
|
}>;
|
|
8
27
|
creatorFacet: import("@endo/exo").Guarded<{
|
|
9
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AAEH,kEAKE;AAkGF;gBA3FiB,UAAU;;;;;;QAkErB;;;WAGG;;;;;;;;4BADQ,iBAAiB;;GAuBe;kCAhHpC;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC1D,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;uCAZiD,eAAe;gCAJvC,gCAAgC;4BAEpC,aAAa;6CAGI,sCAAsC;kCANjD,cAAc;6BAEnB,cAAc"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { makeStateRecord } from '@agoric/async-flow';
|
|
2
2
|
import { AmountShape } from '@agoric/ertp';
|
|
3
3
|
import { heapVowE } from '@agoric/vow/vat.js';
|
|
4
|
-
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
|
|
5
4
|
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
5
|
+
import { Fail } from '@endo/errors';
|
|
6
6
|
import { E } from '@endo/far';
|
|
7
|
-
import { M
|
|
8
|
-
import { makeResumableAgoricNamesHack } from '../exos/agoric-names-tools.js';
|
|
7
|
+
import { M } from '@endo/patterns';
|
|
9
8
|
import { CosmosChainInfoShape } from '../typeGuards.js';
|
|
10
9
|
import { withOrchestration } from '../utils/start-helper.js';
|
|
11
|
-
|
|
12
|
-
const { entries } = Object;
|
|
10
|
+
import { orchestrationFns } from './sendAnywhereFlows.js';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* @import {TimerService} from '@agoric/time';
|
|
@@ -19,9 +17,7 @@ const { entries } = Object;
|
|
|
19
17
|
* @import {Zone} from '@agoric/zone';
|
|
20
18
|
* @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
|
|
21
19
|
* @import {CosmosInterchainService} from '../exos/cosmos-interchain-service.js';
|
|
22
|
-
* @import {Orchestrator} from '../types.js'
|
|
23
20
|
* @import {OrchestrationTools} from '../utils/start-helper.js';
|
|
24
|
-
* @import {OrchestrationAccount} from '../orchestration-api.js'
|
|
25
21
|
*/
|
|
26
22
|
|
|
27
23
|
/**
|
|
@@ -34,54 +30,6 @@ const { entries } = Object;
|
|
|
34
30
|
* }} OrchestrationPowers
|
|
35
31
|
*/
|
|
36
32
|
|
|
37
|
-
/**
|
|
38
|
-
* @param {Orchestrator} orch
|
|
39
|
-
* @param {object} ctx
|
|
40
|
-
* @param {ZCF} ctx.zcf
|
|
41
|
-
* @param {any} ctx.agoricNamesTools TODO Give this a better type
|
|
42
|
-
* @param {{ account: OrchestrationAccount<any> | undefined }} ctx.contractState
|
|
43
|
-
* @param {ZCFSeat} seat
|
|
44
|
-
* @param {object} offerArgs
|
|
45
|
-
* @param {string} offerArgs.chainName
|
|
46
|
-
* @param {string} offerArgs.destAddr
|
|
47
|
-
*/
|
|
48
|
-
const sendItFn = async (
|
|
49
|
-
orch,
|
|
50
|
-
{ zcf, agoricNamesTools, contractState },
|
|
51
|
-
seat,
|
|
52
|
-
offerArgs,
|
|
53
|
-
) => {
|
|
54
|
-
mustMatch(offerArgs, harden({ chainName: M.scalar(), destAddr: M.string() }));
|
|
55
|
-
const { chainName, destAddr } = offerArgs;
|
|
56
|
-
const { give } = seat.getProposal();
|
|
57
|
-
const [[kw, amt]] = entries(give);
|
|
58
|
-
const { denom } = await agoricNamesTools.findBrandInVBank(amt.brand);
|
|
59
|
-
const chain = await orch.getChain(chainName);
|
|
60
|
-
|
|
61
|
-
if (!contractState.account) {
|
|
62
|
-
const agoricChain = await orch.getChain('agoric');
|
|
63
|
-
contractState.account = await agoricChain.makeAccount();
|
|
64
|
-
console.log('contractState.account', contractState.account);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const info = await chain.getChainInfo();
|
|
68
|
-
console.log('info', info);
|
|
69
|
-
const { chainId } = info;
|
|
70
|
-
assert(typeof chainId === 'string', 'bad chainId');
|
|
71
|
-
const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
|
|
72
|
-
// #9212 types for chain account helpers
|
|
73
|
-
// @ts-expect-error LCA should have .deposit() method
|
|
74
|
-
await E.when(pmtP, pmt => contractState.account?.deposit(pmt));
|
|
75
|
-
await contractState.account?.transfer(
|
|
76
|
-
{ denom, value: amt.value },
|
|
77
|
-
{
|
|
78
|
-
value: destAddr,
|
|
79
|
-
encoding: 'bech32',
|
|
80
|
-
chainId,
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
33
|
export const SingleAmountRecord = M.and(
|
|
86
34
|
M.recordOf(M.string(), AmountShape, {
|
|
87
35
|
numPropertiesLimit: 1,
|
|
@@ -103,26 +51,36 @@ const contract = async (
|
|
|
103
51
|
zcf,
|
|
104
52
|
privateArgs,
|
|
105
53
|
zone,
|
|
106
|
-
{ chainHub,
|
|
54
|
+
{ chainHub, orchestrateAll, vowTools, zoeTools },
|
|
107
55
|
) => {
|
|
108
|
-
const agoricNamesTools = makeResumableAgoricNamesHack(zone, {
|
|
109
|
-
agoricNames: privateArgs.agoricNames,
|
|
110
|
-
vowTools,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
56
|
const contractState = makeStateRecord(
|
|
114
57
|
/** @type {{ account: OrchestrationAccount<any> | undefined }} */ {
|
|
115
58
|
account: undefined,
|
|
116
59
|
},
|
|
117
60
|
);
|
|
118
61
|
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
62
|
+
// TODO should be a provided helper
|
|
63
|
+
const findBrandInVBank = vowTools.retriable(
|
|
64
|
+
zone,
|
|
65
|
+
'findBrandInVBank',
|
|
66
|
+
/** @param {Brand} brand */
|
|
67
|
+
async brand => {
|
|
68
|
+
const { agoricNames } = privateArgs;
|
|
69
|
+
const assets = await E(E(agoricNames).lookup('vbankAsset')).values();
|
|
70
|
+
const it = assets.find(a => a.brand === brand);
|
|
71
|
+
it || Fail`brand ${brand} not in agoricNames.vbankAsset`;
|
|
72
|
+
return it;
|
|
73
|
+
},
|
|
124
74
|
);
|
|
125
75
|
|
|
76
|
+
// orchestrate uses the names on orchestrationFns to do a "prepare" of the associated behavior
|
|
77
|
+
const orchFns = orchestrateAll(orchestrationFns, {
|
|
78
|
+
zcf,
|
|
79
|
+
contractState,
|
|
80
|
+
localTransfer: zoeTools.localTransfer,
|
|
81
|
+
findBrandInVBank,
|
|
82
|
+
});
|
|
83
|
+
|
|
126
84
|
const publicFacet = zone.exo(
|
|
127
85
|
'Send PF',
|
|
128
86
|
M.interface('Send PF', {
|
|
@@ -131,7 +89,7 @@ const contract = async (
|
|
|
131
89
|
{
|
|
132
90
|
makeSendInvitation() {
|
|
133
91
|
return zcf.makeInvitation(
|
|
134
|
-
sendIt,
|
|
92
|
+
orchFns.sendIt,
|
|
135
93
|
'send',
|
|
136
94
|
undefined,
|
|
137
95
|
M.splitRecord({ give: SingleAmountRecord }),
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export namespace orchestrationFns {
|
|
2
|
+
/**
|
|
3
|
+
* @param {Orchestrator} orch
|
|
4
|
+
* @param {object} ctx
|
|
5
|
+
* @param {{ account: OrchestrationAccount<any> }} ctx.contractState
|
|
6
|
+
* @param {any} ctx.localTransfer
|
|
7
|
+
* @param {any} ctx.findBrandInVBank
|
|
8
|
+
* @param {ZCFSeat} seat
|
|
9
|
+
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
10
|
+
*/
|
|
11
|
+
function sendIt(orch: Orchestrator, { contractState, localTransfer, findBrandInVBank }: {
|
|
12
|
+
contractState: {
|
|
13
|
+
account: OrchestrationAccount<any>;
|
|
14
|
+
};
|
|
15
|
+
localTransfer: any;
|
|
16
|
+
findBrandInVBank: any;
|
|
17
|
+
}, seat: ZCFSeat, offerArgs: {
|
|
18
|
+
chainName: string;
|
|
19
|
+
destAddr: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
import type { Orchestrator } from '../types.js';
|
|
23
|
+
import type { OrchestrationAccount } from '../types.js';
|
|
24
|
+
//# sourceMappingURL=sendAnywhereFlows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendAnywhereFlows.d.ts","sourceRoot":"","sources":["sendAnywhereFlows.js"],"names":[],"mappings":";IAYE;;;;;;;;OAQG;IACH,sBARW,YAAY,sDAEpB;QAAoD,aAAa,EAAzD;YAAE,OAAO,EAAE,qBAAqB,GAAG,CAAC,CAAA;SAAE;QAC7B,aAAa,EAAtB,GAAG;QACM,gBAAgB,EAAzB,GAAG;KACX,QAAQ,OAAO,aACP;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,iBAsCjD;;kCAtDkD,aAAa;0CAAb,aAAa"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { M, mustMatch } from '@endo/patterns';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import {Orchestrator, OrchestrationAccount} from '../types.js';
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { entries } = Object;
|
|
8
|
+
|
|
9
|
+
// in guest file (the orchestration functions)
|
|
10
|
+
// the second argument is all the endowments provided
|
|
11
|
+
|
|
12
|
+
export const orchestrationFns = harden({
|
|
13
|
+
/**
|
|
14
|
+
* @param {Orchestrator} orch
|
|
15
|
+
* @param {object} ctx
|
|
16
|
+
* @param {{ account: OrchestrationAccount<any> }} ctx.contractState
|
|
17
|
+
* @param {any} ctx.localTransfer
|
|
18
|
+
* @param {any} ctx.findBrandInVBank
|
|
19
|
+
* @param {ZCFSeat} seat
|
|
20
|
+
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
21
|
+
*/
|
|
22
|
+
async sendIt(
|
|
23
|
+
orch,
|
|
24
|
+
{ contractState, localTransfer, findBrandInVBank },
|
|
25
|
+
seat,
|
|
26
|
+
offerArgs,
|
|
27
|
+
) {
|
|
28
|
+
mustMatch(
|
|
29
|
+
offerArgs,
|
|
30
|
+
harden({ chainName: M.scalar(), destAddr: M.string() }),
|
|
31
|
+
);
|
|
32
|
+
const { chainName, destAddr } = offerArgs;
|
|
33
|
+
// NOTE the proposal shape ensures that the `give` is a single asset
|
|
34
|
+
const { give } = seat.getProposal();
|
|
35
|
+
const [[_kw, amt]] = entries(give);
|
|
36
|
+
const { denom } = await findBrandInVBank(amt.brand);
|
|
37
|
+
const chain = await orch.getChain(chainName);
|
|
38
|
+
|
|
39
|
+
if (!contractState.account) {
|
|
40
|
+
const agoricChain = await orch.getChain('agoric');
|
|
41
|
+
contractState.account = await agoricChain.makeAccount();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const info = await chain.getChainInfo();
|
|
45
|
+
const { chainId } = info;
|
|
46
|
+
assert(typeof chainId === 'string', 'bad chainId');
|
|
47
|
+
|
|
48
|
+
await localTransfer(seat, contractState.account, give);
|
|
49
|
+
|
|
50
|
+
await contractState.account.transfer(
|
|
51
|
+
{ denom, value: amt.value },
|
|
52
|
+
{
|
|
53
|
+
value: destAddr,
|
|
54
|
+
encoding: 'bech32',
|
|
55
|
+
chainId,
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -9,12 +9,12 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
9
9
|
/**
|
|
10
10
|
* Invitation to make an account, initialized with the give's BLD
|
|
11
11
|
*/
|
|
12
|
-
makeStakeBldInvitation(): Promise<Invitation<{
|
|
12
|
+
makeStakeBldInvitation(): Promise<Invitation<import("@agoric/vow").Vow<{
|
|
13
13
|
publicSubscribers: {
|
|
14
14
|
account: {
|
|
15
15
|
description: string;
|
|
16
16
|
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
17
|
-
storagePath:
|
|
17
|
+
storagePath: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
@@ -22,16 +22,17 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
22
22
|
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/time").TimestampRecord>, undefined>>;
|
|
23
23
|
CloseAccount(): never;
|
|
24
24
|
}>;
|
|
25
|
-
|
|
25
|
+
holder: import("@endo/exo").Guarded<{
|
|
26
|
+
asContinuingOffer(): import("@agoric/vow").Vow<any>;
|
|
26
27
|
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
27
28
|
getBalances(): import("@agoric/vow").Vow<never>;
|
|
28
|
-
getPublicTopics(): {
|
|
29
|
+
getPublicTopics(): import("@agoric/vow").Vow<{
|
|
29
30
|
account: {
|
|
30
31
|
description: string;
|
|
31
32
|
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
32
|
-
storagePath:
|
|
33
|
+
storagePath: string;
|
|
33
34
|
};
|
|
34
|
-
}
|
|
35
|
+
}>;
|
|
35
36
|
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
|
|
36
37
|
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
|
|
37
38
|
deposit(payment: globalThis.Payment<"nat">, optAmountShape?: globalThis.Pattern): import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount>>;
|
|
@@ -46,17 +47,18 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
46
47
|
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
48
|
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void>;
|
|
48
49
|
}>;
|
|
49
|
-
}
|
|
50
|
+
}>, undefined>>;
|
|
50
51
|
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
52
|
+
asContinuingOffer(): import("@agoric/vow").Vow<any>;
|
|
51
53
|
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
52
54
|
getBalances(): import("@agoric/vow").Vow<never>;
|
|
53
|
-
getPublicTopics(): {
|
|
55
|
+
getPublicTopics(): import("@agoric/vow").Vow<{
|
|
54
56
|
account: {
|
|
55
57
|
description: string;
|
|
56
58
|
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
57
|
-
storagePath:
|
|
59
|
+
storagePath: string;
|
|
58
60
|
};
|
|
59
|
-
}
|
|
61
|
+
}>;
|
|
60
62
|
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
|
|
61
63
|
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
|
|
62
64
|
deposit(payment: globalThis.Payment<"nat">, optAmountShape?: globalThis.Pattern): import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount>>;
|
|
@@ -74,12 +76,12 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
74
76
|
/**
|
|
75
77
|
* Invitation to make an account, without any funds
|
|
76
78
|
*/
|
|
77
|
-
makeAccountInvitationMaker(): Promise<Invitation<{
|
|
79
|
+
makeAccountInvitationMaker(): Promise<Invitation<import("@agoric/vow").Vow<{
|
|
78
80
|
publicSubscribers: {
|
|
79
81
|
account: {
|
|
80
82
|
description: string;
|
|
81
83
|
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
82
|
-
storagePath:
|
|
84
|
+
storagePath: string;
|
|
83
85
|
};
|
|
84
86
|
};
|
|
85
87
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
@@ -87,16 +89,17 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
87
89
|
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/time").TimestampRecord>, undefined>>;
|
|
88
90
|
CloseAccount(): never;
|
|
89
91
|
}>;
|
|
90
|
-
|
|
92
|
+
holder: import("@endo/exo").Guarded<{
|
|
93
|
+
asContinuingOffer(): import("@agoric/vow").Vow<any>;
|
|
91
94
|
getBalance(denom: import("../orchestration-api.js").DenomArg): import("@agoric/vow").Vow<import("../orchestration-api.js").DenomAmount>;
|
|
92
95
|
getBalances(): import("@agoric/vow").Vow<never>;
|
|
93
|
-
getPublicTopics(): {
|
|
96
|
+
getPublicTopics(): import("@agoric/vow").Vow<{
|
|
94
97
|
account: {
|
|
95
98
|
description: string;
|
|
96
99
|
subscriber: globalThis.Subscriber<import("../exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
97
|
-
storagePath:
|
|
100
|
+
storagePath: string;
|
|
98
101
|
};
|
|
99
|
-
}
|
|
102
|
+
}>;
|
|
100
103
|
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<Record<unknown, unknown>>;
|
|
101
104
|
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): import("@agoric/vow").Vow<void | import("@agoric/time").TimestampRecord>;
|
|
102
105
|
deposit(payment: globalThis.Payment<"nat">, optAmountShape?: globalThis.Pattern): import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/vow").Vow<import("@agoric/ertp/src/types.js").NatAmount>>;
|
|
@@ -111,7 +114,7 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
111
114
|
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
115
|
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void>;
|
|
113
116
|
}>;
|
|
114
|
-
}
|
|
117
|
+
}>, undefined>>;
|
|
115
118
|
}>;
|
|
116
119
|
}>;
|
|
117
120
|
import type { NameHub } from '@agoric/vats';
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0BH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAaR;6BA7GyB,cAAc;4BACf,kBAAkB;gCAEd,gCAAgC;kCAD9B,cAAc"}
|
|
@@ -87,17 +87,13 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
87
87
|
async seat => {
|
|
88
88
|
const { give } = seat.getProposal();
|
|
89
89
|
trace('makeStakeBldInvitation', give);
|
|
90
|
-
const { holder
|
|
90
|
+
const { holder } = await makeLocalAccountKit();
|
|
91
91
|
const { In } = await deeplyFulfilled(
|
|
92
92
|
withdrawFromSeat(zcf, seat, give),
|
|
93
93
|
);
|
|
94
94
|
await E(holder).deposit(In);
|
|
95
95
|
seat.exit();
|
|
96
|
-
return
|
|
97
|
-
publicSubscribers: holder.getPublicTopics(),
|
|
98
|
-
invitationMakers,
|
|
99
|
-
account: holder,
|
|
100
|
-
});
|
|
96
|
+
return holder.asContinuingOffer();
|
|
101
97
|
},
|
|
102
98
|
'wantStake',
|
|
103
99
|
undefined,
|
|
@@ -118,12 +114,8 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
118
114
|
trace('makeCreateAccountInvitation');
|
|
119
115
|
return zcf.makeInvitation(async seat => {
|
|
120
116
|
seat.exit();
|
|
121
|
-
const { holder
|
|
122
|
-
return
|
|
123
|
-
publicSubscribers: holder.getPublicTopics(),
|
|
124
|
-
invitationMakers,
|
|
125
|
-
account: holder,
|
|
126
|
-
});
|
|
117
|
+
const { holder } = await makeLocalAccountKit();
|
|
118
|
+
return holder.asContinuingOffer();
|
|
127
119
|
}, 'wantLocalChainAccount');
|
|
128
120
|
},
|
|
129
121
|
},
|
|
@@ -20,12 +20,12 @@ export function start(zcf: ZCF<StakeIcaTerms>, privateArgs: {
|
|
|
20
20
|
}, baggage: Baggage): Promise<{
|
|
21
21
|
publicFacet: import("@endo/exo").Guarded<{
|
|
22
22
|
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
23
|
-
asContinuingOffer(): {
|
|
23
|
+
asContinuingOffer(): import("@agoric/vow").Vow<{
|
|
24
24
|
publicSubscribers: {
|
|
25
25
|
account: {
|
|
26
26
|
description: string;
|
|
27
27
|
subscriber: globalThis.Subscriber<import("../exos/cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
28
|
-
storagePath:
|
|
28
|
+
storagePath: string;
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
@@ -37,14 +37,14 @@ export function start(zcf: ZCF<StakeIcaTerms>, privateArgs: {
|
|
|
37
37
|
TransferAccount(): never;
|
|
38
38
|
}>;
|
|
39
39
|
holder: import("@endo/exo").Guarded<any>;
|
|
40
|
-
}
|
|
41
|
-
getPublicTopics(): {
|
|
40
|
+
}>;
|
|
41
|
+
getPublicTopics(): import("@agoric/vow").Vow<{
|
|
42
42
|
account: {
|
|
43
43
|
description: string;
|
|
44
44
|
subscriber: globalThis.Subscriber<import("../exos/cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
45
|
-
storagePath:
|
|
45
|
+
storagePath: string;
|
|
46
46
|
};
|
|
47
|
-
}
|
|
47
|
+
}>;
|
|
48
48
|
getAddress(): import("../orchestration-api.js").ChainAddress;
|
|
49
49
|
delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): import("@agoric/vow").Vow<undefined>;
|
|
50
50
|
getBalances(): import("@agoric/vow").Vow<never>;
|
|
@@ -57,12 +57,12 @@ export function start(zcf: ZCF<StakeIcaTerms>, privateArgs: {
|
|
|
57
57
|
withdrawRewards(): import("@agoric/vow").Vow<never>;
|
|
58
58
|
undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): import("@agoric/vow").Vow<undefined>;
|
|
59
59
|
}>>;
|
|
60
|
-
makeAccountInvitationMaker(): Promise<Invitation<{
|
|
60
|
+
makeAccountInvitationMaker(): Promise<Invitation<import("@agoric/vow").Vow<{
|
|
61
61
|
publicSubscribers: {
|
|
62
62
|
account: {
|
|
63
63
|
description: string;
|
|
64
64
|
subscriber: globalThis.Subscriber<import("../exos/cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
65
|
-
storagePath:
|
|
65
|
+
storagePath: string;
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
@@ -74,7 +74,7 @@ export function start(zcf: ZCF<StakeIcaTerms>, privateArgs: {
|
|
|
74
74
|
TransferAccount(): never;
|
|
75
75
|
}>;
|
|
76
76
|
holder: import("@endo/exo").Guarded<any>;
|
|
77
|
-
}
|
|
77
|
+
}>, undefined>>;
|
|
78
78
|
}>;
|
|
79
79
|
}>;
|
|
80
80
|
export type StakeIcaTerms = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AA8DA,yCAAyC;AACzC,mBADW,YAAY,CAAC,OAAO,KAAK,CAAC,CAWnC;AASK,0CAHI,KAAK;;;EAIsC;AAmDtD;iBA5CkB,OAAO,OAAO,CAAC;gBAChB,OAAO,UAAU,CAAC;0BACR,OAAO,uBAAuB,CAAC;iBACxC,OAAO,WAAW,CAAC;kBAClB,OAAO,YAAY,CAAC;gBACtB,UAAU;;;;oBAYV,MAAM,CAAC,KAAK,CAAC;uBAAa,sBAAsB;;;GA2BhB;6BA1HvB,cAAc;4BAFf,kBAAkB;gCADd,gCAAgC;6CAEnB,sCAAsC;kCAHjD,cAAc;4CADU,aAAa"}
|