@agoric/pegasus 0.7.9-pismo-dev-0d5327f.0 → 0.7.10-dev-bf4b59f.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.7.9](https://github.com/Agoric/agoric-sdk/compare/@agoric/pegasus@0.7.6...@agoric/pegasus@0.7.9) (2023-05-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * use `subscribeEach` to get reconnect benefits ([fb24132](https://github.com/Agoric/agoric-sdk/commit/fb24132f9b4e117e56bae2803994e57c188344f3))
12
+ * use atomicTransfers rather than stagings. ([#6577](https://github.com/Agoric/agoric-sdk/issues/6577)) ([65d3f14](https://github.com/Agoric/agoric-sdk/commit/65d3f14c8102993168d2568eed5e6acbcba0c48a))
13
+
14
+
15
+
6
16
  ### [0.7.8](https://github.com/Agoric/agoric-sdk/compare/@agoric/pegasus@0.7.7...@agoric/pegasus@0.7.8) (2023-02-17)
7
17
 
8
18
  **Note:** Version bump only for package @agoric/pegasus
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/pegasus",
3
- "version": "0.7.9-pismo-dev-0d5327f.0+0d5327f",
3
+ "version": "0.7.10-dev-bf4b59f.0+bf4b59f",
4
4
  "description": "Peg-as-us contract",
5
5
  "type": "module",
6
6
  "main": "./src/pegasus.js",
@@ -16,7 +16,7 @@
16
16
  "lint-fix": "yarn lint:eslint --fix",
17
17
  "lint": "run-s --continue-on-error lint:*",
18
18
  "lint:eslint": "eslint .",
19
- "lint:types": "tsc --maxNodeModuleJsDepth 4 -p jsconfig.json"
19
+ "lint:types": "tsc -p jsconfig.json"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -29,25 +29,26 @@
29
29
  },
30
30
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
31
31
  "dependencies": {
32
- "@agoric/assert": "0.5.2-pismo-dev-0d5327f.0+0d5327f",
33
- "@agoric/ertp": "0.15.6-pismo-dev-0d5327f.0+0d5327f",
34
- "@agoric/nat": "^4.1.0",
35
- "@agoric/notifier": "0.5.2-pismo-dev-0d5327f.0+0d5327f",
36
- "@agoric/store": "0.8.6-pismo-dev-0d5327f.0+0d5327f",
37
- "@agoric/swingset-vat": "0.31.1-pismo-dev-0d5327f.0+0d5327f",
38
- "@agoric/vats": "0.13.3-pismo-dev-0d5327f.0+0d5327f",
39
- "@agoric/zoe": "0.25.6-pismo-dev-0d5327f.0+0d5327f",
40
- "@endo/bundle-source": "^2.3.1",
41
- "@endo/captp": "^2.0.15",
42
- "@endo/far": "^0.2.11",
43
- "@endo/init": "^0.5.49",
44
- "@endo/promise-kit": "^0.2.49"
32
+ "@agoric/assert": "0.6.1-dev-bf4b59f.0+bf4b59f",
33
+ "@agoric/ertp": "0.16.1-dev-bf4b59f.0+bf4b59f",
34
+ "@agoric/internal": "0.3.1-dev-bf4b59f.0+bf4b59f",
35
+ "@agoric/notifier": "0.6.1-dev-bf4b59f.0+bf4b59f",
36
+ "@agoric/store": "0.9.1-dev-bf4b59f.0+bf4b59f",
37
+ "@agoric/swingset-vat": "0.32.1-dev-bf4b59f.0+bf4b59f",
38
+ "@agoric/vats": "0.14.1-dev-bf4b59f.0+bf4b59f",
39
+ "@agoric/zoe": "0.26.1-dev-bf4b59f.0+bf4b59f",
40
+ "@endo/bundle-source": "^2.5.1",
41
+ "@endo/captp": "^3.1.1",
42
+ "@endo/far": "^0.2.18",
43
+ "@endo/init": "^0.5.56",
44
+ "@endo/nat": "^4.1.27",
45
+ "@endo/promise-kit": "^0.2.56"
45
46
  },
46
47
  "devDependencies": {
47
- "@agoric/deploy-script-support": "0.9.7-pismo-dev-0d5327f.0+0d5327f",
48
- "ava": "^4.3.1",
49
- "c8": "^7.11.0",
50
- "import-meta-resolve": "^1.1.1"
48
+ "@agoric/deploy-script-support": "0.10.1-dev-bf4b59f.0+bf4b59f",
49
+ "ava": "^5.2.0",
50
+ "c8": "^7.13.0",
51
+ "import-meta-resolve": "^2.2.1"
51
52
  },
52
53
  "files": [
53
54
  "scripts/",
@@ -61,11 +62,8 @@
61
62
  ],
62
63
  "timeout": "10m"
63
64
  },
64
- "eslintIgnore": [
65
- "bundle-*.js"
66
- ],
67
65
  "publishConfig": {
68
66
  "access": "public"
69
67
  },
70
- "gitHead": "0d5327f87310cf523834853b0546d0e217f37009"
68
+ "gitHead": "bf4b59f2128aca73d786429c6ef4a7c9cdfb6700"
71
69
  }
@@ -1,5 +1,6 @@
1
1
  import { makeHelpers } from '@agoric/deploy-script-support';
2
2
 
3
+ /** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
3
4
  export const defaultProposalBuilder = async ({ publishRef, install }) =>
4
5
  harden({
5
6
  sourceSpec: '../src/proposals/core-proposal.js',
package/src/courier.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { details as X } from '@agoric/assert';
3
3
 
4
4
  import { AmountMath } from '@agoric/ertp';
5
+ import { WalletName } from '@agoric/internal';
5
6
  import { E, Far } from '@endo/far';
6
7
  import { makeOncePromiseKit } from './once-promise-kit.js';
7
8
 
@@ -28,7 +29,7 @@ export const getCourierPK = (key, keyToCourierPK) => {
28
29
  /**
29
30
  * Create the [send, receive] pair.
30
31
  *
31
- * @typedef {import('@agoric/vats/src/nameHub.js').NameHub} NameHub
32
+ * @typedef {import('@agoric/vats').NameHub} NameHub
32
33
  *
33
34
  * @typedef {object} CourierArgs
34
35
  * @property {ZCF} zcf
@@ -95,7 +96,9 @@ export const makeCourierMaker =
95
96
  /** @type {DepositFacet} */
96
97
  const depositFacet = await E(board)
97
98
  .getValue(depositAddress)
98
- .catch(_ => E(namesByAddress).lookup(depositAddress, 'depositFacet'));
99
+ .catch(_ =>
100
+ E(namesByAddress).lookup(depositAddress, WalletName.depositFacet),
101
+ );
99
102
 
100
103
  const { userSeat, zcfSeat } = zcf.makeEmptySeatKit();
101
104
 
package/src/ibc-trace.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
  import { Far } from '@endo/far';
3
- import { assert, details as X } from '@agoric/assert';
3
+ import { Fail } from '@agoric/assert';
4
4
 
5
5
  import { parse } from '@agoric/swingset-vat/src/vats/network/multiaddr.js';
6
6
 
@@ -8,16 +8,20 @@ import { parse } from '@agoric/swingset-vat/src/vats/network/multiaddr.js';
8
8
  * Return a source-prefixed version of the denomination, as specified in
9
9
  * ICS20-1.
10
10
  *
11
- * @param {Address} addr
11
+ * @param {string} addr
12
12
  * @param {Denom} denom
13
13
  */
14
14
  const sourcePrefixedDenom = (addr, denom) => {
15
15
  const ma = parse(addr);
16
16
 
17
17
  const ibcPort = ma.find(([protocol]) => protocol === 'ibc-port');
18
- assert(ibcPort, X`${addr} does not contain an IBC port`);
18
+ if (!ibcPort) {
19
+ throw Fail`${addr} does not contain an IBC port`;
20
+ }
19
21
  const ibcChannel = ma.find(([protocol]) => protocol === 'ibc-channel');
20
- assert(ibcChannel, X`${addr} does not contain an IBC channel`);
22
+ if (!ibcChannel) {
23
+ throw Fail`${addr} does not contain an IBC channel`;
24
+ }
21
25
 
22
26
  return `${ibcPort[1]}/${ibcChannel[1]}/${denom}`;
23
27
  };
package/src/ics20.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // @ts-check
2
- import { Nat } from '@agoric/nat';
2
+ import { Nat } from '@endo/nat';
3
3
  import { Far } from '@endo/far';
4
- import { assert, details as X } from '@agoric/assert';
4
+ import { assert, details as X, Fail } from '@agoric/assert';
5
5
 
6
6
  /**
7
7
  * @typedef {object} ICS20TransferPacket Packet shape defined at:
8
- * https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures
8
+ * https://github.com/cosmos/ibc/tree/HEAD/spec/app/ics-020-fungible-token-transfer#data-structures
9
9
  * @property {string} amount The extent of the amount
10
10
  * @property {Denom} denom The denomination of the amount
11
11
  * @property {string} sender The sender address
@@ -22,6 +22,7 @@ export const DUMMY_SENDER_ADDRESS = 'pegasus';
22
22
 
23
23
  /**
24
24
  * @param {string} s
25
+ * @returns {Record<string, any>}
25
26
  */
26
27
  const safeJSONParseObject = s => {
27
28
  /** @type {unknown} */
@@ -32,8 +33,12 @@ const safeJSONParseObject = s => {
32
33
  assert.note(e, X`${s} is not valid JSON`);
33
34
  throw e;
34
35
  }
35
- assert.typeof(obj, 'object', X`${s} is not a JSON object`);
36
- assert(obj !== null, X`${s} is null`);
36
+ if (typeof obj !== 'object') {
37
+ throw Fail`${s} is not a JSON object`;
38
+ }
39
+ if (obj === null) {
40
+ throw Fail`${s} is null`;
41
+ }
37
42
  return obj;
38
43
  };
39
44
 
@@ -77,7 +82,6 @@ export const makeICS20TransferPacket = async ({
77
82
  depositAddress,
78
83
  }) => {
79
84
  // We're using Nat as a dynamic check for overflow.
80
- // @ts-expect-error - this causes errors on some versions of TS, but not others.
81
85
  const stringValue = String(Nat(value));
82
86
 
83
87
  // Generate the ics20-1 packet.
@@ -100,8 +104,8 @@ export const makeICS20TransferPacket = async ({
100
104
  */
101
105
  export const assertICS20TransferPacketAck = async ack => {
102
106
  const { result, error } = safeJSONParseObject(ack);
103
- assert(error === undefined, X`ICS20 transfer error ${error}`);
104
- assert(result !== undefined, X`ICS20 transfer missing result in ${ack}`);
107
+ error === undefined || Fail`ICS20 transfer error ${error}`;
108
+ result !== undefined || Fail`ICS20 transfer missing result in ${ack}`;
105
109
  if (result !== ICS20_TRANSFER_SUCCESS_RESULT) {
106
110
  // We don't want to throw an error here, because we want only to be able to
107
111
  // differentiate between a transfer that failed and a transfer that succeeded.
@@ -111,7 +115,7 @@ export const assertICS20TransferPacketAck = async ack => {
111
115
 
112
116
  /**
113
117
  * Create results of the transfer. Acknowledgement shape defined at:
114
- * https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures
118
+ * https://github.com/cosmos/ibc/tree/HEAD/spec/app/ics-020-fungible-token-transfer#data-structures
115
119
  *
116
120
  * @param {boolean} success
117
121
  * @param {any} error
package/src/pegasus.js CHANGED
@@ -1,9 +1,12 @@
1
1
  // @ts-check
2
2
 
3
- import { assert, details as X } from '@agoric/assert';
3
+ import { assert, details as X, Fail } from '@agoric/assert';
4
4
  import { makeLegacyWeakMap, makeLegacyMap } from '@agoric/store';
5
5
  import { E, Far } from '@endo/far';
6
- import { assertProposalShape } from '@agoric/zoe/src/contractSupport/index.js';
6
+ import {
7
+ assertProposalShape,
8
+ atomicTransfer,
9
+ } from '@agoric/zoe/src/contractSupport/index.js';
7
10
  import { makeSubscriptionKit } from '@agoric/notifier';
8
11
 
9
12
  import '@agoric/vats/exported.js';
@@ -31,13 +34,13 @@ const TRANSFER_PROPOSAL_SHAPE = {
31
34
  * @param {ERef<BoardDepositFacet>} board where to find depositFacets by boardID
32
35
  * @param {ERef<NameHub>} namesByAddress where to find depositFacets by bech32
33
36
  *
34
- * @typedef {import('@agoric/vats/src/nameHub.js').NameHub} NameHub
37
+ * @typedef {import('@agoric/vats').NameHub} NameHub
35
38
  */
36
39
  const makePegasus = (zcf, board, namesByAddress) => {
37
40
  /**
38
41
  * @typedef {object} LocalDenomState
39
- * @property {Address} localAddr
40
- * @property {Address} remoteAddr
42
+ * @property {string} localAddr
43
+ * @property {string} remoteAddr
41
44
  * @property {LegacyMap<Denom, PromiseRecord<Courier>>} receiveDenomToCourierPK
42
45
  * @property {IterationObserver<Denom>} receiveDenomPublication
43
46
  * @property {Subscription<Denom>} remoteDenomSubscription
@@ -136,8 +139,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
136
139
  // Only continue if the promise isn't already resolved.
137
140
  const raceWinner = await Promise.race([promise, null]);
138
141
  checkAbort();
139
-
140
- assert(!raceWinner, X`${receiveDenom} is already resolved`);
142
+ !raceWinner || Fail`${receiveDenom} is already resolved`;
141
143
 
142
144
  // If rejected, the rejection is returned to our caller, so we have
143
145
  // handled it correctly and that flow doesn't need to trigger an
@@ -248,9 +250,13 @@ const makePegasus = (zcf, board, namesByAddress) => {
248
250
  winner,
249
251
  ) => {
250
252
  // Transfer the amount to our backing seat.
251
- loser.decrementBy(harden({ [loserKeyword]: amount }));
252
- winner.incrementBy(harden({ [winnerKeyword]: amount }));
253
- zcf.reallocate(loser, winner);
253
+ atomicTransfer(
254
+ zcf,
255
+ loser,
256
+ winner,
257
+ { [loserKeyword]: amount },
258
+ { [winnerKeyword]: amount },
259
+ );
254
260
  };
255
261
 
256
262
  // Describe how to retain/redeem real local erights.
@@ -489,7 +495,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
489
495
  */
490
496
 
491
497
  /**
492
- * @param {ZCF<{board: ERef<BoardDepositFacet>, namesByAddress: ERef<NameHub>}>} zcf
498
+ * @param {ZCF<{board: ERef<BoardDepositFacet>, namesByAddress: ERef<import('@agoric/vats').NameHub>}>} zcf
493
499
  */
494
500
  const start = zcf => {
495
501
  const { board, namesByAddress } = zcf.getTerms();
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
  import { E, Far } from '@endo/far';
3
3
  import { makeNameHubKit } from '@agoric/vats/src/nameHub.js';
4
- import { observeIteration } from '@agoric/notifier';
4
+ import { observeIteration, subscribeEach } from '@agoric/notifier';
5
5
 
6
6
  export const CONTRACT_NAME = 'Pegasus';
7
7
 
@@ -56,7 +56,7 @@ harden(startPegasus);
56
56
  /**
57
57
  * @param {Port} port
58
58
  * @param {*} pegasus
59
- * @param {NameAdmin} pegasusConnectionsAdmin
59
+ * @param {import('@agoric/vats').NameAdmin} pegasusConnectionsAdmin
60
60
  */
61
61
  export const addPegasusTransferPort = async (
62
62
  port,
@@ -64,7 +64,7 @@ export const addPegasusTransferPort = async (
64
64
  pegasusConnectionsAdmin,
65
65
  ) => {
66
66
  const { handler, subscription } = await E(pegasus).makePegasusConnectionKit();
67
- observeIteration(subscription, {
67
+ observeIteration(subscribeEach(subscription), {
68
68
  updateState(connectionState) {
69
69
  const { localAddr, actions } = connectionState;
70
70
  if (actions) {
package/src/types.js CHANGED
@@ -5,7 +5,6 @@
5
5
  /**
6
6
  * @typedef {string} Denom
7
7
  * @typedef {string} DepositAddress
8
- * @typedef {string} Address
9
8
  */
10
9
 
11
10
  /**
@@ -25,10 +24,10 @@
25
24
 
26
25
  /**
27
26
  * @typedef {object} DenomTransformer
28
- * @property {(remoteDenom: Denom, localAddr: Address, remoteAddr: Address)
27
+ * @property {(remoteDenom: Denom, localAddr: string, remoteAddr: string)
29
28
  * => Promise<{ sendDenom: Denom, receiveDenom: Denom }>
30
29
  * } getDenomsForLocalPeg
31
- * @property {(remoteDenom: Denom, localAddr: Address, remoteAddr: Address)
30
+ * @property {(remoteDenom: Denom, localAddr: string, remoteAddr: string)
32
31
  * => Promise<{ sendDenom: Denom, receiveDenom: Denom }>
33
32
  * } getDenomsForRemotePeg
34
33
  */
@@ -101,8 +100,8 @@
101
100
  /**
102
101
  * @typedef {object} PegasusConnection
103
102
  * @property {PegasusConnectionActions} [actions]
104
- * @property {Address} localAddr
105
- * @property {Address} remoteAddr
103
+ * @property {string} localAddr
104
+ * @property {string} remoteAddr
106
105
  * @property {Subscription<Denom>} [remoteDenomSubscription]
107
106
  */
108
107