@agoric/zoe 0.26.3-dev-7e4a2e1.0 → 0.26.3-dev-b13743a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/bundle-contractFacet-js-meta.json +87 -87
- package/bundles/bundle-contractFacet.js +1 -1
- package/package.json +15 -15
- package/src/contractFacet/types-ambient.d.ts +27 -22
- package/src/contractFacet/zcfSeat.js +8 -1
- package/src/contractFacet/zcfZygote.js +2 -1
- package/src/contractSupport/prepare-ownable.js +2 -2
- package/src/contractSupport/zoeHelpers.js +1 -2
- package/src/contracts/auction/firstPriceLogic.js +0 -1
- package/src/contracts/auction/secondPriceLogic.js +0 -1
- package/src/contracts/loan/borrow.js +4 -1
- package/src/types.js +0 -6
- package/src/zoeService/types.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/zoe",
|
|
3
|
-
"version": "0.26.3-dev-
|
|
3
|
+
"version": "0.26.3-dev-b13743a.0+b13743a",
|
|
4
4
|
"description": "Zoe: the Smart Contract Framework for Offer Enforcement",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/zoeService/zoe.js",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@agoric/assert": "0.6.1-dev-
|
|
47
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
48
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
49
|
-
"@agoric/internal": "0.3.3-dev-
|
|
50
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
51
|
-
"@agoric/store": "0.9.3-dev-
|
|
52
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
53
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
54
|
-
"@agoric/time": "0.3.3-dev-
|
|
55
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
56
|
-
"@agoric/zone": "0.2.3-dev-
|
|
46
|
+
"@agoric/assert": "0.6.1-dev-b13743a.0+b13743a",
|
|
47
|
+
"@agoric/base-zone": "0.1.1-dev-b13743a.0+b13743a",
|
|
48
|
+
"@agoric/ertp": "0.16.3-dev-b13743a.0+b13743a",
|
|
49
|
+
"@agoric/internal": "0.3.3-dev-b13743a.0+b13743a",
|
|
50
|
+
"@agoric/notifier": "0.6.3-dev-b13743a.0+b13743a",
|
|
51
|
+
"@agoric/store": "0.9.3-dev-b13743a.0+b13743a",
|
|
52
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-b13743a.0+b13743a",
|
|
53
|
+
"@agoric/swingset-vat": "0.32.3-dev-b13743a.0+b13743a",
|
|
54
|
+
"@agoric/time": "0.3.3-dev-b13743a.0+b13743a",
|
|
55
|
+
"@agoric/vat-data": "0.5.3-dev-b13743a.0+b13743a",
|
|
56
|
+
"@agoric/zone": "0.2.3-dev-b13743a.0+b13743a",
|
|
57
57
|
"@endo/bundle-source": "^3.1.0",
|
|
58
58
|
"@endo/captp": "^4.0.4",
|
|
59
59
|
"@endo/common": "^1.1.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"yargs-parser": "^21.1.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@agoric/kmarshal": "0.1.1-dev-
|
|
71
|
+
"@agoric/kmarshal": "0.1.1-dev-b13743a.0+b13743a",
|
|
72
72
|
"@endo/init": "^1.0.4",
|
|
73
73
|
"ava": "^5.3.0",
|
|
74
74
|
"c8": "^9.1.0",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"access": "public"
|
|
140
140
|
},
|
|
141
141
|
"typeCoverage": {
|
|
142
|
-
"atLeast": 84.
|
|
142
|
+
"atLeast": 84.88
|
|
143
143
|
},
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "b13743a2cccf0cb63a412b54384435596d4e81ea"
|
|
145
145
|
}
|
|
@@ -6,13 +6,6 @@ type IssuerOptionsRecord = import('@agoric/ertp').IssuerOptionsRecord;
|
|
|
6
6
|
type Completion = any;
|
|
7
7
|
type ZCFMakeEmptySeatKit = (exit?: ExitRule | undefined) => ZcfSeatKit;
|
|
8
8
|
|
|
9
|
-
type MakeInvitation = <Result>(
|
|
10
|
-
offerHandler: OfferHandler<Result>,
|
|
11
|
-
description: string,
|
|
12
|
-
customDetails?: object,
|
|
13
|
-
proposalShape?: Pattern,
|
|
14
|
-
) => Promise<Invitation<R, A>>;
|
|
15
|
-
|
|
16
9
|
/**
|
|
17
10
|
* Zoe Contract Facet
|
|
18
11
|
*
|
|
@@ -60,7 +53,12 @@ type ZCF<CT extends unknown = Record<string, unknown>> = {
|
|
|
60
53
|
* getting in the `customDetails`. `customDetails` will be
|
|
61
54
|
* placed in the details of the invitation.
|
|
62
55
|
*/
|
|
63
|
-
makeInvitation:
|
|
56
|
+
makeInvitation: <R, A = undefined>(
|
|
57
|
+
offerHandler: OfferHandler<ERef<R>, A>,
|
|
58
|
+
description: string,
|
|
59
|
+
customDetails?: object,
|
|
60
|
+
proposalShape?: Pattern,
|
|
61
|
+
) => Promise<Invitation<R, A>>;
|
|
64
62
|
shutdown: (completion: Completion) => void;
|
|
65
63
|
shutdownWithFailure: ShutdownWithFailure;
|
|
66
64
|
getZoeService: () => ERef<ZoeService>;
|
|
@@ -164,21 +162,20 @@ type ZCFMint<K extends AssetKind = AssetKind> = {
|
|
|
164
162
|
* normally an instanceof Error.
|
|
165
163
|
*/
|
|
166
164
|
type ZCFSeatFail = (reason: unknown) => Error;
|
|
167
|
-
/**
|
|
168
|
-
* The brand is used for filling in an empty amount if the `keyword`
|
|
169
|
-
* is not present in the allocation
|
|
170
|
-
*/
|
|
171
|
-
type ZCFGetAmountAllocated = (
|
|
172
|
-
keyword: Keyword,
|
|
173
|
-
brand?: Brand<AssetKind> | undefined,
|
|
174
|
-
) => Amount<any>;
|
|
175
165
|
type ZCFSeat = {
|
|
176
166
|
exit: (completion?: Completion) => void;
|
|
177
167
|
fail: ZCFSeatFail;
|
|
178
168
|
getSubscriber: () => Promise<Subscriber<Allocation>>;
|
|
179
169
|
hasExited: () => boolean;
|
|
180
170
|
getProposal: () => ProposalRecord;
|
|
181
|
-
|
|
171
|
+
/**
|
|
172
|
+
* @param brand used for filling in an empty amount if the `keyword`
|
|
173
|
+
* is not present in the allocation
|
|
174
|
+
*/
|
|
175
|
+
getAmountAllocated: <B extends Brand>(
|
|
176
|
+
keyword: Keyword,
|
|
177
|
+
brand?: B,
|
|
178
|
+
) => B extends Brand<infer K> ? Amount<K> : Amount;
|
|
182
179
|
getCurrentAllocation: () => Allocation;
|
|
183
180
|
/**
|
|
184
181
|
* @deprecated Use atomicRearrange instead
|
|
@@ -210,14 +207,14 @@ type ZcfSeatKit = {
|
|
|
210
207
|
zcfSeat: ZCFSeat;
|
|
211
208
|
userSeat: ERef<UserSeat>;
|
|
212
209
|
};
|
|
213
|
-
type HandleOffer<OR extends unknown> = (
|
|
210
|
+
type HandleOffer<OR extends unknown, OA> = (
|
|
214
211
|
seat: ZCFSeat,
|
|
215
|
-
offerArgs?:
|
|
212
|
+
offerArgs?: OA,
|
|
216
213
|
) => OR;
|
|
217
|
-
type OfferHandler<OR extends unknown = unknown> =
|
|
218
|
-
| HandleOffer<OR>
|
|
214
|
+
type OfferHandler<OR extends unknown = unknown, OA = never> =
|
|
215
|
+
| HandleOffer<OR, OA>
|
|
219
216
|
| {
|
|
220
|
-
handle: HandleOffer<OR>;
|
|
217
|
+
handle: HandleOffer<OR, OA>;
|
|
221
218
|
};
|
|
222
219
|
type ContractMeta = {
|
|
223
220
|
customTermsShape?: CopyRecord<any> | undefined;
|
|
@@ -246,3 +243,11 @@ type ContractStartFnResult<PF, CF> = {
|
|
|
246
243
|
};
|
|
247
244
|
type ContractOf<S> = import('../zoeService/utils').ContractOf<S>;
|
|
248
245
|
type AdminFacet = import('../zoeService/utils').AdminFacet<any>;
|
|
246
|
+
|
|
247
|
+
declare const OfferReturn: unique symbol;
|
|
248
|
+
declare const OfferArgs: unique symbol;
|
|
249
|
+
type Invitation<R = unknown, A = undefined> = Payment<'set'> & {
|
|
250
|
+
// because TS is structural, without this the generic is ignored
|
|
251
|
+
[OfferReturn]?: R;
|
|
252
|
+
[OfferArgs]?: A;
|
|
253
|
+
};
|
|
@@ -189,15 +189,22 @@ export const createSeatManager = (
|
|
|
189
189
|
return hasExited(self);
|
|
190
190
|
},
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @type {ZCFSeat['getAmountAllocated']}
|
|
194
|
+
*/
|
|
192
195
|
getAmountAllocated(keyword, brand) {
|
|
193
196
|
const { self } = this;
|
|
194
197
|
assertActive(self);
|
|
195
198
|
const currentAllocation = getCurrentAllocation(self);
|
|
196
199
|
if (currentAllocation[keyword] !== undefined) {
|
|
200
|
+
// @ts-expect-error cast
|
|
197
201
|
return currentAllocation[keyword];
|
|
198
202
|
}
|
|
199
|
-
|
|
203
|
+
if (!brand) {
|
|
204
|
+
throw Fail`A brand must be supplied when the keyword is not defined`;
|
|
205
|
+
}
|
|
200
206
|
const assetKind = getAssetKindByBrand(brand);
|
|
207
|
+
// @ts-expect-error cast
|
|
201
208
|
return AmountMath.makeEmpty(brand, assetKind);
|
|
202
209
|
},
|
|
203
210
|
getCurrentAllocation() {
|
|
@@ -321,7 +321,8 @@ export const makeZCFZygote = async (
|
|
|
321
321
|
customDetails,
|
|
322
322
|
proposalShape,
|
|
323
323
|
);
|
|
324
|
-
|
|
324
|
+
// rely on the ZCF type signature
|
|
325
|
+
return /** @type {any} */ (invitationP);
|
|
325
326
|
},
|
|
326
327
|
// Shutdown the entire vat and give payouts
|
|
327
328
|
shutdown: completion => {
|
|
@@ -20,7 +20,7 @@ const TransferProposalShape = M.splitRecord({
|
|
|
20
20
|
/**
|
|
21
21
|
* @template {(string | symbol)[]} MN Method names
|
|
22
22
|
* @param {import('@agoric/base-zone').Zone} zone
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {ZCF['makeInvitation']} makeInvitation
|
|
24
24
|
* A function with the same behavior as `zcf.makeInvitation`.
|
|
25
25
|
* A contract will normally just extract it from its own zcf using the
|
|
26
26
|
* argument expression
|
|
@@ -34,7 +34,7 @@ const TransferProposalShape = M.splitRecord({
|
|
|
34
34
|
* The method names of the underlying exo class that should be represented
|
|
35
35
|
* by transparently-forwarding methods of the wrapping ownable object.
|
|
36
36
|
* @param {OwnableOptions} [options]
|
|
37
|
-
* @returns {<U>(underlying: U) => Pick<U, MN[number]> & {makeTransferInvitation: () => Invitation}}
|
|
37
|
+
* @returns {<U>(underlying: U) => Pick<U, MN[number]> & {makeTransferInvitation: () => Invitation<U>}}
|
|
38
38
|
*/
|
|
39
39
|
export const prepareOwnable = (
|
|
40
40
|
zone,
|
|
@@ -176,12 +176,11 @@ export const depositToSeatSuccessMsg = `Deposit and reallocation successful.`;
|
|
|
176
176
|
* The `amounts` and `payments` records must have corresponding
|
|
177
177
|
* keywords.
|
|
178
178
|
*
|
|
179
|
-
* @template {object} [OR=unknown]
|
|
180
179
|
* @param {ZCF} zcf
|
|
181
180
|
* @param {ZCFSeat} recipientSeat
|
|
182
181
|
* @param {AmountKeywordRecord} amounts
|
|
183
182
|
* @param {PaymentPKeywordRecord} payments
|
|
184
|
-
* @returns {Promise<
|
|
183
|
+
* @returns {Promise<string>} `Deposit and reallocation successful.`
|
|
185
184
|
*/
|
|
186
185
|
export const depositToSeat = async (zcf, recipientSeat, amounts, payments) => {
|
|
187
186
|
!recipientSeat.hasExited() || Fail`The recipientSeat cannot have exited.`;
|
|
@@ -22,7 +22,6 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
|
|
|
22
22
|
for (const bidSeat of bidSeats) {
|
|
23
23
|
if (!bidSeat.hasExited()) {
|
|
24
24
|
activeBidsCount += 1n;
|
|
25
|
-
/** @type {Amount<'nat'>} */
|
|
26
25
|
const bid = bidSeat.getAmountAllocated('Bid', bidBrand);
|
|
27
26
|
// bidSeat is added in time order, in case of a tie, we privilege the earlier.
|
|
28
27
|
// So the later bidder will need a strictly greater bid to win the auction.
|
|
@@ -23,7 +23,6 @@ export const calcWinnerAndClose = (zcf, sellSeat, bidSeats) => {
|
|
|
23
23
|
bidSeats.forEach(bidSeat => {
|
|
24
24
|
if (!bidSeat.hasExited()) {
|
|
25
25
|
activeBidsCount += 1n;
|
|
26
|
-
/** @type {Amount<'nat'>} */
|
|
27
26
|
const bid = bidSeat.getAmountAllocated('Bid', bidBrand);
|
|
28
27
|
// If the bid is greater than the highestBid, it's the new highestBid
|
|
29
28
|
if (AmountMath.isGTE(bid, highestBid, bidBrand)) {
|
|
@@ -37,7 +37,10 @@ export const makeBorrowInvitation = (zcf, config) => {
|
|
|
37
37
|
want: { Loan: null },
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
const collateralGiven = borrowerSeat.getAmountAllocated(
|
|
40
|
+
const collateralGiven = borrowerSeat.getAmountAllocated(
|
|
41
|
+
'Collateral',
|
|
42
|
+
borrowerSeat.getProposal().give.Collateral.brand,
|
|
43
|
+
);
|
|
41
44
|
const loanWanted = borrowerSeat.getProposal().want.Loan;
|
|
42
45
|
const loanBrand = zcf.getTerms().brands.Loan;
|
|
43
46
|
|
package/src/types.js
CHANGED
package/src/zoeService/types.js
CHANGED
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* @callback GetInvitationDetails
|
|
111
|
-
* @param {ERef<Invitation
|
|
111
|
+
* @param {ERef<Invitation<any, any>>} invitation
|
|
112
112
|
* @returns {Promise<InvitationDetails>}
|
|
113
113
|
*/
|
|
114
114
|
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
*/
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
|
-
* @typedef {<
|
|
151
|
+
* @typedef {<Result, Args = undefined>(
|
|
152
152
|
* invitation: ERef<Invitation<Result, Args>>,
|
|
153
153
|
* proposal?: Proposal,
|
|
154
154
|
* paymentKeywordRecord?: PaymentPKeywordRecord,
|