@agoric/zoe 0.26.2 → 0.26.3-calypso-dev-84eb287.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 (274) hide show
  1. package/README.md +7 -7
  2. package/bundles/bundle-contractFacet-js-meta.json +628 -314
  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 -59
  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/evalContractCode.d.ts.map +1 -1
  11. package/src/contractFacet/evalContractCode.js +2 -2
  12. package/src/contractFacet/exit.d.ts.map +1 -1
  13. package/src/contractFacet/exit.js +1 -0
  14. package/src/contractFacet/internal-types.d.ts +2 -2
  15. package/src/contractFacet/internal-types.d.ts.map +1 -1
  16. package/src/contractFacet/internal-types.js +1 -1
  17. package/src/contractFacet/offerHandlerStorage.d.ts +4 -1
  18. package/src/contractFacet/offerHandlerStorage.d.ts.map +1 -1
  19. package/src/contractFacet/offerHandlerStorage.js +11 -3
  20. package/src/contractFacet/reallocate.d.ts +3 -0
  21. package/src/contractFacet/reallocate.d.ts.map +1 -0
  22. package/src/contractFacet/reallocate.js +94 -0
  23. package/src/contractFacet/rightsConservation.d.ts.map +1 -1
  24. package/src/contractFacet/rightsConservation.js +3 -0
  25. package/src/contractFacet/typeGuards.d.ts +8 -0
  26. package/src/contractFacet/typeGuards.d.ts.map +1 -0
  27. package/src/contractFacet/typeGuards.js +25 -0
  28. package/src/contractFacet/types-ambient.d.ts +271 -0
  29. package/src/contractFacet/types-ambient.js +1 -0
  30. package/src/contractFacet/vatRoot.d.ts +3 -3
  31. package/src/contractFacet/vatRoot.d.ts.map +1 -1
  32. package/src/contractFacet/zcfMint.d.ts +4 -2
  33. package/src/contractFacet/zcfMint.d.ts.map +1 -1
  34. package/src/contractFacet/zcfMint.js +7 -7
  35. package/src/contractFacet/zcfSeat.d.ts +4 -2
  36. package/src/contractFacet/zcfSeat.d.ts.map +1 -1
  37. package/src/contractFacet/zcfSeat.js +130 -7
  38. package/src/contractFacet/zcfZygote.d.ts +1 -2
  39. package/src/contractFacet/zcfZygote.d.ts.map +1 -1
  40. package/src/contractFacet/zcfZygote.js +102 -48
  41. package/src/contractSupport/atomicTransfer.d.ts +0 -6
  42. package/src/contractSupport/atomicTransfer.d.ts.map +1 -1
  43. package/src/contractSupport/atomicTransfer.js +5 -90
  44. package/src/contractSupport/bondingCurves.js +2 -2
  45. package/src/contractSupport/durability.d.ts +3 -3
  46. package/src/contractSupport/durability.d.ts.map +1 -1
  47. package/src/contractSupport/durability.js +5 -5
  48. package/src/contractSupport/index.d.ts +1 -0
  49. package/src/contractSupport/index.js +1 -0
  50. package/src/contractSupport/prepare-ownable.d.ts +11 -0
  51. package/src/contractSupport/prepare-ownable.d.ts.map +1 -0
  52. package/src/contractSupport/prepare-ownable.js +100 -0
  53. package/src/contractSupport/priceAuthority.d.ts +23 -15
  54. package/src/contractSupport/priceAuthority.d.ts.map +1 -1
  55. package/src/contractSupport/priceAuthority.js +33 -18
  56. package/src/contractSupport/priceAuthorityInitial.d.ts +3 -2
  57. package/src/contractSupport/priceAuthorityInitial.d.ts.map +1 -1
  58. package/src/contractSupport/priceAuthorityInitial.js +6 -3
  59. package/src/contractSupport/priceAuthorityQuoteMint.d.ts +2 -1
  60. package/src/contractSupport/priceAuthorityQuoteMint.d.ts.map +1 -1
  61. package/src/contractSupport/priceAuthorityQuoteMint.js +23 -27
  62. package/src/contractSupport/priceAuthorityTransform.d.ts +13 -11
  63. package/src/contractSupport/priceAuthorityTransform.d.ts.map +1 -1
  64. package/src/contractSupport/priceAuthorityTransform.js +10 -8
  65. package/src/contractSupport/priceQuote.d.ts +7 -5
  66. package/src/contractSupport/priceQuote.d.ts.map +1 -1
  67. package/src/contractSupport/priceQuote.js +5 -1
  68. package/src/contractSupport/ratio.d.ts +2 -2
  69. package/src/contractSupport/ratio.d.ts.map +1 -1
  70. package/src/contractSupport/ratio.js +19 -15
  71. package/src/contractSupport/recorder.d.ts +33 -119
  72. package/src/contractSupport/recorder.d.ts.map +1 -1
  73. package/src/contractSupport/recorder.js +21 -10
  74. package/src/contractSupport/safeMath.d.ts +7 -7
  75. package/src/contractSupport/safeMath.d.ts.map +1 -1
  76. package/src/contractSupport/statistics.d.ts +1 -1
  77. package/src/contractSupport/statistics.d.ts.map +1 -1
  78. package/src/contractSupport/topics.d.ts +1 -1
  79. package/src/contractSupport/topics.d.ts.map +1 -1
  80. package/src/contractSupport/{types.d.ts → types-ambient.d.ts} +4 -4
  81. package/src/contractSupport/types-ambient.d.ts.map +1 -0
  82. package/src/contractSupport/{types.js → types-ambient.js} +1 -1
  83. package/src/contractSupport/zoeHelpers.d.ts +1 -1
  84. package/src/contractSupport/zoeHelpers.d.ts.map +1 -1
  85. package/src/contractSupport/zoeHelpers.js +6 -12
  86. package/src/contracts/auction/firstPriceLogic.d.ts.map +1 -1
  87. package/src/contracts/auction/firstPriceLogic.js +5 -8
  88. package/src/contracts/auction/index.d.ts +10 -10
  89. package/src/contracts/auction/index.d.ts.map +1 -1
  90. package/src/contracts/auction/index.js +3 -3
  91. package/src/contracts/auction/secondPriceLogic.d.ts.map +1 -1
  92. package/src/contracts/auction/secondPriceLogic.js +1 -4
  93. package/src/contracts/automaticRefund.d.ts +1 -1
  94. package/src/contracts/automaticRefund.d.ts.map +1 -1
  95. package/src/contracts/autoswap.d.ts.map +1 -1
  96. package/src/contracts/autoswap.js +8 -9
  97. package/src/contracts/barterExchange.d.ts +1 -1
  98. package/src/contracts/barterExchange.d.ts.map +1 -1
  99. package/src/contracts/barterExchange.js +2 -3
  100. package/src/contracts/callSpread/calculateShares.d.ts +1 -8
  101. package/src/contracts/callSpread/calculateShares.d.ts.map +1 -1
  102. package/src/contracts/callSpread/calculateShares.js +1 -1
  103. package/src/contracts/callSpread/fundedCallSpread.d.ts +4 -0
  104. package/src/contracts/callSpread/fundedCallSpread.d.ts.map +1 -1
  105. package/src/contracts/callSpread/fundedCallSpread.js +6 -4
  106. package/src/contracts/callSpread/payoffHandler.d.ts.map +1 -1
  107. package/src/contracts/callSpread/payoffHandler.js +3 -2
  108. package/src/contracts/callSpread/percent.d.ts +2 -4
  109. package/src/contracts/callSpread/percent.d.ts.map +1 -1
  110. package/src/contracts/callSpread/position.d.ts +2 -2
  111. package/src/contracts/callSpread/pricedCallSpread.d.ts +6 -5
  112. package/src/contracts/callSpread/pricedCallSpread.d.ts.map +1 -1
  113. package/src/contracts/callSpread/pricedCallSpread.js +9 -5
  114. package/src/contracts/callSpread/{types.d.ts → types-ambient.d.ts} +3 -3
  115. package/src/contracts/callSpread/types-ambient.d.ts.map +1 -0
  116. package/src/contracts/coveredCall-durable.d.ts +2 -4
  117. package/src/contracts/coveredCall-durable.d.ts.map +1 -1
  118. package/src/contracts/exported.js +3 -3
  119. package/src/contracts/loan/borrow.d.ts.map +1 -1
  120. package/src/contracts/loan/borrow.js +7 -4
  121. package/src/contracts/loan/close.d.ts.map +1 -1
  122. package/src/contracts/loan/close.js +3 -7
  123. package/src/contracts/loan/index.d.ts +5 -1
  124. package/src/contracts/loan/index.d.ts.map +1 -1
  125. package/src/contracts/loan/index.js +4 -0
  126. package/src/contracts/loan/liquidate.d.ts +1 -12
  127. package/src/contracts/loan/liquidate.d.ts.map +1 -1
  128. package/src/contracts/loan/liquidate.js +4 -2
  129. package/src/contracts/loan/scheduleLiquidation.d.ts.map +1 -1
  130. package/src/contracts/loan/scheduleLiquidation.js +2 -1
  131. package/src/contracts/loan/{types.d.ts → types-ambient.d.ts} +16 -17
  132. package/src/contracts/loan/types-ambient.d.ts.map +1 -0
  133. package/src/contracts/loan/{types.js → types-ambient.js} +11 -18
  134. package/src/contracts/loan/updateDebt.js +1 -1
  135. package/src/contracts/mintAndSellNFT.d.ts.map +1 -1
  136. package/src/contracts/mintPayments.d.ts +14 -6
  137. package/src/contracts/mintPayments.d.ts.map +1 -1
  138. package/src/contracts/mintPayments.js +1 -1
  139. package/src/contracts/oracle.d.ts +6 -2
  140. package/src/contracts/oracle.d.ts.map +1 -1
  141. package/src/contracts/oracle.js +10 -3
  142. package/src/contracts/otcDesk.d.ts +3 -3
  143. package/src/contracts/otcDesk.d.ts.map +1 -1
  144. package/src/contracts/otcDesk.js +1 -1
  145. package/src/contracts/priceAggregator.d.ts +25 -17
  146. package/src/contracts/priceAggregator.d.ts.map +1 -1
  147. package/src/contracts/priceAggregator.js +33 -32
  148. package/src/contracts/priceAggregatorTypes.d.ts +2 -2
  149. package/src/contracts/priceAggregatorTypes.d.ts.map +1 -1
  150. package/src/contracts/scaledPriceAuthority.d.ts +3 -4
  151. package/src/contracts/scaledPriceAuthority.d.ts.map +1 -1
  152. package/src/contracts/scaledPriceAuthority.js +6 -0
  153. package/src/contracts/sellItems.d.ts +2 -2
  154. package/src/contracts/sellItems.d.ts.map +1 -1
  155. package/src/contracts/sellItems.js +3 -4
  156. package/src/contracts/simpleExchange.d.ts +3 -3
  157. package/src/contracts/{types.d.ts → types-ambient.d.ts} +1 -1
  158. package/src/contracts/types-ambient.d.ts.map +1 -0
  159. package/src/handleWarning.d.ts.map +1 -1
  160. package/src/instanceRecordStorage.d.ts +1 -1
  161. package/src/instanceRecordStorage.d.ts.map +1 -1
  162. package/src/internal-types.d.ts +21 -32
  163. package/src/internal-types.d.ts.map +1 -1
  164. package/src/internal-types.js +19 -58
  165. package/src/issuerRecord.d.ts +1 -1
  166. package/src/issuerRecord.d.ts.map +1 -1
  167. package/src/issuerStorage.d.ts +3 -3
  168. package/src/issuerStorage.d.ts.map +1 -1
  169. package/src/issuerStorage.js +12 -28
  170. package/src/makeHandle.d.ts +2 -2
  171. package/src/makeHandle.d.ts.map +1 -1
  172. package/src/makeHandle.js +1 -1
  173. package/src/typeGuards.d.ts +114 -20
  174. package/src/typeGuards.d.ts.map +1 -1
  175. package/src/typeGuards.js +19 -20
  176. package/src/types-ambient.d.ts +41 -0
  177. package/src/types-ambient.d.ts.map +1 -0
  178. package/src/{types.js → types-ambient.js} +7 -15
  179. package/src/zoeService/escrowStorage.d.ts +1 -1
  180. package/src/zoeService/escrowStorage.d.ts.map +1 -1
  181. package/src/zoeService/escrowStorage.js +20 -27
  182. package/src/zoeService/feeMint.d.ts +9 -16
  183. package/src/zoeService/feeMint.d.ts.map +1 -1
  184. package/src/zoeService/feeMint.js +21 -15
  185. package/src/zoeService/installationStorage.d.ts +5 -20
  186. package/src/zoeService/installationStorage.d.ts.map +1 -1
  187. package/src/zoeService/installationStorage.js +11 -7
  188. package/src/zoeService/instanceAdminStorage.d.ts +22 -42
  189. package/src/zoeService/instanceAdminStorage.d.ts.map +1 -1
  190. package/src/zoeService/instanceAdminStorage.js +2 -1
  191. package/src/zoeService/internal-types.d.ts +12 -12
  192. package/src/zoeService/internal-types.d.ts.map +1 -1
  193. package/src/zoeService/internal-types.js +6 -6
  194. package/src/zoeService/invitationQueries.d.ts.map +1 -1
  195. package/src/zoeService/invitationQueries.js +7 -5
  196. package/src/zoeService/makeInvitation.d.ts +3 -3
  197. package/src/zoeService/makeInvitation.d.ts.map +1 -1
  198. package/src/zoeService/makeInvitation.js +25 -21
  199. package/src/zoeService/offer/burnInvitation.d.ts.map +1 -1
  200. package/src/zoeService/offer/offer.d.ts.map +1 -1
  201. package/src/zoeService/offer/offer.js +2 -5
  202. package/src/zoeService/originalZoeSeat.d.ts +34 -0
  203. package/src/zoeService/originalZoeSeat.d.ts.map +1 -0
  204. package/src/zoeService/originalZoeSeat.js +353 -0
  205. package/src/zoeService/startInstance.d.ts +3 -3
  206. package/src/zoeService/startInstance.d.ts.map +1 -1
  207. package/src/zoeService/startInstance.js +82 -37
  208. package/src/zoeService/{types.d.ts → types-ambient.d.ts} +23 -28
  209. package/src/zoeService/types-ambient.d.ts.map +1 -0
  210. package/src/zoeService/{types.js → types-ambient.js} +19 -32
  211. package/src/zoeService/utils.d.ts +57 -58
  212. package/src/zoeService/utils.test-d.d.ts +2 -0
  213. package/src/zoeService/utils.test-d.d.ts.map +1 -0
  214. package/src/zoeService/utils.test-d.ts +33 -0
  215. package/src/zoeService/zoe.d.ts +14 -8
  216. package/src/zoeService/zoe.d.ts.map +1 -1
  217. package/src/zoeService/zoe.js +39 -11
  218. package/src/zoeService/zoeSeat.d.ts +15 -45
  219. package/src/zoeService/zoeSeat.d.ts.map +1 -1
  220. package/src/zoeService/zoeSeat.js +215 -115
  221. package/src/zoeService/zoeStorageManager.d.ts +13 -47
  222. package/src/zoeService/zoeStorageManager.d.ts.map +1 -1
  223. package/src/zoeService/zoeStorageManager.js +13 -6
  224. package/tools/fakePriceAuthority.d.ts +9 -8
  225. package/tools/fakePriceAuthority.d.ts.map +1 -1
  226. package/tools/fakePriceAuthority.js +21 -17
  227. package/tools/fakeVatAdmin.d.ts +10 -10
  228. package/tools/manualPriceAuthority.d.ts +11 -6
  229. package/tools/manualPriceAuthority.d.ts.map +1 -1
  230. package/tools/manualPriceAuthority.js +16 -3
  231. package/tools/manualTimer.d.ts +17 -40
  232. package/tools/manualTimer.d.ts.map +1 -1
  233. package/tools/manualTimer.js +30 -16
  234. package/tools/prepare-test-env.js +1 -1
  235. package/tools/scriptedOracle.d.ts +3 -3
  236. package/tools/scriptedOracle.d.ts.map +1 -1
  237. package/tools/scriptedOracle.js +1 -1
  238. package/tools/scriptedPriceAuthority.d.ts +4 -0
  239. package/tools/scriptedPriceAuthority.d.ts.map +1 -1
  240. package/tools/scriptedPriceAuthority.js +8 -3
  241. package/tools/setup-zoe.d.ts +10 -6
  242. package/tools/setup-zoe.d.ts.map +1 -1
  243. package/tools/setup-zoe.js +16 -1
  244. package/tools/test-utils.d.ts +20 -0
  245. package/tools/test-utils.d.ts.map +1 -0
  246. package/tools/test-utils.js +26 -0
  247. package/tools/types.d.ts +21 -21
  248. package/tools/types.d.ts.map +1 -1
  249. package/tools/types.js +10 -10
  250. package/CHANGELOG.md +0 -1171
  251. package/src/contractFacet/types.d.ts +0 -191
  252. package/src/contractFacet/types.d.ts.map +0 -1
  253. package/src/contractFacet/types.js +0 -256
  254. package/src/contractSupport/types.d.ts.map +0 -1
  255. package/src/contracts/callSpread/types.d.ts.map +0 -1
  256. package/src/contracts/loan/types.d.ts.map +0 -1
  257. package/src/contracts/types.d.ts.map +0 -1
  258. package/src/objArrayConversion.d.ts +0 -5
  259. package/src/objArrayConversion.d.ts.map +0 -1
  260. package/src/objArrayConversion.js +0 -35
  261. package/src/types.d.ts +0 -45
  262. package/src/types.d.ts.map +0 -1
  263. package/src/zoeService/types.d.ts.map +0 -1
  264. package/tools/internal-types.d.ts +0 -12
  265. package/tools/internal-types.d.ts.map +0 -1
  266. package/tools/internal-types.js +0 -14
  267. package/tools/priceAuthorityRegistry.d.ts +0 -20
  268. package/tools/priceAuthorityRegistry.d.ts.map +0 -1
  269. package/tools/priceAuthorityRegistry.js +0 -209
  270. package/tools/types-ambient.d.ts +0 -142
  271. package/tools/types-ambient.d.ts.map +0 -1
  272. package/tools/types-ambient.js +0 -160
  273. /package/src/contracts/callSpread/{types.js → types-ambient.js} +0 -0
  274. /package/src/contracts/{types.js → types-ambient.js} +0 -0
@@ -1,36 +1,37 @@
1
- import { E } from '@endo/eventual-send';
2
- import { passStyleOf, Remotable } from '@endo/marshal';
1
+ /* eslint @typescript-eslint/no-floating-promises: "warn" */
3
2
  import { AssetKind } from '@agoric/ertp';
4
- import { makePromiseKit } from '@endo/promise-kit';
5
3
  import { assertPattern, mustMatch } from '@agoric/store';
6
4
  import {
7
5
  canBeDurable,
8
6
  M,
9
7
  makeScalarBigMapStore,
10
- provideDurableMapStore,
11
8
  prepareExo,
12
9
  prepareExoClass,
10
+ provideDurableMapStore,
13
11
  } from '@agoric/vat-data';
12
+ import { E } from '@endo/eventual-send';
13
+ import { passStyleOf } from '@endo/pass-style';
14
+ import { makePromiseKit } from '@endo/promise-kit';
14
15
 
15
16
  import { objectMap } from '@agoric/internal';
16
17
  import { cleanProposal } from '../cleanProposal.js';
18
+ import { handlePKitWarning } from '../handleWarning.js';
19
+ import { makeInstanceRecordStorage } from '../instanceRecordStorage.js';
20
+ import { provideIssuerStorage } from '../issuerStorage.js';
21
+ import { defineDurableHandle } from '../makeHandle.js';
17
22
  import { evalContractBundle } from './evalContractCode.js';
18
23
  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
24
  import { makeOfferHandlerStorage } from './offerHandlerStorage.js';
25
+ import { createSeatManager } from './zcfSeat.js';
25
26
 
26
- import '../internal-types.js';
27
- import './internal-types.js';
28
-
29
- import '@agoric/swingset-vat/src/types-ambient.js';
30
27
  import { HandleOfferI, InvitationHandleShape } from '../typeGuards.js';
31
28
  import { prepareZcMint } from './zcfMint.js';
29
+ import { ZcfI } from './typeGuards.js';
30
+
31
+ /// <reference path="../internal-types.js" />
32
+ /// <reference path="./internal-types.js" />
32
33
 
33
- /** @typedef {import('@agoric/ertp').IssuerOptionsRecord} IssuerOptionsRecord */
34
+ /** @import {IssuerOptionsRecord} from '@agoric/ertp' */
34
35
 
35
36
  const { Fail } = assert;
36
37
 
@@ -76,9 +77,9 @@ export const makeZCFZygote = async (
76
77
  instantiate: instantiateIssuerStorage,
77
78
  } = provideIssuerStorage(zcfBaggage);
78
79
 
79
- /** @type {ShutdownWithFailure} */
80
+ /** @type {import('@agoric/swingset-vat').ShutdownWithFailure} */
80
81
  const shutdownWithFailure = reason => {
81
- E(zoeInstanceAdmin).failAllSeats(reason);
82
+ void E(zoeInstanceAdmin).failAllSeats(reason);
82
83
  seatManager.dropAllReferences();
83
84
  // https://github.com/Agoric/agoric-sdk/issues/3239
84
85
  powers.exitVatWithFailure(reason);
@@ -114,7 +115,7 @@ export const makeZCFZygote = async (
114
115
  const zcfSeat = seatManager.makeZCFSeat(seatData);
115
116
 
116
117
  const exiter = makeExiter(seatData.proposal, zcfSeat);
117
- E(zoeInstanceAdmin)
118
+ void E(zoeInstanceAdmin)
118
119
  .makeNoEscrowSeat(initialAllocation, proposal, exiter, seatHandle)
119
120
  .then(userSeat => userSeatPromiseKit.resolve(userSeat));
120
121
 
@@ -210,6 +211,25 @@ export const makeZCFZygote = async (
210
211
  });
211
212
  const handleOfferObj = makeHandleOfferObj(taker);
212
213
 
214
+ /**
215
+ * @type {() => Promise<
216
+ * | {
217
+ * buildRootObject: any;
218
+ * start: undefined;
219
+ * meta: undefined;
220
+ * }
221
+ * | {
222
+ * prepare: ContractStartFn;
223
+ * customTermsShape?: Pick<ContractMeta, 'customTermsShape'>,
224
+ * privateArgsShape?: Pick<ContractMeta, 'privateArgsShape'>,
225
+ * }
226
+ * | {
227
+ * buildRootObject: undefined;
228
+ * start: ContractStartFn;
229
+ * meta?: ContractMeta;
230
+ * }
231
+ * >}
232
+ */
213
233
  const evaluateContract = () => {
214
234
  let bundle;
215
235
  if (passStyleOf(contractBundleCap) === 'remotable') {
@@ -222,29 +242,48 @@ export const makeZCFZygote = async (
222
242
  return evalContractBundle(bundle);
223
243
  };
224
244
  // evaluate the contract (either the first version, or an upgrade)
225
- const {
226
- start,
227
- buildRootObject,
228
- privateArgsShape,
229
- customTermsShape,
230
- prepare,
231
- } = await evaluateContract();
232
-
233
- if (start === undefined && prepare === undefined) {
234
- buildRootObject === undefined ||
235
- Fail`Did you provide a vat bundle instead of a contract bundle?`;
236
- Fail`contract exports missing start/prepare`;
245
+ const bundleResult = await evaluateContract();
246
+
247
+ //#region backwards compatibility with prepare()
248
+ const { start, meta = {} } = (() => {
249
+ if ('prepare' in bundleResult) {
250
+ if ('start' in bundleResult) {
251
+ Fail`contract must provide exactly one of "start" and "prepare"`;
252
+ }
253
+ // A contract must have one expression of upgradability
254
+ if (/** @type {any} */ (bundleResult).meta?.upgradability) {
255
+ Fail`prepare() is deprecated and incompatible with the 'upgradability' indicator`;
256
+ }
257
+ return {
258
+ start: bundleResult.prepare,
259
+ meta: {
260
+ upgradability: 'canUpgrade',
261
+ customTermsShape: bundleResult.customTermsShape,
262
+ privateArgsShape: bundleResult.privateArgsShape,
263
+ },
264
+ };
265
+ }
266
+ // normal behavior
267
+ return bundleResult;
268
+ })();
269
+ //#endregion
270
+
271
+ if (start === undefined) {
272
+ if ('buildRootObject' in bundleResult) {
273
+ // diagnose a common mistake
274
+ throw Fail`Did you provide a vat bundle instead of a contract bundle?`;
275
+ }
276
+ throw Fail`contract exports missing start`;
237
277
  }
238
- !start ||
239
- !prepare ||
240
- Fail`contract must provide exactly one of "start" and "prepare"`;
278
+
279
+ start.length <= 3 || Fail`invalid start parameters`;
280
+ const durabilityRequired =
281
+ meta.upgradability &&
282
+ ['canBeUpgraded', 'canUpgrade'].includes(meta.upgradability);
241
283
 
242
284
  /** @type {ZCF} */
243
- // Using Remotable rather than Far because there are too many complications
244
- // imposing checking wrappers: makeInvitation() and setJig() want to
245
- // accept raw functions. assert cannot be a valid passable! (It's a function
246
- // and has members.)
247
- const zcf = Remotable('Alleged: zcf', undefined, {
285
+ const zcf = prepareExo(zcfBaggage, 'zcf', ZcfI, {
286
+ atomicRearrange: transfers => seatManager.atomicRearrange(transfers),
248
287
  reallocate: (...seats) => seatManager.reallocate(...seats),
249
288
  assertUniqueKeyword: kwd => getInstanceRecHolder().assertUniqueKeyword(kwd),
250
289
  saveIssuer: async (issuerP, keyword) => {
@@ -279,11 +318,12 @@ export const makeZCFZygote = async (
279
318
  customDetails,
280
319
  proposalShape,
281
320
  );
282
- return invitationP;
321
+ // rely on the ZCF type signature
322
+ return /** @type {any} */ (invitationP);
283
323
  },
284
324
  // Shutdown the entire vat and give payouts
285
325
  shutdown: completion => {
286
- E(zoeInstanceAdmin).exitAllSeats(completion);
326
+ void E(zoeInstanceAdmin).exitAllSeats(completion);
287
327
  seatManager.dropAllReferences();
288
328
  powers.exitVat(completion);
289
329
  },
@@ -300,6 +340,7 @@ export const makeZCFZygote = async (
300
340
  const terms = getInstanceRecHolder().getTerms();
301
341
 
302
342
  // If the contract provided customTermsShape, validate the customTerms.
343
+ const { customTermsShape } = meta;
303
344
  if (customTermsShape) {
304
345
  const { brands: _b, issuers: _i, ...customTerms } = terms;
305
346
  mustMatch(harden(customTerms), customTermsShape, 'customTerms');
@@ -371,14 +412,15 @@ export const makeZCFZygote = async (
371
412
  instanceRecHolder = makeInstanceRecord(instanceRecordFromZoe);
372
413
  instantiateIssuerStorage(issuerStorageFromZoe);
373
414
  zcfBaggage.init('instanceRecHolder', instanceRecHolder);
415
+ zcfBaggage.init('repairedContractCompletionWatcher', true);
374
416
 
375
- const startFn = start || prepare;
417
+ const { privateArgsShape } = meta;
376
418
  if (privateArgsShape) {
377
419
  mustMatch(privateArgs, privateArgsShape, 'privateArgs');
378
420
  }
379
421
  // start a contract for the first time
380
422
  return E.when(
381
- startFn(zcf, privateArgs, contractBaggage),
423
+ start(zcf, privateArgs, contractBaggage),
382
424
  ({
383
425
  creatorFacet = undefined,
384
426
  publicFacet = undefined,
@@ -387,18 +429,16 @@ export const makeZCFZygote = async (
387
429
  }) => {
388
430
  const unexpectedKeys = Object.keys(unexpected);
389
431
  unexpectedKeys.length === 0 ||
390
- Fail`contract ${
391
- prepare ? 'prepare' : 'start'
392
- } returned unrecognized properties ${unexpectedKeys}`;
432
+ Fail`contract "start" returned unrecognized properties ${unexpectedKeys}`;
393
433
 
394
434
  const areDurable = objectMap(
395
435
  { creatorFacet, publicFacet, creatorInvitation },
396
436
  canBeDurable,
397
437
  );
398
438
  const allDurable = Object.values(areDurable).every(Boolean);
399
- if (prepare) {
439
+ if (durabilityRequired) {
400
440
  allDurable ||
401
- Fail`values from prepare() must be durable ${areDurable}`;
441
+ Fail`with ${meta.upgradability}, values from start() must be durable ${areDurable}`;
402
442
  }
403
443
 
404
444
  if (allDurable) {
@@ -418,18 +458,32 @@ export const makeZCFZygote = async (
418
458
  },
419
459
 
420
460
  restartContract: async (privateArgs = undefined) => {
421
- prepare || Fail`prepare must be defined to upgrade a contract`;
461
+ if (meta.upgradability) {
462
+ meta.upgradability === 'canUpgrade' || Fail`contract cannot upgrade`;
463
+ }
422
464
  zoeInstanceAdmin = zcfBaggage.get('zcfInstanceAdmin');
423
465
  instanceRecHolder = zcfBaggage.get('instanceRecHolder');
424
466
  initSeatMgrAndMintKind();
425
467
 
468
+ await null;
469
+ if (!zcfBaggage.has('repairedContractCompletionWatcher')) {
470
+ // We don't wait because it's a cross-vat call (to Zoe) that can't be
471
+ // completed during this vat's start-up
472
+ E(zoeInstanceAdmin)
473
+ .repairContractCompletionWatcher()
474
+ .catch(() => {});
475
+
476
+ zcfBaggage.init('repairedContractCompletionWatcher', true);
477
+ }
478
+
479
+ const { privateArgsShape } = meta;
426
480
  if (privateArgsShape) {
427
481
  mustMatch(privateArgs, privateArgsShape, 'privateArgs');
428
482
  }
429
483
 
430
484
  // restart an upgradeable contract
431
485
  return E.when(
432
- prepare(zcf, privateArgs, contractBaggage),
486
+ start(zcf, privateArgs, contractBaggage),
433
487
  ({
434
488
  creatorFacet = undefined,
435
489
  publicFacet = undefined,
@@ -3,10 +3,4 @@ export function atomicRearrange(zcf: ZCF, transfers: TransferPart[]): void;
3
3
  export function fromOnly(fromSeat: ZCFSeat, fromAmounts: AmountKeywordRecord): TransferPart;
4
4
  export function toOnly(toSeat: ZCFSeat, toAmounts: AmountKeywordRecord): TransferPart;
5
5
  export function atomicTransfer(zcf: ZCF, fromSeat?: ZCFSeat | undefined, toSeat?: ZCFSeat | undefined, fromAmounts?: AmountKeywordRecord | undefined, toAmounts?: AmountKeywordRecord | undefined): void;
6
- export type TransferPart = [
7
- fromSeat?: ZCFSeat,
8
- toSeat?: ZCFSeat,
9
- fromAmounts?: AmountKeywordRecord,
10
- toAmounts?: AmountKeywordRecord
11
- ];
12
6
  //# sourceMappingURL=atomicTransfer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomicTransfer.d.ts","sourceRoot":"","sources":["atomicTransfer.js"],"names":[],"mappings":"AAMA,iEAGE;AAgDK,qCAHI,GAAG,aACH,cAAc,QA+ExB;AAcM,mCAJI,OAAO,eACP,mBAAmB,gBAIc;AAcrC,+BAJI,OAAO,aACP,mBAAmB,gBAIqB;AAW5C,oCANI,GAAG,kKAYiE;2BAzKlE;IACZ,QAAY,CAAC,EAAE,OAAO;IACtB,MAAU,CAAC,EAAE,OAAO;IACpB,WAAe,CAAC,EAAE,mBAAmB;IACrC,SAAa,CAAC,EAAE,mBAAmB;CAChC"}
1
+ {"version":3,"file":"atomicTransfer.d.ts","sourceRoot":"","sources":["atomicTransfer.js"],"names":[],"mappings":"AAGA,iEAGE;AAyCK,qCAHI,GAAG,aACH,YAAY,EAAE,QAIxB;AAcM,mCAJI,OAAO,eACP,mBAAmB,GACjB,YAAY,CAGmB;AAcrC,+BAJI,OAAO,aACP,mBAAmB,GACjB,YAAY,CAG0B;AAW5C,oCANI,GAAG,kKAYgE"}
@@ -1,23 +1,11 @@
1
- import { mustMatch, M } from '@agoric/store';
2
- import { assertRightsConserved } from '../contractFacet/rightsConservation.js';
1
+ import { M } from '@agoric/store';
3
2
  import { AmountKeywordRecordShape, SeatShape } from '../typeGuards.js';
4
3
 
5
- const { Fail, quote: q } = assert;
6
-
7
4
  export const TransferPartShape = M.splitArray(
8
5
  harden([M.opt(SeatShape), M.opt(SeatShape), M.opt(AmountKeywordRecordShape)]),
9
6
  harden([M.opt(AmountKeywordRecordShape)]),
10
7
  );
11
8
 
12
- /**
13
- * @typedef {[
14
- * fromSeat?: ZCFSeat,
15
- * toSeat?: ZCFSeat,
16
- * fromAmounts?: AmountKeywordRecord,
17
- * toAmounts?: AmountKeywordRecord
18
- * ]} TransferPart
19
- */
20
-
21
9
  /**
22
10
  * Asks Zoe (via zcf) to rearrange the allocations among the seats
23
11
  * mentioned. This is a set of changes to allocations that must satisfy
@@ -52,86 +40,13 @@ export const TransferPartShape = M.splitArray(
52
40
  * which will remain helpers. These helper are for convenience
53
41
  * in expressing atomic rearrangements clearly.
54
42
  *
43
+ * @deprecated use the zcf builtin instead
44
+ *
55
45
  * @param {ZCF} zcf
56
46
  * @param {TransferPart[]} transfers
57
47
  */
58
48
  export const atomicRearrange = (zcf, transfers) => {
59
- mustMatch(transfers, M.arrayOf(M.array()), 'transfers');
60
- const uniqueSeatSet = new Set();
61
- for (const [
62
- fromSeat = undefined,
63
- toSeat = undefined,
64
- fromAmounts = undefined,
65
- toAmounts = undefined,
66
- ] of transfers) {
67
- if (fromSeat) {
68
- if (!fromAmounts) {
69
- throw Fail`Transfer from ${fromSeat} must say how much`;
70
- }
71
- uniqueSeatSet.add(fromSeat);
72
- if (toSeat) {
73
- // Conserved transfer between seats
74
- if (toAmounts) {
75
- // distinct amounts, so we check conservation.
76
- assertRightsConserved(
77
- Object.values(fromAmounts),
78
- Object.values(toAmounts),
79
- );
80
- } // else fromAmounts will be used as toAmounts
81
- uniqueSeatSet.add(toSeat);
82
- } else {
83
- // Transfer only from fromSeat
84
- !toAmounts ||
85
- Fail`Transfer without toSeat cannot have toAmounts ${toAmounts}`;
86
- }
87
- } else {
88
- toSeat || Fail`Transfer must have at least one of fromSeat or toSeat`;
89
- // Transfer only to toSeat
90
- !fromAmounts ||
91
- Fail`Transfer without fromSeat cannot have fromAmounts ${fromAmounts}`;
92
- toAmounts || Fail`Transfer to ${toSeat} must say how much`;
93
- uniqueSeatSet.add(toSeat);
94
- }
95
- }
96
-
97
- const uniqueSeats = harden([...uniqueSeatSet.keys()]);
98
- for (const seat of uniqueSeats) {
99
- !seat.hasStagedAllocation() ||
100
- Fail`Cannot mix atomicRearrange with seat stagings: ${seat}`;
101
- }
102
-
103
- // At this point the basic shape has been validated
104
-
105
- try {
106
- for (const [
107
- fromSeat = undefined,
108
- toSeat = undefined,
109
- fromAmounts = undefined,
110
- toAmounts = toSeat && fromAmounts,
111
- ] of transfers) {
112
- if (fromSeat && fromAmounts) {
113
- // testing both just to satisfy the type checker
114
- fromSeat.decrementBy(fromAmounts);
115
- }
116
- if (toSeat && toAmounts) {
117
- // testing both just to satisfy the type checker
118
- toSeat.incrementBy(toAmounts);
119
- }
120
- }
121
-
122
- // Perhaps deprecate this >= 2 restriction?
123
- uniqueSeats.length >= 2 ||
124
- Fail`Can only commit a reallocation among at least 2 seats: ${q(
125
- uniqueSeats.length,
126
- )}`;
127
- // Take it apart and put it back together to satisfy the type checker
128
- const [seat0, seat1, ...restSeats] = uniqueSeats;
129
- zcf.reallocate(seat0, seat1, ...restSeats);
130
- } finally {
131
- for (const seat of uniqueSeats) {
132
- seat.clear();
133
- }
134
- }
49
+ zcf.atomicRearrange(transfers);
135
50
  };
136
51
 
137
52
  /**
@@ -179,4 +94,4 @@ export const atomicTransfer = (
179
94
  toSeat = undefined,
180
95
  fromAmounts = undefined,
181
96
  toAmounts = undefined,
182
- ) => atomicRearrange(zcf, harden([[fromSeat, toSeat, fromAmounts, toAmounts]]));
97
+ ) => zcf.atomicRearrange(harden([[fromSeat, toSeat, fromAmounts, toAmounts]]));
@@ -27,7 +27,7 @@ const BASIS_POINTS = 10000n; // TODO change to 10_000n once tooling copes.
27
27
  * pool of the kind of asset sent in
28
28
  * @param {any} outputReserve - the value in the liquidity
29
29
  * pool of the kind of asset to be sent out
30
- * @param {bigint} [feeBasisPoints=30n] - the fee taken in
30
+ * @param {bigint} [feeBasisPoints] - the fee taken in
31
31
  * basis points. The default is 0.3% or 30 basis points. The fee
32
32
  * is taken from inputValue
33
33
  * @returns {NatValue} outputValue - the current price, in value form
@@ -66,7 +66,7 @@ export const getInputPrice = (
66
66
  * pool of the asset being spent
67
67
  * @param {any} outputReserve - the value in the liquidity
68
68
  * pool of the kind of asset to be sent out
69
- * @param {bigint} [feeBasisPoints=30n] - the fee taken in
69
+ * @param {bigint} [feeBasisPoints] - the fee taken in
70
70
  * basis points. The default is 0.3% or 30 basis points. The fee is taken from
71
71
  * outputValue
72
72
  * @returns {NatValue} inputValue - the value of input required to purchase output
@@ -1,5 +1,5 @@
1
- export function makeEphemeraProvider<E extends {}, K extends {} = any>(init: (key: K) => E): (key: K) => E;
2
- export function provideEmptySeat(zcf: ZCF, baggage: MapStore<string, unknown>, name: string): ZCFSeat;
1
+ export function makeEphemeraProvider<E extends {}, K extends WeakKey>(init: (key: K) => E): (key: K) => E;
2
+ export function provideEmptySeat(zcf: ZCF, baggage: import("@agoric/swingset-liveslots").Baggage, name: string): ZCFSeat;
3
3
  export function provideAll<T extends Record<string, () => ERef<any>>>(baggage: MapStore<string, any>, thunks: T): Promise<{ [K in keyof T]: Awaited<ReturnType<T[K]>>; }>;
4
- export function provideSingleton<T extends () => ERef<any>>(mapStore: MapStore<string, unknown>, key: string, makeValue: T, withValue?: ((value: Awaited<ReturnType<T>>) => void) | undefined): Promise<Awaited<ReturnType<T>>>;
4
+ export function provideSingleton<T extends () => ERef<any>>(mapStore: import("@agoric/vat-data").Baggage, key: string, makeValue: T, withValue?: ((value: Awaited<ReturnType<T>>) => void) | undefined): Promise<Awaited<ReturnType<T>>>;
5
5
  //# sourceMappingURL=durability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["durability.js"],"names":[],"mappings":"AAaO,2GAkBN;AAWM,sCALI,GAAG,4CAEH,MAAM,GACJ,OAAO,CAInB;AAiCM,0DAL4B,KAAK,GAAG,CAAC,YACjC,SAAS,MAAM,EAAE,GAAG,CAAC,sEAyB/B;AAgBM,iDAPa,KAAK,GAAG,CAAC,4CAElB,MAAM,gEAE6B,IAAI,gDAejD"}
1
+ {"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["durability.js"],"names":[],"mappings":"AAaO,qCAJW,CAAC,SAAN,EAAI,EACM,CAAC,SAAV,OAAQ,QACX,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,eASA,CAAC,CAWxB;AAWM,sCALI,GAAG,WACH,OAAO,4BAA4B,EAAE,OAAO,QAC5C,MAAM,GACJ,OAAO,CAInB;AAiCM,2BALwC,CAAC,SAAlC,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,GAAG,CAAC,CAAE,WACnC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,UACrB,CAAC,GACC,OAAO,CAAC,GAAG,CAAY,IAAP,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC,CAuBlE;AAgBM,iCAPwB,CAAC,SAAnB,MAAO,IAAI,CAAC,GAAG,CAAE,YACnB,OAAO,kBAAkB,EAAE,OAAO,OAClC,MAAM,aACN,CAAC,uBACO,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,gBACrC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAc3C"}
@@ -8,7 +8,7 @@ import { E } from '@endo/eventual-send';
8
8
  * representative also remains.
9
9
  *
10
10
  * @template {{}} E Ephemeral state
11
- * @template {{}} [K=any] key on which to provision
11
+ * @template {WeakKey} K key on which to provision
12
12
  * @param {(key: K) => E} init
13
13
  */
14
14
  export const makeEphemeraProvider = init => {
@@ -36,7 +36,7 @@ harden(makeEphemeraProvider);
36
36
  * Provide an empty ZCF seat.
37
37
  *
38
38
  * @param {ZCF} zcf
39
- * @param {import('@agoric/ertp').Baggage} baggage
39
+ * @param {import('@agoric/swingset-liveslots').Baggage} baggage
40
40
  * @param {string} name
41
41
  * @returns {ZCFSeat}
42
42
  */
@@ -113,9 +113,9 @@ harden(provideAll);
113
113
  * @returns {Promise<Awaited<ReturnType<T>>>}
114
114
  */
115
115
  export const provideSingleton = (mapStore, key, makeValue, withValue) => {
116
- const stored =
117
- mapStore.has(key) ||
118
- E.when(makeValue(), v => mapStore.init(key, harden(v)));
116
+ const stored = mapStore.has(key)
117
+ ? undefined
118
+ : E.when(makeValue(), v => mapStore.init(key, harden(v)));
119
119
 
120
120
  return E.when(stored, () => {
121
121
  const value = mapStore.get(key);
@@ -1,6 +1,7 @@
1
1
  export { natSafeMath } from "./safeMath.js";
2
2
  export { makeStateMachine } from "./stateMachine.js";
3
3
  export * from "./durability.js";
4
+ export * from "./prepare-ownable.js";
4
5
  export * from "./priceAuthority.js";
5
6
  export * from "./priceQuote.js";
6
7
  export * from "./statistics.js";
@@ -54,6 +54,7 @@ export {
54
54
  } from './ratio.js';
55
55
 
56
56
  export * from './durability.js';
57
+ export * from './prepare-ownable.js';
57
58
  export * from './priceAuthority.js';
58
59
  export * from './priceQuote.js';
59
60
  export * from './statistics.js';
@@ -0,0 +1,11 @@
1
+ export function prepareOwnable<MN extends (string | symbol)[]>(zone: import("@agoric/base-zone").Zone, makeInvitation: ZCF["makeInvitation"], uKindName: string, uMethodNames: MN, options?: OwnableOptions | undefined): <U>(underlying: U) => Pick<U, MN[number]> & {
2
+ makeTransferInvitation: () => Invitation<U>;
3
+ };
4
+ export type OwnableOptions = {
5
+ /**
6
+ * The `interfaceName` of the underlying interface guard.
7
+ * Defaults to the `uKindName`.
8
+ */
9
+ uInterfaceName?: string | undefined;
10
+ };
11
+ //# sourceMappingURL=prepare-ownable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-ownable.d.ts","sourceRoot":"","sources":["prepare-ownable.js"],"names":[],"mappings":"AA0CO,+BAlB4B,EAAE,SAAvB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAG,QACvB,OAAO,mBAAmB,EAAE,IAAI,kBAChC,GAAG,CAAC,gBAAgB,CAAC,aAQrB,MAAM,gBAEN,EAAE,yCAIA,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG;IAAC,sBAAsB,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,CAAA;CAAC,CA0DrG"}
@@ -0,0 +1,100 @@
1
+ import { M } from '@endo/patterns';
2
+ import { prepareRevocableMakerKit } from '@agoric/base-zone/zone-helpers.js';
3
+ import { OfferHandlerI } from '../typeGuards.js';
4
+
5
+ const TransferProposalShape = M.splitRecord({
6
+ give: {},
7
+ want: {},
8
+ exit: {
9
+ onDemand: null,
10
+ },
11
+ });
12
+
13
+ /**
14
+ * @typedef {object} OwnableOptions
15
+ * @property {string} [uInterfaceName]
16
+ * The `interfaceName` of the underlying interface guard.
17
+ * Defaults to the `uKindName`.
18
+ */
19
+
20
+ /**
21
+ * Prepare a kind that wraps an 'ownable' object with a `makeTransferInvitation`
22
+ * ability and delegates to the underlying object methods specified in an
23
+ * allowlist of method names.
24
+ *
25
+ * @template {(string | symbol)[]} MN Method names
26
+ * @param {import('@agoric/base-zone').Zone} zone
27
+ * @param {ZCF['makeInvitation']} makeInvitation
28
+ * A function with the same behavior as `zcf.makeInvitation`.
29
+ * A contract will normally just extract it from its own zcf using the
30
+ * argument expression
31
+ * ```js
32
+ * (...args) => zcf.makeInvitation(...args)
33
+ * ```
34
+ * See ownable-counter.js for the canonical example.
35
+ * @param {string} uKindName
36
+ * The `kindName` of the underlying exo class
37
+ * @param {MN} uMethodNames
38
+ * The method names of the underlying exo class that should be represented
39
+ * by transparently-forwarding methods of the wrapping ownable object.
40
+ * @param {OwnableOptions} [options]
41
+ * @returns {<U>(underlying: U) => Pick<U, MN[number]> & {makeTransferInvitation: () => Invitation<U>}}
42
+ */
43
+ export const prepareOwnable = (
44
+ zone,
45
+ makeInvitation,
46
+ uKindName,
47
+ uMethodNames,
48
+ options = {},
49
+ ) => {
50
+ const { uInterfaceName = uKindName } = options;
51
+ const { revoke, makeRevocable } = prepareRevocableMakerKit(
52
+ zone,
53
+ uKindName,
54
+ uMethodNames,
55
+ {
56
+ uInterfaceName,
57
+ extraMethodGuards: {
58
+ makeTransferInvitation: M.call().returns(M.promise()),
59
+ },
60
+ extraMethods: {
61
+ makeTransferInvitation() {
62
+ const { underlying } = this.state;
63
+ const { revocable } = this.facets;
64
+ const customDetails = underlying.getInvitationCustomDetails();
65
+ // eslint-disable-next-line no-use-before-define
66
+ const transferHandler = makeTransferHandler(underlying);
67
+
68
+ const invitation = makeInvitation(
69
+ transferHandler,
70
+ 'transfer',
71
+ customDetails,
72
+ TransferProposalShape,
73
+ );
74
+ revoke(revocable);
75
+ return invitation;
76
+ },
77
+ },
78
+ },
79
+ );
80
+
81
+ const makeTransferHandler = zone.exoClass(
82
+ 'TransferHandler',
83
+ OfferHandlerI,
84
+ underlying => ({
85
+ underlying,
86
+ }),
87
+ {
88
+ handle(seat) {
89
+ const { underlying } = this.state;
90
+ const revocable = makeRevocable(underlying);
91
+ seat.exit();
92
+ return revocable;
93
+ },
94
+ },
95
+ );
96
+
97
+ const makeOwnable = underlying => makeRevocable(underlying);
98
+ return harden(makeOwnable);
99
+ };
100
+ harden(prepareOwnable);
@@ -1,22 +1,30 @@
1
- /**
2
- * @param {object} opts
3
- * @param {Issuer<'set'>} opts.quoteIssuer
4
- * @param {ERef<Notifier<unknown>>} opts.notifier
5
- * @param {ERef<import('@agoric/time/src/types').TimerService>} opts.timer
6
- * @param {PriceQuoteCreate} opts.createQuote
7
- * @param {Brand<'nat'>} opts.actualBrandIn
8
- * @param {Brand<'nat'>} opts.actualBrandOut
9
- * @returns {PriceAuthorityKit}
10
- */
1
+ export const PriceAuthorityI: import("@endo/patterns").InterfaceGuard<{
2
+ getQuoteIssuer: import("@endo/patterns").MethodGuard;
3
+ getTimerService: import("@endo/patterns").MethodGuard;
4
+ quoteGiven: import("@endo/patterns").MethodGuard;
5
+ quoteWanted: import("@endo/patterns").MethodGuard;
6
+ makeQuoteNotifier: import("@endo/patterns").MethodGuard;
7
+ quoteAtTime: import("@endo/patterns").MethodGuard;
8
+ quoteWhenLT: import("@endo/patterns").MethodGuard;
9
+ quoteWhenLTE: import("@endo/patterns").MethodGuard;
10
+ quoteWhenGTE: import("@endo/patterns").MethodGuard;
11
+ quoteWhenGT: import("@endo/patterns").MethodGuard;
12
+ mutableQuoteWhenLT: import("@endo/patterns").MethodGuard;
13
+ mutableQuoteWhenLTE: import("@endo/patterns").MethodGuard;
14
+ mutableQuoteWhenGTE: import("@endo/patterns").MethodGuard;
15
+ mutableQuoteWhenGT: import("@endo/patterns").MethodGuard;
16
+ }>;
11
17
  export function makeOnewayPriceAuthorityKit(opts: {
12
- quoteIssuer: Issuer<'set'>;
18
+ quoteIssuer: Issuer<"set", PriceDescription>;
13
19
  notifier: ERef<Notifier<unknown>>;
14
- timer: ERef<import('@agoric/time/src/types').TimerService>;
20
+ timer: ERef<import("@agoric/time").TimerService>;
15
21
  createQuote: PriceQuoteCreate;
16
- actualBrandIn: Brand<'nat'>;
17
- actualBrandOut: Brand<'nat'>;
22
+ actualBrandIn: Brand<"nat">;
23
+ actualBrandOut: Brand<"nat">;
18
24
  }): PriceAuthorityKit;
19
- export const PriceAuthorityI: import("@endo/patterns").InterfaceGuard;
20
25
  export type CompareAmount = (amount: Amount, amountLimit: Amount) => boolean;
21
26
  export type Trigger = (createInstantQuote: PriceQuoteCreate) => Promise<void>;
27
+ import type { PriceDescription } from '@agoric/zoe/tools/types.js';
28
+ import type { PriceQuoteCreate } from '@agoric/zoe/tools/types.js';
29
+ import type { PriceAuthorityKit } from '@agoric/zoe/tools/types.js';
22
30
  //# sourceMappingURL=priceAuthority.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"priceAuthority.d.ts","sourceRoot":"","sources":["priceAuthority.js"],"names":[],"mappings":"AA6DA;;;;;;;;;GASG;AACH;IAR+B,WAAW,EAA/B,OAAO,KAAK,CAAC;IACiB,QAAQ,EAAtC,KAAK,SAAS,OAAO,CAAC,CAAC;IACmC,KAAK,EAA/D,KAAK,OAAO,wBAAwB,EAAE,YAAY,CAAC;IAC5B,WAAW,EAAlC,gBAAgB;IACG,aAAa,EAAhC,MAAM,KAAK,CAAC;IACO,cAAc,EAAjC,MAAM,KAAK,CAAC;IACV,iBAAiB,CA6S7B;AAxUD,sEAiBG;qCA3CQ,MAAM,eACN,MAAM,KACJ,OAAO;2CAiBT,gBAAgB,KACd,QAAQ,IAAI,CAAC"}
1
+ {"version":3,"file":"priceAuthority.d.ts","sourceRoot":"","sources":["priceAuthority.js"],"names":[],"mappings":"AA8CA;;;;;;;;;;;;;;;GAiBG;AAYI,kDARJ;IAA8C,WAAW,EAAjD,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACD,QAAQ,EAAtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACyB,KAAK,EAArD,IAAI,CAAC,OAAO,cAAc,EAAE,YAAY,CAAC;IAClB,WAAW,EAAlC,gBAAgB;IACG,aAAa,EAAhC,KAAK,CAAC,KAAK,CAAC;IACO,cAAc,EAAjC,KAAK,CAAC,KAAK,CAAC;CACpB,GAAU,iBAAiB,CAwT7B;qCA7WU,MAAM,eACN,MAAM,KACJ,OAAO;2CAiBT,gBAAgB,KACd,OAAO,CAAC,IAAI,CAAC;sCA7ByI,4BAA4B;sCAA5B,4BAA4B;uCAA5B,4BAA4B"}