@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.
- package/README.md +7 -7
- package/bundles/bundle-contractFacet-js-meta.json +628 -314
- package/bundles/bundle-contractFacet.d.ts +3 -3
- package/bundles/bundle-contractFacet.js +1 -1
- package/exported.js +1 -12
- package/package.json +75 -59
- 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/typeGuards.d.ts +8 -0
- package/src/contractFacet/typeGuards.d.ts.map +1 -0
- package/src/contractFacet/typeGuards.js +25 -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 +7 -7
- 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 +102 -48
- 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 +21 -32
- package/src/internal-types.d.ts.map +1 -1
- package/src/internal-types.js +19 -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 +114 -20
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +19 -20
- 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 +82 -37
- 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 +14 -8
- package/src/zoeService/zoe.d.ts.map +1 -1
- package/src/zoeService/zoe.js +39 -11
- 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 +13 -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 +10 -6
- 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 -1171
- 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
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
|
|
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
|
-
/** @
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
244
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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 (
|
|
439
|
+
if (durabilityRequired) {
|
|
400
440
|
allDurable ||
|
|
401
|
-
Fail`values from
|
|
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
|
-
|
|
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
|
-
|
|
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":"
|
|
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 {
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
2
|
-
export function provideEmptySeat(zcf: ZCF, baggage:
|
|
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:
|
|
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,
|
|
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 {
|
|
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/
|
|
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
|
-
|
|
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";
|
|
@@ -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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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<
|
|
18
|
+
quoteIssuer: Issuer<"set", PriceDescription>;
|
|
13
19
|
notifier: ERef<Notifier<unknown>>;
|
|
14
|
-
timer: ERef<import(
|
|
20
|
+
timer: ERef<import("@agoric/time").TimerService>;
|
|
15
21
|
createQuote: PriceQuoteCreate;
|
|
16
|
-
actualBrandIn: Brand<
|
|
17
|
-
actualBrandOut: Brand<
|
|
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":"
|
|
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"}
|