viem 2.45.3 → 2.46.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 +17 -0
- package/README.md +0 -18
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/chainConfig.js +21 -24
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/concurrent.js +18 -0
- package/_cjs/tempo/internal/concurrent.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/chainConfig.js +26 -25
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/concurrent.js +26 -0
- package/_esm/tempo/internal/concurrent.js.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +2 -2
- package/_types/chains/definitions/tempoAndantino.d.ts +2 -2
- package/_types/chains/definitions/tempoDevnet.d.ts +2 -2
- package/_types/chains/definitions/tempoLocalnet.d.ts +2 -2
- package/_types/chains/definitions/tempoModerato.d.ts +2 -2
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Transaction.d.ts +1 -1
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/concurrent.d.ts +13 -0
- package/_types/tempo/internal/concurrent.d.ts.map +1 -0
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/tempo/Transaction.ts +1 -1
- package/tempo/chainConfig.ts +25 -24
- package/tempo/internal/concurrent.ts +24 -0
- package/_cjs/tempo/internal/nonceKeyStore.js +0 -43
- package/_cjs/tempo/internal/nonceKeyStore.js.map +0 -1
- package/_esm/tempo/internal/nonceKeyStore.js +0 -41
- package/_esm/tempo/internal/nonceKeyStore.js.map +0 -1
- package/_types/tempo/internal/nonceKeyStore.d.ts +0 -26
- package/_types/tempo/internal/nonceKeyStore.d.ts.map +0 -1
- package/tempo/internal/nonceKeyStore.ts +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# viem
|
|
2
2
|
|
|
3
|
+
## 2.46.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4304](https://github.com/wevm/viem/pull/4304) [`b6b50d40fb6bbadc851377b74b2dd4da584958b0`](https://github.com/wevm/viem/commit/b6b50d40fb6bbadc851377b74b2dd4da584958b0) Thanks [@jxom](https://github.com/jxom)! - **Breaking (`viem/tempo`):** Renamed `nonceKey: 'random'` to `nonceKey: 'expiring'` to align with [TIP-1009](https://docs.tempo.xyz/protocol/tips/tip-1009) terminology.
|
|
8
|
+
|
|
9
|
+
TIP-1009 defines "expiring nonces" as time-based replay protection using `validBefore` timestamps. The name `'expiring'` better describes the mechanism than `'random'`.
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
await sendTransaction(client, {
|
|
13
|
+
account,
|
|
14
|
+
- nonceKey: 'random',
|
|
15
|
+
+ nonceKey: 'expiring',
|
|
16
|
+
to: '0x...',
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
3
20
|
## 2.45.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -189,36 +189,18 @@ Check out the following places for more viem-related content:
|
|
|
189
189
|
<img alt="relay logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/relay-light.svg" width="auto" height="50">
|
|
190
190
|
</picture>
|
|
191
191
|
</a>
|
|
192
|
-
<a href="https://uniswap.org">
|
|
193
|
-
<picture>
|
|
194
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/uniswap-dark.svg">
|
|
195
|
-
<img alt="uniswap logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/uniswap-light.svg" width="auto" height="50">
|
|
196
|
-
</picture>
|
|
197
|
-
</a>
|
|
198
192
|
<a href="https://polymarket.com">
|
|
199
193
|
<picture>
|
|
200
194
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/polymarket-dark.svg">
|
|
201
195
|
<img alt="polymarket logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/polymarket-light.svg" width="auto" height="50">
|
|
202
196
|
</picture>
|
|
203
197
|
</a>
|
|
204
|
-
<a href="https://routescan.io">
|
|
205
|
-
<picture>
|
|
206
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/routescan-dark.svg">
|
|
207
|
-
<img alt="routescan logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/routescan-light.svg" width="auto" height="50">
|
|
208
|
-
</picture>
|
|
209
|
-
</a>
|
|
210
198
|
<a href="https://sequence.xyz">
|
|
211
199
|
<picture>
|
|
212
200
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sequence-dark.svg">
|
|
213
201
|
<img alt="sequence logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/sequence-light.svg" width="auto" height="50">
|
|
214
202
|
</picture>
|
|
215
203
|
</a>
|
|
216
|
-
<a href="https://gemini.com">
|
|
217
|
-
<picture>
|
|
218
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/gemini-dark.svg">
|
|
219
|
-
<img alt="gemini logo" src="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/gemini-light.svg" width="auto" height="50">
|
|
220
|
-
</picture>
|
|
221
|
-
</a>
|
|
222
204
|
<a href="https://web3auth.io">
|
|
223
205
|
<picture>
|
|
224
206
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wevm/.github/main/content/sponsors/web3auth-dark.svg">
|
package/_cjs/errors/version.js
CHANGED
|
@@ -4,14 +4,16 @@ exports.chainConfig = void 0;
|
|
|
4
4
|
const tempo_1 = require("ox/tempo");
|
|
5
5
|
const getCode_js_1 = require("../actions/public/getCode.js");
|
|
6
6
|
const verifyHash_js_1 = require("../actions/public/verifyHash.js");
|
|
7
|
+
const number_js_1 = require("../constants/number.js");
|
|
7
8
|
const defineChain_js_1 = require("../utils/chain/defineChain.js");
|
|
8
9
|
const transaction_js_1 = require("../utils/formatters/transaction.js");
|
|
9
10
|
const transactionReceipt_js_1 = require("../utils/formatters/transactionReceipt.js");
|
|
10
11
|
const transactionRequest_js_1 = require("../utils/formatters/transactionRequest.js");
|
|
11
12
|
const getAction_js_1 = require("../utils/getAction.js");
|
|
12
13
|
const Formatters = require("./Formatters.js");
|
|
13
|
-
const
|
|
14
|
+
const Concurrent = require("./internal/concurrent.js");
|
|
14
15
|
const Transaction = require("./Transaction.js");
|
|
16
|
+
const maxExpirySecs = 25;
|
|
15
17
|
exports.chainConfig = {
|
|
16
18
|
blockTime: 1_000,
|
|
17
19
|
extendSchema: (0, defineChain_js_1.extendSchema)(),
|
|
@@ -36,30 +38,25 @@ exports.chainConfig = {
|
|
|
36
38
|
request.gas = (request.gas ?? 0n) + 20000n;
|
|
37
39
|
return request;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const nonceKey = NonceKeyStore.getNonceKey(NonceKeyStore.store, {
|
|
49
|
-
address,
|
|
50
|
-
chainId: request.chain.id,
|
|
51
|
-
});
|
|
52
|
-
if (nonceKey === 0n)
|
|
53
|
-
return undefined;
|
|
54
|
-
return nonceKey;
|
|
55
|
-
})();
|
|
56
|
-
request.nonce = (() => {
|
|
57
|
-
if (typeof request.nonce === 'number')
|
|
58
|
-
return request.nonce;
|
|
59
|
-
if (request.nonceKey)
|
|
60
|
-
return 0;
|
|
61
|
-
return undefined;
|
|
41
|
+
const useExpiringNonce = await (async () => {
|
|
42
|
+
if (request.nonceKey === 'expiring')
|
|
43
|
+
return true;
|
|
44
|
+
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
45
|
+
return true;
|
|
46
|
+
const address = request.account?.address;
|
|
47
|
+
if (address && typeof request.nonceKey === 'undefined')
|
|
48
|
+
return await Concurrent.detect(address);
|
|
49
|
+
return false;
|
|
62
50
|
})();
|
|
51
|
+
if (useExpiringNonce) {
|
|
52
|
+
request.nonceKey = number_js_1.maxUint256;
|
|
53
|
+
request.nonce = 0;
|
|
54
|
+
if (typeof request.validBefore === 'undefined')
|
|
55
|
+
request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs;
|
|
56
|
+
}
|
|
57
|
+
else if (typeof request.nonceKey !== 'undefined') {
|
|
58
|
+
request.nonce = typeof request.nonce === 'number' ? request.nonce : 0;
|
|
59
|
+
}
|
|
63
60
|
if (!request.feeToken && request.chain?.feeToken)
|
|
64
61
|
request.feeToken = request.chain.feeToken;
|
|
65
62
|
return request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainConfig.js","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":";;;AAAA,oCAA0D;AAC1D,6DAAsD;AACtD,mEAA4D;
|
|
1
|
+
{"version":3,"file":"chainConfig.js","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":";;;AAAA,oCAA0D;AAC1D,6DAAsD;AACtD,mEAA4D;AAC5D,sDAAmD;AAEnD,kEAA4D;AAC5D,uEAAsE;AACtE,qFAAoF;AACpF,qFAAoF;AACpF,wDAAiD;AAGjD,8CAA6C;AAC7C,uDAAsD;AACtD,gDAA+C;AAE/C,MAAM,aAAa,GAAG,EAAE,CAAA;AAEX,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,KAAK;IAChB,YAAY,EAAE,IAAA,6BAAY,GAEtB;IACJ,UAAU,EAAE;QACV,WAAW,EAAE,IAAA,kCAAiB,EAAC;YAC7B,OAAO,EAAE,CAAC,qBAA8B,CAAC;YACzC,MAAM,EAAE,UAAU,CAAC,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WAAW;oBACnC,QAAQ,EAAE,UAAU,CAAC,QAAQ;iBACrB,CAAC,CAAA;gBAEX,IAEE,CAAC,IAAI;oBAEL,IAAI,KAAK,kDAAkD;oBAE3D,OAAO,yBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE;wBACxC,OAAO;wBACP,OAAO,EAAE,IAAI;qBACd,CAAC,CAAA;YACN,CAAC;QACH,CAAC;QAED,OAAO,MAAM,IAAA,wBAAS,EACpB,MAAM,EACN,0BAAU,EACV,YAAY,CACb,CAAC,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CAC0D,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detect = detect;
|
|
4
|
+
const concurrentCounts = new Map();
|
|
5
|
+
async function detect(key) {
|
|
6
|
+
concurrentCounts.set(key, (concurrentCounts.get(key) ?? 0) + 1);
|
|
7
|
+
await Promise.resolve();
|
|
8
|
+
const isConcurrent = (concurrentCounts.get(key) ?? 0) > 1;
|
|
9
|
+
queueMicrotask(() => {
|
|
10
|
+
const count = concurrentCounts.get(key) ?? 0;
|
|
11
|
+
if (count <= 1)
|
|
12
|
+
concurrentCounts.delete(key);
|
|
13
|
+
else
|
|
14
|
+
concurrentCounts.set(key, count - 1);
|
|
15
|
+
});
|
|
16
|
+
return isConcurrent;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=concurrent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrent.js","sourceRoot":"","sources":["../../../tempo/internal/concurrent.ts"],"names":[],"mappings":";;AAaA,wBAUC;AAvBD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAA;AAa3C,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IACvB,MAAM,YAAY,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACzD,cAAc,CAAC,GAAG,EAAE;QAClB,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC5C,IAAI,KAAK,IAAI,CAAC;YAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;;YACvC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IACF,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
package/_esm/errors/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.46.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { SignatureEnvelope } from 'ox/tempo';
|
|
2
2
|
import { getCode } from '../actions/public/getCode.js';
|
|
3
3
|
import { verifyHash } from '../actions/public/verifyHash.js';
|
|
4
|
+
import { maxUint256 } from '../constants/number.js';
|
|
4
5
|
import { extendSchema } from '../utils/chain/defineChain.js';
|
|
5
6
|
import { defineTransaction } from '../utils/formatters/transaction.js';
|
|
6
7
|
import { defineTransactionReceipt } from '../utils/formatters/transactionReceipt.js';
|
|
7
8
|
import { defineTransactionRequest } from '../utils/formatters/transactionRequest.js';
|
|
8
9
|
import { getAction } from '../utils/getAction.js';
|
|
9
10
|
import * as Formatters from './Formatters.js';
|
|
10
|
-
import * as
|
|
11
|
+
import * as Concurrent from './internal/concurrent.js';
|
|
11
12
|
import * as Transaction from './Transaction.js';
|
|
13
|
+
const maxExpirySecs = 25;
|
|
12
14
|
export const chainConfig = {
|
|
13
15
|
blockTime: 1_000,
|
|
14
16
|
extendSchema: extendSchema(),
|
|
@@ -34,31 +36,30 @@ export const chainConfig = {
|
|
|
34
36
|
request.gas = (request.gas ?? 0n) + 20000n;
|
|
35
37
|
return request;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (nonceKey === 0n)
|
|
51
|
-
return undefined;
|
|
52
|
-
return nonceKey;
|
|
53
|
-
})();
|
|
54
|
-
request.nonce = (() => {
|
|
55
|
-
if (typeof request.nonce === 'number')
|
|
56
|
-
return request.nonce;
|
|
57
|
-
// TODO: remove this line once `eth_fillTransaction` supports nonce keys.
|
|
58
|
-
if (request.nonceKey)
|
|
59
|
-
return 0;
|
|
60
|
-
return undefined;
|
|
39
|
+
// Use expiring nonces for concurrent transactions (TIP-1009).
|
|
40
|
+
// When nonceKey is 'expiring', feePayer is specified, or concurrent requests
|
|
41
|
+
// are detected, we use expiring nonces (nonceKey = uint256.max) with a
|
|
42
|
+
// validBefore timestamp.
|
|
43
|
+
const useExpiringNonce = await (async () => {
|
|
44
|
+
if (request.nonceKey === 'expiring')
|
|
45
|
+
return true;
|
|
46
|
+
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
47
|
+
return true;
|
|
48
|
+
const address = request.account?.address;
|
|
49
|
+
if (address && typeof request.nonceKey === 'undefined')
|
|
50
|
+
return await Concurrent.detect(address);
|
|
51
|
+
return false;
|
|
61
52
|
})();
|
|
53
|
+
if (useExpiringNonce) {
|
|
54
|
+
request.nonceKey = maxUint256;
|
|
55
|
+
request.nonce = 0;
|
|
56
|
+
if (typeof request.validBefore === 'undefined')
|
|
57
|
+
request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs;
|
|
58
|
+
}
|
|
59
|
+
else if (typeof request.nonceKey !== 'undefined') {
|
|
60
|
+
// Explicit nonceKey provided (2D nonce mode)
|
|
61
|
+
request.nonce = typeof request.nonce === 'number' ? request.nonce : 0;
|
|
62
|
+
}
|
|
62
63
|
if (!request.feeToken && request.chain?.feeToken)
|
|
63
64
|
request.feeToken = request.chain.feeToken;
|
|
64
65
|
return request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainConfig.js","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,UAAU,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"chainConfig.js","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAgB,MAAM,UAAU,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGjD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAA;AACtD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C,MAAM,aAAa,GAAG,EAAE,CAAA;AA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OAAO,SAAS,KAAK,QAAQ;YAC7B,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACzD,CAAC;YACD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YACzD,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACjC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE;oBACjC,OAAO;oBACP,WAAW,EAAE,UAAU,CAAC,WAAW;oBACnC,QAAQ,EAAE,UAAU,CAAC,QAAQ;iBACrB,CAAC,CAAA;gBACX,8DAA8D;gBAC9D;gBACE,uBAAuB;gBACvB,CAAC,IAAI;oBACL,iCAAiC;oBACjC,IAAI,KAAK,kDAAkD;oBAE3D,OAAO,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE;wBACxC,OAAO;wBACP,OAAO,EAAE,IAAI;qBACd,CAAC,CAAA;YACN,CAAC;QACH,CAAC;QAED,OAAO,MAAM,SAAS,CACpB,MAAM,EACN,UAAU,EACV,YAAY,CACb,CAAC,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CAC0D,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const concurrentCounts = new Map();
|
|
2
|
+
/**
|
|
3
|
+
* Detects if there are concurrent tasks occuring for a given key
|
|
4
|
+
* within the same event loop tick. Registers the request, yields to allow
|
|
5
|
+
* other concurrent calls to register, then returns whether multiple requests
|
|
6
|
+
* were detected.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const isConcurrent = await Concurrent.detect(address)
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export async function detect(key) {
|
|
14
|
+
concurrentCounts.set(key, (concurrentCounts.get(key) ?? 0) + 1);
|
|
15
|
+
await Promise.resolve();
|
|
16
|
+
const isConcurrent = (concurrentCounts.get(key) ?? 0) > 1;
|
|
17
|
+
queueMicrotask(() => {
|
|
18
|
+
const count = concurrentCounts.get(key) ?? 0;
|
|
19
|
+
if (count <= 1)
|
|
20
|
+
concurrentCounts.delete(key);
|
|
21
|
+
else
|
|
22
|
+
concurrentCounts.set(key, count - 1);
|
|
23
|
+
});
|
|
24
|
+
return isConcurrent;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=concurrent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrent.js","sourceRoot":"","sources":["../../../tempo/internal/concurrent.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAA;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IACvB,MAAM,YAAY,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACzD,cAAc,CAAC,GAAG,EAAE;QAClB,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC5C,IAAI,KAAK,IAAI,CAAC;YAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;;YACvC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IACF,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
|
@@ -440,7 +440,7 @@ export declare const tempo: {
|
|
|
440
440
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
441
441
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
442
442
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
443
|
-
nonceKey?: `0x${string}` | "
|
|
443
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
444
444
|
validBefore?: `0x${string}` | undefined;
|
|
445
445
|
validAfter?: `0x${string}` | undefined;
|
|
446
446
|
blobs?: undefined;
|
|
@@ -890,7 +890,7 @@ export declare const tempo: {
|
|
|
890
890
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
891
891
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
892
892
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
893
|
-
nonceKey?: `0x${string}` | "
|
|
893
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
894
894
|
validBefore?: `0x${string}` | undefined;
|
|
895
895
|
validAfter?: `0x${string}` | undefined;
|
|
896
896
|
blobs?: undefined;
|
|
@@ -440,7 +440,7 @@ export declare const tempoAndantino: {
|
|
|
440
440
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
441
441
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
442
442
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
443
|
-
nonceKey?: `0x${string}` | "
|
|
443
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
444
444
|
validBefore?: `0x${string}` | undefined;
|
|
445
445
|
validAfter?: `0x${string}` | undefined;
|
|
446
446
|
blobs?: undefined;
|
|
@@ -890,7 +890,7 @@ export declare const tempoAndantino: {
|
|
|
890
890
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
891
891
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
892
892
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
893
|
-
nonceKey?: `0x${string}` | "
|
|
893
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
894
894
|
validBefore?: `0x${string}` | undefined;
|
|
895
895
|
validAfter?: `0x${string}` | undefined;
|
|
896
896
|
blobs?: undefined;
|
|
@@ -440,7 +440,7 @@ export declare const tempoDevnet: {
|
|
|
440
440
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
441
441
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
442
442
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
443
|
-
nonceKey?: `0x${string}` | "
|
|
443
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
444
444
|
validBefore?: `0x${string}` | undefined;
|
|
445
445
|
validAfter?: `0x${string}` | undefined;
|
|
446
446
|
blobs?: undefined;
|
|
@@ -890,7 +890,7 @@ export declare const tempoDevnet: {
|
|
|
890
890
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
891
891
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
892
892
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
893
|
-
nonceKey?: `0x${string}` | "
|
|
893
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
894
894
|
validBefore?: `0x${string}` | undefined;
|
|
895
895
|
validAfter?: `0x${string}` | undefined;
|
|
896
896
|
blobs?: undefined;
|
|
@@ -445,7 +445,7 @@ export declare const tempoLocalnet: {
|
|
|
445
445
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
446
446
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
447
447
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
448
|
-
nonceKey?: `0x${string}` | "
|
|
448
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
449
449
|
validBefore?: `0x${string}` | undefined;
|
|
450
450
|
validAfter?: `0x${string}` | undefined;
|
|
451
451
|
blobs?: undefined;
|
|
@@ -888,7 +888,7 @@ export declare const tempoLocalnet: {
|
|
|
888
888
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
889
889
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
890
890
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
891
|
-
nonceKey?: `0x${string}` | "
|
|
891
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
892
892
|
validBefore?: `0x${string}` | undefined;
|
|
893
893
|
validAfter?: `0x${string}` | undefined;
|
|
894
894
|
blobs?: undefined;
|
|
@@ -440,7 +440,7 @@ export declare const tempoModerato: {
|
|
|
440
440
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
441
441
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
442
442
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
443
|
-
nonceKey?: `0x${string}` | "
|
|
443
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
444
444
|
validBefore?: `0x${string}` | undefined;
|
|
445
445
|
validAfter?: `0x${string}` | undefined;
|
|
446
446
|
blobs?: undefined;
|
|
@@ -890,7 +890,7 @@ export declare const tempoModerato: {
|
|
|
890
890
|
calls?: readonly import("ox/tempo/TxEnvelopeTempo").Call<`0x${string}`>[] | undefined;
|
|
891
891
|
feePayer?: true | import("../../index.js").Account | undefined;
|
|
892
892
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
893
|
-
nonceKey?: `0x${string}` | "
|
|
893
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
894
894
|
validBefore?: `0x${string}` | undefined;
|
|
895
895
|
validAfter?: `0x${string}` | undefined;
|
|
896
896
|
blobs?: undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.46.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -41,7 +41,7 @@ export type TransactionRequestTempo<quantity = bigint, index = number, type = 't
|
|
|
41
41
|
calls?: readonly TxTempo.Call<quantity>[] | undefined;
|
|
42
42
|
feePayer?: Account | true | undefined;
|
|
43
43
|
feeToken?: Address | bigint | undefined;
|
|
44
|
-
nonceKey?: '
|
|
44
|
+
nonceKey?: 'expiring' | quantity | undefined;
|
|
45
45
|
validBefore?: index | undefined;
|
|
46
46
|
validAfter?: index | undefined;
|
|
47
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../tempo/Transaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAG7B,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,IAAI,qBAAqB,EAChD,iBAAiB,EACjB,eAAe,IAAI,OAAO,EAC3B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,KAAK,EACV,cAAc,IAAI,mBAAmB,EACrC,qBAAqB,IAAI,0BAA0B,EACpD,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,WAAW,IAAI,gBAAgB,EAC/B,kBAAkB,IAAI,uBAAuB,EAC7C,kBAAkB,IAAI,uBAAuB,EAC7C,uBAAuB,IAAI,4BAA4B,EACvD,qBAAqB,IAAI,0BAA0B,EACnD,eAAe,IAAI,oBAAoB,EACxC,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,m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CAAC,IAAI,CAAC,GAAG,0BAA0B,CAAA;AAEjE,MAAM,MAAM,0BAA0B,GAAG,OAAO,MAAM,EAAE,CAAA;AAExD,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,OAAO,CAAA;AAE5D,wBAAgB,OAAO,CACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,WAAW,CAAC,MAAM,CAAC,CAkBrB;AAED,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAO3D;AAED,wBAAgB,WAAW,CACzB,KAAK,CAAC,UAAU,SAAS,4BAA4B,EACrD,qBAAqB,EAAE,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAaxE;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,KAAY,WAAW,CACrB,UAAU,SACR,4BAA4B,GAAG,4BAA4B,IAC3D,UAAU,SAAS,0BAA0B,GAC7C,4BAA4B,GAC5B,0BAA0B,CAAC,UAAU,CAAC,CAAA;CAC3C;AAED,wBAAsB,SAAS,CAC7B,WAAW,EAAE,uBAAuB,GAAG;IACrC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;IACrC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC3B,EACD,SAAS,CAAC,EACN,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,GAAG,cAAc,CAAC,GAC3D,SAAS,0BA6Bd;AAuID,OAAO;AACL,kBAAkB;AAClB,gBAAgB,IAAI,kBAAkB;AACtC,kBAAkB;AAClB,iBAAiB,IAAI,mBAAmB;AACxC,kBAAkB;AAClB,eAAe,IAAI,iBAAiB,GACrC,MAAM,UAAU,CAAA"}
|
|
@@ -409,7 +409,7 @@ export declare const chainConfig: {
|
|
|
409
409
|
calls?: readonly Transaction.z_TxEnvelopeTempo.Call<`0x${string}`>[] | undefined;
|
|
410
410
|
feePayer?: true | import("../index.js").Account | undefined;
|
|
411
411
|
feeToken?: bigint | `0x${string}` | undefined;
|
|
412
|
-
nonceKey?: `0x${string}` | "
|
|
412
|
+
nonceKey?: `0x${string}` | "expiring" | undefined;
|
|
413
413
|
validBefore?: `0x${string}` | undefined;
|
|
414
414
|
validAfter?: `0x${string}` | undefined;
|
|
415
415
|
blobs?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chainConfig.d.ts","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"chainConfig.d.ts","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAA;AAU1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAA;AAI1F,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAI/C,eAAO,MAAM,WAAW;;;mBAGT,OAAO,CAAC,gBAAgB,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAmEK,sBAAsB;;;CAwCjB,CAAA;AAE7D,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects if there are concurrent tasks occuring for a given key
|
|
3
|
+
* within the same event loop tick. Registers the request, yields to allow
|
|
4
|
+
* other concurrent calls to register, then returns whether multiple requests
|
|
5
|
+
* were detected.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const isConcurrent = await Concurrent.detect(address)
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function detect(key: string): Promise<boolean>;
|
|
13
|
+
//# sourceMappingURL=concurrent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrent.d.ts","sourceRoot":"","sources":["../../../tempo/internal/concurrent.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU1D"}
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.46.0'
|
package/package.json
CHANGED
package/tempo/Transaction.ts
CHANGED
|
@@ -121,7 +121,7 @@ export type TransactionRequestTempo<
|
|
|
121
121
|
calls?: readonly TxTempo.Call<quantity>[] | undefined
|
|
122
122
|
feePayer?: Account | true | undefined
|
|
123
123
|
feeToken?: Address | bigint | undefined
|
|
124
|
-
nonceKey?: '
|
|
124
|
+
nonceKey?: 'expiring' | quantity | undefined
|
|
125
125
|
validBefore?: index | undefined
|
|
126
126
|
validAfter?: index | undefined
|
|
127
127
|
}
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SignatureEnvelope, type TokenId } from 'ox/tempo'
|
|
2
2
|
import { getCode } from '../actions/public/getCode.js'
|
|
3
3
|
import { verifyHash } from '../actions/public/verifyHash.js'
|
|
4
|
+
import { maxUint256 } from '../constants/number.js'
|
|
4
5
|
import type { Chain, ChainConfig as viem_ChainConfig } from '../types/chain.js'
|
|
5
6
|
import { extendSchema } from '../utils/chain/defineChain.js'
|
|
6
7
|
import { defineTransaction } from '../utils/formatters/transaction.js'
|
|
@@ -10,9 +11,11 @@ import { getAction } from '../utils/getAction.js'
|
|
|
10
11
|
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
|
11
12
|
import type { Account } from './Account.js'
|
|
12
13
|
import * as Formatters from './Formatters.js'
|
|
13
|
-
import * as
|
|
14
|
+
import * as Concurrent from './internal/concurrent.js'
|
|
14
15
|
import * as Transaction from './Transaction.js'
|
|
15
16
|
|
|
17
|
+
const maxExpirySecs = 25
|
|
18
|
+
|
|
16
19
|
export const chainConfig = {
|
|
17
20
|
blockTime: 1_000,
|
|
18
21
|
extendSchema: extendSchema<{
|
|
@@ -49,31 +52,29 @@ export const chainConfig = {
|
|
|
49
52
|
return request as unknown as typeof r
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
chainId: request.chain.id,
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
if (nonceKey === 0n) return undefined
|
|
68
|
-
return nonceKey
|
|
55
|
+
// Use expiring nonces for concurrent transactions (TIP-1009).
|
|
56
|
+
// When nonceKey is 'expiring', feePayer is specified, or concurrent requests
|
|
57
|
+
// are detected, we use expiring nonces (nonceKey = uint256.max) with a
|
|
58
|
+
// validBefore timestamp.
|
|
59
|
+
const useExpiringNonce = await (async () => {
|
|
60
|
+
if (request.nonceKey === 'expiring') return true
|
|
61
|
+
if (request.feePayer && typeof request.nonceKey === 'undefined')
|
|
62
|
+
return true
|
|
63
|
+
const address = request.account?.address
|
|
64
|
+
if (address && typeof request.nonceKey === 'undefined')
|
|
65
|
+
return await Concurrent.detect(address)
|
|
66
|
+
return false
|
|
69
67
|
})()
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (request.
|
|
75
|
-
|
|
76
|
-
}
|
|
69
|
+
if (useExpiringNonce) {
|
|
70
|
+
request.nonceKey = maxUint256
|
|
71
|
+
request.nonce = 0
|
|
72
|
+
if (typeof request.validBefore === 'undefined')
|
|
73
|
+
request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs
|
|
74
|
+
} else if (typeof request.nonceKey !== 'undefined') {
|
|
75
|
+
// Explicit nonceKey provided (2D nonce mode)
|
|
76
|
+
request.nonce = typeof request.nonce === 'number' ? request.nonce : 0
|
|
77
|
+
}
|
|
77
78
|
|
|
78
79
|
if (!request.feeToken && request.chain?.feeToken)
|
|
79
80
|
request.feeToken = request.chain.feeToken
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const concurrentCounts = new Map<string, number>()
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Detects if there are concurrent tasks occuring for a given key
|
|
5
|
+
* within the same event loop tick. Registers the request, yields to allow
|
|
6
|
+
* other concurrent calls to register, then returns whether multiple requests
|
|
7
|
+
* were detected.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const isConcurrent = await Concurrent.detect(address)
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export async function detect(key: string): Promise<boolean> {
|
|
15
|
+
concurrentCounts.set(key, (concurrentCounts.get(key) ?? 0) + 1)
|
|
16
|
+
await Promise.resolve()
|
|
17
|
+
const isConcurrent = (concurrentCounts.get(key) ?? 0) > 1
|
|
18
|
+
queueMicrotask(() => {
|
|
19
|
+
const count = concurrentCounts.get(key) ?? 0
|
|
20
|
+
if (count <= 1) concurrentCounts.delete(key)
|
|
21
|
+
else concurrentCounts.set(key, count - 1)
|
|
22
|
+
})
|
|
23
|
+
return isConcurrent
|
|
24
|
+
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.store = void 0;
|
|
4
|
-
exports.create = create;
|
|
5
|
-
exports.getCacheKey = getCacheKey;
|
|
6
|
-
exports.getEntry = getEntry;
|
|
7
|
-
exports.reset = reset;
|
|
8
|
-
exports.getNonceKey = getNonceKey;
|
|
9
|
-
const Hex = require("ox/Hex");
|
|
10
|
-
exports.store = create();
|
|
11
|
-
function create() {
|
|
12
|
-
return new Map();
|
|
13
|
-
}
|
|
14
|
-
function getCacheKey(parameters) {
|
|
15
|
-
return `${parameters.address.toLowerCase()}-${parameters.chainId}`;
|
|
16
|
-
}
|
|
17
|
-
function getEntry(store, parameters) {
|
|
18
|
-
const key = getCacheKey(parameters);
|
|
19
|
-
let entry = store.get(key);
|
|
20
|
-
if (!entry) {
|
|
21
|
-
entry = { counter: 0, resetScheduled: false };
|
|
22
|
-
store.set(key, entry);
|
|
23
|
-
}
|
|
24
|
-
return entry;
|
|
25
|
-
}
|
|
26
|
-
function reset(store, parameters) {
|
|
27
|
-
const entry = getEntry(store, parameters);
|
|
28
|
-
entry.counter = 0;
|
|
29
|
-
entry.resetScheduled = false;
|
|
30
|
-
}
|
|
31
|
-
function getNonceKey(store, parameters) {
|
|
32
|
-
const entry = getEntry(store, parameters);
|
|
33
|
-
if (!entry.resetScheduled) {
|
|
34
|
-
entry.resetScheduled = true;
|
|
35
|
-
queueMicrotask(() => reset(store, parameters));
|
|
36
|
-
}
|
|
37
|
-
const count = entry.counter;
|
|
38
|
-
entry.counter++;
|
|
39
|
-
if (count === 0)
|
|
40
|
-
return 0n;
|
|
41
|
-
return Hex.toBigInt(Hex.random(6));
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=nonceKeyStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|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cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAA;IAC3B,KAAK,CAAC,OAAO,EAAE,CAAA;IACf,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAC1B,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as Hex from 'ox/Hex';
|
|
2
|
-
/** @internal */
|
|
3
|
-
export const store = /*#__PURE__*/ create();
|
|
4
|
-
/** @internal */
|
|
5
|
-
export function create() {
|
|
6
|
-
return new Map();
|
|
7
|
-
}
|
|
8
|
-
/** @internal */
|
|
9
|
-
export function getCacheKey(parameters) {
|
|
10
|
-
return `${parameters.address.toLowerCase()}-${parameters.chainId}`;
|
|
11
|
-
}
|
|
12
|
-
/** @internal */
|
|
13
|
-
export function getEntry(store, parameters) {
|
|
14
|
-
const key = getCacheKey(parameters);
|
|
15
|
-
let entry = store.get(key);
|
|
16
|
-
if (!entry) {
|
|
17
|
-
entry = { counter: 0, resetScheduled: false };
|
|
18
|
-
store.set(key, entry);
|
|
19
|
-
}
|
|
20
|
-
return entry;
|
|
21
|
-
}
|
|
22
|
-
/** @internal */
|
|
23
|
-
export function reset(store, parameters) {
|
|
24
|
-
const entry = getEntry(store, parameters);
|
|
25
|
-
entry.counter = 0;
|
|
26
|
-
entry.resetScheduled = false;
|
|
27
|
-
}
|
|
28
|
-
/** @internal */
|
|
29
|
-
export function getNonceKey(store, parameters) {
|
|
30
|
-
const entry = getEntry(store, parameters);
|
|
31
|
-
if (!entry.resetScheduled) {
|
|
32
|
-
entry.resetScheduled = true;
|
|
33
|
-
queueMicrotask(() => reset(store, parameters));
|
|
34
|
-
}
|
|
35
|
-
const count = entry.counter;
|
|
36
|
-
entry.counter++;
|
|
37
|
-
if (count === 0)
|
|
38
|
-
return 0n;
|
|
39
|
-
return Hex.toBigInt(Hex.random(6));
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=nonceKeyStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nonceKeyStore.js","sourceRoot":"","sources":["../../../tempo/internal/nonceKeyStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAM7B,gBAAgB;AAChB,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,EAAE,CAAA;AAE3C,gBAAgB;AAChB,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,GAAG,EAAE,CAAA;AAClB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,WAAW,CAAC,UAAsB;IAChD,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,UAAU,CAAC,OAAO,EAAE,CAAA;AACpE,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,QAAQ,CAAC,KAAY,EAAE,UAAsB;IAC3D,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;IACnC,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAA;QAC7C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACvB,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,KAAK,CAAC,KAAY,EAAE,UAAsB;IACxD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IACzC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAA;IACjB,KAAK,CAAC,cAAc,GAAG,KAAK,CAAA;AAC9B,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,UAAsB;IAC9D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IACzC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;QAC1B,KAAK,CAAC,cAAc,GAAG,IAAI,CAAA;QAC3B,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAA;IAC3B,KAAK,CAAC,OAAO,EAAE,CAAA;IACf,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAC1B,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Address } from 'abitype';
|
|
2
|
-
type Parameters = {
|
|
3
|
-
address: Address;
|
|
4
|
-
chainId: number;
|
|
5
|
-
};
|
|
6
|
-
type Store = Map<string, {
|
|
7
|
-
counter: number;
|
|
8
|
-
resetScheduled: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
/** @internal */
|
|
11
|
-
export declare const store: Store;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare function create(): Store;
|
|
14
|
-
/** @internal */
|
|
15
|
-
export declare function getCacheKey(parameters: Parameters): string;
|
|
16
|
-
/** @internal */
|
|
17
|
-
export declare function getEntry(store: Store, parameters: Parameters): {
|
|
18
|
-
counter: number;
|
|
19
|
-
resetScheduled: boolean;
|
|
20
|
-
};
|
|
21
|
-
/** @internal */
|
|
22
|
-
export declare function reset(store: Store, parameters: Parameters): void;
|
|
23
|
-
/** @internal */
|
|
24
|
-
export declare function getNonceKey(store: Store, parameters: Parameters): bigint;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=nonceKeyStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nonceKeyStore.d.ts","sourceRoot":"","sources":["../../../tempo/internal/nonceKeyStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGtC,KAAK,UAAU,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvD,KAAK,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAEtE,gBAAgB;AAChB,eAAO,MAAM,KAAK,OAAyB,CAAA;AAE3C,gBAAgB;AAChB,wBAAgB,MAAM,IAAI,KAAK,CAE9B;AAED,gBAAgB;AAChB,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,UAEjD;AAED,gBAAgB;AAChB,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU;aAhBzB,MAAM;oBAAkB,OAAO;EAwBlE;AAED,gBAAgB;AAChB,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,QAIzD;AAED,gBAAgB;AAChB,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,UAU/D"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Address } from 'abitype'
|
|
2
|
-
import * as Hex from 'ox/Hex'
|
|
3
|
-
|
|
4
|
-
type Parameters = { address: Address; chainId: number }
|
|
5
|
-
|
|
6
|
-
type Store = Map<string, { counter: number; resetScheduled: boolean }>
|
|
7
|
-
|
|
8
|
-
/** @internal */
|
|
9
|
-
export const store = /*#__PURE__*/ create()
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export function create(): Store {
|
|
13
|
-
return new Map()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export function getCacheKey(parameters: Parameters) {
|
|
18
|
-
return `${parameters.address.toLowerCase()}-${parameters.chainId}`
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** @internal */
|
|
22
|
-
export function getEntry(store: Store, parameters: Parameters) {
|
|
23
|
-
const key = getCacheKey(parameters)
|
|
24
|
-
let entry = store.get(key)
|
|
25
|
-
if (!entry) {
|
|
26
|
-
entry = { counter: 0, resetScheduled: false }
|
|
27
|
-
store.set(key, entry)
|
|
28
|
-
}
|
|
29
|
-
return entry
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** @internal */
|
|
33
|
-
export function reset(store: Store, parameters: Parameters) {
|
|
34
|
-
const entry = getEntry(store, parameters)
|
|
35
|
-
entry.counter = 0
|
|
36
|
-
entry.resetScheduled = false
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** @internal */
|
|
40
|
-
export function getNonceKey(store: Store, parameters: Parameters) {
|
|
41
|
-
const entry = getEntry(store, parameters)
|
|
42
|
-
if (!entry.resetScheduled) {
|
|
43
|
-
entry.resetScheduled = true
|
|
44
|
-
queueMicrotask(() => reset(store, parameters))
|
|
45
|
-
}
|
|
46
|
-
const count = entry.counter
|
|
47
|
-
entry.counter++
|
|
48
|
-
if (count === 0) return 0n
|
|
49
|
-
return Hex.toBigInt(Hex.random(6))
|
|
50
|
-
}
|