@agoric/pegasus 0.7.13-dev-7ffae88.0 → 0.7.13-dev-c5284e4.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/package.json +19 -17
- package/src/contract.js +34 -0
- package/src/courier.js +3 -2
- package/src/pegasus.js +9 -19
- package/src/proposals/core-proposal.js +6 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/pegasus",
|
|
3
|
-
"version": "0.7.13-dev-
|
|
3
|
+
"version": "0.7.13-dev-c5284e4.0+c5284e4",
|
|
4
4
|
"description": "Peg-as-us contract",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/pegasus.js",
|
|
@@ -28,21 +28,23 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agoric/assert": "0.6.1-dev-
|
|
32
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
33
|
-
"@agoric/internal": "0.3.3-dev-
|
|
34
|
-
"@agoric/network": "0.1.1-dev-
|
|
35
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
36
|
-
"@agoric/store": "0.9.3-dev-
|
|
37
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
38
|
-
"@agoric/
|
|
39
|
-
"@agoric/
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@endo/
|
|
43
|
-
"@endo/
|
|
44
|
-
"@endo/
|
|
45
|
-
"@endo/
|
|
31
|
+
"@agoric/assert": "0.6.1-dev-c5284e4.0+c5284e4",
|
|
32
|
+
"@agoric/ertp": "0.16.3-dev-c5284e4.0+c5284e4",
|
|
33
|
+
"@agoric/internal": "0.3.3-dev-c5284e4.0+c5284e4",
|
|
34
|
+
"@agoric/network": "0.1.1-dev-c5284e4.0+c5284e4",
|
|
35
|
+
"@agoric/notifier": "0.6.3-dev-c5284e4.0+c5284e4",
|
|
36
|
+
"@agoric/store": "0.9.3-dev-c5284e4.0+c5284e4",
|
|
37
|
+
"@agoric/swingset-vat": "0.32.3-dev-c5284e4.0+c5284e4",
|
|
38
|
+
"@agoric/vat-data": "0.5.3-dev-c5284e4.0+c5284e4",
|
|
39
|
+
"@agoric/vats": "0.15.2-dev-c5284e4.0+c5284e4",
|
|
40
|
+
"@agoric/zoe": "0.26.3-dev-c5284e4.0+c5284e4",
|
|
41
|
+
"@agoric/zone": "0.2.3-dev-c5284e4.0+c5284e4",
|
|
42
|
+
"@endo/bundle-source": "^3.1.0",
|
|
43
|
+
"@endo/captp": "^4.0.4",
|
|
44
|
+
"@endo/far": "^1.0.4",
|
|
45
|
+
"@endo/init": "^1.0.4",
|
|
46
|
+
"@endo/nat": "^5.0.4",
|
|
47
|
+
"@endo/promise-kit": "^1.0.4"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"ava": "^5.3.0",
|
|
@@ -70,5 +72,5 @@
|
|
|
70
72
|
"typeCoverage": {
|
|
71
73
|
"atLeast": 89.97
|
|
72
74
|
},
|
|
73
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "c5284e4721ad2702c4551f216bb8eed7abe4d7cf"
|
|
74
76
|
}
|
package/src/contract.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { prepareVowTools } from '@agoric/vat-data/vow.js';
|
|
2
|
+
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
3
|
+
import { makePegasus } from './pegasus.js';
|
|
4
|
+
|
|
5
|
+
import '@agoric/zoe/exported.js';
|
|
6
|
+
|
|
7
|
+
import '../exported.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {ContractStartFn<Pegasus, never, {}, {
|
|
11
|
+
* board: ERef<BoardDepositFacet>,
|
|
12
|
+
* namesByAddress: ERef<import('@agoric/vats').NameHub>
|
|
13
|
+
* }}
|
|
14
|
+
*/
|
|
15
|
+
export const start = (zcf, privateArgs, baggage) => {
|
|
16
|
+
const zone = makeDurableZone(baggage);
|
|
17
|
+
|
|
18
|
+
const whenZone = zone.subZone('when');
|
|
19
|
+
const { when } = prepareVowTools(whenZone);
|
|
20
|
+
|
|
21
|
+
const { board, namesByAddress } = privateArgs;
|
|
22
|
+
|
|
23
|
+
// start requires that the object passed in must be durable. Given that we
|
|
24
|
+
// haven't made pegasus durable yet, we'll wrap its non-durable methods within
|
|
25
|
+
// an exo object to workaround this requirement.
|
|
26
|
+
const publicFacet = zone.exo('PublicFacet', undefined, {
|
|
27
|
+
...makePegasus({ zcf, board, namesByAddress, when }),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return harden({
|
|
31
|
+
publicFacet,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
harden(start);
|
package/src/courier.js
CHANGED
|
@@ -40,6 +40,7 @@ export const getCourierPK = (key, keyToCourierPK) => {
|
|
|
40
40
|
* @property {(zcfSeat: ZCFSeat, amounts: AmountKeywordRecord) => void} retain
|
|
41
41
|
* @property {(zcfSeat: ZCFSeat, amounts: AmountKeywordRecord) => void} redeem
|
|
42
42
|
* @property {ERef<TransferProtocol>} transferProtocol
|
|
43
|
+
* @property {ReturnType<import('@agoric/vow').prepareVowTools>['when']} when
|
|
43
44
|
* @param {ERef<Connection>} connection
|
|
44
45
|
* @returns {(args: CourierArgs) => Courier}
|
|
45
46
|
*/
|
|
@@ -54,6 +55,7 @@ export const makeCourierMaker =
|
|
|
54
55
|
retain,
|
|
55
56
|
redeem,
|
|
56
57
|
transferProtocol,
|
|
58
|
+
when,
|
|
57
59
|
}) => {
|
|
58
60
|
/** @type {Sender} */
|
|
59
61
|
const send = async (zcfSeat, depositAddress, memo, opts) => {
|
|
@@ -71,8 +73,7 @@ export const makeCourierMaker =
|
|
|
71
73
|
retain(zcfSeat, { Transfer: amount });
|
|
72
74
|
|
|
73
75
|
// The payment is already escrowed, and proposed to retain, so try sending.
|
|
74
|
-
return E(connection)
|
|
75
|
-
.send(transferPacket)
|
|
76
|
+
return when(E(connection).send(transferPacket))
|
|
76
77
|
.then(ack => E(transferProtocol).assertTransferPacketAck(ack))
|
|
77
78
|
.then(
|
|
78
79
|
_ => zcfSeat.exit(),
|
package/src/pegasus.js
CHANGED
|
@@ -29,13 +29,15 @@ const TRANSFER_PROPOSAL_SHAPE = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Make a Pegasus public API.
|
|
31
31
|
*
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {ERef<
|
|
32
|
+
* @param {object} powers
|
|
33
|
+
* @param {ZCF} powers.zcf the Zoe Contract Facet
|
|
34
|
+
* @param {ERef<BoardDepositFacet>} powers.board where to find depositFacets by boardID
|
|
35
|
+
* @param {ERef<NameHub>} powers.namesByAddress where to find depositFacets by bech32
|
|
36
|
+
* @param {ReturnType<import('@agoric/vow').prepareVowTools>['when']} powers.when
|
|
35
37
|
*
|
|
36
38
|
* @typedef {import('@agoric/vats').NameHub} NameHub
|
|
37
39
|
*/
|
|
38
|
-
const makePegasus = (zcf, board, namesByAddress) => {
|
|
40
|
+
export const makePegasus = ({ zcf, board, namesByAddress, when }) => {
|
|
39
41
|
/**
|
|
40
42
|
* @typedef {object} LocalDenomState
|
|
41
43
|
* @property {string} localAddr
|
|
@@ -190,6 +192,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
|
|
|
190
192
|
zcfMint.mintGains(harden(amounts), zcfSeat);
|
|
191
193
|
},
|
|
192
194
|
transferProtocol,
|
|
195
|
+
when,
|
|
193
196
|
});
|
|
194
197
|
|
|
195
198
|
const courierPK = getCourierPK(receiveDenom, receiveDenomToCourierPK);
|
|
@@ -282,6 +285,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
|
|
|
282
285
|
transferSeat,
|
|
283
286
|
),
|
|
284
287
|
transferProtocol,
|
|
288
|
+
when,
|
|
285
289
|
});
|
|
286
290
|
|
|
287
291
|
const { receiveDenomToCourierPK } = localDenomState;
|
|
@@ -489,22 +493,8 @@ const makePegasus = (zcf, board, namesByAddress) => {
|
|
|
489
493
|
},
|
|
490
494
|
});
|
|
491
495
|
};
|
|
496
|
+
harden(makePegasus);
|
|
492
497
|
|
|
493
498
|
/**
|
|
494
499
|
* @typedef {ReturnType<typeof makePegasus>} Pegasus
|
|
495
500
|
*/
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* @param {ZCF<{board: ERef<BoardDepositFacet>, namesByAddress: ERef<import('@agoric/vats').NameHub>}>} zcf
|
|
499
|
-
*/
|
|
500
|
-
const start = zcf => {
|
|
501
|
-
const { board, namesByAddress } = zcf.getTerms();
|
|
502
|
-
|
|
503
|
-
return {
|
|
504
|
-
publicFacet: makePegasus(zcf, board, namesByAddress),
|
|
505
|
-
};
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
harden(start);
|
|
509
|
-
harden(makePegasus);
|
|
510
|
-
export { start, makePegasus };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
/* eslint @typescript-eslint/no-floating-promises: "warn" */
|
|
3
2
|
import { E, Far } from '@endo/far';
|
|
4
3
|
import { makeNameHubKit } from '@agoric/vats/src/nameHub.js';
|
|
5
4
|
import { observeIteration, subscribeEach } from '@agoric/notifier';
|
|
@@ -42,12 +41,13 @@ export const startPegasus = async ({
|
|
|
42
41
|
},
|
|
43
42
|
}) => {
|
|
44
43
|
const [board, namesByAddress] = await Promise.all([boardP, namesByAddressP]);
|
|
45
|
-
const
|
|
44
|
+
const privates = { board, namesByAddress };
|
|
46
45
|
|
|
47
46
|
const { instance } = await E(zoe).startInstance(
|
|
48
47
|
pegasusInstall,
|
|
49
48
|
undefined,
|
|
50
|
-
|
|
49
|
+
undefined,
|
|
50
|
+
privates,
|
|
51
51
|
);
|
|
52
52
|
|
|
53
53
|
produceInstance.resolve(instance);
|
|
@@ -76,7 +76,9 @@ export const addPegasusTransferPort = async (
|
|
|
76
76
|
void E(pegasusConnectionsAdmin).delete(localAddr);
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
})
|
|
79
|
+
}).catch(err =>
|
|
80
|
+
console.error('Error observing Pegasus connection kit:', err),
|
|
81
|
+
);
|
|
80
82
|
return E(port).addListener(
|
|
81
83
|
Far('listener', {
|
|
82
84
|
async onAccept(_port, _localAddr, _remoteAddr, _listenHandler) {
|