@agoric/zoe 0.27.0-upgrade-20-dev-ef71cfd.0 → 0.27.0-upgrade-19-devnet-dev-5428c4d.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 (159) hide show
  1. package/bundles/bundle-contractFacet-js-meta.json +275 -270
  2. package/bundles/bundle-contractFacet.js +1 -1
  3. package/package.json +29 -29
  4. package/src/cleanProposal.d.ts +0 -2
  5. package/src/cleanProposal.d.ts.map +1 -1
  6. package/src/cleanProposal.js +2 -4
  7. package/src/contractFacet/exit.d.ts +1 -1
  8. package/src/contractFacet/exit.d.ts.map +1 -1
  9. package/src/contractFacet/internal-types.d.ts +8 -0
  10. package/src/contractFacet/internal-types.d.ts.map +1 -0
  11. package/src/contractFacet/internal-types.js +15 -0
  12. package/src/contractFacet/offerHandlerStorage.d.ts +1 -1
  13. package/src/contractFacet/rightsConservation.d.ts.map +1 -1
  14. package/src/contractFacet/rightsConservation.js +1 -0
  15. package/src/contractFacet/{types.ts → types-ambient.d.ts} +29 -66
  16. package/src/contractFacet/types-ambient.js +1 -0
  17. package/src/contractFacet/vatRoot.d.ts +2 -8
  18. package/src/contractFacet/vatRoot.d.ts.map +1 -1
  19. package/src/contractFacet/vatRoot.js +4 -5
  20. package/src/contractFacet/zcfMint.d.ts +2 -3
  21. package/src/contractFacet/zcfMint.d.ts.map +1 -1
  22. package/src/contractFacet/zcfMint.js +7 -7
  23. package/src/contractFacet/zcfSeat.js +2 -2
  24. package/src/contractFacet/zcfZygote.d.ts +1 -9
  25. package/src/contractFacet/zcfZygote.d.ts.map +1 -1
  26. package/src/contractFacet/zcfZygote.js +5 -17
  27. package/src/contractSupport/atomicTransfer.d.ts +0 -6
  28. package/src/contractSupport/atomicTransfer.d.ts.map +1 -1
  29. package/src/contractSupport/atomicTransfer.js +0 -4
  30. package/src/contractSupport/bondingCurves.js +1 -1
  31. package/src/contractSupport/index.d.ts +2 -2
  32. package/src/contractSupport/index.js +19 -2
  33. package/src/contractSupport/priceAuthorityInitial.d.ts +0 -2
  34. package/src/contractSupport/priceAuthorityInitial.d.ts.map +1 -1
  35. package/src/contractSupport/priceAuthorityInitial.js +1 -3
  36. package/src/contractSupport/ratio.d.ts +37 -0
  37. package/src/contractSupport/ratio.d.ts.map +1 -0
  38. package/src/contractSupport/ratio.js +419 -0
  39. package/src/contractSupport/safeMath.d.ts +11 -0
  40. package/src/contractSupport/safeMath.d.ts.map +1 -0
  41. package/src/contractSupport/safeMath.js +49 -0
  42. package/src/contractSupport/types-ambient.d.ts.map +1 -1
  43. package/src/contractSupport/types-ambient.js +0 -1
  44. package/src/contractSupport/zoeHelpers.d.ts +1 -6
  45. package/src/contractSupport/zoeHelpers.d.ts.map +1 -1
  46. package/src/contractSupport/zoeHelpers.js +0 -1
  47. package/src/contracts/atomicSwap.d.ts +1 -1
  48. package/src/contracts/auction/index.d.ts +3 -3
  49. package/src/contracts/automaticRefund.d.ts +3 -3
  50. package/src/contracts/autoswap.d.ts +0 -4
  51. package/src/contracts/autoswap.d.ts.map +1 -1
  52. package/src/contracts/autoswap.js +0 -4
  53. package/src/contracts/barterExchange.d.ts +2 -2
  54. package/src/contracts/callSpread/fundedCallSpread.d.ts +1 -1
  55. package/src/contracts/callSpread/pricedCallSpread.d.ts +4 -4
  56. package/src/contracts/coveredCall-durable.d.ts +1 -1
  57. package/src/contracts/coveredCall.d.ts +1 -1
  58. package/src/contracts/loan/index.d.ts +1 -1
  59. package/src/contracts/loan/types-ambient.d.ts +13 -13
  60. package/src/contracts/loan/types-ambient.d.ts.map +1 -1
  61. package/src/contracts/loan/types-ambient.js +17 -17
  62. package/src/contracts/mintPayments.d.ts +2 -2
  63. package/src/contracts/oracle.d.ts +0 -3
  64. package/src/contracts/oracle.d.ts.map +1 -1
  65. package/src/contracts/oracle.js +0 -1
  66. package/src/contracts/priceAggregator.d.ts +0 -2
  67. package/src/contracts/priceAggregator.d.ts.map +1 -1
  68. package/src/contracts/priceAggregator.js +8 -10
  69. package/src/contracts/scaledPriceAuthority.d.ts +0 -1
  70. package/src/contracts/scaledPriceAuthority.d.ts.map +1 -1
  71. package/src/contracts/scaledPriceAuthority.js +0 -1
  72. package/src/contracts/sellItems.d.ts +1 -1
  73. package/src/contracts/simpleExchange.d.ts +0 -5
  74. package/src/contracts/simpleExchange.d.ts.map +1 -1
  75. package/src/contracts/simpleExchange.js +0 -4
  76. package/src/contracts/types-ambient.d.ts +7 -7
  77. package/src/contracts/types-ambient.d.ts.map +1 -1
  78. package/src/contracts/types-ambient.js +7 -7
  79. package/src/contracts/valueVow.contract.d.ts +2 -5
  80. package/src/contracts/valueVow.contract.d.ts.map +1 -1
  81. package/src/contracts/valueVow.contract.js +0 -1
  82. package/src/instanceRecordStorage.d.ts.map +1 -1
  83. package/src/instanceRecordStorage.js +1 -3
  84. package/src/internal-types.d.ts +5 -15
  85. package/src/internal-types.d.ts.map +1 -1
  86. package/src/internal-types.js +4 -9
  87. package/src/issuerRecord.d.ts +2 -3
  88. package/src/issuerRecord.d.ts.map +1 -1
  89. package/src/issuerRecord.js +2 -6
  90. package/src/issuerStorage.d.ts +2 -3
  91. package/src/issuerStorage.d.ts.map +1 -1
  92. package/src/issuerStorage.js +5 -6
  93. package/src/typeGuards.d.ts +6 -10
  94. package/src/typeGuards.d.ts.map +1 -1
  95. package/src/typeGuards.js +5 -7
  96. package/src/types-ambient.d.ts +40 -0
  97. package/src/types-ambient.d.ts.map +1 -1
  98. package/src/types-ambient.js +42 -4
  99. package/src/zoeService/feeMint.d.ts +0 -1
  100. package/src/zoeService/feeMint.d.ts.map +1 -1
  101. package/src/zoeService/feeMint.js +0 -4
  102. package/src/zoeService/installationStorage.d.ts +2 -3
  103. package/src/zoeService/installationStorage.d.ts.map +1 -1
  104. package/src/zoeService/installationStorage.js +5 -2
  105. package/src/zoeService/internal-types.d.ts +3 -11
  106. package/src/zoeService/internal-types.d.ts.map +1 -1
  107. package/src/zoeService/internal-types.js +3 -9
  108. package/src/zoeService/invitationQueries.d.ts +3 -3
  109. package/src/zoeService/invitationQueries.js +3 -3
  110. package/src/zoeService/makeInvitation.d.ts +0 -1
  111. package/src/zoeService/makeInvitation.d.ts.map +1 -1
  112. package/src/zoeService/makeInvitation.js +0 -3
  113. package/src/zoeService/offer/offer.d.ts +0 -1
  114. package/src/zoeService/offer/offer.d.ts.map +1 -1
  115. package/src/zoeService/offer/offer.js +1 -3
  116. package/src/zoeService/originalZoeSeat.d.ts.map +1 -1
  117. package/src/zoeService/originalZoeSeat.js +1 -0
  118. package/src/zoeService/startInstance.d.ts.map +1 -1
  119. package/src/zoeService/startInstance.js +2 -0
  120. package/src/zoeService/types-ambient.d.ts +226 -0
  121. package/src/zoeService/types-ambient.d.ts.map +1 -1
  122. package/src/zoeService/types-ambient.js +327 -4
  123. package/src/zoeService/utils.d.ts +5 -13
  124. package/src/zoeService/utils.test-d.ts +0 -1
  125. package/src/zoeService/zoe.d.ts +1 -11
  126. package/src/zoeService/zoe.d.ts.map +1 -1
  127. package/src/zoeService/zoe.js +1 -8
  128. package/src/zoeService/zoeSeat.d.ts.map +1 -1
  129. package/src/zoeService/zoeSeat.js +2 -1
  130. package/src/zoeService/zoeStorageManager.d.ts +5 -5
  131. package/src/zoeService/zoeStorageManager.d.ts.map +1 -1
  132. package/src/zoeService/zoeStorageManager.js +3 -4
  133. package/tools/fakeVatAdmin.d.ts +2 -9
  134. package/tools/fakeVatAdmin.d.ts.map +1 -1
  135. package/tools/fakeVatAdmin.js +10 -18
  136. package/tools/manualPriceAuthority.d.ts +1 -4
  137. package/tools/manualPriceAuthority.d.ts.map +1 -1
  138. package/tools/manualPriceAuthority.js +0 -1
  139. package/tools/scriptedOracle.d.ts +2 -6
  140. package/tools/scriptedOracle.d.ts.map +1 -1
  141. package/tools/scriptedOracle.js +0 -4
  142. package/tools/setup-zoe.d.ts +6 -12
  143. package/tools/setup-zoe.d.ts.map +1 -1
  144. package/tools/setup-zoe.js +5 -38
  145. package/tools/test-utils.d.ts +1 -1
  146. package/tools/test-utils.js +1 -1
  147. package/tools/types.d.ts +0 -1
  148. package/tools/types.d.ts.map +1 -1
  149. package/tools/types.js +0 -1
  150. package/src/contractFacet/types.d.ts +0 -184
  151. package/src/contractFacet/types.d.ts.map +0 -1
  152. package/src/types-index.d.ts +0 -4
  153. package/src/types-index.js +0 -2
  154. package/src/types.d.ts +0 -29
  155. package/src/types.d.ts.map +0 -1
  156. package/src/types.ts +0 -44
  157. package/src/zoeService/types.d.ts +0 -238
  158. package/src/zoeService/types.d.ts.map +0 -1
  159. package/src/zoeService/types.ts +0 -307
@@ -1,307 +0,0 @@
1
- import type {
2
- AnyAmount,
3
- AssetKind,
4
- DisplayInfo,
5
- Issuer,
6
- NatValue,
7
- Payment,
8
- } from '@agoric/ertp';
9
- import type { Subscriber } from '@agoric/notifier';
10
- import type { ERef, EReturn } from '@endo/eventual-send';
11
- import type { Bundle, BundleID } from '@agoric/swingset-vat';
12
- import type { ContractStartFunction, StartParams } from './utils.js';
13
- import type {
14
- Keyword,
15
- InvitationHandle,
16
- BrandKeywordRecord,
17
- Handle,
18
- IssuerKeywordRecord,
19
- } from '../types.js';
20
- import type { Allocation } from '../types-index.js';
21
-
22
- /**
23
- * @see {@link https://github.com/sindresorhus/type-fest/blob/main/source/is-any.d.ts}
24
- */
25
- type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
26
-
27
- /**
28
- * Zoe provides a framework for deploying and working with smart
29
- * contracts. It is accessed as a long-lived and well-trusted service
30
- * that enforces offer safety for the contracts that use it. Zoe has a
31
- * single `invitationIssuer` for the entirety of its lifetime. By
32
- * having a reference to Zoe, a user can get the `invitationIssuer`
33
- * and thus validate any `invitation` they receive from someone else.
34
- *
35
- * Zoe has two different facets: the public Zoe service and the
36
- * contract facet (ZCF). Each contract instance has a copy of ZCF
37
- * within its vat. The contract and ZCF never have direct access to
38
- * the users' payments or the Zoe purses.
39
- */
40
- export type ZoeService = {
41
- /**
42
- * Zoe has a single `invitationIssuer` for the entirety of its
43
- * lifetime. By having a reference to Zoe, a user can get the
44
- * `invitationIssuer` and thus validate any `invitation` they receive
45
- * from someone else. The mint associated with the invitationIssuer
46
- * creates the ERTP payments that represent the right to interact with
47
- * a smart contract in particular ways.
48
- */
49
- getInvitationIssuer: GetInvitationIssuer;
50
- install: InstallBundle;
51
- installBundleID: InstallBundleID;
52
- startInstance: import('./utils.js').StartInstance;
53
- offer: Offer;
54
- getPublicFacet: <I extends Instance>(
55
- instance: ERef<I>,
56
- ) => Promise<
57
- IsAny<I> extends true
58
- ? any
59
- : I extends import('./utils.js').Instance<
60
- infer SF extends ContractStartFunction
61
- >
62
- ? IsAny<SF> extends true
63
- ? unknown
64
- : EReturn<SF>['publicFacet']
65
- : never
66
- >;
67
- getIssuers: GetIssuers;
68
- getBrands: GetBrands;
69
- getTerms: <I extends ERef<Instance>>(
70
- instance: I,
71
- ) => IsAny<I> extends true
72
- ? Promise<any>
73
- : I extends ERef<
74
- import('./utils.js').Instance<infer SF extends ContractStartFunction>
75
- >
76
- ? IsAny<SF> extends true
77
- ? Promise<unknown>
78
- : Promise<StartParams<SF>['terms']>
79
- : never;
80
- getOfferFilter: (instance: ERef<Instance>) => Promise<string[]>;
81
- getInstallationForInstance: GetInstallationForInstance;
82
- getInstance: GetInstance;
83
- getInstallation: GetInstallation;
84
- /**
85
- * Return an object with the instance, installation, description, invitation
86
- * handle, and any custom properties specific to the contract.
87
- */
88
- getInvitationDetails: GetInvitationDetails;
89
- getFeeIssuer: GetFeeIssuer;
90
- getConfiguration: GetConfiguration;
91
- getBundleIDFromInstallation: GetBundleIDFromInstallation;
92
- /**
93
- * Return the pattern (if any) associated with the invitationHandle that a
94
- * proposal is required to match to be accepted by zoe.offer().
95
- */
96
- getProposalShapeForInvitation: (
97
- invitationHandle: InvitationHandle,
98
- ) => import('@endo/patterns').Pattern | undefined;
99
- };
100
- type GetInvitationIssuer = () => Promise<Issuer<'set', InvitationDetails>>;
101
- type GetFeeIssuer = () => Promise<Issuer<'nat'>>;
102
- type GetConfiguration = () => {
103
- feeIssuerConfig: FeeIssuerConfig;
104
- };
105
- export type GetIssuers = (
106
- instance: import('./utils.js').Instance<any>,
107
- ) => Promise<IssuerKeywordRecord>;
108
- export type GetBrands = (
109
- instance: import('./utils.js').Instance<any>,
110
- ) => Promise<BrandKeywordRecord>;
111
- type GetInstallationForInstance = (
112
- instance: import('./utils.js').Instance<any>,
113
- ) => Promise<Installation>;
114
- export type GetInstance = (
115
- invitation: ERef<import('../types-index.js').Invitation>,
116
- ) => Promise<import('./utils.js').Instance<any>>;
117
- export type GetInstallation = (
118
- invitation: ERef<import('../types-index.js').Invitation>,
119
- ) => Promise<Installation>;
120
- export type GetInvitationDetails = (
121
- invitation: ERef<import('../types-index.js').Invitation<any, any>>,
122
- ) => Promise<InvitationDetails>;
123
- /**
124
- * Create an installation by safely evaluating the code and
125
- * registering it with Zoe. Returns an installation.
126
- */
127
- export type InstallBundle = (
128
- bundle: Bundle | SourceBundle,
129
- bundleLabel?: string | undefined,
130
- ) => Promise<Installation>;
131
- /**
132
- * Create an installation from a Bundle ID. Returns an installation.
133
- */
134
- export type InstallBundleID = (
135
- bundleID: BundleID,
136
- bundleLabel?: string | undefined,
137
- ) => Promise<Installation>;
138
- /**
139
- * Verify that an alleged Installation is real, and return the Bundle ID it
140
- * will use for contract code.
141
- */
142
- export type GetBundleIDFromInstallation = (
143
- allegedInstallation: ERef<Installation>,
144
- ) => Promise<string>;
145
- /**
146
- * To redeem an invitation, the user normally provides a proposal (their
147
- * rules for the offer) as well as payments to be escrowed by Zoe. If
148
- * either the proposal or payments would be empty, indicate this by
149
- * omitting that argument or passing undefined, rather than passing an
150
- * empty record.
151
- *
152
- * The proposal has three parts: `want` and `give` are used by Zoe to
153
- * enforce offer safety, and `exit` is used to specify the particular
154
- * payout-liveness policy that Zoe can guarantee. `want` and `give`
155
- * are objects with keywords as keys and amounts as values.
156
- * `paymentKeywordRecord` is a record with keywords as keys, and the
157
- * values are the actual payments to be escrowed. A payment is
158
- * expected for every rule under `give`.
159
- */
160
- export type Offer = <Result, Args = undefined>(
161
- invitation: ERef<import('../types-index.js').Invitation<Result, Args>>,
162
- proposal?: Proposal,
163
- paymentKeywordRecord?: PaymentPKeywordRecord,
164
- offerArgs?: Args,
165
- ) => Promise<UserSeat<Result>>;
166
- /**
167
- * Zoe uses seats to access or manipulate offers. They let contracts and users
168
- * interact with them. Zoe has two kinds of seats. ZCFSeats are used within
169
- * contracts and with zcf methods. UserSeats represent offers external to Zoe
170
- * and the contract. The party who exercises an invitation and sends the offer()
171
- * message to Zoe gets a UserSeat that can check payouts' status or retrieve the
172
- * result of processing the offer in the contract. This varies, but examples are
173
- * a string and an invitation for another seat.
174
- *
175
- * Also, a UserSeat can be handed to an agent outside Zoe and the contract,
176
- * letting them query or monitor the current state, access the payouts and
177
- * result, and, if it's allowed for this seat, call tryExit().
178
- *
179
- * Since anyone can attempt to exit the seat if they have a reference to it, you
180
- * should only share a UserSeat with trusted parties.
181
- *
182
- * UserSeat includes queries for the associated offer's current state and an
183
- * operation to request that the offer exit, as follows:
184
- */
185
- export type UserSeat<OR = unknown> = {
186
- getProposal: () => Promise<ProposalRecord>;
187
- /**
188
- * returns a promise for a KeywordPaymentRecord containing all the payouts from
189
- * this seat. The promise will resolve after the seat has exited.
190
- */
191
- getPayouts: () => Promise<PaymentPKeywordRecord>;
192
- /**
193
- * returns a promise for the Payment corresponding to the indicated keyword.
194
- * The promise will resolve after the seat has exited. If there is no payment
195
- * corresponding to the keyword, an error will be thrown. (It used to return
196
- * undefined.)
197
- */
198
- getPayout: (keyword: Keyword) => Promise<Payment<any, any>>;
199
- getOfferResult: () => Promise<OR>;
200
- /**
201
- * Note: Only works if the seat's `proposal` has an `OnDemand` `exit` clause. Zoe's
202
- * offer-safety guarantee applies no matter how a seat's interaction with a
203
- * contract ends. Under normal circumstances, the participant might be able to
204
- * call `tryExit()`, or the contract might do something explicitly. On exiting,
205
- * the seat holder gets its current `allocation` and the `seat` can no longer
206
- * interact with the contract.
207
- */
208
- tryExit?: (() => void) | undefined;
209
- /**
210
- * Returns true if the seat has exited, false if it is still active.
211
- */
212
- hasExited: () => Promise<boolean>;
213
- /**
214
- * returns 1 if the proposal's
215
- * want clause was satisfied by the final allocation, otherwise 0. This is
216
- * numeric to support a planned enhancement called "multiples" which will allow
217
- * the return value to be any non-negative number. The promise will resolve
218
- * after the seat has exited.
219
- */
220
- numWantsSatisfied: () => Promise<0 | 1>;
221
- /**
222
- * return a promise for the final allocation. The promise will resolve after the
223
- * seat has exited.
224
- */
225
- getFinalAllocation: () => Promise<Allocation>;
226
- /**
227
- * returns a subscriber that
228
- * will be notified when the seat has exited or failed.
229
- */
230
- getExitSubscriber: () => Subscriber<import('../types-index.js').Completion>;
231
- };
232
- export type Proposal = Partial<ProposalRecord>;
233
- export type ProposalRecord = {
234
- give: AmountKeywordRecord;
235
- want: AmountKeywordRecord;
236
- exit: ExitRule;
237
- };
238
- /**
239
- * The keys are keywords, and the values are amounts. For example:
240
- * { Asset: AmountMath.make(assetBrand, 5n), Price:
241
- * AmountMath.make(priceBrand, 9n) }
242
- */
243
- export type AmountKeywordRecord = Record<Keyword, AnyAmount>;
244
- export type Waker = {
245
- wake: () => void;
246
- };
247
- export type OnDemandExitRule = {
248
- onDemand: null;
249
- };
250
- export type WaivedExitRule = {
251
- waived: null;
252
- };
253
- export type AfterDeadlineExitRule = {
254
- afterDeadline: {
255
- timer: import('@agoric/time').TimerService;
256
- deadline: import('@agoric/time').Timestamp;
257
- };
258
- };
259
- /**
260
- * The possible keys are 'waived', 'onDemand', and 'afterDeadline'.
261
- * `timer` and `deadline` only are used for the `afterDeadline` key.
262
- * The possible records are:
263
- * `{ waived: null }`
264
- * `{ onDemand: null }`
265
- * `{ afterDeadline: { timer :Timer<Deadline>, deadline :Deadline } }`
266
- */
267
- export type ExitRule =
268
- | OnDemandExitRule
269
- | WaivedExitRule
270
- | AfterDeadlineExitRule;
271
- export type Instance<SF = any> = import('./utils.js').Instance<SF>;
272
- export type ZCFSpec =
273
- | {
274
- bundleCap: import('@agoric/swingset-vat').BundleCap;
275
- }
276
- | {
277
- name: string;
278
- }
279
- | {
280
- /** Bundle ID */
281
- id: string;
282
- };
283
- /**
284
- * Opaque type for a JSONable source bundle
285
- */
286
- export type SourceBundle = Record<string, any>;
287
- export type PaymentPKeywordRecord = Record<Keyword, ERef<Payment<any>>>;
288
- export type PaymentKeywordRecord = Record<Keyword, Payment<any>>;
289
- export type InvitationDetails = {
290
- installation: Installation;
291
- instance: import('./utils.js').Instance<any>;
292
- handle: InvitationHandle;
293
- description: string;
294
- customDetails?: Record<string, any> | undefined;
295
- };
296
- export type Installation<SF = any> = import('./utils.js').Installation<SF>;
297
- export type InstallationStart<I extends Installation> =
298
- import('./utils.js').InstallationStart<I>;
299
- export type FeeIssuerConfig = {
300
- name: string;
301
- assetKind: AssetKind;
302
- displayInfo: DisplayInfo;
303
- };
304
- export type ZoeFeesConfig = {
305
- getPublicFacetFee: NatValue;
306
- };
307
- export type FeeMintAccess = Handle<'feeMintAccess'>;