@agoric/vats 0.15.2-dev-1dd4473.0 → 0.15.2-dev-accf269.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-1dd4473.0+1dd4473",
3
+ "version": "0.15.2-dev-accf269.0+accf269",
4
4
  "description": "Agoric's Vat library",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -22,18 +22,18 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/assert": "0.6.1-dev-1dd4473.0+1dd4473",
26
- "@agoric/ertp": "0.16.3-dev-1dd4473.0+1dd4473",
27
- "@agoric/governance": "0.10.4-dev-1dd4473.0+1dd4473",
28
- "@agoric/internal": "0.3.3-dev-1dd4473.0+1dd4473",
29
- "@agoric/network": "0.1.1-dev-1dd4473.0+1dd4473",
30
- "@agoric/notifier": "0.6.3-dev-1dd4473.0+1dd4473",
31
- "@agoric/store": "0.9.3-dev-1dd4473.0+1dd4473",
32
- "@agoric/swingset-vat": "0.32.3-dev-1dd4473.0+1dd4473",
33
- "@agoric/time": "0.3.3-dev-1dd4473.0+1dd4473",
34
- "@agoric/vat-data": "0.5.3-dev-1dd4473.0+1dd4473",
35
- "@agoric/zoe": "0.26.3-dev-1dd4473.0+1dd4473",
36
- "@agoric/zone": "0.2.3-dev-1dd4473.0+1dd4473",
25
+ "@agoric/assert": "0.6.1-dev-accf269.0+accf269",
26
+ "@agoric/ertp": "0.16.3-dev-accf269.0+accf269",
27
+ "@agoric/governance": "0.10.4-dev-accf269.0+accf269",
28
+ "@agoric/internal": "0.3.3-dev-accf269.0+accf269",
29
+ "@agoric/network": "0.1.1-dev-accf269.0+accf269",
30
+ "@agoric/notifier": "0.6.3-dev-accf269.0+accf269",
31
+ "@agoric/store": "0.9.3-dev-accf269.0+accf269",
32
+ "@agoric/swingset-vat": "0.32.3-dev-accf269.0+accf269",
33
+ "@agoric/time": "0.3.3-dev-accf269.0+accf269",
34
+ "@agoric/vat-data": "0.5.3-dev-accf269.0+accf269",
35
+ "@agoric/zoe": "0.26.3-dev-accf269.0+accf269",
36
+ "@agoric/zone": "0.2.3-dev-accf269.0+accf269",
37
37
  "@endo/far": "^1.0.4",
38
38
  "@endo/import-bundle": "^1.0.4",
39
39
  "@endo/marshal": "^1.3.0",
@@ -44,7 +44,7 @@
44
44
  "jessie.js": "^0.3.2"
45
45
  },
46
46
  "devDependencies": {
47
- "@agoric/swingset-liveslots": "0.10.3-dev-1dd4473.0+1dd4473",
47
+ "@agoric/swingset-liveslots": "0.10.3-dev-accf269.0+accf269",
48
48
  "@endo/bundle-source": "^3.1.0",
49
49
  "@endo/init": "^1.0.4",
50
50
  "ava": "^5.3.0",
@@ -77,5 +77,5 @@
77
77
  "typeCoverage": {
78
78
  "atLeast": 89.52
79
79
  },
80
- "gitHead": "1dd4473170bf0c5a4f780681d0250212f88bc630"
80
+ "gitHead": "accf269881172476c07506de498adb204637884b"
81
81
  }
@@ -1,22 +1,79 @@
1
1
  export const LocalChainAccountI: import("@endo/patterns").InterfaceGuard<{
2
2
  getAddress: import("@endo/patterns").MethodGuard;
3
+ deposit: import("@endo/patterns").MethodGuard;
3
4
  executeTx: import("@endo/patterns").MethodGuard;
4
- allBalances: import("@endo/patterns").MethodGuard;
5
5
  }>;
6
6
  export const LocalChainI: import("@endo/patterns").InterfaceGuard<{
7
7
  createAccount: import("@endo/patterns").MethodGuard;
8
8
  query: import("@endo/patterns").MethodGuard;
9
+ queryMany: import("@endo/patterns").MethodGuard;
10
+ }>;
11
+ export const LocalChainAdminI: import("@endo/patterns").InterfaceGuard<{
12
+ setPower: import("@endo/patterns").MethodGuard;
9
13
  }>;
10
14
  export function prepareLocalChainTools(zone: import('@agoric/base-zone').Zone): {
11
- makeLocalChain: (system: import("./types.js").ScopedBridgeManager) => import("@endo/exo/src/exo-makers.js").Guarded<{
12
- createAccount(): Promise<import("@endo/exo/src/exo-makers.js").Guarded<{
13
- getAddress(): Promise<string>;
14
- allBalances(): Promise<any>;
15
- executeTx(messages: any): Promise<any>;
16
- }>>;
17
- query(messages: any): Promise<any>;
15
+ makeLocalChain: (initialPowers?: Partial<LocalChainPowers> | undefined) => import("@endo/exo/src/exo-makers.js").GuardedKit<{
16
+ admin: {
17
+ /**
18
+ * @template {keyof LocalChainPowers} K
19
+ * @param {K} name
20
+ * @param {LocalChainPowers[K]} [power]
21
+ */
22
+ setPower<K extends keyof LocalChainPowers>(name: K, power?: LocalChainPowers[K] | undefined): void;
23
+ };
24
+ public: {
25
+ /**
26
+ * Allocate a fresh address that doesn't correspond with a public key,
27
+ * and follows the ICA guidelines to help reduce collisions. See
28
+ * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
29
+ * hash and block data hash.
30
+ */
31
+ createAccount(): Promise<import("@endo/exo/src/exo-makers.js").Guarded<{
32
+ getAddress(): Promise<string>;
33
+ /**
34
+ * Deposit a payment into the bank purse that matches the alleged brand.
35
+ * This is safe, since even if the payment lies about its brand, ERTP will
36
+ * reject spoofed payment objects when depositing into a purse.
37
+ *
38
+ * @param {Payment} payment
39
+ */
40
+ deposit(payment: Payment): Promise<Amount<AssetKind>>;
41
+ executeTx(messages: any): Promise<any>;
42
+ }>>;
43
+ /**
44
+ * Make a single query to the local chain. Will reject with an error if
45
+ * the query fails. Otherwise, return the response as a JSON-compatible
46
+ * object.
47
+ *
48
+ * @param {Proto3Jsonable} request
49
+ * @returns {Promise<Proto3Jsonable>}
50
+ */
51
+ query(request: Proto3Jsonable): Promise<Proto3Jsonable>;
52
+ /**
53
+ * Send a batch of query requests to the local chain. Unless there is a
54
+ * system error, will return all results to indicate their success or
55
+ * failure.
56
+ *
57
+ * @param {Proto3Jsonable[]} requests
58
+ * @returns {Promise<{ error?: string; reply: Proto3Jsonable }[]>}
59
+ */
60
+ queryMany(requests: Proto3Jsonable[]): Promise<{
61
+ error?: string;
62
+ reply: Proto3Jsonable;
63
+ }[]>;
64
+ };
18
65
  }>;
19
66
  };
67
+ export type Proto3Jsonable = {
68
+ [x: string]: unknown;
69
+ '@type': string;
70
+ };
71
+ export type LocalChainPowers = {
72
+ system: import('./types.js').ScopedBridgeManager;
73
+ bankManager: import('./vat-bank.js').BankManager;
74
+ };
75
+ export type PowerStore = MapStore<keyof LocalChainPowers, LocalChainPowers[keyof LocalChainPowers]>;
20
76
  export type LocalChainTools = ReturnType<typeof prepareLocalChainTools>;
21
- export type LocalChain = ReturnType<LocalChainTools['makeLocalChain']>;
77
+ export type LocalChainKit = ReturnType<LocalChainTools['makeLocalChain']>;
78
+ export type LocalChain = LocalChainKit['public'];
22
79
  //# sourceMappingURL=localchain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAKA;;;;GAMG;AA+CH;;;GAGG;AAmCI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;;;;;;;;EAM3C;8BAGa,WAAW,6BAA6B,CAAC;yBACzC,WAAW,eAAe,CAAC,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAoCA;;;;GAMG;AAkDH;;;;GAIG;AAEH;;GAEG;AAiGI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;;YAzEpC;;;;eAIG;;;;YAgBH;;;;;eAKG;;;gBAzFL;;;;;;mBAMG;iCADQ,OAAO;;;YA6FhB;;;;;;;eAOG;2BAFQ,cAAc,GACZ,QAAQ,cAAc,CAAC;YAapC;;;;;;;eAOG;gCAFQ,cAAc,EAAE,GACd,QAAQ;gBAAE,KAAK,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,cAAc,CAAA;aAAE,EAAE,CAAC;;;EAoBxE;;;aAjMa,MAAM;;+BAMP;IACZ,MAAU,EAAE,OAAO,YAAY,EAAE,mBAAmB,CAAC;IACrD,WAAe,EAAE,OAAO,eAAe,EAAE,WAAW,CAAC;CAClD;yBAES,SACZ,MAAU,gBAAgB,EAC1B,gBAAoB,CAAC,MAAM,gBAAgB,CAAC,CACzC;8BAsLU,WAAW,6BAA6B,CAAC;4BACzC,WAAW,eAAe,CAAC,gBAAgB,CAAC,CAAC;yBAC7C,aAAa,CAAC,QAAQ,CAAC"}
package/src/localchain.js CHANGED
@@ -1,14 +1,45 @@
1
+ // @ts-check
1
2
  import { E } from '@endo/far';
2
3
  import { M } from '@endo/patterns';
4
+ import { AmountShape } from '@agoric/ertp';
3
5
 
4
- const { Fail } = assert;
6
+ const { Fail, bare } = assert;
7
+
8
+ /**
9
+ * @typedef {{
10
+ * '@type': string;
11
+ * [x: string]: unknown;
12
+ * }} Proto3Jsonable
13
+ */
14
+
15
+ /**
16
+ * @typedef {{
17
+ * system: import('./types.js').ScopedBridgeManager;
18
+ * bankManager: import('./vat-bank.js').BankManager;
19
+ * }} LocalChainPowers
20
+ *
21
+ * @typedef {MapStore<
22
+ * keyof LocalChainPowers,
23
+ * LocalChainPowers[keyof LocalChainPowers]
24
+ * >} PowerStore
25
+ */
26
+
27
+ /**
28
+ * @template {keyof LocalChainPowers} K
29
+ * @param {PowerStore} powers
30
+ * @param {K} name
31
+ */
32
+ const getPower = (powers, name) => {
33
+ powers.has(name) || Fail`need powers.${bare(name)} for this method`;
34
+ return /** @type {LocalChainPowers[K]} */ (powers.get(name));
35
+ };
5
36
 
6
37
  export const LocalChainAccountI = M.interface('LocalChainAccount', {
7
38
  getAddress: M.callWhen().returns(M.string()),
39
+ deposit: M.callWhen(M.remotable('Payment'))
40
+ .optional(M.pattern())
41
+ .returns(AmountShape),
8
42
  executeTx: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
9
- // An example of a high-level query. TODO: Move this functionality to a higher
10
- // layer that implements the Orchestration API.
11
- allBalances: M.callWhen().returns(M.record()),
12
43
  });
13
44
 
14
45
  /** @param {import('@agoric/base-zone').Zone} zone */
@@ -17,32 +48,34 @@ const prepareLocalChainAccount = zone =>
17
48
  'LocalChainAccount',
18
49
  LocalChainAccountI,
19
50
  /**
20
- * @param {import('./types.js').ScopedBridgeManager} system
21
51
  * @param {string} address
22
- * @param {{ query: (messages: any[]) => Promise<any> }} chain
52
+ * @param {PowerStore} powers
23
53
  */
24
- (system, address, chain) => ({ system, address, chain }),
54
+ (address, powers) => ({ address, powers }),
25
55
  {
26
56
  // Information that the account creator needs.
27
57
  async getAddress() {
28
58
  return this.state.address;
29
59
  },
30
- async allBalances() {
31
- // We make a balance request, scoped to our own address.
32
- const { address, chain } = this.state;
33
- const res = await chain.query([
34
- {
35
- '@type': '/cosmos.bank.v1beta1.QueryAllBalancesRequest',
36
- address,
37
- },
38
- ]);
39
- if (res[0].error) {
40
- throw Fail`query failed: ${res[0].error}`;
41
- }
42
- return res[0].reply;
60
+ /**
61
+ * Deposit a payment into the bank purse that matches the alleged brand.
62
+ * This is safe, since even if the payment lies about its brand, ERTP will
63
+ * reject spoofed payment objects when depositing into a purse.
64
+ *
65
+ * @param {Payment} payment
66
+ */
67
+ async deposit(payment) {
68
+ const { address, powers } = this.state;
69
+
70
+ const bankManager = getPower(powers, 'bankManager');
71
+
72
+ const allegedBrand = await E(payment).getAllegedBrand();
73
+ const bankAcct = E(bankManager).getBankForAddress(address);
74
+ const allegedPurse = E(bankAcct).getPurse(allegedBrand);
75
+ return E(allegedPurse).deposit(payment);
43
76
  },
44
77
  async executeTx(messages) {
45
- const { system, address } = this.state;
78
+ const { address, powers } = this.state;
46
79
  const obj = {
47
80
  type: 'VLOCALCHAIN_EXECUTE_TX',
48
81
  // This address is the only one that `VLOCALCHAIN_EXECUTE_TX` will
@@ -51,6 +84,7 @@ const prepareLocalChainAccount = zone =>
51
84
  address,
52
85
  messages,
53
86
  };
87
+ const system = getPower(powers, 'system');
54
88
  return E(system).toBridge(obj);
55
89
  },
56
90
  },
@@ -58,7 +92,12 @@ const prepareLocalChainAccount = zone =>
58
92
 
59
93
  export const LocalChainI = M.interface('LocalChain', {
60
94
  createAccount: M.callWhen().returns(M.remotable('LocalChainAccount')),
61
- query: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
95
+ query: M.callWhen(M.record()).returns(M.record()),
96
+ queryMany: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
97
+ });
98
+
99
+ export const LocalChainAdminI = M.interface('LocalChainAdmin', {
100
+ setPower: M.callWhen(M.string(), M.await(M.any())).returns(),
62
101
  });
63
102
 
64
103
  /**
@@ -66,29 +105,91 @@ export const LocalChainI = M.interface('LocalChain', {
66
105
  * @param {ReturnType<typeof prepareLocalChainAccount>} createAccount
67
106
  */
68
107
  const prepareLocalChain = (zone, createAccount) =>
69
- zone.exoClass(
108
+ zone.exoClassKit(
70
109
  'LocalChain',
71
- LocalChainI,
72
- /** @param {import('./types.js').ScopedBridgeManager} system */
73
- system => ({ system }),
110
+ { public: LocalChainI, admin: LocalChainAdminI },
111
+ /** @param {Partial<LocalChainPowers>} [initialPowers] */
112
+ initialPowers => {
113
+ /** @type {PowerStore} */
114
+ const powers = zone.detached().mapStore('PowerStore');
115
+ if (initialPowers) {
116
+ for (const [name, power] of Object.entries(initialPowers)) {
117
+ powers.init(/** @type {keyof LocalChainPowers} */ (name), power);
118
+ }
119
+ }
120
+ return { powers };
121
+ },
74
122
  {
75
- async createAccount() {
76
- const { system } = this.state;
77
- // Allocate a fresh address that doesn't correspond with a public key,
78
- // and follows the ICA guidelines to help reduce collisions. See
79
- // x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
80
- // hash and block data hash.
81
- const address = await E(system).toBridge({
82
- type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
83
- });
84
- return createAccount(system, address, this.self);
123
+ admin: {
124
+ /**
125
+ * @template {keyof LocalChainPowers} K
126
+ * @param {K} name
127
+ * @param {LocalChainPowers[K]} [power]
128
+ */
129
+ setPower(name, power) {
130
+ const { powers } = this.state;
131
+ if (power === undefined) {
132
+ // Remove from powers.
133
+ powers.delete(name);
134
+ } else if (powers.has(name)) {
135
+ // Replace an existing power.
136
+ powers.set(name, power);
137
+ } else {
138
+ // Add a new power.
139
+ powers.init(name, power);
140
+ }
141
+ },
85
142
  },
86
- async query(messages) {
87
- const { system } = this.state;
88
- return E(system).toBridge({
89
- type: 'VLOCALCHAIN_QUERY',
90
- messages,
91
- });
143
+ public: {
144
+ /**
145
+ * Allocate a fresh address that doesn't correspond with a public key,
146
+ * and follows the ICA guidelines to help reduce collisions. See
147
+ * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
148
+ * hash and block data hash.
149
+ */
150
+ async createAccount() {
151
+ const { powers } = this.state;
152
+ const system = getPower(powers, 'system');
153
+ const address = await E(system).toBridge({
154
+ type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
155
+ });
156
+ return createAccount(address, powers);
157
+ },
158
+ /**
159
+ * Make a single query to the local chain. Will reject with an error if
160
+ * the query fails. Otherwise, return the response as a JSON-compatible
161
+ * object.
162
+ *
163
+ * @param {Proto3Jsonable} request
164
+ * @returns {Promise<Proto3Jsonable>}
165
+ */
166
+ async query(request) {
167
+ const requests = harden([request]);
168
+ const results = await E(this.facets.public).queryMany(requests);
169
+ results.length === 1 ||
170
+ Fail`expected exactly one result; got ${results}`;
171
+ const { error, reply } = results[0];
172
+ if (error) {
173
+ throw Fail`query failed: ${error}`;
174
+ }
175
+ return reply;
176
+ },
177
+ /**
178
+ * Send a batch of query requests to the local chain. Unless there is a
179
+ * system error, will return all results to indicate their success or
180
+ * failure.
181
+ *
182
+ * @param {Proto3Jsonable[]} requests
183
+ * @returns {Promise<{ error?: string; reply: Proto3Jsonable }[]>}
184
+ */
185
+ async queryMany(requests) {
186
+ const { powers } = this.state;
187
+ const system = getPower(powers, 'system');
188
+ return E(system).toBridge({
189
+ type: 'VLOCALCHAIN_QUERY_MANY',
190
+ messages: requests,
191
+ });
192
+ },
92
193
  },
93
194
  },
94
195
  );
@@ -103,4 +204,5 @@ export const prepareLocalChainTools = zone => {
103
204
  harden(prepareLocalChainTools);
104
205
 
105
206
  /** @typedef {ReturnType<typeof prepareLocalChainTools>} LocalChainTools */
106
- /** @typedef {ReturnType<LocalChainTools['makeLocalChain']>} LocalChain */
207
+ /** @typedef {ReturnType<LocalChainTools['makeLocalChain']>} LocalChainKit */
208
+ /** @typedef {LocalChainKit['public']} LocalChain */
@@ -1,4 +1,4 @@
1
- export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager: bridgeManagerP, localchainBridgeManager: localchainBridgeManagerP, }, produce: { localchainVat, localchain, localchainBridgeManager }, }: WellKnownSpaces & PromiseSpaceOf<ChainBootstrapSpaceT & {
1
+ export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager: bridgeManagerP, localchainBridgeManager: localchainBridgeManagerP, bankManager, }, produce: { localchainVat, localchain, localchainAdmin: localchainAdminP, localchainBridgeManager, }, }: WellKnownSpaces & PromiseSpaceOf<ChainBootstrapSpaceT & {
2
2
  vatAdminSvc: import("@agoric/swingset-vat").VatAdminSvc;
3
3
  }, {}, {
4
4
  loadVat: VatLoader<unknown>;
@@ -400,9 +400,11 @@ export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager:
400
400
  loadCriticalVat: VatLoader<any>;
401
401
  bridgeManager: import('../types').BridgeManager;
402
402
  localchainBridgeManager: import('../types').ScopedBridgeManager;
403
+ bankManager: Promise<import('../vat-bank.js').BankManager>;
403
404
  };
404
405
  produce: {
405
406
  localchain: Producer<any>;
407
+ localchainAdmin: Producer<any>;
406
408
  localchainVat: Producer<any>;
407
409
  localchainBridgeManager: Producer<any>;
408
410
  };
@@ -425,11 +427,14 @@ export function getManifestForLocalChain(_powers: any, { localchainRef }: {
425
427
  loadCriticalVat: boolean;
426
428
  bridgeManager: string;
427
429
  localchainBridgeManager: string;
430
+ bankManager: string;
431
+ transferMiddleware: string;
428
432
  client?: undefined;
429
433
  localchain?: undefined;
430
434
  };
431
435
  produce: {
432
436
  localchain: string;
437
+ localchainAdmin: string;
433
438
  localchainVat: string;
434
439
  localchainBridgeManager: string;
435
440
  };
@@ -440,6 +445,8 @@ export function getManifestForLocalChain(_powers: any, { localchainRef }: {
440
445
  loadCriticalVat?: undefined;
441
446
  bridgeManager?: undefined;
442
447
  localchainBridgeManager?: undefined;
448
+ bankManager?: undefined;
449
+ transferMiddleware?: undefined;
443
450
  };
444
451
  produce?: undefined;
445
452
  };
@@ -1 +1 @@
1
- {"version":3,"file":"localchain-proposal.d.ts","sourceRoot":"","sources":["localchain-proposal.js"],"names":[],"mappings":"AAwBO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAjBiB,UAAU,GAAG,CAAC;uBAChB,OAAO,UAAU,EAAE,aAAa;iCACtB,OAAO,UAAU,EAAE,mBAAmB;;aAExD;QACb,UAAgB,EAAE,SAAS,GAAG,CAAC,CAAC;QAChC,aAAmB,EAAE,SAAS,GAAG,CAAC,CAAC;QACnC,uBAA6B,EAAE,SAAS,GAAG,CAAC,CAAC;KACxC;;;uBAGsB,YAAY;;kBAqDvC;AAUM,2EAPI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAA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;;;;;;;;;;;;;;;EA4BL;6BA/HW;IACZ,UAAc,EAAE,KAAK,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC;CAChE"}
@@ -8,9 +8,11 @@ import { BridgeId as BRIDGE_ID } from '@agoric/internal';
8
8
  * loadCriticalVat: VatLoader<any>;
9
9
  * bridgeManager: import('../types').BridgeManager;
10
10
  * localchainBridgeManager: import('../types').ScopedBridgeManager;
11
+ * bankManager: Promise<import('../vat-bank.js').BankManager>;
11
12
  * };
12
13
  * produce: {
13
14
  * localchain: Producer<any>;
15
+ * localchainAdmin: Producer<any>;
14
16
  * localchainVat: Producer<any>;
15
17
  * localchainBridgeManager: Producer<any>;
16
18
  * };
@@ -28,8 +30,14 @@ export const setupLocalChainVat = async (
28
30
  loadCriticalVat,
29
31
  bridgeManager: bridgeManagerP,
30
32
  localchainBridgeManager: localchainBridgeManagerP,
33
+ bankManager,
34
+ },
35
+ produce: {
36
+ localchainVat,
37
+ localchain,
38
+ localchainAdmin: localchainAdminP,
39
+ localchainBridgeManager,
31
40
  },
32
- produce: { localchainVat, localchain, localchainBridgeManager },
33
41
  },
34
42
  options,
35
43
  ) => {
@@ -66,9 +74,34 @@ export const setupLocalChainVat = async (
66
74
  );
67
75
  }
68
76
 
69
- const newLocalChain = await E(vats.localchain).makeLocalChain(scopedManager);
77
+ const { admin: localChainAdmin, public: newLocalChain } = await E(
78
+ vats.localchain,
79
+ ).makeLocalChain({
80
+ system: scopedManager,
81
+ });
82
+
70
83
  localchain.reset();
71
84
  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
+ );
72
105
  };
73
106
 
74
107
  /**
@@ -93,9 +126,12 @@ export const getManifestForLocalChain = (_powers, { localchainRef }) => ({
93
126
  loadCriticalVat: true,
94
127
  bridgeManager: 'bridge',
95
128
  localchainBridgeManager: 'localchain',
129
+ bankManager: 'bank',
130
+ transferMiddleware: 'transfer',
96
131
  },
97
132
  produce: {
98
133
  localchain: 'localchain',
134
+ localchainAdmin: 'localchain',
99
135
  localchainVat: 'localchain',
100
136
  localchainBridgeManager: 'localchain',
101
137
  },
@@ -1 +1 @@
1
- {"version":3,"file":"localchain-test.d.ts","sourceRoot":"","sources":["localchain-test.js"],"names":[],"mappings":"AAYO,0EARI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH;IAE2C,OAAO,EAA3C;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;kBAwDpC;AAEM;;;;;;;;;;;;;;EAYL"}
1
+ {"version":3,"file":"localchain-test.d.ts","sourceRoot":"","sources":["localchain-test.js"],"names":[],"mappings":"AAYO,0EARI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH;IAE2C,OAAO,EAA3C;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;kBA2DpC;AAEM;;;;;;;;;;;;;;EAYL"}
@@ -31,7 +31,10 @@ export const testLocalChain = async (
31
31
  console.info('created account', lca);
32
32
  const address = await E(lca).getAddress();
33
33
  console.info('address', address);
34
- const balances = await E(lca).allBalances();
34
+ const balances = await E(localchain).query({
35
+ '@type': '/cosmos.bank.v1beta1.QueryAllBalancesRequest',
36
+ address,
37
+ });
35
38
  console.info('balances', balances);
36
39
  await E(lca)
37
40
  .executeTx([
@@ -53,7 +56,7 @@ export const testLocalChain = async (
53
56
  },
54
57
  );
55
58
 
56
- const emptyQuery = await E(localchain).query([]);
59
+ const emptyQuery = await E(localchain).queryMany([]);
57
60
  console.info('emptyQuery', emptyQuery);
58
61
 
59
62
  result = { success: true };
package/src/vat-bank.d.ts CHANGED
@@ -172,5 +172,464 @@ export type Bank = {
172
172
  */
173
173
  getPurse: (brand: Brand) => Promise<VirtualPurse>;
174
174
  };
175
+ export type BankManager = ReturnType<ReturnType<typeof prepareBankManager>>;
175
176
  import { prepareVirtualPurse } from './virtual-purse.js';
177
+ /**
178
+ * @param {import('@agoric/zone').Zone} zone
179
+ * @param {object} makers
180
+ * @param {ReturnType<prepareAssetSubscription>} makers.provideAssetSubscription
181
+ * @param {ReturnType<prepareBank>} makers.makeBank
182
+ * @param {ReturnType<prepareDurablePublishKit>} makers.makePublishKit
183
+ * @param {ReturnType<prepareRewardPurseController>} makers.makeRewardPurseController
184
+ * @param {ReturnType<prepareVirtualPurse>} makers.makeVirtualPurse
185
+ */
186
+ declare function prepareBankManager(zone: import('@agoric/zone').Zone, { provideAssetSubscription, makeBank, makePublishKit, makeRewardPurseController, makeVirtualPurse, }: {
187
+ provideAssetSubscription: ReturnType<(zone: import('@agoric/zone').Zone) => (brandToAssetDescriptor?: any, assetSubscriber?: any) => import("@endo/exo/src/exo-makers.js").Guarded<{
188
+ subscribeAfter(publishCount?: bigint): any;
189
+ [Symbol.asyncIterator](): ForkableAsyncIterableIterator<any, any, undefined>;
190
+ }>>;
191
+ makeBank: ReturnType<(zone: import('@agoric/zone').Zone, { provideAssetSubscription, makePublishKit, makeVirtualPurse }: {
192
+ provideAssetSubscription: ReturnType<(zone: import('@agoric/zone').Zone) => (brandToAssetDescriptor?: any, assetSubscriber?: any) => import("@endo/exo/src/exo-makers.js").Guarded<{
193
+ subscribeAfter(publishCount?: bigint): any;
194
+ [Symbol.asyncIterator](): ForkableAsyncIterableIterator<any, any, undefined>;
195
+ }>>;
196
+ makePublishKit: ReturnType<(baggage: MapStore<string, any>, kindName: string) => (options?: {
197
+ valueDurability?: "mandatory" | undefined;
198
+ } | undefined) => import("@endo/exo/src/exo-makers.js").GuardedKit<{
199
+ publisher: {
200
+ publish(value: any): void;
201
+ finish(finalValue: any): void;
202
+ fail(reason: any): void;
203
+ };
204
+ subscriber: {
205
+ subscribeAfter(publishCount?: bigint): Promise<any>;
206
+ getUpdateSince(updateCount: any): any;
207
+ };
208
+ }>>;
209
+ makeVirtualPurse: ReturnType<(zone: import("@agoric/zone").Zone) => (vpc: ERef<import("./virtual-purse.js").VirtualPurseController>, { escrowPurse: defaultEscrowPurse, ...issuerKit }: {
210
+ issuer: ERef<Issuer<AssetKind>>;
211
+ brand: Brand<AssetKind>;
212
+ mint?: ERef<Mint<AssetKind>> | undefined;
213
+ escrowPurse?: ERef<Purse<AssetKind>> | undefined;
214
+ }) => Promise<{
215
+ /**
216
+ * Get the alleged Brand for this
217
+ * Purse
218
+ */
219
+ getAllegedBrand: () => import("@endo/eventual-send").ERef<{
220
+ /**
221
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
222
+ */
223
+ isMyIssuer: (allegedIssuer: ERef<Issuer<AssetKind>>) => import("@endo/eventual-send").ERef<boolean>;
224
+ getAllegedName: () => import("@endo/eventual-send").ERef<string>;
225
+ /**
226
+ * Give information to UI on how
227
+ * to display the amount.
228
+ */
229
+ getDisplayInfo: () => import("@endo/eventual-send").ERef<DisplayInfo<AssetKind>>;
230
+ getAmountShape: () => any;
231
+ }>;
232
+ /**
233
+ * Get the amount contained in this
234
+ * purse.
235
+ */
236
+ getCurrentAmount: () => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
237
+ /**
238
+ * Get a lossy
239
+ * notifier for changes to this purse's balance.
240
+ */
241
+ getCurrentAmountNotifier: () => import("@endo/eventual-send").ERef<{
242
+ /**
243
+ * Returns a promise for an update record as of an update count.
244
+ * If the `updateCount` argument is omitted or differs from the current update count,
245
+ * the promise promptly resolves to the current record.
246
+ * Otherwise, after the next state change, the promise resolves to the resulting record.
247
+ * This is an attenuated form of `subscribeAfter` whose return value stands alone and
248
+ * does not allow consumers to pin a chain of historical PublicationRecords.
249
+ * Used to make lossy ("latest") iterators.
250
+ * NOTE: Use of `number` as an `updateCount` is deprecated.
251
+ */
252
+ getUpdateSince: (updateCount?: number | bigint | undefined) => import("@endo/eventual-send").ERef<UpdateRecord<Amount<AssetKind>>>;
253
+ }>;
254
+ /**
255
+ * Deposit all the contents of payment into
256
+ * this purse, returning the amount. If the optional argument `optAmount` does
257
+ * not equal the amount of digital assets in the payment, throw an error.
258
+ *
259
+ * If payment is a promise, throw an error.
260
+ */
261
+ deposit: (args_0: Payment<AssetKind>, args_1?: any) => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
262
+ /**
263
+ * Return an object whose
264
+ * `receive` method deposits to the current Purse.
265
+ */
266
+ getDepositFacet: () => import("@endo/eventual-send").ERef<{
267
+ /**
268
+ * Deposit all the contents of payment
269
+ * into the purse that made this facet, returning the amount. If the optional
270
+ * argument `optAmount` does not equal the amount of digital assets in the
271
+ * payment, throw an error.
272
+ *
273
+ * If payment is a promise, throw an error.
274
+ */
275
+ receive: (args_0: Payment<AssetKind>, args_1?: any) => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
276
+ }>;
277
+ /**
278
+ * Withdraw amount from
279
+ * this purse into a new Payment.
280
+ */
281
+ withdraw: (amount: Amount<AssetKind>) => import("@endo/eventual-send").ERef<{
282
+ /**
283
+ * Get the allegedBrand, indicating
284
+ * the type of digital asset this payment purports to be, and which issuer to
285
+ * use. Because payments are not trusted, any method calls on payments should
286
+ * be treated with suspicion and verified elsewhere.
287
+ */
288
+ getAllegedBrand: () => import("@endo/eventual-send").ERef<{
289
+ /**
290
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
291
+ */
292
+ isMyIssuer: (allegedIssuer: ERef<Issuer<AssetKind>>) => import("@endo/eventual-send").ERef<boolean>;
293
+ getAllegedName: () => import("@endo/eventual-send").ERef<string>;
294
+ /**
295
+ * Give information to UI on how
296
+ * to display the amount.
297
+ */
298
+ getDisplayInfo: () => import("@endo/eventual-send").ERef<DisplayInfo<AssetKind>>;
299
+ getAmountShape: () => any;
300
+ }>;
301
+ }>;
302
+ /**
303
+ * The set of payments
304
+ * withdrawn from this purse that are still live. These are the payments that
305
+ * can still be recovered in emergencies by, for example, depositing into this
306
+ * purse. Such a deposit action is like canceling an outstanding check because
307
+ * you're tired of waiting for it. Once your cancellation is acknowledged, you
308
+ * can spend the assets at stake on other things. Afterwards, if the recipient
309
+ * of the original check finally gets around to depositing it, their deposit
310
+ * fails.
311
+ *
312
+ * Returns an empty set if this issuer does not support recovery sets.
313
+ */
314
+ getRecoverySet: () => import("@endo/eventual-send").ERef<CopySet<Payment<AssetKind>>>;
315
+ /**
316
+ * For use in emergencies, such as coming
317
+ * back from a traumatic crash and upgrade. This deposits all the payments in
318
+ * this purse's recovery set into the purse itself, returning the total amount
319
+ * of assets recovered.
320
+ *
321
+ * Returns an empty amount if this issuer does not support recovery sets.
322
+ */
323
+ recoverAll: () => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
324
+ }>>;
325
+ }) => (args_0: {
326
+ address: string;
327
+ assetSubscriber: EachTopic<AssetDescriptor>;
328
+ brandToAssetDescriptor: MapStore<Brand, AssetDescriptor>;
329
+ bankChannel?: BridgeChannel | undefined;
330
+ brandToAssetRecord: MapStore<Brand, AssetRecord>;
331
+ brandToVPurse: MapStore<Brand, VirtualPurse>;
332
+ denomToAddressUpdater: MapStore<string, MapStore<string, BalanceUpdater>>;
333
+ }) => import("@endo/exo/src/exo-makers.js").Guarded<{
334
+ getAssetSubscription(): import("@endo/exo/src/exo-makers.js").Guarded<{
335
+ subscribeAfter(publishCount?: bigint): any;
336
+ [Symbol.asyncIterator](): ForkableAsyncIterableIterator<any, any, undefined>;
337
+ }>;
338
+ /** @param {Brand} brand */
339
+ getPurse(brand: Brand): Promise<{
340
+ /**
341
+ * Get the alleged Brand for this
342
+ * Purse
343
+ */
344
+ getAllegedBrand: () => import("@endo/eventual-send").ERef<{
345
+ /**
346
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
347
+ */
348
+ isMyIssuer: (allegedIssuer: ERef<Issuer<AssetKind>>) => import("@endo/eventual-send").ERef<boolean>;
349
+ getAllegedName: () => import("@endo/eventual-send").ERef<string>;
350
+ /**
351
+ * Give information to UI on how
352
+ * to display the amount.
353
+ */
354
+ getDisplayInfo: () => import("@endo/eventual-send").ERef<DisplayInfo<AssetKind>>;
355
+ getAmountShape: () => any;
356
+ }>;
357
+ /**
358
+ * Get the amount contained in this
359
+ * purse.
360
+ */
361
+ getCurrentAmount: () => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
362
+ /**
363
+ * Get a lossy
364
+ * notifier for changes to this purse's balance.
365
+ */
366
+ getCurrentAmountNotifier: () => import("@endo/eventual-send").ERef<{
367
+ /**
368
+ * Returns a promise for an update record as of an update count.
369
+ * If the `updateCount` argument is omitted or differs from the current update count,
370
+ * the promise promptly resolves to the current record.
371
+ * Otherwise, after the next state change, the promise resolves to the resulting record.
372
+ * This is an attenuated form of `subscribeAfter` whose return value stands alone and
373
+ * does not allow consumers to pin a chain of historical PublicationRecords.
374
+ * Used to make lossy ("latest") iterators.
375
+ * NOTE: Use of `number` as an `updateCount` is deprecated.
376
+ */
377
+ getUpdateSince: (updateCount?: number | bigint | undefined) => import("@endo/eventual-send").ERef<UpdateRecord<Amount<AssetKind>>>;
378
+ }>;
379
+ /**
380
+ * Deposit all the contents of payment into
381
+ * this purse, returning the amount. If the optional argument `optAmount` does
382
+ * not equal the amount of digital assets in the payment, throw an error.
383
+ *
384
+ * If payment is a promise, throw an error.
385
+ */
386
+ deposit: (args_0: Payment<AssetKind>, args_1?: any) => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
387
+ /**
388
+ * Return an object whose
389
+ * `receive` method deposits to the current Purse.
390
+ */
391
+ getDepositFacet: () => import("@endo/eventual-send").ERef<{
392
+ /**
393
+ * Deposit all the contents of payment
394
+ * into the purse that made this facet, returning the amount. If the optional
395
+ * argument `optAmount` does not equal the amount of digital assets in the
396
+ * payment, throw an error.
397
+ *
398
+ * If payment is a promise, throw an error.
399
+ */
400
+ receive: (args_0: Payment<AssetKind>, args_1?: any) => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
401
+ }>;
402
+ /**
403
+ * Withdraw amount from
404
+ * this purse into a new Payment.
405
+ */
406
+ withdraw: (amount: Amount<AssetKind>) => import("@endo/eventual-send").ERef<{
407
+ /**
408
+ * Get the allegedBrand, indicating
409
+ * the type of digital asset this payment purports to be, and which issuer to
410
+ * use. Because payments are not trusted, any method calls on payments should
411
+ * be treated with suspicion and verified elsewhere.
412
+ */
413
+ getAllegedBrand: () => import("@endo/eventual-send").ERef<{
414
+ /**
415
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
416
+ */
417
+ isMyIssuer: (allegedIssuer: ERef<Issuer<AssetKind>>) => import("@endo/eventual-send").ERef<boolean>;
418
+ getAllegedName: () => import("@endo/eventual-send").ERef<string>;
419
+ /**
420
+ * Give information to UI on how
421
+ * to display the amount.
422
+ */
423
+ getDisplayInfo: () => import("@endo/eventual-send").ERef<DisplayInfo<AssetKind>>;
424
+ getAmountShape: () => any;
425
+ }>;
426
+ }>;
427
+ /**
428
+ * The set of payments
429
+ * withdrawn from this purse that are still live. These are the payments that
430
+ * can still be recovered in emergencies by, for example, depositing into this
431
+ * purse. Such a deposit action is like canceling an outstanding check because
432
+ * you're tired of waiting for it. Once your cancellation is acknowledged, you
433
+ * can spend the assets at stake on other things. Afterwards, if the recipient
434
+ * of the original check finally gets around to depositing it, their deposit
435
+ * fails.
436
+ *
437
+ * Returns an empty set if this issuer does not support recovery sets.
438
+ */
439
+ getRecoverySet: () => import("@endo/eventual-send").ERef<CopySet<Payment<AssetKind>>>;
440
+ /**
441
+ * For use in emergencies, such as coming
442
+ * back from a traumatic crash and upgrade. This deposits all the payments in
443
+ * this purse's recovery set into the purse itself, returning the total amount
444
+ * of assets recovered.
445
+ *
446
+ * Returns an empty amount if this issuer does not support recovery sets.
447
+ */
448
+ recoverAll: () => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
449
+ }>;
450
+ }>>;
451
+ makePublishKit: ReturnType<(baggage: MapStore<string, any>, kindName: string) => (options?: {
452
+ valueDurability?: "mandatory" | undefined;
453
+ } | undefined) => import("@endo/exo/src/exo-makers.js").GuardedKit<{
454
+ publisher: {
455
+ publish(value: any): void;
456
+ finish(finalValue: any): void;
457
+ fail(reason: any): void;
458
+ };
459
+ subscriber: {
460
+ subscribeAfter(publishCount?: bigint): Promise<any>;
461
+ getUpdateSince(updateCount: any): any;
462
+ };
463
+ }>>;
464
+ makeRewardPurseController: ReturnType<(zone: import('@agoric/zone').Zone) => (bankChannel: BridgeChannel, denom: string, brand: Brand<AssetKind>) => import("@endo/exo/src/exo-makers.js").Guarded<{
465
+ getBalances(b: any): Notifier<any>;
466
+ pullAmount(_amount: any): Promise<never>;
467
+ pushAmount(amount: any): Promise<void>;
468
+ }>>;
469
+ makeVirtualPurse: ReturnType<(zone: import("@agoric/zone").Zone) => (vpc: ERef<import("./virtual-purse.js").VirtualPurseController>, { escrowPurse: defaultEscrowPurse, ...issuerKit }: {
470
+ issuer: ERef<Issuer<AssetKind>>;
471
+ brand: Brand<AssetKind>;
472
+ mint?: ERef<Mint<AssetKind>> | undefined;
473
+ escrowPurse?: ERef<Purse<AssetKind>> | undefined;
474
+ }) => Promise<{
475
+ /**
476
+ * Get the alleged Brand for this
477
+ * Purse
478
+ */
479
+ getAllegedBrand: () => import("@endo/eventual-send").ERef<{
480
+ /**
481
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
482
+ */
483
+ isMyIssuer: (allegedIssuer: ERef<Issuer<AssetKind>>) => import("@endo/eventual-send").ERef<boolean>;
484
+ getAllegedName: () => import("@endo/eventual-send").ERef<string>;
485
+ /**
486
+ * Give information to UI on how
487
+ * to display the amount.
488
+ */
489
+ getDisplayInfo: () => import("@endo/eventual-send").ERef<DisplayInfo<AssetKind>>;
490
+ getAmountShape: () => any;
491
+ }>;
492
+ /**
493
+ * Get the amount contained in this
494
+ * purse.
495
+ */
496
+ getCurrentAmount: () => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
497
+ /**
498
+ * Get a lossy
499
+ * notifier for changes to this purse's balance.
500
+ */
501
+ getCurrentAmountNotifier: () => import("@endo/eventual-send").ERef<{
502
+ /**
503
+ * Returns a promise for an update record as of an update count.
504
+ * If the `updateCount` argument is omitted or differs from the current update count,
505
+ * the promise promptly resolves to the current record.
506
+ * Otherwise, after the next state change, the promise resolves to the resulting record.
507
+ * This is an attenuated form of `subscribeAfter` whose return value stands alone and
508
+ * does not allow consumers to pin a chain of historical PublicationRecords.
509
+ * Used to make lossy ("latest") iterators.
510
+ * NOTE: Use of `number` as an `updateCount` is deprecated.
511
+ */
512
+ getUpdateSince: (updateCount?: number | bigint | undefined) => import("@endo/eventual-send").ERef<UpdateRecord<Amount<AssetKind>>>;
513
+ }>;
514
+ /**
515
+ * Deposit all the contents of payment into
516
+ * this purse, returning the amount. If the optional argument `optAmount` does
517
+ * not equal the amount of digital assets in the payment, throw an error.
518
+ *
519
+ * If payment is a promise, throw an error.
520
+ */
521
+ deposit: (args_0: Payment<AssetKind>, args_1?: any) => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
522
+ /**
523
+ * Return an object whose
524
+ * `receive` method deposits to the current Purse.
525
+ */
526
+ getDepositFacet: () => import("@endo/eventual-send").ERef<{
527
+ /**
528
+ * Deposit all the contents of payment
529
+ * into the purse that made this facet, returning the amount. If the optional
530
+ * argument `optAmount` does not equal the amount of digital assets in the
531
+ * payment, throw an error.
532
+ *
533
+ * If payment is a promise, throw an error.
534
+ */
535
+ receive: (args_0: Payment<AssetKind>, args_1?: any) => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
536
+ }>;
537
+ /**
538
+ * Withdraw amount from
539
+ * this purse into a new Payment.
540
+ */
541
+ withdraw: (amount: Amount<AssetKind>) => import("@endo/eventual-send").ERef<{
542
+ /**
543
+ * Get the allegedBrand, indicating
544
+ * the type of digital asset this payment purports to be, and which issuer to
545
+ * use. Because payments are not trusted, any method calls on payments should
546
+ * be treated with suspicion and verified elsewhere.
547
+ */
548
+ getAllegedBrand: () => import("@endo/eventual-send").ERef<{
549
+ /**
550
+ * Should be used with `issuer.getBrand` to ensure an issuer and brand match.
551
+ */
552
+ isMyIssuer: (allegedIssuer: ERef<Issuer<AssetKind>>) => import("@endo/eventual-send").ERef<boolean>;
553
+ getAllegedName: () => import("@endo/eventual-send").ERef<string>;
554
+ /**
555
+ * Give information to UI on how
556
+ * to display the amount.
557
+ */
558
+ getDisplayInfo: () => import("@endo/eventual-send").ERef<DisplayInfo<AssetKind>>;
559
+ getAmountShape: () => any;
560
+ }>;
561
+ }>;
562
+ /**
563
+ * The set of payments
564
+ * withdrawn from this purse that are still live. These are the payments that
565
+ * can still be recovered in emergencies by, for example, depositing into this
566
+ * purse. Such a deposit action is like canceling an outstanding check because
567
+ * you're tired of waiting for it. Once your cancellation is acknowledged, you
568
+ * can spend the assets at stake on other things. Afterwards, if the recipient
569
+ * of the original check finally gets around to depositing it, their deposit
570
+ * fails.
571
+ *
572
+ * Returns an empty set if this issuer does not support recovery sets.
573
+ */
574
+ getRecoverySet: () => import("@endo/eventual-send").ERef<CopySet<Payment<AssetKind>>>;
575
+ /**
576
+ * For use in emergencies, such as coming
577
+ * back from a traumatic crash and upgrade. This deposits all the payments in
578
+ * this purse's recovery set into the purse itself, returning the total amount
579
+ * of assets recovered.
580
+ *
581
+ * Returns an empty amount if this issuer does not support recovery sets.
582
+ */
583
+ recoverAll: () => import("@endo/eventual-send").ERef<Amount<AssetKind>>;
584
+ }>>;
585
+ }): (args_0: {
586
+ bankChannel?: BridgeChannel | undefined;
587
+ denomToAddressUpdater: MapStore<string, MapStore<string, BalanceUpdater>>;
588
+ nameAdmin?: Pick<import("./types.js").NameAdmin, "update"> | undefined;
589
+ }) => import("@endo/exo/src/exo-makers.js").Guarded<{
590
+ /**
591
+ * Returns assets as they are added to the bank.
592
+ *
593
+ * @returns {IterableEachTopic<AssetDescriptor>}
594
+ */
595
+ getAssetSubscription(): IterableEachTopic<AssetDescriptor>;
596
+ /**
597
+ * @param {string} denom
598
+ * @param {AssetIssuerKit} feeKit
599
+ * @returns {ERef<import('@endo/far').EOnly<DepositFacet>>}
600
+ */
601
+ getRewardDistributorDepositFacet(denom: string, feeKit: AssetIssuerKit): ERef<import('@endo/far').EOnly<DepositFacet>>;
602
+ /**
603
+ * Get the address of named module account.
604
+ *
605
+ * @param {string} moduleName
606
+ * @returns {Promise<string | null>} address of named module account, or
607
+ * null if unimplemented (no bankChannel)
608
+ */
609
+ getModuleAccountAddress(moduleName: string): Promise<string | null>;
610
+ /**
611
+ * Add an asset to the bank, and publish it to the subscriptions. If
612
+ * nameAdmin is defined, update with denom to AssetInfo entry.
613
+ *
614
+ * Note that AssetInfo has the settled identity of the issuer, not just a
615
+ * promise for it.
616
+ *
617
+ * @param {string} denom lower-level denomination string
618
+ * @param {string} issuerName
619
+ * @param {string} proposedName
620
+ * @param {AssetIssuerKit & { payment?: ERef<Payment> }} kit ERTP issuer
621
+ * kit (mint, brand, issuer)
622
+ */
623
+ addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit<AssetKind> & {
624
+ payment?: ERef<Payment<AssetKind>> | undefined;
625
+ }): Promise<void>;
626
+ /**
627
+ * Create a new personal bank interface for a given address.
628
+ *
629
+ * @param {string} address lower-level bank account address
630
+ * @returns {Promise<Bank>}
631
+ */
632
+ getBankForAddress(address: string): Promise<Bank>;
633
+ }>;
634
+ export {};
176
635
  //# sourceMappingURL=vat-bank.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vat-bank.d.ts","sourceRoot":"","sources":["vat-bank.js"],"names":[],"mappings":"AAy0BA;IASI;;;;;;OAMG;yCALQ,KAAK,OAAO,YAAY,EAAE,mBAAmB,GAAG,SAA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MAAM,GACJ,QAAQ,IAAI,CAAC;GAiC/B"}
package/src/vat-bank.js CHANGED
@@ -787,6 +787,7 @@ const prepareBankManager = (
787
787
  );
788
788
  return makeBankManager;
789
789
  };
790
+ /** @typedef {ReturnType<ReturnType<typeof prepareBankManager>>} BankManager */
790
791
 
791
792
  /** @param {MapStore<string, any>} baggage */
792
793
  const prepareFromBaggage = baggage => {
@@ -3,30 +3,48 @@ 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 {import('./types').ScopedBridgeManager} system
6
+ * @param {Partial<import('./localchain.js').LocalChainPowers>} [initialPowers]
7
7
  */
8
- makeLocalChain(system: import('./types').ScopedBridgeManager): import("@endo/exo/src/exo-makers.js").Guarded<{
9
- createAccount(): Promise<import("@endo/exo/src/exo-makers.js").Guarded<{
10
- getAddress(): Promise<string>;
11
- allBalances(): Promise<any>;
12
- executeTx(messages: any): Promise<any>;
13
- }>>;
14
- query(messages: any): Promise<any>;
8
+ makeLocalChain(initialPowers?: Partial<import("./localchain.js").LocalChainPowers> | undefined): import("@endo/exo/src/exo-makers.js").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
+ createAccount(): Promise<import("@endo/exo/src/exo-makers.js").Guarded<{
14
+ getAddress(): Promise<string>;
15
+ deposit(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
16
+ executeTx(messages: any): Promise<any>;
17
+ }>>;
18
+ query(request: import("./localchain.js").Proto3Jsonable): Promise<import("./localchain.js").Proto3Jsonable>;
19
+ queryMany(requests: import("./localchain.js").Proto3Jsonable[]): Promise<{
20
+ error?: string | undefined;
21
+ reply: import("./localchain.js").Proto3Jsonable;
22
+ }[]>;
23
+ };
15
24
  }>;
16
25
  } & import("@endo/eventual-send").RemotableBrand<{}, {
17
26
  /**
18
27
  * Create a local chain that allows permissionlessly making fresh local
19
28
  * chain accounts, then using them to send chain queries and transactions.
20
29
  *
21
- * @param {import('./types').ScopedBridgeManager} system
30
+ * @param {Partial<import('./localchain.js').LocalChainPowers>} [initialPowers]
22
31
  */
23
- makeLocalChain(system: import('./types').ScopedBridgeManager): import("@endo/exo/src/exo-makers.js").Guarded<{
24
- createAccount(): Promise<import("@endo/exo/src/exo-makers.js").Guarded<{
25
- getAddress(): Promise<string>;
26
- allBalances(): Promise<any>;
27
- executeTx(messages: any): Promise<any>;
28
- }>>;
29
- query(messages: any): Promise<any>;
32
+ makeLocalChain(initialPowers?: Partial<import("./localchain.js").LocalChainPowers> | undefined): import("@endo/exo/src/exo-makers.js").GuardedKit<{
33
+ admin: {
34
+ setPower<K extends keyof import("./localchain.js").LocalChainPowers>(name: K, power?: import("./localchain.js").LocalChainPowers[K] | undefined): void;
35
+ };
36
+ public: {
37
+ createAccount(): Promise<import("@endo/exo/src/exo-makers.js").Guarded<{
38
+ getAddress(): Promise<string>;
39
+ deposit(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
40
+ executeTx(messages: any): Promise<any>;
41
+ }>>;
42
+ query(request: import("./localchain.js").Proto3Jsonable): Promise<import("./localchain.js").Proto3Jsonable>;
43
+ queryMany(requests: import("./localchain.js").Proto3Jsonable[]): Promise<{
44
+ error?: string | undefined;
45
+ reply: import("./localchain.js").Proto3Jsonable;
46
+ }[]>;
47
+ };
30
48
  }>;
31
49
  }>;
32
50
  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;2BADQ,OAAO,SAAS,EAAE,mBAAmB;;;;;;;;;IAJhD;;;;;OAKG;2BADQ,OAAO,SAAS,EAAE,mBAAmB;;;;;;;;GAMnD;4BAEa,WAAW,sBAAsB,CAAC"}
1
+ {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;;;;;;;;;;;;;;;;;;;IALH;;;;;OAKG;;;;;;;;;;;;;;;;;;GAKN;4BAEa,WAAW,sBAAsB,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 {import('./types').ScopedBridgeManager} system
16
+ * @param {Partial<import('./localchain.js').LocalChainPowers>} [initialPowers]
17
17
  */
18
- makeLocalChain(system) {
19
- return makeLocalChain(system);
18
+ makeLocalChain(initialPowers = {}) {
19
+ return makeLocalChain(initialPowers);
20
20
  },
21
21
  });
22
22
  };