@agoric/zoe 0.26.3-upgrade-14-dev-c8f9e7b.0 → 0.26.3-upgrade-16-fi-dev-8879538.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 +622 -313
- 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/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 +259 -0
- package/src/contractFacet/types-ambient.js +1 -0
- package/src/contractFacet/vatRoot.d.ts +4 -4
- package/src/contractFacet/vatRoot.d.ts.map +1 -1
- package/src/contractFacet/zcfMint.d.ts +5 -3
- package/src/contractFacet/zcfMint.d.ts.map +1 -1
- package/src/contractFacet/zcfMint.js +4 -4
- package/src/contractFacet/zcfSeat.d.ts +4 -2
- package/src/contractFacet/zcfSeat.d.ts.map +1 -1
- package/src/contractFacet/zcfSeat.js +125 -5
- package/src/contractFacet/zcfZygote.d.ts +1 -2
- package/src/contractFacet/zcfZygote.d.ts.map +1 -1
- package/src/contractFacet/zcfZygote.js +95 -42
- 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 +32 -17
- package/src/contractSupport/priceAuthorityInitial.d.ts +3 -2
- package/src/contractSupport/priceAuthorityInitial.d.ts.map +1 -1
- package/src/contractSupport/priceAuthorityInitial.js +5 -2
- 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 +14 -12
- 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 +31 -117
- 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 +5 -11
- 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 +2 -1
- 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 +2 -1
- 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 +8 -4
- 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 +1 -0
- 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 +25 -3
- package/src/contracts/oracle.d.ts.map +1 -1
- package/src/contracts/oracle.js +7 -0
- 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 +112 -18
- package/src/contracts/priceAggregator.d.ts.map +1 -1
- package/src/contracts/priceAggregator.js +16 -18
- package/src/contracts/priceAggregatorTypes.d.ts +2 -2
- package/src/contracts/priceAggregatorTypes.d.ts.map +1 -1
- package/src/contracts/scaledPriceAuthority.d.ts +4 -5
- 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 +2 -3
- 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 +2 -2
- package/src/issuerRecord.d.ts.map +1 -1
- package/src/issuerStorage.d.ts +4 -4
- 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} +6 -14
- 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 +1 -0
- package/src/zoeService/internal-types.d.ts +16 -16
- 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} +26 -31
- 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 +54 -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 +214 -114
- package/src/zoeService/zoeStorageManager.d.ts +9 -43
- 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 +15 -2
- package/tools/manualTimer.d.ts +21 -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 +6 -1
- 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 -1203
- 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,36 @@
|
|
|
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, Remotable } from '@endo/marshal';
|
|
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';
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
/// <reference path="../internal-types.js" />
|
|
31
|
+
/// <reference path="./internal-types.js" />
|
|
32
|
+
|
|
33
|
+
/** @import {IssuerOptionsRecord} from '@agoric/ertp' */
|
|
34
34
|
|
|
35
35
|
const { Fail } = assert;
|
|
36
36
|
|
|
@@ -76,7 +76,7 @@ export const makeZCFZygote = async (
|
|
|
76
76
|
instantiate: instantiateIssuerStorage,
|
|
77
77
|
} = provideIssuerStorage(zcfBaggage);
|
|
78
78
|
|
|
79
|
-
/** @type {ShutdownWithFailure} */
|
|
79
|
+
/** @type {import('@agoric/swingset-vat').ShutdownWithFailure} */
|
|
80
80
|
const shutdownWithFailure = reason => {
|
|
81
81
|
E(zoeInstanceAdmin).failAllSeats(reason);
|
|
82
82
|
seatManager.dropAllReferences();
|
|
@@ -210,6 +210,25 @@ export const makeZCFZygote = async (
|
|
|
210
210
|
});
|
|
211
211
|
const handleOfferObj = makeHandleOfferObj(taker);
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* @type {() => Promise<
|
|
215
|
+
* | {
|
|
216
|
+
* buildRootObject: any;
|
|
217
|
+
* start: undefined;
|
|
218
|
+
* meta: undefined;
|
|
219
|
+
* }
|
|
220
|
+
* | {
|
|
221
|
+
* prepare: ContractStartFn;
|
|
222
|
+
* customTermsShape?: Pick<ContractMeta, 'customTermsShape'>,
|
|
223
|
+
* privateArgsShape?: Pick<ContractMeta, 'privateArgsShape'>,
|
|
224
|
+
* }
|
|
225
|
+
* | {
|
|
226
|
+
* buildRootObject: undefined;
|
|
227
|
+
* start: ContractStartFn;
|
|
228
|
+
* meta?: ContractMeta;
|
|
229
|
+
* }
|
|
230
|
+
* >}
|
|
231
|
+
*/
|
|
213
232
|
const evaluateContract = () => {
|
|
214
233
|
let bundle;
|
|
215
234
|
if (passStyleOf(contractBundleCap) === 'remotable') {
|
|
@@ -222,22 +241,44 @@ export const makeZCFZygote = async (
|
|
|
222
241
|
return evalContractBundle(bundle);
|
|
223
242
|
};
|
|
224
243
|
// evaluate the contract (either the first version, or an upgrade)
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
244
|
+
const bundleResult = await evaluateContract();
|
|
245
|
+
|
|
246
|
+
//#region backwards compatibility with prepare()
|
|
247
|
+
const { start, meta = {} } = (() => {
|
|
248
|
+
if ('prepare' in bundleResult) {
|
|
249
|
+
if ('start' in bundleResult) {
|
|
250
|
+
Fail`contract must provide exactly one of "start" and "prepare"`;
|
|
251
|
+
}
|
|
252
|
+
// A contract must have one expression of upgradability
|
|
253
|
+
if (/** @type {any} */ (bundleResult).meta?.upgradability) {
|
|
254
|
+
Fail`prepare() is deprecated and incompatible with the 'upgradability' indicator`;
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
start: bundleResult.prepare,
|
|
258
|
+
meta: {
|
|
259
|
+
upgradability: 'canUpgrade',
|
|
260
|
+
customTermsShape: bundleResult.customTermsShape,
|
|
261
|
+
privateArgsShape: bundleResult.privateArgsShape,
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
// normal behavior
|
|
266
|
+
return bundleResult;
|
|
267
|
+
})();
|
|
268
|
+
//#endregion
|
|
269
|
+
|
|
270
|
+
if (start === undefined) {
|
|
271
|
+
if ('buildRootObject' in bundleResult) {
|
|
272
|
+
// diagnose a common mistake
|
|
273
|
+
throw Fail`Did you provide a vat bundle instead of a contract bundle?`;
|
|
274
|
+
}
|
|
275
|
+
throw Fail`contract exports missing start`;
|
|
237
276
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
277
|
+
|
|
278
|
+
start.length <= 3 || Fail`invalid start parameters`;
|
|
279
|
+
const durabilityRequired =
|
|
280
|
+
meta.upgradability &&
|
|
281
|
+
['canBeUpgraded', 'canUpgrade'].includes(meta.upgradability);
|
|
241
282
|
|
|
242
283
|
/** @type {ZCF} */
|
|
243
284
|
// Using Remotable rather than Far because there are too many complications
|
|
@@ -245,6 +286,7 @@ export const makeZCFZygote = async (
|
|
|
245
286
|
// accept raw functions. assert cannot be a valid passable! (It's a function
|
|
246
287
|
// and has members.)
|
|
247
288
|
const zcf = Remotable('Alleged: zcf', undefined, {
|
|
289
|
+
atomicRearrange: transfers => seatManager.atomicRearrange(transfers),
|
|
248
290
|
reallocate: (...seats) => seatManager.reallocate(...seats),
|
|
249
291
|
assertUniqueKeyword: kwd => getInstanceRecHolder().assertUniqueKeyword(kwd),
|
|
250
292
|
saveIssuer: async (issuerP, keyword) => {
|
|
@@ -279,7 +321,8 @@ export const makeZCFZygote = async (
|
|
|
279
321
|
customDetails,
|
|
280
322
|
proposalShape,
|
|
281
323
|
);
|
|
282
|
-
|
|
324
|
+
// rely on the ZCF type signature
|
|
325
|
+
return /** @type {any} */ (invitationP);
|
|
283
326
|
},
|
|
284
327
|
// Shutdown the entire vat and give payouts
|
|
285
328
|
shutdown: completion => {
|
|
@@ -300,6 +343,7 @@ export const makeZCFZygote = async (
|
|
|
300
343
|
const terms = getInstanceRecHolder().getTerms();
|
|
301
344
|
|
|
302
345
|
// If the contract provided customTermsShape, validate the customTerms.
|
|
346
|
+
const { customTermsShape } = meta;
|
|
303
347
|
if (customTermsShape) {
|
|
304
348
|
const { brands: _b, issuers: _i, ...customTerms } = terms;
|
|
305
349
|
mustMatch(harden(customTerms), customTermsShape, 'customTerms');
|
|
@@ -373,13 +417,13 @@ export const makeZCFZygote = async (
|
|
|
373
417
|
zcfBaggage.init('instanceRecHolder', instanceRecHolder);
|
|
374
418
|
zcfBaggage.init('repairedContractCompletionWatcher', true);
|
|
375
419
|
|
|
376
|
-
const
|
|
420
|
+
const { privateArgsShape } = meta;
|
|
377
421
|
if (privateArgsShape) {
|
|
378
422
|
mustMatch(privateArgs, privateArgsShape, 'privateArgs');
|
|
379
423
|
}
|
|
380
424
|
// start a contract for the first time
|
|
381
425
|
return E.when(
|
|
382
|
-
|
|
426
|
+
start(zcf, privateArgs, contractBaggage),
|
|
383
427
|
({
|
|
384
428
|
creatorFacet = undefined,
|
|
385
429
|
publicFacet = undefined,
|
|
@@ -388,18 +432,16 @@ export const makeZCFZygote = async (
|
|
|
388
432
|
}) => {
|
|
389
433
|
const unexpectedKeys = Object.keys(unexpected);
|
|
390
434
|
unexpectedKeys.length === 0 ||
|
|
391
|
-
Fail`contract ${
|
|
392
|
-
prepare ? 'prepare' : 'start'
|
|
393
|
-
} returned unrecognized properties ${unexpectedKeys}`;
|
|
435
|
+
Fail`contract "start" returned unrecognized properties ${unexpectedKeys}`;
|
|
394
436
|
|
|
395
437
|
const areDurable = objectMap(
|
|
396
438
|
{ creatorFacet, publicFacet, creatorInvitation },
|
|
397
439
|
canBeDurable,
|
|
398
440
|
);
|
|
399
441
|
const allDurable = Object.values(areDurable).every(Boolean);
|
|
400
|
-
if (
|
|
442
|
+
if (durabilityRequired) {
|
|
401
443
|
allDurable ||
|
|
402
|
-
Fail`values from
|
|
444
|
+
Fail`with ${meta.upgradability}, values from start() must be durable ${areDurable}`;
|
|
403
445
|
}
|
|
404
446
|
|
|
405
447
|
if (allDurable) {
|
|
@@ -419,21 +461,32 @@ export const makeZCFZygote = async (
|
|
|
419
461
|
},
|
|
420
462
|
|
|
421
463
|
restartContract: async (privateArgs = undefined) => {
|
|
422
|
-
|
|
464
|
+
if (meta.upgradability) {
|
|
465
|
+
meta.upgradability === 'canUpgrade' || Fail`contract cannot upgrade`;
|
|
466
|
+
}
|
|
423
467
|
zoeInstanceAdmin = zcfBaggage.get('zcfInstanceAdmin');
|
|
424
468
|
instanceRecHolder = zcfBaggage.get('instanceRecHolder');
|
|
425
469
|
initSeatMgrAndMintKind();
|
|
426
470
|
|
|
427
471
|
await null;
|
|
428
472
|
if (!zcfBaggage.has('repairedContractCompletionWatcher')) {
|
|
429
|
-
|
|
430
|
-
|
|
473
|
+
// We don't wait because it's a cross-vat call (to Zoe) that can't be
|
|
474
|
+
// completed during this vat's start-up
|
|
475
|
+
E(zoeInstanceAdmin)
|
|
476
|
+
.repairContractCompletionWatcher()
|
|
477
|
+
.catch(() => {});
|
|
478
|
+
|
|
431
479
|
zcfBaggage.init('repairedContractCompletionWatcher', true);
|
|
432
480
|
}
|
|
433
481
|
|
|
482
|
+
const { privateArgsShape } = meta;
|
|
483
|
+
if (privateArgsShape) {
|
|
484
|
+
mustMatch(privateArgs, privateArgsShape, 'privateArgs');
|
|
485
|
+
}
|
|
486
|
+
|
|
434
487
|
// restart an upgradeable contract
|
|
435
488
|
return E.when(
|
|
436
|
-
|
|
489
|
+
start(zcf, privateArgs, contractBaggage),
|
|
437
490
|
({
|
|
438
491
|
creatorFacet = undefined,
|
|
439
492
|
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,qCAOiB,CAAC,aATR,CAAC,wBAAP,CAAC,GAAG,EAAE,CAAC,KASM,CAAC,AATD,eASA,CAAC,CAWxB;AAWM,sCALI,GAAG,WACH,OAAO,4BAA4B,EAAE,OAAO,QAC5C,MAAM,GACJ,OAAO,CAInB;AAiCM,2BAFmD,CAAC,8BAHxB,IAAI,CAAC,GAAG,CAAC,YACjC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,UAE0B,CAAC,AAD/C,GACC,OAAO,CAAC,GAAG,CAAC,IAAI,MAA6B,CAAC,AAAvB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC,CAuBlE;AAgBM,iCAFiC,CAAC,eALrB,IAAI,CAAC,GAAG,CAAC,YAClB,OAAO,kBAAkB,EAAE,OAAO,OAClC,MAAM,aAGuB,CAAC,AAF7B,uBACO,OAAO,CAAC,UAAU,CACG,CAAC,AADF,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,+BAFoC,EAAE,oCAflC,OAAO,mBAAmB,EAAE,IAAI,kBAChC,GAAG,CAAC,gBAAgB,CAAC,aAQrB,MAAM,gBAM0B,EAAE,AAJhC,yCAIA,CAAC,CAAC,EAAE,UAAU,EAAwE,CAAC,AAAtE,KAAK,IAAI,CAA4D,CAAC,AAA3D,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: globalThis.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;;cAPI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;WACvB,IAAI,CAAC,OAAO,cAAc,EAAE,YAAY,CAAC;;mBAEzC,KAAK,CAAC,KAAK,CAAC;oBACZ,KAAK,CAAC,KAAK,CAAC;sBAyTtB;qCA7WU,MAAM,eACN,MAAM,KACJ,OAAO;gEAkBP,OAAO,CAAC,IAAI,CAAC;sCA7ByI,4BAA4B;sCAA5B,4BAA4B;uCAA5B,4BAA4B"}
|