@agoric/zoe 0.26.3-upgrade-14-dev-c8f9e7b.0 → 0.26.3-upgrade-16-fi-dev-8879538.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.
Files changed (269) hide show
  1. package/README.md +7 -7
  2. package/bundles/bundle-contractFacet-js-meta.json +622 -313
  3. package/bundles/bundle-contractFacet.d.ts +3 -3
  4. package/bundles/bundle-contractFacet.js +1 -1
  5. package/exported.js +1 -12
  6. package/package.json +75 -60
  7. package/src/cleanProposal.d.ts +2 -2
  8. package/src/cleanProposal.d.ts.map +1 -1
  9. package/src/cleanProposal.js +15 -12
  10. package/src/contractFacet/exit.d.ts.map +1 -1
  11. package/src/contractFacet/exit.js +1 -0
  12. package/src/contractFacet/internal-types.d.ts +2 -2
  13. package/src/contractFacet/internal-types.d.ts.map +1 -1
  14. package/src/contractFacet/internal-types.js +1 -1
  15. package/src/contractFacet/offerHandlerStorage.d.ts +4 -1
  16. package/src/contractFacet/offerHandlerStorage.d.ts.map +1 -1
  17. package/src/contractFacet/offerHandlerStorage.js +11 -3
  18. package/src/contractFacet/reallocate.d.ts +3 -0
  19. package/src/contractFacet/reallocate.d.ts.map +1 -0
  20. package/src/contractFacet/reallocate.js +94 -0
  21. package/src/contractFacet/rightsConservation.d.ts.map +1 -1
  22. package/src/contractFacet/rightsConservation.js +3 -0
  23. package/src/contractFacet/types-ambient.d.ts +259 -0
  24. package/src/contractFacet/types-ambient.js +1 -0
  25. package/src/contractFacet/vatRoot.d.ts +4 -4
  26. package/src/contractFacet/vatRoot.d.ts.map +1 -1
  27. package/src/contractFacet/zcfMint.d.ts +5 -3
  28. package/src/contractFacet/zcfMint.d.ts.map +1 -1
  29. package/src/contractFacet/zcfMint.js +4 -4
  30. package/src/contractFacet/zcfSeat.d.ts +4 -2
  31. package/src/contractFacet/zcfSeat.d.ts.map +1 -1
  32. package/src/contractFacet/zcfSeat.js +125 -5
  33. package/src/contractFacet/zcfZygote.d.ts +1 -2
  34. package/src/contractFacet/zcfZygote.d.ts.map +1 -1
  35. package/src/contractFacet/zcfZygote.js +95 -42
  36. package/src/contractSupport/atomicTransfer.d.ts +0 -6
  37. package/src/contractSupport/atomicTransfer.d.ts.map +1 -1
  38. package/src/contractSupport/atomicTransfer.js +5 -90
  39. package/src/contractSupport/bondingCurves.js +2 -2
  40. package/src/contractSupport/durability.d.ts +3 -3
  41. package/src/contractSupport/durability.d.ts.map +1 -1
  42. package/src/contractSupport/durability.js +5 -5
  43. package/src/contractSupport/index.d.ts +1 -0
  44. package/src/contractSupport/index.js +1 -0
  45. package/src/contractSupport/prepare-ownable.d.ts +11 -0
  46. package/src/contractSupport/prepare-ownable.d.ts.map +1 -0
  47. package/src/contractSupport/prepare-ownable.js +100 -0
  48. package/src/contractSupport/priceAuthority.d.ts +23 -15
  49. package/src/contractSupport/priceAuthority.d.ts.map +1 -1
  50. package/src/contractSupport/priceAuthority.js +32 -17
  51. package/src/contractSupport/priceAuthorityInitial.d.ts +3 -2
  52. package/src/contractSupport/priceAuthorityInitial.d.ts.map +1 -1
  53. package/src/contractSupport/priceAuthorityInitial.js +5 -2
  54. package/src/contractSupport/priceAuthorityQuoteMint.d.ts +2 -1
  55. package/src/contractSupport/priceAuthorityQuoteMint.d.ts.map +1 -1
  56. package/src/contractSupport/priceAuthorityQuoteMint.js +23 -27
  57. package/src/contractSupport/priceAuthorityTransform.d.ts +14 -12
  58. package/src/contractSupport/priceAuthorityTransform.d.ts.map +1 -1
  59. package/src/contractSupport/priceAuthorityTransform.js +10 -8
  60. package/src/contractSupport/priceQuote.d.ts +7 -5
  61. package/src/contractSupport/priceQuote.d.ts.map +1 -1
  62. package/src/contractSupport/priceQuote.js +5 -1
  63. package/src/contractSupport/ratio.d.ts +2 -2
  64. package/src/contractSupport/ratio.d.ts.map +1 -1
  65. package/src/contractSupport/ratio.js +19 -15
  66. package/src/contractSupport/recorder.d.ts +31 -117
  67. package/src/contractSupport/recorder.d.ts.map +1 -1
  68. package/src/contractSupport/recorder.js +21 -10
  69. package/src/contractSupport/safeMath.d.ts +7 -7
  70. package/src/contractSupport/safeMath.d.ts.map +1 -1
  71. package/src/contractSupport/statistics.d.ts +1 -1
  72. package/src/contractSupport/statistics.d.ts.map +1 -1
  73. package/src/contractSupport/topics.d.ts +1 -1
  74. package/src/contractSupport/topics.d.ts.map +1 -1
  75. package/src/contractSupport/{types.d.ts → types-ambient.d.ts} +4 -4
  76. package/src/contractSupport/types-ambient.d.ts.map +1 -0
  77. package/src/contractSupport/{types.js → types-ambient.js} +1 -1
  78. package/src/contractSupport/zoeHelpers.d.ts +1 -1
  79. package/src/contractSupport/zoeHelpers.d.ts.map +1 -1
  80. package/src/contractSupport/zoeHelpers.js +5 -11
  81. package/src/contracts/auction/firstPriceLogic.d.ts.map +1 -1
  82. package/src/contracts/auction/firstPriceLogic.js +5 -8
  83. package/src/contracts/auction/index.d.ts +10 -10
  84. package/src/contracts/auction/index.d.ts.map +1 -1
  85. package/src/contracts/auction/index.js +2 -1
  86. package/src/contracts/auction/secondPriceLogic.d.ts.map +1 -1
  87. package/src/contracts/auction/secondPriceLogic.js +1 -4
  88. package/src/contracts/automaticRefund.d.ts +1 -1
  89. package/src/contracts/automaticRefund.d.ts.map +1 -1
  90. package/src/contracts/autoswap.d.ts.map +1 -1
  91. package/src/contracts/autoswap.js +8 -9
  92. package/src/contracts/barterExchange.d.ts +1 -1
  93. package/src/contracts/barterExchange.d.ts.map +1 -1
  94. package/src/contracts/barterExchange.js +2 -3
  95. package/src/contracts/callSpread/calculateShares.d.ts +1 -8
  96. package/src/contracts/callSpread/calculateShares.d.ts.map +1 -1
  97. package/src/contracts/callSpread/calculateShares.js +1 -1
  98. package/src/contracts/callSpread/fundedCallSpread.d.ts +4 -0
  99. package/src/contracts/callSpread/fundedCallSpread.d.ts.map +1 -1
  100. package/src/contracts/callSpread/fundedCallSpread.js +6 -4
  101. package/src/contracts/callSpread/payoffHandler.d.ts.map +1 -1
  102. package/src/contracts/callSpread/payoffHandler.js +2 -1
  103. package/src/contracts/callSpread/percent.d.ts +2 -4
  104. package/src/contracts/callSpread/percent.d.ts.map +1 -1
  105. package/src/contracts/callSpread/position.d.ts +2 -2
  106. package/src/contracts/callSpread/pricedCallSpread.d.ts +6 -5
  107. package/src/contracts/callSpread/pricedCallSpread.d.ts.map +1 -1
  108. package/src/contracts/callSpread/pricedCallSpread.js +8 -4
  109. package/src/contracts/callSpread/{types.d.ts → types-ambient.d.ts} +3 -3
  110. package/src/contracts/callSpread/types-ambient.d.ts.map +1 -0
  111. package/src/contracts/coveredCall-durable.d.ts +2 -4
  112. package/src/contracts/coveredCall-durable.d.ts.map +1 -1
  113. package/src/contracts/exported.js +3 -3
  114. package/src/contracts/loan/borrow.d.ts.map +1 -1
  115. package/src/contracts/loan/borrow.js +7 -4
  116. package/src/contracts/loan/close.d.ts.map +1 -1
  117. package/src/contracts/loan/close.js +3 -7
  118. package/src/contracts/loan/index.d.ts +5 -1
  119. package/src/contracts/loan/index.d.ts.map +1 -1
  120. package/src/contracts/loan/index.js +4 -0
  121. package/src/contracts/loan/liquidate.d.ts +1 -12
  122. package/src/contracts/loan/liquidate.d.ts.map +1 -1
  123. package/src/contracts/loan/liquidate.js +4 -2
  124. package/src/contracts/loan/scheduleLiquidation.d.ts.map +1 -1
  125. package/src/contracts/loan/scheduleLiquidation.js +1 -0
  126. package/src/contracts/loan/{types.d.ts → types-ambient.d.ts} +16 -17
  127. package/src/contracts/loan/types-ambient.d.ts.map +1 -0
  128. package/src/contracts/loan/{types.js → types-ambient.js} +11 -18
  129. package/src/contracts/loan/updateDebt.js +1 -1
  130. package/src/contracts/mintAndSellNFT.d.ts.map +1 -1
  131. package/src/contracts/mintPayments.d.ts +14 -6
  132. package/src/contracts/mintPayments.d.ts.map +1 -1
  133. package/src/contracts/mintPayments.js +1 -1
  134. package/src/contracts/oracle.d.ts +25 -3
  135. package/src/contracts/oracle.d.ts.map +1 -1
  136. package/src/contracts/oracle.js +7 -0
  137. package/src/contracts/otcDesk.d.ts +3 -3
  138. package/src/contracts/otcDesk.d.ts.map +1 -1
  139. package/src/contracts/otcDesk.js +1 -1
  140. package/src/contracts/priceAggregator.d.ts +112 -18
  141. package/src/contracts/priceAggregator.d.ts.map +1 -1
  142. package/src/contracts/priceAggregator.js +16 -18
  143. package/src/contracts/priceAggregatorTypes.d.ts +2 -2
  144. package/src/contracts/priceAggregatorTypes.d.ts.map +1 -1
  145. package/src/contracts/scaledPriceAuthority.d.ts +4 -5
  146. package/src/contracts/scaledPriceAuthority.d.ts.map +1 -1
  147. package/src/contracts/scaledPriceAuthority.js +6 -0
  148. package/src/contracts/sellItems.d.ts +2 -2
  149. package/src/contracts/sellItems.d.ts.map +1 -1
  150. package/src/contracts/sellItems.js +2 -3
  151. package/src/contracts/simpleExchange.d.ts +3 -3
  152. package/src/contracts/{types.d.ts → types-ambient.d.ts} +1 -1
  153. package/src/contracts/types-ambient.d.ts.map +1 -0
  154. package/src/handleWarning.d.ts.map +1 -1
  155. package/src/instanceRecordStorage.d.ts +1 -1
  156. package/src/instanceRecordStorage.d.ts.map +1 -1
  157. package/src/internal-types.d.ts +20 -32
  158. package/src/internal-types.d.ts.map +1 -1
  159. package/src/internal-types.js +18 -58
  160. package/src/issuerRecord.d.ts +2 -2
  161. package/src/issuerRecord.d.ts.map +1 -1
  162. package/src/issuerStorage.d.ts +4 -4
  163. package/src/issuerStorage.d.ts.map +1 -1
  164. package/src/issuerStorage.js +12 -28
  165. package/src/makeHandle.d.ts +2 -2
  166. package/src/makeHandle.d.ts.map +1 -1
  167. package/src/makeHandle.js +1 -1
  168. package/src/typeGuards.d.ts +119 -20
  169. package/src/typeGuards.d.ts.map +1 -1
  170. package/src/typeGuards.js +18 -9
  171. package/src/types-ambient.d.ts +41 -0
  172. package/src/types-ambient.d.ts.map +1 -0
  173. package/src/{types.js → types-ambient.js} +6 -14
  174. package/src/zoeService/escrowStorage.d.ts +1 -1
  175. package/src/zoeService/escrowStorage.d.ts.map +1 -1
  176. package/src/zoeService/escrowStorage.js +20 -27
  177. package/src/zoeService/feeMint.d.ts +9 -16
  178. package/src/zoeService/feeMint.d.ts.map +1 -1
  179. package/src/zoeService/feeMint.js +21 -15
  180. package/src/zoeService/installationStorage.d.ts +5 -20
  181. package/src/zoeService/installationStorage.d.ts.map +1 -1
  182. package/src/zoeService/installationStorage.js +11 -7
  183. package/src/zoeService/instanceAdminStorage.d.ts +22 -42
  184. package/src/zoeService/instanceAdminStorage.d.ts.map +1 -1
  185. package/src/zoeService/instanceAdminStorage.js +1 -0
  186. package/src/zoeService/internal-types.d.ts +16 -16
  187. package/src/zoeService/internal-types.d.ts.map +1 -1
  188. package/src/zoeService/internal-types.js +6 -6
  189. package/src/zoeService/invitationQueries.d.ts.map +1 -1
  190. package/src/zoeService/invitationQueries.js +7 -5
  191. package/src/zoeService/makeInvitation.d.ts +3 -3
  192. package/src/zoeService/makeInvitation.d.ts.map +1 -1
  193. package/src/zoeService/makeInvitation.js +25 -21
  194. package/src/zoeService/offer/burnInvitation.d.ts.map +1 -1
  195. package/src/zoeService/offer/offer.d.ts.map +1 -1
  196. package/src/zoeService/offer/offer.js +2 -5
  197. package/src/zoeService/originalZoeSeat.d.ts +34 -0
  198. package/src/zoeService/originalZoeSeat.d.ts.map +1 -0
  199. package/src/zoeService/originalZoeSeat.js +353 -0
  200. package/src/zoeService/startInstance.d.ts +3 -3
  201. package/src/zoeService/startInstance.d.ts.map +1 -1
  202. package/src/zoeService/startInstance.js +17 -11
  203. package/src/zoeService/{types.d.ts → types-ambient.d.ts} +26 -31
  204. package/src/zoeService/types-ambient.d.ts.map +1 -0
  205. package/src/zoeService/{types.js → types-ambient.js} +19 -32
  206. package/src/zoeService/utils.d.ts +54 -58
  207. package/src/zoeService/utils.test-d.d.ts +2 -0
  208. package/src/zoeService/utils.test-d.d.ts.map +1 -0
  209. package/src/zoeService/utils.test-d.ts +33 -0
  210. package/src/zoeService/zoe.d.ts +9 -13
  211. package/src/zoeService/zoe.d.ts.map +1 -1
  212. package/src/zoeService/zoe.js +7 -7
  213. package/src/zoeService/zoeSeat.d.ts +15 -45
  214. package/src/zoeService/zoeSeat.d.ts.map +1 -1
  215. package/src/zoeService/zoeSeat.js +214 -114
  216. package/src/zoeService/zoeStorageManager.d.ts +9 -43
  217. package/src/zoeService/zoeStorageManager.d.ts.map +1 -1
  218. package/src/zoeService/zoeStorageManager.js +8 -6
  219. package/tools/fakePriceAuthority.d.ts +9 -8
  220. package/tools/fakePriceAuthority.d.ts.map +1 -1
  221. package/tools/fakePriceAuthority.js +21 -17
  222. package/tools/fakeVatAdmin.d.ts +10 -10
  223. package/tools/manualPriceAuthority.d.ts +11 -6
  224. package/tools/manualPriceAuthority.d.ts.map +1 -1
  225. package/tools/manualPriceAuthority.js +15 -2
  226. package/tools/manualTimer.d.ts +21 -40
  227. package/tools/manualTimer.d.ts.map +1 -1
  228. package/tools/manualTimer.js +30 -16
  229. package/tools/prepare-test-env.js +1 -1
  230. package/tools/scriptedOracle.d.ts +3 -3
  231. package/tools/scriptedOracle.d.ts.map +1 -1
  232. package/tools/scriptedOracle.js +1 -1
  233. package/tools/scriptedPriceAuthority.d.ts +4 -0
  234. package/tools/scriptedPriceAuthority.d.ts.map +1 -1
  235. package/tools/scriptedPriceAuthority.js +6 -1
  236. package/tools/setup-zoe.d.ts +8 -9
  237. package/tools/setup-zoe.d.ts.map +1 -1
  238. package/tools/setup-zoe.js +16 -1
  239. package/tools/test-utils.d.ts +20 -0
  240. package/tools/test-utils.d.ts.map +1 -0
  241. package/tools/test-utils.js +26 -0
  242. package/tools/types.d.ts +21 -21
  243. package/tools/types.d.ts.map +1 -1
  244. package/tools/types.js +10 -10
  245. package/CHANGELOG.md +0 -1203
  246. package/src/contractFacet/types.d.ts +0 -191
  247. package/src/contractFacet/types.d.ts.map +0 -1
  248. package/src/contractFacet/types.js +0 -256
  249. package/src/contractSupport/types.d.ts.map +0 -1
  250. package/src/contracts/callSpread/types.d.ts.map +0 -1
  251. package/src/contracts/loan/types.d.ts.map +0 -1
  252. package/src/contracts/types.d.ts.map +0 -1
  253. package/src/objArrayConversion.d.ts +0 -5
  254. package/src/objArrayConversion.d.ts.map +0 -1
  255. package/src/objArrayConversion.js +0 -35
  256. package/src/types.d.ts +0 -45
  257. package/src/types.d.ts.map +0 -1
  258. package/src/zoeService/types.d.ts.map +0 -1
  259. package/tools/internal-types.d.ts +0 -12
  260. package/tools/internal-types.d.ts.map +0 -1
  261. package/tools/internal-types.js +0 -14
  262. package/tools/priceAuthorityRegistry.d.ts +0 -20
  263. package/tools/priceAuthorityRegistry.d.ts.map +0 -1
  264. package/tools/priceAuthorityRegistry.js +0 -209
  265. package/tools/types-ambient.d.ts +0 -142
  266. package/tools/types-ambient.d.ts.map +0 -1
  267. package/tools/types-ambient.js +0 -160
  268. /package/src/contracts/callSpread/{types.js → types-ambient.js} +0 -0
  269. /package/src/contracts/{types.js → types-ambient.js} +0 -0
@@ -0,0 +1,259 @@
1
+ /// <reference types="@agoric/ertp/exported" />
2
+ /// <reference types="@endo/pass-style" />
3
+ /// <reference path="../zoeService/utils.d.ts" />
4
+
5
+ /**
6
+ * Any passable non-thenable. Often an explanatory string.
7
+ */
8
+ type Completion = import('@endo/pass-style').Passable;
9
+ type ZCFMakeEmptySeatKit = (exit?: ExitRule | undefined) => ZcfSeatKit;
10
+
11
+ type InvitationAmount = Amount<'set', InvitationDetails>;
12
+
13
+ /**
14
+ * Zoe Contract Facet
15
+ *
16
+ * The Zoe interface specific to a contract instance. The Zoe Contract
17
+ * Facet is an API object used by running contract instances to access
18
+ * the Zoe state for that instance. The Zoe Contract Facet is accessed
19
+ * synchronously from within the contract, and usually is referred to
20
+ * in code as zcf.
21
+ */
22
+ type ZCF<CT extends unknown = Record<string, unknown>> = {
23
+ /**
24
+ * - atomically reallocate amounts among seats.
25
+ */
26
+ atomicRearrange: (transfers: TransferPart[]) => void;
27
+ /**
28
+ * - reallocate amounts among seats.
29
+ * @deprecated Use atomicRearrange instead.
30
+ */
31
+ reallocate: Reallocate;
32
+ /**
33
+ * - check
34
+ * whether a keyword is valid and unique and could be added in
35
+ * `saveIssuer`
36
+ */
37
+ assertUniqueKeyword: (keyword: Keyword) => void;
38
+ /**
39
+ * Informs Zoe about an issuer and returns a promise for acknowledging
40
+ * when the issuer is added and ready.
41
+ *
42
+ * @returns the AmountMath and brand synchronously accessible after
43
+ * saving
44
+ */
45
+ saveIssuer: <I extends Issuer>(
46
+ issuerP: ERef<I>,
47
+ keyword: Keyword,
48
+ ) => Promise<I extends Issuer<infer K, infer M> ? IssuerRecord<K, M> : never>;
49
+
50
+ /**
51
+ * Make a credible Zoe invitation for a particular smart contract
52
+ * indicated by the `instance` in the details of the invitation. Zoe
53
+ * also puts the `installation` and a unique `handle` in the details
54
+ * of the invitation. The contract must provide a `description` for
55
+ * the invitation and should include whatever information is necessary
56
+ * for a potential buyer of the invitation to know what they are
57
+ * getting in the `customDetails`. `customDetails` will be
58
+ * placed in the details of the invitation.
59
+ */
60
+ makeInvitation: <R, A = undefined>(
61
+ offerHandler: OfferHandler<ERef<R>, A>,
62
+ description: string,
63
+ customDetails?: object,
64
+ proposalShape?: Pattern,
65
+ ) => Promise<Invitation<R, A>>;
66
+ shutdown: (completion: Completion) => void;
67
+ shutdownWithFailure: import('@agoric/swingset-vat').ShutdownWithFailure;
68
+ getZoeService: () => ERef<ZoeService>;
69
+ getInvitationIssuer: () => Issuer<'set'>;
70
+ getTerms: () => StandardTerms & CT;
71
+ getBrandForIssuer: <K extends AssetKind>(issuer: Issuer<K>) => Brand<K>;
72
+ getIssuerForBrand: <K_1 extends AssetKind>(brand: Brand<K_1>) => Issuer<K_1>;
73
+ getAssetKind: GetAssetKindByBrand;
74
+ makeZCFMint: <K_2 extends AssetKind = 'nat'>(
75
+ keyword: Keyword,
76
+ assetKind?: K_2 | undefined,
77
+ displayInfo?: AdditionalDisplayInfo,
78
+ options?: import('@agoric/ertp').IssuerOptionsRecord,
79
+ ) => Promise<ZCFMint<K_2>>;
80
+ registerFeeMint: ZCFRegisterFeeMint;
81
+ makeEmptySeatKit: ZCFMakeEmptySeatKit;
82
+ setTestJig: SetTestJig;
83
+ stopAcceptingOffers: () => Promise<void>;
84
+ setOfferFilter: (strings: Array<string>) => Promise<void>;
85
+ getOfferFilter: () => Promise<Array<string>>;
86
+ getInstance: () => Instance;
87
+ };
88
+ /**
89
+ * The contract can reallocate over seats, which commits the staged
90
+ * allocation for each seat. On commit, the staged allocation becomes
91
+ * the current allocation and the staged allocation is deleted.
92
+ *
93
+ * The reallocation will only succeed if the reallocation 1) conserves
94
+ * rights (the amounts specified have the same total value as the
95
+ * current total amount), and 2) is 'offer-safe' for all parties
96
+ * involved. All seats that have staged allocations must be included
97
+ * as arguments to `reallocate`, or an error is thrown. Additionally,
98
+ * an error is thrown if any seats included in `reallocate` do not
99
+ * have a staged allocation.
100
+ *
101
+ * The reallocation is partial, meaning that it applies only to the
102
+ * seats passed in as arguments. By induction, if rights conservation
103
+ * and offer safety hold before, they will hold after a safe
104
+ * reallocation, even though we only re-validate for the seats whose
105
+ * allocations will change. Since rights are conserved for the change,
106
+ * overall rights will be unchanged, and a reallocation can only
107
+ * effect offer safety for seats whose allocations change.
108
+ */
109
+ type Reallocate = (
110
+ seat1: ZCFSeat,
111
+ seat2: ZCFSeat,
112
+ ...seatRest: Array<ZCFSeat>
113
+ ) => void;
114
+ type TransferPart = [
115
+ fromSeat?: ZCFSeat,
116
+ toSeat?: ZCFSeat,
117
+ fromAmounts?: AmountKeywordRecord,
118
+ toAmounts?: AmountKeywordRecord,
119
+ ];
120
+
121
+ type ZCFRegisterFeeMint = (
122
+ keyword: Keyword,
123
+ allegedFeeMintAccess: FeeMintAccess,
124
+ ) => Promise<ZCFMint<'nat'>>;
125
+ /**
126
+ * Provide a jig object for testing purposes only.
127
+ *
128
+ * The contract code provides a callback whose return result will
129
+ * be made available to the test that started this contract. The
130
+ * supplied callback will only be called in a testing context,
131
+ * never in production; i.e., it is only called if `testJigSetter`
132
+ * was supplied.
133
+ *
134
+ * If no, `testFn` is supplied, then an empty jig will be used.
135
+ * An additional `zcf` property set to the current ContractFacet
136
+ * will be appended to the returned jig object (overriding any
137
+ * provided by the `testFn`).
138
+ */
139
+ type SetTestJig = (testFn: () => Record<string, unknown>) => void;
140
+ type ZCFMint<K extends AssetKind = AssetKind> = {
141
+ getIssuerRecord: () => IssuerRecord<K>;
142
+ /**
143
+ * All the amounts in gains must be of this ZCFMint's brand.
144
+ * The gains' keywords are in the namespace of that seat.
145
+ * Add the gains to that seat's allocation.
146
+ * The resulting state must be offer safe. (Currently, increasing assets can
147
+ * never violate offer safety anyway.)
148
+ *
149
+ * Mint that amount of assets into the pooled purse.
150
+ * If a seat is provided, it is returned. Otherwise a new seat is
151
+ * returned.
152
+ */
153
+ mintGains: (gains: AmountKeywordRecord, zcfSeat?: ZCFSeat) => ZCFSeat;
154
+ /**
155
+ * All the amounts in losses must be of this ZCFMint's brand.
156
+ * The losses' keywords are in the namespace of that seat.
157
+ * Subtract losses from that seat's allocation.
158
+ * The resulting state must be offer safe.
159
+ *
160
+ * Burn that amount of assets from the pooled purse.
161
+ */
162
+ burnLosses: (losses: AmountKeywordRecord, zcfSeat: ZCFSeat) => void;
163
+ };
164
+ /**
165
+ * fail called with the reason for this failure, where reason is
166
+ * normally an instanceof Error.
167
+ */
168
+ type ZCFSeatFail = (reason: unknown) => Error;
169
+ type ZCFSeat = import('@endo/pass-style').RemotableObject & {
170
+ exit: (completion?: Completion) => void;
171
+ fail: ZCFSeatFail;
172
+ getSubscriber: () => Promise<Subscriber<Allocation>>;
173
+ hasExited: () => boolean;
174
+ getProposal: () => ProposalRecord;
175
+ /**
176
+ * @param brand used for filling in an empty amount if the `keyword`
177
+ * is not present in the allocation
178
+ */
179
+ getAmountAllocated: <B extends Brand>(
180
+ keyword: Keyword,
181
+ brand?: B,
182
+ ) => B extends Brand<infer K> ? Amount<K> : Amount;
183
+ getCurrentAllocation: () => Allocation;
184
+ /**
185
+ * @deprecated Use atomicRearrange instead
186
+ */
187
+ getStagedAllocation: () => Allocation;
188
+ /**
189
+ * @deprecated Use atomicRearrange instead
190
+ */
191
+ hasStagedAllocation: () => boolean;
192
+ isOfferSafe: (newAllocation: Allocation) => boolean;
193
+ /**
194
+ * @deprecated Use atomicRearrange instead
195
+ */
196
+ incrementBy: (
197
+ amountKeywordRecord: AmountKeywordRecord,
198
+ ) => AmountKeywordRecord;
199
+ /**
200
+ * @deprecated Use atomicRearrange instead
201
+ */
202
+ decrementBy: (
203
+ amountKeywordRecord: AmountKeywordRecord,
204
+ ) => AmountKeywordRecord;
205
+ /**
206
+ * @deprecated Use atomicRearrange instead
207
+ */
208
+ clear: () => void;
209
+ };
210
+ type ZcfSeatKit = {
211
+ zcfSeat: ZCFSeat;
212
+ userSeat: ERef<UserSeat>;
213
+ };
214
+ type HandleOffer<OR extends unknown, OA> = (seat: ZCFSeat, offerArgs: OA) => OR;
215
+ type OfferHandler<OR extends unknown = unknown, OA = never> =
216
+ | HandleOffer<OR, OA>
217
+ | {
218
+ handle: HandleOffer<OR, OA>;
219
+ };
220
+ type ContractMeta = {
221
+ customTermsShape?: import('@endo/pass-style').CopyRecord<any> | undefined;
222
+ privateArgsShape?: import('@endo/pass-style').CopyRecord<any> | undefined;
223
+ upgradability?: 'none' | 'canBeUpgraded' | 'canUpgrade' | undefined;
224
+ };
225
+ /**
226
+ * API for a contract start function.
227
+ *
228
+ * CAVEAT: assumes synchronous
229
+ */
230
+ type ContractStartFn<
231
+ PF extends unknown = any,
232
+ CF extends unknown = any,
233
+ CT extends unknown = any,
234
+ PA extends unknown = any,
235
+ > = (
236
+ zcf: ZCF<CT>,
237
+ privateArgs: PA,
238
+ baggage: import('@agoric/vat-data').Baggage,
239
+ ) => ContractStartFnResult<PF, CF>;
240
+ type ContractStartFnResult<PF, CF> = {
241
+ publicFacet?: PF;
242
+ creatorFacet?: CF;
243
+ creatorInvitation?: Promise<Invitation<any, any>> | undefined;
244
+ };
245
+
246
+ // XXX redef, losing documentation
247
+ type ContractOf<S> = import('../zoeService/utils').ContractOf<S>;
248
+ type AdminFacet = import('../zoeService/utils').AdminFacet<any>;
249
+
250
+ declare const OfferReturn: unique symbol;
251
+ declare const OfferArgs: unique symbol;
252
+ type Invitation<R = unknown, A = undefined> = Payment<
253
+ 'set',
254
+ InvitationDetails
255
+ > & {
256
+ // because TS is structural, without this the generic is ignored
257
+ [OfferReturn]?: R;
258
+ [OfferArgs]?: A;
259
+ };
@@ -0,0 +1 @@
1
+ // Dummy file for .d.ts twin to declare ambients
@@ -3,12 +3,12 @@
3
3
  * @param {{contractBundleCap: BundleCap, zoeService: ZoeService, invitationIssuer: Issuer<'set'>, privateArgs?: any}} vatParameters
4
4
  * @param {import('@agoric/vat-data').Baggage} baggage
5
5
  */
6
- export function buildRootObject(powers: import("@agoric/swingset-vat").TerminationVatPowers & {
6
+ export function buildRootObject(powers: TerminationVatPowers & {
7
7
  testJigSetter: TestJigSetter;
8
8
  }, vatParameters: {
9
- contractBundleCap: BundleCap;
9
+ contractBundleCap: any;
10
10
  zoeService: ZoeService;
11
- invitationIssuer: Issuer<'set'>;
11
+ invitationIssuer: Issuer<"set">;
12
12
  privateArgs?: any;
13
- }, baggage: MapStore<string, unknown>): Promise<import("@endo/eventual-send").RemotableBrand<{}, {}>>;
13
+ }, baggage: import("@agoric/vat-data").Baggage): Promise<import("@endo/marshal").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {}>>;
14
14
  //# sourceMappingURL=vatRoot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vatRoot.d.ts","sourceRoot":"","sources":["vatRoot.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH;mBAJwC,aAAa;;uBACtB,SAAS;gBAAc,UAAU;sBAAoB,OAAO,KAAK,CAAC;kBAAgB,GAAG;sGAgEnH"}
1
+ {"version":3,"file":"vatRoot.d.ts","sourceRoot":"","sources":["vatRoot.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH;mBAJwC,aAAa;;;gBACC,UAAU;sBAAoB,MAAM,CAAC,KAAK,CAAC;kBAAgB,GAAG;YACzG,OAAO,kBAAkB,EAAE,OAAO,iIA+D5C"}
@@ -1,6 +1,8 @@
1
- export function sumAmountKeywordRecord<K extends AssetKind>(amr: AmountKeywordRecord, issuerRecord: IssuerRecord<K>): Amount<K>;
2
- export function prepareZcMint(zcfBaggage: MapStore<string, unknown>, recordIssuer: (keyword: string, issuerRecord: IssuerRecord) => void, getAssetKindByBrand: GetAssetKindByBrand, makeEmptySeatKit: (exit?: undefined) => {
1
+ export function sumAmountKeywordRecord(amr: AmountKeywordRecord, issuerRecord: IssuerRecord): Amount;
2
+ export function prepareZcMint(zcfBaggage: import("@agoric/vat-data").Baggage, recordIssuer: {
3
+ (keyword: string, issuerRecord: IssuerRecord): void;
4
+ }, getAssetKindByBrand: GetAssetKindByBrand, makeEmptySeatKit: (exit?: undefined) => {
3
5
  zcfSeat: any;
4
6
  userSeat: Promise<UserSeat>;
5
- }, reallocator: ZcfMintReallocator): <K extends AssetKind>(keyword: string, zoeMintP: ERef<ZoeMint<K>>) => Promise<ZCFMint<K>>;
7
+ }, reallocator: ZcfMintReallocator): <K extends globalThis.AssetKind>(keyword: string, zoeMintP: ERef<ZoeMint<K>>) => Promise<ZCFMint<K>>;
6
8
  //# sourceMappingURL=zcfMint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zcfMint.d.ts","sourceRoot":"","sources":["zcfMint.js"],"names":[],"mappings":"AAqBO,iEAJI,mBAAmB,4CAc7B;AASM,6FALgB,MAAM,gBAAgB,YAAY,KAAG,IAAI,uBACrD,mBAAmB,4BACX,SAAS,KAAK;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,QAAQ,QAAQ,CAAC,CAAA;CAAE,eACnE,kBAAkB,kCAkHhB,MAAM,qDAalB"}
1
+ {"version":3,"file":"zcfMint.d.ts","sourceRoot":"","sources":["zcfMint.js"],"names":[],"mappings":"AAqBO,4CAJI,mBAAmB,gBACnB,YAAY,GACV,MAAM,CAYlB;AASM,0CANI,OAAO,kBAAkB,EAAE,OAAO,gBAClC;IAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAA;CAAE,uBACvD,mBAAmB,oBACnB,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;CAAE,eACnE,kBAAkB,IAoHE,CAAC,wCAFnB,MAAM,YACN,IAAI,CAAC,OAAO,CACM,CAAC,AADL,CAAC,CAAC,KACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAWjC"}
@@ -1,3 +1,4 @@
1
+ /* eslint @typescript-eslint/no-floating-promises: "warn" */
1
2
  import { AmountMath } from '@agoric/ertp';
2
3
  import { prepareExoClass } from '@agoric/vat-data';
3
4
  import { E } from '@endo/eventual-send';
@@ -9,15 +10,14 @@ import { addToAllocation, subtractFromAllocation } from './allocationMath.js';
9
10
  import '../internal-types.js';
10
11
  import { ZcfMintI } from '../typeGuards.js';
11
12
  import './internal-types.js';
12
- import './types.js';
13
+ import './types-ambient.js';
13
14
 
14
15
  const { Fail } = assert;
15
16
 
16
17
  /**
17
- * @template {AssetKind} K
18
18
  * @param {AmountKeywordRecord} amr
19
- * @param {IssuerRecord<K>} issuerRecord
20
- * @returns {Amount<K>}
19
+ * @param {IssuerRecord} issuerRecord
20
+ * @returns {Amount}
21
21
  */
22
22
  export const sumAmountKeywordRecord = (amr, issuerRecord) => {
23
23
  const empty = AmountMath.makeEmpty(
@@ -1,3 +1,5 @@
1
- /** @type {CreateSeatManager} */
2
- export const createSeatManager: CreateSeatManager;
1
+ export function createSeatManager(zoeInstanceAdmin: ERef<ZoeInstanceAdmin>, getAssetKindByBrand: GetAssetKindByBrand, shutdownWithFailure: import("@agoric/swingset-vat").ShutdownWithFailure, zcfBaggage: import("@agoric/vat-data").Baggage): {
2
+ seatManager: ZcfSeatManager;
3
+ zcfMintReallocator: ZcfMintReallocator;
4
+ };
3
5
  //# sourceMappingURL=zcfSeat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zcfSeat.d.ts","sourceRoot":"","sources":["zcfSeat.js"],"names":[],"mappings":"AAwBA,gCAAgC;AAChC,gCADW,iBAAiB,CAsX1B"}
1
+ {"version":3,"file":"zcfSeat.d.ts","sourceRoot":"","sources":["zcfSeat.js"],"names":[],"mappings":"AAqCO,oDANI,IAAI,CAAC,gBAAgB,CAAC,uBACtB,mBAAmB,uBACnB,OAAO,sBAAsB,EAAE,mBAAmB,cAClD,OAAO,kBAAkB,EAAE,OAAO,GAChC;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,kBAAkB,EAAE,kBAAkB,CAAA;CAAE,CAmenF"}
@@ -1,10 +1,11 @@
1
+ /* eslint @typescript-eslint/no-floating-promises: "warn" */
1
2
  import {
2
3
  makeScalarBigWeakMapStore,
3
- provideDurableMapStore,
4
- provideDurableWeakMapStore,
4
+ prepareExoClass,
5
5
  prepareExoClassKit,
6
6
  provide,
7
- prepareExoClass,
7
+ provideDurableMapStore,
8
+ provideDurableWeakMapStore,
8
9
  } from '@agoric/vat-data';
9
10
  import { E } from '@endo/eventual-send';
10
11
  import { AmountMath } from '@agoric/ertp';
@@ -19,10 +20,21 @@ import {
19
20
  SeatDataShape,
20
21
  SeatShape,
21
22
  } from '../typeGuards.js';
23
+ import { makeAllocationMap } from './reallocate.js';
24
+ import { TransferPartShape } from '../contractSupport/atomicTransfer.js';
22
25
 
23
26
  const { Fail } = assert;
24
27
 
25
- /** @type {CreateSeatManager} */
28
+ /**
29
+ * The SeatManager holds the active zcfSeats and can reallocate and
30
+ * make new zcfSeats.
31
+ *
32
+ * @param {ERef<ZoeInstanceAdmin>} zoeInstanceAdmin
33
+ * @param {GetAssetKindByBrand} getAssetKindByBrand
34
+ * @param {import('@agoric/swingset-vat').ShutdownWithFailure} shutdownWithFailure
35
+ * @param {import('@agoric/vat-data').Baggage} zcfBaggage
36
+ * @returns {{ seatManager: ZcfSeatManager, zcfMintReallocator: ZcfMintReallocator }}
37
+ */
26
38
  export const createSeatManager = (
27
39
  zoeInstanceAdmin,
28
40
  getAssetKindByBrand,
@@ -156,6 +168,7 @@ export const createSeatManager = (
156
168
  assertNoStagedAllocation(self);
157
169
  doExitSeat(self);
158
170
  E(zoeInstanceAdmin).exitSeat(zcfSeatToSeatHandle.get(self), completion);
171
+ zcfSeatToSeatHandle.delete(self);
159
172
  },
160
173
  fail(
161
174
  reason = Error(
@@ -176,6 +189,7 @@ export const createSeatManager = (
176
189
  zcfSeatToSeatHandle.get(self),
177
190
  harden(reason),
178
191
  );
192
+ zcfSeatToSeatHandle.delete(self);
179
193
  }
180
194
  return reason;
181
195
  },
@@ -184,15 +198,22 @@ export const createSeatManager = (
184
198
  return hasExited(self);
185
199
  },
186
200
 
201
+ /**
202
+ * @type {ZCFSeat['getAmountAllocated']}
203
+ */
187
204
  getAmountAllocated(keyword, brand) {
188
205
  const { self } = this;
189
206
  assertActive(self);
190
207
  const currentAllocation = getCurrentAllocation(self);
191
208
  if (currentAllocation[keyword] !== undefined) {
209
+ // @ts-expect-error never checks brand
192
210
  return currentAllocation[keyword];
193
211
  }
194
- brand || Fail`A brand must be supplied when the keyword is not defined`;
212
+ if (!brand) {
213
+ throw Fail`A brand must be supplied when the keyword is not defined`;
214
+ }
195
215
  const assetKind = getAssetKindByBrand(brand);
216
+ // @ts-expect-error cast
196
217
  return AmountMath.makeEmpty(brand, assetKind);
197
218
  },
198
219
  getCurrentAllocation() {
@@ -214,6 +235,10 @@ export const createSeatManager = (
214
235
 
215
236
  return isOfferSafe(state.proposal, reallocation);
216
237
  },
238
+ /**
239
+ * @deprecated switch to zcf.atomicRearrange()
240
+ * @param {AmountKeywordRecord} amountKeywordRecord
241
+ */
217
242
  incrementBy(amountKeywordRecord) {
218
243
  const { self } = this;
219
244
  assertActive(self);
@@ -227,6 +252,10 @@ export const createSeatManager = (
227
252
  );
228
253
  return amountKeywordRecord;
229
254
  },
255
+ /**
256
+ * @deprecated switch to zcf.atomicRearrange()
257
+ * @param {AmountKeywordRecord} amountKeywordRecord
258
+ */
230
259
  decrementBy(amountKeywordRecord) {
231
260
  const { self } = this;
232
261
  assertActive(self);
@@ -265,6 +294,7 @@ export const createSeatManager = (
265
294
  const ZcfSeatManagerIKit = harden({
266
295
  seatManager: M.interface('ZcfSeatManager', {
267
296
  makeZCFSeat: M.call(SeatDataShape).returns(M.remotable('zcfSeat')),
297
+ atomicRearrange: M.call(M.arrayOf(TransferPartShape)).returns(),
268
298
  reallocate: M.call(M.remotable('zcfSeat'), M.remotable('zcfSeat'))
269
299
  .rest(M.arrayOf(M.remotable('zcfSeat')))
270
300
  .returns(),
@@ -289,6 +319,96 @@ export const createSeatManager = (
289
319
  return zcfSeat;
290
320
  },
291
321
 
322
+ /**
323
+ * Rearrange the allocations according to the transfer descriptions.
324
+ * This is a set of changes to allocations that must satisfy several
325
+ * constraints. If these constraints are all met, then the reallocation
326
+ * happens atomically. Otherwise, it does not happen at all.
327
+ *
328
+ * The conditions
329
+ * * All the mentioned seats are still live,
330
+ * * No outstanding stagings for any of the mentioned seats. Stagings
331
+ * have been deprecated in favor or atomicRearrange. To prevent
332
+ * confusion, for each reallocation, it can only be expressed in
333
+ * the old way or the new way, but not a mixture.
334
+ * * Offer safety
335
+ * * Overall conservation
336
+ *
337
+ * The overall transfer is expressed as an array of `TransferPart`. Each
338
+ * individual `TransferPart` is one of
339
+ * - A transfer from a `fromSeat` to a `toSeat`. Specify both toAmount
340
+ * and fromAmount to change keywords, otherwise only fromAmount is required.
341
+ * - A taking from a `fromSeat`'s allocation. See the `fromOnly` helper.
342
+ * - A giving into a `toSeat`'s allocation. See the `toOnly` helper.
343
+ *
344
+ * @param {TransferPart[]} transfers
345
+ */
346
+ atomicRearrange(transfers) {
347
+ const newAllocations = makeAllocationMap(transfers);
348
+
349
+ // ////// All Seats are active /////////////////////////////////
350
+ for (const [seat] of newAllocations) {
351
+ assertActive(seat);
352
+ !seat.hasStagedAllocation() ||
353
+ Fail`Cannot mix atomicRearrange with seat stagings: ${seat}`;
354
+ zcfSeatToSeatHandle.has(seat) ||
355
+ Fail`The seat ${seat} was not recognized`;
356
+ }
357
+
358
+ // ////// Ensure that rights are conserved overall /////////////
359
+
360
+ // convert array of keywordAmountRecords to 1-level array of Amounts
361
+ const flattenAmounts = allocations =>
362
+ allocations.flatMap(Object.values);
363
+ const previousAmounts = flattenAmounts(
364
+ newAllocations.map(([seat]) => seat.getCurrentAllocation()),
365
+ );
366
+ const newAmounts = flattenAmounts(
367
+ newAllocations.map(([_, allocation]) => allocation),
368
+ );
369
+ assertRightsConserved(previousAmounts, newAmounts);
370
+
371
+ // ////// Ensure that offer safety holds ///////////////////////
372
+ for (const [seat, allocation] of newAllocations) {
373
+ isOfferSafe(seat.getProposal(), allocation) ||
374
+ Fail`Offer safety was violated by the proposed allocation: ${allocation}. Proposal was ${seat.getProposal()}`;
375
+ }
376
+
377
+ const seatHandleAllocations = newAllocations.map(
378
+ ([seat, allocation]) => {
379
+ const seatHandle = zcfSeatToSeatHandle.get(seat);
380
+ return { allocation, seatHandle };
381
+ },
382
+ );
383
+ try {
384
+ // No side effects above. All conditions checked which could have
385
+ // caused us to reject this reallocation. Notice that the current
386
+ // allocations are captured in seatHandleAllocations, so there must
387
+ // be no awaits between that assignment and here.
388
+ //
389
+ // COMMIT POINT
390
+ //
391
+ // The effects must succeed atomically. The call to
392
+ // replaceAllocations() will be processed in the order of updates
393
+ // from ZCF to Zoe. Its effects must occur immediately in Zoe on
394
+ // reception, and must not fail.
395
+ //
396
+ // Commit the new allocations (currentAllocation is replaced
397
+ // for each of the seats) and inform Zoe of the new allocation.
398
+
399
+ for (const [seat, allocation] of newAllocations) {
400
+ activeZCFSeats.set(seat, allocation);
401
+ }
402
+
403
+ // we don't wait for the results here. As described in
404
+ // docs/zoe-zcf.md, The initial allocation to a seat originates with
405
+ // Zoe, but *all subsequent updates come from ZCF to Zoe*.
406
+ void E(zoeInstanceAdmin).replaceAllocations(seatHandleAllocations);
407
+ } catch (err) {
408
+ shutdownWithFailure(err);
409
+ throw err;
410
+ }
411
+ },
292
412
  reallocate(/** @type {ZCFSeat[]} */ ...seats) {
293
413
  seats.forEach(assertActive);
294
414
  seats.forEach(assertStagedAllocation);
@@ -1,3 +1,2 @@
1
- export function makeZCFZygote(powers: VatPowers, zoeService: ERef<ZoeService>, invitationIssuer: Issuer<'set'>, testJigSetter: TestJigSetter, contractBundleCap: BundleCap, zcfBaggage?: MapStore<string, unknown>): Promise<ZCFZygote>;
2
- export type IssuerOptionsRecord = import('@agoric/ertp').IssuerOptionsRecord;
1
+ export function makeZCFZygote(powers: TerminationVatPowers, zoeService: ERef<ZoeService>, invitationIssuer: Issuer<"set">, testJigSetter: TestJigSetter, contractBundleCap: any, zcfBaggage?: import("@agoric/vat-data").Baggage): Promise<ZCFZygote>;
3
2
  //# sourceMappingURL=zcfZygote.d.ts.map
@@ -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,2CAEP,QAAQ,SAAS,CAAC,CA6Z9B;kCA5aa,OAAO,cAAc,EAAE,mBAAmB"}
1
+ {"version":3,"file":"zcfZygote.d.ts","sourceRoot":"","sources":["zcfZygote.js"],"names":[],"mappings":"AAiDO,wEAPI,IAAI,CAAC,UAAU,CAAC,oBAChB,MAAM,CAAC,KAAK,CAAC,iBACb,aAAa,uCAEb,OAAO,kBAAkB,EAAE,OAAO,GAChC,OAAO,CAAC,SAAS,CAAC,CAkd9B"}