@agoric/vats 0.15.2-dev-822ab08.0 → 0.15.2-dev-c11fecb.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/vats",
3
- "version": "0.15.2-dev-822ab08.0+822ab08",
3
+ "version": "0.15.2-dev-c11fecb.0+c11fecb",
4
4
  "description": "Agoric's Vat library",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -22,20 +22,20 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/assert": "0.6.1-dev-822ab08.0+822ab08",
26
- "@agoric/cosmic-proto": "0.4.1-dev-822ab08.0+822ab08",
27
- "@agoric/ertp": "0.16.3-dev-822ab08.0+822ab08",
28
- "@agoric/governance": "0.10.4-dev-822ab08.0+822ab08",
29
- "@agoric/internal": "0.3.3-dev-822ab08.0+822ab08",
30
- "@agoric/network": "0.1.1-dev-822ab08.0+822ab08",
31
- "@agoric/notifier": "0.6.3-dev-822ab08.0+822ab08",
32
- "@agoric/store": "0.9.3-dev-822ab08.0+822ab08",
33
- "@agoric/swingset-vat": "0.32.3-dev-822ab08.0+822ab08",
34
- "@agoric/time": "0.3.3-dev-822ab08.0+822ab08",
35
- "@agoric/vat-data": "0.5.3-dev-822ab08.0+822ab08",
36
- "@agoric/vow": "0.1.1-dev-822ab08.0+822ab08",
37
- "@agoric/zoe": "0.26.3-dev-822ab08.0+822ab08",
38
- "@agoric/zone": "0.2.3-dev-822ab08.0+822ab08",
25
+ "@agoric/assert": "0.6.1-dev-c11fecb.0+c11fecb",
26
+ "@agoric/cosmic-proto": "0.4.1-dev-c11fecb.0+c11fecb",
27
+ "@agoric/ertp": "0.16.3-dev-c11fecb.0+c11fecb",
28
+ "@agoric/governance": "0.10.4-dev-c11fecb.0+c11fecb",
29
+ "@agoric/internal": "0.3.3-dev-c11fecb.0+c11fecb",
30
+ "@agoric/network": "0.1.1-dev-c11fecb.0+c11fecb",
31
+ "@agoric/notifier": "0.6.3-dev-c11fecb.0+c11fecb",
32
+ "@agoric/store": "0.9.3-dev-c11fecb.0+c11fecb",
33
+ "@agoric/swingset-vat": "0.32.3-dev-c11fecb.0+c11fecb",
34
+ "@agoric/time": "0.3.3-dev-c11fecb.0+c11fecb",
35
+ "@agoric/vat-data": "0.5.3-dev-c11fecb.0+c11fecb",
36
+ "@agoric/vow": "0.1.1-dev-c11fecb.0+c11fecb",
37
+ "@agoric/zoe": "0.26.3-dev-c11fecb.0+c11fecb",
38
+ "@agoric/zone": "0.2.3-dev-c11fecb.0+c11fecb",
39
39
  "@endo/base64": "^1.0.5",
40
40
  "@endo/far": "^1.1.2",
41
41
  "@endo/import-bundle": "^1.1.2",
@@ -47,7 +47,7 @@
47
47
  "jessie.js": "^0.3.4"
48
48
  },
49
49
  "devDependencies": {
50
- "@agoric/swingset-liveslots": "0.10.3-dev-822ab08.0+822ab08",
50
+ "@agoric/swingset-liveslots": "0.10.3-dev-c11fecb.0+c11fecb",
51
51
  "@endo/bundle-source": "^3.2.3",
52
52
  "@endo/init": "^1.1.2",
53
53
  "ava": "^5.3.0",
@@ -81,5 +81,5 @@
81
81
  "typeCoverage": {
82
82
  "atLeast": 91.33
83
83
  },
84
- "gitHead": "822ab08b63f3bb737372eb6c3a4fad1fbf22e09f"
84
+ "gitHead": "c11fecbb0105bde2631adc14e106daf19c3f1201"
85
85
  }
@@ -1,3 +1,14 @@
1
+ /**
2
+ * @import {BankManager} from './vat-bank.js';
3
+ * @import {ScopedBridgeManager} from './types.js';
4
+ */
5
+ /** @import {TypedJson, ResponseTo} from '@agoric/cosmic-proto'; */
6
+ /**
7
+ * @typedef {{
8
+ * system: ScopedBridgeManager;
9
+ * bankManager: BankManager;
10
+ * }} LocalChainPowers
11
+ */
1
12
  export const LocalChainAccountI: import("@endo/patterns").InterfaceGuard<{
2
13
  getAddress: import("@endo/patterns").MethodGuard;
3
14
  deposit: import("@endo/patterns").MethodGuard;
@@ -13,90 +24,94 @@ export const LocalChainI: import("@endo/patterns").InterfaceGuard<{
13
24
  query: import("@endo/patterns").MethodGuard;
14
25
  queryMany: import("@endo/patterns").MethodGuard;
15
26
  }>;
16
- export const LocalChainAdminI: import("@endo/patterns").InterfaceGuard<{
17
- setPower: import("@endo/patterns").MethodGuard;
18
- }>;
19
27
  export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone): {
20
- makeLocalChain: (initialPowers?: Partial<LocalChainPowers> | undefined) => import("@endo/exo").GuardedKit<{
21
- admin: {
22
- /**
23
- * @template {keyof LocalChainPowers} K
24
- * @param {K} name
25
- * @param {LocalChainPowers[K]} [power]
26
- */
27
- setPower<K extends keyof LocalChainPowers>(name: K, power?: LocalChainPowers[K] | undefined): void;
28
- };
29
- public: {
28
+ makeLocalChain: (powers: LocalChainPowers) => import("@endo/exo").Guarded<{
29
+ /**
30
+ * Allocate a fresh address that doesn't correspond with a public key, and
31
+ * follows the ICA guidelines to help reduce collisions. See
32
+ * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
33
+ * hash and block data hash.
34
+ */
35
+ makeAccount(): Promise<import("@endo/exo").Guarded<{
36
+ getAddress(): Promise<string>;
30
37
  /**
31
- * Allocate a fresh address that doesn't correspond with a public key,
32
- * and follows the ICA guidelines to help reduce collisions. See
33
- * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
34
- * hash and block data hash.
35
- */
36
- makeAccount(): Promise<import("@endo/exo").Guarded<{
37
- getAddress(): Promise<string>;
38
- /**
39
- * Deposit a payment into the bank purse that matches the alleged brand.
40
- * This is safe, since even if the payment lies about its brand, ERTP will
41
- * reject spoofed payment objects when depositing into a purse.
42
- *
43
- * @param {Payment} payment
44
- */
45
- deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
46
- /**
47
- * Execute a batch of transactions and return the responses. Use
48
- * `typedJson()` on the arguments to get typed return values.
49
- *
50
- * @template {TypedJson[]} MT messages tuple (use const with multiple
51
- * elements or it will be a mixed array)
52
- * @param {MT} messages
53
- * @returns {Promise<{ [K in keyof MT]: ResponseTo<MT[K]> }>}
54
- */
55
- executeTx<MT extends {
56
- '@type': string;
57
- }[]>(messages: MT): Promise<{ [K_1 in keyof MT]: ResponseTo<MT[K_1]>; }>;
58
- }>>;
59
- /**
60
- * Make a single query to the local chain. Will reject with an error if
61
- * the query fails. Otherwise, return the response as a JSON-compatible
62
- * object.
38
+ * Deposit a payment into the bank purse that matches the alleged brand.
39
+ * This is safe, since even if the payment lies about its brand, ERTP will
40
+ * reject spoofed payment objects when depositing into a purse.
63
41
  *
64
- * @param {import('@agoric/cosmic-proto').TypedJson} request
65
- * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
42
+ * @param {Payment} payment
66
43
  */
67
- query(request: import("@agoric/cosmic-proto").TypedJson): Promise<import("@agoric/cosmic-proto").TypedJson>;
44
+ deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
68
45
  /**
69
- * Send a batch of query requests to the local chain. Unless there is a
70
- * system error, will return all results to indicate their success or
71
- * failure.
46
+ * Execute a batch of transactions and return the responses. Use
47
+ * `typedJson()` on the arguments to get typed return values.
72
48
  *
73
- * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
74
- * @returns {Promise<
75
- * {
76
- * error?: string;
77
- * reply: import('@agoric/cosmic-proto').TypedJson;
78
- * }[]
79
- * >}
49
+ * @template {TypedJson[]} MT messages tuple (use const with multiple
50
+ * elements or it will be a mixed array)
51
+ * @param {MT} messages
52
+ * @returns {Promise<{ [K in keyof MT]: ResponseTo<MT[K]> }>}
80
53
  */
81
- queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
82
- error?: string;
83
- reply: import("@agoric/cosmic-proto").TypedJson;
84
- }[]>;
85
- };
54
+ executeTx<MT extends {
55
+ '@type': string;
56
+ }[]>(messages: MT): Promise<{ [K in keyof MT]: ResponseTo<MT[K]>; }>;
57
+ }>>;
58
+ /**
59
+ * Make a single query to the local chain. Will reject with an error if
60
+ * the query fails. Otherwise, return the response as a JSON-compatible
61
+ * object.
62
+ *
63
+ * @param {import('@agoric/cosmic-proto').TypedJson} request
64
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
65
+ */
66
+ query(request: import("@agoric/cosmic-proto").TypedJson): Promise<import("@agoric/cosmic-proto").TypedJson>;
67
+ /**
68
+ * Send a batch of query requests to the local chain. Unless there is a
69
+ * system error, will return all results to indicate their success or
70
+ * failure.
71
+ *
72
+ * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
73
+ * @returns {Promise<
74
+ * {
75
+ * error?: string;
76
+ * reply: import('@agoric/cosmic-proto').TypedJson;
77
+ * }[]
78
+ * >}
79
+ */
80
+ queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
81
+ error?: string;
82
+ reply: import("@agoric/cosmic-proto").TypedJson;
83
+ }[]>;
86
84
  }>;
87
85
  };
88
86
  export type LocalChainPowers = {
89
- system: import("./types.js").ScopedBridgeManager;
90
- bankManager: import("./vat-bank.js").BankManager;
87
+ system: ScopedBridgeManager;
88
+ bankManager: import("@endo/exo").Guarded<{
89
+ getAssetSubscription(): globalThis.IterableEachTopic<import("./vat-bank.js").AssetDescriptor>;
90
+ getRewardDistributorDepositFacet(denom: string, feeKit: AssetIssuerKit): globalThis.ERef<{
91
+ /**
92
+ * Deposit all the contents of payment
93
+ * into the purse that made this facet, returning the amount. If the optional
94
+ * argument `optAmount` does not equal the amount of digital assets in the
95
+ * payment, throw an error.
96
+ *
97
+ * If payment is a promise, throw an error.
98
+ */
99
+ receive: (args_0: globalThis.Payment, args_1?: globalThis.Pattern) => globalThis.ERef<globalThis.Amount>;
100
+ }>;
101
+ getModuleAccountAddress(moduleName: string): Promise<string | null>;
102
+ addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
103
+ payment?: ERef<Payment>;
104
+ }): Promise<void>;
105
+ getBankForAddress(address: string): Promise<import("./vat-bank.js").Bank>;
106
+ }>;
91
107
  };
92
- export type PowerStore = MapStore<keyof LocalChainPowers, LocalChainPowers[keyof LocalChainPowers]>;
93
108
  export type LocalChainAccount = Awaited<ReturnType<Awaited<ReturnType<typeof prepareLocalChainAccount>>>>;
94
109
  export type LocalChainTools = ReturnType<typeof prepareLocalChainTools>;
95
- export type LocalChainKit = ReturnType<LocalChainTools["makeLocalChain"]>;
96
- export type LocalChain = LocalChainKit["public"];
110
+ export type LocalChain = ReturnType<LocalChainTools["makeLocalChain"]>;
97
111
  import type { ResponseTo } from '@agoric/cosmic-proto';
112
+ import type { ScopedBridgeManager } from './types.js';
98
113
  /** @param {import('@agoric/base-zone').Zone} zone */
99
- declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone): (address: string, powers: PowerStore) => import("@endo/exo").Guarded<{
114
+ declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone): (address: string, powers: LocalChainPowers) => import("@endo/exo").Guarded<{
100
115
  getAddress(): Promise<string>;
101
116
  /**
102
117
  * Deposit a payment into the bank purse that matches the alleged brand.
@@ -1 +1 @@
1
- {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AA+BA;;;;GAMG;AA4DH;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAsGI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;;YA9EpC;;;;eAIG;qBAFQ,CAAC,uCAAD,CAAC;;;YAkBZ;;;;;eAKG;;;gBAzGL;;;;;;mBAMG;iCADQ,OAAO;gBAYlB;;;;;;;;mBAQG;0BADgD,EAAE;;+BAAF,EAAE,AADxC;;YA2FX;;;;;;;eAOG;2BAFQ,OAAO,sBAAsB,EAAE,SAAS,GACtC,OAAO,CAAC,OAAO,sBAAsB,EAAE,SAAS,CAAC;YAa9D;;;;;;;;;;;;eAYG;gCAPQ,OAAO,sBAAsB,EAAE,SAAS,EAAE,GACxC,OAAO,CACnB;gBACA,KAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,KAAW,EAAE,OAAO,sBAAsB,EAAE,SAAS,CAAC;aACjD,EAAE,CACJ;;;EAoBX;+BAhNY;IACZ,MAAU,EAAE,OAAO,YAAY,EAAE,mBAAmB,CAAC;IACrD,WAAe,EAAE,OAAO,eAAe,EAAE,WAAW,CAAC;CAClD;yBAES,QAAQ,CACpB,MAAU,gBAAgB,EAC1B,gBAAoB,CAAC,MAAM,gBAAgB,CAAC,CACzC;gCAgFS,OAAO,CACnB,UAAc,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CACjE;8BAyHU,UAAU,CAAC,OAAO,sBAAsB,CAAC;4BACzC,UAAU,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;yBAC7C,aAAa,CAAC,QAAQ,CAAC;gCAxNI,sBAAsB;AAgC/D,qDAAqD;AACrD,gDADY,OAAO,mBAAmB,EAAE,IAAI;;IAetC;;;;;;OAMG;qBADQ,OAAO;IAYlB;;;;;;;;OAQG;cADgD,EAAE;;mBAAF,EAAE,AADxC;GAmBhB"}
1
+ {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH,mEAAmE;AAEnE;;;;;GAKG;AAEH;;;;GAMG;AAyDH;;;;GAIG;AAEH;;;;GAIG;AAuEI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;QAvDtC;;;;;WAKG;;;YAtEH;;;;;;eAMG;6BADQ,OAAO;YAUlB;;;;;;;;eAQG;sBADgD,EAAE;;2BAAF,EAAE,AADxC;;QAyDb;;;;;;;WAOG;uBAFQ,OAAO,sBAAsB,EAAE,SAAS,GACtC,OAAO,CAAC,OAAO,sBAAsB,EAAE,SAAS,CAAC;QAa9D;;;;;;;;;;;;WAYG;4BAPQ,OAAO,sBAAsB,EAAE,SAAS,EAAE,GACxC,OAAO,CACnB;YACA,KAAW,CAAC,EAAE,MAAM,CAAC;YACrB,KAAW,EAAE,OAAO,sBAAsB,EAAE,SAAS,CAAC;SACjD,EAAE,CACJ;;EAkBT;;;;;gEAK2xa,cAAc;;;;;;;;;;;;+EAAgiD,cAAc,GAAE;YAAE,OAAQ,CAAC,EAAC,KAAM,OAAO,CAAC,CAAA;SAAE;;;;gCA1Fz2d,OAAO,CACnB,UAAc,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CACjE;8BAsFU,UAAU,CAAC,OAAO,sBAAsB,CAAC;yBACzC,UAAU,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;gCAlKlB,sBAAsB;yCAHzB,YAAY;AAoBlD,qDAAqD;AACrD,gDADY,OAAO,mBAAmB,EAAE,IAAI;;IAetC;;;;;;OAMG;qBADQ,OAAO;IAUlB;;;;;;;;OAQG;cADgD,EAAE;;mBAAF,EAAE,AADxC;GAkBhB"}
package/src/localchain.js CHANGED
@@ -3,32 +3,22 @@ import { E } from '@endo/far';
3
3
  import { M } from '@endo/patterns';
4
4
  import { AmountShape } from '@agoric/ertp';
5
5
 
6
- const { Fail, bare } = assert;
6
+ const { Fail } = assert;
7
+
8
+ /**
9
+ * @import {BankManager} from './vat-bank.js';
10
+ * @import {ScopedBridgeManager} from './types.js';
11
+ */
7
12
 
8
13
  /** @import {TypedJson, ResponseTo} from '@agoric/cosmic-proto'; */
9
14
 
10
15
  /**
11
16
  * @typedef {{
12
- * system: import('./types.js').ScopedBridgeManager;
13
- * bankManager: import('./vat-bank.js').BankManager;
17
+ * system: ScopedBridgeManager;
18
+ * bankManager: BankManager;
14
19
  * }} LocalChainPowers
15
- *
16
- * @typedef {MapStore<
17
- * keyof LocalChainPowers,
18
- * LocalChainPowers[keyof LocalChainPowers]
19
- * >} PowerStore
20
20
  */
21
21
 
22
- /**
23
- * @template {keyof LocalChainPowers} K
24
- * @param {PowerStore} powers
25
- * @param {K} name
26
- */
27
- const getPower = (powers, name) => {
28
- powers.has(name) || Fail`need powers.${bare(name)} for this method`;
29
- return /** @type {LocalChainPowers[K]} */ (powers.get(name));
30
- };
31
-
32
22
  export const LocalChainAccountI = M.interface('LocalChainAccount', {
33
23
  getAddress: M.callWhen().returns(M.string()),
34
24
  deposit: M.callWhen(M.remotable('Payment'))
@@ -44,9 +34,9 @@ const prepareLocalChainAccount = zone =>
44
34
  LocalChainAccountI,
45
35
  /**
46
36
  * @param {string} address
47
- * @param {PowerStore} powers
37
+ * @param {LocalChainPowers} powers
48
38
  */
49
- (address, powers) => ({ address, powers }),
39
+ (address, powers) => ({ address, ...powers, reserved: undefined }),
50
40
  {
51
41
  // Information that the account creator needs.
52
42
  async getAddress() {
@@ -60,9 +50,7 @@ const prepareLocalChainAccount = zone =>
60
50
  * @param {Payment} payment
61
51
  */
62
52
  async deposit(payment) {
63
- const { address, powers } = this.state;
64
-
65
- const bankManager = getPower(powers, 'bankManager');
53
+ const { address, bankManager } = this.state;
66
54
 
67
55
  const allegedBrand = await E(payment).getAllegedBrand();
68
56
  const bankAcct = E(bankManager).getBankForAddress(address);
@@ -79,7 +67,7 @@ const prepareLocalChainAccount = zone =>
79
67
  * @returns {Promise<{ [K in keyof MT]: ResponseTo<MT[K]> }>}
80
68
  */
81
69
  async executeTx(messages) {
82
- const { address, powers } = this.state;
70
+ const { address, system } = this.state;
83
71
  messages.length > 0 || Fail`need at least one message to execute`;
84
72
 
85
73
  const obj = {
@@ -90,7 +78,6 @@ const prepareLocalChainAccount = zone =>
90
78
  address,
91
79
  messages,
92
80
  };
93
- const system = getPower(powers, 'system');
94
81
  return E(system).toBridge(obj);
95
82
  },
96
83
  },
@@ -107,105 +94,70 @@ export const LocalChainI = M.interface('LocalChain', {
107
94
  queryMany: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
108
95
  });
109
96
 
110
- export const LocalChainAdminI = M.interface('LocalChainAdmin', {
111
- setPower: M.callWhen(M.string(), M.await(M.any())).returns(),
112
- });
113
-
114
97
  /**
115
98
  * @param {import('@agoric/base-zone').Zone} zone
116
99
  * @param {ReturnType<typeof prepareLocalChainAccount>} makeAccount
117
100
  */
118
101
  const prepareLocalChain = (zone, makeAccount) =>
119
- zone.exoClassKit(
102
+ zone.exoClass(
120
103
  'LocalChain',
121
- { public: LocalChainI, admin: LocalChainAdminI },
122
- /** @param {Partial<LocalChainPowers>} [initialPowers] */
123
- initialPowers => {
124
- /** @type {PowerStore} */
125
- const powers = zone.detached().mapStore('PowerStore');
126
- if (initialPowers) {
127
- for (const [name, power] of Object.entries(initialPowers)) {
128
- powers.init(/** @type {keyof LocalChainPowers} */ (name), power);
129
- }
130
- }
131
- return { powers };
104
+ LocalChainI,
105
+ /** @param {LocalChainPowers} powers */
106
+ powers => {
107
+ return { ...powers };
132
108
  },
133
109
  {
134
- admin: {
135
- /**
136
- * @template {keyof LocalChainPowers} K
137
- * @param {K} name
138
- * @param {LocalChainPowers[K]} [power]
139
- */
140
- setPower(name, power) {
141
- const { powers } = this.state;
142
- if (power === undefined) {
143
- // Remove from powers.
144
- powers.delete(name);
145
- } else if (powers.has(name)) {
146
- // Replace an existing power.
147
- powers.set(name, power);
148
- } else {
149
- // Add a new power.
150
- powers.init(name, power);
151
- }
152
- },
110
+ /**
111
+ * Allocate a fresh address that doesn't correspond with a public key, and
112
+ * follows the ICA guidelines to help reduce collisions. See
113
+ * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
114
+ * hash and block data hash.
115
+ */
116
+ async makeAccount() {
117
+ const { system, bankManager } = this.state;
118
+ const address = await E(system).toBridge({
119
+ type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
120
+ });
121
+ return makeAccount(address, { system, bankManager });
153
122
  },
154
- public: {
155
- /**
156
- * Allocate a fresh address that doesn't correspond with a public key,
157
- * and follows the ICA guidelines to help reduce collisions. See
158
- * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
159
- * hash and block data hash.
160
- */
161
- async makeAccount() {
162
- const { powers } = this.state;
163
- const system = getPower(powers, 'system');
164
- const address = await E(system).toBridge({
165
- type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
166
- });
167
- return makeAccount(address, powers);
168
- },
169
- /**
170
- * Make a single query to the local chain. Will reject with an error if
171
- * the query fails. Otherwise, return the response as a JSON-compatible
172
- * object.
173
- *
174
- * @param {import('@agoric/cosmic-proto').TypedJson} request
175
- * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
176
- */
177
- async query(request) {
178
- const requests = harden([request]);
179
- const results = await E(this.facets.public).queryMany(requests);
180
- results.length === 1 ||
181
- Fail`expected exactly one result; got ${results}`;
182
- const { error, reply } = results[0];
183
- if (error) {
184
- throw Fail`query failed: ${error}`;
185
- }
186
- return reply;
187
- },
188
- /**
189
- * Send a batch of query requests to the local chain. Unless there is a
190
- * system error, will return all results to indicate their success or
191
- * failure.
192
- *
193
- * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
194
- * @returns {Promise<
195
- * {
196
- * error?: string;
197
- * reply: import('@agoric/cosmic-proto').TypedJson;
198
- * }[]
199
- * >}
200
- */
201
- async queryMany(requests) {
202
- const { powers } = this.state;
203
- const system = getPower(powers, 'system');
204
- return E(system).toBridge({
205
- type: 'VLOCALCHAIN_QUERY_MANY',
206
- messages: requests,
207
- });
208
- },
123
+ /**
124
+ * Make a single query to the local chain. Will reject with an error if
125
+ * the query fails. Otherwise, return the response as a JSON-compatible
126
+ * object.
127
+ *
128
+ * @param {import('@agoric/cosmic-proto').TypedJson} request
129
+ * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
130
+ */
131
+ async query(request) {
132
+ const requests = harden([request]);
133
+ const results = await E(this.self).queryMany(requests);
134
+ results.length === 1 ||
135
+ Fail`expected exactly one result; got ${results}`;
136
+ const { error, reply } = results[0];
137
+ if (error) {
138
+ throw Fail`query failed: ${error}`;
139
+ }
140
+ return reply;
141
+ },
142
+ /**
143
+ * Send a batch of query requests to the local chain. Unless there is a
144
+ * system error, will return all results to indicate their success or
145
+ * failure.
146
+ *
147
+ * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
148
+ * @returns {Promise<
149
+ * {
150
+ * error?: string;
151
+ * reply: import('@agoric/cosmic-proto').TypedJson;
152
+ * }[]
153
+ * >}
154
+ */
155
+ async queryMany(requests) {
156
+ const { system } = this.state;
157
+ return E(system).toBridge({
158
+ type: 'VLOCALCHAIN_QUERY_MANY',
159
+ messages: requests,
160
+ });
209
161
  },
210
162
  },
211
163
  );
@@ -220,5 +172,4 @@ export const prepareLocalChainTools = zone => {
220
172
  harden(prepareLocalChainTools);
221
173
 
222
174
  /** @typedef {ReturnType<typeof prepareLocalChainTools>} LocalChainTools */
223
- /** @typedef {ReturnType<LocalChainTools['makeLocalChain']>} LocalChainKit */
224
- /** @typedef {LocalChainKit['public']} LocalChain */
175
+ /** @typedef {ReturnType<LocalChainTools['makeLocalChain']>} LocalChain */
@@ -1,13 +1,10 @@
1
- export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager: bridgeManagerP, localchainBridgeManager: localchainBridgeManagerP, bankManager, }, produce: { localchainVat, localchain, localchainAdmin: localchainAdminP, localchainBridgeManager, }, }: BootstrapPowers & {
1
+ export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager: bridgeManagerP, localchainBridgeManager: localchainBridgeManagerP, bankManager, }, produce: { localchainVat, localchain, localchainBridgeManager }, }: BootstrapPowers & {
2
2
  consume: {
3
3
  loadCriticalVat: VatLoader<any>;
4
- bridgeManager: import("../types").BridgeManager;
5
4
  localchainBridgeManager: import("../types").ScopedBridgeManager;
6
- bankManager: Promise<import("../vat-bank.js").BankManager>;
7
5
  };
8
6
  produce: {
9
7
  localchain: Producer<any>;
10
- localchainAdmin: Producer<any>;
11
8
  localchainVat: Producer<any>;
12
9
  localchainBridgeManager: Producer<any>;
13
10
  };
@@ -37,7 +34,6 @@ export function getManifestForLocalChain(_powers: any, { localchainRef }: {
37
34
  };
38
35
  produce: {
39
36
  localchain: string;
40
- localchainAdmin: string;
41
37
  localchainVat: string;
42
38
  localchainBridgeManager: string;
43
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"localchain-proposal.d.ts","sourceRoot":"","sources":["localchain-proposal.js"],"names":[],"mappings":"AA0BO,2QArBI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,eAAqB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,aAAmB,EAAE,OAAO,UAAU,EAAE,aAAa,CAAC;QACtD,uBAA6B,EAAE,OAAO,UAAU,EAAE,mBAAmB,CAAC;QACtE,WAAiB,EAAE,OAAO,CAAC,OAAO,gBAAgB,EAAE,WAAW,CAAC,CAAC;KAC5D,CAAC;IACN,OAAW,EAAE;QACb,UAAgB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,eAAqB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QACrC,aAAmB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnC,uBAA6B,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;KACxC,CAAC;CACH;IAEgD,OAAO,EAAhD;QAAE,aAAa,EAAE,YAAY,CAAA;KAAE;kBAoFzC;AAUM,2EAPI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH,YACO,MAAM,iBAOhB;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BL;6BA/HW;IACZ,UAAc,EAAE,IAAI,CAAC,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC;CAChE"}
1
+ {"version":3,"file":"localchain-proposal.d.ts","sourceRoot":"","sources":["localchain-proposal.js"],"names":[],"mappings":"AAuBO,uOAlBI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,eAAqB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,uBAA6B,EAAE,OAAO,UAAU,EAAE,mBAAmB,CAAC;KACjE,CAAC;IACN,OAAW,EAAE;QACb,UAAgB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,aAAmB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnC,uBAA6B,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;KACxC,CAAC;CACH;IAEgD,OAAO,EAAhD;QAAE,aAAa,EAAE,YAAY,CAAA;KAAE;kBA0DzC;AAUM,2EAPI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH,YACO,MAAM,iBAOhB;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BL;6BApGW;IACZ,UAAc,EAAE,IAAI,CAAC,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC;CAChE"}
@@ -6,13 +6,10 @@ import { BridgeId as BRIDGE_ID } from '@agoric/internal';
6
6
  * @param {BootstrapPowers & {
7
7
  * consume: {
8
8
  * loadCriticalVat: VatLoader<any>;
9
- * bridgeManager: import('../types').BridgeManager;
10
9
  * localchainBridgeManager: import('../types').ScopedBridgeManager;
11
- * bankManager: Promise<import('../vat-bank.js').BankManager>;
12
10
  * };
13
11
  * produce: {
14
12
  * localchain: Producer<any>;
15
- * localchainAdmin: Producer<any>;
16
13
  * localchainVat: Producer<any>;
17
14
  * localchainBridgeManager: Producer<any>;
18
15
  * };
@@ -32,12 +29,7 @@ export const setupLocalChainVat = async (
32
29
  localchainBridgeManager: localchainBridgeManagerP,
33
30
  bankManager,
34
31
  },
35
- produce: {
36
- localchainVat,
37
- localchain,
38
- localchainAdmin: localchainAdminP,
39
- localchainBridgeManager,
40
- },
32
+ produce: { localchainVat, localchain, localchainBridgeManager },
41
33
  },
42
34
  options,
43
35
  ) => {
@@ -74,34 +66,13 @@ export const setupLocalChainVat = async (
74
66
  );
75
67
  }
76
68
 
77
- const { admin: localChainAdmin, public: newLocalChain } = await E(
78
- vats.localchain,
79
- ).makeLocalChain({
69
+ const newLocalChain = await E(vats.localchain).makeLocalChain({
80
70
  system: scopedManager,
71
+ bankManager: await bankManager,
81
72
  });
82
73
 
83
74
  localchain.reset();
84
75
  localchain.resolve(newLocalChain);
85
- localchainAdminP.reset();
86
- localchainAdminP.resolve(localChainAdmin);
87
-
88
- /** @type {Record<string, Promise<void>>} */
89
- const descToPromise = {
90
- 'bank manager power': bankManager.then(bm =>
91
- E(localChainAdmin).setPower('bankManager', bm),
92
- ),
93
- };
94
- void Promise.all(
95
- Object.entries(descToPromise).map(([desc, p]) =>
96
- p
97
- .then(() =>
98
- console.info(`Completed configuration of localchain with ${desc}`),
99
- )
100
- .catch(e =>
101
- console.error(`Failed to configure localchain with ${desc}:`, e),
102
- ),
103
- ),
104
- );
105
76
  };
106
77
 
107
78
  /**
@@ -131,7 +102,6 @@ export const getManifestForLocalChain = (_powers, { localchainRef }) => ({
131
102
  },
132
103
  produce: {
133
104
  localchain: 'localchain',
134
- localchainAdmin: 'localchain',
135
105
  localchainVat: 'localchain',
136
106
  localchainBridgeManager: 'localchain',
137
107
  },
@@ -3,60 +3,50 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
3
3
  * Create a local chain that allows permissionlessly making fresh local
4
4
  * chain accounts, then using them to send chain queries and transactions.
5
5
  *
6
- * @param {Partial<import('./localchain.js').LocalChainPowers>} [initialPowers]
6
+ * @param {import('./localchain.js').LocalChainPowers} powers
7
7
  */
8
- makeLocalChain(initialPowers?: Partial<import("./localchain.js").LocalChainPowers> | undefined): import("@endo/exo").GuardedKit<{
9
- admin: {
10
- setPower<K extends keyof import("./localchain.js").LocalChainPowers>(name: K, power?: import("./localchain.js").LocalChainPowers[K] | undefined): void;
11
- };
12
- public: {
13
- makeAccount(): Promise<import("@endo/exo").Guarded<{
14
- getAddress(): Promise<string>;
15
- deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
16
- executeTx<MT extends {
17
- '@type': string;
18
- }[]>(messages: MT): Promise<{ [K_1 in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K_1]>; }>;
19
- }>>;
20
- query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
8
+ makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
9
+ makeAccount(): Promise<import("@endo/exo").Guarded<{
10
+ getAddress(): Promise<string>;
11
+ deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
12
+ executeTx<MT extends {
21
13
  '@type': string;
22
- }>;
23
- queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
24
- error?: string | undefined;
25
- reply: {
26
- '@type': string;
27
- };
28
- }[]>;
29
- };
14
+ }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
15
+ }>>;
16
+ query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
17
+ '@type': string;
18
+ }>;
19
+ queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
20
+ error?: string | undefined;
21
+ reply: {
22
+ '@type': string;
23
+ };
24
+ }[]>;
30
25
  }>;
31
26
  } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
32
27
  /**
33
28
  * Create a local chain that allows permissionlessly making fresh local
34
29
  * chain accounts, then using them to send chain queries and transactions.
35
30
  *
36
- * @param {Partial<import('./localchain.js').LocalChainPowers>} [initialPowers]
31
+ * @param {import('./localchain.js').LocalChainPowers} powers
37
32
  */
38
- makeLocalChain(initialPowers?: Partial<import("./localchain.js").LocalChainPowers> | undefined): import("@endo/exo").GuardedKit<{
39
- admin: {
40
- setPower<K extends keyof import("./localchain.js").LocalChainPowers>(name: K, power?: import("./localchain.js").LocalChainPowers[K] | undefined): void;
41
- };
42
- public: {
43
- makeAccount(): Promise<import("@endo/exo").Guarded<{
44
- getAddress(): Promise<string>;
45
- deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
46
- executeTx<MT extends {
47
- '@type': string;
48
- }[]>(messages: MT): Promise<{ [K_1 in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K_1]>; }>;
49
- }>>;
50
- query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
33
+ makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
34
+ makeAccount(): Promise<import("@endo/exo").Guarded<{
35
+ getAddress(): Promise<string>;
36
+ deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
37
+ executeTx<MT extends {
38
+ '@type': string;
39
+ }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
40
+ }>>;
41
+ query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
42
+ '@type': string;
43
+ }>;
44
+ queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
45
+ error?: string | undefined;
46
+ reply: {
51
47
  '@type': string;
52
- }>;
53
- queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
54
- error?: string | undefined;
55
- reply: {
56
- '@type': string;
57
- };
58
- }[]>;
59
- };
48
+ };
49
+ }[]>;
60
50
  }>;
61
51
  }>;
62
52
  export type LocalChainVat = ReturnType<typeof buildRootObject>;
@@ -1 +1 @@
1
- {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;;;uFAQ8kH,CAAC;;;;;iCAArqF,OAAO;;;+BAA8sB,EAAE;;2BAAkvG,OAAO,sBAAsB,EAAE,SAAS;;;gCAAwtB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;IAbhqL;;;;;OAKG;;;;;;;;;;;;;0DAQk5J,SAAS;;;+DAAuvB,SAAS;;;;;;;;GAHjqL;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;6BAS6mB,OAAO;;;2BAAqpB,EAAE;;uBAA8kE,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IAbzoI;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;;;;;;sDASw3G,SAAS;;;2DAAwsB,SAAS;;;;;;;GAH1oI;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
@@ -13,10 +13,10 @@ export const buildRootObject = (_vatPowers, _args, baggage) => {
13
13
  * Create a local chain that allows permissionlessly making fresh local
14
14
  * chain accounts, then using them to send chain queries and transactions.
15
15
  *
16
- * @param {Partial<import('./localchain.js').LocalChainPowers>} [initialPowers]
16
+ * @param {import('./localchain.js').LocalChainPowers} powers
17
17
  */
18
- makeLocalChain(initialPowers = {}) {
19
- return makeLocalChain(initialPowers);
18
+ makeLocalChain(powers) {
19
+ return makeLocalChain(powers);
20
20
  },
21
21
  });
22
22
  };