@agoric/orchestration 0.1.1-dev-6ee57ba.0 → 0.1.1-dev-c04c91c.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/send-anywhere.contract.d.ts +1 -1
- package/src/examples/send-anywhere.contract.d.ts.map +1 -1
- package/src/examples/send-anywhere.contract.js +6 -6
- package/src/examples/send-anywhere.flows.d.ts +3 -3
- package/src/examples/send-anywhere.flows.d.ts.map +1 -1
- package/src/examples/send-anywhere.flows.js +20 -11
- package/src/examples/stakeBld.contract.d.ts.map +1 -1
- package/src/examples/stakeBld.contract.js +3 -0
- package/src/examples/staking-combinations.flows.d.ts.map +1 -1
- package/src/examples/staking-combinations.flows.js +5 -4
- package/src/exos/local-orchestration-account.d.ts +18 -1
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +82 -3
- package/src/proposals/start-stakeBld.d.ts.map +1 -1
- package/src/typeGuards.d.ts +5 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +10 -0
- package/src/utils/start-helper.d.ts +2 -1
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +10 -4
- package/src/utils/zoe-tools.d.ts +5 -8
- package/src/utils/zoe-tools.d.ts.map +1 -1
- package/src/utils/zoe-tools.js +135 -32
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-c04c91c.0+c04c91c",
|
|
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-c04c91c.0+c04c91c",
|
|
37
|
+
"@agoric/cosmic-proto": "0.4.1-dev-c04c91c.0+c04c91c",
|
|
38
|
+
"@agoric/ertp": "0.16.3-dev-c04c91c.0+c04c91c",
|
|
39
|
+
"@agoric/internal": "0.3.3-dev-c04c91c.0+c04c91c",
|
|
40
|
+
"@agoric/network": "0.1.1-dev-c04c91c.0+c04c91c",
|
|
41
|
+
"@agoric/notifier": "0.6.3-dev-c04c91c.0+c04c91c",
|
|
42
|
+
"@agoric/store": "0.9.3-dev-c04c91c.0+c04c91c",
|
|
43
|
+
"@agoric/time": "0.3.3-dev-c04c91c.0+c04c91c",
|
|
44
|
+
"@agoric/vat-data": "0.5.3-dev-c04c91c.0+c04c91c",
|
|
45
|
+
"@agoric/vats": "0.15.2-dev-c04c91c.0+c04c91c",
|
|
46
|
+
"@agoric/vow": "0.1.1-dev-c04c91c.0+c04c91c",
|
|
47
|
+
"@agoric/zoe": "0.26.3-dev-c04c91c.0+c04c91c",
|
|
48
|
+
"@agoric/zone": "0.2.3-dev-c04c91c.0+c04c91c",
|
|
49
49
|
"@endo/base64": "^1.0.7",
|
|
50
50
|
"@endo/errors": "^1.2.5",
|
|
51
51
|
"@endo/far": "^1.1.5",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@noble/hashes": "^1.5.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
57
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-c04c91c.0+c04c91c",
|
|
58
58
|
"@chain-registry/client": "^1.47.4",
|
|
59
59
|
"@cosmjs/amino": "^0.32.3",
|
|
60
60
|
"@cosmjs/proto-signing": "^0.32.3",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"typeCoverage": {
|
|
95
95
|
"atLeast": 97.6
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "c04c91c35e863e39728454326b95f00fc4f09d3e"
|
|
98
98
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @import {Zone} from '@agoric/zone';
|
|
3
3
|
* @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js';
|
|
4
4
|
*/
|
|
5
|
-
export const
|
|
5
|
+
export const SingleNatAmountRecord: import("@endo/patterns").Matcher;
|
|
6
6
|
export const start: (zcf: ZCF<Record<string, unknown>>, privateArgs: OrchestrationPowers & {
|
|
7
7
|
marshaller: Marshaller;
|
|
8
8
|
}, baggage: import("@agoric/vat-data").Baggage) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-anywhere.contract.d.ts","sourceRoot":"","sources":["send-anywhere.contract.js"],"names":[],"mappings":"AAQA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"send-anywhere.contract.d.ts","sourceRoot":"","sources":["send-anywhere.contract.js"],"names":[],"mappings":"AAQA;;;GAGG;AAEH,qEAKE;AAsDF;gBA9CiB,UAAU;;;;;;;;;;;;;;;;;;;GA8CsB;yCA9DS,0BAA0B"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { makeSharedStateRecord } from '@agoric/async-flow';
|
|
2
|
-
import { AmountShape } from '@agoric/ertp';
|
|
3
2
|
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
4
3
|
import { M } from '@endo/patterns';
|
|
5
4
|
import { withOrchestration } from '../utils/start-helper.js';
|
|
6
5
|
import * as flows from './send-anywhere.flows.js';
|
|
7
6
|
import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js';
|
|
7
|
+
import { AnyNatAmountShape } from '../typeGuards.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @import {Zone} from '@agoric/zone';
|
|
11
11
|
* @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js';
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
export const
|
|
15
|
-
M.recordOf(M.string(),
|
|
14
|
+
export const SingleNatAmountRecord = M.and(
|
|
15
|
+
M.recordOf(M.string(), AnyNatAmountShape, {
|
|
16
16
|
numPropertiesLimit: 1,
|
|
17
17
|
}),
|
|
18
18
|
M.not(harden({})),
|
|
19
19
|
);
|
|
20
|
-
harden(
|
|
20
|
+
harden(SingleNatAmountRecord);
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Orchestration contract to be wrapped by withOrchestration for Zoe
|
|
@@ -47,7 +47,7 @@ const contract = async (
|
|
|
47
47
|
const orchFns = orchestrateAll(flows, {
|
|
48
48
|
zcf,
|
|
49
49
|
contractState,
|
|
50
|
-
|
|
50
|
+
zoeTools,
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
const publicFacet = zone.exo(
|
|
@@ -61,7 +61,7 @@ const contract = async (
|
|
|
61
61
|
orchFns.sendIt,
|
|
62
62
|
'send',
|
|
63
63
|
undefined,
|
|
64
|
-
M.splitRecord({ give:
|
|
64
|
+
M.splitRecord({ give: SingleNatAmountRecord }),
|
|
65
65
|
);
|
|
66
66
|
},
|
|
67
67
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function sendIt(orch: Orchestrator, { contractState, localTransfer }: {
|
|
1
|
+
export function sendIt(orch: Orchestrator, { contractState, zoeTools: { localTransfer, withdrawToSeat } }: {
|
|
2
2
|
contractState: {
|
|
3
3
|
localAccount?: OrchestrationAccountI & LocalAccountMethods;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
zoeTools: GuestInterface<ZoeTools>;
|
|
6
6
|
}, seat: ZCFSeat, offerArgs: {
|
|
7
7
|
chainName: string;
|
|
8
8
|
destAddr: string;
|
|
@@ -11,5 +11,5 @@ import type { Orchestrator } from '../types.js';
|
|
|
11
11
|
import type { OrchestrationAccountI } from '../types.js';
|
|
12
12
|
import type { LocalAccountMethods } from '../types.js';
|
|
13
13
|
import type { ZoeTools } from '../utils/zoe-tools.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type { GuestInterface } from '@agoric/async-flow';
|
|
15
15
|
//# sourceMappingURL=send-anywhere.flows.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-anywhere.flows.d.ts","sourceRoot":"","sources":["send-anywhere.flows.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"send-anywhere.flows.d.ts","sourceRoot":"","sources":["send-anywhere.flows.js"],"names":[],"mappings":"AAwBO,6BAPI,YAAY,kEAEpB;IAA4E,aAAa,EAAjF;QAAE,YAAY,CAAC,EAAE,qBAAqB,GAAG,mBAAmB,CAAA;KAAE;IAChC,QAAQ,EAAtC,eAAe,QAAQ,CAAC;CAChC,QAAQ,OAAO,aACP;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,iBAiDjD;kCAhE6F,aAAa;2CAAb,aAAa;yCAAb,aAAa;8BADhF,uBAAuB;oCADjB,oBAAoB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NonNullish } from '@agoric/internal';
|
|
2
|
+
import { makeError, q } from '@endo/errors';
|
|
2
3
|
import { M, mustMatch } from '@endo/patterns';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* @import {
|
|
6
|
+
* @import {GuestInterface} from '@agoric/async-flow';
|
|
6
7
|
* @import {ZoeTools} from '../utils/zoe-tools.js';
|
|
7
8
|
* @import {Orchestrator, LocalAccountMethods, OrchestrationAccountI, OrchestrationFlow} from '../types.js';
|
|
8
9
|
*/
|
|
@@ -17,13 +18,13 @@ const { entries } = Object;
|
|
|
17
18
|
* @param {Orchestrator} orch
|
|
18
19
|
* @param {object} ctx
|
|
19
20
|
* @param {{ localAccount?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState
|
|
20
|
-
* @param {
|
|
21
|
+
* @param {GuestInterface<ZoeTools>} ctx.zoeTools
|
|
21
22
|
* @param {ZCFSeat} seat
|
|
22
23
|
* @param {{ chainName: string; destAddr: string }} offerArgs
|
|
23
24
|
*/
|
|
24
25
|
export const sendIt = async (
|
|
25
26
|
orch,
|
|
26
|
-
{ contractState, localTransfer },
|
|
27
|
+
{ contractState, zoeTools: { localTransfer, withdrawToSeat } },
|
|
27
28
|
seat,
|
|
28
29
|
offerArgs,
|
|
29
30
|
) => {
|
|
@@ -51,14 +52,22 @@ export const sendIt = async (
|
|
|
51
52
|
|
|
52
53
|
await localTransfer(seat, contractState.localAccount, give);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
try {
|
|
56
|
+
await contractState.localAccount.transfer(
|
|
57
|
+
{ denom, value: amt.value },
|
|
58
|
+
{
|
|
59
|
+
value: destAddr,
|
|
60
|
+
encoding: 'bech32',
|
|
61
|
+
chainId,
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
await withdrawToSeat(contractState.localAccount, seat, give);
|
|
66
|
+
const errorMsg = `IBC Transfer failed ${q(e)}`;
|
|
67
|
+
seat.exit(errorMsg);
|
|
68
|
+
throw makeError(errorMsg);
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
seat.exit();
|
|
63
72
|
};
|
|
64
73
|
harden(sendIt);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"AAoCO,2BAVI,GAAG,eACH;IACN,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC;IAC7B,UAAU,EAAE,OAAO,UAAU,CAAC,CAAC;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;CAC5B,WACO,OAAO,kBAAkB,EAAE,OAAO;;QAkEvC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0BH;;WAEG;;;GAaR;6BA9HyB,cAAc;4BACf,kBAAkB;gCAEd,gCAAgC;kCAD9B,cAAc"}
|
|
@@ -12,6 +12,7 @@ import { M } from '@endo/patterns';
|
|
|
12
12
|
import { makeChainHub } from '../exos/chain-hub.js';
|
|
13
13
|
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
|
|
14
14
|
import fetchedChainInfo from '../fetched-chain-info.js';
|
|
15
|
+
import { makeZoeTools } from '../utils/zoe-tools.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* @import {NameHub} from '@agoric/vats';
|
|
@@ -43,6 +44,7 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
43
44
|
const vowTools = prepareVowTools(zone.subZone('vows'));
|
|
44
45
|
|
|
45
46
|
const chainHub = makeChainHub(privateArgs.agoricNames, vowTools);
|
|
47
|
+
const zoeTools = makeZoeTools(zcf, vowTools);
|
|
46
48
|
|
|
47
49
|
const { localchain, timerService } = privateArgs;
|
|
48
50
|
const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
|
|
@@ -54,6 +56,7 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
54
56
|
vowTools,
|
|
55
57
|
chainHub,
|
|
56
58
|
localchain,
|
|
59
|
+
zoeTools,
|
|
57
60
|
},
|
|
58
61
|
);
|
|
59
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking-combinations.flows.d.ts","sourceRoot":"","sources":["staking-combinations.flows.js"],"names":[],"mappings":"AA2BO,kCATI,YAAY,OACZ;IACN,2BAA2B,EAAE,2BAA2B,CAAC;IACzD,wBAAwB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,gBAAgB,CAAC;CAC9D,SACO,OAAO,iBACP;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAkB1C;AAcM,yCATI,YAAY,+BAEpB;IAA4E,aAAa,EAAjF;QAAE,YAAY,CAAC,EAAE,qBAAqB,GAAG,mBAAmB,CAAA;KAAE;IAChC,QAAQ,EAAtC,eAAe,QAAQ,CAAC;CAChC,WAAQ,eAAe,0BAA0B,CAAC,QAC1C,OAAO,aACP,sBAAsB,GACpB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"staking-combinations.flows.d.ts","sourceRoot":"","sources":["staking-combinations.flows.js"],"names":[],"mappings":"AA2BO,kCATI,YAAY,OACZ;IACN,2BAA2B,EAAE,2BAA2B,CAAC;IACzD,wBAAwB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,gBAAgB,CAAC;CAC9D,SACO,OAAO,iBACP;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAkB1C;AAcM,yCATI,YAAY,+BAEpB;IAA4E,aAAa,EAAjF;QAAE,YAAY,CAAC,EAAE,qBAAqB,GAAG,mBAAmB,CAAA;KAAE;IAChC,QAAQ,EAAtC,eAAe,QAAQ,CAAC;CAChC,WAAQ,eAAe,0BAA0B,CAAC,QAC1C,OAAO,aACP,sBAAsB,GACpB,OAAO,CAAC,IAAI,CAAC,CA8BzB;AAcM,4CATI,YAAY,OACZ,MAAM,WACN,eAAe,0BAA0B,CAAC,gCAC1C;IACN,WAAW,EAAE;QAAE,MAAM,EAAE,SAAS,CAAC;QAAC,SAAS,EAAE,sBAAsB,CAAA;KAAE,EAAE,CAAC;IACxE,WAAW,EAAE,YAAY,CAAC;CAC3B,GACS,OAAO,CAAC,IAAI,CAAC,CAYzB;kCA3G8I,aAAa;iDAE9G,sCAAsC;sCAD1B,mCAAmC;2CAAnC,mCAAmC;2CADkD,aAAa;yCAAb,aAAa;8BAIjI,uBAAuB;oCALjB,oBAAoB;gDAIR,yCAAyC;4CAHyD,aAAa;+BAAb,aAAa;kCAAb,aAAa"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { mustMatch } from '@endo/patterns';
|
|
11
|
-
import { makeError } from '@endo/errors';
|
|
11
|
+
import { makeError, q } from '@endo/errors';
|
|
12
12
|
import { makeTracer } from '@agoric/internal';
|
|
13
13
|
import { ChainAddressShape } from '../typeGuards.js';
|
|
14
14
|
|
|
@@ -76,9 +76,10 @@ export const depositAndDelegate = async (
|
|
|
76
76
|
try {
|
|
77
77
|
await contractState.localAccount.transfer(give.Stake, address);
|
|
78
78
|
} catch (cause) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
await zoeTools.withdrawToSeat(contractState.localAccount, seat, give);
|
|
80
|
+
const errMsg = makeError(`ibc transfer failed ${q(cause)}`);
|
|
81
|
+
seat.exit(errMsg);
|
|
82
|
+
throw errMsg;
|
|
82
83
|
}
|
|
83
84
|
seat.exit();
|
|
84
85
|
await account.delegate(validator, give.Stake);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export function prepareLocalOrchestrationAccountKit(zone: Zone, { makeRecorderKit, zcf, timerService, vowTools, chainHub, localchain }: {
|
|
1
|
+
export function prepareLocalOrchestrationAccountKit(zone: Zone, { makeRecorderKit, zcf, timerService, vowTools, chainHub, localchain, zoeTools, }: {
|
|
2
2
|
makeRecorderKit: MakeRecorderKit;
|
|
3
3
|
zcf: ZCF;
|
|
4
4
|
timerService: Remote<TimerService>;
|
|
5
5
|
vowTools: VowTools;
|
|
6
6
|
chainHub: ChainHub;
|
|
7
7
|
localchain: Remote<LocalChain>;
|
|
8
|
+
zoeTools: ZoeTools;
|
|
8
9
|
}): (args_0: {
|
|
9
10
|
account: LocalChainAccount;
|
|
10
11
|
address: ChainAddress;
|
|
@@ -23,6 +24,7 @@ export function prepareLocalOrchestrationAccountKit(zone: Zone, { makeRecorderKi
|
|
|
23
24
|
* @param {Amount<'nat'>} ertpAmount
|
|
24
25
|
*/
|
|
25
26
|
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<Vow<Record<unknown, unknown>>, undefined>>;
|
|
27
|
+
Deposit(): Promise<Invitation<Vow<void>, undefined>>;
|
|
26
28
|
/**
|
|
27
29
|
* @param {string} validatorAddress
|
|
28
30
|
* @param {Amount<'nat'>} ertpAmount
|
|
@@ -42,6 +44,7 @@ export function prepareLocalOrchestrationAccountKit(zone: Zone, { makeRecorderKi
|
|
|
42
44
|
destination: ChainAddress;
|
|
43
45
|
opts: IBCMsgTransferOptions;
|
|
44
46
|
}>>;
|
|
47
|
+
Withdraw(): Promise<Invitation<Vow<void>, undefined>>;
|
|
45
48
|
};
|
|
46
49
|
undelegateWatcher: {
|
|
47
50
|
/**
|
|
@@ -98,6 +101,19 @@ export function prepareLocalOrchestrationAccountKit(zone: Zone, { makeRecorderKi
|
|
|
98
101
|
*/
|
|
99
102
|
onFulfilled(natAmount: Amount<"nat">, denom: DenomAmount["denom"]): DenomAmount;
|
|
100
103
|
};
|
|
104
|
+
/** exits or fails a seat depending the outcome */
|
|
105
|
+
seatExiterHandler: {
|
|
106
|
+
/**
|
|
107
|
+
* @param {undefined} _
|
|
108
|
+
* @param {ZCFSeat} seat
|
|
109
|
+
*/
|
|
110
|
+
onFulfilled(_: undefined, seat: ZCFSeat): void;
|
|
111
|
+
/**
|
|
112
|
+
* @param {Error} reason
|
|
113
|
+
* @param {ZCFSeat} seat
|
|
114
|
+
*/
|
|
115
|
+
onRejected(reason: Error, seat: ZCFSeat): never;
|
|
116
|
+
};
|
|
101
117
|
/**
|
|
102
118
|
* handles a QueryBalanceRequest from localchain.query and returns the
|
|
103
119
|
* balance as a DenomAmount
|
|
@@ -223,6 +239,7 @@ import type { Remote } from '@agoric/internal';
|
|
|
223
239
|
import type { VowTools } from '@agoric/vow';
|
|
224
240
|
import type { ChainHub } from './chain-hub.js';
|
|
225
241
|
import type { LocalChain } from '@agoric/vats/src/localchain.js';
|
|
242
|
+
import type { ZoeTools } from '../utils/zoe-tools.js';
|
|
226
243
|
import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
|
|
227
244
|
import type { ChainAddress } from '@agoric/orchestration';
|
|
228
245
|
import type { AmountArg } from '@agoric/orchestration';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-orchestration-account.d.ts","sourceRoot":"","sources":["local-orchestration-account.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-orchestration-account.d.ts","sourceRoot":"","sources":["local-orchestration-account.js"],"names":[],"mappings":"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"}
|
|
@@ -10,6 +10,7 @@ import { Fail, q } from '@endo/errors';
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
AmountArgShape,
|
|
13
|
+
AnyNatAmountsRecord,
|
|
13
14
|
ChainAddressShape,
|
|
14
15
|
DenomAmountShape,
|
|
15
16
|
DenomShape,
|
|
@@ -39,6 +40,7 @@ import { coerceCoin, coerceDenomAmount } from '../utils/amounts.js';
|
|
|
39
40
|
* @import {Matcher} from '@endo/patterns';
|
|
40
41
|
* @import {ChainHub} from './chain-hub.js';
|
|
41
42
|
* @import {PacketTools} from './packet-tools.js';
|
|
43
|
+
* @import {ZoeTools} from '../utils/zoe-tools.js';
|
|
42
44
|
*/
|
|
43
45
|
|
|
44
46
|
const trace = makeTracer('LOA');
|
|
@@ -91,10 +93,19 @@ const PUBLIC_TOPICS = {
|
|
|
91
93
|
* @param {VowTools} powers.vowTools
|
|
92
94
|
* @param {ChainHub} powers.chainHub
|
|
93
95
|
* @param {Remote<LocalChain>} powers.localchain
|
|
96
|
+
* @param {ZoeTools} powers.zoeTools
|
|
94
97
|
*/
|
|
95
98
|
export const prepareLocalOrchestrationAccountKit = (
|
|
96
99
|
zone,
|
|
97
|
-
{
|
|
100
|
+
{
|
|
101
|
+
makeRecorderKit,
|
|
102
|
+
zcf,
|
|
103
|
+
timerService,
|
|
104
|
+
vowTools,
|
|
105
|
+
chainHub,
|
|
106
|
+
localchain,
|
|
107
|
+
zoeTools,
|
|
108
|
+
},
|
|
98
109
|
) => {
|
|
99
110
|
const { watch, allVows, asVow, when } = vowTools;
|
|
100
111
|
const { makeIBCTransferSender } = prepareIBCTools(
|
|
@@ -139,6 +150,12 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
139
150
|
returnVoidWatcher: M.interface('returnVoidWatcher', {
|
|
140
151
|
onFulfilled: M.call(M.any()).optional(M.any()).returns(M.undefined()),
|
|
141
152
|
}),
|
|
153
|
+
seatExiterHandler: M.interface('seatExiterHandler', {
|
|
154
|
+
onFulfilled: M.call(M.undefined(), M.remotable()).returns(
|
|
155
|
+
M.undefined(),
|
|
156
|
+
),
|
|
157
|
+
onRejected: M.call(M.error(), M.remotable()).returns(M.undefined()),
|
|
158
|
+
}),
|
|
142
159
|
getBalanceWatcher: M.interface('getBalanceWatcher', {
|
|
143
160
|
onFulfilled: M.call(AmountShape, DenomShape).returns(DenomAmountShape),
|
|
144
161
|
}),
|
|
@@ -151,12 +168,14 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
151
168
|
),
|
|
152
169
|
}),
|
|
153
170
|
invitationMakers: M.interface('invitationMakers', {
|
|
154
|
-
Delegate: M.call(M.string(), AmountShape).returns(M.promise()),
|
|
155
|
-
Undelegate: M.call(M.string(), AmountShape).returns(M.promise()),
|
|
156
171
|
CloseAccount: M.call().returns(M.promise()),
|
|
172
|
+
Delegate: M.call(M.string(), AmountShape).returns(M.promise()),
|
|
173
|
+
Deposit: M.call().returns(M.promise()),
|
|
157
174
|
Send: M.call().returns(M.promise()),
|
|
158
175
|
SendAll: M.call().returns(M.promise()),
|
|
159
176
|
Transfer: M.call().returns(M.promise()),
|
|
177
|
+
Undelegate: M.call(M.string(), AmountShape).returns(M.promise()),
|
|
178
|
+
Withdraw: M.call().returns(M.promise()),
|
|
160
179
|
}),
|
|
161
180
|
},
|
|
162
181
|
/**
|
|
@@ -200,6 +219,27 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
200
219
|
);
|
|
201
220
|
}, 'Delegate');
|
|
202
221
|
},
|
|
222
|
+
Deposit() {
|
|
223
|
+
trace('Deposit');
|
|
224
|
+
return zcf.makeInvitation(
|
|
225
|
+
seat => {
|
|
226
|
+
const { give } = seat.getProposal();
|
|
227
|
+
return watch(
|
|
228
|
+
zoeTools.localTransfer(
|
|
229
|
+
seat,
|
|
230
|
+
// @ts-expect-error LocalAccount vs LocalAccountMethods
|
|
231
|
+
this.state.account,
|
|
232
|
+
give,
|
|
233
|
+
),
|
|
234
|
+
this.facets.seatExiterHandler,
|
|
235
|
+
seat,
|
|
236
|
+
);
|
|
237
|
+
},
|
|
238
|
+
'Deposit',
|
|
239
|
+
undefined,
|
|
240
|
+
M.splitRecord({ give: AnyNatAmountsRecord, want: {} }),
|
|
241
|
+
);
|
|
242
|
+
},
|
|
203
243
|
/**
|
|
204
244
|
* @param {string} validatorAddress
|
|
205
245
|
* @param {Amount<'nat'>} ertpAmount
|
|
@@ -262,6 +302,27 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
262
302
|
};
|
|
263
303
|
return zcf.makeInvitation(offerHandler, 'Transfer');
|
|
264
304
|
},
|
|
305
|
+
Withdraw() {
|
|
306
|
+
trace('Withdraw');
|
|
307
|
+
return zcf.makeInvitation(
|
|
308
|
+
seat => {
|
|
309
|
+
const { want } = seat.getProposal();
|
|
310
|
+
return watch(
|
|
311
|
+
zoeTools.withdrawToSeat(
|
|
312
|
+
// @ts-expect-error LocalAccount vs LocalAccountMethods
|
|
313
|
+
this.state.account,
|
|
314
|
+
seat,
|
|
315
|
+
want,
|
|
316
|
+
),
|
|
317
|
+
this.facets.seatExiterHandler,
|
|
318
|
+
seat,
|
|
319
|
+
);
|
|
320
|
+
},
|
|
321
|
+
'Withdraw',
|
|
322
|
+
undefined,
|
|
323
|
+
M.splitRecord({ give: {}, want: AnyNatAmountsRecord }),
|
|
324
|
+
);
|
|
325
|
+
},
|
|
265
326
|
},
|
|
266
327
|
undelegateWatcher: {
|
|
267
328
|
/**
|
|
@@ -362,6 +423,24 @@ export const prepareLocalOrchestrationAccountKit = (
|
|
|
362
423
|
return harden({ denom, value: natAmount.value });
|
|
363
424
|
},
|
|
364
425
|
},
|
|
426
|
+
/** exits or fails a seat depending the outcome */
|
|
427
|
+
seatExiterHandler: {
|
|
428
|
+
/**
|
|
429
|
+
* @param {undefined} _
|
|
430
|
+
* @param {ZCFSeat} seat
|
|
431
|
+
*/
|
|
432
|
+
onFulfilled(_, seat) {
|
|
433
|
+
seat.exit();
|
|
434
|
+
},
|
|
435
|
+
/**
|
|
436
|
+
* @param {Error} reason
|
|
437
|
+
* @param {ZCFSeat} seat
|
|
438
|
+
*/
|
|
439
|
+
onRejected(reason, seat) {
|
|
440
|
+
seat.exit(reason);
|
|
441
|
+
throw reason;
|
|
442
|
+
},
|
|
443
|
+
},
|
|
365
444
|
/**
|
|
366
445
|
* handles a QueryBalanceRequest from localchain.query and returns the
|
|
367
446
|
* balance as a DenomAmount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-stakeBld.d.ts","sourceRoot":"","sources":["start-stakeBld.js"],"names":[],"mappings":"AAkBO,6TAVI,eAAe,GAAG;IACxB,YAAY,EAAE;QACZ,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY,CAC9B;;;;;;+
|
|
1
|
+
{"version":3,"file":"start-stakeBld.d.ts","sourceRoot":"","sources":["start-stakeBld.js"],"names":[],"mappings":"AAkBO,6TAVI,eAAe,GAAG;IACxB,YAAY,EAAE;QACZ,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY,CAC9B;;;;;;+BAuCkB,kBACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAxC8D,CACxD,CAAC;SACH,CAAC;KACH,CAAC;CACH,iBAwDH;AAGM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BN;sBApGqB,gCAAgC"}
|
package/src/typeGuards.d.ts
CHANGED
|
@@ -73,6 +73,11 @@ export namespace TimestampProtoShape {
|
|
|
73
73
|
* @internal
|
|
74
74
|
*/
|
|
75
75
|
export const TxBodyOptsShape: import("@endo/patterns").Matcher;
|
|
76
|
+
/**
|
|
77
|
+
* Ensures at least one {@link AmountKeywordRecord} entry is present and only
|
|
78
|
+
* permits Nat (fungible) amounts.
|
|
79
|
+
*/
|
|
80
|
+
export const AnyNatAmountsRecord: import("@endo/patterns").Matcher;
|
|
76
81
|
import type { ChainAddress } from './types.js';
|
|
77
82
|
import type { TypedPattern } from '@agoric/internal';
|
|
78
83
|
import type { Any as Proto3Msg } from '@agoric/cosmic-proto/google/protobuf/any.js';
|
package/src/typeGuards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;GAIG;AACH;;;GAQE;AAEF,yCAAyC;AACzC,gCADW,aAAa,YAAY,CAAC,CAKnC;AAEF,sCAAsC;AACtC,0BADW,aAAa,SAAS,CAAC,CAIhC;AAEF,gBAAgB;AAChB,uEAUE;AAEF,gBAAgB;AAChB,iEAA4C;AAC5C,gBAAgB;AAChB,mEAQG;AACH,gBAAgB;AAChB,oEAA+C;AAC/C,gBAAgB;AAChB,sEASG;AAEH,4CAA4C;AAC5C,mCADW,aAAa,eAAe,CAAC,CASrC;AAEH,4CAA4C;AAC5C,mCADW,aAAa,eAAe,CAAC,CAWtC;AAEF,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CAG/B;AACH,sEAAuE;AACvE,0DAAqC;AAErC,gDAAgD;AAChD,6BADW,aAAa,UAAU,GAAG,EAAE,GAAG,CAAC,CAAC,CAM1C;AAEF,wCAAwC;AACxC,+BADW,aAAa,WAAW,CAAC,CACqC;AAEzE,0CAA0C;AAC1C,gCADW,aAAa,MAAM,CAAC,KAAK,CAAC,CAAC,CAInC;AAEH,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CACsC;AAExE;;;;;GAKG;AACH,8BALU,aAAa;IAClB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC,CAQH;AAEF,sCAAsC;AACtC,2DAGE;AAEF,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CACmC;;;;;;;;;AAiBrE;;;;GAIG;AACH,+DAQE;
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;GAIG;AACH;;;GAQE;AAEF,yCAAyC;AACzC,gCADW,aAAa,YAAY,CAAC,CAKnC;AAEF,sCAAsC;AACtC,0BADW,aAAa,SAAS,CAAC,CAIhC;AAEF,gBAAgB;AAChB,uEAUE;AAEF,gBAAgB;AAChB,iEAA4C;AAC5C,gBAAgB;AAChB,mEAQG;AACH,gBAAgB;AAChB,oEAA+C;AAC/C,gBAAgB;AAChB,sEASG;AAEH,4CAA4C;AAC5C,mCADW,aAAa,eAAe,CAAC,CASrC;AAEH,4CAA4C;AAC5C,mCADW,aAAa,eAAe,CAAC,CAWtC;AAEF,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CAG/B;AACH,sEAAuE;AACvE,0DAAqC;AAErC,gDAAgD;AAChD,6BADW,aAAa,UAAU,GAAG,EAAE,GAAG,CAAC,CAAC,CAM1C;AAEF,wCAAwC;AACxC,+BADW,aAAa,WAAW,CAAC,CACqC;AAEzE,0CAA0C;AAC1C,gCADW,aAAa,MAAM,CAAC,KAAK,CAAC,CAAC,CAInC;AAEH,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CACsC;AAExE;;;;;GAKG;AACH,8BALU,aAAa;IAClB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC,CAQH;AAEF,sCAAsC;AACtC,2DAGE;AAEF,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CACmC;;;;;;;;;AAiBrE;;;;GAIG;AACH,+DAQE;AAEF;;;GAGG;AACH,mEAGE;kCAzLyJ,YAAY;kCADxI,kBAAkB;sCAEd,6CAA6C;qCAD2E,YAAY;qCAAZ,YAAY;+BAAZ,YAAY;+BAAZ,YAAY;iCAAZ,YAAY;+BAAZ,YAAY;4CAAZ,YAAY;+BAI3I,sBAAsB"}
|
package/src/typeGuards.js
CHANGED
|
@@ -180,3 +180,13 @@ export const TxBodyOptsShape = M.splitRecord(
|
|
|
180
180
|
nonCriticalExtensionOptions: M.arrayOf(M.any()),
|
|
181
181
|
},
|
|
182
182
|
);
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Ensures at least one {@link AmountKeywordRecord} entry is present and only
|
|
186
|
+
* permits Nat (fungible) amounts.
|
|
187
|
+
*/
|
|
188
|
+
export const AnyNatAmountsRecord = M.and(
|
|
189
|
+
M.recordOf(M.string(), AnyNatAmountShape),
|
|
190
|
+
M.not(harden({})),
|
|
191
|
+
);
|
|
192
|
+
harden(AnyNatAmountsRecord);
|
|
@@ -70,7 +70,8 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
|
|
|
70
70
|
prepareEndowment: (zone: Zone, tag: string, e: unknown) => any;
|
|
71
71
|
};
|
|
72
72
|
zoeTools: {
|
|
73
|
-
localTransfer: (srcSeat: ZCFSeat, localAccount: import("../cosmos-api.js").LocalAccountMethods,
|
|
73
|
+
localTransfer: (srcSeat: ZCFSeat, localAccount: import("../cosmos-api.js").LocalAccountMethods, amounts: AmountKeywordRecord) => import("@agoric/vow").Vow<void>;
|
|
74
|
+
withdrawToSeat: (localAccount: import("../cosmos-api.js").LocalAccountMethods, destSeat: ZCFSeat, amounts: AmountKeywordRecord) => import("@agoric/vow").Vow<void>;
|
|
74
75
|
};
|
|
75
76
|
zone: Zone;
|
|
76
77
|
orchestrate: <HC, GF extends import("../orchestration-api.js").OrchestrationFlow<import("@agoric/async-flow").GuestInterface<HC>>>(durableName: string, hostCtx: HC, guestFn: GF) => HostForGuest<GF>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AA6CO,0CANI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;+
|
|
1
|
+
{"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AA6CO,0CANI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;+BA2GR,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAzEM,GAAG;;+BAhDV,GAAG,+EAMoD,GAAG,yCAG9D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Id;AA8BM,kCAdgC,EAAE,SAA3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,EAGhC,EAAE,SAFM,mBAAmB,GAAG;IAC/B,UAAU,EAAE,UAAU,CAAC;CACvB,EACQ,CAAC,cACH,CACN,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EACZ,WAAW,EAAE,EAAE,EACf,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,kBAAkB,KACtB,OAAO,CAAC,CAAC,CAAC,GACL,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAYzE;kCA9LU;IACR,UAAU,EAAE,OAAO,UAAU,CAAC,CAAC;IAC/B,oBAAoB,EAAE,OAAO,uBAAuB,CAAC,CAAC;IACtD,WAAW,EAAE,OAAO,WAAW,CAAC,CAAC;IACjC,YAAY,EAAE,OAAO,YAAY,CAAC,CAAC;IACnC,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;iCAoJU,IAAI,CAAC,UAAU,CAAC,OAAO,oBAAoB,CAAC,EAAE,MAAM,CAAC;6BAlKzC,kBAAkB;0BAGrB,cAAc;gCALR,gCAAgC;4BAIpC,aAAa;6CAEI,2BAA2B;kCAL1B,cAAc;6BAE/B,cAAc"}
|
|
@@ -63,8 +63,6 @@ export const provideOrchestration = (
|
|
|
63
63
|
orchestration: zone.subZone('orchestration'),
|
|
64
64
|
/** system names for vows */
|
|
65
65
|
vows: zone.subZone('vows'),
|
|
66
|
-
/** system names for zoe */
|
|
67
|
-
zoe: zone.subZone('zoe'),
|
|
68
66
|
/** contract-provided names, and subzones */
|
|
69
67
|
contract: zone.subZone('contract'),
|
|
70
68
|
};
|
|
@@ -76,12 +74,20 @@ export const provideOrchestration = (
|
|
|
76
74
|
|
|
77
75
|
const chainHub = makeChainHub(agoricNames, vowTools);
|
|
78
76
|
|
|
79
|
-
const zoeTools = makeZoeTools(
|
|
77
|
+
const zoeTools = makeZoeTools(zcf, vowTools);
|
|
80
78
|
|
|
81
79
|
const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
|
|
82
80
|
const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
|
|
83
81
|
zones.orchestration,
|
|
84
|
-
{
|
|
82
|
+
{
|
|
83
|
+
makeRecorderKit,
|
|
84
|
+
zcf,
|
|
85
|
+
timerService,
|
|
86
|
+
vowTools,
|
|
87
|
+
chainHub,
|
|
88
|
+
localchain,
|
|
89
|
+
zoeTools,
|
|
90
|
+
},
|
|
85
91
|
);
|
|
86
92
|
|
|
87
93
|
const asyncFlowTools = prepareAsyncFlowTools(zones.asyncFlow, {
|
package/src/utils/zoe-tools.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
export function makeZoeTools(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}): {
|
|
5
|
-
localTransfer: (srcSeat: ZCFSeat, localAccount: LocalAccountMethods, give: AmountKeywordRecord) => Vow<void>;
|
|
1
|
+
export function makeZoeTools(zcf: ZCF, { when, allVows, allSettled, asVow }: VowTools): {
|
|
2
|
+
localTransfer: (srcSeat: ZCFSeat, localAccount: LocalAccountMethods, amounts: AmountKeywordRecord) => import("@agoric/vow").Vow<void>;
|
|
3
|
+
withdrawToSeat: (localAccount: LocalAccountMethods, destSeat: ZCFSeat, amounts: AmountKeywordRecord) => import("@agoric/vow").Vow<void>;
|
|
6
4
|
};
|
|
7
5
|
export type ResolvedContinuingOfferResult = {
|
|
8
6
|
invitationMakers: InvitationMakers;
|
|
9
7
|
publicSubscribers: Record<string, ResolvedPublicTopic<any>>;
|
|
10
8
|
};
|
|
11
|
-
export type LocalTransfer = (srcSeat: ZCFSeat, localAccount: LocalAccountMethods,
|
|
9
|
+
export type LocalTransfer = (srcSeat: ZCFSeat, localAccount: LocalAccountMethods, amounts: AmountKeywordRecord) => Promise<void>;
|
|
10
|
+
export type WithdrawToSeat = (localAccount: LocalAccountMethods, destSeat: ZCFSeat, amounts: AmountKeywordRecord) => Promise<void>;
|
|
12
11
|
export type ZoeTools = ReturnType<typeof makeZoeTools>;
|
|
13
|
-
import type { Zone } from '@agoric/zone';
|
|
14
12
|
import type { VowTools } from '@agoric/vow';
|
|
15
13
|
import type { LocalAccountMethods } from '../types.js';
|
|
16
|
-
import type { Vow } from '@agoric/vow';
|
|
17
14
|
import type { InvitationMakers } from '@agoric/smart-wallet/src/types.js';
|
|
18
15
|
import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
|
|
19
16
|
//# sourceMappingURL=zoe-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoe-tools.d.ts","sourceRoot":"","sources":["zoe-tools.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zoe-tools.d.ts","sourceRoot":"","sources":["zoe-tools.js"],"names":[],"mappings":"AA4DO,kCAHI,GAAG,wCACH,QAAQ;;;EA6HlB;4CAvJY;IACR,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,CAAC;CAC7D;4BAMS,CACR,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,mBAAmB,KACzB,OAAO,CAAC,IAAI,CAAC;6BAIR,CACR,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,mBAAmB,KACzB,OAAO,CAAC,IAAI,CAAC;uBAoIP,UAAU,CAAC,OAAO,YAAY,CAAC;8BA9JlB,aAAa;yCACF,aAAa;sCAHhB,mCAAmC;yCAChC,2CAA2C"}
|
package/src/utils/zoe-tools.js
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Helper functions for transferring payments between a LocalChainAccount
|
|
3
|
+
* and a ZCFSeat.
|
|
4
|
+
*
|
|
5
|
+
* Maintainers: This exists as an endowment for orchestrated async-flows so we
|
|
6
|
+
* can make use of E and promises. The logic for recovering partial failures
|
|
7
|
+
* is also an added convenience for developers.
|
|
8
|
+
*
|
|
9
|
+
* Functions are written using `asVow` and non-resumable promises as we expect
|
|
10
|
+
* each invocation to resolve promptly - there are no timers or interchain
|
|
11
|
+
* network calls.
|
|
12
|
+
*
|
|
13
|
+
* A promise resolved promptly is currently safe from being severed by an
|
|
14
|
+
* upgrade because we only trigger vat upgrades as the result of network
|
|
15
|
+
* input.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { makeError, q, Fail } from '@endo/errors';
|
|
19
|
+
import { depositToSeat } from '@agoric/zoe/src/contractSupport/index.js';
|
|
3
20
|
import { E } from '@endo/far';
|
|
4
21
|
|
|
22
|
+
const { assign, keys, values } = Object;
|
|
23
|
+
|
|
5
24
|
/**
|
|
25
|
+
* @import {HostOf} from '@agoric/async-flow';
|
|
6
26
|
* @import {InvitationMakers} from '@agoric/smart-wallet/src/types.js';
|
|
7
27
|
* @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
|
|
8
|
-
* @import {
|
|
9
|
-
* @import {Zone} from '@agoric/zone';
|
|
10
|
-
* @import {OrchestrationAccount} from '../orchestration-api.js'
|
|
28
|
+
* @import {VowTools} from '@agoric/vow';
|
|
11
29
|
* @import {LocalAccountMethods} from '../types.js';
|
|
12
30
|
*/
|
|
13
31
|
|
|
@@ -24,31 +42,38 @@ import { E } from '@endo/far';
|
|
|
24
42
|
* @typedef {(
|
|
25
43
|
* srcSeat: ZCFSeat,
|
|
26
44
|
* localAccount: LocalAccountMethods,
|
|
27
|
-
*
|
|
45
|
+
* amounts: AmountKeywordRecord,
|
|
28
46
|
* ) => Promise<void>} LocalTransfer
|
|
29
47
|
*/
|
|
30
48
|
|
|
31
49
|
/**
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
50
|
+
* @typedef {(
|
|
51
|
+
* localAccount: LocalAccountMethods,
|
|
52
|
+
* destSeat: ZCFSeat,
|
|
53
|
+
* amounts: AmountKeywordRecord,
|
|
54
|
+
* ) => Promise<void>} WithdrawToSeat
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {ZCF} zcf
|
|
59
|
+
* @param {VowTools} vowTools
|
|
34
60
|
*/
|
|
35
|
-
export const makeZoeTools = (
|
|
61
|
+
export const makeZoeTools = (zcf, { when, allVows, allSettled, asVow }) => {
|
|
36
62
|
/**
|
|
37
|
-
* Transfer the `
|
|
63
|
+
* Transfer the `amounts` from `srcSeat` to `localAccount`. If any of the
|
|
64
|
+
* deposits fail, everything will be rolled back to the `srcSeat`. Supports
|
|
65
|
+
* multiple items in the `amounts` {@link AmountKeywordRecord}.
|
|
66
|
+
*
|
|
67
|
+
* @type {HostOf<LocalTransfer>}
|
|
38
68
|
*/
|
|
39
|
-
const localTransfer =
|
|
40
|
-
|
|
41
|
-
'localTransfer',
|
|
42
|
-
/**
|
|
43
|
-
* @type {LocalTransfer}
|
|
44
|
-
*/
|
|
45
|
-
async (srcSeat, localAccount, give) => {
|
|
69
|
+
const localTransfer = (srcSeat, localAccount, amounts) =>
|
|
70
|
+
asVow(async () => {
|
|
46
71
|
!srcSeat.hasExited() || Fail`The seat cannot have exited.`;
|
|
47
72
|
const { zcfSeat: tempSeat, userSeat: userSeatP } = zcf.makeEmptySeatKit();
|
|
48
73
|
const userSeat = await userSeatP;
|
|
49
|
-
|
|
74
|
+
zcf.atomicRearrange(harden([[srcSeat, tempSeat, amounts]]));
|
|
50
75
|
tempSeat.exit();
|
|
51
|
-
// TODO get the userSeat into baggage so it's at least recoverable
|
|
76
|
+
// TODO (#9541) get the userSeat into baggage so it's at least recoverable
|
|
52
77
|
// const userSeat = await subzone.makeOnce(
|
|
53
78
|
// 'localTransferHelper',
|
|
54
79
|
// async () => {
|
|
@@ -56,28 +81,106 @@ export const makeZoeTools = (zone, { zcf, vowTools }) => {
|
|
|
56
81
|
// zcf.makeEmptySeatKit();
|
|
57
82
|
// const uSeat = await userSeatP;
|
|
58
83
|
// // TODO how do I store in the place for this retriable?
|
|
59
|
-
// atomicTransfer(zcf, srcSeat, tempSeat,
|
|
84
|
+
// atomicTransfer(zcf, srcSeat, tempSeat, amounts);
|
|
60
85
|
// tempSeat.exit();
|
|
61
86
|
// return uSeat;
|
|
62
87
|
// },
|
|
63
88
|
// );
|
|
64
89
|
|
|
65
|
-
// Now all the `
|
|
90
|
+
// Now all the `amounts` are accessible, so we can move them to the localAccount
|
|
91
|
+
const payments = await Promise.all(
|
|
92
|
+
keys(amounts).map(kw => E(userSeat).getPayout(kw)),
|
|
93
|
+
);
|
|
94
|
+
const settleDeposits = await when(
|
|
95
|
+
allSettled(payments.map(pmt => E(localAccount).deposit(pmt))),
|
|
96
|
+
);
|
|
97
|
+
// if any of the deposits to localAccount failed, unwind all of the allocations
|
|
98
|
+
if (settleDeposits.find(x => x.status === 'rejected')) {
|
|
99
|
+
const amts = values(amounts);
|
|
100
|
+
const errors = [];
|
|
101
|
+
// withdraw the successfully deposited payments
|
|
102
|
+
const paymentsOrWithdrawVs = settleDeposits.map((x, i) => {
|
|
103
|
+
if (x.status === 'rejected') {
|
|
104
|
+
errors.push(x.reason);
|
|
105
|
+
return payments[i];
|
|
106
|
+
}
|
|
107
|
+
return E(localAccount).withdraw(amts[i]);
|
|
108
|
+
});
|
|
66
109
|
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
// return all payments to the srcSeat
|
|
111
|
+
const paymentsToReturn = await when(allVows(paymentsOrWithdrawVs));
|
|
112
|
+
const paymentKwr = harden(
|
|
113
|
+
keys(amounts).reduce(
|
|
114
|
+
(kwr, kw, i) => assign(kwr, { [kw]: paymentsToReturn[i] }),
|
|
115
|
+
{},
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
const depositResponse = await depositToSeat(
|
|
119
|
+
zcf,
|
|
120
|
+
srcSeat,
|
|
121
|
+
amounts,
|
|
122
|
+
paymentKwr,
|
|
123
|
+
);
|
|
124
|
+
console.debug(depositResponse);
|
|
125
|
+
throw makeError(`One or more deposits failed ${q(errors)}`);
|
|
126
|
+
}
|
|
127
|
+
// TODO #9541 remove userSeat from baggage
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Transfer the `amounts` from a `localAccount` to the `recipientSeat`. If any
|
|
132
|
+
* of the withdrawals fail, everything will be rolled back to the
|
|
133
|
+
* `srcLocalAccount`. Supports multiple items in the `amounts`
|
|
134
|
+
* {@link PaymentKeywordRecord}
|
|
135
|
+
*
|
|
136
|
+
* @type {HostOf<WithdrawToSeat>}
|
|
137
|
+
*/
|
|
138
|
+
const withdrawToSeat = (localAccount, destSeat, amounts) =>
|
|
139
|
+
asVow(async () => {
|
|
140
|
+
!destSeat.hasExited() || Fail`The seat cannot have exited.`;
|
|
141
|
+
|
|
142
|
+
const settledWithdrawals = await when(
|
|
143
|
+
allSettled(values(amounts).map(amt => E(localAccount).withdraw(amt))),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// if any of the withdrawals were rejected, unwind the successful ones
|
|
147
|
+
if (settledWithdrawals.find(x => x.status === 'rejected')) {
|
|
148
|
+
const returnPaymentVs = [];
|
|
149
|
+
const errors = [];
|
|
150
|
+
for (const result of settledWithdrawals) {
|
|
151
|
+
if (result.status === 'fulfilled') {
|
|
152
|
+
returnPaymentVs.push(E(localAccount).deposit(result.value));
|
|
153
|
+
} else {
|
|
154
|
+
errors.push(result.reason);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
await when(allVows(returnPaymentVs));
|
|
158
|
+
throw makeError(`One or more withdrawals failed ${q(errors)}`);
|
|
159
|
+
}
|
|
160
|
+
// successfully withdrew payments from srcLocalAccount, deposit to recipientSeat
|
|
161
|
+
const paymentKwr = harden(
|
|
162
|
+
keys(amounts).reduce(
|
|
163
|
+
(acc, kw, i) =>
|
|
164
|
+
assign(acc, {
|
|
165
|
+
[kw]: /** @type {{ value: Amount }[]} */ (settledWithdrawals)[i]
|
|
166
|
+
.value,
|
|
167
|
+
}),
|
|
168
|
+
{},
|
|
169
|
+
),
|
|
170
|
+
);
|
|
171
|
+
const depositResponse = await depositToSeat(
|
|
172
|
+
zcf,
|
|
173
|
+
destSeat,
|
|
174
|
+
amounts,
|
|
175
|
+
paymentKwr,
|
|
176
|
+
);
|
|
177
|
+
console.debug(depositResponse);
|
|
178
|
+
});
|
|
78
179
|
|
|
79
180
|
return harden({
|
|
80
181
|
localTransfer,
|
|
182
|
+
withdrawToSeat,
|
|
81
183
|
});
|
|
82
184
|
};
|
|
185
|
+
|
|
83
186
|
/** @typedef {ReturnType<typeof makeZoeTools>} ZoeTools */
|