@agoric/orchestration 0.1.1-dev-27cc9b8.0 → 0.1.1-dev-96c19f5.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.
Files changed (33) hide show
  1. package/package.json +15 -15
  2. package/src/chain-info.d.ts.map +1 -1
  3. package/src/chain-info.js +8 -16
  4. package/src/examples/sendAnywhere.contract.d.ts +74 -0
  5. package/src/examples/sendAnywhere.contract.d.ts.map +1 -0
  6. package/src/examples/sendAnywhere.contract.js +168 -0
  7. package/src/examples/stakeBld.contract.d.ts +0 -2
  8. package/src/examples/stakeBld.contract.d.ts.map +1 -1
  9. package/src/examples/stakeBld.contract.js +3 -11
  10. package/src/examples/swapExample.contract.d.ts +1 -0
  11. package/src/examples/swapExample.contract.d.ts.map +1 -1
  12. package/src/examples/swapExample.contract.js +18 -1
  13. package/src/examples/unbondExample.contract.d.ts +3 -1
  14. package/src/examples/unbondExample.contract.d.ts.map +1 -1
  15. package/src/examples/unbondExample.contract.js +16 -1
  16. package/src/exos/local-chain-account-kit.d.ts +11 -35
  17. package/src/exos/local-chain-account-kit.d.ts.map +1 -1
  18. package/src/exos/local-chain-account-kit.js +15 -18
  19. package/src/facade.d.ts +3 -19
  20. package/src/facade.d.ts.map +1 -1
  21. package/src/facade.js +22 -52
  22. package/src/proposals/start-stakeBld.d.ts +0 -1
  23. package/src/proposals/start-stakeBld.d.ts.map +1 -1
  24. package/src/proposals/start-stakeBld.js +1 -3
  25. package/src/typeGuards.d.ts +4 -0
  26. package/src/typeGuards.d.ts.map +1 -1
  27. package/src/typeGuards.js +31 -1
  28. package/src/utils/chainHub.d.ts +51 -0
  29. package/src/utils/chainHub.d.ts.map +1 -0
  30. package/src/utils/chainHub.js +136 -0
  31. package/src/utils/time.d.ts +4 -7
  32. package/src/utils/time.d.ts.map +1 -1
  33. package/src/utils/time.js +15 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/orchestration",
3
- "version": "0.1.1-dev-27cc9b8.0+27cc9b8",
3
+ "version": "0.1.1-dev-96c19f5.0+96c19f5",
4
4
  "description": "Chain abstraction for Agoric's orchestration clients",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -31,19 +31,19 @@
31
31
  },
32
32
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
33
33
  "dependencies": {
34
- "@agoric/assert": "0.6.1-dev-27cc9b8.0+27cc9b8",
35
- "@agoric/cosmic-proto": "0.4.1-dev-27cc9b8.0+27cc9b8",
36
- "@agoric/ertp": "0.16.3-dev-27cc9b8.0+27cc9b8",
37
- "@agoric/internal": "0.3.3-dev-27cc9b8.0+27cc9b8",
38
- "@agoric/network": "0.1.1-dev-27cc9b8.0+27cc9b8",
39
- "@agoric/notifier": "0.6.3-dev-27cc9b8.0+27cc9b8",
40
- "@agoric/store": "0.9.3-dev-27cc9b8.0+27cc9b8",
41
- "@agoric/time": "0.3.3-dev-27cc9b8.0+27cc9b8",
42
- "@agoric/vat-data": "0.5.3-dev-27cc9b8.0+27cc9b8",
43
- "@agoric/vats": "0.15.2-dev-27cc9b8.0+27cc9b8",
44
- "@agoric/vow": "0.1.1-dev-27cc9b8.0+27cc9b8",
45
- "@agoric/zoe": "0.26.3-dev-27cc9b8.0+27cc9b8",
46
- "@agoric/zone": "0.2.3-dev-27cc9b8.0+27cc9b8",
34
+ "@agoric/assert": "0.6.1-dev-96c19f5.0+96c19f5",
35
+ "@agoric/cosmic-proto": "0.4.1-dev-96c19f5.0+96c19f5",
36
+ "@agoric/ertp": "0.16.3-dev-96c19f5.0+96c19f5",
37
+ "@agoric/internal": "0.3.3-dev-96c19f5.0+96c19f5",
38
+ "@agoric/network": "0.1.1-dev-96c19f5.0+96c19f5",
39
+ "@agoric/notifier": "0.6.3-dev-96c19f5.0+96c19f5",
40
+ "@agoric/store": "0.9.3-dev-96c19f5.0+96c19f5",
41
+ "@agoric/time": "0.3.3-dev-96c19f5.0+96c19f5",
42
+ "@agoric/vat-data": "0.5.3-dev-96c19f5.0+96c19f5",
43
+ "@agoric/vats": "0.15.2-dev-96c19f5.0+96c19f5",
44
+ "@agoric/vow": "0.1.1-dev-96c19f5.0+96c19f5",
45
+ "@agoric/zoe": "0.26.3-dev-96c19f5.0+96c19f5",
46
+ "@agoric/zone": "0.2.3-dev-96c19f5.0+96c19f5",
47
47
  "@endo/base64": "^1.0.5",
48
48
  "@endo/far": "^1.1.2",
49
49
  "@endo/marshal": "^1.5.0",
@@ -84,5 +84,5 @@
84
84
  "typeCoverage": {
85
85
  "atLeast": 97.1
86
86
  },
87
- "gitHead": "27cc9b8be59abb048f1ea226b96697c3dccc4d0f"
87
+ "gitHead": "96c19f54bd17fd616883713d372a9dc8ca0140f9"
88
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"chain-info.d.ts","sourceRoot":"","sources":["chain-info.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHO,yDAHI,IAAI,CAAC,OAAO,cAAc,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,OACpD,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,iBAazC;;qCA1H+C,YAAY;kCAAZ,YAAY"}
1
+ {"version":3,"file":"chain-info.d.ts","sourceRoot":"","sources":["chain-info.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHO,yDAHI,IAAI,CAAC,OAAO,cAAc,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,OACpD,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,iBAOzC;;qCAnHgD,YAAY;kCAAZ,YAAY"}
package/src/chain-info.js CHANGED
@@ -2,11 +2,9 @@
2
2
 
3
3
  /** @file temporary static lookup of chain info */
4
4
 
5
- import { E } from '@endo/far';
5
+ import { registerChain } from './utils/chainHub.js';
6
6
 
7
- /**
8
- * @import {CosmosChainInfo, EthChainInfo} from './types.js';
9
- */
7
+ /** @import {CosmosChainInfo, EthChainInfo} from './types.js'; */
10
8
 
11
9
  /** @typedef {CosmosChainInfo | EthChainInfo} ChainInfo */
12
10
 
@@ -83,7 +81,7 @@ export const wellKnownChainInfo =
83
81
  stakingTokens: [{ denom: 'ustride' }],
84
82
  },
85
83
  cosmos: {
86
- chainId: 'cosmoshub-4',
84
+ chainId: 'cosmoslocal',
87
85
  connections: {},
88
86
  icaEnabled: true,
89
87
  icqEnabled: true,
@@ -101,7 +99,7 @@ export const wellKnownChainInfo =
101
99
  stakingTokens: [{ denom: 'utia' }],
102
100
  },
103
101
  osmosis: {
104
- chainId: 'osmosis-1',
102
+ chainId: 'osmosislocal',
105
103
  connections: {},
106
104
  icaEnabled: true,
107
105
  icqEnabled: true,
@@ -117,14 +115,8 @@ export const wellKnownChainInfo =
117
115
  * @param {(...messages: string[]) => void} log
118
116
  */
119
117
  export const registerChainNamespace = async (agoricNamesAdmin, log) => {
120
- const { nameAdmin } = await E(agoricNamesAdmin).provideChild('chain');
121
-
122
- const registrationPromises = Object.entries(wellKnownChainInfo).map(
123
- async ([name, info]) => {
124
- log(`registering chain ${name}`);
125
- return E(nameAdmin).update(name, info);
126
- },
127
- );
128
-
129
- await Promise.all(registrationPromises);
118
+ for await (const [name, info] of Object.entries(wellKnownChainInfo)) {
119
+ log(`registering agoricNames chain.${name}`);
120
+ await registerChain(agoricNamesAdmin, name, info);
121
+ }
130
122
  };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @import {Baggage} from '@agoric/vat-data';
3
+ * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
4
+ * @import {TimerService, TimerBrand} from '@agoric/time';
5
+ * @import {LocalChain} from '@agoric/vats/src/localchain.js';
6
+ * @import {OrchestrationService} from '../service.js';
7
+ * @import {NameHub} from '@agoric/vats';
8
+ * @import {Remote} from '@agoric/vow';
9
+ */
10
+ /**
11
+ * @typedef {{
12
+ * localchain: Remote<LocalChain>;
13
+ * orchestrationService: Remote<OrchestrationService>;
14
+ * storageNode: Remote<StorageNode>;
15
+ * timerService: Remote<TimerService>;
16
+ * agoricNames: Remote<NameHub>;
17
+ * }} OrchestrationPowers
18
+ */
19
+ export const SingleAmountRecord: import("@endo/patterns").Matcher;
20
+ export function start(zcf: ZCF, privateArgs: OrchestrationPowers & {
21
+ marshaller: Marshaller;
22
+ }, baggage: Baggage): Promise<{
23
+ publicFacet: import("@endo/exo").Guarded<{
24
+ makeSendInvitation(): Promise<Invitation<unknown, never>>;
25
+ }>;
26
+ creatorFacet: import("@endo/exo").Guarded<{
27
+ /**
28
+ * @param {CosmosChainInfo} chainInfo
29
+ * @param {IBCConnectionInfo} connectionInfo
30
+ */
31
+ addChain(chainInfo: CosmosChainInfo, connectionInfo: IBCConnectionInfo): Promise<string>;
32
+ }>;
33
+ }>;
34
+ export type OrchestrationPowers = {
35
+ localchain: Remote<import("@endo/exo").Guarded<{
36
+ makeAccount(): Promise<import("@endo/exo").Guarded<{
37
+ getAddress(): string;
38
+ getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
39
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
40
+ withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
41
+ executeTx<MT extends {
42
+ '@type': string;
43
+ }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
44
+ monitorTransfers(tap: any): Promise<any>;
45
+ }>>;
46
+ query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
47
+ '@type': string;
48
+ }>;
49
+ queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
50
+ error?: string | undefined;
51
+ reply: {
52
+ '@type': string;
53
+ };
54
+ }[]>;
55
+ }>>;
56
+ orchestrationService: Remote<import("@endo/exo").Guarded<{
57
+ makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("../cosmos-api").IcaAccount>;
58
+ provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
59
+ getLocalAddress(): `/ibc-port/${string}`;
60
+ getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
61
+ query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
62
+ }>>;
63
+ }>>;
64
+ storageNode: Remote<globalThis.StorageNode>;
65
+ timerService: Remote<TimerService>;
66
+ agoricNames: Remote<NameHub>;
67
+ };
68
+ import type { Baggage } from '@agoric/vat-data';
69
+ import type { CosmosChainInfo } from '../cosmos-api';
70
+ import type { IBCConnectionInfo } from '../cosmos-api';
71
+ import type { Remote } from '@agoric/vow';
72
+ import type { TimerService } from '@agoric/time';
73
+ import type { NameHub } from '@agoric/vats';
74
+ //# sourceMappingURL=sendAnywhere.contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AAEH,kEAKE;AASK,2BANI,GAAG,eACH,mBAAmB,GAAG;IAChC,UAAc,EAAE,UAAU,CAAC;CACxB;;;;;QAqGE;;;WAGG;;;GAgBR;;;;;8BArHgD,MAAM,KACvD,CAAC;6BAYG,QAAK,KACT,CAAC,mBACuB,OAAM;6BAuBM,OAAO,KAAK,CAAC;;;2BAczC,EAAA;;;uBAkE+lB,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;6BAvJx0C,kBAAkB;qCACS,eAAe;uCAAf,eAAe;4BAK3C,aAAa;kCAJK,cAAc;6BAG/B,cAAc"}
@@ -0,0 +1,168 @@
1
+ import { makeDurableZone } from '@agoric/zone/durable.js';
2
+ import { M, mustMatch } from '@endo/patterns';
3
+ import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
4
+ import { E } from '@endo/far';
5
+ import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
6
+
7
+ import { AmountShape } from '@agoric/ertp';
8
+ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
9
+ import { CosmosChainInfoShape } from '../typeGuards.js';
10
+ import { makeOrchestrationFacade } from '../facade.js';
11
+ import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';
12
+ import { makeChainHub } from '../utils/chainHub.js';
13
+
14
+ const { entries } = Object;
15
+ const { Fail } = assert;
16
+
17
+ /**
18
+ * @import {Baggage} from '@agoric/vat-data';
19
+ * @import {CosmosChainInfo, IBCConnectionInfo} from '../cosmos-api';
20
+ * @import {TimerService, TimerBrand} from '@agoric/time';
21
+ * @import {LocalChain} from '@agoric/vats/src/localchain.js';
22
+ * @import {OrchestrationService} from '../service.js';
23
+ * @import {NameHub} from '@agoric/vats';
24
+ * @import {Remote} from '@agoric/vow';
25
+ */
26
+
27
+ /**
28
+ * @typedef {{
29
+ * localchain: Remote<LocalChain>;
30
+ * orchestrationService: Remote<OrchestrationService>;
31
+ * storageNode: Remote<StorageNode>;
32
+ * timerService: Remote<TimerService>;
33
+ * agoricNames: Remote<NameHub>;
34
+ * }} OrchestrationPowers
35
+ */
36
+
37
+ export const SingleAmountRecord = M.and(
38
+ M.recordOf(M.string(), AmountShape, {
39
+ numPropertiesLimit: 1,
40
+ }),
41
+ M.not(harden({})),
42
+ );
43
+
44
+ /**
45
+ * @param {ZCF} zcf
46
+ * @param {OrchestrationPowers & {
47
+ * marshaller: Marshaller;
48
+ * }} privateArgs
49
+ * @param {Baggage} baggage
50
+ */
51
+ export const start = async (zcf, privateArgs, baggage) => {
52
+ const zone = makeDurableZone(baggage);
53
+
54
+ const chainHub = makeChainHub(privateArgs.agoricNames);
55
+
56
+ // TODO once durability is settled, provide some helpers to reduce boilerplate
57
+ const { marshaller, ...orchPowers } = privateArgs;
58
+ const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
59
+ const makeLocalChainAccountKit = prepareLocalChainAccountKit(
60
+ zone,
61
+ makeRecorderKit,
62
+ zcf,
63
+ privateArgs.timerService,
64
+ chainHub,
65
+ );
66
+ const { orchestrate } = makeOrchestrationFacade({
67
+ zcf,
68
+ zone,
69
+ chainHub,
70
+ makeLocalChainAccountKit,
71
+ ...orchPowers,
72
+ });
73
+
74
+ let contractAccount;
75
+
76
+ const findBrandInVBank = async brand => {
77
+ const assets = await E(
78
+ E(privateArgs.agoricNames).lookup('vbankAsset'),
79
+ ).values();
80
+ const it = assets.find(a => a.brand === brand);
81
+ it || Fail`brand ${brand} not in agoricNames.vbankAsset`;
82
+ return it;
83
+ };
84
+
85
+ /** @type {OfferHandler} */
86
+ const sendIt = orchestrate(
87
+ 'sendIt',
88
+ { zcf },
89
+ // eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
90
+ async (orch, { zcf }, seat, offerArgs) => {
91
+ mustMatch(
92
+ offerArgs,
93
+ harden({ chainName: M.scalar(), destAddr: M.string() }),
94
+ );
95
+ const { chainName, destAddr } = offerArgs;
96
+ const { give } = seat.getProposal();
97
+ const [[kw, amt]] = entries(give);
98
+ const { denom } = await findBrandInVBank(amt.brand);
99
+ const chain = await orch.getChain(chainName);
100
+
101
+ // XXX ok to use a heap var crossing the membrane scope this way?
102
+ if (!contractAccount) {
103
+ const agoricChain = await orch.getChain('agoric');
104
+ contractAccount = await agoricChain.makeAccount();
105
+ }
106
+
107
+ const info = await chain.getChainInfo();
108
+ const { chainId } = info;
109
+ const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give);
110
+ await E.when(pmtP, pmt => contractAccount.deposit(pmt, amt));
111
+ await contractAccount.transfer(
112
+ { denom, value: amt.value },
113
+ {
114
+ address: destAddr,
115
+ addressEncoding: 'bech32',
116
+ chainId,
117
+ },
118
+ );
119
+ },
120
+ );
121
+
122
+ const publicFacet = zone.exo(
123
+ 'Send PF',
124
+ M.interface('Send PF', {
125
+ makeSendInvitation: M.callWhen().returns(InvitationShape),
126
+ }),
127
+ {
128
+ makeSendInvitation() {
129
+ return zcf.makeInvitation(
130
+ sendIt,
131
+ 'send',
132
+ undefined,
133
+ M.splitRecord({ give: SingleAmountRecord }),
134
+ );
135
+ },
136
+ },
137
+ );
138
+
139
+ let nonce = 0n;
140
+ const ConnectionInfoShape = M.record(); // TODO
141
+ const creatorFacet = zone.exo(
142
+ 'Send CF',
143
+ M.interface('Send CF', {
144
+ addChain: M.callWhen(CosmosChainInfoShape, ConnectionInfoShape).returns(
145
+ M.scalar(),
146
+ ),
147
+ }),
148
+ {
149
+ /**
150
+ * @param {CosmosChainInfo} chainInfo
151
+ * @param {IBCConnectionInfo} connectionInfo
152
+ */
153
+ async addChain(chainInfo, connectionInfo) {
154
+ const chainKey = `${chainInfo.chainId}-${(nonce += 1n)}`;
155
+ const agoricChainInfo = await chainHub.getChainInfo('agoric');
156
+ chainHub.registerChain(chainKey, chainInfo);
157
+ chainHub.registerConnection(
158
+ agoricChainInfo.chainId,
159
+ chainInfo.chainId,
160
+ connectionInfo,
161
+ );
162
+ return chainKey;
163
+ },
164
+ },
165
+ );
166
+
167
+ return { publicFacet, creatorFacet };
168
+ };
@@ -24,7 +24,6 @@ export function start(zcf: ZCF, privateArgs: {
24
24
  marshaller: Marshaller;
25
25
  storageNode: StorageNode;
26
26
  timerService: TimerService;
27
- timerBrand: TimerBrand;
28
27
  }, baggage: import("@agoric/vat-data").Baggage): Promise<{
29
28
  publicFacet: import("@endo/exo").Guarded<{
30
29
  /**
@@ -130,5 +129,4 @@ export function start(zcf: ZCF, privateArgs: {
130
129
  import type { NameHub } from '@agoric/vats';
131
130
  import type { Remote } from '@agoric/internal';
132
131
  import type { TimerService } from '@agoric/time';
133
- import type { TimerBrand } from '@agoric/time';
134
132
  //# sourceMappingURL=stakeBld.contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"AAkCO,2BAXI,GAAG;;;;;8BA0BY,MAAM,KAAK,CAAC;6BAiBF,QAAQ,KAAK,CAAC,mBAA4B,OAAM;6BAkB7E,OACD,KAAE,CAAC;;;2BAaK,EAAE;;;uBAoCs5C,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;gBA3GhpE,UAAU;iBACT,WAAW;;;YAIlB,OAAO,kBAAkB,EAAE,OAAO;;QAkDvC;;WAEG;;;;;;;;;;+DAiCqB,OACtB,KAAH,CAAC;;;iEAgB0B,OAAO,KAAK,CAAC;;;;;;;;;;;+DAAs4B,OAAO,KAAK,CAAC;;;iEAA+yB,OAAO,KAAK,CAAC;iCApExtD,QAAQ,KAAK,CAAC,mBAA4B,OAAM;iCAkB7E,OACD,KAAE,CAAC;;;+BAaK,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;QAgBV;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBR;6BAvHyB,cAAc;4BACf,kBAAkB;kCACA,cAAc;gCAAd,cAAc"}
1
+ {"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"AAkCO,2BAVI,GAAG;;;;;8BA4Be,MAAM,KAAK,CAAC;6BAgB1B,QAAQ,KAAK,CAAC,mBACJ,OAAO;6BAaa,OAAO,KAAK,CAAC;;;2BAmBvC,EAAE;;;uBAyBooD,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;gBAlGn4E,UAAU;iBACT,WAAW;;YAGlB,OAAO,kBAAkB,EAAE,OAAO;;QA0CvC;;WAEG;;;;;;;;;;+DA2CA,OAAO,KAAK,CAAC;;;iEAOyX,OAAO,KAAK,CAAC;;;;;;;;;;;+DAAs4B,OAAO,KAAK,CAAC;;;iEAA+yB,OAAO,KAAK,CAAC;iCA1D5lE,QAAQ,KAAK,CAAC,mBACJ,OAAO;iCAaa,OAAO,KAAK,CAAC;;;+BAmBvC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;QAKf;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBR;6BA9GyB,cAAc;4BACf,kBAAkB;kCACZ,cAAc"}
@@ -10,11 +10,12 @@ import { E } from '@endo/far';
10
10
  import { deeplyFulfilled } from '@endo/marshal';
11
11
  import { M } from '@endo/patterns';
12
12
  import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';
13
+ import { makeChainHub } from '../utils/chainHub.js';
13
14
 
14
15
  /**
15
16
  * @import {NameHub} from '@agoric/vats';
16
17
  * @import {Remote} from '@agoric/internal';
17
- * @import {TimerBrand, TimerService} from '@agoric/time';
18
+ * @import {TimerService} from '@agoric/time';
18
19
  * @import {LocalChain} from '@agoric/vats/src/localchain.js';
19
20
  */
20
21
 
@@ -28,7 +29,6 @@ const trace = makeTracer('StakeBld');
28
29
  * marshaller: Marshaller;
29
30
  * storageNode: StorageNode;
30
31
  * timerService: TimerService;
31
- * timerBrand: TimerBrand;
32
32
  * }} privateArgs
33
33
  * @param {import('@agoric/vat-data').Baggage} baggage
34
34
  */
@@ -45,20 +45,12 @@ export const start = async (zcf, privateArgs, baggage) => {
45
45
  privateArgs.marshaller,
46
46
  );
47
47
 
48
- // FIXME in a second incarnation we can't make a remote call before defining all kinds
49
- // UNTIL https://github.com/Agoric/agoric-sdk/issues/8879
50
- const agoricChainInfo = await E(privateArgs.agoricNames).lookup(
51
- 'chain',
52
- 'agoric',
53
- );
54
-
55
48
  const makeLocalChainAccountKit = prepareLocalChainAccountKit(
56
49
  zone,
57
50
  makeRecorderKit,
58
51
  zcf,
59
52
  privateArgs.timerService,
60
- privateArgs.timerBrand,
61
- agoricChainInfo,
53
+ makeChainHub(privateArgs.agoricNames),
62
54
  );
63
55
 
64
56
  async function makeLocalAccountKit() {
@@ -46,6 +46,7 @@ export function start(zcf: ZCF, privateArgs: {
46
46
  }>>;
47
47
  storageNode: Remote<globalThis.StorageNode>;
48
48
  timerService: Remote<TimerService>;
49
+ marshaller: Marshaller;
49
50
  }, baggage: Baggage): Promise<{
50
51
  publicFacet: {
51
52
  makeSwapAndStakeInvitation: () => Promise<Invitation<unknown, {
@@ -1 +1 @@
1
- {"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAUrB;AASK,0CAHI,KAAK;;;EAIsC;AAa/C,2BAVI,GAAG;;;;;8BAIwC,MACjD,KAAG,CAAC;6BAmBA,QACL,KAAC,CAAC,mBACW,OAAO;6BAqBQ,OAAO,KAAK,CAAC;;;2BAgB9B,EAAE;;;uBAsCs1C,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;oBAhEjlE,MAAM,CAAC,KAAK,CAAC;;;;;oBAAb,MAAM,CAAC,KAAK,CAAC;;;;GA+D7B;6BA9HyB,cAAc;4BAHf,kBAAkB;gCAHwB,aAAa;kCACjD,cAAc;6BAInB,kBAAkB;4CALuB,aAAa"}
1
+ {"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AAaA;;;;;;;;GAQG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAWrB;AASK,0CAHI,KAAK;;;EAIsC;AAc/C,2BAXI,GAAG;;;;;8BAJV,MAAM,KAAK,CAAC;6BAec,QAAQ,KAAK,CAAC,mBACjC,OAAO;6BAyBd,OAAI,KAAK,CAAC;;;2BAqBgB,EAAE;;;uBAwD4uB,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;gBA3Gt/C,UAAU;;;;oBA2CV,MAAM,CAAC,KAAK,CAAC;;;;;oBAAb,MAAM,CAAC,KAAK,CAAC;;;;GA+D7B;6BA5IyB,cAAc;4BAHf,kBAAkB;gCAHwB,aAAa;kCACjD,cAAc;6BAInB,kBAAkB;4CALuB,aAAa"}
@@ -5,8 +5,11 @@ import { makeDurableZone } from '@agoric/zone/durable.js';
5
5
  import { Far } from '@endo/far';
6
6
  import { deeplyFulfilled } from '@endo/marshal';
7
7
  import { M, objectMap } from '@endo/patterns';
8
+ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
8
9
  import { makeOrchestrationFacade } from '../facade.js';
9
10
  import { orcUtils } from '../utils/orc.js';
11
+ import { makeChainHub } from '../utils/chainHub.js';
12
+ import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';
10
13
 
11
14
  /**
12
15
  * @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
@@ -25,6 +28,7 @@ export const meta = {
25
28
  localchain: M.remotable('localchain'),
26
29
  orchestrationService: M.or(M.remotable('orchestration'), null),
27
30
  storageNode: StorageNodeShape,
31
+ marshaller: M.remotable('marshaller'),
28
32
  timerService: M.or(TimerServiceShape, null),
29
33
  },
30
34
  upgradability: 'canUpgrade',
@@ -48,6 +52,7 @@ export const makeNatAmountShape = (brand, min) =>
48
52
  * orchestrationService: Remote<OrchestrationService>;
49
53
  * storageNode: Remote<StorageNode>;
50
54
  * timerService: Remote<TimerService>;
55
+ * marshaller: Marshaller;
51
56
  * }} privateArgs
52
57
  * @param {Baggage} baggage
53
58
  */
@@ -62,16 +67,28 @@ export const start = async (zcf, privateArgs, baggage) => {
62
67
  orchestrationService,
63
68
  storageNode,
64
69
  timerService,
70
+ marshaller,
65
71
  } = privateArgs;
66
72
 
73
+ const chainHub = makeChainHub(agoricNames);
74
+ const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
75
+ const makeLocalChainAccountKit = prepareLocalChainAccountKit(
76
+ zone,
77
+ makeRecorderKit,
78
+ zcf,
79
+ timerService,
80
+ chainHub,
81
+ );
82
+
67
83
  const { orchestrate } = makeOrchestrationFacade({
68
- agoricNames,
69
84
  localchain,
70
85
  orchestrationService,
71
86
  storageNode,
72
87
  timerService,
73
88
  zcf,
74
89
  zone,
90
+ chainHub,
91
+ makeLocalChainAccountKit,
75
92
  });
76
93
 
77
94
  /** deprecated historical example */
@@ -5,7 +5,8 @@ export function start(zcf: ZCF, privateArgs: {
5
5
  getAddress(): string;
6
6
  getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
7
7
  deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
8
- withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
8
+ withdraw(amount: Amount<// ??? should this be synchronous? depends on how names are resolved.
9
+ "nat">): Promise<globalThis.Payment<"nat">>;
9
10
  executeTx<MT extends {
10
11
  '@type': string;
11
12
  }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
@@ -30,6 +31,7 @@ export function start(zcf: ZCF, privateArgs: {
30
31
  }>>;
31
32
  }>>;
32
33
  storageNode: Remote<globalThis.StorageNode>;
34
+ marshaller: Marshaller;
33
35
  timerService: Remote<TimerService>;
34
36
  }, baggage: Baggage): Promise<{
35
37
  publicFacet: {
@@ -1 +1 @@
1
- {"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AA0BO,2BAVI,GAAG;;;;;8BAsCsB,MAAM,KAAK,CAAC;6BAUnC,QAAQ,KAAK,CAAC,mBAA2B,OAAO;6BAevD,OAAE,KAAK,CAAC;;;2BAiB+I,EAAE;;;uBAAg0E,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;GADztG;6BArFyB,cAAc;4BACf,kBAAkB;gCALwB,aAAa;kCACjD,cAAc;6BACnB,kBAAkB"}
1
+ {"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AA8BO,2BAXI,GAAG;;;;;8BAgCV,MAAC,KAAK,CAAC;6BAgBY,QAAO,KAAK,CAAC,mBACxB,OAAO;6BAYb,OADA,qEAAqE;YACrE,KADK,CAAC;;;2BAauB,EAAE;;;uBAmBo2D,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;gBAtFnnF,UAAU;;;;;;;;GAqF1B;6BAjGyB,cAAc;4BACf,kBAAkB;gCALwB,aAAa;kCACjD,cAAc;6BACnB,kBAAkB"}
@@ -1,7 +1,10 @@
1
1
  import { makeDurableZone } from '@agoric/zone/durable.js';
2
2
  import { Far } from '@endo/far';
3
3
  import { M } from '@endo/patterns';
4
+ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
4
5
  import { makeOrchestrationFacade } from '../facade.js';
6
+ import { makeChainHub } from '../utils/chainHub.js';
7
+ import { prepareLocalChainAccountKit } from '../exos/local-chain-account-kit.js';
5
8
 
6
9
  /**
7
10
  * @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
@@ -20,6 +23,7 @@ import { makeOrchestrationFacade } from '../facade.js';
20
23
  * localchain: Remote<LocalChain>;
21
24
  * orchestrationService: Remote<OrchestrationService>;
22
25
  * storageNode: Remote<StorageNode>;
26
+ * marshaller: Marshaller;
23
27
  * timerService: Remote<TimerService>;
24
28
  * }} privateArgs
25
29
  * @param {Baggage} baggage
@@ -30,18 +34,29 @@ export const start = async (zcf, privateArgs, baggage) => {
30
34
  localchain,
31
35
  orchestrationService,
32
36
  storageNode,
37
+ marshaller,
33
38
  timerService,
34
39
  } = privateArgs;
35
40
  const zone = makeDurableZone(baggage);
36
41
 
42
+ const chainHub = makeChainHub(agoricNames);
43
+ const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
44
+ const makeLocalChainAccountKit = prepareLocalChainAccountKit(
45
+ zone,
46
+ makeRecorderKit,
47
+ zcf,
48
+ privateArgs.timerService,
49
+ chainHub,
50
+ );
37
51
  const { orchestrate } = makeOrchestrationFacade({
38
- agoricNames,
39
52
  localchain,
40
53
  orchestrationService,
41
54
  storageNode,
42
55
  timerService,
43
56
  zcf,
44
57
  zone,
58
+ chainHub: makeChainHub(agoricNames),
59
+ makeLocalChainAccountKit,
45
60
  });
46
61
 
47
62
  /** @type {OfferHandler} */
@@ -1,17 +1,13 @@
1
- export function prepareLocalChainAccountKit(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF, timerService: TimerService, timerBrand: TimerBrand, agoricChainInfo: CosmosChainInfo): (args_0: {
1
+ export function prepareLocalChainAccountKit(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF, timerService: Remote<TimerService>, chainHub: {
2
+ registerChain(name: string, chainInfo: CosmosChainInfo): void;
3
+ getChainInfo(chainName: string): Promise<CosmosChainInfo>;
4
+ registerConnection(srcChainId: string, destChainId: string, connectionInfo: import("@agoric/orchestration").IBCConnectionInfo): void;
5
+ getConnectionInfo(srcChainId: string, destChainId: string): Promise<import("@agoric/orchestration").IBCConnectionInfo>;
6
+ }): (args_0: {
2
7
  account: import("@endo/exo").Guarded<{
3
8
  getAddress(): string;
4
9
  getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
5
- deposit(payment: Payment<"nat"
6
- /**
7
- * @param {Zone} zone
8
- * @param {MakeRecorderKit} makeRecorderKit
9
- * @param {ZCF} zcf
10
- * @param {TimerService} timerService
11
- * @param {TimerBrand} timerBrand
12
- * @param {CosmosChainInfo} agoricChainInfo
13
- */
14
- >, optAmountShape?: Pattern): Promise<globalThis.Amount>;
10
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
15
11
  withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
16
12
  executeTx<MT extends {
17
13
  '@type': string;
@@ -63,25 +59,14 @@ export function prepareLocalChainAccountKit(zone: Zone, makeRecorderKit: <T>(sto
63
59
  * transferred.
64
60
  */
65
61
  /** @type {LocalChainAccount['deposit']} */
66
- deposit(payment: Payment<"nat"
67
- /**
68
- * @param {Zone} zone
69
- * @param {MakeRecorderKit} makeRecorderKit
70
- * @param {ZCF} zcf
71
- * @param {TimerService} timerService
72
- * @param {TimerBrand} timerBrand
73
- * @param {CosmosChainInfo} agoricChainInfo
74
- */
75
- >, optAmountShape?: Pattern): Promise<globalThis.Amount>;
62
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
76
63
  /** @type {LocalChainAccount['withdraw']} */
77
64
  withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
78
65
  /** @type {LocalChainAccount['executeTx']} */
79
66
  executeTx<MT extends {
80
67
  '@type': string;
81
68
  }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]>>; }>;
82
- /**
83
- * @returns {ChainAddress['address']}
84
- */
69
+ /** @returns {ChainAddress['address']} */
85
70
  getAddress(): string;
86
71
  /**
87
72
  * @param {AmountArg} amount an ERTP {@link Amount} or a
@@ -103,16 +88,7 @@ export type State = {
103
88
  account: import("@endo/exo").Guarded<{
104
89
  getAddress(): string;
105
90
  getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
106
- deposit(payment: Payment<"nat"
107
- /**
108
- * @param {Zone} zone
109
- * @param {MakeRecorderKit} makeRecorderKit
110
- * @param {ZCF} zcf
111
- * @param {TimerService} timerService
112
- * @param {TimerBrand} timerBrand
113
- * @param {CosmosChainInfo} agoricChainInfo
114
- */
115
- >, optAmountShape?: Pattern): Promise<globalThis.Amount>;
91
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
116
92
  withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
117
93
  executeTx<MT extends {
118
94
  '@type': string;
@@ -125,7 +101,7 @@ export type LocalChainAccountKit = ReturnType<ReturnType<typeof prepareLocalChai
125
101
  import type { Zone } from '@agoric/zone';
126
102
  import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
127
103
  import type { TimerService } from '@agoric/time';
128
- import type { TimerBrand } from '@agoric/time';
104
+ import type { Remote } from '@agoric/internal';
129
105
  import type { CosmosChainInfo } from '@agoric/orchestration';
130
106
  import type { AmountArg } from '@agoric/orchestration';
131
107
  import type { ChainAddress } from '@agoric/orchestration';
@@ -1 +1 @@
1
- {"version":3,"file":"local-chain-account-kit.d.ts","sourceRoot":"","sources":["local-chain-account-kit.js"],"names":[],"mappings":"AAmEO,0FA2EG,WAAG,GAAE,QAAS,OACZ,WAAI,EAAE,MACjB,CAAa,WAAD,CAAC,CAAC,0HAlFJ,GAAG;;;0BAjB+B,MAAM,KAAK,CAAC;yBAWpB,QAAO,KAC1C;QAEF;;;;;;;WAOG;SARH,mBAGC,OAAM;yBAqBC,OAAO,KAAK,CAAC;;;uBAef,EACN;;;;iBAHe,WAAW;;;QAalB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAYxB;;;WAGG;qCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;QA0BxB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAsBxB;;;;WAIG;qCAHQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,IAAI,CAAC;QA2B1B;;;;WAIG;QACH,2CAA2C;yBAzJd,QAAO,KAC1C;QAEF;;;;;;;WAOG;SARH,mBAGC,OAAM;QAwJC,4CAA4C;yBAnI5C,OAAO,KAAK,CAAC;QAuIb,6CAA6C;;;uBAxH/C,EACN;QA4HQ;;WAEG;;QAIH;;;;;;;;WAQG;0GADU,OAAO,CAAC,IAAI,CAAC;;GA+CjC;;aA5Pa,MAAM;;;;;;0BAeyB,MAAM,KAAK,CAAC;yBAWpB,QAAO,KAC1C;QAEF;;;;;;;WAOG;SARH,mBAGC,OAAM;yBAqBC,OAAO,KAAK,CAAC;;;uBAef,EACN;;;;;mCAyLc,UAAU,CAAC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;0BAtQjD,cAAc;iCADU,6CAA6C;kCAEjD,cAAc;gCAAd,cAAc;qCAHsC,uBAAuB;+BAAvB,uBAAuB;kCAAvB,uBAAuB;2CAAvB,uBAAuB"}
1
+ {"version":3,"file":"local-chain-account-kit.d.ts","sourceRoot":"","sources":["local-chain-account-kit.js"],"names":[],"mappings":"AAoEO,0FAmEwB,WAAW,GAAE,QACpC,OACF,WACD,EAAE,MAAM,CAAC,WACL,CAAC,CAAC,0HA3EA,GAAG;;;;;;;;0BAlBG,MAAM,KAAK,CAAC;yBAUT,QAAS,KAAI,CAAC,mBAA2B,OAAO;yBAqBjD,OAAO,KAAK,CAAC;;;uBAgBlB,EAAE;;;;iBACD,WAAW;;;QAalB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAYxB;;;WAGG;qCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;QA0BxB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAsBxB;;;;WAIG;qCAHQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,IAAI,CAAC;QA2B1B;;;;WAIG;QACH,2CAA2C;yBAxJ/B,QAAS,KAAI,CAAC,mBAA2B,OAAO;QA4J5D,4CAA4C;yBAvIjC,OAAO,KAAK,CAAC;QA2IxB,6CAA6C;;;uBA3HvC,EAAE;QAgIR,yCAAyC;;QAIzC;;;;;;;;WAQG;0GADU,OAAO,CAAC,IAAI,CAAC;;GA+CjC;;aAvPa,MAAM;;;;;;0BAcH,MAAM,KAAK,CAAC;yBAUT,QAAS,KAAI,CAAC,mBAA2B,OAAO;yBAqBjD,OAAO,KAAK,CAAC;;;uBAgBlB,EAAE;;;;;mCA2LF,UAAU,CAAC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;0BAnQjD,cAAc;iCADU,6CAA6C;kCAGjD,cAAc;4BADhC,kBAAkB;qCAHoD,uBAAuB;+BAAvB,uBAAuB;kCAAvB,uBAAuB;2CAAvB,uBAAuB"}