@agoric/vats 0.15.2-dev-249a5d4.0 → 0.15.2-dev-5856dc0.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-249a5d4.0+249a5d4",
3
+ "version": "0.15.2-dev-5856dc0.0+5856dc0",
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-249a5d4.0+249a5d4",
26
- "@agoric/cosmic-proto": "0.4.1-dev-249a5d4.0+249a5d4",
27
- "@agoric/ertp": "0.16.3-dev-249a5d4.0+249a5d4",
28
- "@agoric/governance": "0.10.4-dev-249a5d4.0+249a5d4",
29
- "@agoric/internal": "0.3.3-dev-249a5d4.0+249a5d4",
30
- "@agoric/network": "0.1.1-dev-249a5d4.0+249a5d4",
31
- "@agoric/notifier": "0.6.3-dev-249a5d4.0+249a5d4",
32
- "@agoric/store": "0.9.3-dev-249a5d4.0+249a5d4",
33
- "@agoric/swingset-vat": "0.32.3-dev-249a5d4.0+249a5d4",
34
- "@agoric/time": "0.3.3-dev-249a5d4.0+249a5d4",
35
- "@agoric/vat-data": "0.5.3-dev-249a5d4.0+249a5d4",
36
- "@agoric/vow": "0.1.1-dev-249a5d4.0+249a5d4",
37
- "@agoric/zoe": "0.26.3-dev-249a5d4.0+249a5d4",
38
- "@agoric/zone": "0.2.3-dev-249a5d4.0+249a5d4",
25
+ "@agoric/assert": "0.6.1-dev-5856dc0.0+5856dc0",
26
+ "@agoric/cosmic-proto": "0.4.1-dev-5856dc0.0+5856dc0",
27
+ "@agoric/ertp": "0.16.3-dev-5856dc0.0+5856dc0",
28
+ "@agoric/governance": "0.10.4-dev-5856dc0.0+5856dc0",
29
+ "@agoric/internal": "0.3.3-dev-5856dc0.0+5856dc0",
30
+ "@agoric/network": "0.1.1-dev-5856dc0.0+5856dc0",
31
+ "@agoric/notifier": "0.6.3-dev-5856dc0.0+5856dc0",
32
+ "@agoric/store": "0.9.3-dev-5856dc0.0+5856dc0",
33
+ "@agoric/swingset-vat": "0.32.3-dev-5856dc0.0+5856dc0",
34
+ "@agoric/time": "0.3.3-dev-5856dc0.0+5856dc0",
35
+ "@agoric/vat-data": "0.5.3-dev-5856dc0.0+5856dc0",
36
+ "@agoric/vow": "0.1.1-dev-5856dc0.0+5856dc0",
37
+ "@agoric/zoe": "0.26.3-dev-5856dc0.0+5856dc0",
38
+ "@agoric/zone": "0.2.3-dev-5856dc0.0+5856dc0",
39
39
  "@endo/far": "^1.1.2",
40
40
  "@endo/import-bundle": "^1.1.2",
41
41
  "@endo/marshal": "^1.5.0",
@@ -46,7 +46,7 @@
46
46
  "jessie.js": "^0.3.4"
47
47
  },
48
48
  "devDependencies": {
49
- "@agoric/swingset-liveslots": "0.10.3-dev-249a5d4.0+249a5d4",
49
+ "@agoric/swingset-liveslots": "0.10.3-dev-5856dc0.0+5856dc0",
50
50
  "@endo/bundle-source": "^3.2.3",
51
51
  "@endo/init": "^1.1.2",
52
52
  "ava": "^5.3.0",
@@ -78,5 +78,5 @@
78
78
  "typeCoverage": {
79
79
  "atLeast": 91.21
80
80
  },
81
- "gitHead": "249a5d429ebf18be65e8e04ada7acda06e7be02d"
81
+ "gitHead": "5856dc0a002031bdcc1d22a68a6fcf6fa9be38e0"
82
82
  }
package/src/ibc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export function prepareIBCConnectionHandler(zone: Zone): any;
2
2
  export function prepareIBCProtocol(zone: Zone, powers: {
3
- when: <T, TResult1 = import("@agoric/vow").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("@agoric/vow").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
3
+ 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>;
4
4
  watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => import("@agoric/vow").Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
5
5
  makeVowKit: <T_2>() => VowKit<T_2>;
6
6
  allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
package/src/ibc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ibc.d.ts","sourceRoot":"","sources":["ibc.js"],"names":[],"mappings":"AAmDO,yDAFM,GAAG,CAmHf;AAMM;uFAvJJ,CAAC;;;oBASO,SAAS;;cAqJJ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;;;;EAunB7D;AAIM;IAOD;;;OAGG;qBAFQ,MAAM,OACN,GAAG;GAYnB;;;;;;;gBAxxBgB,UAAU;kBACR;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;;0BAbf,mBAAmB;4BAC0B,aAAa;qCAH+B,iBAAiB;mCACyE,YAAY;yCAAZ,YAAY;wCAZjL,iBAAiB;iCAcc,aAAa;oCAFyH,YAAY"}
1
+ {"version":3,"file":"ibc.d.ts","sourceRoot":"","sources":["ibc.js"],"names":[],"mappings":"AAmDO,yDAFM,GAAG,CAmHf;AAMM;wFAvJF,CAAC;;;oBASK,SAAS;;cAqJJ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;;;;EAunB7D;AAIM;IAOD;;;OAGG;qBAFQ,MAAM,OACN,GAAG;GAYnB;;;;;;;gBAxxBgB,UAAU;kBACR;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;;0BAbf,mBAAmB;4BAC0B,aAAa;qCAH+B,iBAAiB;mCACyE,YAAY;yCAAZ,YAAY;wCAZjL,iBAAiB;iCAcc,aAAa;oCAFyH,YAAY"}
@@ -1,8 +1,23 @@
1
1
  /**
2
2
  * @import {TypedJson, ResponseTo, JsonSafe} from '@agoric/cosmic-proto';
3
+ * @import {PromiseVow, VowTools} from '@agoric/vow';
4
+ * @import {TargetApp, TargetRegistration} from './bridge-target.js';
3
5
  * @import {BankManager, Bank} from './vat-bank.js';
4
6
  * @import {ScopedBridgeManager} from './types.js';
5
7
  */
8
+ /**
9
+ * @template {unknown[]} T
10
+ * @typedef {Promise<T>} PromiseVowOfTupleMappedToGenerics Temporary hack
11
+ *
12
+ * UNTIL(microsoft/TypeScript#57122): This type should be replaced with just
13
+ * PromiseVow<T>, but TypeScript doesn't understand that the result of a
14
+ * mapping a tuple type using generics is iterable:
15
+ *
16
+ * 'JsonSafe<MsgTransferResponse & { '@type':
17
+ * "/ibc.applications.transfer.v1.MsgTransferResponse"; }>[] |
18
+ * Vow<JsonSafe<MsgTransferResponse & { ...; }>[]>' must have a
19
+ * '[Symbol.iterator]()' method that returns an iterator.
20
+ */
6
21
  /**
7
22
  * @typedef {{
8
23
  * system: ScopedBridgeManager<'vlocalchain'>;
@@ -25,88 +40,197 @@ export const LocalChainAccountI: import("@endo/patterns").InterfaceGuard<{
25
40
  executeTx: import("@endo/patterns").MethodGuard;
26
41
  monitorTransfers: import("@endo/patterns").MethodGuard;
27
42
  }>;
43
+ export function prepareLocalChainAccountKit(zone: import("@agoric/base-zone").Zone, { watch }: {
44
+ 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>;
45
+ watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => import("@agoric/vow").Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
46
+ makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
47
+ allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
48
+ }): (address: string, powers: AccountPowers) => import("@endo/exo").GuardedKit<{
49
+ depositPaymentWatcher: {
50
+ /**
51
+ * @param {Brand<'nat'>} brand
52
+ * @param {{
53
+ * payment: Payment<'nat'>;
54
+ * optAmountShape: Amount<'nat'>;
55
+ * }} ctx
56
+ */
57
+ onFulfilled(brand: Brand<"nat">, { payment, optAmountShape }: {
58
+ payment: Payment<"nat">;
59
+ optAmountShape: Amount<"nat">;
60
+ }): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
61
+ };
62
+ account: {
63
+ getAddress(): string;
64
+ /**
65
+ * @param {Brand<'nat'>} brand
66
+ * @returns {PromiseVow<Amount<'nat'>>}
67
+ */
68
+ getBalance(brand: Brand<"nat">): PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
69
+ /**
70
+ * Deposit a payment into the bank purse that matches the alleged brand.
71
+ * This is safe, since even if the payment lies about its brand, ERTP
72
+ * will reject spoofed payment objects when depositing into a purse.
73
+ *
74
+ * @param {Payment<'nat'>} payment
75
+ * @param {Pattern} [optAmountShape] throws if the Amount of the Payment
76
+ * does not match the provided Pattern
77
+ * @returns {PromiseVow<Amount<'nat'>>}
78
+ */
79
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
80
+ /**
81
+ * Withdraw a payment from the account's bank purse of the amount's
82
+ * brand.
83
+ *
84
+ * @param {Amount<'nat'>} amount
85
+ * @returns {PromiseVow<Payment<'nat'>>} payment
86
+ */
87
+ withdraw(amount: Amount<"nat">): PromiseVow<globalThis.Payment<"nat">>;
88
+ /**
89
+ * Execute a batch of messages in order as a single atomic transaction
90
+ * and return the responses. If any of the messages fails, the entire
91
+ * batch will be rolled back. Use `typedJson()` on the arguments to get
92
+ * typed return values.
93
+ *
94
+ * @template {TypedJson[]} MT messages tuple (use const with multiple
95
+ * elements or it will be a mixed array)
96
+ * @param {MT} messages
97
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
98
+ * [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>;
99
+ * }>}
100
+ */
101
+ executeTx<MT extends {
102
+ '@type': string;
103
+ }[]>(messages: MT): PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>; }>;
104
+ /**
105
+ * @param {TargetApp} tap
106
+ * @returns {PromiseVow<TargetRegistration>}
107
+ */
108
+ monitorTransfers(tap: TargetApp): PromiseVow<TargetRegistration>;
109
+ };
110
+ }>;
28
111
  /**
29
112
  * @typedef {Awaited<
30
- * ReturnType<Awaited<ReturnType<typeof prepareLocalChainAccount>>>
31
- * >} LocalChainAccount
113
+ * ReturnType<ReturnType<typeof prepareLocalChainAccountKit>>
114
+ * >} LocalChainAccountKit
32
115
  */
116
+ /** @typedef {LocalChainAccountKit['account']} LocalChainAccount */
33
117
  export const LocalChainI: import("@endo/patterns").InterfaceGuard<{
34
118
  makeAccount: import("@endo/patterns").MethodGuard;
35
119
  query: import("@endo/patterns").MethodGuard;
36
120
  queryMany: import("@endo/patterns").MethodGuard;
37
121
  }>;
38
- export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone): {
122
+ export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone, vowTools: {
123
+ 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>;
124
+ watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = never, C = any>(specimenP: import("@agoric/vow").ERef<T_1 | import("@agoric/vow").Vow<T_1>>, watcher?: import("@agoric/vow").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: C | undefined) => import("@agoric/vow").Vow<Exclude<TResult1_1, void> | Exclude<TResult2_1, void> extends never ? TResult1_1 : Exclude<TResult1_1, void> | Exclude<TResult2_1, void>>;
125
+ makeVowKit: <T_2>() => import("@agoric/vow").VowKit<T_2>;
126
+ allVows: (vows: unknown[]) => import("@agoric/vow").Vow<any[]>;
127
+ }): {
39
128
  makeLocalChain: (powers: LocalChainPowers) => import("@endo/exo").Guarded<{
40
129
  /**
41
- * Allocate a fresh address that doesn't correspond with a public key, and
42
- * follows the ICA guidelines to help reduce collisions. See
130
+ * Allocate a fresh address that doesn't correspond with a public key,
131
+ * and follows the ICA guidelines to help reduce collisions. See
43
132
  * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
44
133
  * hash and block data hash.
134
+ *
135
+ * @returns {PromiseVow<LocalChainAccount>}
45
136
  */
46
- makeAccount(): Promise<import("@endo/exo").Guarded<{
137
+ makeAccount(): PromiseVow<import("@endo/exo").Guarded<{
47
138
  getAddress(): string;
48
- /** @param {Brand<'nat'>} brand */
49
- getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
139
+ /**
140
+ * @param {Brand<'nat'>} brand
141
+ * @returns {PromiseVow<Amount<'nat'>>}
142
+ */
143
+ getBalance(brand: Brand<"nat">): PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
50
144
  /**
51
145
  * Deposit a payment into the bank purse that matches the alleged brand.
52
- * This is safe, since even if the payment lies about its brand, ERTP will
53
- * reject spoofed payment objects when depositing into a purse.
146
+ * This is safe, since even if the payment lies about its brand, ERTP
147
+ * will reject spoofed payment objects when depositing into a purse.
54
148
  *
55
149
  * @param {Payment<'nat'>} payment
56
150
  * @param {Pattern} [optAmountShape] throws if the Amount of the Payment
57
151
  * does not match the provided Pattern
58
- * @returns {Promise<Amount>}
152
+ * @returns {PromiseVow<Amount<'nat'>>}
59
153
  */
60
- deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<Amount>;
154
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
61
155
  /**
62
- * Withdraw a payment from the account's bank purse of the amount's brand.
156
+ * Withdraw a payment from the account's bank purse of the amount's
157
+ * brand.
63
158
  *
64
159
  * @param {Amount<'nat'>} amount
65
- * @returns {Promise<Payment<'nat'>>} payment
160
+ * @returns {PromiseVow<Payment<'nat'>>} payment
66
161
  */
67
- withdraw(amount: Amount<"nat">): Promise<Payment<"nat">>;
162
+ withdraw(amount: Amount<"nat">): PromiseVow<globalThis.Payment<"nat">>;
68
163
  /**
69
- * Execute a batch of transactions and return the responses. Use
70
- * `typedJson()` on the arguments to get typed return values.
164
+ * Execute a batch of messages in order as a single atomic transaction
165
+ * and return the responses. If any of the messages fails, the entire
166
+ * batch will be rolled back. Use `typedJson()` on the arguments to get
167
+ * typed return values.
71
168
  *
72
169
  * @template {TypedJson[]} MT messages tuple (use const with multiple
73
170
  * elements or it will be a mixed array)
74
171
  * @param {MT} messages
75
- * @returns {Promise<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>> }>}
172
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
173
+ * [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>;
174
+ * }>}
76
175
  */
77
176
  executeTx<MT extends {
78
177
  '@type': string;
79
- }[]>(messages: MT): Promise<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>; }>;
80
- monitorTransfers(tap: any): Promise<any>;
178
+ }[]>(messages: MT): PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>; }>;
179
+ /**
180
+ * @param {TargetApp} tap
181
+ * @returns {PromiseVow<TargetRegistration>}
182
+ */
183
+ monitorTransfers(tap: TargetApp): PromiseVow<TargetRegistration>;
81
184
  }>>;
82
185
  /**
83
186
  * Make a single query to the local chain. Will reject with an error if
84
187
  * the query fails. Otherwise, return the response as a JSON-compatible
85
188
  * object.
86
189
  *
87
- * @param {import('@agoric/cosmic-proto').TypedJson} request
88
- * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
190
+ * @template {TypedJson} [T=TypedJson]
191
+ * @param {T} request
192
+ * @returns {PromiseVow<JsonSafe<ResponseTo<T>>>}
89
193
  */
90
- query(request: import("@agoric/cosmic-proto").TypedJson): Promise<import("@agoric/cosmic-proto").TypedJson>;
194
+ query<T extends {
195
+ '@type': string;
196
+ } = {
197
+ '@type': string;
198
+ }>(request: T): PromiseVow<JsonSafe<ResponseTo<T>>>;
91
199
  /**
92
200
  * Send a batch of query requests to the local chain. Unless there is a
93
201
  * system error, will return all results to indicate their success or
94
202
  * failure.
95
203
  *
96
- * @param {import('@agoric/cosmic-proto').TypedJson[]} requests
97
- * @returns {Promise<
98
- * {
204
+ * @template {import('@agoric/cosmic-proto').TypedJson[]} RT
205
+ * @param {RT} requests
206
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
207
+ * [K in keyof RT]: JsonSafe<{
99
208
  * error?: string;
100
- * reply: import('@agoric/cosmic-proto').TypedJson;
101
- * }[]
102
- * >}
209
+ * reply: ResponseTo<RT[K]>;
210
+ * }>;
211
+ * }>}
103
212
  */
104
- queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
213
+ queryMany<RT extends {
214
+ '@type': string;
215
+ }[]>(requests: RT): PromiseVowOfTupleMappedToGenerics<{ [K_1 in keyof RT]: JsonSafe<{
105
216
  error?: string;
106
- reply: import("@agoric/cosmic-proto").TypedJson;
107
- }[]>;
217
+ reply: ResponseTo<RT[K_1]>;
218
+ }>; }>;
108
219
  }>;
109
220
  };
221
+ /**
222
+ * Temporary hack
223
+ *
224
+ * UNTIL(microsoft/TypeScript#57122): This type should be replaced with just
225
+ * PromiseVow<T>, but TypeScript doesn't understand that the result of a
226
+ * mapping a tuple type using generics is iterable:
227
+ *
228
+ * 'JsonSafe<MsgTransferResponse & { '@type':
229
+ * "/ibc.applications.transfer.v1.MsgTransferResponse"; }>[] |
230
+ * Vow<JsonSafe<MsgTransferResponse & { ...; }>[]>' must have a
231
+ * '[Symbol.iterator]()' method that returns an iterator.
232
+ */
233
+ export type PromiseVowOfTupleMappedToGenerics<T extends unknown[]> = Promise<T>;
110
234
  export type AccountPowers = {
111
235
  system: ScopedBridgeManager<"vlocalchain">;
112
236
  bank: Bank;
@@ -135,49 +259,15 @@ export type LocalChainPowers = {
135
259
  }>;
136
260
  transfer: import("./transfer.js").TransferMiddleware;
137
261
  };
138
- export type LocalChainAccount = Awaited<ReturnType<Awaited<ReturnType<typeof prepareLocalChainAccount>>>>;
262
+ export type LocalChainAccountKit = Awaited<ReturnType<ReturnType<typeof prepareLocalChainAccountKit>>>;
263
+ export type LocalChainAccount = LocalChainAccountKit["account"];
139
264
  export type LocalChainTools = ReturnType<typeof prepareLocalChainTools>;
140
265
  export type LocalChain = ReturnType<LocalChainTools["makeLocalChain"]>;
266
+ import type { PromiseVow } from '@agoric/vow';
141
267
  import type { ResponseTo } from '@agoric/cosmic-proto';
142
268
  import type { JsonSafe } from '@agoric/cosmic-proto';
269
+ import type { TargetApp } from './bridge-target.js';
270
+ import type { TargetRegistration } from './bridge-target.js';
143
271
  import type { ScopedBridgeManager } from './types.js';
144
272
  import type { Bank } from './vat-bank.js';
145
- /** @param {import('@agoric/base-zone').Zone} zone */
146
- declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone): (address: string, powers: AccountPowers) => import("@endo/exo").Guarded<{
147
- getAddress(): string;
148
- /** @param {Brand<'nat'>} brand */
149
- getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
150
- /**
151
- * Deposit a payment into the bank purse that matches the alleged brand.
152
- * This is safe, since even if the payment lies about its brand, ERTP will
153
- * reject spoofed payment objects when depositing into a purse.
154
- *
155
- * @param {Payment<'nat'>} payment
156
- * @param {Pattern} [optAmountShape] throws if the Amount of the Payment
157
- * does not match the provided Pattern
158
- * @returns {Promise<Amount>}
159
- */
160
- deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<Amount>;
161
- /**
162
- * Withdraw a payment from the account's bank purse of the amount's brand.
163
- *
164
- * @param {Amount<'nat'>} amount
165
- * @returns {Promise<Payment<'nat'>>} payment
166
- */
167
- withdraw(amount: Amount<"nat">): Promise<Payment<"nat">>;
168
- /**
169
- * Execute a batch of transactions and return the responses. Use
170
- * `typedJson()` on the arguments to get typed return values.
171
- *
172
- * @template {TypedJson[]} MT messages tuple (use const with multiple
173
- * elements or it will be a mixed array)
174
- * @param {MT} messages
175
- * @returns {Promise<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>> }>}
176
- */
177
- executeTx<MT extends {
178
- '@type': string;
179
- }[]>(messages: MT): Promise<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>; }>;
180
- monitorTransfers(tap: any): Promise<any>;
181
- }>;
182
- export {};
183
273
  //# sourceMappingURL=localchain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;;GASG;AAgFH;;;;GAIG;AAEH;;;;GAIG;AAwEI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;QAxDtC;;;;;WAKG;;;YA7FH,kCAAkC;8BAAtB,KAAK,CAAC,KAAK,CAAC;YAMxB;;;;;;;;;eASG;6BAJQ,OAAO,CAAC,KAAK,CAAC,mBACd,OAAO,GAEL,OAAO,CAAC,MAAM,CAAC;YAS5B;;;;;eAKG;6BAFQ,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAOpC;;;;;;;;eAQG;sBADyD,EAAE;;2BAAF,EAAE,AADjD;;;QA8Db;;;;;;;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;;;;cA5Lc,OAAO,eAAe,EAAE,kBAAkB;;;;;;gEAiM++X,cAAc;;;;;;;;;;;;+EAAiiD,cAAc,GAAE;YAAE,OAAQ,CAAC,EAAC,KAAM,QAAQ,KAAK,CAAC,CAAC,CAAA;SAAE;;;cAzL3nb,OAAO,eAAe,EAAE,kBAAkB;;gCA8F5C,OAAO,CACnB,UAAc,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CACjE;8BAuFU,UAAU,CAAC,OAAO,sBAAsB,CAAC;yBACzC,UAAU,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;gCAzMT,sBAAsB;8BAAtB,sBAAsB;yCAElC,YAAY;0BADd,eAAe;AA+BnD,qDAAqD;AACrD,gDADY,OAAO,mBAAmB,EAAE,IAAI;;IAetC,kCAAkC;sBAAtB,KAAK,CAAC,KAAK,CAAC;IAMxB;;;;;;;;;OASG;qBAJQ,OAAO,CAAC,KAAK,CAAC,mBACd,OAAO,GAEL,OAAO,CAAC,MAAM,CAAC;IAS5B;;;;;OAKG;qBAFQ,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAOpC;;;;;;;;OAQG;cADyD,EAAE;;mBAAF,EAAE,AADjD;;GAsBhB"}
1
+ {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAWG;AAMI,kDAHI,OAAO,mBAAmB,EAAE,IAAI;wFAhDf,CAAC;;;oBAYH,SAAS;;;QAgE3B;;;;;;WAMG;2BALQ,KAAK,CAAC,KAAK,CAAC,+BACZ;YACV,OAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,cAAkB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;SAC/B;;;;QAYJ;;;WAGG;0BAFQ,KAAK,CAAC,KAAK,CAAC;QAQvB;;;;;;;;;WASG;yBAJQ,OAAO,CAAC,KAAK,CAAC,mBACd,OAAO;QAclB;;;;;;WAMG;yBAFQ,MAAM,CAAC,KAAK,CAAC;QAQxB;;;;;;;;;;;;WAYG;kBAFuC,EAAE;;uBAAF,EAAE,AAF/B;QAmBb;;;WAGG;;;GAOR;AAEH;;;;GAIG;AAEH,mEAAmE;AAEnE;;;;GAIG;AAiHI,6CAHI,OAAO,mBAAmB,EAAE,IAAI;;;;;;6BAP9B,gBAAgB;QA9ErB;;;;;;;WAOG;;;YA5HH;;;eAGG;8BAFQ,KAAK,CAAC,KAAK,CAAC;YAQvB;;;;;;;;;eASG;6BAJQ,OAAO,CAAC,KAAK,CAAC,mBACd,OAAO;YAclB;;;;;;eAMG;6BAFQ,MAAM,CAAC,KAAK,CAAC;YAQxB;;;;;;;;;;;;eAYG;sBAFuC,EAAE;;2BAAF,EAAE,AAF/B;YAmBb;;;eAGG;;;QA8DH;;;;;;;;WAQG;cADyC,CAAC;;;;oBAAD,CAAC,AADjC;QAUZ;;;;;;;;;;;;;WAaG;kBAHsB,EAAE;;uBAAF,EAAE,AAJd,wCAIe,GAAC;oBADd,MAAM;;;;EAoD5B;;;;;;;;;;;;;8CAzSoB,CAAC,sBAAT,OAAO,CAAC,CAAC,CAAC;;;;cAgBR,OAAO,eAAe,EAAE,kBAAkB;;;;;;gEA8RgrR,cAAc;;;;;;;;;;;;+EAAiiD,cAAc,GAAE;YAAE,OAAQ,CAAC,EAAC,KAAM,QAAQ,KAAK,CAAC,CAAC,CAAA;SAAE;;;cAtR5zU,OAAO,eAAe,EAAE,kBAAkB;;mCAgJ5C,OAAO,CACnB,UAAc,CAAC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC,CAC3D;gCAGU,oBAAoB,CAAC,SAAS,CAAC;8BA+H/B,UAAU,CAAC,OAAO,sBAAsB,CAAC;yBACzC,UAAU,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;gCArTpB,aAAa;gCADF,sBAAsB;8BAAtB,sBAAsB;+BAExB,oBAAoB;wCAApB,oBAAoB;yCAE9B,YAAY;0BADd,eAAe"}
package/src/localchain.js CHANGED
@@ -2,15 +2,32 @@
2
2
  import { E } from '@endo/far';
3
3
  import { M } from '@endo/patterns';
4
4
  import { AmountShape, BrandShape, PaymentShape } from '@agoric/ertp';
5
+ import { Shape as NetworkShape } from '@agoric/network';
5
6
 
6
7
  const { Fail } = assert;
7
8
 
8
9
  /**
9
10
  * @import {TypedJson, ResponseTo, JsonSafe} from '@agoric/cosmic-proto';
11
+ * @import {PromiseVow, VowTools} from '@agoric/vow';
12
+ * @import {TargetApp, TargetRegistration} from './bridge-target.js';
10
13
  * @import {BankManager, Bank} from './vat-bank.js';
11
14
  * @import {ScopedBridgeManager} from './types.js';
12
15
  */
13
16
 
17
+ /**
18
+ * @template {unknown[]} T
19
+ * @typedef {Promise<T>} PromiseVowOfTupleMappedToGenerics Temporary hack
20
+ *
21
+ * UNTIL(microsoft/TypeScript#57122): This type should be replaced with just
22
+ * PromiseVow<T>, but TypeScript doesn't understand that the result of a
23
+ * mapping a tuple type using generics is iterable:
24
+ *
25
+ * 'JsonSafe<MsgTransferResponse & { '@type':
26
+ * "/ibc.applications.transfer.v1.MsgTransferResponse"; }>[] |
27
+ * Vow<JsonSafe<MsgTransferResponse & { ...; }>[]>' must have a
28
+ * '[Symbol.iterator]()' method that returns an iterator.
29
+ */
30
+
14
31
  /**
15
32
  * @typedef {{
16
33
  * system: ScopedBridgeManager<'vlocalchain'>;
@@ -30,7 +47,9 @@ const { Fail } = assert;
30
47
  export const LocalChainAccountI = M.interface('LocalChainAccount', {
31
48
  getAddress: M.callWhen().returns(M.string()),
32
49
  getBalance: M.callWhen(BrandShape).returns(AmountShape),
33
- deposit: M.callWhen(PaymentShape).optional(M.pattern()).returns(AmountShape),
50
+ deposit: M.callWhen(PaymentShape)
51
+ .optional(M.pattern())
52
+ .returns(NetworkShape.Vow$(AmountShape)),
34
53
  withdraw: M.callWhen(AmountShape).returns(PaymentShape),
35
54
  executeTx: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
36
55
  monitorTransfers: M.callWhen(M.remotable('TransferTap')).returns(
@@ -38,90 +57,140 @@ export const LocalChainAccountI = M.interface('LocalChainAccount', {
38
57
  ),
39
58
  });
40
59
 
41
- /** @param {import('@agoric/base-zone').Zone} zone */
42
- const prepareLocalChainAccount = zone =>
43
- zone.exoClass(
44
- 'LocalChainAccount',
45
- LocalChainAccountI,
60
+ /**
61
+ * @param {import('@agoric/base-zone').Zone} zone
62
+ * @param {VowTools} vowTools
63
+ */
64
+ export const prepareLocalChainAccountKit = (zone, { watch }) =>
65
+ zone.exoClassKit(
66
+ 'LocalChainAccountKit',
67
+ {
68
+ account: LocalChainAccountI,
69
+ depositPaymentWatcher: M.interface('DepositPaymentWatcher', {
70
+ onFulfilled: M.call(BrandShape)
71
+ .optional({
72
+ payment: PaymentShape,
73
+ optAmountShape: M.or(M.undefined(), AmountShape),
74
+ })
75
+ .returns(M.promise()),
76
+ }),
77
+ },
46
78
  /**
47
79
  * @param {string} address
48
80
  * @param {AccountPowers} powers
49
81
  */
50
- (address, powers) => ({ address, ...powers, reserved: undefined }),
82
+ (address, powers) => ({
83
+ address,
84
+ ...powers,
85
+ reserved: undefined,
86
+ }),
51
87
  {
52
- // Information that the account creator needs.
53
- getAddress() {
54
- return this.state.address;
55
- },
56
- /** @param {Brand<'nat'>} brand */
57
- async getBalance(brand) {
58
- const { bank } = this.state;
59
- const purse = E(bank).getPurse(brand);
60
- return E(purse).getCurrentAmount();
61
- },
62
- /**
63
- * Deposit a payment into the bank purse that matches the alleged brand.
64
- * This is safe, since even if the payment lies about its brand, ERTP will
65
- * reject spoofed payment objects when depositing into a purse.
66
- *
67
- * @param {Payment<'nat'>} payment
68
- * @param {Pattern} [optAmountShape] throws if the Amount of the Payment
69
- * does not match the provided Pattern
70
- * @returns {Promise<Amount>}
71
- */
72
- async deposit(payment, optAmountShape) {
73
- const { bank } = this.state;
74
-
75
- const allegedBrand = await E(payment).getAllegedBrand();
76
- const purse = E(bank).getPurse(allegedBrand);
77
- return E(purse).deposit(payment, optAmountShape);
78
- },
79
- /**
80
- * Withdraw a payment from the account's bank purse of the amount's brand.
81
- *
82
- * @param {Amount<'nat'>} amount
83
- * @returns {Promise<Payment<'nat'>>} payment
84
- */
85
- async withdraw(amount) {
86
- const { bank } = this.state;
87
- const purse = E(bank).getPurse(amount.brand);
88
- return E(purse).withdraw(amount);
89
- },
90
- /**
91
- * Execute a batch of transactions and return the responses. Use
92
- * `typedJson()` on the arguments to get typed return values.
93
- *
94
- * @template {TypedJson[]} MT messages tuple (use const with multiple
95
- * elements or it will be a mixed array)
96
- * @param {MT} messages
97
- * @returns {Promise<{ [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>> }>}
98
- */
99
- async executeTx(messages) {
100
- const { address, system } = this.state;
101
- messages.length > 0 || Fail`need at least one message to execute`;
102
-
103
- const obj = {
104
- type: 'VLOCALCHAIN_EXECUTE_TX',
105
- // This address is the only one that `VLOCALCHAIN_EXECUTE_TX` will
106
- // accept as a signer for the transaction. If the messages have other
107
- // addresses in signer positions, the transaction will be aborted.
108
- address,
109
- messages,
110
- };
111
- return E(system).toBridge(obj);
88
+ depositPaymentWatcher: {
89
+ /**
90
+ * @param {Brand<'nat'>} brand
91
+ * @param {{
92
+ * payment: Payment<'nat'>;
93
+ * optAmountShape: Amount<'nat'>;
94
+ * }} ctx
95
+ */
96
+ onFulfilled(brand, { payment, optAmountShape }) {
97
+ const purse = E(this.state.bank).getPurse(brand);
98
+ return E(purse).deposit(payment, optAmountShape);
99
+ },
112
100
  },
113
- async monitorTransfers(tap) {
114
- const { address, transfer } = this.state;
115
- return E(transfer).registerTap(address, tap);
101
+ account: {
102
+ // Information that the account creator needs.
103
+ getAddress() {
104
+ return this.state.address;
105
+ },
106
+ /**
107
+ * @param {Brand<'nat'>} brand
108
+ * @returns {PromiseVow<Amount<'nat'>>}
109
+ */
110
+ async getBalance(brand) {
111
+ const { bank } = this.state;
112
+ const purse = E(bank).getPurse(brand);
113
+ return E(purse).getCurrentAmount();
114
+ },
115
+ /**
116
+ * Deposit a payment into the bank purse that matches the alleged brand.
117
+ * This is safe, since even if the payment lies about its brand, ERTP
118
+ * will reject spoofed payment objects when depositing into a purse.
119
+ *
120
+ * @param {Payment<'nat'>} payment
121
+ * @param {Pattern} [optAmountShape] throws if the Amount of the Payment
122
+ * does not match the provided Pattern
123
+ * @returns {PromiseVow<Amount<'nat'>>}
124
+ */
125
+ async deposit(payment, optAmountShape) {
126
+ return watch(
127
+ E(payment).getAllegedBrand(),
128
+ this.facets.depositPaymentWatcher,
129
+ {
130
+ payment,
131
+ optAmountShape,
132
+ },
133
+ );
134
+ },
135
+ /**
136
+ * Withdraw a payment from the account's bank purse of the amount's
137
+ * brand.
138
+ *
139
+ * @param {Amount<'nat'>} amount
140
+ * @returns {PromiseVow<Payment<'nat'>>} payment
141
+ */
142
+ async withdraw(amount) {
143
+ const { bank } = this.state;
144
+ const purse = E(bank).getPurse(amount.brand);
145
+ return E(purse).withdraw(amount);
146
+ },
147
+ /**
148
+ * Execute a batch of messages in order as a single atomic transaction
149
+ * and return the responses. If any of the messages fails, the entire
150
+ * batch will be rolled back. Use `typedJson()` on the arguments to get
151
+ * typed return values.
152
+ *
153
+ * @template {TypedJson[]} MT messages tuple (use const with multiple
154
+ * elements or it will be a mixed array)
155
+ * @param {MT} messages
156
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
157
+ * [K in keyof MT]: JsonSafe<ResponseTo<MT[K]>>;
158
+ * }>}
159
+ */
160
+ async executeTx(messages) {
161
+ const { address, system } = this.state;
162
+ messages.length > 0 || Fail`need at least one message to execute`;
163
+
164
+ const obj = {
165
+ type: 'VLOCALCHAIN_EXECUTE_TX',
166
+ // This address is the only one that `VLOCALCHAIN_EXECUTE_TX` will
167
+ // accept as a signer for the transaction. If the messages have other
168
+ // addresses in signer positions, the transaction will be aborted.
169
+ address,
170
+ messages,
171
+ };
172
+ return E(system).toBridge(obj);
173
+ },
174
+ /**
175
+ * @param {TargetApp} tap
176
+ * @returns {PromiseVow<TargetRegistration>}
177
+ */
178
+ async monitorTransfers(tap) {
179
+ const { address, transfer } = this.state;
180
+ return E(transfer).registerTap(address, tap);
181
+ },
116
182
  },
117
183
  },
118
184
  );
185
+
119
186
  /**
120
187
  * @typedef {Awaited<
121
- * ReturnType<Awaited<ReturnType<typeof prepareLocalChainAccount>>>
122
- * >} LocalChainAccount
188
+ * ReturnType<ReturnType<typeof prepareLocalChainAccountKit>>
189
+ * >} LocalChainAccountKit
123
190
  */
124
191
 
192
+ /** @typedef {LocalChainAccountKit['account']} LocalChainAccount */
193
+
125
194
  export const LocalChainI = M.interface('LocalChain', {
126
195
  makeAccount: M.callWhen().returns(M.remotable('LocalChainAccount')),
127
196
  query: M.callWhen(M.record()).returns(M.record()),
@@ -130,77 +199,118 @@ export const LocalChainI = M.interface('LocalChain', {
130
199
 
131
200
  /**
132
201
  * @param {import('@agoric/base-zone').Zone} zone
133
- * @param {ReturnType<typeof prepareLocalChainAccount>} makeAccount
202
+ * @param {ReturnType<typeof prepareLocalChainAccountKit>} makeAccountKit
203
+ * @param {VowTools} vowTools
134
204
  */
135
- const prepareLocalChain = (zone, makeAccount) =>
136
- zone.exoClass(
137
- 'LocalChain',
138
- LocalChainI,
205
+ const prepareLocalChain = (zone, makeAccountKit, { watch }) => {
206
+ const makeLocalChainKit = zone.exoClassKit(
207
+ 'LocalChainKit',
208
+ {
209
+ public: LocalChainI,
210
+ extractFirstQueryResultWatcher: M.interface(
211
+ 'ExtractFirstQueryResultWatcher',
212
+ {
213
+ onFulfilled: M.call(M.arrayOf(M.record())).returns(M.record()),
214
+ },
215
+ ),
216
+ },
139
217
  /** @param {LocalChainPowers} powers */
140
218
  powers => {
141
219
  return { ...powers };
142
220
  },
143
221
  {
144
- /**
145
- * Allocate a fresh address that doesn't correspond with a public key, and
146
- * 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 makeAccount() {
151
- const { system, bankManager, transfer } = this.state;
152
- const address = await E(system).toBridge({
153
- type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
154
- });
155
- const bank = await E(bankManager).getBankForAddress(address);
156
- return makeAccount(address, { system, bank, transfer });
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 {import('@agoric/cosmic-proto').TypedJson} request
164
- * @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
165
- */
166
- async query(request) {
167
- const requests = harden([request]);
168
- const results = await E(this.self).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;
222
+ public: {
223
+ /**
224
+ * Allocate a fresh address that doesn't correspond with a public key,
225
+ * and follows the ICA guidelines to help reduce collisions. See
226
+ * x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
227
+ * hash and block data hash.
228
+ *
229
+ * @returns {PromiseVow<LocalChainAccount>}
230
+ */
231
+ async makeAccount() {
232
+ const { system, bankManager, transfer } = this.state;
233
+ const address = await E(system).toBridge({
234
+ type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
235
+ });
236
+ const bank = await E(bankManager).getBankForAddress(address);
237
+ return makeAccountKit(address, { system, bank, transfer }).account;
238
+ },
239
+ /**
240
+ * Make a single query to the local chain. Will reject with an error if
241
+ * the query fails. Otherwise, return the response as a JSON-compatible
242
+ * object.
243
+ *
244
+ * @template {TypedJson} [T=TypedJson]
245
+ * @param {T} request
246
+ * @returns {PromiseVow<JsonSafe<ResponseTo<T>>>}
247
+ */
248
+ async query(request) {
249
+ const requests = harden([request]);
250
+ return watch(
251
+ E(this.facets.public).queryMany(requests),
252
+ this.facets.extractFirstQueryResultWatcher,
253
+ );
254
+ },
255
+ /**
256
+ * Send a batch of query requests to the local chain. Unless there is a
257
+ * system error, will return all results to indicate their success or
258
+ * failure.
259
+ *
260
+ * @template {import('@agoric/cosmic-proto').TypedJson[]} RT
261
+ * @param {RT} requests
262
+ * @returns {PromiseVowOfTupleMappedToGenerics<{
263
+ * [K in keyof RT]: JsonSafe<{
264
+ * error?: string;
265
+ * reply: ResponseTo<RT[K]>;
266
+ * }>;
267
+ * }>}
268
+ */
269
+ async queryMany(requests) {
270
+ const { system } = this.state;
271
+ return E(system).toBridge({
272
+ type: 'VLOCALCHAIN_QUERY_MANY',
273
+ messages: requests,
274
+ });
275
+ },
176
276
  },
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 {import('@agoric/cosmic-proto').TypedJson[]} requests
183
- * @returns {Promise<
184
- * {
185
- * error?: string;
186
- * reply: import('@agoric/cosmic-proto').TypedJson;
187
- * }[]
188
- * >}
189
- */
190
- async queryMany(requests) {
191
- const { system } = this.state;
192
- return E(system).toBridge({
193
- type: 'VLOCALCHAIN_QUERY_MANY',
194
- messages: requests,
195
- });
277
+ extractFirstQueryResultWatcher: {
278
+ /**
279
+ * Extract the first result from the array of results or throw an error
280
+ * if that result failed.
281
+ *
282
+ * @param {JsonSafe<{
283
+ * error?: string;
284
+ * reply: TypedJson<any>;
285
+ * }>[]} results
286
+ */
287
+ onFulfilled(results) {
288
+ results.length === 1 ||
289
+ Fail`expected exactly one result; got ${results}`;
290
+ const { error, reply } = results[0];
291
+ if (error) {
292
+ throw Fail`query failed: ${error}`;
293
+ }
294
+ return reply;
295
+ },
196
296
  },
197
297
  },
198
298
  );
199
299
 
200
- /** @param {import('@agoric/base-zone').Zone} zone */
201
- export const prepareLocalChainTools = zone => {
202
- const makeAccount = prepareLocalChainAccount(zone);
203
- const makeLocalChain = prepareLocalChain(zone, makeAccount);
300
+ /**
301
+ * @param {LocalChainPowers} powers
302
+ */
303
+ const makeLocalChain = powers => makeLocalChainKit(powers).public;
304
+ return makeLocalChain;
305
+ };
306
+
307
+ /**
308
+ * @param {import('@agoric/base-zone').Zone} zone
309
+ * @param {VowTools} vowTools
310
+ */
311
+ export const prepareLocalChainTools = (zone, vowTools) => {
312
+ const makeAccountKit = prepareLocalChainAccountKit(zone, vowTools);
313
+ const makeLocalChain = prepareLocalChain(zone, makeAccountKit, vowTools);
204
314
 
205
315
  return harden({ makeLocalChain });
206
316
  };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { E } from '@endo/far';
2
+ import { V as E } from '@agoric/vow/vat.js';
3
3
  import { typedJson } from '@agoric/cosmic-proto/vatsafe';
4
4
 
5
5
  /**
@@ -6,25 +6,27 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
6
6
  * @param {import('./localchain.js').LocalChainPowers} powers
7
7
  */
8
8
  makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
9
- makeAccount(): Promise<import("@endo/exo").Guarded<{
9
+ makeAccount(): import("@agoric/vow").PromiseVow<import("@endo/exo").Guarded<{
10
10
  getAddress(): string;
11
- getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
12
- deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
13
- withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
11
+ getBalance(brand: Brand<"nat">): import("@agoric/vow").PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
12
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): import("@agoric/vow").PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
13
+ withdraw(amount: Amount<"nat">): import("@agoric/vow").PromiseVow<globalThis.Payment<"nat">>;
14
14
  executeTx<MT extends {
15
15
  '@type': string;
16
- }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
17
- monitorTransfers(tap: any): Promise<any>;
16
+ }[]>(messages: MT): import("./localchain.js").PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
17
+ monitorTransfers(tap: import("./bridge-target.js").TargetApp): import("@agoric/vow").PromiseVow<import("./bridge-target.js").TargetRegistration>;
18
18
  }>>;
19
- query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
19
+ query<T extends {
20
20
  '@type': string;
21
- }>;
22
- queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
21
+ } = {
22
+ '@type': string;
23
+ }>(request: T): import("@agoric/vow").PromiseVow<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<T>>>;
24
+ queryMany<RT extends {
25
+ '@type': string;
26
+ }[]>(requests: RT): import("./localchain.js").PromiseVowOfTupleMappedToGenerics<{ [K_1 in keyof RT]: import("@agoric/cosmic-proto").JsonSafe<{
23
27
  error?: string | undefined;
24
- reply: {
25
- '@type': string;
26
- };
27
- }[]>;
28
+ reply: import("@agoric/cosmic-proto").ResponseTo<RT[K_1]>;
29
+ }>; }>;
28
30
  }>;
29
31
  } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
30
32
  /**
@@ -34,25 +36,27 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
34
36
  * @param {import('./localchain.js').LocalChainPowers} powers
35
37
  */
36
38
  makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
37
- makeAccount(): Promise<import("@endo/exo").Guarded<{
39
+ makeAccount(): import("@agoric/vow").PromiseVow<import("@endo/exo").Guarded<{
38
40
  getAddress(): string;
39
- getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
40
- deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
41
- withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
41
+ getBalance(brand: Brand<"nat">): import("@agoric/vow").PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
42
+ deposit(payment: Payment<"nat">, optAmountShape?: Pattern): import("@agoric/vow").PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
43
+ withdraw(amount: Amount<"nat">): import("@agoric/vow").PromiseVow<globalThis.Payment<"nat">>;
42
44
  executeTx<MT extends {
43
45
  '@type': string;
44
- }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
45
- monitorTransfers(tap: any): Promise<any>;
46
+ }[]>(messages: MT): import("./localchain.js").PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
47
+ monitorTransfers(tap: import("./bridge-target.js").TargetApp): import("@agoric/vow").PromiseVow<import("./bridge-target.js").TargetRegistration>;
46
48
  }>>;
47
- query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
49
+ query<T extends {
48
50
  '@type': string;
49
- }>;
50
- queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
51
+ } = {
52
+ '@type': string;
53
+ }>(request: T): import("@agoric/vow").PromiseVow<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<T>>>;
54
+ queryMany<RT extends {
55
+ '@type': string;
56
+ }[]>(requests: RT): import("./localchain.js").PromiseVowOfTupleMappedToGenerics<{ [K_1 in keyof RT]: import("@agoric/cosmic-proto").JsonSafe<{
51
57
  error?: string | undefined;
52
- reply: {
53
- '@type': string;
54
- };
55
- }[]>;
58
+ reply: import("@agoric/cosmic-proto").ResponseTo<RT[K_1]>;
59
+ }>; }>;
56
60
  }>;
57
61
  }>;
58
62
  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,iBAAiB,EAAE,gBAAgB;;;8BASs1B,MAAM,KAAK,CAAC;6BAA8b,QAAQ,KAAK,CAAC,mBAA2B,OAAO;6BAAwhB,OAAO,KAAK,CAAC;;;2BAAgiB,EAAE;;;uBAAg0E,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IAbvgL;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;;;;;;;;;sDASsvJ,SAAS;;;2DAAwsB,SAAS;;;;;;;GAHxgL;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAOO;IASH;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;8BAS4xE,MAAM,KAAK,CAAC;6BAA6gB,QAAQ,KAAK,CAAC,mBAA6B,OAAO;6BAAwjB,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;;;;oBAAqjG,CAAC;;;uBAA6lB,EAAE;;;;;;IAbrzP;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;GAMxD;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
@@ -1,12 +1,17 @@
1
1
  // @ts-check
2
2
  import { Far } from '@endo/far';
3
3
  import { makeDurableZone } from '@agoric/zone/durable.js';
4
+ import { prepareVowTools } from '@agoric/vow/vat.js';
4
5
 
5
6
  import { prepareLocalChainTools } from './localchain.js';
6
7
 
7
8
  export const buildRootObject = (_vatPowers, _args, baggage) => {
8
9
  const zone = makeDurableZone(baggage);
9
- const { makeLocalChain } = prepareLocalChainTools(zone.subZone('localchain'));
10
+ const vowTools = prepareVowTools(zone.subZone('VowTools'));
11
+ const { makeLocalChain } = prepareLocalChainTools(
12
+ zone.subZone('localchain'),
13
+ vowTools,
14
+ );
10
15
 
11
16
  return Far('LocalChainVat', {
12
17
  /**
@@ -45,10 +45,10 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
45
45
  /** @param {Parameters<typeof protocol.unregisterProtocolHandler>} args */
46
46
  unregisterProtocolHandler: (prefix: string, protocolHandler: import("@agoric/internal").Remote<import("@agoric/network").ProtocolHandler>) => void;
47
47
  getPortAllocator(): import("@endo/exo").Guarded<{
48
- allocateCustomIBCPort(specifiedName?: string): import("@agoric/vow").Vow<import("@agoric/network").Port>;
49
- allocateICAControllerPort(): import("@agoric/vow").Vow<import("@agoric/network").Port>;
50
- allocateICQControllerPort(): import("@agoric/vow").Vow<import("@agoric/network").Port>;
51
- allocateCustomLocalPort(specifiedName?: string): import("@agoric/vow").Vow<import("@agoric/network").Port>;
48
+ allocateCustomIBCPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
49
+ allocateICAControllerPort(): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
50
+ allocateICQControllerPort(): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
51
+ allocateCustomLocalPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
52
52
  }>;
53
53
  } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
54
54
  makeLoopbackProtocolHandler: (instancePrefix?: string | undefined) => import("@endo/exo").Guarded<{
@@ -110,10 +110,10 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
110
110
  /** @param {Parameters<typeof protocol.unregisterProtocolHandler>} args */
111
111
  unregisterProtocolHandler: (prefix: string, protocolHandler: import("@agoric/internal").Remote<import("@agoric/network").ProtocolHandler>) => void;
112
112
  getPortAllocator(): import("@endo/exo").Guarded<{
113
- allocateCustomIBCPort(specifiedName?: string): import("@agoric/vow").Vow<import("@agoric/network").Port>;
114
- allocateICAControllerPort(): import("@agoric/vow").Vow<import("@agoric/network").Port>;
115
- allocateICQControllerPort(): import("@agoric/vow").Vow<import("@agoric/network").Port>;
116
- allocateCustomLocalPort(specifiedName?: string): import("@agoric/vow").Vow<import("@agoric/network").Port>;
113
+ allocateCustomIBCPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
114
+ allocateICAControllerPort(): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
115
+ allocateICQControllerPort(): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
116
+ allocateCustomLocalPort(specifiedName?: string): Promise<import("@agoric/vow").Vow<import("@agoric/network").Port>>;
117
117
  }>;
118
118
  }>;
119
119
  //# sourceMappingURL=vat-network.d.ts.map