@agoric/pegasus 0.7.13-dev-cdd20f7.0 → 0.7.13-dev-00cd6ae.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/pegasus",
3
- "version": "0.7.13-dev-cdd20f7.0+cdd20f7",
3
+ "version": "0.7.13-dev-00cd6ae.0+00cd6ae",
4
4
  "description": "Peg-as-us contract",
5
5
  "type": "module",
6
6
  "main": "./src/pegasus.js",
@@ -28,15 +28,15 @@
28
28
  },
29
29
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
30
30
  "dependencies": {
31
- "@agoric/assert": "0.6.1-dev-cdd20f7.0+cdd20f7",
32
- "@agoric/ertp": "0.16.3-dev-cdd20f7.0+cdd20f7",
33
- "@agoric/internal": "0.3.3-dev-cdd20f7.0+cdd20f7",
34
- "@agoric/network": "0.1.1-dev-cdd20f7.0+cdd20f7",
35
- "@agoric/notifier": "0.6.3-dev-cdd20f7.0+cdd20f7",
36
- "@agoric/store": "0.9.3-dev-cdd20f7.0+cdd20f7",
37
- "@agoric/swingset-vat": "0.32.3-dev-cdd20f7.0+cdd20f7",
38
- "@agoric/vats": "0.15.2-dev-cdd20f7.0+cdd20f7",
39
- "@agoric/zoe": "0.26.3-dev-cdd20f7.0+cdd20f7",
31
+ "@agoric/assert": "0.6.1-dev-00cd6ae.0+00cd6ae",
32
+ "@agoric/ertp": "0.16.3-dev-00cd6ae.0+00cd6ae",
33
+ "@agoric/internal": "0.3.3-dev-00cd6ae.0+00cd6ae",
34
+ "@agoric/network": "0.1.1-dev-00cd6ae.0+00cd6ae",
35
+ "@agoric/notifier": "0.6.3-dev-00cd6ae.0+00cd6ae",
36
+ "@agoric/store": "0.9.3-dev-00cd6ae.0+00cd6ae",
37
+ "@agoric/swingset-vat": "0.32.3-dev-00cd6ae.0+00cd6ae",
38
+ "@agoric/vats": "0.15.2-dev-00cd6ae.0+00cd6ae",
39
+ "@agoric/zoe": "0.26.3-dev-00cd6ae.0+00cd6ae",
40
40
  "@endo/bundle-source": "^2.7.0",
41
41
  "@endo/captp": "^3.1.4",
42
42
  "@endo/far": "^0.2.21",
@@ -70,5 +70,5 @@
70
70
  "typeCoverage": {
71
71
  "atLeast": 90.04
72
72
  },
73
- "gitHead": "cdd20f7407af2f09f93cfedc4d26966597ac70d2"
73
+ "gitHead": "00cd6aec8f6a8c8baa1eb29ad929054b32491733"
74
74
  }
package/src/courier.js CHANGED
@@ -56,7 +56,7 @@ export const makeCourierMaker =
56
56
  transferProtocol,
57
57
  }) => {
58
58
  /** @type {Sender} */
59
- const send = async (zcfSeat, depositAddress, memo) => {
59
+ const send = async (zcfSeat, depositAddress, memo, opts) => {
60
60
  const tryToSend = async () => {
61
61
  const amount = zcfSeat.getAmountAllocated('Transfer', localBrand);
62
62
  const transferPacket = await E(transferProtocol).makeTransferPacket({
@@ -64,6 +64,7 @@ export const makeCourierMaker =
64
64
  remoteDenom: sendDenom,
65
65
  depositAddress,
66
66
  memo,
67
+ opts,
67
68
  });
68
69
 
69
70
  // Retain the payment. We must not proceed on failure.
package/src/ics20.js CHANGED
@@ -17,9 +17,8 @@ import { assert, details as X, Fail } from '@agoric/assert';
17
17
  const ICS20_TRANSFER_SUCCESS_RESULT = 'AQ==';
18
18
 
19
19
  // ibc-go as late as v3 requires the `sender` to be nonempty, but doesn't
20
- // actually use it on the receiving side. We don't need it on the sending side,
21
- // either, so we can just omit it.
22
- export const DUMMY_SENDER_ADDRESS = 'pegasus';
20
+ // actually use it on the receiving side.
21
+ export const DEFAULT_SENDER_ADDRESS = 'pegasus';
23
22
 
24
23
  /**
25
24
  * @param {string} s
@@ -51,7 +50,7 @@ const safeJSONParseObject = s => {
51
50
  */
52
51
  export const parseICS20TransferPacket = async packet => {
53
52
  const ics20Packet = safeJSONParseObject(packet);
54
- const { amount, denom, receiver, memo } = ics20Packet;
53
+ const { amount, denom, receiver, memo, opts } = ics20Packet;
55
54
 
56
55
  assert.typeof(denom, 'string', X`Denom ${denom} must be a string`);
57
56
  assert.typeof(receiver, 'string', X`Receiver ${receiver} must be a string`);
@@ -74,6 +73,7 @@ export const parseICS20TransferPacket = async packet => {
74
73
  remoteDenom: denom,
75
74
  value,
76
75
  memo,
76
+ opts,
77
77
  });
78
78
  };
79
79
 
@@ -89,6 +89,7 @@ export const makeICS20TransferPacket = async ({
89
89
  remoteDenom,
90
90
  depositAddress,
91
91
  memo,
92
+ opts: { sender = DEFAULT_SENDER_ADDRESS },
92
93
  }) => {
93
94
  // We're using Nat as a dynamic check for overflow.
94
95
  const stringValue = String(Nat(value));
@@ -99,7 +100,7 @@ export const makeICS20TransferPacket = async ({
99
100
  amount: stringValue,
100
101
  denom: remoteDenom,
101
102
  receiver: depositAddress,
102
- sender: DUMMY_SENDER_ADDRESS,
103
+ sender,
103
104
  memo,
104
105
  };
105
106
 
package/src/pegasus.js CHANGED
@@ -457,9 +457,10 @@ const makePegasus = (zcf, board, namesByAddress) => {
457
457
  * @param {ERef<Peg>} pegP the peg over which to transfer
458
458
  * @param {DepositAddress} depositAddress the remote receiver's address
459
459
  * @param {string} [memo] the memo to attach to ics transfer packet
460
+ * @param {SenderOptions} [opts] additional sender options
460
461
  * @returns {Promise<Invitation>} to transfer, make an offer of { give: { Transfer: pegAmount } } to this invitation
461
462
  */
462
- async makeInvitationToTransfer(pegP, depositAddress, memo = '') {
463
+ async makeInvitationToTransfer(pegP, depositAddress, memo = '', opts = {}) {
463
464
  // Verify the peg.
464
465
  const peg = await pegP;
465
466
  const denomState = pegToDenomState.get(peg);
@@ -481,7 +482,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
481
482
  */
482
483
  const offerHandler = zcfSeat => {
483
484
  assertProposalShape(zcfSeat, TRANSFER_PROPOSAL_SHAPE);
484
- send(zcfSeat, depositAddress, memo);
485
+ send(zcfSeat, depositAddress, memo, opts);
485
486
  };
486
487
 
487
488
  return zcf.makeInvitation(offerHandler, `pegasus ${sendDenom} transfer`);
package/src/types.js CHANGED
@@ -13,6 +13,7 @@
13
13
  * @property {Denom} remoteDenom
14
14
  * @property {DepositAddress} depositAddress
15
15
  * @property {string} memo
16
+ * @property {SenderOptions} opts
16
17
  */
17
18
 
18
19
  /**
@@ -47,7 +48,7 @@
47
48
  */
48
49
 
49
50
  /**
50
- * @typedef {(zcfSeat: ZCFSeat, depositAddress: DepositAddress, memo: string) => Promise<void>} Sender
51
+ * @typedef {(zcfSeat: ZCFSeat, depositAddress: DepositAddress, memo: string, opt: SenderOptions) => Promise<void>} Sender
51
52
  * Successive transfers are not guaranteed to be processed in the order in which they were sent.
52
53
  * @typedef {(parts: PacketParts) => Promise<Bytes>} Receiver
53
54
  * @typedef {object} Courier
@@ -111,3 +112,8 @@
111
112
  * @property {ConnectionHandler} handler
112
113
  * @property {Subscription<PegasusConnection>} subscription
113
114
  */
115
+
116
+ /**
117
+ * @typedef {object} SenderOptions
118
+ * @property {string} [sender] the sender address attached to the packet to receive any refund
119
+ */