viem 2.7.0 → 2.7.1
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 +6 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +5 -5
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/utils/promise/withRetry.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +7 -8
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/utils/promise/withRetry.js.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts +13 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/utils/promise/withRetry.d.ts +4 -3
- package/_types/utils/promise/withRetry.d.ts.map +1 -1
- package/actions/public/waitForTransactionReceipt.ts +20 -7
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/utils/promise/withRetry.ts +16 -14
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# viem
|
2
2
|
|
3
|
+
## 2.7.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [`3c1d790e57c667ded5321d6861d9c5d4cbc38a3a`](https://github.com/wevm/viem/commit/3c1d790e57c667ded5321d6861d9c5d4cbc38a3a) Thanks [@jxom](https://github.com/jxom)! - Added `retryCount` & `retryDelay` as a property to `waitForTransactionReceipt`.
|
8
|
+
|
3
9
|
## 2.7.0
|
4
10
|
|
5
11
|
### Minor Changes
|
@@ -11,7 +11,7 @@ const getBlock_js_1 = require("./getBlock.js");
|
|
11
11
|
const getTransaction_js_1 = require("./getTransaction.js");
|
12
12
|
const getTransactionReceipt_js_1 = require("./getTransactionReceipt.js");
|
13
13
|
const watchBlockNumber_js_1 = require("./watchBlockNumber.js");
|
14
|
-
async function waitForTransactionReceipt(client, { confirmations = 1, hash, onReplaced, pollingInterval = client.pollingInterval, timeout, }) {
|
14
|
+
async function waitForTransactionReceipt(client, { confirmations = 1, hash, onReplaced, pollingInterval = client.pollingInterval, retryCount = 6, retryDelay = ({ count }) => ~~(1 << count) * 200, timeout, }) {
|
15
15
|
const observerId = (0, stringify_js_1.stringify)(['waitForTransactionReceipt', client.uid, hash]);
|
16
16
|
let transaction;
|
17
17
|
let replacedTransaction;
|
@@ -51,8 +51,8 @@ async function waitForTransactionReceipt(client, { confirmations = 1, hash, onRe
|
|
51
51
|
if (transaction.blockNumber)
|
52
52
|
blockNumber = transaction.blockNumber;
|
53
53
|
}, {
|
54
|
-
delay:
|
55
|
-
retryCount
|
54
|
+
delay: retryDelay,
|
55
|
+
retryCount,
|
56
56
|
});
|
57
57
|
retrying = false;
|
58
58
|
}
|
@@ -77,8 +77,8 @@ async function waitForTransactionReceipt(client, { confirmations = 1, hash, onRe
|
|
77
77
|
blockNumber,
|
78
78
|
includeTransactions: true,
|
79
79
|
}), {
|
80
|
-
delay:
|
81
|
-
retryCount
|
80
|
+
delay: retryDelay,
|
81
|
+
retryCount,
|
82
82
|
shouldRetry: ({ error }) => error instanceof block_js_1.BlockNotFoundError,
|
83
83
|
});
|
84
84
|
retrying = false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"waitForTransactionReceipt.js","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":";;;AAEA,oDAA0D;AAC1D,gEAIoC;AAKpC,2DAAoD;AACpD,uDAAuE;AACvE,
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt.js","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":";;;AAEA,oDAA0D;AAC1D,gEAIoC;AAKpC,2DAAoD;AACpD,uDAAuE;AACvE,mEAGyC;AACzC,2DAAoD;AAEpD,+CAAgE;AAChE,2DAI4B;AAC5B,yEAImC;AACnC,+DAG8B;AA6FvB,KAAK,UA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AAC,KAAK,EAC1D,CAAC;oCACD,MAAM,GAAG,UAAU,CAAA;gCACrB,CAAC;qCAAM,IACL,sBAAsB,CAAC,IAAI,KAAK,sBAAsB,CAAC,EAAE;oCACzD,sBAAsB,CAAC,KAAK,KAAK,EAAE,EACnC,CAAC;oCACD,MAAM,GAAG,WAAW,CAAA;gCACtB,CAAC;gCAED,IAAI,CAAC,GAAG,EAAE;oCACR,IAAI,CAAC,UAAU,EAAE,CAAC;wCAChB,MAAM;wCACN,mBAAmB,EAAE,mBAA2B;wCAChD,WAAW,EAAE,sBAAsB;wCACnC,kBAAkB,EAAE,OAAO;qCAC5B,CAAC,CAAA;oCACF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gCACvB,CAAC,CAAC,CAAA;4BACJ,CAAC;4BAAC,OAAO,IAAI,EAAE,CAAC;gCACd,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;4BAC/B,CAAC;wBACH,CAAC;6BAAM,CAAC;4BACN,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;wBAC9B,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC,CAAA;QACJ,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AA9MD,8DA8MC"}
|
package/_cjs/errors/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withRetry.js","sourceRoot":"","sources":["../../../utils/promise/withRetry.ts"],"names":[],"mappings":";;;AACA,wCAAiC;
|
1
|
+
{"version":3,"file":"withRetry.js","sourceRoot":"","sources":["../../../utils/promise/withRetry.ts"],"names":[],"mappings":";;;AACA,wCAAiC;AAmBjC,SAAgB,SAAS,CACvB,EAAwB,EACxB,EACE,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,MACD,EAAE;IAE3B,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,KAAK,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;YAChD,MAAM,KAAK,GAAG,KAAK,EAAE,EAAE,KAAK,EAAoB,EAAE,EAAE;gBAClD,MAAM,KAAK,GACT,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;gBAClE,IAAI,KAAK;oBAAE,MAAM,IAAA,cAAI,EAAC,KAAK,CAAC,CAAA;gBAC5B,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;YACpC,CAAC,CAAA;YAED,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,EAAE,EAAE,CAAA;gBACvB,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,KAAK,GAAG,UAAU;oBAClB,CAAC,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAY,EAAE,CAAC,CAAC;oBAEnD,OAAO,KAAK,CAAC,EAAE,KAAK,EAAE,GAAY,EAAE,CAAC,CAAA;gBACvC,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC;QACH,CAAC,CAAA;QACD,YAAY,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC;AA/BD,8BA+BC"}
|
@@ -2,7 +2,7 @@ import { BlockNotFoundError } from '../../errors/block.js';
|
|
2
2
|
import { TransactionNotFoundError, TransactionReceiptNotFoundError, WaitForTransactionReceiptTimeoutError, } from '../../errors/transaction.js';
|
3
3
|
import { getAction } from '../../utils/getAction.js';
|
4
4
|
import { observe } from '../../utils/observe.js';
|
5
|
-
import { withRetry } from '../../utils/promise/withRetry.js';
|
5
|
+
import { withRetry, } from '../../utils/promise/withRetry.js';
|
6
6
|
import { stringify } from '../../utils/stringify.js';
|
7
7
|
import { getBlock } from './getBlock.js';
|
8
8
|
import { getTransaction, } from './getTransaction.js';
|
@@ -46,7 +46,8 @@ import { watchBlockNumber, } from './watchBlockNumber.js';
|
|
46
46
|
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
47
47
|
* })
|
48
48
|
*/
|
49
|
-
export async function waitForTransactionReceipt(client, { confirmations = 1, hash, onReplaced, pollingInterval = client.pollingInterval,
|
49
|
+
export async function waitForTransactionReceipt(client, { confirmations = 1, hash, onReplaced, pollingInterval = client.pollingInterval, retryCount = 6, retryDelay = ({ count }) => ~~(1 << count) * 200, // exponential backoff
|
50
|
+
timeout, }) {
|
50
51
|
const observerId = stringify(['waitForTransactionReceipt', client.uid, hash]);
|
51
52
|
let transaction;
|
52
53
|
let replacedTransaction;
|
@@ -91,9 +92,8 @@ export async function waitForTransactionReceipt(client, { confirmations = 1, has
|
|
91
92
|
if (transaction.blockNumber)
|
92
93
|
blockNumber = transaction.blockNumber;
|
93
94
|
}, {
|
94
|
-
|
95
|
-
|
96
|
-
retryCount: 6,
|
95
|
+
delay: retryDelay,
|
96
|
+
retryCount,
|
97
97
|
});
|
98
98
|
retrying = false;
|
99
99
|
}
|
@@ -125,9 +125,8 @@ export async function waitForTransactionReceipt(client, { confirmations = 1, has
|
|
125
125
|
blockNumber,
|
126
126
|
includeTransactions: true,
|
127
127
|
}), {
|
128
|
-
|
129
|
-
|
130
|
-
retryCount: 6,
|
128
|
+
delay: retryDelay,
|
129
|
+
retryCount,
|
131
130
|
shouldRetry: ({ error }) => error instanceof BlockNotFoundError,
|
132
131
|
});
|
133
132
|
retrying = false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"waitForTransactionReceipt.js","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,qCAAqC,GACtC,MAAM,6BAA6B,CAAA;AAKpC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt.js","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,qCAAqC,GACtC,MAAM,6BAA6B,CAAA;AAKpC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAEL,SAAS,GACV,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,EAA0B,QAAQ,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAGL,cAAc,GACf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAGL,qBAAqB,GACtB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAEL,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAuD9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAG7C,MAAiC,EACjC,EACE,aAAa,GAAG,CAAC,EACjB,IAAI,EACJ,UAAU,EACV,eAAe,GAAG,MAAM,CAAC,eAAe,EACxC,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK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A;gCACrB,CAAC;qCAAM,IACL,sBAAsB,CAAC,IAAI,KAAK,sBAAsB,CAAC,EAAE;oCACzD,sBAAsB,CAAC,KAAK,KAAK,EAAE,EACnC,CAAC;oCACD,MAAM,GAAG,WAAW,CAAA;gCACtB,CAAC;gCAED,IAAI,CAAC,GAAG,EAAE;oCACR,IAAI,CAAC,UAAU,EAAE,CAAC;wCAChB,MAAM;wCACN,mBAAmB,EAAE,mBAA2B;wCAChD,WAAW,EAAE,sBAAsB;wCACnC,kBAAkB,EAAE,OAAO;qCAC5B,CAAC,CAAA;oCACF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;gCACvB,CAAC,CAAC,CAAA;4BACJ,CAAC;4BAAC,OAAO,IAAI,EAAE,CAAC;gCACd,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;4BAC/B,CAAC;wBACH,CAAC;6BAAM,CAAC;4BACN,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;wBAC9B,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC,CAAA;QACJ,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/_esm/errors/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = '2.7.
|
1
|
+
export const version = '2.7.1';
|
2
2
|
//# sourceMappingURL=version.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withRetry.js","sourceRoot":"","sources":["../../../utils/promise/withRetry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;
|
1
|
+
{"version":3,"file":"withRetry.js","sourceRoot":"","sources":["../../../utils/promise/withRetry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAmBjC,MAAM,UAAU,SAAS,CACvB,EAAwB,EACxB,EACE,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,MACD,EAAE;IAE3B,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,KAAK,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;YAChD,MAAM,KAAK,GAAG,KAAK,EAAE,EAAE,KAAK,EAAoB,EAAE,EAAE;gBAClD,MAAM,KAAK,GACT,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;gBAClE,IAAI,KAAK;oBAAE,MAAM,IAAI,CAAC,KAAK,CAAC,CAAA;gBAC5B,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;YACpC,CAAC,CAAA;YAED,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,EAAE,EAAE,CAAA;gBACvB,OAAO,CAAC,IAAI,CAAC,CAAA;YACf,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,KAAK,GAAG,UAAU;oBAClB,CAAC,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAY,EAAE,CAAC,CAAC;oBAEnD,OAAO,KAAK,CAAC,EAAE,KAAK,EAAE,GAAY,EAAE,CAAC,CAAA;gBACvC,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC;QACH,CAAC,CAAA;QACD,YAAY,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
@@ -5,6 +5,7 @@ import type { Chain } from '../../types/chain.js';
|
|
5
5
|
import type { Hash } from '../../types/misc.js';
|
6
6
|
import type { Transaction } from '../../types/transaction.js';
|
7
7
|
import { type ObserveErrorType } from '../../utils/observe.js';
|
8
|
+
import { type WithRetryParameters } from '../../utils/promise/withRetry.js';
|
8
9
|
import { type GetBlockErrorType } from './getBlock.js';
|
9
10
|
import { type GetTransactionErrorType } from './getTransaction.js';
|
10
11
|
import { type GetTransactionReceiptErrorType, type GetTransactionReceiptReturnType } from './getTransactionReceipt.js';
|
@@ -32,6 +33,16 @@ export type WaitForTransactionReceiptParameters<TChain extends Chain | undefined
|
|
32
33
|
* @default client.pollingInterval
|
33
34
|
*/
|
34
35
|
pollingInterval?: number;
|
36
|
+
/**
|
37
|
+
* Number of times to retry if the transaction or block is not found.
|
38
|
+
* @default 6 (exponential backoff)
|
39
|
+
*/
|
40
|
+
retryCount?: WithRetryParameters['retryCount'];
|
41
|
+
/**
|
42
|
+
* Time to wait (in ms) between retries.
|
43
|
+
* @default `({ count }) => ~~(1 << count) * 200` (exponential backoff)
|
44
|
+
*/
|
45
|
+
retryDelay?: WithRetryParameters['delay'];
|
35
46
|
/** Optional timeout (in milliseconds) to wait before stopping polling. */
|
36
47
|
timeout?: number;
|
37
48
|
};
|
@@ -74,5 +85,6 @@ export type WaitForTransactionReceiptErrorType = ObserveErrorType | GetBlockErro
|
|
74
85
|
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
75
86
|
* })
|
76
87
|
*/
|
77
|
-
export declare function waitForTransactionReceipt<TChain extends Chain | undefined>(client: Client<Transport, TChain>, { confirmations, hash, onReplaced, pollingInterval,
|
88
|
+
export declare function waitForTransactionReceipt<TChain extends Chain | undefined>(client: Client<Transport, TChain>, { confirmations, hash, onReplaced, pollingInterval, retryCount, retryDelay, // exponential backoff
|
89
|
+
timeout, }: WaitForTransactionReceiptParameters<TChain>): Promise<WaitForTransactionReceiptReturnType<TChain>>;
|
78
90
|
//# sourceMappingURL=waitForTransactionReceipt.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"waitForTransactionReceipt.d.ts","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAO5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;
|
1
|
+
{"version":3,"file":"waitForTransactionReceipt.d.ts","sourceRoot":"","sources":["../../../actions/public/waitForTransactionReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAO5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;AACvE,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,kCAAkC,CAAA;AAGzC,OAAO,EAAE,KAAK,iBAAiB,EAAY,MAAM,eAAe,CAAA;AAChE,OAAO,EACL,KAAK,uBAAuB,EAG7B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EAErC,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,KAAK,y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AAM,SAAS,KAAK,GAAG,SAAS,EAEhC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,EACjC,EACE,aAAiB,EACjB,IAAI,EACJ,UAAU,EACV,eAAwC,EACxC,UAAc,EACd,UAAgD,EAAE,sBAAsB;AACxE,OAAO,GACR,EAAE,mCAAmC,CAAC,MAAM,CAAC,GAC7C,OAAO,CAAC,mCAAmC,CAAC,MAAM,CAAC,CAAC,CAiMtD"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "2.7.
|
1
|
+
export declare const version = "2.7.1";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import type { ErrorType } from '../../errors/utils.js';
|
2
|
-
export type
|
3
|
-
export declare function withRetry<TData>(fn: () => Promise<TData>, { delay: delay_, retryCount, shouldRetry, }?: {
|
2
|
+
export type WithRetryParameters = {
|
4
3
|
delay?: ((config: {
|
5
4
|
count: number;
|
6
5
|
error: Error;
|
@@ -10,5 +9,7 @@ export declare function withRetry<TData>(fn: () => Promise<TData>, { delay: dela
|
|
10
9
|
count: number;
|
11
10
|
error: Error;
|
12
11
|
}) => Promise<boolean> | boolean;
|
13
|
-
}
|
12
|
+
};
|
13
|
+
export type WithRetryErrorType = ErrorType;
|
14
|
+
export declare function withRetry<TData>(fn: () => Promise<TData>, { delay: delay_, retryCount, shouldRetry, }?: WithRetryParameters): Promise<TData>;
|
14
15
|
//# sourceMappingURL=withRetry.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withRetry.d.ts","sourceRoot":"","sources":["../../../utils/promise/withRetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGtD,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"withRetry.d.ts","sourceRoot":"","sources":["../../../utils/promise/withRetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGtD,MAAM,MAAM,mBAAmB,GAAG;IAEhC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC,GAAG,MAAM,CAAA;IAEtE,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,WAAW,CAAC,EAAE,CAAC,EACb,KAAK,EACL,KAAK,GACN,EAAE;QACD,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,KAAK,CAAA;KACb,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAA;AAE1C,wBAAgB,SAAS,CAAC,KAAK,EAC7B,EAAE,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EACxB,EACE,KAAK,EAAE,MAAY,EACnB,UAAc,EACd,WAAwB,GACzB,GAAE,mBAAwB,kBAyB5B"}
|
@@ -12,7 +12,10 @@ import type { Hash } from '../../types/misc.js'
|
|
12
12
|
import type { Transaction } from '../../types/transaction.js'
|
13
13
|
import { getAction } from '../../utils/getAction.js'
|
14
14
|
import { type ObserveErrorType, observe } from '../../utils/observe.js'
|
15
|
-
import {
|
15
|
+
import {
|
16
|
+
type WithRetryParameters,
|
17
|
+
withRetry,
|
18
|
+
} from '../../utils/promise/withRetry.js'
|
16
19
|
import { stringify } from '../../utils/stringify.js'
|
17
20
|
|
18
21
|
import { type GetBlockErrorType, getBlock } from './getBlock.js'
|
@@ -62,6 +65,16 @@ export type WaitForTransactionReceiptParameters<
|
|
62
65
|
* @default client.pollingInterval
|
63
66
|
*/
|
64
67
|
pollingInterval?: number
|
68
|
+
/**
|
69
|
+
* Number of times to retry if the transaction or block is not found.
|
70
|
+
* @default 6 (exponential backoff)
|
71
|
+
*/
|
72
|
+
retryCount?: WithRetryParameters['retryCount']
|
73
|
+
/**
|
74
|
+
* Time to wait (in ms) between retries.
|
75
|
+
* @default `({ count }) => ~~(1 << count) * 200` (exponential backoff)
|
76
|
+
*/
|
77
|
+
retryDelay?: WithRetryParameters['delay']
|
65
78
|
/** Optional timeout (in milliseconds) to wait before stopping polling. */
|
66
79
|
timeout?: number
|
67
80
|
}
|
@@ -121,6 +134,8 @@ export async function waitForTransactionReceipt<
|
|
121
134
|
hash,
|
122
135
|
onReplaced,
|
123
136
|
pollingInterval = client.pollingInterval,
|
137
|
+
retryCount = 6,
|
138
|
+
retryDelay = ({ count }) => ~~(1 << count) * 200, // exponential backoff
|
124
139
|
timeout,
|
125
140
|
}: WaitForTransactionReceiptParameters<TChain>,
|
126
141
|
): Promise<WaitForTransactionReceiptReturnType<TChain>> {
|
@@ -193,9 +208,8 @@ export async function waitForTransactionReceipt<
|
|
193
208
|
blockNumber = transaction.blockNumber
|
194
209
|
},
|
195
210
|
{
|
196
|
-
|
197
|
-
|
198
|
-
retryCount: 6,
|
211
|
+
delay: retryDelay,
|
212
|
+
retryCount,
|
199
213
|
},
|
200
214
|
)
|
201
215
|
retrying = false
|
@@ -247,9 +261,8 @@ export async function waitForTransactionReceipt<
|
|
247
261
|
includeTransactions: true,
|
248
262
|
}),
|
249
263
|
{
|
250
|
-
|
251
|
-
|
252
|
-
retryCount: 6,
|
264
|
+
delay: retryDelay,
|
265
|
+
retryCount,
|
253
266
|
shouldRetry: ({ error }) =>
|
254
267
|
error instanceof BlockNotFoundError,
|
255
268
|
},
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.7.
|
1
|
+
export const version = '2.7.1'
|
package/package.json
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
import type { ErrorType } from '../../errors/utils.js'
|
2
2
|
import { wait } from '../wait.js'
|
3
3
|
|
4
|
+
export type WithRetryParameters = {
|
5
|
+
// The delay (in ms) between retries.
|
6
|
+
delay?: ((config: { count: number; error: Error }) => number) | number
|
7
|
+
// The max number of times to retry.
|
8
|
+
retryCount?: number
|
9
|
+
// Whether or not to retry when an error is thrown.
|
10
|
+
shouldRetry?: ({
|
11
|
+
count,
|
12
|
+
error,
|
13
|
+
}: {
|
14
|
+
count: number
|
15
|
+
error: Error
|
16
|
+
}) => Promise<boolean> | boolean
|
17
|
+
}
|
18
|
+
|
4
19
|
export type WithRetryErrorType = ErrorType
|
5
20
|
|
6
21
|
export function withRetry<TData>(
|
@@ -9,20 +24,7 @@ export function withRetry<TData>(
|
|
9
24
|
delay: delay_ = 100,
|
10
25
|
retryCount = 2,
|
11
26
|
shouldRetry = () => true,
|
12
|
-
}: {
|
13
|
-
// The delay (in ms) between retries.
|
14
|
-
delay?: ((config: { count: number; error: Error }) => number) | number
|
15
|
-
// The max number of times to retry.
|
16
|
-
retryCount?: number
|
17
|
-
// Whether or not to retry when an error is thrown.
|
18
|
-
shouldRetry?: ({
|
19
|
-
count,
|
20
|
-
error,
|
21
|
-
}: {
|
22
|
-
count: number
|
23
|
-
error: Error
|
24
|
-
}) => Promise<boolean> | boolean
|
25
|
-
} = {},
|
27
|
+
}: WithRetryParameters = {},
|
26
28
|
) {
|
27
29
|
return new Promise<TData>((resolve, reject) => {
|
28
30
|
const attemptRetry = async ({ count = 0 } = {}) => {
|