@agoric/smart-wallet 0.5.4-other-dev-d15096d.0.d15096d → 0.5.4-other-dev-ecf44df.0.ecf44df

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.
Files changed (43) hide show
  1. package/package.json +39 -48
  2. package/source-spec-registry.d.ts +13 -0
  3. package/source-spec-registry.d.ts.map +1 -0
  4. package/source-spec-registry.js +17 -0
  5. package/src/index.js +0 -4
  6. package/src/invitations.d.ts +8 -2
  7. package/src/invitations.d.ts.map +1 -1
  8. package/src/invitations.js +7 -3
  9. package/src/marshal-contexts.d.ts +5 -3
  10. package/src/marshal-contexts.d.ts.map +1 -1
  11. package/src/marshal-contexts.js +5 -3
  12. package/src/offerWatcher.d.ts +25 -3
  13. package/src/offerWatcher.d.ts.map +1 -1
  14. package/src/offerWatcher.js +76 -5
  15. package/src/offers.d.ts +2 -1
  16. package/src/offers.d.ts.map +1 -1
  17. package/src/offers.js +1 -1
  18. package/src/proposals/upgrade-wallet-factory2-proposal.js +6 -1
  19. package/src/proposals/upgrade-walletFactory-proposal.js +3 -0
  20. package/src/smartWallet.d.ts +35 -10
  21. package/src/smartWallet.d.ts.map +1 -1
  22. package/src/smartWallet.js +95 -37
  23. package/src/typeGuards.d.ts +13 -1
  24. package/src/typeGuards.js +3 -3
  25. package/src/types.d.ts +9 -1
  26. package/src/types.d.ts.map +1 -1
  27. package/src/types.js +107 -0
  28. package/src/utils.d.ts +21 -25
  29. package/src/utils.d.ts.map +1 -1
  30. package/src/utils.js +12 -23
  31. package/src/walletFactory.d.ts +14 -4
  32. package/src/walletFactory.d.ts.map +1 -1
  33. package/src/walletFactory.js +21 -2
  34. package/tools/fixtures/gameAssetContract.d.ts +12 -0
  35. package/tools/fixtures/gameAssetContract.d.ts.map +1 -0
  36. package/tools/fixtures/gameAssetContract.js +75 -0
  37. package/tools/fixtures/start-game1-proposal.d.ts +14 -0
  38. package/tools/fixtures/start-game1-proposal.d.ts.map +1 -0
  39. package/tools/fixtures/start-game1-proposal.js +122 -0
  40. package/tools/wf-tools.d.ts +109 -0
  41. package/tools/wf-tools.d.ts.map +1 -0
  42. package/tools/wf-tools.js +124 -0
  43. package/src/types.ts +0 -90
package/package.json CHANGED
@@ -1,81 +1,72 @@
1
1
  {
2
2
  "name": "@agoric/smart-wallet",
3
- "version": "0.5.4-other-dev-d15096d.0.d15096d",
3
+ "version": "0.5.4-other-dev-ecf44df.0.ecf44df",
4
4
  "description": "Wallet contract",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Agoric/agoric-sdk.git"
8
+ },
5
9
  "type": "module",
6
10
  "main": "src/index.js",
7
11
  "scripts": {
8
- "build": "yarn build:bundles",
9
- "build:bundles": "node ./scripts/build-bundles.js",
10
- "prepack": "yarn run -T tsc --build tsconfig.build.json",
11
- "postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'",
12
+ "prepack": "yarn run -T prepack-package",
13
+ "postpack": "yarn run -T postpack-package",
12
14
  "test": "ava",
13
15
  "test:c8": "c8 --all $C8_OPTIONS ava",
14
16
  "test:xs": "exit 0",
15
17
  "lint": "yarn run -T run-s --continue-on-error 'lint:*'",
16
18
  "lint-fix": "yarn lint:eslint --fix",
17
- "lint:types": "yarn run -T tsc",
18
- "lint:eslint": "yarn run -T eslint ."
19
+ "lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo",
20
+ "lint:eslint": "node ../../scripts/eslint-repo.mjs ."
19
21
  },
20
22
  "devDependencies": {
21
- "@agoric/casting": "0.4.3-other-dev-d15096d.0.d15096d",
22
- "@agoric/cosmic-proto": "0.4.1-other-dev-d15096d.0.d15096d",
23
- "@agoric/swingset-vat": "0.32.3-other-dev-d15096d.0.d15096d",
24
- "@endo/bundle-source": "^4.1.2",
25
- "@endo/captp": "^4.4.8",
26
- "@endo/init": "^1.1.12",
27
- "ava": "^5.3.0",
23
+ "@agoric/casting": "0.4.3-other-dev-ecf44df.0.ecf44df",
24
+ "@agoric/cosmic-proto": "0.4.1-other-dev-ecf44df.0.ecf44df",
25
+ "@agoric/swingset-vat": "0.32.3-other-dev-ecf44df.0.ecf44df",
26
+ "@endo/bundle-source": "^4.3.2",
27
+ "@endo/captp": "^4.5.1",
28
+ "@endo/init": "^1.1.13",
29
+ "ava": "^8.0.1",
28
30
  "import-meta-resolve": "^4.1.0"
29
31
  },
30
32
  "dependencies": {
31
- "@agoric/ertp": "0.16.3-other-dev-d15096d.0.d15096d",
32
- "@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
33
- "@agoric/notifier": "0.6.3-other-dev-d15096d.0.d15096d",
34
- "@agoric/store": "0.9.3-other-dev-d15096d.0.d15096d",
35
- "@agoric/vat-data": "0.5.3-other-dev-d15096d.0.d15096d",
36
- "@agoric/vats": "0.15.2-other-dev-d15096d.0.d15096d",
37
- "@agoric/vow": "0.1.1-other-dev-d15096d.0.d15096d",
38
- "@agoric/zoe": "0.26.3-other-dev-d15096d.0.d15096d",
39
- "@agoric/zone": "0.2.3-other-dev-d15096d.0.d15096d",
40
- "@endo/errors": "^1.2.13",
41
- "@endo/eventual-send": "^1.3.4",
33
+ "@agoric/ertp": "0.16.3-other-dev-ecf44df.0.ecf44df",
34
+ "@agoric/internal": "0.3.3-other-dev-ecf44df.0.ecf44df",
35
+ "@agoric/notifier": "0.6.3-other-dev-ecf44df.0.ecf44df",
36
+ "@agoric/store": "0.9.3-other-dev-ecf44df.0.ecf44df",
37
+ "@agoric/vat-data": "0.5.3-other-dev-ecf44df.0.ecf44df",
38
+ "@agoric/vats": "0.15.2-other-dev-ecf44df.0.ecf44df",
39
+ "@agoric/vow": "0.1.1-other-dev-ecf44df.0.ecf44df",
40
+ "@agoric/zoe": "0.26.3-other-dev-ecf44df.0.ecf44df",
41
+ "@agoric/zone": "0.2.3-other-dev-ecf44df.0.ecf44df",
42
+ "@endo/errors": "^1.3.1",
43
+ "@endo/eventual-send": "^1.5.0",
42
44
  "@endo/far": "^1.1.14",
43
- "@endo/marshal": "^1.8.0",
44
- "@endo/nat": "^5.1.3",
45
- "@endo/patterns": "^1.7.0",
46
- "@endo/promise-kit": "^1.1.13"
45
+ "@endo/marshal": "^1.10.0",
46
+ "@endo/nat": "^5.2.0",
47
+ "@endo/patterns": "^1.9.1",
48
+ "@endo/promise-kit": "^1.2.1"
47
49
  },
48
50
  "files": [
49
- "src/"
51
+ "src/",
52
+ "tools/",
53
+ "source-spec-registry.*"
50
54
  ],
51
55
  "keywords": [],
52
- "repository": {
53
- "type": "git",
54
- "url": "git+https://github.com/Agoric/agoric"
55
- },
56
56
  "author": "Agoric",
57
57
  "license": "Apache-2.0",
58
58
  "bugs": {
59
- "url": "https://github.com/Agoric/agoric/issues"
60
- },
61
- "homepage": "https://github.com/Agoric/agoric#readme",
62
- "ava": {
63
- "files": [
64
- "test/**/*.test.*"
65
- ],
66
- "require": [
67
- "@endo/init/debug.js"
68
- ],
69
- "timeout": "2m"
59
+ "url": "https://github.com/Agoric/agoric-sdk/issues"
70
60
  },
61
+ "homepage": "https://github.com/Agoric/agoric-sdk#readme",
71
62
  "publishConfig": {
72
63
  "access": "public"
73
64
  },
74
65
  "typeCoverage": {
75
- "atLeast": 93.68
66
+ "atLeast": 94.41
76
67
  },
77
68
  "engines": {
78
- "node": "^20.9 || ^22.11"
69
+ "node": "^22.11 || ^24.14"
79
70
  },
80
- "gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
71
+ "gitHead": "ecf44df5eadcc7a1d68745f056fca19155fb5231"
81
72
  }
@@ -0,0 +1,13 @@
1
+ export namespace smartWalletSourceSpecRegistry {
2
+ namespace walletFactory {
3
+ let bundleName: string;
4
+ let packagePath: string;
5
+ let sourceSpec: string;
6
+ }
7
+ }
8
+ export function getSmartWalletSourceSpec(name: keyof typeof smartWalletSourceSpecRegistry): {
9
+ bundleName: string;
10
+ packagePath: string;
11
+ sourceSpec: string;
12
+ };
13
+ //# sourceMappingURL=source-spec-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-spec-registry.d.ts","sourceRoot":"","sources":["source-spec-registry.js"],"names":[],"mappings":";;;;;;;AAeO,+CADK,MAAM,OAAO,6BAA6B;;;;EAEjB"}
@@ -0,0 +1,17 @@
1
+ import { fileURLToPath } from 'node:url';
2
+
3
+ /** @param {string} packagePath */
4
+ const resolveSourceSpec = packagePath =>
5
+ fileURLToPath(import.meta.resolve(packagePath));
6
+
7
+ export const smartWalletSourceSpecRegistry = {
8
+ walletFactory: {
9
+ bundleName: 'walletFactory',
10
+ packagePath: '@agoric/smart-wallet/src/walletFactory.js',
11
+ sourceSpec: resolveSourceSpec('@agoric/smart-wallet/src/walletFactory.js'),
12
+ },
13
+ };
14
+
15
+ /** @param {keyof typeof smartWalletSourceSpecRegistry} name */
16
+ export const getSmartWalletSourceSpec = name =>
17
+ smartWalletSourceSpecRegistry[name];
package/src/index.js CHANGED
@@ -1,6 +1,2 @@
1
- /// <reference types="@agoric/internal/exported.js" />
2
- /// <reference types="@agoric/ertp/exported.js" />
3
- /// <reference types="@agoric/zoe/exported.js" />
4
-
5
1
  // eslint-disable-next-line import/export
6
2
  export * from './types-index.js'; // no named exports
@@ -20,7 +20,7 @@ export type AgoricContractInvitationSpec = {
20
20
  */
21
21
  export type ContractInvitationSpec = {
22
22
  source: "contract";
23
- instance: Instance;
23
+ instance: Instance<any>;
24
24
  publicInvitationMaker: string;
25
25
  invitationArgs?: any[];
26
26
  };
@@ -32,7 +32,7 @@ export type ContractInvitationSpec = {
32
32
  */
33
33
  export type PurseInvitationSpec = {
34
34
  source: "purse";
35
- instance: Instance;
35
+ instance: Instance<any>;
36
36
  description: string;
37
37
  };
38
38
  /**
@@ -46,8 +46,14 @@ export type ContinuingInvitationSpec = {
46
46
  invitationArgs?: any[];
47
47
  };
48
48
  export type InvitationsPurseQuery = Pick<InvitationDetails, "description" | "instance">;
49
+ import type { ZoeService } from '@agoric/zoe';
50
+ import type { ERef } from '@agoric/vow';
49
51
  import type { NameHub } from '@agoric/vats';
52
+ import type { Brand } from '@agoric/ertp';
50
53
  import type { InvitationDetails } from '@agoric/zoe';
54
+ import type { Purse } from '@agoric/ertp';
51
55
  import type { InvitationMakers } from './types.js';
56
+ import type { Invitation } from '@agoric/zoe';
57
+ import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
52
58
  import type { OfferId } from './offers.js';
53
59
  //# sourceMappingURL=invitations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["invitations.js"],"names":[],"mappings":"AA8EO,2CANI,IAAI,CAAC,UAAU,CAAC,eAChB,IAAI,CAAC,OAAO,CAAC,mBACb,KAAK,CAAC,KAAK,CAAC,oBACZ,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,6BAC/B,CAAC,WAAW,EAAE,MAAM,KAAK,gBAAgB,UAoFhC,cAAc,KAAK,IAAI,CAAC,UAAU,CAAC,CAgBtD;;;;6BA9JY,4BAA4B,GAClC,sBAAsB,GACtB,mBAAmB,GACnB,wBAAwB;;;;;;;;2CAKlB;IACR,MAAM,EAAE,gBAAgB,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;CACtD;;;;qCAQS;IACR,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;CACxB;;;;;;;kCAGS;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;;;;;uCAOS;IACR,MAAM,EAAE,YAAY,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,E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CALsB,aAAa;2BAMjD,cAAc;sCAJH,YAAY;gCAFa,aAAa;8BAG9C,qCAAqC;6BAJtC,aAAa"}
@@ -7,9 +7,13 @@ import { shape } from './typeGuards.js';
7
7
 
8
8
  /**
9
9
  * @import {OfferId} from './offers.js';
10
- * @import {InvitationDetails} from '@agoric/zoe';
10
+ * @import {Invitation, InvitationDetails, ZoeService} from '@agoric/zoe';
11
11
  * @import {NameHub} from '@agoric/vats';
12
12
  * @import {InvitationMakers} from './types.js';
13
+ * @import {Instance} from '@agoric/zoe/src/zoeService/utils.js';
14
+ * @import {ERef} from '@agoric/vow';
15
+ * @import {Brand} from '@agoric/ertp';
16
+ * @import {Purse} from '@agoric/ertp';
13
17
  */
14
18
 
15
19
  // A safety limit
@@ -38,7 +42,7 @@ const MAX_PIPE_LENGTH = 2;
38
42
  *
39
43
  * @typedef {{
40
44
  * source: 'contract';
41
- * instance: Instance;
45
+ * instance: Instance<any>;
42
46
  * publicInvitationMaker: string;
43
47
  * invitationArgs?: any[];
44
48
  * }} ContractInvitationSpec
@@ -46,7 +50,7 @@ const MAX_PIPE_LENGTH = 2;
46
50
  *
47
51
  * @typedef {{
48
52
  * source: 'purse';
49
- * instance: Instance;
53
+ * instance: Instance<any>;
50
54
  * description: string;
51
55
  * }} PurseInvitationSpec
52
56
  * the invitation is already in your Zoe "invitation" purse so we need to query
@@ -3,14 +3,14 @@ export function makeExportContext(): {
3
3
  fromCapData: import("@endo/marshal").FromCapData<string>;
4
4
  serialize: import("@endo/marshal").ToCapData<string>;
5
5
  unserialize: import("@endo/marshal").FromCapData<string>;
6
- savePurseActions: (val: globalThis.Purse) => void;
7
- savePaymentActions: (val: globalThis.Payment) => void;
6
+ savePurseActions: (val: Purse) => void;
7
+ savePaymentActions: (val: Payment) => void;
8
8
  /**
9
9
  * @param {number} id
10
10
  * @param {Purse} purse
11
11
  */
12
12
  initPurseId: (id: number, purse: Purse) => void;
13
- purseEntries: (keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<[number, globalThis.Purse]>;
13
+ purseEntries: (keyPatt?: import("@endo/patterns").Pattern, valuePatt?: import("@endo/patterns").Pattern) => Iterable<[number, Purse]>;
14
14
  /**
15
15
  * @param {BoardId} id
16
16
  * @param {RemotableObject} val
@@ -84,6 +84,8 @@ export type IdTable<Slot extends Key, Val extends PassableCap> = {
84
84
  };
85
85
  export type ExportContext = ReturnType<typeof makeExportContext>;
86
86
  export type ImportContext = ReturnType<typeof makeImportContext>;
87
+ import type { Purse } from '@agoric/ertp';
88
+ import type { Payment } from '@agoric/ertp';
87
89
  import type { BoardId } from '@agoric/vats/src/lib-board.js';
88
90
  import type { RemotableObject } from '@endo/marshal';
89
91
  import type { PassableCap } from '@endo/marshal';
@@ -1 +1 @@
1
- {"version":3,"file":"marshal-contexts.d.ts","sourceRoot":"","sources":["marshal-contexts.js"],"names":[],"mappings":"AAwHO;;;;;;;IAoFH;;;OAGG;sBAFQ,MAAM,SACN,KAAK;;IAMhB;;;OAGG;sBAFQ,OAAO,OACP,eAAe;IAK1B;;;OAGG;wBAFQ,OAAO,OACP,eAAe;EAW7B;AAcM,iDAFI,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW;IA8FrC;;;OAGG;sBAFQ,OAAO,OACP,WAAW;IAKtB;;;OAGG;wBAFQ,OAAO,OACP,WAAW;;;;;;;;;;;;;;;;;;;;;;;EAYzB;AA4BM,2CAHI,MAAM,OACN,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,OAapC;;;;uBAlXgD,CAAC,SAApC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAE,IACnC,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,MAAM,EAAE;;;;qBAGtB,CAAC,SAAV,MAAQ,IACR,GAAG,CAAC,IAAI,MAAM,EAAE;;;;;sBA0CoB,CAAC,SAApC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAE,IACnC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B,GAAG,GAAG,IAAI,GAAG,KAAK;;;;oBAKZ,IAAI,SAAV,GAAK,EACS,GAAG,SAAjB,WAAa,IACb;IACR,MAAM,EAAE,SAAS,IAAI,EAAE,GAAG,CAAC,CAAC;IAC5B,KAAK,EAAE,SAAS,GAAG,EAAE,IAAI,CAAC,CAAC;CAC5B;4BAgJU,UAAU,CAAC,OAAO,iBAAiB,CAAC;4BA+HpC,UAAU,CAAC,OAAO,iBAAiB,CAAC;2BA7V1B,cAAc;6BACZ,cAAc;6BAFd,+BAA+B;qCAHV,eAAe;iCAAf,eAAe;yBACxC,gBAAgB;8BACX,4BAA4B"}
@@ -11,6 +11,8 @@ import { DEFAULT_PREFIX } from '@agoric/vats/src/lib-board.js';
11
11
  * @import {Key} from '@endo/patterns';
12
12
  * @import {MapStore} from '@agoric/swingset-liveslots';
13
13
  * @import {BoardId} from '@agoric/vats/src/lib-board.js';
14
+ * @import {Purse} from '@agoric/ertp';
15
+ * @import {Payment} from '@agoric/ertp';
14
16
  */
15
17
 
16
18
  /**
@@ -186,10 +188,10 @@ export const makeExportContext = () => {
186
188
 
187
189
  /**
188
190
  * @template {PassableCap} V
189
- * @param {string & keyof typeof walletObjects} kind
191
+ * @param {string & keyof typeof walletObjects} _kind
190
192
  * @param {IdTable<number, V>} table
191
193
  */
192
- const makeSaver = (kind, table) => {
194
+ const makeSaver = (_kind, table) => {
193
195
  let nonce = 0;
194
196
  /** @param {V} val */
195
197
  const saver = val => {
@@ -374,7 +376,7 @@ export const makeImportContext = (makePresence = defaultMakePresence) => {
374
376
  const makePresence = (iface, handler) => {
375
377
  let obj;
376
378
 
377
- void new HandledPromise((resolve, reject, resolveWithPresence) => {
379
+ void new HandledPromise((_resolve, _reject, resolveWithPresence) => {
378
380
  obj = resolveWithPresence(handler);
379
381
  });
380
382
  assert(obj);
@@ -1,5 +1,5 @@
1
- export function makeWatchOfferOutcomes(vowTools: VowTools): (watchers: OutcomeWatchers, seat: UserSeat) => Promise<any[]>;
2
- export function prepareOfferWatcher(baggage: Baggage, vowTools: VowTools): (walletHelper: any, deposit: {
1
+ export function makeWatchOfferOutcomes(vowTools: VowTools): (watchers: OutcomeWatchers, seat: UserSeat) => Promise<(void | 0 | 1 | PaymentPKeywordRecord)[]>;
2
+ export function prepareOfferWatcher(baggage: Baggage, vowTools: VowTools, zone: Zone): (walletHelper: any, deposit: {
3
3
  receive: (payment: Payment) => Promise<Amount>;
4
4
  }, offerSpec: OfferSpec, address: string, invitationAmount: import("@agoric/ertp").SetAmount<import("@endo/patterns").Key>, seatRef: UserSeat) => import("@endo/exo").GuardedKit<{
5
5
  helper: {
@@ -31,6 +31,25 @@ export function prepareOfferWatcher(baggage: Baggage, vowTools: VowTools): (wall
31
31
  resultWatcher: OutcomeWatchers["resultWatcher"];
32
32
  /** @type {OutcomeWatchers['numWantsWatcher']} */
33
33
  numWantsWatcher: OutcomeWatchers["numWantsWatcher"];
34
+ }, {
35
+ helper: import("@endo/patterns").InterfaceGuard<{
36
+ updateStatus: import("@endo/patterns").MethodGuard;
37
+ onNewContinuingOffer: import("@endo/patterns").MethodGuard;
38
+ publishResult: import("@endo/patterns").MethodGuard;
39
+ handleError: import("@endo/patterns").MethodGuard;
40
+ }>;
41
+ paymentWatcher: import("@endo/patterns").InterfaceGuard<{
42
+ onFulfilled?: import("@endo/patterns").MethodGuard | undefined;
43
+ onRejected?: import("@endo/patterns").MethodGuard | undefined;
44
+ }>;
45
+ resultWatcher: import("@endo/patterns").InterfaceGuard<{
46
+ onFulfilled?: import("@endo/patterns").MethodGuard | undefined;
47
+ onRejected?: import("@endo/patterns").MethodGuard | undefined;
48
+ }>;
49
+ numWantsWatcher: import("@endo/patterns").InterfaceGuard<{
50
+ onFulfilled?: import("@endo/patterns").MethodGuard | undefined;
51
+ onRejected?: import("@endo/patterns").MethodGuard | undefined;
52
+ }>;
34
53
  }>;
35
54
  /**
36
55
  * <T, [UserSeat]
@@ -45,12 +64,15 @@ export type MakeOfferWatcher = ReturnType<typeof prepareOfferWatcher>;
45
64
  export type OfferWatcher = ReturnType<MakeOfferWatcher>;
46
65
  import type { VowTools } from '@agoric/vow';
47
66
  import type { UserSeat } from '@agoric/zoe';
67
+ import type { PaymentPKeywordRecord } from '@agoric/zoe';
48
68
  import type { Baggage } from '@agoric/vat-data';
69
+ import type { Zone } from '@agoric/base-zone';
70
+ import type { Payment } from '@agoric/ertp';
71
+ import type { Amount } from '@agoric/ertp';
49
72
  import type { OfferSpec } from './offers.js';
50
73
  import type { InvitationMakers } from './types.js';
51
74
  import type { PublicSubscribers } from './types.js';
52
75
  import type { Passable } from '@endo/pass-style';
53
76
  import type { ContinuingOfferResult } from './types.js';
54
77
  import type { PromiseWatcher } from '@agoric/swingset-liveslots';
55
- import type { PaymentPKeywordRecord } from '@agoric/zoe';
56
78
  //# sourceMappingURL=offerWatcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"offerWatcher.d.ts","sourceRoot":"","sources":["offerWatcher.js"],"names":[],"mappings":"AA4EO,iDADK,QAAQ,cAKP,eAAe,QACf,QAAQ,oBAiBpB;AAmCM,6CAHI,OAAO,YACP,QAAQ;aAWO,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC;;;QAgBvD;;WAEG;yCADQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;QAQlC;;;;;WAKG;sCAJQ,MAAM,oBACN,MAAM,CAAC,KAAK,CAAC,oBACb,gBAAgB,qBAChB,iBAAiB;QAkB5B,uDAAuD;8BAA3C,QAAQ,GAAG,qBAAqB;QAoC5C;;;;;;WAMG;yBADQ,KAAK;;IAclB,gDAAgD;oBAArC,eAAe,CAAC,gBAAgB,CAAC;IA8B5C,+CAA+C;mBAApC,eAAe,CAAC,eAAe,CAAC;IAsC3C,iDAAiD;qBAAtC,eAAe,CAAC,iBAAiB,CAAC;GA0BlD;;;;gCAtTkB,CAAC,oBACP,eAAe,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;8BAI7B;IACR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qBAAqB,CAAC,CAAC;CAC5D;+BAiXU,UAAU,CAAC,OAAO,mBAAmB,CAAC;2BACtC,UAAU,CAAC,gBAAgB,CAAC;8BAtYV,aAAa;8BAE2B,aAAa;2CAAb,aAAa;6BAH3D,kBAAkB;0BAErB,mBAAmB;6BAKhB,cAAc;4BACf,cAAc;+BAZX,aAAa;sCAQN,YAAY;uCACX,YAAY;8BAPrB,kBAAkB;2CADL,YAAY;oCAEnB,4BAA4B"}
@@ -1,6 +1,9 @@
1
1
  import { E, passStyleOf } from '@endo/far';
2
2
 
3
- import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
3
+ import {
4
+ isAbandonedError,
5
+ isUpgradeDisconnection,
6
+ } from '@agoric/internal/src/upgrade-api.js';
4
7
  import { prepareExoClassKit, watchPromise } from '@agoric/vat-data';
5
8
  import { M } from '@agoric/store';
6
9
  import {
@@ -19,10 +22,13 @@ import { UNPUBLISHED_RESULT } from './offers.js';
19
22
  * @import {PromiseWatcher} from '@agoric/swingset-liveslots';
20
23
  * @import {Baggage} from '@agoric/vat-data';
21
24
  * @import {Vow, VowTools} from '@agoric/vow';
25
+ * @import {Zone} from '@agoric/base-zone';
22
26
  * @import {PaymentPKeywordRecord, Proposal, UserSeat, ZoeService} from '@agoric/zoe';
23
27
  * @import {InvitationMakers} from './types.js';
24
28
  * @import {PublicSubscribers} from './types.js';
25
29
  * @import {UpgradeDisconnection} from '@agoric/internal/src/upgrade-api.js';
30
+ * @import {Payment} from '@agoric/ertp';
31
+ * @import {Amount} from '@agoric/ertp';
26
32
  */
27
33
 
28
34
  /**
@@ -38,6 +44,28 @@ import { UNPUBLISHED_RESULT } from './offers.js';
38
44
  * }} OutcomeWatchers
39
45
  */
40
46
 
47
+ /**
48
+ * Adopted from `@agoric/vow/vat.js`
49
+ *
50
+ * @param {unknown} reason
51
+ * @param {unknown} priorRetryValue
52
+ */
53
+ const isRetryableReason = (reason, priorRetryValue) => {
54
+ if (
55
+ isUpgradeDisconnection(reason) &&
56
+ (!isUpgradeDisconnection(priorRetryValue) ||
57
+ reason.incarnationNumber > priorRetryValue.incarnationNumber)
58
+ ) {
59
+ return reason;
60
+ }
61
+ // For abandoned errors there is no way to differentiate errors from
62
+ // consecutive upgrades
63
+ if (isAbandonedError(reason) && !isAbandonedError(priorRetryValue)) {
64
+ return reason;
65
+ }
66
+ return undefined;
67
+ };
68
+
41
69
  /** @param {VowTools} vowTools */
42
70
  const makeWatchForOfferResult = ({ watch }) => {
43
71
  /**
@@ -130,9 +158,49 @@ const offerWatcherGuard = harden({
130
158
  /**
131
159
  * @param {Baggage} baggage
132
160
  * @param {VowTools} vowTools
161
+ * @param {Zone} zone
133
162
  */
134
- export const prepareOfferWatcher = (baggage, vowTools) => {
163
+ export const prepareOfferWatcher = (baggage, vowTools, zone) => {
135
164
  const watchForOfferResult = makeWatchForOfferResult(vowTools);
165
+
166
+ const extraProps = zone.weakMapStore('offerWatcherExtraProps');
167
+ /**
168
+ * Implement retry logic for offer watchers. This uses the stateful
169
+ * `isRetryableReason` to avoid infinite promise rejection loops upon remote
170
+ * vat upgrade.
171
+ *
172
+ * @param {{}} facet
173
+ * @param {unknown} reason
174
+ * @returns {reason is UpgradeDisconnection} roughly
175
+ */
176
+ const needsRetry = (facet, reason) => {
177
+ const exists = extraProps.has(facet);
178
+ const extra = exists ? extraProps.get(facet) : harden({});
179
+
180
+ const key = `priorRetry`;
181
+ const priorRetryable = extra[key];
182
+ const retryable = isRetryableReason(reason, priorRetryable);
183
+ if (retryable) {
184
+ // Insert / update the new state.
185
+ extraProps[exists ? 'set' : 'init'](
186
+ facet,
187
+ harden({
188
+ ...extra,
189
+ [key]: retryable,
190
+ }),
191
+ );
192
+ } else if (exists) {
193
+ // Delete/shrink existing state to clean up unnecessary state.
194
+ const { [key]: _omit, ...rest } = extra;
195
+ if (Object.keys(rest).length === 0) {
196
+ extraProps.delete(facet);
197
+ } else {
198
+ extraProps.set(facet, harden(rest));
199
+ }
200
+ }
201
+ return !!retryable;
202
+ };
203
+
136
204
  return prepareExoClassKit(
137
205
  baggage,
138
206
  'OfferWatcher',
@@ -264,7 +332,7 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
264
332
  */
265
333
  onRejected(reason, seat) {
266
334
  const { facets } = this;
267
- if (isUpgradeDisconnection(reason)) {
335
+ if (needsRetry(facets.paymentWatcher, reason)) {
268
336
  void watchForPayout(facets, seat);
269
337
  } else {
270
338
  facets.helper.handleError(reason);
@@ -300,7 +368,7 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
300
368
  */
301
369
  onRejected(reason, seat) {
302
370
  const { facets } = this;
303
- if (isUpgradeDisconnection(reason)) {
371
+ if (needsRetry(facets.resultWatcher, reason)) {
304
372
  void watchForOfferResult(facets, seat);
305
373
  } else {
306
374
  facets.helper.handleError(reason);
@@ -329,9 +397,12 @@ export const prepareOfferWatcher = (baggage, vowTools) => {
329
397
  */
330
398
  onRejected(reason, seat) {
331
399
  const { facets } = this;
332
- if (isUpgradeDisconnection(reason)) {
400
+ if (needsRetry(facets.numWantsWatcher, reason)) {
333
401
  void watchForNumWants(facets, seat);
402
+ } else {
403
+ facets.helper.handleError(reason);
334
404
  }
405
+ throw reason;
335
406
  },
336
407
  },
337
408
  },
package/src/offers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @import {Proposal} from '@agoric/zoe';
2
+ * @import {AmountKeywordRecord, Proposal} from '@agoric/zoe';
3
3
  * @import {Passable} from '@endo/pass-style';
4
4
  * @import {InvitationSpec} from './invitations.js';
5
5
  */
@@ -80,4 +80,5 @@ export type OfferStatus = OfferSpec & {
80
80
  import type { Passable } from '@endo/pass-style';
81
81
  import type { InvitationSpec } from './invitations.js';
82
82
  import type { Proposal } from '@agoric/zoe';
83
+ import type { AmountKeywordRecord } from '@agoric/zoe';
83
84
  //# sourceMappingURL=offers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["offers.js"],"names":[],"mappings":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jB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;;;;;;wBAIS;IACR,EAAE,EAAE,OAAO,CAAC;IACZ,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;0BAUS,SAAS,GAAG;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EACH,OAAO,GACP,OAAO,kBAAkB,GACzB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;8BAnDuB,kBAAkB;oCACZ,kBAAkB;8BAFH,aAAa;yCAAb,aAAa"}
package/src/offers.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @import {Proposal} from '@agoric/zoe';
2
+ * @import {AmountKeywordRecord, Proposal} from '@agoric/zoe';
3
3
  * @import {Passable} from '@endo/pass-style';
4
4
  * @import {InvitationSpec} from './invitations.js';
5
5
  */
@@ -1,9 +1,14 @@
1
1
  // @ts-check
2
- /// <reference types="@agoric/vats/src/core/types-ambient.js" />
3
2
 
4
3
  import { E } from '@endo/far';
5
4
  import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
6
5
 
6
+ /**
7
+ * @import {BootstrapPowers} from '@agoric/vats/src/core/types.js';
8
+ * @import {ChainBootstrapSpace} from '@agoric/vats/src/core/types.js';
9
+ * @import {VatSourceRef} from '@agoric/vats/src/core/types.js';
10
+ */
11
+
7
12
  /**
8
13
  * @param {BootstrapPowers & ChainBootstrapSpace} powers
9
14
  * @param {object} options
@@ -7,6 +7,9 @@ import { allValues } from '@agoric/internal';
7
7
  /**
8
8
  * @import {NameHub} from '@agoric/vats';
9
9
  * @import {BootstrapManifest} from '@agoric/vats/src/core/lib-boot.js';
10
+ * @import {ERef} from '@agoric/vow';
11
+ * @import {BootstrapPowers} from '@agoric/vats/src/core/types.js';
12
+ * @import {VatSourceRef} from '@agoric/vats/src/core/types.js';
10
13
  */
11
14
 
12
15
  console.warn('upgrade-walletFactory-proposal.js module evaluating');