@agoric/vats 0.15.2-dev-96f4c73.0 → 0.15.2-dev-60cffcf.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-96f4c73.0+96f4c73",
3
+ "version": "0.15.2-dev-60cffcf.0+60cffcf",
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-96f4c73.0+96f4c73",
26
- "@agoric/cosmic-proto": "0.4.1-dev-96f4c73.0+96f4c73",
27
- "@agoric/ertp": "0.16.3-dev-96f4c73.0+96f4c73",
28
- "@agoric/governance": "0.10.4-dev-96f4c73.0+96f4c73",
29
- "@agoric/internal": "0.3.3-dev-96f4c73.0+96f4c73",
30
- "@agoric/network": "0.1.1-dev-96f4c73.0+96f4c73",
31
- "@agoric/notifier": "0.6.3-dev-96f4c73.0+96f4c73",
32
- "@agoric/store": "0.9.3-dev-96f4c73.0+96f4c73",
33
- "@agoric/swingset-vat": "0.32.3-dev-96f4c73.0+96f4c73",
34
- "@agoric/time": "0.3.3-dev-96f4c73.0+96f4c73",
35
- "@agoric/vat-data": "0.5.3-dev-96f4c73.0+96f4c73",
36
- "@agoric/vow": "0.1.1-dev-96f4c73.0+96f4c73",
37
- "@agoric/zoe": "0.26.3-dev-96f4c73.0+96f4c73",
38
- "@agoric/zone": "0.2.3-dev-96f4c73.0+96f4c73",
25
+ "@agoric/assert": "0.6.1-dev-60cffcf.0+60cffcf",
26
+ "@agoric/cosmic-proto": "0.4.1-dev-60cffcf.0+60cffcf",
27
+ "@agoric/ertp": "0.16.3-dev-60cffcf.0+60cffcf",
28
+ "@agoric/governance": "0.10.4-dev-60cffcf.0+60cffcf",
29
+ "@agoric/internal": "0.3.3-dev-60cffcf.0+60cffcf",
30
+ "@agoric/network": "0.1.1-dev-60cffcf.0+60cffcf",
31
+ "@agoric/notifier": "0.6.3-dev-60cffcf.0+60cffcf",
32
+ "@agoric/store": "0.9.3-dev-60cffcf.0+60cffcf",
33
+ "@agoric/swingset-vat": "0.32.3-dev-60cffcf.0+60cffcf",
34
+ "@agoric/time": "0.3.3-dev-60cffcf.0+60cffcf",
35
+ "@agoric/vat-data": "0.5.3-dev-60cffcf.0+60cffcf",
36
+ "@agoric/vow": "0.1.1-dev-60cffcf.0+60cffcf",
37
+ "@agoric/zoe": "0.26.3-dev-60cffcf.0+60cffcf",
38
+ "@agoric/zone": "0.2.3-dev-60cffcf.0+60cffcf",
39
39
  "@endo/base64": "^1.0.5",
40
40
  "@endo/far": "^1.1.2",
41
41
  "@endo/import-bundle": "^1.1.2",
@@ -47,7 +47,7 @@
47
47
  "jessie.js": "^0.3.4"
48
48
  },
49
49
  "devDependencies": {
50
- "@agoric/swingset-liveslots": "0.10.3-dev-96f4c73.0+96f4c73",
50
+ "@agoric/swingset-liveslots": "0.10.3-dev-60cffcf.0+60cffcf",
51
51
  "@endo/bundle-source": "^3.2.3",
52
52
  "@endo/init": "^1.1.2",
53
53
  "ava": "^5.3.0",
@@ -80,5 +80,5 @@
80
80
  "typeCoverage": {
81
81
  "atLeast": 91.27
82
82
  },
83
- "gitHead": "96f4c736b0762c592c4e2d778304f693cfc8e681"
83
+ "gitHead": "60cffcf3b14bfd0f4902c00764904aa5de0b81ad"
84
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"basic-behaviors.d.ts","sourceRoot":"","sources":["basic-behaviors.js"],"names":[],"mappings":"AA0DO,mIANI,eAAe,GAAG,EAAE,iBAiE9B;AAIM,gDADK,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,iBAW/C;AAGM,0FADK,cAAc,GAAG;IAAE,IAAI,EAAE,OAAO,cAAc,EAAE,IAAI,CAAA;CAAE,iB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;SAAE,CAAA;KAAE,CAAC;CACzD,iBAmCH;AAUM,kTAJI,cAAc,GAAG;IAC3B,OAAW,EAAE;QAAE,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC;CACxD,iBAwFH;AAGD,wDAAwD;AACxD,sCADW,OAAO,eAAe,EAAE,iBAAiB,CA0IlD;;qBA/fW,IAAI,CAAC,UAAU,gDAAyC,CAAC;gCAiCzD,IAAI,CAChB,UAAc,2DAAoD,CAC/D;;;;;;;;;;;;;sCA5T+B,sBAAsB"}
@@ -653,7 +653,9 @@ export const addBankAssets = async ({
653
653
  });
654
654
 
655
655
  const bldBrand = await E(bldIssuer).getBrand();
656
- const bldKit = harden({ mint: bldMint, issuer: bldIssuer, brand: bldBrand });
656
+ const bldKit = /** @type {IssuerKit<'nat'>} */ (
657
+ harden({ mint: bldMint, issuer: bldIssuer, brand: bldBrand })
658
+ );
657
659
  bldIssuerKit.resolve(bldKit);
658
660
 
659
661
  const assetAdmin = E(agoricNamesAdmin).lookupAdmin('vbankAsset');
@@ -1 +1 @@
1
- {"version":3,"file":"startWalletFactory.d.ts","sourceRoot":"","sources":["startWalletFactory.js"],"names":[],"mappings":"AAiFO,qnBArBI,eAAe,GACzB,qBAAyB,GACzB,cAAkB,CAAC;IACnB,6BAAmC,EAAE,OAAO,qCAAqC,EAAE,+BAA+B,CAAC;IACnH,cAAoB,EAAE;QACtB,YAAoB,EAAE,OAAO,CAC7B,UAAoB,CACpB,oEAAyE,OAAO,CAAC,CACtE,CACF,CAAC,cAAc,CAAC,CAAC;QAC1B,UAAkB,EAAE,UAAU,CAAC;KACxB,CAAC;IACR,mBAAyB,EAAE,OAAO,aAAa,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC/E,4BAAkC,EAAE,OAAO,aAAa,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;CAC5F,CAAC;cAEQ;QACd,sBAA4B,CAAC,EAAE,MAAM,C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7 +390,7 @@ type ChainBootstrapSpaceT = {
390
390
  GovernanceFacetKit<any> & { label: string }
391
391
  >;
392
392
  /** Used only for testing. Should not appear in any production proposals. */
393
- testFirstAnchorKit: import('../vat-bank.js').AssetIssuerKit<'nat'>;
393
+ testFirstAnchorKit: import('../vat-bank.js').AssetIssuerKit;
394
394
  walletBridgeManager: import('../types.js').ScopedBridgeManager | undefined;
395
395
  walletFactoryStartResult: import('./startWalletFactory.js').WalletFactoryStartResult;
396
396
  provisionPoolStartResult: GovernanceFacetKit<
@@ -17,6 +17,7 @@
17
17
  */
18
18
  export const LocalChainAccountI: import("@endo/patterns").InterfaceGuard<{
19
19
  getAddress: import("@endo/patterns").MethodGuard;
20
+ getBalance: import("@endo/patterns").MethodGuard;
20
21
  deposit: import("@endo/patterns").MethodGuard;
21
22
  withdraw: import("@endo/patterns").MethodGuard;
22
23
  executeTx: import("@endo/patterns").MethodGuard;
@@ -41,6 +42,8 @@ export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone):
41
42
  */
42
43
  makeAccount(): Promise<import("@endo/exo").Guarded<{
43
44
  getAddress(): Promise<string>;
45
+ /** @param {Brand<'nat'>} brand */
46
+ getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
44
47
  /**
45
48
  * Deposit a payment into the bank purse that matches the alleged brand.
46
49
  * This is safe, since even if the payment lies about its brand, ERTP will
@@ -56,9 +59,9 @@ export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone):
56
59
  * Withdraw a payment from the account's bank purse of the amount's brand.
57
60
  *
58
61
  * @param {Amount<'nat'>} amount
59
- * @returns {Promise<Payment>} payment
62
+ * @returns {Promise<Payment<'nat'>>} payment
60
63
  */
61
- withdraw(amount: Amount<"nat">): Promise<Payment>;
64
+ withdraw(amount: Amount<"nat">): Promise<Payment<"nat">>;
62
65
  /**
63
66
  * Execute a batch of transactions and return the responses. Use
64
67
  * `typedJson()` on the arguments to get typed return values.
@@ -121,7 +124,7 @@ export type LocalChainPowers = {
121
124
  }>;
122
125
  getModuleAccountAddress(moduleName: string): Promise<string | null>;
123
126
  addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
124
- payment?: ERef<Payment>;
127
+ payment?: ERef<Payment<"nat">>;
125
128
  }): Promise<void>;
126
129
  getBankForAddress(address: string): Promise<Bank>;
127
130
  }>;
@@ -135,6 +138,8 @@ import type { Bank } from './vat-bank.js';
135
138
  /** @param {import('@agoric/base-zone').Zone} zone */
136
139
  declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone): (address: string, powers: AccountPowers) => import("@endo/exo").Guarded<{
137
140
  getAddress(): Promise<string>;
141
+ /** @param {Brand<'nat'>} brand */
142
+ getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
138
143
  /**
139
144
  * Deposit a payment into the bank purse that matches the alleged brand.
140
145
  * This is safe, since even if the payment lies about its brand, ERTP will
@@ -150,9 +155,9 @@ declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone
150
155
  * Withdraw a payment from the account's bank purse of the amount's brand.
151
156
  *
152
157
  * @param {Amount<'nat'>} amount
153
- * @returns {Promise<Payment>} payment
158
+ * @returns {Promise<Payment<'nat'>>} payment
154
159
  */
155
- withdraw(amount: Amount<"nat">): Promise<Payment>;
160
+ withdraw(amount: Amount<"nat">): Promise<Payment<"nat">>;
156
161
  /**
157
162
  * Execute a batch of transactions and return the responses. Use
158
163
  * `typedJson()` on the arguments to get typed return values.
@@ -1 +1 @@
1
- {"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAOA;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAsEH;;;;GAIG;AAEH;;;;GAIG;AAwEI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;QAxDtC;;;;;WAKG;;;YAnFH;;;;;;;;;eASG;6BAJQ,OAAO,CAAC,KAAK,CAAC,mBACd,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C,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;cADgD,EAAE;;mBAAF,EAAE,AADxC;GAkBhB"}
package/src/localchain.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
  import { E } from '@endo/far';
3
3
  import { M } from '@endo/patterns';
4
- import { AmountShape, PaymentShape } from '@agoric/ertp';
4
+ import { AmountShape, BrandShape, PaymentShape } from '@agoric/ertp';
5
5
 
6
6
  const { Fail } = assert;
7
7
 
@@ -27,6 +27,7 @@ const { Fail } = assert;
27
27
 
28
28
  export const LocalChainAccountI = M.interface('LocalChainAccount', {
29
29
  getAddress: M.callWhen().returns(M.string()),
30
+ getBalance: M.callWhen(BrandShape).returns(AmountShape),
30
31
  deposit: M.callWhen(PaymentShape).optional(M.pattern()).returns(AmountShape),
31
32
  withdraw: M.callWhen(AmountShape).returns(PaymentShape),
32
33
  executeTx: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
@@ -47,6 +48,12 @@ const prepareLocalChainAccount = zone =>
47
48
  async getAddress() {
48
49
  return this.state.address;
49
50
  },
51
+ /** @param {Brand<'nat'>} brand */
52
+ async getBalance(brand) {
53
+ const { bank } = this.state;
54
+ const purse = E(bank).getPurse(brand);
55
+ return E(purse).getCurrentAmount();
56
+ },
50
57
  /**
51
58
  * Deposit a payment into the bank purse that matches the alleged brand.
52
59
  * This is safe, since even if the payment lies about its brand, ERTP will
@@ -68,7 +75,7 @@ const prepareLocalChainAccount = zone =>
68
75
  * Withdraw a payment from the account's bank purse of the amount's brand.
69
76
  *
70
77
  * @param {Amount<'nat'>} amount
71
- * @returns {Promise<Payment>} payment
78
+ * @returns {Promise<Payment<'nat'>>} payment
72
79
  */
73
80
  async withdraw(amount) {
74
81
  const { bank } = this.state;
package/src/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Bytes } from '@agoric/network';
2
- import type { PromiseVow } from '@agoric/vow';
2
+ import type { PromiseVow, Remote } from '@agoric/vow';
3
3
  import type { Guarded } from '@endo/exo';
4
4
  import type { ERef } from '@endo/far';
5
5
  import type { BridgeIdValue } from '@agoric/internal';
@@ -106,15 +106,15 @@ export type ScopedBridgeManager<BridgeId extends BridgeIdValue> = Guarded<{
106
106
  getBridgeId?: () => BridgeId;
107
107
  toBridge: (obj: any) => Promise<any>;
108
108
  fromBridge: (obj: any) => PromiseVow<void>;
109
- initHandler: (handler: ERef<BridgeHandler>) => void;
110
- setHandler: (handler: ERef<BridgeHandler>) => void;
109
+ initHandler: (handler: Remote<BridgeHandler>) => void;
110
+ setHandler: (handler: Remote<BridgeHandler>) => void;
111
111
  }>;
112
112
 
113
113
  /** The object to manage this bridge */
114
114
  export type BridgeManager = {
115
115
  register: <BridgeId extends BridgeIdValue>(
116
116
  bridgeId: BridgeId,
117
- handler?: ERef<BridgeHandler | undefined>,
117
+ handler?: Remote<BridgeHandler | undefined>,
118
118
  ) => ScopedBridgeManager<BridgeId>;
119
119
  };
120
120
 
package/src/vat-bank.d.ts CHANGED
@@ -45,11 +45,11 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
45
45
  * @param {string} denom lower-level denomination string
46
46
  * @param {string} issuerName
47
47
  * @param {string} proposedName
48
- * @param {AssetIssuerKit & { payment?: ERef<Payment> }} kit ERTP issuer
49
- * kit (mint, brand, issuer)
48
+ * @param {AssetIssuerKit & { payment?: ERef<Payment<'nat'>> }} kit ERTP
49
+ * issuer kit (mint, brand, issuer)
50
50
  */
51
51
  addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
52
- payment?: ERef<Payment>;
52
+ payment?: ERef<Payment<"nat">>;
53
53
  }): Promise<void>;
54
54
  /**
55
55
  * Create a new personal bank interface for a given address.
@@ -106,11 +106,11 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
106
106
  * @param {string} denom lower-level denomination string
107
107
  * @param {string} issuerName
108
108
  * @param {string} proposedName
109
- * @param {AssetIssuerKit & { payment?: ERef<Payment> }} kit ERTP issuer
110
- * kit (mint, brand, issuer)
109
+ * @param {AssetIssuerKit & { payment?: ERef<Payment<'nat'>> }} kit ERTP
110
+ * issuer kit (mint, brand, issuer)
111
111
  */
112
112
  addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
113
- payment?: ERef<Payment>;
113
+ payment?: ERef<Payment<"nat">>;
114
114
  }): Promise<void>;
115
115
  /**
116
116
  * Create a new personal bank interface for a given address.
@@ -124,7 +124,7 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
124
124
  /**
125
125
  * @typedef {AssetIssuerKit & {
126
126
  * denom: string;
127
- * escrowPurse?: RemotableObject & ERef<Purse>;
127
+ * escrowPurse?: RemotableObject & ERef<Purse<'nat'>>;
128
128
  * }} AssetRecord
129
129
  */
130
130
  /**
@@ -162,15 +162,15 @@ export type BalanceUpdater = {
162
162
  } & import("../../../node_modules/@endo/exo/src/get-interface.js").GetInterfaceGuard<{
163
163
  update: (value: string, nonce?: string) => void;
164
164
  }>> & RemotableObject;
165
- export type BridgeChannel = Pick<import("./types.js").ScopedBridgeManager<any>, "fromBridge" | "toBridge">;
166
- export type AssetIssuerKit<K extends globalThis.AssetKind = globalThis.AssetKind> = {
167
- mint?: globalThis.Mint<K> | undefined;
168
- issuer: Issuer<K>;
169
- brand: Brand<K>;
165
+ export type BridgeChannel = Pick<import("./types.js").ScopedBridgeManager<"bank">, "getBridgeId" | "fromBridge" | "toBridge">;
166
+ export type AssetIssuerKit = {
167
+ mint?: globalThis.Mint<"nat"> | undefined;
168
+ issuer: Issuer<"nat">;
169
+ brand: Brand<"nat">;
170
170
  };
171
- export type AssetRecord = AssetIssuerKit<globalThis.AssetKind> & {
171
+ export type AssetRecord = AssetIssuerKit & {
172
172
  denom: string;
173
- escrowPurse?: (RemotableObject & globalThis.ERef<globalThis.Purse>) | undefined;
173
+ escrowPurse?: (RemotableObject & globalThis.ERef<globalThis.Purse<"nat">>) | undefined;
174
174
  };
175
175
  export type AssetDescriptor = {
176
176
  brand: Brand;
@@ -222,7 +222,6 @@ declare function prepareBankManager(zone: import("@agoric/zone").Zone, { provide
222
222
  } | undefined) => import("@endo/exo").GuardedKit<{
223
223
  publisher: {
224
224
  publish(value: any): void;
225
- /** @type {MapStore<string, VirtualPurse>} */
226
225
  finish(finalValue: any): void;
227
226
  fail(reason: any): void;
228
227
  };
@@ -232,11 +231,11 @@ declare function prepareBankManager(zone: import("@agoric/zone").Zone, { provide
232
231
  };
233
232
  }>>;
234
233
  makeVirtualPurse: ReturnType<(zone: import("@agoric/zone").Zone) => (vpc: ERef<VirtualPurseController>, { escrowPurse: defaultEscrowPurse, ...issuerKit }: {
235
- issuer: ERef<Issuer>;
236
- brand: Brand;
237
- mint?: ERef<Mint>;
238
- escrowPurse?: ERef<Purse>;
239
- }) => Promise<globalThis.Purse>>;
234
+ issuer: ERef<Issuer<"nat">>;
235
+ brand: Brand<"nat">;
236
+ mint?: ERef<Mint<"nat">>;
237
+ escrowPurse?: ERef<Purse<"nat">>;
238
+ }) => Promise<globalThis.Purse<"nat">>>;
240
239
  }) => (args_0: {
241
240
  address: string;
242
241
  assetSubscriber: EachTopic<AssetDescriptor>;
@@ -251,14 +250,13 @@ declare function prepareBankManager(zone: import("@agoric/zone").Zone, { provide
251
250
  [Symbol.asyncIterator](): import("@agoric/notifier").ForkableAsyncIterableIterator<any, any>;
252
251
  }>;
253
252
  /** @param {Brand} brand */
254
- getPurse(brand: Brand): Promise<RemotableObject & import("@agoric/ertp/src/types.js").PurseMethods<globalThis.AssetKind, import("@endo/patterns").Key>>;
253
+ getPurse(brand: Brand): Promise<RemotableObject & import("@agoric/ertp/src/types.js").PurseMethods<"nat", import("@endo/patterns").Key>>;
255
254
  }>>;
256
255
  makePublishKit: ReturnType<(baggage: import("@agoric/swingset-liveslots").Baggage, kindName: string) => (options?: {
257
256
  valueDurability?: "mandatory" | undefined;
258
257
  } | undefined) => import("@endo/exo").GuardedKit<{
259
258
  publisher: {
260
259
  publish(value: any): void;
261
- /** @type {MapStore<string, VirtualPurse>} */
262
260
  finish(finalValue: any): void;
263
261
  fail(reason: any): void;
264
262
  };
@@ -273,11 +271,11 @@ declare function prepareBankManager(zone: import("@agoric/zone").Zone, { provide
273
271
  pushAmount(amount: any): Promise<void>;
274
272
  }>>;
275
273
  makeVirtualPurse: ReturnType<(zone: import("@agoric/zone").Zone) => (vpc: ERef<VirtualPurseController>, { escrowPurse: defaultEscrowPurse, ...issuerKit }: {
276
- issuer: ERef<Issuer>;
277
- brand: Brand;
278
- mint?: ERef<Mint>;
279
- escrowPurse?: ERef<Purse>;
280
- }) => Promise<globalThis.Purse>>;
274
+ issuer: ERef<Issuer<"nat">>;
275
+ brand: Brand<"nat">;
276
+ mint?: ERef<Mint<"nat">>;
277
+ escrowPurse?: ERef<Purse<"nat">>;
278
+ }) => Promise<globalThis.Purse<"nat">>>;
281
279
  }): (args_0: {
282
280
  bankChannel?: BridgeChannel | undefined;
283
281
  denomToAddressUpdater: MapStore<string, MapStore<string, BalanceUpdater>>;
@@ -317,11 +315,11 @@ declare function prepareBankManager(zone: import("@agoric/zone").Zone, { provide
317
315
  * @param {string} denom lower-level denomination string
318
316
  * @param {string} issuerName
319
317
  * @param {string} proposedName
320
- * @param {AssetIssuerKit & { payment?: ERef<Payment> }} kit ERTP issuer
321
- * kit (mint, brand, issuer)
318
+ * @param {AssetIssuerKit & { payment?: ERef<Payment<'nat'>> }} kit ERTP
319
+ * issuer kit (mint, brand, issuer)
322
320
  */
323
321
  addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
324
- payment?: ERef<Payment>;
322
+ payment?: ERef<Payment<"nat">>;
325
323
  }): Promise<void>;
326
324
  /**
327
325
  * Create a new personal bank interface for a given address.
@@ -1 +1 @@
1
- {"version":3,"file":"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2B;wBAAf,KAAK;OAyFW;IACsB,cAAc,EAA3D,UAAU,gDAjKK,OAAO;;;;;;;;;;;;OAiKc;IACa,yBAAyB,EAA1E,UAAU,QAhaT,OAAO,cAAc,EAAE,IAAI;;;;OAgaY;IACA,gBAAgB,EAAxD,UAAU,+BAjPU,IAC9B;;;YASmB,CAAC;mBAEM,CAAC;2CAqOc;;;2BAoB3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;;;IAwC3D;;;;OAIG;4BADU,iBAAiB,CAAC,eAAe,CAAC;IAS/C;;;;;;;;OAQG;4CAPQ,MAAM,UACN,cAAc,GACZ,IAAI,CAChB,OAAW,WAAW,EAAE,KAAK,CAC7B,OAAa,2BAA2B,EAAE,YAAY,CACjD,CACF;IAkBJ;;;;;;OAMG;wCAHQ,MAAM,GACJ,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAenC;;;;;;;;;;;;OAYG;oBALQ,MAAM,cACN,MAAM,gBACN,MAAM,OACN,cAAc,GAAG;QAAE,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;KAAE;IA2E9D;;;;;OAKG;+BAFQ,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC;GAiC/B;4CA5vBwC,oBAAoB"}
package/src/vat-bank.js CHANGED
@@ -52,8 +52,8 @@ const BalanceUpdaterI = M.interface('BalanceUpdater', {
52
52
 
53
53
  /**
54
54
  * @typedef {Pick<
55
- * import('./types.js').ScopedBridgeManager<any>,
56
- * 'fromBridge' | 'toBridge'
55
+ * import('./types.js').ScopedBridgeManager<'bank'>,
56
+ * 'getBridgeId' | 'fromBridge' | 'toBridge'
57
57
  * >} BridgeChannel
58
58
  */
59
59
 
@@ -199,7 +199,6 @@ const prepareBankChannelHandler = zone =>
199
199
  if (addressToUpdater.has(address)) {
200
200
  updater = addressToUpdater.get(address);
201
201
  }
202
- // console.info('bank balance update', update);
203
202
  } catch (e) {
204
203
  console.error('Unregistered denom in', update, e);
205
204
  }
@@ -207,6 +206,10 @@ const prepareBankChannelHandler = zone =>
207
206
  try {
208
207
  updater.update(value, nonce);
209
208
  } catch (e) {
209
+ // ??? Is this an invariant that should complain louder?
210
+
211
+ // NB: this failure does not propagate. The update() method is
212
+ // responsible for propagating the errow without side-effects.
210
213
  console.error('Error updating balance', update, e);
211
214
  }
212
215
  }
@@ -350,11 +353,10 @@ const prepareAssetSubscription = zone => {
350
353
  };
351
354
 
352
355
  /**
353
- * @template {AssetKind} [K=AssetKind]
354
356
  * @typedef {object} AssetIssuerKit
355
- * @property {Mint<K>} [mint]
356
- * @property {Issuer<K>} issuer
357
- * @property {Brand<K>} brand
357
+ * @property {Mint<'nat'>} [mint]
358
+ * @property {Issuer<'nat'>} issuer
359
+ * @property {Brand<'nat'>} brand
358
360
  */
359
361
 
360
362
  const BaseIssuerKitShape = harden({
@@ -369,7 +371,7 @@ const AssetIssuerKitShape = M.splitRecord(BaseIssuerKitShape, {
369
371
  /**
370
372
  * @typedef {AssetIssuerKit & {
371
373
  * denom: string;
372
- * escrowPurse?: RemotableObject & ERef<Purse>;
374
+ * escrowPurse?: RemotableObject & ERef<Purse<'nat'>>;
373
375
  * }} AssetRecord
374
376
  */
375
377
 
@@ -687,8 +689,8 @@ const prepareBankManager = (
687
689
  * @param {string} denom lower-level denomination string
688
690
  * @param {string} issuerName
689
691
  * @param {string} proposedName
690
- * @param {AssetIssuerKit & { payment?: ERef<Payment> }} kit ERTP issuer
691
- * kit (mint, brand, issuer)
692
+ * @param {AssetIssuerKit & { payment?: ERef<Payment<'nat'>> }} kit ERTP
693
+ * issuer kit (mint, brand, issuer)
692
694
  */
693
695
  async addAsset(denom, issuerName, proposedName, kit) {
694
696
  const {
@@ -882,25 +884,27 @@ export function buildRootObject(_vatPowers, _args, baggage) {
882
884
  'denomToAddressUpdater',
883
885
  );
884
886
 
885
- /** @param {ERef<import('./types.js').ScopedBridgeManager<'bank'>>} [bankBridgeMgr] */
886
- async function getBankChannel(bankBridgeMgr) {
887
+ async function getBankChannel() {
887
888
  // We do the logic here if the bridge manager is available. Otherwise,
888
889
  // the bank is not "remote" (such as on sim-chain), so we just use
889
890
  // immediate purses instead of virtual ones.
890
- if (!bankBridgeMgr) {
891
+ if (!bankBridgeManager) {
892
+ console.warn(
893
+ 'no bank bridge manager, using immediate purses instead of virtual ones',
894
+ );
891
895
  return undefined;
892
896
  }
893
897
 
894
898
  // We need to synchronise with the remote bank.
895
899
  const handler = makeBankChannelHandler(denomToAddressUpdater);
896
- await E(bankBridgeMgr).initHandler(handler);
900
+ await E(bankBridgeManager).initHandler(handler);
897
901
 
898
902
  // We can only downcall to the bank if there exists a bridge manager.
899
- return makeBridgeChannelAttenuator({ target: bankBridgeMgr });
903
+ return makeBridgeChannelAttenuator({ target: bankBridgeManager });
900
904
  }
901
905
 
902
906
  const [bankChannel, nameAdmin] = await Promise.all([
903
- getBankChannel(bankBridgeManager),
907
+ getBankChannel(),
904
908
  nameAdminP,
905
909
  ]);
906
910
  return makeBankManager({
@@ -8,8 +8,9 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
8
8
  makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
9
9
  makeAccount(): Promise<import("@endo/exo").Guarded<{
10
10
  getAddress(): Promise<string>;
11
+ getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
11
12
  deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
12
- withdraw(amount: Amount<"nat">): Promise<globalThis.Payment>;
13
+ withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
13
14
  executeTx<MT extends {
14
15
  '@type': string;
15
16
  }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
@@ -34,8 +35,9 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
34
35
  makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
35
36
  makeAccount(): Promise<import("@endo/exo").Guarded<{
36
37
  getAddress(): Promise<string>;
38
+ getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
37
39
  deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
38
- withdraw(amount: Amount<"nat">): Promise<globalThis.Payment>;
40
+ withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
39
41
  executeTx<MT extends {
40
42
  '@type': string;
41
43
  }[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
@@ -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;;;6BAS6xB,QAAQ,KAAK,CAAC,mBAA2B,OAAO;6BAAwhB,OAAO,KAAK,CAAC;;;2BAAyhB,EAAE;;uBAA6oE,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IAb10J;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;;;;;;;sDASyjI,SAAS;;;2DAAwsB,SAAS;;;;;;;GAH30J;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;8BAS4mB,MAAM,KAAK,CAAC;6BAA8b,QAAQ,KAAK,CAAC,mBAA2B,OAAO;6BAAwhB,OAAO,KAAK,CAAC;;;2BAAgiB,EAAE;;uBAA6oE,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IAb1mK;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;;;;;;;;sDASy1I,SAAS;;;2DAAwsB,SAAS;;;;;;;GAH3mK;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
@@ -34,13 +34,13 @@ export function makeVirtualPurseKitIKit(brandShape?: Pattern, amountShape?: Patt
34
34
  }>;
35
35
  };
36
36
  export function prepareVirtualPurse(zone: import("@agoric/zone").Zone): (vpc: ERef<VirtualPurseController>, { escrowPurse: defaultEscrowPurse, ...issuerKit }: {
37
- issuer: ERef<Issuer>;
38
- brand: Brand;
39
- mint?: ERef<Mint>;
40
- escrowPurse?: ERef<Purse>;
41
- }) => Promise<globalThis.Purse>;
42
- export type Retain = (pmt: Payment, optAmountShape?: Pattern) => Promise<Amount>;
43
- export type Redeem = (amt: Amount) => Promise<Payment>;
37
+ issuer: ERef<Issuer<"nat">>;
38
+ brand: Brand<"nat">;
39
+ mint?: ERef<Mint<"nat">>;
40
+ escrowPurse?: ERef<Purse<"nat">>;
41
+ }) => Promise<globalThis.Purse<"nat">>;
42
+ export type Retain = (pmt: Payment<"nat">, optAmountShape?: Pattern) => Promise<Amount>;
43
+ export type Redeem = (amt: Amount<"nat">) => Promise<Payment<"nat">>;
44
44
  /**
45
45
  * The object that determines the
46
46
  * remote behaviour of a virtual purse.
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-purse.d.ts","sourceRoot":"","sources":["virtual-purse.js"],"names":[],"mappings":"AAoBO,qDAHI,OAAO,gBACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DjB;AAwLM,0CADK,OAAO,cAAc,EAAE,IAAI,SAK1B,IAAI,CAAC,sBAAsB,CAAC,qDAE5B;IACV,MAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,KAAS,EAAE,KAAK,CAAC;IACjB,IAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,WAAe,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C,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;iBAIjC,CAAC,KAAK,EAAE,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC"}
@@ -81,8 +81,13 @@ export const makeVirtualPurseKitIKit = (
81
81
 
82
82
  /** @import {EOnly} from '@endo/far'; */
83
83
 
84
- /** @typedef {(pmt: Payment, optAmountShape?: Pattern) => Promise<Amount>} Retain */
85
- /** @typedef {(amt: Amount) => Promise<Payment>} Redeem */
84
+ /**
85
+ * @typedef {(
86
+ * pmt: Payment<'nat'>,
87
+ * optAmountShape?: Pattern,
88
+ * ) => Promise<Amount>} Retain
89
+ */
90
+ /** @typedef {(amt: Amount<'nat'>) => Promise<Payment<'nat'>>} Redeem */
86
91
 
87
92
  /**
88
93
  * @typedef {object} VirtualPurseController The object that determines the
@@ -106,8 +111,15 @@ const prepareVirtualPurseKit = zone =>
106
111
  makeVirtualPurseKitIKit().VirtualPurseIKit,
107
112
  /**
108
113
  * @param {ERef<VirtualPurseController>} vpc
109
- * @param {{ issuer: ERef<Issuer>; brand: Brand; mint?: ERef<Mint> }} issuerKit
110
- * @param {{ recoveryPurse: ERef<Purse>; escrowPurse?: ERef<Purse> }} purses
114
+ * @param {{
115
+ * issuer: ERef<Issuer>;
116
+ * brand: Brand;
117
+ * mint?: ERef<Mint<'nat'>>;
118
+ * }} issuerKit
119
+ * @param {{
120
+ * recoveryPurse: ERef<Purse<'nat'>>;
121
+ * escrowPurse?: ERef<Purse<'nat'>>;
122
+ * }} purses
111
123
  */
112
124
  (vpc, issuerKit, purses) => ({
113
125
  vpc,
@@ -124,8 +136,9 @@ const prepareVirtualPurseKit = zone =>
124
136
  * this on the `retain` operations (since we are just burning the
125
137
  * payment or depositing it directly in the `escrowPurse`).
126
138
  *
127
- * @param {ERef<Payment>} payment
128
- * @param {Amount} [optAmountShape]
139
+ * @param {ERef<Payment<'nat'>>} payment
140
+ * @param {Amount<'nat'>} [optAmountShape]
141
+ * @returns {Promise<Payment<'nat'>>}
129
142
  */
130
143
  async recoverableClaim(payment, optAmountShape) {
131
144
  const {
@@ -235,6 +248,7 @@ const prepareVirtualPurseKit = zone =>
235
248
  getDepositFacet() {
236
249
  return this.facets.depositFacet;
237
250
  },
251
+ /** @type {(amount: Amount<'nat'>) => Promise<Payment<'nat'>>} */
238
252
  async withdraw(amount) {
239
253
  // Both ensure that the amount exists, and have the other side "send" it
240
254
  // to us. If this fails, the balance is not affected and the withdraw
@@ -268,10 +282,10 @@ export const prepareVirtualPurse = zone => {
268
282
  * @param {ERef<VirtualPurseController>} vpc the controller that represents
269
283
  * the "other side" of this purse.
270
284
  * @param {{
271
- * issuer: ERef<Issuer>;
272
- * brand: Brand;
273
- * mint?: ERef<Mint>;
274
- * escrowPurse?: ERef<Purse>;
285
+ * issuer: ERef<Issuer<'nat'>>;
286
+ * brand: Brand<'nat'>;
287
+ * mint?: ERef<Mint<'nat'>>;
288
+ * escrowPurse?: ERef<Purse<'nat'>>;
275
289
  * }} params
276
290
  * the contents of the issuer kit for "us".
277
291
  *
@@ -280,9 +294,9 @@ export const prepareVirtualPurse = zone => {
280
294
  * general, but escrow doesn't support the case where the "other side" is
281
295
  * also minting assets... our escrow purse may not have enough assets in it
282
296
  * to redeem the ones that are sent from the "other side".
283
- * @returns {Promise<Awaited<EOnly<Purse>>>} This is not just a Purse because
284
- * it plays fast-and-loose with the synchronous Purse interface. So, the
285
- * consumer of this result must only interact with the virtual purse via
297
+ * @returns {Promise<Awaited<EOnly<Purse<'nat'>>>>} This is not just a Purse
298
+ * because it plays fast-and-loose with the synchronous Purse interface. So,
299
+ * the consumer of this result must only interact with the virtual purse via
286
300
  * eventual-send (to conceal the methods that are returning promises instead
287
301
  * of synchronously).
288
302
  */
@@ -1,6 +1,30 @@
1
- export function makeFakeBankKit(issuerKits: Pick<IssuerKit, "brand" | "issuer">[]): {
1
+ export function makeFakeBankKit(issuerKits: Pick<IssuerKit<"nat">, "brand" | "issuer">[]): {
2
2
  addAsset: (denom: string, issuerName: string, proposedName: string, kit: import("../src/vat-bank.js").AssetIssuerKit) => void;
3
3
  assetPublication: globalThis.IterationObserver<import("../src/vat-bank.js").AssetDescriptor>;
4
4
  bank: import("../src/vat-bank.js").Bank;
5
5
  };
6
+ export function makeFakeBankManagerKit(opts?: {
7
+ balances: import("./fake-bridge.js").Balances;
8
+ } | undefined): Promise<{
9
+ bankManager: import("@endo/exo").Guarded<{
10
+ getAssetSubscription(): globalThis.IterableEachTopic<import("../src/vat-bank.js").AssetDescriptor>;
11
+ getRewardDistributorDepositFacet(denom: string, feeKit: AssetIssuerKit): globalThis.ERef<{
12
+ /**
13
+ * Deposit all the contents of payment
14
+ * into the purse that made this facet, returning the amount. If the optional
15
+ * argument `optAmount` does not equal the amount of digital assets in the
16
+ * payment, throw an error.
17
+ *
18
+ * If payment is a promise, throw an error.
19
+ */
20
+ receive: (args_0: globalThis.Payment, args_1?: globalThis.Pattern) => globalThis.ERef<globalThis.Amount>;
21
+ }>;
22
+ getModuleAccountAddress(moduleName: string): Promise<string | null>;
23
+ addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
24
+ payment?: ERef<Payment<"nat">>;
25
+ }): Promise<void>;
26
+ getBankForAddress(address: string): Promise<import("../src/vat-bank.js").Bank>;
27
+ }>;
28
+ pourPayment: (amount: Amount<"nat">) => Promise<Payment<"nat">>;
29
+ }>;
6
30
  //# sourceMappingURL=bank-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bank-utils.d.ts","sourceRoot":"","sources":["bank-utils.js"],"names":[],"mappings":"AAMO,4CADK,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC,EAAE;sBA2BpC,MAAM,cACN,MAAM,gBACN,MAAM,OACN,OAAO,oBAAoB,EAAE,cAAc;;;EAqBvD"}
1
+ {"version":3,"file":"bank-utils.d.ts","sourceRoot":"","sources":["bank-utils.js"],"names":[],"mappings":"AAYO,4CAFI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,EAAE;sBA4B1C,MAAM,cACN,MAAM,gBACN,MAAM,OACN,OAAO,oBAAoB,EAAE,cAAc;;;EAqBvD;AAMM;cAFI,OAAO,kBAAkB,EAAE,QAAQ;;;;gEA0B03gB,cAAc;;;;;;;;;;;;+EAAiiD,cAAc,GAAE;YAAE,OAAQ,CAAC,EAAC,KAAM,QAAQ,KAAK,CAAC,CAAC,CAAA;SAAE;;;0BAX7/jB,MAAM,CAAC,KAAK,CAAC,KACX,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;GASrC"}
@@ -1,9 +1,15 @@
1
1
  import { makeSubscriptionKit } from '@agoric/notifier';
2
- import { makeScalarMapStore } from '@agoric/vat-data';
2
+ import { makeScalarBigMapStore, makeScalarMapStore } from '@agoric/vat-data';
3
+ import { makeDurableZone } from '@agoric/zone/durable.js';
3
4
  import { E } from '@endo/far';
4
5
  import { Far } from '@endo/marshal';
6
+ import { buildRootObject as buildBankVatRoot } from '../src/vat-bank.js';
7
+ import { FAUCET_ADDRESS, makeFakeBankBridge } from './fake-bridge.js';
5
8
 
6
- /** @param {Pick<IssuerKit, 'brand' | 'issuer'>[]} issuerKits */
9
+ /**
10
+ * @deprecated use makeFakeBankManagerKit
11
+ * @param {Pick<IssuerKit<'nat'>, 'brand' | 'issuer'>[]} issuerKits
12
+ */
7
13
  export const makeFakeBankKit = issuerKits => {
8
14
  /** @type {MapStore<Brand, Issuer>} */
9
15
  const issuers = makeScalarMapStore();
@@ -55,3 +61,32 @@ export const makeFakeBankKit = issuerKits => {
55
61
 
56
62
  return { addAsset, assetPublication: publication, bank };
57
63
  };
64
+
65
+ /**
66
+ * @param {object} [opts]
67
+ * @param {import('./fake-bridge.js').Balances} opts.balances initial balances
68
+ */
69
+ export const makeFakeBankManagerKit = async opts => {
70
+ const baggage = makeScalarBigMapStore('baggage');
71
+ const zone = makeDurableZone(baggage);
72
+
73
+ const bankManager = await buildBankVatRoot(
74
+ undefined,
75
+ undefined,
76
+ zone.mapStore('bankManager'),
77
+ ).makeBankManager(makeFakeBankBridge(zone, opts));
78
+
79
+ /**
80
+ * Get a payment from the faucet
81
+ *
82
+ * @param {Amount<'nat'>} amount
83
+ * @returns {Promise<Payment<'nat'>>}
84
+ */
85
+ const pourPayment = async amount => {
86
+ const faucet = await E(bankManager).getBankForAddress(FAUCET_ADDRESS);
87
+ const purse = await E(faucet).getPurse(amount.brand);
88
+ return E(purse).withdraw(amount);
89
+ };
90
+
91
+ return { bankManager, pourPayment };
92
+ };
@@ -1,4 +1,15 @@
1
- export function makeFakeIbcBridge(zone: import("@agoric/zone").Zone, onToBridge: (obj: any) => void, onFromBridge: (handler: any, obj: any) => Promise<void>): ScopedBridgeManager<"dibc">;
2
- export function makeFakeLocalchainBridge(zone: import("@agoric/zone").Zone, onToBridge?: ((obj: any) => void) | undefined, onFromBridge?: ((handler: any, obj: any) => ERef<void>) | undefined): ScopedBridgeManager<"vlocalchain">;
1
+ /** @typedef {{ [address: string]: { [denom: string]: bigint } }} Balances */
2
+ export const FAUCET_ADDRESS: "faucet";
3
+ export function makeFakeBankBridge(zone: import("@agoric/zone").Zone, opts?: {
4
+ balances: Balances;
5
+ }): ScopedBridgeManager<"bank">;
6
+ export function makeFakeIbcBridge(zone: import("@agoric/zone").Zone, onToBridge: (obj: any) => void): ScopedBridgeManager<"dibc">;
7
+ export const LOCALCHAIN_DEFAULT_ADDRESS: "agoric1fakeLCAAddress";
8
+ export function makeFakeLocalchainBridge(zone: import("@agoric/zone").Zone, onToBridge?: ((obj: any) => void) | undefined): ScopedBridgeManager<"vlocalchain">;
9
+ export type Balances = {
10
+ [address: string]: {
11
+ [denom: string]: bigint;
12
+ };
13
+ };
3
14
  import type { ScopedBridgeManager } from '../src/types.js';
4
15
  //# sourceMappingURL=fake-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fake-bridge.d.ts","sourceRoot":"","sources":["fake-bridge.js"],"names":[],"mappings":"AAcO,wCALI,OAAO,cAAc,EAAE,IAAI,cAC3B,CAAC,GAAG,KAAA,KAAK,IAAI,gBACb,CAAC,OAAO,KAAA,EAAE,GAAG,KAAA,KAAK,OAAO,CAAC,IAAI,CAAC,+BA8BzC;AAQM,+CALI,OAAO,cAAc,EAAE,IAAI,8BAClB,IAAI,2DACK,IAAI,CAAC,IAAI,CAAC,mDA+DtC;yCAxGqC,iBAAiB"}
1
+ {"version":3,"file":"fake-bridge.d.ts","sourceRoot":"","sources":["fake-bridge.js"],"names":[],"mappings":"AAeA,6EAA6E;AAE7E,sCAAuC;AAchC,yCANI,OAAO,cAAc,EAAE,IAAI;IAEZ,QAAQ,EAAvB,QAAQ;gCAyFlB;AAOM,wCAJI,OAAO,cAAc,EAAE,IAAI,cAC3B,CAAC,GAAG,KAAA,KAAK,IAAI,+BA+BvB;AAED,iEAAkE;AAO3D,+CAJI,OAAO,cAAc,EAAE,IAAI,8BAClB,IAAI,mDA4DvB;uBA1Ma;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CAAE;yCAPX,iBAAiB"}
@@ -1,18 +1,128 @@
1
- import { Fail } from '@agoric/assert';
2
- import assert from 'node:assert/strict';
1
+ import { assert, Fail } from '@agoric/assert';
2
+ import { makeTracer, VBankAccount } from '@agoric/internal';
3
+ import { E } from '@endo/far';
4
+ import { makeWhen } from '@agoric/vow/src/when.js';
5
+ import { Nat } from '@endo/nat';
3
6
 
4
7
  /**
5
8
  * @import {MsgDelegateResponse} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js';
6
- * @import {ScopedBridgeManager} from '../src/types.js';
9
+ * @import {BridgeHandler, ScopedBridgeManager} from '../src/types.js';
10
+ * @import {Remote} from '@agoric/vow';
7
11
  */
12
+ const trace = makeTracer('FakeBridge');
13
+
14
+ const when = makeWhen();
15
+
16
+ /** @typedef {{ [address: string]: { [denom: string]: bigint } }} Balances */
17
+
18
+ export const FAUCET_ADDRESS = 'faucet';
19
+ const INFINITE_AMOUNT = 99999999999n;
20
+
21
+ /**
22
+ * You can withdraw from the `faucet` address infinitely because its balance is
23
+ * always huge. When you withdraw, it's as if it is topped up again by a Cosmos
24
+ * transaction outside the Agoric VM. (Similarly for deposits.)
25
+ *
26
+ * @param {import('@agoric/zone').Zone} zone
27
+ * @param {object} opts
28
+ * @param {Balances} opts.balances initial balances
29
+ * @returns {ScopedBridgeManager<'bank'>}
30
+ * @see {makeFakeBankManagerKit} and its `pourPayment` for a helper
31
+ */
32
+ export const makeFakeBankBridge = (zone, opts = { balances: {} }) => {
33
+ const { balances } = opts;
34
+
35
+ const currentBalance = ({ address, denom }) =>
36
+ address === FAUCET_ADDRESS
37
+ ? INFINITE_AMOUNT
38
+ : Nat((balances[address] && balances[address][denom]) ?? 0n);
39
+
40
+ let lastNonce = 0n;
41
+ /** @type {Remote<BridgeHandler>} */
42
+ let hndlr;
43
+ return zone.exo('Fake Bank Bridge Manager', undefined, {
44
+ getBridgeId: () => 'bank',
45
+ toBridge: async obj => {
46
+ const { method, type, ...params } = obj;
47
+ trace('toBridge', type, method, params);
48
+ switch (obj.type) {
49
+ case 'VBANK_GET_MODULE_ACCOUNT_ADDRESS': {
50
+ const { moduleName } = obj;
51
+ const moduleDescriptor = Object.values(VBankAccount).find(
52
+ ({ module }) => module === moduleName,
53
+ );
54
+ if (!moduleDescriptor) {
55
+ return 'undefined';
56
+ }
57
+ return moduleDescriptor.address;
58
+ }
59
+
60
+ // Observed message:
61
+ // address: 'agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346',
62
+ // denom: 'ibc/toyatom',
63
+ // type: 'VBANK_GET_BALANCE'
64
+ case 'VBANK_GET_BALANCE': {
65
+ return String(currentBalance(obj));
66
+ }
67
+
68
+ case 'VBANK_GRAB':
69
+ case 'VBANK_GIVE': {
70
+ const { amount, denom } = obj;
71
+ const address = type === 'VBANK_GRAB' ? obj.sender : obj.recipient;
72
+ balances[address] ||= {};
73
+ balances[address][denom] ||= 0n;
74
+
75
+ if (type === 'VBANK_GRAB') {
76
+ balances[address][denom] = Nat(
77
+ currentBalance({ address, denom }) - BigInt(amount),
78
+ );
79
+ } else {
80
+ balances[address][denom] = Nat(
81
+ currentBalance({ address, denom }) + BigInt(amount),
82
+ );
83
+ }
84
+
85
+ lastNonce += 1n;
86
+ // Also empty balances.
87
+ return harden({
88
+ type: 'VBANK_BALANCE_UPDATE',
89
+ nonce: `${lastNonce}`,
90
+ updated: [
91
+ {
92
+ address,
93
+ denom,
94
+ amount: String(currentBalance({ address, denom })),
95
+ },
96
+ ],
97
+ });
98
+ }
99
+ default:
100
+ Fail`unknown type ${type}`;
101
+ }
102
+ },
103
+ fromBridge: async obj => {
104
+ if (!hndlr) throw Error('no handler!');
105
+ trace('fromBridge', obj);
106
+ return when(E(hndlr).fromBridge(obj));
107
+ },
108
+ initHandler: h => {
109
+ if (hndlr) throw Error('already init');
110
+ hndlr = h;
111
+ },
112
+ setHandler: h => {
113
+ if (!hndlr) throw Error('must init first');
114
+ hndlr = h;
115
+ },
116
+ });
117
+ };
8
118
 
9
119
  /**
10
120
  * @param {import('@agoric/zone').Zone} zone
11
121
  * @param {(obj) => void} onToBridge
12
- * @param {(handler, obj) => Promise<void>} onFromBridge
13
122
  * @returns {ScopedBridgeManager<'dibc'>}
14
123
  */
15
- export const makeFakeIbcBridge = (zone, onToBridge, onFromBridge) => {
124
+ export const makeFakeIbcBridge = (zone, onToBridge) => {
125
+ /** @type {Remote<BridgeHandler>} */
16
126
  let hndlr;
17
127
  return zone.exo('Fake IBC Bridge Manager', undefined, {
18
128
  getBridgeId: () => 'dibc',
@@ -28,7 +138,7 @@ export const makeFakeIbcBridge = (zone, onToBridge, onFromBridge) => {
28
138
  },
29
139
  fromBridge: async obj => {
30
140
  if (!hndlr) throw Error('no handler!');
31
- await onFromBridge(hndlr, obj);
141
+ return when(E(hndlr).fromBridge(obj));
32
142
  },
33
143
  initHandler: h => {
34
144
  if (hndlr) throw Error('already init');
@@ -41,17 +151,15 @@ export const makeFakeIbcBridge = (zone, onToBridge, onFromBridge) => {
41
151
  });
42
152
  };
43
153
 
154
+ export const LOCALCHAIN_DEFAULT_ADDRESS = 'agoric1fakeLCAAddress';
155
+
44
156
  /**
45
157
  * @param {import('@agoric/zone').Zone} zone
46
158
  * @param {(obj) => void} [onToBridge]
47
- * @param {(handler, obj) => ERef<void>} [onFromBridge]
48
159
  * @returns {ScopedBridgeManager<'vlocalchain'>}
49
160
  */
50
- export const makeFakeLocalchainBridge = (
51
- zone,
52
- onToBridge = () => {},
53
- onFromBridge = () => {},
54
- ) => {
161
+ export const makeFakeLocalchainBridge = (zone, onToBridge = () => {}) => {
162
+ /** @type {Remote<BridgeHandler>} */
55
163
  let hndlr;
56
164
  let lcaExecuteTxSequence = 0;
57
165
  return zone.exo('Fake Localchain Bridge Manager', undefined, {
@@ -59,10 +167,10 @@ export const makeFakeLocalchainBridge = (
59
167
  toBridge: async obj => {
60
168
  onToBridge(obj);
61
169
  const { method, type, ...params } = obj;
62
- console.info('toBridge', type, method, params);
170
+ trace('toBridge', type, method, params);
63
171
  switch (type) {
64
172
  case 'VLOCALCHAIN_ALLOCATE_ADDRESS':
65
- return 'agoric1fakeLCAAddress';
173
+ return LOCALCHAIN_DEFAULT_ADDRESS;
66
174
  case 'VLOCALCHAIN_EXECUTE_TX': {
67
175
  lcaExecuteTxSequence += 1;
68
176
  return obj.messages.map(message => {
@@ -96,7 +204,7 @@ export const makeFakeLocalchainBridge = (
96
204
  },
97
205
  fromBridge: async obj => {
98
206
  if (!hndlr) throw Error('no handler!');
99
- await onFromBridge(hndlr, obj);
207
+ return when(E(hndlr).fromBridge(obj));
100
208
  },
101
209
  initHandler: h => {
102
210
  if (hndlr) throw Error('already init');