Skip to content

Commit 9065d6e

Browse files
committed
fix(pegasus): use bigints for nonces
1 parent 208109f commit 9065d6e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

packages/pegasus/src/pegasus.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ const makePegasus = (zcf, board, namesByAddress) => {
3838
* @property {LegacyMap<Denom, PromiseRecord<Courier>>} remoteDenomToCourierPK
3939
* @property {IterationObserver<Denom>} remoteDenomPublication
4040
* @property {Subscription<Denom>} remoteDenomSubscription
41-
* @property {number} lastDenomNonce
41+
* @property {bigint} lastDenomNonce Distinguish Pegasus-created denom names
42+
* that are sent and received from a remote connection
4243
* @property {(reason: CloseReason) => void} abort
4344
*/
4445

45-
let lastLocalIssuerNonce = 0;
46+
let lastLocalIssuerNonce = 0n;
4647
/**
4748
* Create a new issuer keyword (based on Local + nonce)
4849
*
4950
* @returns {string}
5051
*/
5152
const createLocalIssuerKeyword = () => {
52-
lastLocalIssuerNonce += 1;
53+
lastLocalIssuerNonce += 1n;
5354
return `Local${lastLocalIssuerNonce}`;
5455
};
5556

@@ -172,11 +173,10 @@ const makePegasus = (zcf, board, namesByAddress) => {
172173
async pegLocal(allegedName, localIssuer) {
173174
checkAbort();
174175

175-
// We need the last nonce for our denom name.
176-
localDenomState.lastDenomNonce += 1;
176+
localDenomState.lastDenomNonce += 1n;
177177
const remoteDenom = `pegasus${localDenomState.lastDenomNonce}`;
178178

179-
// Create a seat in which to keep our denomination.
179+
// Create a seat in which to keep our escrowed ERTP assets of this denomination.
180180
const { zcfSeat: poolSeat } = zcf.makeEmptySeatKit();
181181

182182
// Ensure the issuer can be used in Zoe offers.
@@ -298,7 +298,7 @@ const makePegasus = (zcf, board, namesByAddress) => {
298298
localAddr,
299299
remoteAddr,
300300
remoteDenomToCourierPK,
301-
lastDenomNonce: 0,
301+
lastDenomNonce: 0n,
302302
remoteDenomPublication,
303303
remoteDenomSubscription,
304304
abort: reason => {
@@ -336,10 +336,8 @@ const makePegasus = (zcf, board, namesByAddress) => {
336336
const { remoteDenom } = parts;
337337
assert.typeof(remoteDenom, 'string');
338338

339-
const {
340-
remoteDenomToCourierPK,
341-
remoteDenomPublication,
342-
} = connectionToLocalDenomState.get(c);
339+
const { remoteDenomToCourierPK, remoteDenomPublication } =
340+
connectionToLocalDenomState.get(c);
343341

344342
if (!remoteDenomToCourierPK.has(remoteDenom)) {
345343
// This is the first time we've heard of this denomination.

0 commit comments

Comments
 (0)