@agoric/orchestration 0.1.1-dev-0889e20.0 → 0.1.1-dev-81ac381.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/cosmos-api.d.ts +12 -0
- package/src/cosmos-api.d.ts.map +1 -1
- package/src/cosmos-api.ts +15 -0
- package/src/examples/auto-stake-it-tap-kit.d.ts +49 -0
- package/src/examples/auto-stake-it-tap-kit.d.ts.map +1 -0
- package/src/examples/auto-stake-it-tap-kit.js +157 -0
- package/src/examples/auto-stake-it.contract.d.ts +45 -0
- package/src/examples/auto-stake-it.contract.d.ts.map +1 -0
- package/src/examples/auto-stake-it.contract.js +188 -0
- package/src/examples/basic-flows.contract.d.ts +14 -5
- package/src/examples/basic-flows.contract.d.ts.map +1 -1
- package/src/examples/basic-flows.contract.js +74 -12
- package/src/examples/sendAnywhere.contract.d.ts +3 -9
- package/src/examples/sendAnywhere.contract.d.ts.map +1 -1
- package/src/examples/sendAnywhere.contract.js +3 -35
- package/src/examples/stakeBld.contract.d.ts +21 -0
- package/src/examples/stakeBld.contract.d.ts.map +1 -1
- package/src/exos/chain-hub-admin.d.ts +21 -0
- package/src/exos/chain-hub-admin.d.ts.map +1 -0
- package/src/exos/chain-hub-admin.js +56 -0
- package/src/exos/local-chain-facade.d.ts +42 -0
- package/src/exos/local-chain-facade.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.d.ts +22 -0
- package/src/exos/local-orchestration-account.d.ts.map +1 -1
- package/src/exos/local-orchestration-account.js +10 -3
- package/src/exos/portfolio-holder-kit.d.ts +64 -0
- package/src/exos/portfolio-holder-kit.d.ts.map +1 -0
- package/src/exos/portfolio-holder-kit.js +174 -0
- package/src/proposals/start-stakeBld.d.ts +21 -0
- package/src/proposals/start-stakeBld.d.ts.map +1 -1
- package/src/utils/time.d.ts +1 -0
- package/src/utils/time.d.ts.map +1 -1
- package/src/utils/time.js +1 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { M, mustMatch } from '@endo/patterns';
|
|
2
|
+
import { E } from '@endo/far';
|
|
3
|
+
import { Fail } from '@endo/errors';
|
|
4
|
+
import { PublicTopicShape } from '@agoric/zoe/src/contractSupport/topics.js';
|
|
5
|
+
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
6
|
+
import { VowShape } from '@agoric/vow';
|
|
7
|
+
|
|
8
|
+
const { fromEntries } = Object;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @import {HostOf} from '@agoric/async-flow';
|
|
12
|
+
* @import {MapStore} from '@agoric/store';
|
|
13
|
+
* @import {VowTools} from '@agoric/vow';
|
|
14
|
+
* @import {ResolvedPublicTopic} from '@agoric/zoe/src/contractSupport/topics.js';
|
|
15
|
+
* @import {Zone} from '@agoric/zone';
|
|
16
|
+
* @import {OrchestrationAccount, OrchestrationAccountI} from '@agoric/orchestration';
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* accounts: MapStore<string, OrchestrationAccount<any>>;
|
|
22
|
+
* publicTopics: MapStore<string, ResolvedPublicTopic<unknown>>;
|
|
23
|
+
* }} PortfolioHolderState
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const ChainNameShape = M.string();
|
|
27
|
+
|
|
28
|
+
const AccountEntriesShape = M.arrayOf([
|
|
29
|
+
M.string(),
|
|
30
|
+
M.remotable('OrchestrationAccount'),
|
|
31
|
+
]);
|
|
32
|
+
const PublicTopicEntriesShape = M.arrayOf([M.string(), PublicTopicShape]);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Kit that holds several OrchestrationAccountKits and returns a invitation
|
|
36
|
+
* makers.
|
|
37
|
+
*
|
|
38
|
+
* @param {Zone} zone
|
|
39
|
+
* @param {VowTools} vowTools
|
|
40
|
+
*/
|
|
41
|
+
const preparePortfolioHolderKit = (zone, { asVow, when }) => {
|
|
42
|
+
return zone.exoClassKit(
|
|
43
|
+
'PortfolioHolderKit',
|
|
44
|
+
{
|
|
45
|
+
invitationMakers: M.interface('InvitationMakers', {
|
|
46
|
+
MakeInvitation: M.call(
|
|
47
|
+
ChainNameShape,
|
|
48
|
+
M.string(),
|
|
49
|
+
M.arrayOf(M.any()),
|
|
50
|
+
).returns(M.promise()),
|
|
51
|
+
}),
|
|
52
|
+
holder: M.interface('Holder', {
|
|
53
|
+
asContinuingOffer: M.call().returns(VowShape),
|
|
54
|
+
getPublicTopics: M.call().returns(VowShape),
|
|
55
|
+
getAccount: M.call(ChainNameShape).returns(VowShape),
|
|
56
|
+
addAccount: M.call(
|
|
57
|
+
ChainNameShape,
|
|
58
|
+
M.remotable(),
|
|
59
|
+
PublicTopicShape,
|
|
60
|
+
).returns(VowShape),
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* @param {Iterable<[string, OrchestrationAccount<any>]>} accountEntries
|
|
65
|
+
* @param {Iterable<[string, ResolvedPublicTopic<unknown>]>} publicTopicEntries
|
|
66
|
+
*/
|
|
67
|
+
(accountEntries, publicTopicEntries) => {
|
|
68
|
+
mustMatch(accountEntries, AccountEntriesShape, 'must provide accounts');
|
|
69
|
+
mustMatch(
|
|
70
|
+
publicTopicEntries,
|
|
71
|
+
PublicTopicEntriesShape,
|
|
72
|
+
'must provide public topics',
|
|
73
|
+
);
|
|
74
|
+
const accounts = harden(
|
|
75
|
+
makeScalarBigMapStore('accounts', { durable: true }),
|
|
76
|
+
);
|
|
77
|
+
const publicTopics = harden(
|
|
78
|
+
makeScalarBigMapStore('publicTopics', { durable: true }),
|
|
79
|
+
);
|
|
80
|
+
accounts.addAll(accountEntries);
|
|
81
|
+
publicTopics.addAll(publicTopicEntries);
|
|
82
|
+
return /** @type {PortfolioHolderState} */ (
|
|
83
|
+
harden({
|
|
84
|
+
accounts,
|
|
85
|
+
publicTopics,
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
invitationMakers: {
|
|
91
|
+
/**
|
|
92
|
+
* @template {unknown[]} IA
|
|
93
|
+
* @param {string} chainName key where the account is stored
|
|
94
|
+
* @param {string} action invitation maker name, e.g. 'Delegate'
|
|
95
|
+
* @param {IA} invitationArgs
|
|
96
|
+
* @returns {Promise<Invitation<unknown, IA>>}
|
|
97
|
+
*/
|
|
98
|
+
MakeInvitation(chainName, action, invitationArgs) {
|
|
99
|
+
const { accounts } = this.state;
|
|
100
|
+
accounts.has(chainName) || Fail`no account found for ${chainName}`;
|
|
101
|
+
const account = accounts.get(chainName);
|
|
102
|
+
return when(E(account).asContinuingOffer(), ({ invitationMakers }) =>
|
|
103
|
+
E(invitationMakers)[action](...invitationArgs),
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
holder: {
|
|
108
|
+
// FIXME /** @type {HostOf<OrchestrationAccountI['asContinuingOffer']>} */
|
|
109
|
+
asContinuingOffer() {
|
|
110
|
+
return asVow(() => {
|
|
111
|
+
const { invitationMakers } = this.facets;
|
|
112
|
+
const { publicTopics } = this.state;
|
|
113
|
+
return harden({
|
|
114
|
+
publicSubscribers: fromEntries(publicTopics.entries()),
|
|
115
|
+
invitationMakers,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
// FIXME /** @type {HostOf<OrchestrationAccountI['getPublicTopics']>} */
|
|
120
|
+
getPublicTopics() {
|
|
121
|
+
return asVow(() => {
|
|
122
|
+
const { publicTopics } = this.state;
|
|
123
|
+
return harden(fromEntries(publicTopics.entries()));
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* @param {string} chainName key where the account is stored
|
|
128
|
+
* @param {OrchestrationAccount<any>} account
|
|
129
|
+
* @param {ResolvedPublicTopic<unknown>} publicTopic
|
|
130
|
+
*/
|
|
131
|
+
addAccount(chainName, account, publicTopic) {
|
|
132
|
+
return asVow(() => {
|
|
133
|
+
if (this.state.accounts.has(chainName)) {
|
|
134
|
+
throw Fail`account already exists for ${chainName}`;
|
|
135
|
+
}
|
|
136
|
+
zone.isStorable(account) ||
|
|
137
|
+
Fail`account for ${chainName} must be storable`;
|
|
138
|
+
zone.isStorable(publicTopic) ||
|
|
139
|
+
Fail`publicTopic for ${chainName} must be storable`;
|
|
140
|
+
|
|
141
|
+
this.state.publicTopics.init(chainName, publicTopic);
|
|
142
|
+
this.state.accounts.init(chainName, account);
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* @param {string} chainName key where the account is stored
|
|
147
|
+
*/
|
|
148
|
+
getAccount(chainName) {
|
|
149
|
+
return asVow(() => this.state.accounts.get(chainName));
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A portfolio holder stores two or more OrchestrationAccounts and combines
|
|
158
|
+
* ContinuingOfferResult's from each into a single result.
|
|
159
|
+
*
|
|
160
|
+
* XXX consider an interface for extending the exo maker with additional
|
|
161
|
+
* invitation makers.
|
|
162
|
+
*
|
|
163
|
+
* @param {Zone} zone
|
|
164
|
+
* @param {VowTools} vowTools
|
|
165
|
+
* @returns {(
|
|
166
|
+
* ...args: Parameters<ReturnType<typeof preparePortfolioHolderKit>>
|
|
167
|
+
* ) => ReturnType<ReturnType<typeof preparePortfolioHolderKit>>['holder']}
|
|
168
|
+
*/
|
|
169
|
+
export const preparePortfolioHolder = (zone, vowTools) => {
|
|
170
|
+
const makeKit = preparePortfolioHolderKit(zone, vowTools);
|
|
171
|
+
return (...args) => makeKit(...args).holder;
|
|
172
|
+
};
|
|
173
|
+
/** @typedef {ReturnType<typeof preparePortfolioHolder>} MakePortfolioHolder */
|
|
174
|
+
/** @typedef {ReturnType<MakePortfolioHolder>} PortfolioHolder */
|
|
@@ -32,6 +32,27 @@ export function startStakeBld({ consume: { agoricNames: agoricNamesP, board, cha
|
|
|
32
32
|
send(toAccount: any, amount: any): import("@agoric/vow").Vow<never>;
|
|
33
33
|
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>;
|
|
34
34
|
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): import("@agoric/vow").Vow<void extends import("@endo/pass-style").Passable ? import("@endo/pass-style").Passable & void : import("@agoric/async-flow").HostInterface<void>>;
|
|
35
|
+
monitorTransfers(tap: import("@agoric/vats/src/bridge-target.js").TargetApp): import("@agoric/vow").Vow<import("@agoric/vats/src/bridge-target.js").TargetRegistration | import("@agoric/vow").Vow<import("@agoric/vats/src/bridge-target.js").TargetRegistration> extends import("@endo/pass-style").Passable ? (string & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (string & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
36
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
37
|
+
}) | (number & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (number & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
38
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
39
|
+
}) | (bigint & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (false & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (false & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
40
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
41
|
+
}) | (true & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (true & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
42
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
43
|
+
}) | (symbol & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (symbol & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
44
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
45
|
+
}) | (import("@endo/pass-style").RemotableObject<string> & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (Promise<any> & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (Promise<any> & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
46
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
47
|
+
}) | (Error & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (Error & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
48
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
49
|
+
}) | (import("@endo/pass-style").CopyArrayI<import("@endo/pass-style").PassableCap, Error> & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (import("@endo/pass-style").CopyArrayI<import("@endo/pass-style").PassableCap, Error> & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
50
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
51
|
+
}) | (import("@endo/pass-style").CopyRecordI<import("@endo/pass-style").PassableCap, Error> & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (import("@endo/pass-style").CopyRecordI<import("@endo/pass-style").PassableCap, Error> & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
52
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
53
|
+
}) | (import("@endo/pass-style").CopyTaggedI<import("@endo/pass-style").PassableCap, Error> & import("@agoric/vats/src/bridge-target.js").TargetRegistration) | (import("@endo/pass-style").CopyTaggedI<import("@endo/pass-style").PassableCap, Error> & import("@endo/pass-style").PassStyled<"tagged", "Vow"> & {
|
|
54
|
+
payload: import("@agoric/vow").VowPayload<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
55
|
+
}) : import("@agoric/async-flow").HostInterface<import("@agoric/vats/src/bridge-target.js").TargetRegistration | import("@agoric/vow").Vow<import("@agoric/vats/src/bridge-target.js").TargetRegistration>>>;
|
|
35
56
|
}>>;
|
|
36
57
|
makeAccountInvitationMaker(): Promise<Invitation<import("@agoric/vow").Vow<import("@agoric/async-flow").HostInterface<import("../utils/zoe-tools.js").ResolvedContinuingOfferResult>>, undefined>>;
|
|
37
58
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-stakeBld.d.ts","sourceRoot":"","sources":["start-stakeBld.js"],"names":[],"mappings":"AAkBO,6TAVI,eAAe,GAAG;IAC5B,YAAgB,EAAE;QAClB,OAAa,EAAE;YACf,QAAgB,EAAE,YAAY,CAC9B;;;;;;+BAiCqB,kBAAiB
|
|
1
|
+
{"version":3,"file":"start-stakeBld.d.ts","sourceRoot":"","sources":["start-stakeBld.js"],"names":[],"mappings":"AAkBO,6TAVI,eAAe,GAAG;IAC5B,YAAgB,EAAE;QAClB,OAAa,EAAE;YACf,QAAgB,EAAE,YAAY,CAC9B;;;;;;+BAiCqB,kBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAjC2B,CACxD,CAAC;SACH,CAAC;KACH,CAAC;CACH,iBAwDH;AAGM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BN;sBApGqB,gCAAgC"}
|
package/src/utils/time.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export function makeTimestampHelper(timer: Remote<TimerService>): {
|
|
|
23
23
|
*/
|
|
24
24
|
export const SECONDS_PER_MINUTE: 60n;
|
|
25
25
|
export const MILLISECONDS_PER_SECOND: 1000n;
|
|
26
|
+
export const NANOSECONDS_PER_MILLISECOND: 1000000n;
|
|
26
27
|
export const NANOSECONDS_PER_SECOND: 1000000000n;
|
|
27
28
|
export type TimestampHelper = Awaited<ReturnType<typeof makeTimestampHelper>>;
|
|
28
29
|
import type { TimerService } from '@agoric/time';
|
package/src/utils/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["time.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["time.js"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,2CAFW,OAAO,YAAY,CAAC;IAY3B;;;;;;;;;;OAUG;0EAFU,OAAO,CAAC,MAAM,CAAC;EAiB/B;AAlDD;;;GAGG;AAEH,qCAAsC;AACtC,4CAA6C;AAC7C,mDAAsD;AACtD,iDAAqD;8BA4CvC,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;kCAnDE,cAAc;4BACpD,kBAAkB;wCADoB,cAAc"}
|
package/src/utils/time.js
CHANGED