@agoric/pegasus 0.7.12 → 0.7.13-dev-8c14632.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 +12 -12
- package/src/courier.js +2 -1
- package/src/ics20.js +11 -1
- package/src/pegasus.js +3 -2
- package/src/types.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/pegasus",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13-dev-8c14632.0+8c14632",
|
|
4
4
|
"description": "Peg-as-us contract",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/pegasus.js",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agoric/assert": "
|
|
33
|
-
"@agoric/ertp": "
|
|
34
|
-
"@agoric/internal": "
|
|
35
|
-
"@agoric/notifier": "
|
|
36
|
-
"@agoric/store": "
|
|
37
|
-
"@agoric/swingset-vat": "
|
|
38
|
-
"@agoric/vats": "
|
|
39
|
-
"@agoric/zoe": "
|
|
32
|
+
"@agoric/assert": "0.6.1-dev-8c14632.0+8c14632",
|
|
33
|
+
"@agoric/ertp": "0.16.3-dev-8c14632.0+8c14632",
|
|
34
|
+
"@agoric/internal": "0.3.3-dev-8c14632.0+8c14632",
|
|
35
|
+
"@agoric/notifier": "0.6.3-dev-8c14632.0+8c14632",
|
|
36
|
+
"@agoric/store": "0.9.3-dev-8c14632.0+8c14632",
|
|
37
|
+
"@agoric/swingset-vat": "0.32.3-dev-8c14632.0+8c14632",
|
|
38
|
+
"@agoric/vats": "0.15.2-dev-8c14632.0+8c14632",
|
|
39
|
+
"@agoric/zoe": "0.26.3-dev-8c14632.0+8c14632",
|
|
40
40
|
"@endo/bundle-source": "^2.5.1",
|
|
41
41
|
"@endo/captp": "^3.1.1",
|
|
42
42
|
"@endo/far": "^0.2.18",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@endo/promise-kit": "^0.2.56"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@agoric/deploy-script-support": "
|
|
49
|
-
"ava": "^5.
|
|
48
|
+
"@agoric/deploy-script-support": "0.10.4-dev-8c14632.0+8c14632",
|
|
49
|
+
"ava": "^5.3.0",
|
|
50
50
|
"c8": "^7.13.0",
|
|
51
51
|
"import-meta-resolve": "^2.2.1"
|
|
52
52
|
},
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "8c14632298cfb982f91dc0ef271681703237a93f"
|
|
69
69
|
}
|
package/src/courier.js
CHANGED
|
@@ -56,13 +56,14 @@ export const makeCourierMaker =
|
|
|
56
56
|
transferProtocol,
|
|
57
57
|
}) => {
|
|
58
58
|
/** @type {Sender} */
|
|
59
|
-
const send = async (zcfSeat, depositAddress) => {
|
|
59
|
+
const send = async (zcfSeat, depositAddress, memo) => {
|
|
60
60
|
const tryToSend = async () => {
|
|
61
61
|
const amount = zcfSeat.getAmountAllocated('Transfer', localBrand);
|
|
62
62
|
const transferPacket = await E(transferProtocol).makeTransferPacket({
|
|
63
63
|
value: amount.value,
|
|
64
64
|
remoteDenom: sendDenom,
|
|
65
65
|
depositAddress,
|
|
66
|
+
memo,
|
|
66
67
|
});
|
|
67
68
|
|
|
68
69
|
// Retain the payment. We must not proceed on failure.
|
package/src/ics20.js
CHANGED
|
@@ -10,6 +10,7 @@ import { assert, details as X, Fail } from '@agoric/assert';
|
|
|
10
10
|
* @property {Denom} denom The denomination of the amount
|
|
11
11
|
* @property {string} sender The sender address
|
|
12
12
|
* @property {DepositAddress} receiver The receiver deposit address
|
|
13
|
+
* @property {string} memo The packet memo
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
// As specified in ICS20, the success result is a base64-encoded '\0x1' byte.
|
|
@@ -50,10 +51,16 @@ const safeJSONParseObject = s => {
|
|
|
50
51
|
*/
|
|
51
52
|
export const parseICS20TransferPacket = async packet => {
|
|
52
53
|
const ics20Packet = safeJSONParseObject(packet);
|
|
53
|
-
const { amount, denom, receiver } = ics20Packet;
|
|
54
|
+
const { amount, denom, receiver, memo } = ics20Packet;
|
|
54
55
|
|
|
55
56
|
assert.typeof(denom, 'string', X`Denom ${denom} must be a string`);
|
|
56
57
|
assert.typeof(receiver, 'string', X`Receiver ${receiver} must be a string`);
|
|
58
|
+
memo === undefined ||
|
|
59
|
+
assert.typeof(
|
|
60
|
+
memo,
|
|
61
|
+
'string',
|
|
62
|
+
X`Memo ${memo} must be a string or 'undefined'`,
|
|
63
|
+
);
|
|
57
64
|
|
|
58
65
|
// amount is a string in JSON.
|
|
59
66
|
assert.typeof(amount, 'string', X`Amount ${amount} must be a string`);
|
|
@@ -66,6 +73,7 @@ export const parseICS20TransferPacket = async packet => {
|
|
|
66
73
|
depositAddress: receiver,
|
|
67
74
|
remoteDenom: denom,
|
|
68
75
|
value,
|
|
76
|
+
memo,
|
|
69
77
|
});
|
|
70
78
|
};
|
|
71
79
|
|
|
@@ -80,6 +88,7 @@ export const makeICS20TransferPacket = async ({
|
|
|
80
88
|
value,
|
|
81
89
|
remoteDenom,
|
|
82
90
|
depositAddress,
|
|
91
|
+
memo,
|
|
83
92
|
}) => {
|
|
84
93
|
// We're using Nat as a dynamic check for overflow.
|
|
85
94
|
const stringValue = String(Nat(value));
|
|
@@ -91,6 +100,7 @@ export const makeICS20TransferPacket = async ({
|
|
|
91
100
|
denom: remoteDenom,
|
|
92
101
|
receiver: depositAddress,
|
|
93
102
|
sender: DUMMY_SENDER_ADDRESS,
|
|
103
|
+
memo,
|
|
94
104
|
};
|
|
95
105
|
|
|
96
106
|
return JSON.stringify(ics20);
|
package/src/pegasus.js
CHANGED
|
@@ -458,9 +458,10 @@ const makePegasus = (zcf, board, namesByAddress) => {
|
|
|
458
458
|
*
|
|
459
459
|
* @param {ERef<Peg>} pegP the peg over which to transfer
|
|
460
460
|
* @param {DepositAddress} depositAddress the remote receiver's address
|
|
461
|
+
* @param {string} [memo] the memo to attach to ics transfer packet
|
|
461
462
|
* @returns {Promise<Invitation>} to transfer, make an offer of { give: { Transfer: pegAmount } } to this invitation
|
|
462
463
|
*/
|
|
463
|
-
async makeInvitationToTransfer(pegP, depositAddress) {
|
|
464
|
+
async makeInvitationToTransfer(pegP, depositAddress, memo = '') {
|
|
464
465
|
// Verify the peg.
|
|
465
466
|
const peg = await pegP;
|
|
466
467
|
const denomState = pegToDenomState.get(peg);
|
|
@@ -482,7 +483,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
|
|
|
482
483
|
*/
|
|
483
484
|
const offerHandler = zcfSeat => {
|
|
484
485
|
assertProposalShape(zcfSeat, TRANSFER_PROPOSAL_SHAPE);
|
|
485
|
-
send(zcfSeat, depositAddress);
|
|
486
|
+
send(zcfSeat, depositAddress, memo);
|
|
486
487
|
};
|
|
487
488
|
|
|
488
489
|
return zcf.makeInvitation(offerHandler, `pegasus ${sendDenom} transfer`);
|
package/src/types.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* @property {AmountValue} value
|
|
13
13
|
* @property {Denom} remoteDenom
|
|
14
14
|
* @property {DepositAddress} depositAddress
|
|
15
|
+
* @property {string} memo
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
|
-
* @typedef {(zcfSeat: ZCFSeat, depositAddress: DepositAddress) => Promise<void>} Sender
|
|
50
|
+
* @typedef {(zcfSeat: ZCFSeat, depositAddress: DepositAddress, memo: string) => Promise<void>} Sender
|
|
50
51
|
* Successive transfers are not guaranteed to be processed in the order in which they were sent.
|
|
51
52
|
* @typedef {(parts: PacketParts) => Promise<Bytes>} Receiver
|
|
52
53
|
* @typedef {object} Courier
|