@reyaxyz/common 0.319.0 → 0.321.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/README.md +1 -1
- package/dist/types/utils/delay.d.ts +2 -0
- package/dist/types/utils/delay.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/transaction-receipt.d.ts +8 -0
- package/dist/types/utils/transaction-receipt.d.ts.map +1 -0
- package/dist/utils/delay.js +8 -0
- package/dist/utils/delay.js.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/transaction-receipt.js +76 -0
- package/dist/utils/transaction-receipt.js.map +1 -0
- package/package.json +2 -2
- package/src/utils/delay.ts +2 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/transaction-receipt.ts +29 -0
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.d.ts","sourceRoot":"/","sources":["utils/delay.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,OAAQ,MAAM,KAAG,QAAQ,IAAI,CACI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Provider } from 'ethers';
|
|
2
|
+
type TransactionReceiptMetadata = {
|
|
3
|
+
pollingInterval?: number;
|
|
4
|
+
maxRetries?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const getTransactionReceipt: (provider: Provider, txHash: string, metadata?: TransactionReceiptMetadata) => Promise<import("ethers").TransactionReceipt | null>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=transaction-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-receipt.d.ts","sourceRoot":"/","sources":["utils/transaction-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,KAAK,0BAA0B,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACtB,QAAQ,UACV,MAAM,aACJ,0BAA0B,wDAiBrC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.delay = void 0;
|
|
4
|
+
var delay = function (ms) {
|
|
5
|
+
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
6
|
+
};
|
|
7
|
+
exports.delay = delay;
|
|
8
|
+
//# sourceMappingURL=delay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"/","sources":["utils/delay.ts"],"names":[],"mappings":";;;AAAO,IAAM,KAAK,GAAG,UAAC,EAAU;IAC9B,OAAA,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC;AAAjD,CAAiD,CAAC;AADvC,QAAA,KAAK,SACkC","sourcesContent":["export const delay = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms));\n"]}
|
package/dist/utils/index.js
CHANGED
|
@@ -29,4 +29,6 @@ __exportStar(require("./whitelisted-wallets"), exports);
|
|
|
29
29
|
__exportStar(require("./stringify"), exports);
|
|
30
30
|
__exportStar(require("./sbt-helpers"), exports);
|
|
31
31
|
__exportStar(require("./minting-helpers"), exports);
|
|
32
|
+
__exportStar(require("./delay"), exports);
|
|
33
|
+
__exportStar(require("./transaction-receipt"), exports);
|
|
32
34
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,sDAAoC;AACpC,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB;AACxB,iDAA+B;AAC/B,wDAAsC;AACtC,8CAA4B;AAC5B,gDAA8B;AAC9B,oDAAkC","sourcesContent":["export * from './consts';\nexport * from './points';\nexport * from './calculate';\nexport * from './struct';\nexport * from './cooldown-interval';\nexport * from './network';\nexport * from './number';\nexport * from './retry';\nexport * from './timestamp';\nexport * from './token';\nexport * from './task-wrapper';\nexport * from './whitelisted-wallets';\nexport * from './stringify';\nexport * from './sbt-helpers';\nexport * from './minting-helpers';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,sDAAoC;AACpC,4CAA0B;AAC1B,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB;AACxB,iDAA+B;AAC/B,wDAAsC;AACtC,8CAA4B;AAC5B,gDAA8B;AAC9B,oDAAkC;AAClC,0CAAwB;AACxB,wDAAsC","sourcesContent":["export * from './consts';\nexport * from './points';\nexport * from './calculate';\nexport * from './struct';\nexport * from './cooldown-interval';\nexport * from './network';\nexport * from './number';\nexport * from './retry';\nexport * from './timestamp';\nexport * from './token';\nexport * from './task-wrapper';\nexport * from './whitelisted-wallets';\nexport * from './stringify';\nexport * from './sbt-helpers';\nexport * from './minting-helpers';\nexport * from './delay';\nexport * from './transaction-receipt';\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getTransactionReceipt = void 0;
|
|
40
|
+
var delay_1 = require("./delay");
|
|
41
|
+
var getTransactionReceipt = function (provider, txHash, metadata) {
|
|
42
|
+
if (metadata === void 0) { metadata = {}; }
|
|
43
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
var maxRetries, pollingInterval, attempts, receipt;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
maxRetries = metadata.maxRetries || 40;
|
|
49
|
+
pollingInterval = metadata.pollingInterval || 50;
|
|
50
|
+
attempts = 0;
|
|
51
|
+
_a.label = 1;
|
|
52
|
+
case 1:
|
|
53
|
+
if (!(attempts < maxRetries)) return [3 /*break*/, 5];
|
|
54
|
+
return [4 /*yield*/, provider.getTransactionReceipt(txHash)];
|
|
55
|
+
case 2:
|
|
56
|
+
receipt = _a.sent();
|
|
57
|
+
if (receipt) {
|
|
58
|
+
return [2 /*return*/, receipt];
|
|
59
|
+
}
|
|
60
|
+
// Wait for the specified interval before retrying
|
|
61
|
+
return [4 /*yield*/, (0, delay_1.delay)(pollingInterval)];
|
|
62
|
+
case 3:
|
|
63
|
+
// Wait for the specified interval before retrying
|
|
64
|
+
_a.sent();
|
|
65
|
+
attempts++;
|
|
66
|
+
_a.label = 4;
|
|
67
|
+
case 4:
|
|
68
|
+
attempts++;
|
|
69
|
+
return [3 /*break*/, 1];
|
|
70
|
+
case 5: return [2 /*return*/, null];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
exports.getTransactionReceipt = getTransactionReceipt;
|
|
76
|
+
//# sourceMappingURL=transaction-receipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-receipt.js","sourceRoot":"/","sources":["utils/transaction-receipt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAgC;AAOzB,IAAM,qBAAqB,GAAG,UACnC,QAAkB,EAClB,MAAc,EACd,QAAyC;IAAzC,yBAAA,EAAA,aAAyC;;;;;;oBAEnC,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;oBACvC,eAAe,GAAG,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC;oBAE9C,QAAQ,GAAG,CAAC;;;yBAAE,CAAA,QAAQ,GAAG,UAAU,CAAA;oBAC1B,qBAAM,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAA;;oBAAtD,OAAO,GAAG,SAA4C;oBAC5D,IAAI,OAAO,EAAE,CAAC;wBACZ,sBAAO,OAAO,EAAC;oBACjB,CAAC;oBAED,kDAAkD;oBAClD,qBAAM,IAAA,aAAK,EAAC,eAAe,CAAC,EAAA;;oBAD5B,kDAAkD;oBAClD,SAA4B,CAAC;oBAC7B,QAAQ,EAAE,CAAC;;;oBARiC,QAAQ,EAAE,CAAA;;wBAWxD,sBAAO,IAAI,EAAC;;;;CACb,CAAC;AApBW,QAAA,qBAAqB,yBAoBhC","sourcesContent":["import { Provider } from 'ethers';\nimport { delay } from './delay';\n\ntype TransactionReceiptMetadata = {\n pollingInterval?: number;\n maxRetries?: number;\n};\n\nexport const getTransactionReceipt = async (\n provider: Provider,\n txHash: string,\n metadata: TransactionReceiptMetadata = {},\n) => {\n const maxRetries = metadata.maxRetries || 40;\n const pollingInterval = metadata.pollingInterval || 50;\n\n for (let attempts = 0; attempts < maxRetries; attempts++) {\n const receipt = await provider.getTransactionReceipt(txHash);\n if (receipt) {\n return receipt;\n }\n\n // Wait for the specified interval before retrying\n await delay(pollingInterval);\n attempts++;\n }\n\n return null;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.321.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
45
45
|
},
|
|
46
46
|
"packageManager": "pnpm@8.3.1",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "8b567a09f421d9a406f84f32bdfd4b7b1c7e8393"
|
|
48
48
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Provider } from 'ethers';
|
|
2
|
+
import { delay } from './delay';
|
|
3
|
+
|
|
4
|
+
type TransactionReceiptMetadata = {
|
|
5
|
+
pollingInterval?: number;
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getTransactionReceipt = async (
|
|
10
|
+
provider: Provider,
|
|
11
|
+
txHash: string,
|
|
12
|
+
metadata: TransactionReceiptMetadata = {},
|
|
13
|
+
) => {
|
|
14
|
+
const maxRetries = metadata.maxRetries || 40;
|
|
15
|
+
const pollingInterval = metadata.pollingInterval || 50;
|
|
16
|
+
|
|
17
|
+
for (let attempts = 0; attempts < maxRetries; attempts++) {
|
|
18
|
+
const receipt = await provider.getTransactionReceipt(txHash);
|
|
19
|
+
if (receipt) {
|
|
20
|
+
return receipt;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Wait for the specified interval before retrying
|
|
24
|
+
await delay(pollingInterval);
|
|
25
|
+
attempts++;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null;
|
|
29
|
+
};
|