@agoric/orchestration 0.1.1-dev-3aa5d66.0 → 0.1.1-dev-80db38c.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/orchestration",
3
- "version": "0.1.1-dev-3aa5d66.0+3aa5d66",
3
+ "version": "0.1.1-dev-80db38c.0+80db38c",
4
4
  "description": "Chain abstraction for Agoric's orchestration clients",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -33,20 +33,20 @@
33
33
  },
34
34
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
35
35
  "dependencies": {
36
- "@agoric/assert": "0.6.1-dev-3aa5d66.0+3aa5d66",
37
- "@agoric/async-flow": "0.1.1-dev-3aa5d66.0+3aa5d66",
38
- "@agoric/cosmic-proto": "0.4.1-dev-3aa5d66.0+3aa5d66",
39
- "@agoric/ertp": "0.16.3-dev-3aa5d66.0+3aa5d66",
40
- "@agoric/internal": "0.3.3-dev-3aa5d66.0+3aa5d66",
41
- "@agoric/network": "0.1.1-dev-3aa5d66.0+3aa5d66",
42
- "@agoric/notifier": "0.6.3-dev-3aa5d66.0+3aa5d66",
43
- "@agoric/store": "0.9.3-dev-3aa5d66.0+3aa5d66",
44
- "@agoric/time": "0.3.3-dev-3aa5d66.0+3aa5d66",
45
- "@agoric/vat-data": "0.5.3-dev-3aa5d66.0+3aa5d66",
46
- "@agoric/vats": "0.15.2-dev-3aa5d66.0+3aa5d66",
47
- "@agoric/vow": "0.1.1-dev-3aa5d66.0+3aa5d66",
48
- "@agoric/zoe": "0.26.3-dev-3aa5d66.0+3aa5d66",
49
- "@agoric/zone": "0.2.3-dev-3aa5d66.0+3aa5d66",
36
+ "@agoric/assert": "0.6.1-dev-80db38c.0+80db38c",
37
+ "@agoric/async-flow": "0.1.1-dev-80db38c.0+80db38c",
38
+ "@agoric/cosmic-proto": "0.4.1-dev-80db38c.0+80db38c",
39
+ "@agoric/ertp": "0.16.3-dev-80db38c.0+80db38c",
40
+ "@agoric/internal": "0.3.3-dev-80db38c.0+80db38c",
41
+ "@agoric/network": "0.1.1-dev-80db38c.0+80db38c",
42
+ "@agoric/notifier": "0.6.3-dev-80db38c.0+80db38c",
43
+ "@agoric/store": "0.9.3-dev-80db38c.0+80db38c",
44
+ "@agoric/time": "0.3.3-dev-80db38c.0+80db38c",
45
+ "@agoric/vat-data": "0.5.3-dev-80db38c.0+80db38c",
46
+ "@agoric/vats": "0.15.2-dev-80db38c.0+80db38c",
47
+ "@agoric/vow": "0.1.1-dev-80db38c.0+80db38c",
48
+ "@agoric/zoe": "0.26.3-dev-80db38c.0+80db38c",
49
+ "@agoric/zone": "0.2.3-dev-80db38c.0+80db38c",
50
50
  "@endo/base64": "^1.0.5",
51
51
  "@endo/far": "^1.1.2",
52
52
  "@endo/marshal": "^1.5.0",
@@ -90,5 +90,5 @@
90
90
  "typeCoverage": {
91
91
  "atLeast": 97.1
92
92
  },
93
- "gitHead": "3aa5d6635dd781372c3c43ae04512773bf4a84c0"
93
+ "gitHead": "80db38cafed64c67a087c38bda5dd3373564e50e"
94
94
  }
@@ -5,7 +5,6 @@
5
5
  * @import {LocalChain} from '@agoric/vats/src/localchain.js';
6
6
  * @import {OrchestrationService} from '../service.js';
7
7
  * @import {NameHub} from '@agoric/vats';
8
- * @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
9
8
  * @import {Remote} from '@agoric/vow';
10
9
  */
11
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AAEH,kEAKE;AASK,2BANI,GAAG,eACH,mBAAmB,GAAG;IAChC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;QAgGZ;;;WAGG;4BAFQ,eAAe,kBACf,iBAAiB;;GAmBjC;kCA1IY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAjBsB,kBAAkB;qCACS,eAAe;uCAAf,eAAe;gCAEvC,gCAAgC;4BAIpC,aAAa;0CAHC,eAAe;kCAFX,cAAc;6BAG/B,cAAc"}
1
+ {"version":3,"file":"sendAnywhere.contract.d.ts","sourceRoot":"","sources":["sendAnywhere.contract.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AAEH,kEAKE;AASK,2BANI,GAAG,eACH,mBAAmB,GAAG;IAChC,UAAc,EAAE,UAAU,CAAC;CACxB,WACO,OAAO;;;;;QAyFZ;;;WAGG;4BAFQ,eAAe,kBACf,iBAAiB;;GAmBjC;kCAnIY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAhBsB,kBAAkB;qCACS,eAAe;uCAAf,eAAe;gCAEvC,gCAAgC;4BAGpC,aAAa;0CAFC,eAAe;kCAFX,cAAc;6BAG/B,cAAc"}
@@ -5,9 +5,9 @@ import { heapVowE as E } from '@agoric/vow/vat.js';
5
5
  import { AmountShape } from '@agoric/ertp';
6
6
  import { CosmosChainInfoShape } from '../typeGuards.js';
7
7
  import { provideOrchestration } from '../utils/start-helper.js';
8
+ import { makeResumableAgoricNamesHack } from '../exos/agoric-names-tools.js';
8
9
 
9
10
  const { entries } = Object;
10
- const { Fail } = assert;
11
11
 
12
12
  /**
13
13
  * @import {Baggage} from '@agoric/vat-data';
@@ -16,7 +16,6 @@ const { Fail } = assert;
16
16
  * @import {LocalChain} from '@agoric/vats/src/localchain.js';
17
17
  * @import {OrchestrationService} from '../service.js';
18
18
  * @import {NameHub} from '@agoric/vats';
19
- * @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js';
20
19
  * @import {Remote} from '@agoric/vow';
21
20
  */
22
21
 
@@ -45,36 +44,26 @@ export const SingleAmountRecord = M.and(
45
44
  * @param {Baggage} baggage
46
45
  */
47
46
  export const start = async (zcf, privateArgs, baggage) => {
48
- const { chainHub, orchestrate, zone } = provideOrchestration(
47
+ const { chainHub, orchestrate, vowTools, zone } = provideOrchestration(
49
48
  zcf,
50
49
  baggage,
51
50
  privateArgs,
52
51
  privateArgs.marshaller,
53
52
  );
53
+ const agoricNamesTools = makeResumableAgoricNamesHack(zone, {
54
+ agoricNames: privateArgs.agoricNames,
55
+ vowTools,
56
+ });
54
57
 
55
58
  /** @type {import('../orchestration-api.js').OrchestrationAccount<any>} */
56
59
  let contractAccount;
57
60
 
58
- const findBrandInVBank = async brand => {
59
- const assets = await E(
60
- // XXX heapVowE
61
- /** @type {Promise<Promise<NameHub<VBankAssetDetail>>>} */ (
62
- E(privateArgs.agoricNames).lookup('vbankAsset')
63
- ),
64
- ).values();
65
- const it = assets.find(a => a.brand === brand);
66
- if (!it) {
67
- throw Fail`brand ${brand} not in agoricNames.vbankAsset`;
68
- }
69
- return it;
70
- };
71
-
72
61
  /** @type {OfferHandler} */
73
62
  const sendIt = orchestrate(
74
63
  'sendIt',
75
- { zcf },
64
+ { zcf, agoricNamesTools },
76
65
  // eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
77
- async (orch, { zcf }, seat, offerArgs) => {
66
+ async (orch, { zcf, agoricNamesTools }, seat, offerArgs) => {
78
67
  mustMatch(
79
68
  offerArgs,
80
69
  harden({ chainName: M.scalar(), destAddr: M.string() }),
@@ -82,7 +71,10 @@ export const start = async (zcf, privateArgs, baggage) => {
82
71
  const { chainName, destAddr } = offerArgs;
83
72
  const { give } = seat.getProposal();
84
73
  const [[kw, amt]] = entries(give);
85
- const { denom } = await findBrandInVBank(amt.brand);
74
+ // XXX when() until membrane
75
+ const { denom } = await E.when(
76
+ agoricNamesTools.findBrandInVBank(amt.brand),
77
+ );
86
78
  const chain = await orch.getChain(chainName);
87
79
 
88
80
  // FIXME ok to use a heap var crossing the membrane scope this way?
@@ -0,0 +1,27 @@
1
+ export function makeResumableAgoricNamesHack(zone: Zone, { agoricNames, vowTools: { watch, asVow } }: {
2
+ agoricNames: Remote<NameHub>;
3
+ vowTools: VowTools;
4
+ }): import("@endo/exo").Guarded<{
5
+ /** @param {...string} args */
6
+ lookup(...args: string[]): Vow<any>;
7
+ /**
8
+ * Look up asset info, like denom, in agoricNames.vbankAsset using a
9
+ * Brand.
10
+ *
11
+ * Caches the query to agoricNames in the first call. Subsequent lookups
12
+ * are via cache unless a refetch is specified or a brand is not found.
13
+ *
14
+ * @param {Brand<'nat'>} brand
15
+ * @param {boolean} [refetch] if true, will invalidate the cache
16
+ * @returns {Vow<AssetInfo>}
17
+ */
18
+ findBrandInVBank(brand: Brand<"nat">, refetch?: boolean | undefined): Vow<AssetInfo>;
19
+ }>;
20
+ export type AgNamesTools = ReturnType<typeof makeResumableAgoricNamesHack>;
21
+ import type { Zone } from '@agoric/zone';
22
+ import type { NameHub } from '@agoric/vats';
23
+ import type { Remote } from '@agoric/internal';
24
+ import type { VowTools } from '@agoric/vow';
25
+ import type { Vow } from '@agoric/vow';
26
+ import type { AssetInfo } from '@agoric/vats/src/vat-bank.js';
27
+ //# sourceMappingURL=agoric-names-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agoric-names-tools.d.ts","sourceRoot":"","sources":["agoric-names-tools.js"],"names":[],"mappings":"AA4BO,mDAHI,IAAI,+CACJ;IAAE,WAAW,EAAE,OAAO,OAAO,CAAC,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;IA8CvD,8BAA8B;oBAAf,MAAM,EAAA;IAIrB;;;;;;;;;;OAUG;4BAHQ,KAAK,CAAC,KAAK,CAAC,kCAEV,IAAI,SAAS,CAAC;GAsBlC;2BACa,UAAU,CAAC,OAAO,4BAA4B,CAAC;0BAhGtC,cAAc;6BAJX,cAAc;4BAEf,kBAAkB;8BACX,aAAa;yBAAb,aAAa;+BAFjB,8BAA8B"}
@@ -0,0 +1,109 @@
1
+ import { VowShape } from '@agoric/vow';
2
+ import { E } from '@endo/far';
3
+ import { M, makeCopyMap } from '@endo/patterns';
4
+ import { BrandShape } from '@agoric/ertp';
5
+
6
+ const { Fail } = assert;
7
+
8
+ /**
9
+ * @import {NameHub} from '@agoric/vats';
10
+ * @import {AssetInfo} from '@agoric/vats/src/vat-bank.js';
11
+ * @import {Remote} from '@agoric/internal';
12
+ * @import {Vow, VowTools} from '@agoric/vow';
13
+ * @import {Zone} from '@agoric/zone';
14
+ */
15
+
16
+ /**
17
+ * Perform remote calls to agoricNames in membrane-friendly way. This is an
18
+ * interim approach until https://github.com/Agoric/agoric-sdk/issues/9541,
19
+ * https://github.com/Agoric/agoric-sdk/pull/9322, or
20
+ * https://github.com/Agoric/agoric-sdk/pull/9519.
21
+ *
22
+ * XXX only works once per zone.
23
+ *
24
+ * XXX consider exposing `has`, `entries`, `keys`, `values` from `NameHub`
25
+ *
26
+ * @param {Zone} zone
27
+ * @param {{ agoricNames: Remote<NameHub>; vowTools: VowTools }} powers
28
+ */
29
+ export const makeResumableAgoricNamesHack = (
30
+ zone,
31
+ { agoricNames, vowTools: { watch, asVow } },
32
+ ) => {
33
+ const makeResumableAgoricNamesHackKit = zone.exoClassKit(
34
+ 'ResumableAgoricNamesHack',
35
+ {
36
+ public: M.interface('ResumableAgoricNamesHackI', {
37
+ lookup: M.call().rest(M.arrayOf(M.string())).returns(VowShape),
38
+ findBrandInVBank: M.call(BrandShape)
39
+ .optional(M.boolean())
40
+ .returns(VowShape),
41
+ }),
42
+ vbankAssetEntriesWatcher: M.interface('vbankAssetEntriesWatcher', {
43
+ onFulfilled: M.call(M.arrayOf(M.record()))
44
+ .optional({ brand: BrandShape })
45
+ .returns(VowShape),
46
+ }),
47
+ },
48
+ () => ({
49
+ vbankAssetsByBrand: zone.mapStore('vbankAssetsByBrand', {
50
+ keyShape: BrandShape,
51
+ valueShape: M.any(),
52
+ }),
53
+ }),
54
+ {
55
+ vbankAssetEntriesWatcher: {
56
+ /**
57
+ * @param {AssetInfo[]} assets
58
+ * @param {{ brand: Brand<'nat'> }} ctx
59
+ */
60
+ onFulfilled(assets, { brand }) {
61
+ return asVow(() => {
62
+ const { vbankAssetsByBrand } = this.state;
63
+ vbankAssetsByBrand.addAll(
64
+ makeCopyMap(assets.map(a => [a.brand, a])),
65
+ );
66
+ vbankAssetsByBrand.has(brand) ||
67
+ Fail`brand ${brand} not in agoricNames.vbankAsset`;
68
+ return vbankAssetsByBrand.get(brand);
69
+ });
70
+ },
71
+ },
72
+ public: {
73
+ /** @param {...string} args */
74
+ lookup(...args) {
75
+ return watch(E(agoricNames).lookup(...args));
76
+ },
77
+ /**
78
+ * Look up asset info, like denom, in agoricNames.vbankAsset using a
79
+ * Brand.
80
+ *
81
+ * Caches the query to agoricNames in the first call. Subsequent lookups
82
+ * are via cache unless a refetch is specified or a brand is not found.
83
+ *
84
+ * @param {Brand<'nat'>} brand
85
+ * @param {boolean} [refetch] if true, will invalidate the cache
86
+ * @returns {Vow<AssetInfo>}
87
+ */
88
+ findBrandInVBank(brand, refetch) {
89
+ return asVow(() => {
90
+ const { vbankAssetsByBrand } = this.state;
91
+ if (vbankAssetsByBrand.has(brand) && !refetch) {
92
+ return vbankAssetsByBrand.get(brand);
93
+ }
94
+ const vbankAssetNameHubP = E(agoricNames).lookup('vbankAsset');
95
+ const vbankAssetEntriesP = E(vbankAssetNameHubP).values();
96
+ return watch(
97
+ vbankAssetEntriesP,
98
+ this.facets.vbankAssetEntriesWatcher,
99
+ { brand },
100
+ );
101
+ });
102
+ },
103
+ },
104
+ },
105
+ );
106
+ // XXX only works once per zone.
107
+ return makeResumableAgoricNamesHackKit().public;
108
+ };
109
+ /** @typedef {ReturnType<typeof makeResumableAgoricNamesHack>} AgNamesTools */
@@ -10,6 +10,13 @@ export function provideOrchestration(zcf: ZCF, baggage: Baggage, remotePowers: O
10
10
  }): import("@agoric/vow").Vow<import("../cosmos-api.js").IBCConnectionInfo>;
11
11
  getChainsAndConnection<C1 extends string, C2 extends string>(chainName1: C1, chainName2: C2): import("@agoric/vow").Vow<[ActualChainInfo<C1>, ActualChainInfo<C2>, import("../cosmos-api.js").IBCConnectionInfo]>;
12
12
  }>;
13
+ vowTools: {
14
+ when: <T, TResult1 = import("@agoric/vow").EUnwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow").EUnwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
15
+ watch: <T = any, TResult1 = T, TResult2 = never, C extends any[] = any[]>(specimenP: import("@agoric/vow").ERef<T | import("@agoric/vow").Vow<T>>, watcher?: import("@agoric/vow").Watcher<T, TResult1, TResult2, C> | undefined, ...watcherArgs: C) => import("@agoric/vow").Vow<Exclude<TResult1, void> | Exclude<TResult2, void> extends never ? TResult1 : Exclude<TResult1, void> | Exclude<TResult2, void>>;
16
+ makeVowKit: <T>() => import("@agoric/vow").VowKit<T>;
17
+ allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
18
+ asVow: <T extends unknown>(fn: (...args: any[]) => import("@agoric/vow").Vow<Awaited<T>> | Awaited<T>) => import("@agoric/vow").Vow<Awaited<T>>;
19
+ };
13
20
  zone: import("@agoric/base-zone").Zone;
14
21
  orchestrate<Return, Context, Args extends any[]>(durableName: string, ctx: Context, fn: (orc: import("../orchestration-api.js").Orchestrator, ctx2: Context, ...args: Args) => Promise<Return>): (...args: Args) => Promise<Return>;
15
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AAwCO,0CALI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;;;;;;;;;;;;;iKA4DT,GAAa,kCAED,GACxB;EAKC;kCApFY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAbsB,kBAAkB;gCAFf,gCAAgC;4BAIpC,aAAa;0CACC,eAAe;kCAJX,cAAc;6BAE/B,cAAc"}
1
+ {"version":3,"file":"start-helper.d.ts","sourceRoot":"","sources":["start-helper.js"],"names":[],"mappings":"AAwCO,0CALI,GAAG,WACH,OAAO,gBACP,mBAAmB,cACnB,UAAU;;;;;;;;;;;;;;;;;wCAyCjB,GAAF;;;iKAmBG,GAAa,kCAEI,GAAG;EAOxB;kCArFY;IACZ,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,WAAe,EAAE,OAAO,OAAO,CAAC,CAAC;CAC9B;6BAbsB,kBAAkB;gCAFf,gCAAgC;4BAIpC,aAAa;0CACC,eAAe;kCAJX,cAAc;6BAE/B,cAAc"}
@@ -45,8 +45,9 @@ export const provideOrchestration = (
45
45
  marshaller,
46
46
  ) => {
47
47
  const zone = makeDurableZone(baggage);
48
+ const { agoricNames, timerService } = remotePowers;
48
49
 
49
- const chainHub = makeChainHub(remotePowers.agoricNames);
50
+ const chainHub = makeChainHub(agoricNames);
50
51
 
51
52
  const vowTools = prepareVowTools(zone.subZone('vows'));
52
53
 
@@ -55,7 +56,7 @@ export const provideOrchestration = (
55
56
  zone,
56
57
  makeRecorderKit,
57
58
  zcf,
58
- remotePowers.timerService,
59
+ timerService,
59
60
  vowTools,
60
61
  chainHub,
61
62
  );
@@ -103,6 +104,6 @@ export const provideOrchestration = (
103
104
  vowTools,
104
105
  ...remotePowers,
105
106
  });
106
- return { ...facade, chainHub, zone };
107
+ return { ...facade, chainHub, vowTools, zone };
107
108
  };
108
109
  harden(provideOrchestration);