@agoric/zoe 0.26.3-dev-2d71c01.0 → 0.26.3-dev-cbec0c6.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/zoe",
3
- "version": "0.26.3-dev-2d71c01.0+2d71c01",
3
+ "version": "0.26.3-dev-cbec0c6.0+cbec0c6",
4
4
  "description": "Zoe: the Smart Contract Framework for Offer Enforcement",
5
5
  "type": "module",
6
6
  "main": "./src/zoeService/zoe.js",
@@ -43,15 +43,15 @@
43
43
  },
44
44
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
45
45
  "dependencies": {
46
- "@agoric/assert": "0.6.1-dev-2d71c01.0+2d71c01",
47
- "@agoric/ertp": "0.16.3-dev-2d71c01.0+2d71c01",
48
- "@agoric/internal": "0.3.3-dev-2d71c01.0+2d71c01",
49
- "@agoric/notifier": "0.6.3-dev-2d71c01.0+2d71c01",
50
- "@agoric/store": "0.9.3-dev-2d71c01.0+2d71c01",
51
- "@agoric/swingset-liveslots": "0.10.3-dev-2d71c01.0+2d71c01",
52
- "@agoric/swingset-vat": "0.32.3-dev-2d71c01.0+2d71c01",
53
- "@agoric/time": "0.3.3-dev-2d71c01.0+2d71c01",
54
- "@agoric/vat-data": "0.5.3-dev-2d71c01.0+2d71c01",
46
+ "@agoric/assert": "0.6.1-dev-cbec0c6.0+cbec0c6",
47
+ "@agoric/ertp": "0.16.3-dev-cbec0c6.0+cbec0c6",
48
+ "@agoric/internal": "0.3.3-dev-cbec0c6.0+cbec0c6",
49
+ "@agoric/notifier": "0.6.3-dev-cbec0c6.0+cbec0c6",
50
+ "@agoric/store": "0.9.3-dev-cbec0c6.0+cbec0c6",
51
+ "@agoric/swingset-liveslots": "0.10.3-dev-cbec0c6.0+cbec0c6",
52
+ "@agoric/swingset-vat": "0.32.3-dev-cbec0c6.0+cbec0c6",
53
+ "@agoric/time": "0.3.3-dev-cbec0c6.0+cbec0c6",
54
+ "@agoric/vat-data": "0.5.3-dev-cbec0c6.0+cbec0c6",
55
55
  "@endo/bundle-source": "^2.5.2",
56
56
  "@endo/captp": "^3.1.2",
57
57
  "@endo/eventual-send": "^0.17.3",
@@ -101,6 +101,7 @@
101
101
  "test/unitTests/zcf/test-feeMintAccess.js",
102
102
  "# import.meta.url by way of setupZcfTest",
103
103
  "test/unitTests/test-zoe.js",
104
+ "test/unitTests/test-zoe-startInstance.js",
104
105
  "test/unitTests/test-blockedOffers.js",
105
106
  "test/unitTests/zcf/test-reallocate-empty.js",
106
107
  "test/unitTests/zcf/test-zoeHelpersWZcf.js",
@@ -129,5 +130,5 @@
129
130
  "publishConfig": {
130
131
  "access": "public"
131
132
  },
132
- "gitHead": "2d71c017b889787a35a7343fce4e58d443f5e97e"
133
+ "gitHead": "cbec0c67e13056e7ffc7d42c840946e6d5316ad0"
133
134
  }
@@ -112,10 +112,10 @@ const assertKeywordNotInBoth = (want, give) => {
112
112
  const wantKeywordSet = new Set(ownKeys(want));
113
113
  const giveKeywords = ownKeys(give);
114
114
 
115
- giveKeywords.forEach(keyword => {
115
+ for (const keyword of giveKeywords) {
116
116
  !wantKeywordSet.has(keyword) ||
117
117
  Fail`a keyword cannot be in both 'want' and 'give'`;
118
- });
118
+ }
119
119
  };
120
120
 
121
121
  /**
@@ -188,7 +188,7 @@ type OfferHandler<OR extends unknown = unknown> = HandleOffer<OR> | {
188
188
  type ContractMeta = {
189
189
  customTermsShape?: CopyRecord<any> | undefined;
190
190
  privateArgsShape?: CopyRecord<any> | undefined;
191
- upgradability?: "canBeUpgraded" | "canUpgrade" | undefined;
191
+ upgradability?: "none" | "canBeUpgraded" | "canUpgrade" | undefined;
192
192
  };
193
193
  /**
194
194
  * API for a contract start function.
@@ -236,7 +236,7 @@
236
236
  * @typedef ContractMeta
237
237
  * @property {CopyRecord<Pattern>} [customTermsShape]
238
238
  * @property {CopyRecord<Pattern>} [privateArgsShape]
239
- * @property {'canBeUpgraded' | 'canUpgrade'} [upgradability]
239
+ * @property {'none' | 'canBeUpgraded' | 'canUpgrade'} [upgradability='none']
240
240
  */
241
241
 
242
242
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"zcfZygote.d.ts","sourceRoot":"","sources":["zcfZygote.js"],"names":[],"mappings":"AAiDO,sCARI,SAAS,cACT,KAAK,UAAU,CAAC,oBAChB,OAAO,KAAK,CAAC,iBACb,aAAa,qBACb,SAAS,uCAEP,QAAQ,SAAS,CAAC,CAka9B;kCAjba,OAAO,cAAc,EAAE,mBAAmB"}
1
+ {"version":3,"file":"zcfZygote.d.ts","sourceRoot":"","sources":["zcfZygote.js"],"names":[],"mappings":"AAiDO,sCARI,SAAS,cACT,KAAK,UAAU,CAAC,oBAChB,OAAO,KAAK,CAAC,iBACb,aAAa,qBACb,SAAS,uCAEP,QAAQ,SAAS,CAAC,CAqc9B;kCApda,OAAO,cAAc,EAAE,mBAAmB"}
@@ -1,27 +1,27 @@
1
- import { E } from '@endo/eventual-send';
2
- import { passStyleOf, Remotable } from '@endo/marshal';
3
1
  import { AssetKind } from '@agoric/ertp';
4
- import { makePromiseKit } from '@endo/promise-kit';
5
2
  import { assertPattern, mustMatch } from '@agoric/store';
6
3
  import {
7
4
  canBeDurable,
8
5
  M,
9
6
  makeScalarBigMapStore,
10
- provideDurableMapStore,
11
7
  prepareExo,
12
8
  prepareExoClass,
9
+ provideDurableMapStore,
13
10
  } from '@agoric/vat-data';
11
+ import { E } from '@endo/eventual-send';
12
+ import { passStyleOf, Remotable } from '@endo/marshal';
13
+ import { makePromiseKit } from '@endo/promise-kit';
14
14
 
15
15
  import { objectMap } from '@agoric/internal';
16
16
  import { cleanProposal } from '../cleanProposal.js';
17
+ import { handlePKitWarning } from '../handleWarning.js';
18
+ import { makeInstanceRecordStorage } from '../instanceRecordStorage.js';
19
+ import { provideIssuerStorage } from '../issuerStorage.js';
20
+ import { defineDurableHandle } from '../makeHandle.js';
17
21
  import { evalContractBundle } from './evalContractCode.js';
18
22
  import { makeMakeExiter } from './exit.js';
19
- import { defineDurableHandle } from '../makeHandle.js';
20
- import { provideIssuerStorage } from '../issuerStorage.js';
21
- import { createSeatManager } from './zcfSeat.js';
22
- import { makeInstanceRecordStorage } from '../instanceRecordStorage.js';
23
- import { handlePKitWarning } from '../handleWarning.js';
24
23
  import { makeOfferHandlerStorage } from './offerHandlerStorage.js';
24
+ import { createSeatManager } from './zcfSeat.js';
25
25
 
26
26
  import '../internal-types.js';
27
27
  import './internal-types.js';
@@ -211,15 +211,24 @@ export const makeZCFZygote = async (
211
211
  const handleOfferObj = makeHandleOfferObj(taker);
212
212
 
213
213
  /**
214
- * @type {() => Promise< {
215
- * buildRootObject: any,
216
- * start: undefined,
217
- * meta: undefined,
218
- * } | {
219
- * buildRootObject: undefined,
220
- * start: ContractStartFn,
221
- * meta?: ContractMeta,
222
- }>} */
214
+ * @type {() => Promise<
215
+ * | {
216
+ * buildRootObject: any;
217
+ * start: undefined;
218
+ * meta: undefined;
219
+ * }
220
+ * | {
221
+ * prepare: ContractStartFn;
222
+ * customTermsShape?: Pick<ContractMeta, 'customTermsShape'>,
223
+ * privateArgsShape?: Pick<ContractMeta, 'privateArgsShape'>,
224
+ * }
225
+ * | {
226
+ * buildRootObject: undefined;
227
+ * start: ContractStartFn;
228
+ * meta?: ContractMeta;
229
+ * }
230
+ * >}
231
+ */
223
232
  const evaluateContract = () => {
224
233
  let bundle;
225
234
  if (passStyleOf(contractBundleCap) === 'remotable') {
@@ -232,18 +241,44 @@ export const makeZCFZygote = async (
232
241
  return evalContractBundle(bundle);
233
242
  };
234
243
  // evaluate the contract (either the first version, or an upgrade)
235
- const { start, buildRootObject, meta = {} } = await evaluateContract();
244
+ const bundleResult = await evaluateContract();
245
+
246
+ //#region backwards compatibility with prepare()
247
+ const { start, meta = {} } = (() => {
248
+ if ('prepare' in bundleResult) {
249
+ if ('start' in bundleResult) {
250
+ Fail`contract must provide exactly one of "start" and "prepare"`;
251
+ }
252
+ // A contract must have one expression of upgradability
253
+ if (/** @type {any} */ (bundleResult).meta?.upgradability) {
254
+ Fail`prepare() is deprecated and incompatible with the 'upgradability' indicator`;
255
+ }
256
+ return {
257
+ start: bundleResult.prepare,
258
+ meta: {
259
+ upgradability: 'canUpgrade',
260
+ customTermsShape: bundleResult.customTermsShape,
261
+ privateArgsShape: bundleResult.privateArgsShape,
262
+ },
263
+ };
264
+ }
265
+ // normal behavior
266
+ return bundleResult;
267
+ })();
268
+ //#endregion
236
269
 
237
270
  if (start === undefined) {
238
- buildRootObject === undefined ||
239
- Fail`Did you provide a vat bundle instead of a contract bundle?`;
271
+ if ('buildRootObject' in bundleResult) {
272
+ // diagnose a common mistake
273
+ throw Fail`Did you provide a vat bundle instead of a contract bundle?`;
274
+ }
240
275
  throw Fail`contract exports missing start`;
241
276
  }
242
277
 
243
278
  start.length <= 3 || Fail`invalid start parameters`;
244
- const durabilityRequired = meta.upgradability
245
- ? ['canBeUpgraded', 'canUpgrade'].includes(meta.upgradability)
246
- : false;
279
+ const durabilityRequired =
280
+ meta.upgradability &&
281
+ ['canBeUpgraded', 'canUpgrade'].includes(meta.upgradability);
247
282
 
248
283
  /** @type {ZCF} */
249
284
  // Using Remotable rather than Far because there are too many complications
@@ -19,7 +19,7 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
19
19
  let highestBidSeat = bidSeats[0];
20
20
  let activeBidsCount = 0n;
21
21
 
22
- bidSeats.forEach(bidSeat => {
22
+ for (const bidSeat of bidSeats) {
23
23
  if (!bidSeat.hasExited()) {
24
24
  activeBidsCount += 1n;
25
25
  /** @type {Amount<'nat'>} */
@@ -34,7 +34,7 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
34
34
  highestBidSeat = bidSeat;
35
35
  }
36
36
  }
37
- });
37
+ }
38
38
 
39
39
  if (activeBidsCount === 0n) {
40
40
  throw sellSeat.fail(Error(`Could not close auction. No bids were active`));
@@ -49,10 +49,10 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
49
49
  );
50
50
 
51
51
  sellSeat.exit();
52
- bidSeats.forEach(bidSeat => {
52
+ for (const bidSeat of bidSeats) {
53
53
  if (!bidSeat.hasExited()) {
54
54
  bidSeat.exit();
55
55
  }
56
- });
56
+ }
57
57
  zcf.shutdown('Auction closed.');
58
58
  };
@@ -1,13 +1,4 @@
1
- /**
2
- * @typedef {object} ScaledPriceAuthorityOpts
3
- * @property {ERef<PriceAuthority>} sourcePriceAuthority
4
- * @property {Ratio} scaleIn - sourceAmountIn:targetAmountIn
5
- * @property {Ratio} scaleOut - sourceAmountOut:targetAmountOut
6
- * @property {Ratio} [initialPrice] - targetAmountIn:targetAmountOut
7
- */
8
- /** @type {ContractMeta} */
9
- export const meta: ContractMeta;
10
- export function start(zcf: ZCF<ScaledPriceAuthorityOpts>, privateArgs: object, baggage: MapStore<string, any>): Promise<{
1
+ export function prepare(zcf: ZCF<ScaledPriceAuthorityOpts>, privateArgs: object, baggage: MapStore<string, any>): Promise<{
11
2
  publicFacet: {
12
3
  getPriceAuthority: () => Promise<PriceAuthority>;
13
4
  } & import("@endo/eventual-send").RemotableBrand<{}, {
@@ -1 +1 @@
1
- {"version":3,"file":"scaledPriceAuthority.d.ts","sourceRoot":"","sources":["scaledPriceAuthority.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAGrB;AAgBK,2BAJI,IAAI,wBAAwB,CAAC,eAC7B,MAAM;;;;;;GAyDhB;;0BA/Ea,KAAK,cAAc,CAAC;;;;aACpB,KAAK;;;;cACL,KAAK"}
1
+ {"version":3,"file":"scaledPriceAuthority.d.ts","sourceRoot":"","sources":["scaledPriceAuthority.js"],"names":[],"mappings":"AAiCO,6BALI,IAAI,wBAAwB,CAAC,eAC7B,MAAM;;;;;;GA0DhB;;0BA1Ea,KAAK,cAAc,CAAC;;;;aACpB,KAAK;;;;cACL,KAAK"}
@@ -17,12 +17,6 @@ import { provideQuoteMint } from '../contractSupport/priceAuthorityQuoteMint.js'
17
17
  * @property {Ratio} [initialPrice] - targetAmountIn:targetAmountOut
18
18
  */
19
19
 
20
- /** @type {ContractMeta} */
21
- export const meta = {
22
- upgradability: 'canUpgrade',
23
- };
24
- harden(meta);
25
-
26
20
  /**
27
21
  * A contract that scales a source price authority to a target price authority
28
22
  * via ratios.
@@ -36,7 +30,8 @@ harden(meta);
36
30
  * @param {object} privateArgs
37
31
  * @param {import('@agoric/vat-data').Baggage} baggage
38
32
  */
39
- export const start = async (zcf, privateArgs, baggage) => {
33
+ // 'prepare' is deprecated but still supported
34
+ export const prepare = async (zcf, privateArgs, baggage) => {
40
35
  const quoteMint = provideQuoteMint(baggage);
41
36
 
42
37
  const { sourcePriceAuthority, scaleIn, scaleOut, initialPrice } =
@@ -91,4 +86,4 @@ export const start = async (zcf, privateArgs, baggage) => {
91
86
  );
92
87
  return harden({ publicFacet });
93
88
  };
94
- harden(start);
89
+ harden(prepare);