@agoric/zoe 0.26.3-u15.0 → 0.26.3-u16.1
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/README.md +7 -7
- package/bundles/bundle-contractFacet-js-meta.json +620 -311
- package/bundles/bundle-contractFacet.d.ts +3 -3
- package/bundles/bundle-contractFacet.js +1 -1
- package/exported.js +1 -12
- package/package.json +75 -60
- package/src/cleanProposal.d.ts +2 -2
- package/src/cleanProposal.d.ts.map +1 -1
- package/src/cleanProposal.js +15 -12
- package/src/contractFacet/evalContractCode.d.ts.map +1 -1
- package/src/contractFacet/evalContractCode.js +2 -2
- package/src/contractFacet/exit.d.ts.map +1 -1
- package/src/contractFacet/exit.js +1 -0
- package/src/contractFacet/internal-types.d.ts +2 -2
- package/src/contractFacet/internal-types.d.ts.map +1 -1
- package/src/contractFacet/internal-types.js +1 -1
- package/src/contractFacet/offerHandlerStorage.d.ts +4 -1
- package/src/contractFacet/offerHandlerStorage.d.ts.map +1 -1
- package/src/contractFacet/offerHandlerStorage.js +11 -3
- package/src/contractFacet/reallocate.d.ts +3 -0
- package/src/contractFacet/reallocate.d.ts.map +1 -0
- package/src/contractFacet/reallocate.js +94 -0
- package/src/contractFacet/rightsConservation.d.ts.map +1 -1
- package/src/contractFacet/rightsConservation.js +3 -0
- package/src/contractFacet/types-ambient.d.ts +271 -0
- package/src/contractFacet/types-ambient.js +1 -0
- package/src/contractFacet/vatRoot.d.ts +3 -3
- package/src/contractFacet/vatRoot.d.ts.map +1 -1
- package/src/contractFacet/zcfMint.d.ts +4 -2
- package/src/contractFacet/zcfMint.d.ts.map +1 -1
- package/src/contractFacet/zcfMint.js +6 -6
- package/src/contractFacet/zcfSeat.d.ts +4 -2
- package/src/contractFacet/zcfSeat.d.ts.map +1 -1
- package/src/contractFacet/zcfSeat.js +130 -7
- package/src/contractFacet/zcfZygote.d.ts +1 -2
- package/src/contractFacet/zcfZygote.d.ts.map +1 -1
- package/src/contractFacet/zcfZygote.js +92 -43
- package/src/contractSupport/atomicTransfer.d.ts +0 -6
- package/src/contractSupport/atomicTransfer.d.ts.map +1 -1
- package/src/contractSupport/atomicTransfer.js +5 -90
- package/src/contractSupport/bondingCurves.js +2 -2
- package/src/contractSupport/durability.d.ts +3 -3
- package/src/contractSupport/durability.d.ts.map +1 -1
- package/src/contractSupport/durability.js +5 -5
- package/src/contractSupport/index.d.ts +1 -0
- package/src/contractSupport/index.js +1 -0
- package/src/contractSupport/prepare-ownable.d.ts +11 -0
- package/src/contractSupport/prepare-ownable.d.ts.map +1 -0
- package/src/contractSupport/prepare-ownable.js +100 -0
- package/src/contractSupport/priceAuthority.d.ts +23 -15
- package/src/contractSupport/priceAuthority.d.ts.map +1 -1
- package/src/contractSupport/priceAuthority.js +33 -18
- package/src/contractSupport/priceAuthorityInitial.d.ts +3 -2
- package/src/contractSupport/priceAuthorityInitial.d.ts.map +1 -1
- package/src/contractSupport/priceAuthorityInitial.js +6 -3
- package/src/contractSupport/priceAuthorityQuoteMint.d.ts +2 -1
- package/src/contractSupport/priceAuthorityQuoteMint.d.ts.map +1 -1
- package/src/contractSupport/priceAuthorityQuoteMint.js +23 -27
- package/src/contractSupport/priceAuthorityTransform.d.ts +13 -11
- package/src/contractSupport/priceAuthorityTransform.d.ts.map +1 -1
- package/src/contractSupport/priceAuthorityTransform.js +10 -8
- package/src/contractSupport/priceQuote.d.ts +7 -5
- package/src/contractSupport/priceQuote.d.ts.map +1 -1
- package/src/contractSupport/priceQuote.js +5 -1
- package/src/contractSupport/ratio.d.ts +2 -2
- package/src/contractSupport/ratio.d.ts.map +1 -1
- package/src/contractSupport/ratio.js +19 -15
- package/src/contractSupport/recorder.d.ts +33 -119
- package/src/contractSupport/recorder.d.ts.map +1 -1
- package/src/contractSupport/recorder.js +21 -10
- package/src/contractSupport/safeMath.d.ts +7 -7
- package/src/contractSupport/safeMath.d.ts.map +1 -1
- package/src/contractSupport/statistics.d.ts +1 -1
- package/src/contractSupport/statistics.d.ts.map +1 -1
- package/src/contractSupport/topics.d.ts +1 -1
- package/src/contractSupport/topics.d.ts.map +1 -1
- package/src/contractSupport/{types.d.ts → types-ambient.d.ts} +4 -4
- package/src/contractSupport/types-ambient.d.ts.map +1 -0
- package/src/contractSupport/{types.js → types-ambient.js} +1 -1
- package/src/contractSupport/zoeHelpers.d.ts +1 -1
- package/src/contractSupport/zoeHelpers.d.ts.map +1 -1
- package/src/contractSupport/zoeHelpers.js +6 -12
- package/src/contracts/auction/firstPriceLogic.d.ts.map +1 -1
- package/src/contracts/auction/firstPriceLogic.js +5 -8
- package/src/contracts/auction/index.d.ts +10 -10
- package/src/contracts/auction/index.d.ts.map +1 -1
- package/src/contracts/auction/index.js +3 -3
- package/src/contracts/auction/secondPriceLogic.d.ts.map +1 -1
- package/src/contracts/auction/secondPriceLogic.js +1 -4
- package/src/contracts/automaticRefund.d.ts +1 -1
- package/src/contracts/automaticRefund.d.ts.map +1 -1
- package/src/contracts/autoswap.d.ts.map +1 -1
- package/src/contracts/autoswap.js +8 -9
- package/src/contracts/barterExchange.d.ts +1 -1
- package/src/contracts/barterExchange.d.ts.map +1 -1
- package/src/contracts/barterExchange.js +2 -3
- package/src/contracts/callSpread/calculateShares.d.ts +1 -8
- package/src/contracts/callSpread/calculateShares.d.ts.map +1 -1
- package/src/contracts/callSpread/calculateShares.js +1 -1
- package/src/contracts/callSpread/fundedCallSpread.d.ts +4 -0
- package/src/contracts/callSpread/fundedCallSpread.d.ts.map +1 -1
- package/src/contracts/callSpread/fundedCallSpread.js +6 -4
- package/src/contracts/callSpread/payoffHandler.d.ts.map +1 -1
- package/src/contracts/callSpread/payoffHandler.js +3 -2
- package/src/contracts/callSpread/percent.d.ts +2 -4
- package/src/contracts/callSpread/percent.d.ts.map +1 -1
- package/src/contracts/callSpread/position.d.ts +2 -2
- package/src/contracts/callSpread/pricedCallSpread.d.ts +6 -5
- package/src/contracts/callSpread/pricedCallSpread.d.ts.map +1 -1
- package/src/contracts/callSpread/pricedCallSpread.js +9 -5
- package/src/contracts/callSpread/{types.d.ts → types-ambient.d.ts} +3 -3
- package/src/contracts/callSpread/types-ambient.d.ts.map +1 -0
- package/src/contracts/coveredCall-durable.d.ts +2 -4
- package/src/contracts/coveredCall-durable.d.ts.map +1 -1
- package/src/contracts/exported.js +3 -3
- package/src/contracts/loan/borrow.d.ts.map +1 -1
- package/src/contracts/loan/borrow.js +7 -4
- package/src/contracts/loan/close.d.ts.map +1 -1
- package/src/contracts/loan/close.js +3 -7
- package/src/contracts/loan/index.d.ts +5 -1
- package/src/contracts/loan/index.d.ts.map +1 -1
- package/src/contracts/loan/index.js +4 -0
- package/src/contracts/loan/liquidate.d.ts +1 -12
- package/src/contracts/loan/liquidate.d.ts.map +1 -1
- package/src/contracts/loan/liquidate.js +4 -2
- package/src/contracts/loan/scheduleLiquidation.d.ts.map +1 -1
- package/src/contracts/loan/scheduleLiquidation.js +2 -1
- package/src/contracts/loan/{types.d.ts → types-ambient.d.ts} +16 -17
- package/src/contracts/loan/types-ambient.d.ts.map +1 -0
- package/src/contracts/loan/{types.js → types-ambient.js} +11 -18
- package/src/contracts/loan/updateDebt.js +1 -1
- package/src/contracts/mintAndSellNFT.d.ts.map +1 -1
- package/src/contracts/mintPayments.d.ts +14 -6
- package/src/contracts/mintPayments.d.ts.map +1 -1
- package/src/contracts/mintPayments.js +1 -1
- package/src/contracts/oracle.d.ts +6 -2
- package/src/contracts/oracle.d.ts.map +1 -1
- package/src/contracts/oracle.js +10 -3
- package/src/contracts/otcDesk.d.ts +3 -3
- package/src/contracts/otcDesk.d.ts.map +1 -1
- package/src/contracts/otcDesk.js +1 -1
- package/src/contracts/priceAggregator.d.ts +25 -17
- package/src/contracts/priceAggregator.d.ts.map +1 -1
- package/src/contracts/priceAggregator.js +33 -32
- package/src/contracts/priceAggregatorTypes.d.ts +2 -2
- package/src/contracts/priceAggregatorTypes.d.ts.map +1 -1
- package/src/contracts/scaledPriceAuthority.d.ts +3 -4
- package/src/contracts/scaledPriceAuthority.d.ts.map +1 -1
- package/src/contracts/scaledPriceAuthority.js +6 -0
- package/src/contracts/sellItems.d.ts +2 -2
- package/src/contracts/sellItems.d.ts.map +1 -1
- package/src/contracts/sellItems.js +3 -4
- package/src/contracts/simpleExchange.d.ts +3 -3
- package/src/contracts/{types.d.ts → types-ambient.d.ts} +1 -1
- package/src/contracts/types-ambient.d.ts.map +1 -0
- package/src/handleWarning.d.ts.map +1 -1
- package/src/instanceRecordStorage.d.ts +1 -1
- package/src/instanceRecordStorage.d.ts.map +1 -1
- package/src/internal-types.d.ts +20 -32
- package/src/internal-types.d.ts.map +1 -1
- package/src/internal-types.js +18 -58
- package/src/issuerRecord.d.ts +1 -1
- package/src/issuerRecord.d.ts.map +1 -1
- package/src/issuerStorage.d.ts +3 -3
- package/src/issuerStorage.d.ts.map +1 -1
- package/src/issuerStorage.js +12 -28
- package/src/makeHandle.d.ts +2 -2
- package/src/makeHandle.d.ts.map +1 -1
- package/src/makeHandle.js +1 -1
- package/src/typeGuards.d.ts +119 -20
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +18 -9
- package/src/types-ambient.d.ts +41 -0
- package/src/types-ambient.d.ts.map +1 -0
- package/src/{types.js → types-ambient.js} +7 -15
- package/src/zoeService/escrowStorage.d.ts +1 -1
- package/src/zoeService/escrowStorage.d.ts.map +1 -1
- package/src/zoeService/escrowStorage.js +20 -27
- package/src/zoeService/feeMint.d.ts +9 -16
- package/src/zoeService/feeMint.d.ts.map +1 -1
- package/src/zoeService/feeMint.js +21 -15
- package/src/zoeService/installationStorage.d.ts +5 -20
- package/src/zoeService/installationStorage.d.ts.map +1 -1
- package/src/zoeService/installationStorage.js +11 -7
- package/src/zoeService/instanceAdminStorage.d.ts +22 -42
- package/src/zoeService/instanceAdminStorage.d.ts.map +1 -1
- package/src/zoeService/instanceAdminStorage.js +2 -1
- package/src/zoeService/internal-types.d.ts +12 -12
- package/src/zoeService/internal-types.d.ts.map +1 -1
- package/src/zoeService/internal-types.js +6 -6
- package/src/zoeService/invitationQueries.d.ts.map +1 -1
- package/src/zoeService/invitationQueries.js +7 -5
- package/src/zoeService/makeInvitation.d.ts +3 -3
- package/src/zoeService/makeInvitation.d.ts.map +1 -1
- package/src/zoeService/makeInvitation.js +25 -21
- package/src/zoeService/offer/burnInvitation.d.ts.map +1 -1
- package/src/zoeService/offer/offer.d.ts.map +1 -1
- package/src/zoeService/offer/offer.js +2 -5
- package/src/zoeService/originalZoeSeat.d.ts +34 -0
- package/src/zoeService/originalZoeSeat.d.ts.map +1 -0
- package/src/zoeService/originalZoeSeat.js +353 -0
- package/src/zoeService/startInstance.d.ts +3 -3
- package/src/zoeService/startInstance.d.ts.map +1 -1
- package/src/zoeService/startInstance.js +17 -11
- package/src/zoeService/{types.d.ts → types-ambient.d.ts} +23 -28
- package/src/zoeService/types-ambient.d.ts.map +1 -0
- package/src/zoeService/{types.js → types-ambient.js} +19 -32
- package/src/zoeService/utils.d.ts +57 -58
- package/src/zoeService/utils.test-d.d.ts +2 -0
- package/src/zoeService/utils.test-d.d.ts.map +1 -0
- package/src/zoeService/utils.test-d.ts +33 -0
- package/src/zoeService/zoe.d.ts +9 -13
- package/src/zoeService/zoe.d.ts.map +1 -1
- package/src/zoeService/zoe.js +7 -7
- package/src/zoeService/zoeSeat.d.ts +15 -45
- package/src/zoeService/zoeSeat.d.ts.map +1 -1
- package/src/zoeService/zoeSeat.js +215 -115
- package/src/zoeService/zoeStorageManager.d.ts +13 -47
- package/src/zoeService/zoeStorageManager.d.ts.map +1 -1
- package/src/zoeService/zoeStorageManager.js +8 -6
- package/tools/fakePriceAuthority.d.ts +9 -8
- package/tools/fakePriceAuthority.d.ts.map +1 -1
- package/tools/fakePriceAuthority.js +21 -17
- package/tools/fakeVatAdmin.d.ts +10 -10
- package/tools/manualPriceAuthority.d.ts +11 -6
- package/tools/manualPriceAuthority.d.ts.map +1 -1
- package/tools/manualPriceAuthority.js +16 -3
- package/tools/manualTimer.d.ts +17 -40
- package/tools/manualTimer.d.ts.map +1 -1
- package/tools/manualTimer.js +30 -16
- package/tools/prepare-test-env.js +1 -1
- package/tools/scriptedOracle.d.ts +3 -3
- package/tools/scriptedOracle.d.ts.map +1 -1
- package/tools/scriptedOracle.js +1 -1
- package/tools/scriptedPriceAuthority.d.ts +4 -0
- package/tools/scriptedPriceAuthority.d.ts.map +1 -1
- package/tools/scriptedPriceAuthority.js +8 -3
- package/tools/setup-zoe.d.ts +8 -9
- package/tools/setup-zoe.d.ts.map +1 -1
- package/tools/setup-zoe.js +16 -1
- package/tools/test-utils.d.ts +20 -0
- package/tools/test-utils.d.ts.map +1 -0
- package/tools/test-utils.js +26 -0
- package/tools/types.d.ts +21 -21
- package/tools/types.d.ts.map +1 -1
- package/tools/types.js +10 -10
- package/CHANGELOG.md +0 -1227
- package/src/contractFacet/types.d.ts +0 -191
- package/src/contractFacet/types.d.ts.map +0 -1
- package/src/contractFacet/types.js +0 -256
- package/src/contractSupport/types.d.ts.map +0 -1
- package/src/contracts/callSpread/types.d.ts.map +0 -1
- package/src/contracts/loan/types.d.ts.map +0 -1
- package/src/contracts/types.d.ts.map +0 -1
- package/src/objArrayConversion.d.ts +0 -5
- package/src/objArrayConversion.d.ts.map +0 -1
- package/src/objArrayConversion.js +0 -35
- package/src/types.d.ts +0 -45
- package/src/types.d.ts.map +0 -1
- package/src/zoeService/types.d.ts.map +0 -1
- package/tools/internal-types.d.ts +0 -12
- package/tools/internal-types.d.ts.map +0 -1
- package/tools/internal-types.js +0 -14
- package/tools/priceAuthorityRegistry.d.ts +0 -20
- package/tools/priceAuthorityRegistry.d.ts.map +0 -1
- package/tools/priceAuthorityRegistry.js +0 -209
- package/tools/types-ambient.d.ts +0 -142
- package/tools/types-ambient.d.ts.map +0 -1
- package/tools/types-ambient.js +0 -160
- /package/src/contracts/callSpread/{types.js → types-ambient.js} +0 -0
- /package/src/contracts/{types.js → types-ambient.js} +0 -0
|
@@ -0,0 +1,271 @@
|
|
|
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
|
+
SF extends // import inline to maintain ambient mode
|
|
222
|
+
import('../zoeService/utils').ContractStartFunction = import('../zoeService/utils').ContractStartFunction,
|
|
223
|
+
> = {
|
|
224
|
+
customTermsShape?: Record<
|
|
225
|
+
Parameters<SF>[0] extends ZCF<infer CT> ? keyof CT : never,
|
|
226
|
+
Pattern
|
|
227
|
+
>;
|
|
228
|
+
privateArgsShape?: { [K in keyof Parameters<SF>[1]]: Pattern };
|
|
229
|
+
/**
|
|
230
|
+
* - `none` means that the contract is not upgradable.
|
|
231
|
+
* - `canUpgrade` means this code can perform an upgrade
|
|
232
|
+
* - `canBeUpgraded` means that the contract stores kinds durably such that the next version can upgrade
|
|
233
|
+
*/
|
|
234
|
+
upgradability?: 'none' | 'canBeUpgraded' | 'canUpgrade' | undefined;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* API for a contract start function.
|
|
238
|
+
*
|
|
239
|
+
* CAVEAT: assumes synchronous
|
|
240
|
+
*/
|
|
241
|
+
type ContractStartFn<
|
|
242
|
+
PF extends unknown = any,
|
|
243
|
+
CF extends unknown = any,
|
|
244
|
+
CT extends unknown = any,
|
|
245
|
+
PA extends unknown = any,
|
|
246
|
+
> = (
|
|
247
|
+
zcf: ZCF<CT>,
|
|
248
|
+
privateArgs: PA,
|
|
249
|
+
baggage: import('@agoric/vat-data').Baggage,
|
|
250
|
+
) => ContractStartFnResult<PF, CF>;
|
|
251
|
+
type ContractStartFnResult<PF, CF> = {
|
|
252
|
+
publicFacet?: PF;
|
|
253
|
+
creatorFacet?: CF;
|
|
254
|
+
creatorInvitation?: Promise<Invitation<any, any>> | undefined;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// XXX redef, losing documentation
|
|
258
|
+
type ContractOf<S extends (...args: any) => any> =
|
|
259
|
+
import('../zoeService/utils').ContractOf<S>;
|
|
260
|
+
type AdminFacet = import('../zoeService/utils').AdminFacet<any>;
|
|
261
|
+
|
|
262
|
+
declare const OfferReturn: unique symbol;
|
|
263
|
+
declare const OfferArgs: unique symbol;
|
|
264
|
+
type Invitation<R = unknown, A = undefined> = Payment<
|
|
265
|
+
'set',
|
|
266
|
+
InvitationDetails
|
|
267
|
+
> & {
|
|
268
|
+
// because TS is structural, without this the generic is ignored
|
|
269
|
+
[OfferReturn]?: R;
|
|
270
|
+
[OfferArgs]?: A;
|
|
271
|
+
};
|
|
@@ -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:
|
|
6
|
+
export function buildRootObject(powers: VatPowers & {
|
|
7
7
|
testJigSetter: TestJigSetter;
|
|
8
8
|
}, vatParameters: {
|
|
9
9
|
contractBundleCap: BundleCap;
|
|
10
10
|
zoeService: ZoeService;
|
|
11
|
-
invitationIssuer: Issuer<
|
|
11
|
+
invitationIssuer: Issuer<"set">;
|
|
12
12
|
privateArgs?: any;
|
|
13
|
-
}, baggage:
|
|
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;
|
|
1
|
+
{"version":3,"file":"vatRoot.d.ts","sourceRoot":"","sources":["vatRoot.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,wCAJW,SAAS,GAAG;IAAE,aAAa,EAAE,aAAa,CAAA;CAAE,iBAC5C;IAAC,iBAAiB,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAC,WAC1G,OAAO,kBAAkB,EAAE,OAAO,iIA+D5C"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export function sumAmountKeywordRecord
|
|
2
|
-
export function prepareZcMint(zcfBaggage:
|
|
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
7
|
}, reallocator: ZcfMintReallocator): <K extends AssetKind>(keyword: string, zoeMintP: ERef<ZoeMint<K>>) => Promise<ZCFMint<K>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zcfMint.d.ts","sourceRoot":"","sources":["zcfMint.js"],"names":[],"mappings":"AAqBO,
|
|
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,IAiHF,CAAC,SAAZ,SAAU,WACb,MAAM,YACN,IAAI,CAAC,OAAO,CAAC,CAAC,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
|
|
20
|
-
* @returns {Amount
|
|
19
|
+
* @param {IssuerRecord} issuerRecord
|
|
20
|
+
* @returns {Amount}
|
|
21
21
|
*/
|
|
22
22
|
export const sumAmountKeywordRecord = (amr, issuerRecord) => {
|
|
23
23
|
const empty = AmountMath.makeEmpty(
|
|
@@ -106,7 +106,7 @@ export const prepareZcMint = (
|
|
|
106
106
|
// committed atomically, but it is not a disaster if they are
|
|
107
107
|
// not. If we minted only, no one would ever get those
|
|
108
108
|
// invisibly-minted assets.
|
|
109
|
-
E(zoeMint).mintAndEscrow(totalToMint);
|
|
109
|
+
void E(zoeMint).mintAndEscrow(totalToMint);
|
|
110
110
|
reallocator.reallocate(zcfSeat, allocationPlusGains);
|
|
111
111
|
return zcfSeat;
|
|
112
112
|
},
|
|
@@ -143,7 +143,7 @@ export const prepareZcMint = (
|
|
|
143
143
|
// not. If we only commit the allocationMinusLosses no one would
|
|
144
144
|
// ever get the unburned assets.
|
|
145
145
|
reallocator.reallocate(zcfSeat, allocationMinusLosses);
|
|
146
|
-
E(zoeMint).withdrawAndBurn(totalToBurn);
|
|
146
|
+
void E(zoeMint).withdrawAndBurn(totalToBurn);
|
|
147
147
|
},
|
|
148
148
|
},
|
|
149
149
|
);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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":"
|
|
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,CAsenF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/* eslint @typescript-eslint/no-floating-promises: "warn" */
|
|
1
2
|
import {
|
|
2
3
|
makeScalarBigWeakMapStore,
|
|
3
|
-
|
|
4
|
-
provideDurableWeakMapStore,
|
|
4
|
+
prepareExoClass,
|
|
5
5
|
prepareExoClassKit,
|
|
6
6
|
provide,
|
|
7
|
-
|
|
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
|
-
/**
|
|
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,
|
|
@@ -155,7 +167,11 @@ export const createSeatManager = (
|
|
|
155
167
|
assertActive(self);
|
|
156
168
|
assertNoStagedAllocation(self);
|
|
157
169
|
doExitSeat(self);
|
|
158
|
-
E(zoeInstanceAdmin).exitSeat(
|
|
170
|
+
void E(zoeInstanceAdmin).exitSeat(
|
|
171
|
+
zcfSeatToSeatHandle.get(self),
|
|
172
|
+
completion,
|
|
173
|
+
);
|
|
174
|
+
zcfSeatToSeatHandle.delete(self);
|
|
159
175
|
},
|
|
160
176
|
fail(
|
|
161
177
|
reason = Error(
|
|
@@ -172,10 +188,11 @@ export const createSeatManager = (
|
|
|
172
188
|
}
|
|
173
189
|
if (!hasExited(self)) {
|
|
174
190
|
doExitSeat(self);
|
|
175
|
-
E(zoeInstanceAdmin).failSeat(
|
|
191
|
+
void E(zoeInstanceAdmin).failSeat(
|
|
176
192
|
zcfSeatToSeatHandle.get(self),
|
|
177
193
|
harden(reason),
|
|
178
194
|
);
|
|
195
|
+
zcfSeatToSeatHandle.delete(self);
|
|
179
196
|
}
|
|
180
197
|
return reason;
|
|
181
198
|
},
|
|
@@ -184,15 +201,22 @@ export const createSeatManager = (
|
|
|
184
201
|
return hasExited(self);
|
|
185
202
|
},
|
|
186
203
|
|
|
204
|
+
/**
|
|
205
|
+
* @type {ZCFSeat['getAmountAllocated']}
|
|
206
|
+
*/
|
|
187
207
|
getAmountAllocated(keyword, brand) {
|
|
188
208
|
const { self } = this;
|
|
189
209
|
assertActive(self);
|
|
190
210
|
const currentAllocation = getCurrentAllocation(self);
|
|
191
211
|
if (currentAllocation[keyword] !== undefined) {
|
|
212
|
+
// @ts-expect-error never checks brand
|
|
192
213
|
return currentAllocation[keyword];
|
|
193
214
|
}
|
|
194
|
-
|
|
215
|
+
if (!brand) {
|
|
216
|
+
throw Fail`A brand must be supplied when the keyword is not defined`;
|
|
217
|
+
}
|
|
195
218
|
const assetKind = getAssetKindByBrand(brand);
|
|
219
|
+
// @ts-expect-error cast
|
|
196
220
|
return AmountMath.makeEmpty(brand, assetKind);
|
|
197
221
|
},
|
|
198
222
|
getCurrentAllocation() {
|
|
@@ -214,6 +238,10 @@ export const createSeatManager = (
|
|
|
214
238
|
|
|
215
239
|
return isOfferSafe(state.proposal, reallocation);
|
|
216
240
|
},
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated switch to zcf.atomicRearrange()
|
|
243
|
+
* @param {AmountKeywordRecord} amountKeywordRecord
|
|
244
|
+
*/
|
|
217
245
|
incrementBy(amountKeywordRecord) {
|
|
218
246
|
const { self } = this;
|
|
219
247
|
assertActive(self);
|
|
@@ -227,6 +255,10 @@ export const createSeatManager = (
|
|
|
227
255
|
);
|
|
228
256
|
return amountKeywordRecord;
|
|
229
257
|
},
|
|
258
|
+
/**
|
|
259
|
+
* @deprecated switch to zcf.atomicRearrange()
|
|
260
|
+
* @param {AmountKeywordRecord} amountKeywordRecord
|
|
261
|
+
*/
|
|
230
262
|
decrementBy(amountKeywordRecord) {
|
|
231
263
|
const { self } = this;
|
|
232
264
|
assertActive(self);
|
|
@@ -265,6 +297,7 @@ export const createSeatManager = (
|
|
|
265
297
|
const ZcfSeatManagerIKit = harden({
|
|
266
298
|
seatManager: M.interface('ZcfSeatManager', {
|
|
267
299
|
makeZCFSeat: M.call(SeatDataShape).returns(M.remotable('zcfSeat')),
|
|
300
|
+
atomicRearrange: M.call(M.arrayOf(TransferPartShape)).returns(),
|
|
268
301
|
reallocate: M.call(M.remotable('zcfSeat'), M.remotable('zcfSeat'))
|
|
269
302
|
.rest(M.arrayOf(M.remotable('zcfSeat')))
|
|
270
303
|
.returns(),
|
|
@@ -289,6 +322,96 @@ export const createSeatManager = (
|
|
|
289
322
|
return zcfSeat;
|
|
290
323
|
},
|
|
291
324
|
|
|
325
|
+
/**
|
|
326
|
+
* Rearrange the allocations according to the transfer descriptions.
|
|
327
|
+
* This is a set of changes to allocations that must satisfy several
|
|
328
|
+
* constraints. If these constraints are all met, then the reallocation
|
|
329
|
+
* happens atomically. Otherwise, it does not happen at all.
|
|
330
|
+
*
|
|
331
|
+
* The conditions
|
|
332
|
+
* * All the mentioned seats are still live,
|
|
333
|
+
* * No outstanding stagings for any of the mentioned seats. Stagings
|
|
334
|
+
* have been deprecated in favor or atomicRearrange. To prevent
|
|
335
|
+
* confusion, for each reallocation, it can only be expressed in
|
|
336
|
+
* the old way or the new way, but not a mixture.
|
|
337
|
+
* * Offer safety
|
|
338
|
+
* * Overall conservation
|
|
339
|
+
*
|
|
340
|
+
* The overall transfer is expressed as an array of `TransferPart`. Each
|
|
341
|
+
* individual `TransferPart` is one of
|
|
342
|
+
* - A transfer from a `fromSeat` to a `toSeat`. Specify both toAmount
|
|
343
|
+
* and fromAmount to change keywords, otherwise only fromAmount is required.
|
|
344
|
+
* - A taking from a `fromSeat`'s allocation. See the `fromOnly` helper.
|
|
345
|
+
* - A giving into a `toSeat`'s allocation. See the `toOnly` helper.
|
|
346
|
+
*
|
|
347
|
+
* @param {TransferPart[]} transfers
|
|
348
|
+
*/
|
|
349
|
+
atomicRearrange(transfers) {
|
|
350
|
+
const newAllocations = makeAllocationMap(transfers);
|
|
351
|
+
|
|
352
|
+
// ////// All Seats are active /////////////////////////////////
|
|
353
|
+
for (const [seat] of newAllocations) {
|
|
354
|
+
assertActive(seat);
|
|
355
|
+
!seat.hasStagedAllocation() ||
|
|
356
|
+
Fail`Cannot mix atomicRearrange with seat stagings: ${seat}`;
|
|
357
|
+
zcfSeatToSeatHandle.has(seat) ||
|
|
358
|
+
Fail`The seat ${seat} was not recognized`;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// ////// Ensure that rights are conserved overall /////////////
|
|
362
|
+
|
|
363
|
+
// convert array of keywordAmountRecords to 1-level array of Amounts
|
|
364
|
+
const flattenAmounts = allocations =>
|
|
365
|
+
allocations.flatMap(Object.values);
|
|
366
|
+
const previousAmounts = flattenAmounts(
|
|
367
|
+
newAllocations.map(([seat]) => seat.getCurrentAllocation()),
|
|
368
|
+
);
|
|
369
|
+
const newAmounts = flattenAmounts(
|
|
370
|
+
newAllocations.map(([_, allocation]) => allocation),
|
|
371
|
+
);
|
|
372
|
+
assertRightsConserved(previousAmounts, newAmounts);
|
|
373
|
+
|
|
374
|
+
// ////// Ensure that offer safety holds ///////////////////////
|
|
375
|
+
for (const [seat, allocation] of newAllocations) {
|
|
376
|
+
isOfferSafe(seat.getProposal(), allocation) ||
|
|
377
|
+
Fail`Offer safety was violated by the proposed allocation: ${allocation}. Proposal was ${seat.getProposal()}`;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const seatHandleAllocations = newAllocations.map(
|
|
381
|
+
([seat, allocation]) => {
|
|
382
|
+
const seatHandle = zcfSeatToSeatHandle.get(seat);
|
|
383
|
+
return { allocation, seatHandle };
|
|
384
|
+
},
|
|
385
|
+
);
|
|
386
|
+
try {
|
|
387
|
+
// No side effects above. All conditions checked which could have
|
|
388
|
+
// caused us to reject this reallocation. Notice that the current
|
|
389
|
+
// allocations are captured in seatHandleAllocations, so there must
|
|
390
|
+
// be no awaits between that assignment and here.
|
|
391
|
+
//
|
|
392
|
+
// COMMIT POINT
|
|
393
|
+
//
|
|
394
|
+
// The effects must succeed atomically. The call to
|
|
395
|
+
// replaceAllocations() will be processed in the order of updates
|
|
396
|
+
// from ZCF to Zoe. Its effects must occur immediately in Zoe on
|
|
397
|
+
// reception, and must not fail.
|
|
398
|
+
//
|
|
399
|
+
// Commit the new allocations (currentAllocation is replaced
|
|
400
|
+
// for each of the seats) and inform Zoe of the new allocation.
|
|
401
|
+
|
|
402
|
+
for (const [seat, allocation] of newAllocations) {
|
|
403
|
+
activeZCFSeats.set(seat, allocation);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// we don't wait for the results here. As described in
|
|
407
|
+
// docs/zoe-zcf.md, The initial allocation to a seat originates with
|
|
408
|
+
// Zoe, but *all subsequent updates come from ZCF to Zoe*.
|
|
409
|
+
void E(zoeInstanceAdmin).replaceAllocations(seatHandleAllocations);
|
|
410
|
+
} catch (err) {
|
|
411
|
+
shutdownWithFailure(err);
|
|
412
|
+
throw err;
|
|
413
|
+
}
|
|
414
|
+
},
|
|
292
415
|
reallocate(/** @type {ZCFSeat[]} */ ...seats) {
|
|
293
416
|
seats.forEach(assertActive);
|
|
294
417
|
seats.forEach(assertStagedAllocation);
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export function makeZCFZygote(powers: VatPowers, zoeService: ERef<ZoeService>, invitationIssuer: Issuer<
|
|
2
|
-
export type IssuerOptionsRecord = import('@agoric/ertp').IssuerOptionsRecord;
|
|
1
|
+
export function makeZCFZygote(powers: VatPowers, zoeService: ERef<ZoeService>, invitationIssuer: Issuer<"set">, testJigSetter: TestJigSetter, contractBundleCap: BundleCap, 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,
|
|
1
|
+
{"version":3,"file":"zcfZygote.d.ts","sourceRoot":"","sources":["zcfZygote.js"],"names":[],"mappings":"AAiDO,sCARI,SAAS,cACT,IAAI,CAAC,UAAU,CAAC,oBAChB,MAAM,CAAC,KAAK,CAAC,iBACb,aAAa,qBACb,SAAS,eACT,OAAO,kBAAkB,EAAE,OAAO,GAChC,OAAO,CAAC,SAAS,CAAC,CAkd9B"}
|