@railgun-community/shared-models 5.0.2 → 5.1.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.
Files changed (60) hide show
  1. package/README.md +2 -0
  2. package/dist/index.js +2 -18
  3. package/dist/index.js.map +1 -1
  4. package/dist/models/artifact.js +2 -5
  5. package/dist/models/artifact.js.map +1 -1
  6. package/dist/models/blocked-address.js +1 -4
  7. package/dist/models/blocked-address.js.map +1 -1
  8. package/dist/models/fee-token.js +1 -2
  9. package/dist/models/function-types.js +1 -2
  10. package/dist/models/index.js +11 -27
  11. package/dist/models/index.js.map +1 -1
  12. package/dist/models/merkletree-scan.js +2 -5
  13. package/dist/models/merkletree-scan.js.map +1 -1
  14. package/dist/models/network-config.js +72 -76
  15. package/dist/models/network-config.js.map +1 -1
  16. package/dist/models/proof.js +2 -5
  17. package/dist/models/proof.js.map +1 -1
  18. package/dist/models/relayer.js +2 -5
  19. package/dist/models/relayer.js.map +1 -1
  20. package/dist/models/response-types.d.ts +15 -35
  21. package/dist/models/response-types.js +8 -11
  22. package/dist/models/response-types.js.map +1 -1
  23. package/dist/models/transaction.js +1 -2
  24. package/dist/models/wallet.js +2 -5
  25. package/dist/models/wallet.js.map +1 -1
  26. package/dist/utils/artifact-v2.js +8 -18
  27. package/dist/utils/artifact-v2.js.map +1 -1
  28. package/dist/utils/available-rpc.js +38 -98
  29. package/dist/utils/available-rpc.js.map +1 -1
  30. package/dist/utils/compare.js +1 -5
  31. package/dist/utils/compare.js.map +1 -1
  32. package/dist/utils/error.js +5 -9
  33. package/dist/utils/error.js.map +1 -1
  34. package/dist/utils/fallback-provider.d.ts +2 -2
  35. package/dist/utils/fallback-provider.js +15 -36
  36. package/dist/utils/fallback-provider.js.map +1 -1
  37. package/dist/utils/format.d.ts +1 -2
  38. package/dist/utils/format.js +2 -11
  39. package/dist/utils/format.js.map +1 -1
  40. package/dist/utils/gas.d.ts +5 -9
  41. package/dist/utils/gas.js +20 -79
  42. package/dist/utils/gas.js.map +1 -1
  43. package/dist/utils/index.d.ts +0 -1
  44. package/dist/utils/index.js +10 -27
  45. package/dist/utils/index.js.map +1 -1
  46. package/dist/utils/median.js +3 -7
  47. package/dist/utils/median.js.map +1 -1
  48. package/dist/utils/network.js +3 -9
  49. package/dist/utils/network.js.map +1 -1
  50. package/dist/utils/polling-json-rpc-provider.d.ts +8 -0
  51. package/dist/utils/polling-json-rpc-provider.js +11 -0
  52. package/dist/utils/polling-json-rpc-provider.js.map +1 -0
  53. package/dist/utils/promises.js +21 -78
  54. package/dist/utils/promises.js.map +1 -1
  55. package/dist/utils/versions.js +5 -9
  56. package/dist/utils/versions.js.map +1 -1
  57. package/package.json +3 -9
  58. package/dist/utils/serializer.d.ts +0 -5
  59. package/dist/utils/serializer.js +0 -57
  60. package/dist/utils/serializer.js.map +0 -1
@@ -1,13 +1,4 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.decimalToHexString = exports.decimalStringToHexString = void 0;
4
- var bignumber_1 = require("@ethersproject/bignumber");
5
- var decimalStringToHexString = function (dec) {
6
- return bignumber_1.BigNumber.from(dec).toHexString();
1
+ export const decimalToHexString = (dec) => {
2
+ return BigInt(dec).toString(16);
7
3
  };
8
- exports.decimalStringToHexString = decimalStringToHexString;
9
- var decimalToHexString = function (dec) {
10
- return bignumber_1.BigNumber.from(dec).toHexString();
11
- };
12
- exports.decimalToHexString = decimalToHexString;
13
4
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":";;;AAAA,sDAAqD;AAE9C,IAAM,wBAAwB,GAAG,UAAC,GAAW;IAClD,OAAO,qBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,wBAAwB,4BAEnC;AAEK,IAAM,kBAAkB,GAAG,UAAC,GAAW;IAC5C,OAAO,qBAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\n\nexport const decimalStringToHexString = (dec: string) => {\n return BigNumber.from(dec).toHexString();\n};\n\nexport const decimalToHexString = (dec: number) => {\n return BigNumber.from(dec).toHexString();\n};\n"]}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,EAAE;IACzD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["export const decimalToHexString = (dec: string | number) => {\n return BigInt(dec).toString(16);\n};\n"]}
@@ -1,11 +1,7 @@
1
- /// <reference types="../types/global" />
2
- import { BigNumber } from '@ethersproject/bignumber';
3
1
  import { NetworkName } from '../models/network-config';
4
- import { EVMGasType, TransactionGasDetails, TransactionGasDetailsSerialized } from '../models/response-types';
2
+ import { EVMGasType, TransactionGasDetails } from '../models/response-types';
5
3
  export declare const getEVMGasTypeForTransaction: (networkName: NetworkName, sendWithPublicWallet: boolean) => EVMGasType;
6
- export declare const calculateGasLimit: (gasEstimate: BigNumber) => BigNumber;
7
- export declare const calculateGasPrice: (gasDetails: TransactionGasDetails) => BigNumber;
8
- export declare const calculateTotalGas: (transactionGasDetails: TransactionGasDetails) => BigNumber;
9
- export declare const calculateMaximumGas: (transactionGasDetails: TransactionGasDetails) => BigNumber;
10
- export declare const serializeTransactionGasDetails: (gasDetails: TransactionGasDetails) => TransactionGasDetailsSerialized;
11
- export declare const deserializeTransactionGasDetails: (gasDetailsSerialized: Optional<TransactionGasDetailsSerialized>) => Optional<TransactionGasDetails>;
4
+ export declare const calculateGasLimit: (gasEstimate: bigint) => bigint;
5
+ export declare const calculateGasPrice: (gasDetails: TransactionGasDetails) => bigint;
6
+ export declare const calculateTotalGas: (transactionGasDetails: TransactionGasDetails) => bigint;
7
+ export declare const calculateMaximumGas: (transactionGasDetails: TransactionGasDetails) => bigint;
package/dist/utils/gas.js CHANGED
@@ -1,96 +1,37 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.deserializeTransactionGasDetails = exports.serializeTransactionGasDetails = exports.calculateMaximumGas = exports.calculateTotalGas = exports.calculateGasPrice = exports.calculateGasLimit = exports.getEVMGasTypeForTransaction = void 0;
4
- /// <reference types="../types/global" />
5
- var bignumber_1 = require("@ethersproject/bignumber");
6
- var network_config_1 = require("../models/network-config");
7
- var response_types_1 = require("../models/response-types");
8
- var getEVMGasTypeForTransaction = function (networkName, sendWithPublicWallet) {
9
- var defaultEVMGasType = network_config_1.NETWORK_CONFIG[networkName].defaultEVMGasType;
10
- if (defaultEVMGasType === response_types_1.EVMGasType.Type2 && !sendWithPublicWallet) {
1
+ import { NETWORK_CONFIG } from '../models/network-config';
2
+ import { EVMGasType } from '../models/response-types';
3
+ export const getEVMGasTypeForTransaction = (networkName, sendWithPublicWallet) => {
4
+ const { defaultEVMGasType } = NETWORK_CONFIG[networkName];
5
+ if (defaultEVMGasType === EVMGasType.Type2 && !sendWithPublicWallet) {
11
6
  // Relayer transactions require overallBatchMinGasPrice.
12
7
  // This is only supported by type 1 transactions.
13
- return response_types_1.EVMGasType.Type1;
8
+ return EVMGasType.Type1;
14
9
  }
15
10
  return defaultEVMGasType;
16
11
  };
17
- exports.getEVMGasTypeForTransaction = getEVMGasTypeForTransaction;
18
- var calculateGasLimit = function (gasEstimate) {
12
+ export const calculateGasLimit = (gasEstimate) => {
19
13
  // Gas Limit: Add 20% to gas estimate.
20
- return gasEstimate.mul(12000).div(10000);
14
+ return (gasEstimate * 12000n) / 10000n;
21
15
  };
22
- exports.calculateGasLimit = calculateGasLimit;
23
- var calculateGasPrice = function (gasDetails) {
16
+ export const calculateGasPrice = (gasDetails) => {
24
17
  switch (gasDetails.evmGasType) {
25
- case response_types_1.EVMGasType.Type0:
26
- case response_types_1.EVMGasType.Type1: {
18
+ case EVMGasType.Type0:
19
+ case EVMGasType.Type1: {
27
20
  return gasDetails.gasPrice;
28
21
  }
29
- case response_types_1.EVMGasType.Type2: {
22
+ case EVMGasType.Type2: {
30
23
  return gasDetails.maxFeePerGas;
31
24
  }
32
25
  }
33
26
  };
34
- exports.calculateGasPrice = calculateGasPrice;
35
- var calculateTotalGas = function (transactionGasDetails) {
36
- var gasPrice = (0, exports.calculateGasPrice)(transactionGasDetails);
37
- var gasEstimate = transactionGasDetails.gasEstimate;
38
- return gasEstimate.mul(gasPrice);
27
+ export const calculateTotalGas = (transactionGasDetails) => {
28
+ const gasPrice = calculateGasPrice(transactionGasDetails);
29
+ const { gasEstimate } = transactionGasDetails;
30
+ return gasEstimate * gasPrice;
39
31
  };
40
- exports.calculateTotalGas = calculateTotalGas;
41
- var calculateMaximumGas = function (transactionGasDetails) {
42
- var gasPrice = (0, exports.calculateGasPrice)(transactionGasDetails);
43
- var gasEstimate = transactionGasDetails.gasEstimate;
44
- return (0, exports.calculateGasLimit)(gasEstimate).mul(gasPrice);
32
+ export const calculateMaximumGas = (transactionGasDetails) => {
33
+ const gasPrice = calculateGasPrice(transactionGasDetails);
34
+ const { gasEstimate } = transactionGasDetails;
35
+ return calculateGasLimit(gasEstimate) * gasPrice;
45
36
  };
46
- exports.calculateMaximumGas = calculateMaximumGas;
47
- var serializeTransactionGasDetails = function (gasDetails) {
48
- switch (gasDetails.evmGasType) {
49
- case response_types_1.EVMGasType.Type0:
50
- case response_types_1.EVMGasType.Type1: {
51
- var evmGasType = gasDetails.evmGasType, gasEstimate = gasDetails.gasEstimate, gasPrice = gasDetails.gasPrice;
52
- return {
53
- evmGasType: evmGasType,
54
- gasEstimateString: gasEstimate.toHexString(),
55
- gasPriceString: gasPrice.toHexString()
56
- };
57
- }
58
- case response_types_1.EVMGasType.Type2: {
59
- var evmGasType = gasDetails.evmGasType, gasEstimate = gasDetails.gasEstimate, maxFeePerGas = gasDetails.maxFeePerGas, maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas;
60
- return {
61
- evmGasType: evmGasType,
62
- gasEstimateString: gasEstimate.toHexString(),
63
- maxFeePerGasString: maxFeePerGas.toHexString(),
64
- maxPriorityFeePerGasString: maxPriorityFeePerGas.toHexString()
65
- };
66
- }
67
- }
68
- };
69
- exports.serializeTransactionGasDetails = serializeTransactionGasDetails;
70
- var deserializeTransactionGasDetails = function (gasDetailsSerialized) {
71
- if (!gasDetailsSerialized) {
72
- return undefined;
73
- }
74
- switch (gasDetailsSerialized.evmGasType) {
75
- case response_types_1.EVMGasType.Type0:
76
- case response_types_1.EVMGasType.Type1: {
77
- var evmGasType = gasDetailsSerialized.evmGasType, gasEstimateString = gasDetailsSerialized.gasEstimateString, gasPriceString = gasDetailsSerialized.gasPriceString;
78
- return {
79
- evmGasType: evmGasType,
80
- gasEstimate: bignumber_1.BigNumber.from(gasEstimateString),
81
- gasPrice: bignumber_1.BigNumber.from(gasPriceString)
82
- };
83
- }
84
- case response_types_1.EVMGasType.Type2: {
85
- var evmGasType = gasDetailsSerialized.evmGasType, gasEstimateString = gasDetailsSerialized.gasEstimateString, maxFeePerGasString = gasDetailsSerialized.maxFeePerGasString, maxPriorityFeePerGasString = gasDetailsSerialized.maxPriorityFeePerGasString;
86
- return {
87
- evmGasType: evmGasType,
88
- gasEstimate: bignumber_1.BigNumber.from(gasEstimateString),
89
- maxFeePerGas: bignumber_1.BigNumber.from(maxFeePerGasString),
90
- maxPriorityFeePerGas: bignumber_1.BigNumber.from(maxPriorityFeePerGasString)
91
- };
92
- }
93
- }
94
- };
95
- exports.deserializeTransactionGasDetails = deserializeTransactionGasDetails;
96
37
  //# sourceMappingURL=gas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"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","sourcesContent":["/// <reference types=\"../types/global\" />\nimport { BigNumber } from '@ethersproject/bignumber';\nimport { NetworkName, NETWORK_CONFIG } from '../models/network-config';\nimport {\n EVMGasType,\n TransactionGasDetails,\n TransactionGasDetailsSerialized,\n} from '../models/response-types';\n\nexport const getEVMGasTypeForTransaction = (\n networkName: NetworkName,\n sendWithPublicWallet: boolean,\n): EVMGasType => {\n const { defaultEVMGasType } = NETWORK_CONFIG[networkName];\n\n if (defaultEVMGasType === EVMGasType.Type2 && !sendWithPublicWallet) {\n // Relayer transactions require overallBatchMinGasPrice.\n // This is only supported by type 1 transactions.\n return EVMGasType.Type1;\n }\n\n return defaultEVMGasType;\n};\n\nexport const calculateGasLimit = (gasEstimate: BigNumber): BigNumber => {\n // Gas Limit: Add 20% to gas estimate.\n return gasEstimate.mul(12000).div(10000);\n};\n\nexport const calculateGasPrice = (gasDetails: TransactionGasDetails) => {\n switch (gasDetails.evmGasType) {\n case EVMGasType.Type0:\n case EVMGasType.Type1: {\n return gasDetails.gasPrice;\n }\n case EVMGasType.Type2: {\n return gasDetails.maxFeePerGas;\n }\n }\n};\n\nexport const calculateTotalGas = (\n transactionGasDetails: TransactionGasDetails,\n) => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return gasEstimate.mul(gasPrice);\n};\n\nexport const calculateMaximumGas = (\n transactionGasDetails: TransactionGasDetails,\n): BigNumber => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return calculateGasLimit(gasEstimate).mul(gasPrice);\n};\n\nexport const serializeTransactionGasDetails = (\n gasDetails: TransactionGasDetails,\n): TransactionGasDetailsSerialized => {\n switch (gasDetails.evmGasType) {\n case EVMGasType.Type0:\n case EVMGasType.Type1: {\n const { evmGasType, gasEstimate, gasPrice } = gasDetails;\n return {\n evmGasType,\n gasEstimateString: gasEstimate.toHexString(),\n gasPriceString: gasPrice.toHexString(),\n };\n }\n case EVMGasType.Type2: {\n const { evmGasType, gasEstimate, maxFeePerGas, maxPriorityFeePerGas } =\n gasDetails;\n return {\n evmGasType,\n gasEstimateString: gasEstimate.toHexString(),\n maxFeePerGasString: maxFeePerGas.toHexString(),\n maxPriorityFeePerGasString: maxPriorityFeePerGas.toHexString(),\n };\n }\n }\n};\n\nexport const deserializeTransactionGasDetails = (\n gasDetailsSerialized: Optional<TransactionGasDetailsSerialized>,\n): Optional<TransactionGasDetails> => {\n if (!gasDetailsSerialized) {\n return undefined;\n }\n switch (gasDetailsSerialized.evmGasType) {\n case EVMGasType.Type0:\n case EVMGasType.Type1: {\n const { evmGasType, gasEstimateString, gasPriceString } =\n gasDetailsSerialized;\n return {\n evmGasType,\n gasEstimate: BigNumber.from(gasEstimateString),\n gasPrice: BigNumber.from(gasPriceString),\n };\n }\n case EVMGasType.Type2: {\n const {\n evmGasType,\n gasEstimateString,\n maxFeePerGasString,\n maxPriorityFeePerGasString,\n } = gasDetailsSerialized;\n return {\n evmGasType,\n gasEstimate: BigNumber.from(gasEstimateString),\n maxFeePerGas: BigNumber.from(maxFeePerGasString),\n maxPriorityFeePerGas: BigNumber.from(maxPriorityFeePerGasString),\n };\n }\n }\n};\n"]}
1
+ {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAyB,MAAM,0BAA0B,CAAC;AAE7E,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,WAAwB,EACxB,oBAA6B,EACjB,EAAE;IACd,MAAM,EAAE,iBAAiB,EAAE,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAE1D,IAAI,iBAAiB,KAAK,UAAU,CAAC,KAAK,IAAI,CAAC,oBAAoB,EAAE;QACnE,wDAAwD;QACxD,iDAAiD;QACjD,OAAO,UAAU,CAAC,KAAK,CAAC;KACzB;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAU,EAAE;IAC/D,sCAAsC;IACtC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,UAAiC,EAAE,EAAE;IACrE,QAAQ,UAAU,CAAC,UAAU,EAAE;QAC7B,KAAK,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,UAAU,CAAC,QAAQ,CAAC;SAC5B;QACD,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,UAAU,CAAC,YAAY,CAAC;SAChC;KACF;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,qBAA4C,EAC5C,EAAE;IACF,MAAM,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAC1D,MAAM,EAAE,WAAW,EAAE,GAAG,qBAAqB,CAAC;IAC9C,OAAO,WAAW,GAAG,QAAQ,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,qBAA4C,EACpC,EAAE;IACV,MAAM,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAC1D,MAAM,EAAE,WAAW,EAAE,GAAG,qBAAqB,CAAC;IAC9C,OAAO,iBAAiB,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC;AACnD,CAAC,CAAC","sourcesContent":["import { NetworkName, NETWORK_CONFIG } from '../models/network-config';\nimport { EVMGasType, TransactionGasDetails } from '../models/response-types';\n\nexport const getEVMGasTypeForTransaction = (\n networkName: NetworkName,\n sendWithPublicWallet: boolean,\n): EVMGasType => {\n const { defaultEVMGasType } = NETWORK_CONFIG[networkName];\n\n if (defaultEVMGasType === EVMGasType.Type2 && !sendWithPublicWallet) {\n // Relayer transactions require overallBatchMinGasPrice.\n // This is only supported by type 1 transactions.\n return EVMGasType.Type1;\n }\n\n return defaultEVMGasType;\n};\n\nexport const calculateGasLimit = (gasEstimate: bigint): bigint => {\n // Gas Limit: Add 20% to gas estimate.\n return (gasEstimate * 12000n) / 10000n;\n};\n\nexport const calculateGasPrice = (gasDetails: TransactionGasDetails) => {\n switch (gasDetails.evmGasType) {\n case EVMGasType.Type0:\n case EVMGasType.Type1: {\n return gasDetails.gasPrice;\n }\n case EVMGasType.Type2: {\n return gasDetails.maxFeePerGas;\n }\n }\n};\n\nexport const calculateTotalGas = (\n transactionGasDetails: TransactionGasDetails,\n) => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return gasEstimate * gasPrice;\n};\n\nexport const calculateMaximumGas = (\n transactionGasDetails: TransactionGasDetails,\n): bigint => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return calculateGasLimit(gasEstimate) * gasPrice;\n};\n"]}
@@ -7,5 +7,4 @@ export * from './format';
7
7
  export * from './gas';
8
8
  export * from './network';
9
9
  export * from './promises';
10
- export * from './serializer';
11
10
  export * from './versions';
@@ -1,28 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- exports.__esModule = true;
17
- __exportStar(require("./artifact-v2"), exports);
18
- __exportStar(require("./available-rpc"), exports);
19
- __exportStar(require("./compare"), exports);
20
- __exportStar(require("./fallback-provider"), exports);
21
- __exportStar(require("./error"), exports);
22
- __exportStar(require("./format"), exports);
23
- __exportStar(require("./gas"), exports);
24
- __exportStar(require("./network"), exports);
25
- __exportStar(require("./promises"), exports);
26
- __exportStar(require("./serializer"), exports);
27
- __exportStar(require("./versions"), exports);
1
+ export * from './artifact-v2';
2
+ export * from './available-rpc';
3
+ export * from './compare';
4
+ export * from './fallback-provider';
5
+ export * from './error';
6
+ export * from './format';
7
+ export * from './gas';
8
+ export * from './network';
9
+ export * from './promises';
10
+ export * from './versions';
28
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,kDAAgC;AAChC,4CAA0B;AAC1B,sDAAoC;AACpC,0CAAwB;AACxB,2CAAyB;AACzB,wCAAsB;AACtB,4CAA0B;AAC1B,6CAA2B;AAC3B,+CAA6B;AAC7B,6CAA2B","sourcesContent":["export * from './artifact-v2';\nexport * from './available-rpc';\nexport * from './compare';\nexport * from './fallback-provider';\nexport * from './error';\nexport * from './format';\nexport * from './gas';\nexport * from './network';\nexport * from './promises';\nexport * from './serializer';\nexport * from './versions';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC","sourcesContent":["export * from './artifact-v2';\nexport * from './available-rpc';\nexport * from './compare';\nexport * from './fallback-provider';\nexport * from './error';\nexport * from './format';\nexport * from './gas';\nexport * from './network';\nexport * from './promises';\nexport * from './versions';\n"]}
@@ -1,13 +1,9 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.getUpperBoundMedian = void 0;
4
- var getUpperBoundMedian = function (numbers) {
1
+ export const getUpperBoundMedian = (numbers) => {
5
2
  if (!numbers.length) {
6
3
  return 0;
7
4
  }
8
- var index = Math.floor(numbers.length / 2);
9
- var sorted = numbers.sort();
5
+ const index = Math.floor(numbers.length / 2);
6
+ const sorted = numbers.sort();
10
7
  return sorted[index];
11
8
  };
12
- exports.getUpperBoundMedian = getUpperBoundMedian;
13
9
  //# sourceMappingURL=median.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"median.js","sourceRoot":"","sources":["../../src/utils/median.ts"],"names":[],"mappings":";;;AAAO,IAAM,mBAAmB,GAAG,UAAC,OAAiB;IACnD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,CAAC,CAAC;KACV;IACD,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAPW,QAAA,mBAAmB,uBAO9B","sourcesContent":["export const getUpperBoundMedian = (numbers: number[]) => {\n if (!numbers.length) {\n return 0;\n }\n const index = Math.floor(numbers.length / 2);\n const sorted = numbers.sort();\n return sorted[index];\n};\n"]}
1
+ {"version":3,"file":"median.js","sourceRoot":"","sources":["../../src/utils/median.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAiB,EAAE,EAAE;IACvD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,OAAO,CAAC,CAAC;KACV;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC","sourcesContent":["export const getUpperBoundMedian = (numbers: number[]) => {\n if (!numbers.length) {\n return 0;\n }\n const index = Math.floor(numbers.length / 2);\n const sorted = numbers.sort();\n return sorted[index];\n};\n"]}
@@ -1,11 +1,5 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.networkForChain = void 0;
4
- var network_config_1 = require("../models/network-config");
5
- var networkForChain = function (chain) {
6
- return Object.values(network_config_1.NETWORK_CONFIG).find(function (network) {
7
- return network.chain.type === chain.type && network.chain.id === chain.id;
8
- });
1
+ import { NETWORK_CONFIG } from '../models/network-config';
2
+ export const networkForChain = (chain) => {
3
+ return Object.values(NETWORK_CONFIG).find(network => network.chain.type === chain.type && network.chain.id === chain.id);
9
4
  };
10
- exports.networkForChain = networkForChain;
11
5
  //# sourceMappingURL=network.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/utils/network.ts"],"names":[],"mappings":";;;AAAA,2DAAmE;AAG5D,IAAM,eAAe,GAAG,UAAC,KAAY;IAC1C,OAAO,MAAM,CAAC,MAAM,CAAC,+BAAc,CAAC,CAAC,IAAI,CACvC,UAAA,OAAO;QACL,OAAA,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE;IAAlE,CAAkE,CACrE,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,eAAe,mBAK1B","sourcesContent":["import { Network, NETWORK_CONFIG } from '../models/network-config';\nimport { Chain } from '../models/response-types';\n\nexport const networkForChain = (chain: Chain): Optional<Network> => {\n return Object.values(NETWORK_CONFIG).find(\n network =>\n network.chain.type === chain.type && network.chain.id === chain.id,\n );\n};\n"]}
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/utils/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAGnE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAY,EAAqB,EAAE;IACjE,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CACvC,OAAO,CAAC,EAAE,CACR,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CACrE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Network, NETWORK_CONFIG } from '../models/network-config';\nimport { Chain } from '../models/response-types';\n\nexport const networkForChain = (chain: Chain): Optional<Network> => {\n return Object.values(NETWORK_CONFIG).find(\n network =>\n network.chain.type === chain.type && network.chain.id === chain.id,\n );\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import { JsonRpcProvider, Networkish } from 'ethers';
2
+ /**
3
+ * Uses a setting in JsonRpcProvider to poll for events,
4
+ * rather than using sparsely-implemented eth_filter events.
5
+ */
6
+ export declare class PollingJsonRpcProvider extends JsonRpcProvider {
7
+ constructor(url: string, network: Networkish);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { JsonRpcProvider } from 'ethers';
2
+ /**
3
+ * Uses a setting in JsonRpcProvider to poll for events,
4
+ * rather than using sparsely-implemented eth_filter events.
5
+ */
6
+ export class PollingJsonRpcProvider extends JsonRpcProvider {
7
+ constructor(url, network) {
8
+ super(url, network, { polling: true });
9
+ }
10
+ }
11
+ //# sourceMappingURL=polling-json-rpc-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-json-rpc-provider.js","sourceRoot":"","sources":["../../src/utils/polling-json-rpc-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAc,MAAM,QAAQ,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACzD,YAAY,GAAW,EAAE,OAAmB;QAC1C,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { JsonRpcProvider, Networkish } from 'ethers';\n\n/**\n * Uses a setting in JsonRpcProvider to poll for events,\n * rather than using sparsely-implemented eth_filter events.\n */\nexport class PollingJsonRpcProvider extends JsonRpcProvider {\n constructor(url: string, network: Networkish) {\n super(url, network, { polling: true });\n }\n}\n"]}
@@ -1,95 +1,38 @@
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 (_) 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
- exports.__esModule = true;
39
- exports.poll = exports.promiseTimeout = exports.delay = void 0;
40
- var delay = function (delayInMS) {
41
- return new Promise(function (resolve) { return setTimeout(resolve, delayInMS); });
1
+ export const delay = (delayInMS) => {
2
+ return new Promise(resolve => setTimeout(resolve, delayInMS));
42
3
  };
43
- exports.delay = delay;
44
- function promiseTimeout(promise, ms, customTimeoutError) {
4
+ export function promiseTimeout(promise, ms, customTimeoutError) {
45
5
  // Create a promise that rejects in <ms> milliseconds
46
- var timeout = new Promise(function (_resolve, reject) {
47
- var id = setTimeout(function () {
6
+ const timeout = new Promise((_resolve, reject) => {
7
+ const id = setTimeout(() => {
48
8
  clearTimeout(id);
49
- reject(new Error("Timed out in ".concat(ms, " ms.")));
9
+ reject(new Error(`Timed out in ${ms} ms.`));
50
10
  }, ms);
51
11
  });
52
12
  // Returns a race between our timeout and the passed in promise
53
13
  return Promise.race([promise, timeout])
54
- .then(function (result) { return result; })["catch"](function (err) {
14
+ .then(result => result)
15
+ .catch(err => {
55
16
  if (!(err instanceof Error)) {
56
17
  throw err;
57
18
  }
58
19
  if (err.message.startsWith('Timed out')) {
59
- throw customTimeoutError !== null && customTimeoutError !== void 0 ? customTimeoutError : err;
20
+ throw customTimeoutError ?? err;
60
21
  }
61
22
  throw err;
62
23
  });
63
24
  }
64
- exports.promiseTimeout = promiseTimeout;
65
- function poll(fn, passCondition, delayInMS, allowedAttempts) {
66
- if (allowedAttempts === void 0) { allowedAttempts = 1; }
67
- return __awaiter(this, void 0, void 0, function () {
68
- var result, attempts;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
71
- case 0: return [4 /*yield*/, fn()];
72
- case 1:
73
- result = _a.sent();
74
- attempts = 1;
75
- _a.label = 2;
76
- case 2:
77
- if (!(attempts <= allowedAttempts)) return [3 /*break*/, 5];
78
- if (passCondition(result)) {
79
- return [2 /*return*/, result];
80
- }
81
- return [4 /*yield*/, (0, exports.delay)(delayInMS)];
82
- case 3:
83
- _a.sent();
84
- return [4 /*yield*/, fn()];
85
- case 4:
86
- result = _a.sent();
87
- attempts++;
88
- return [3 /*break*/, 2];
89
- case 5: return [2 /*return*/, undefined];
90
- }
91
- });
92
- });
25
+ export async function poll(fn, passCondition, delayInMS, allowedAttempts = 1) {
26
+ let result = await fn();
27
+ let attempts = 1;
28
+ while (attempts <= allowedAttempts) {
29
+ if (passCondition(result)) {
30
+ return result;
31
+ }
32
+ await delay(delayInMS);
33
+ result = await fn();
34
+ attempts++;
35
+ }
36
+ return undefined;
93
37
  }
94
- exports.poll = poll;
95
38
  //# sourceMappingURL=promises.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"promises.js","sourceRoot":"","sources":["../../src/utils/promises.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,KAAK,GAAG,UAAC,SAAiB;IACrC,OAAO,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,EAA9B,CAA8B,CAAC,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB;AAEF,SAAgB,cAAc,CAC5B,OAAmB,EACnB,EAAU,EACV,kBAA0B;IAE1B,qDAAqD;IACrD,IAAM,OAAO,GAAG,IAAI,OAAO,CAAC,UAAC,QAAQ,EAAE,MAAM;QAC3C,IAAM,EAAE,GAAG,UAAU,CAAC;YACpB,YAAY,CAAC,EAAE,CAAC,CAAC;YACjB,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAgB,EAAE,SAAM,CAAC,CAAC,CAAC;QAC9C,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACpC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,MAAW,EAAX,CAAW,CAAC,CAC3B,OAAK,CAAA,CAAC,UAAA,GAAG;QACR,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE;YAC3B,MAAM,GAAG,CAAC;SACX;QACD,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;YACvC,MAAM,kBAAkB,aAAlB,kBAAkB,cAAlB,kBAAkB,GAAI,GAAG,CAAC;SACjC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;AACP,CAAC;AAzBD,wCAyBC;AAED,SAAsB,IAAI,CACxB,EAAoB,EACpB,aAAqC,EACrC,SAAiB,EACjB,eAAmB;IAAnB,gCAAA,EAAA,mBAAmB;;;;;wBAEN,qBAAM,EAAE,EAAE,EAAA;;oBAAnB,MAAM,GAAG,SAAU;oBACnB,QAAQ,GAAG,CAAC,CAAC;;;yBACV,CAAA,QAAQ,IAAI,eAAe,CAAA;oBAChC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;wBACzB,sBAAO,MAAM,EAAC;qBACf;oBACD,qBAAM,IAAA,aAAK,EAAC,SAAS,CAAC,EAAA;;oBAAtB,SAAsB,CAAC;oBACd,qBAAM,EAAE,EAAE,EAAA;;oBAAnB,MAAM,GAAG,SAAU,CAAC;oBACpB,QAAQ,EAAE,CAAC;;wBAEb,sBAAO,SAAS,EAAC;;;;CAClB;AAjBD,oBAiBC","sourcesContent":["export const delay = (delayInMS: number): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, delayInMS));\n};\n\nexport function promiseTimeout<T>(\n promise: Promise<T>,\n ms: number,\n customTimeoutError?: Error,\n): Promise<T> {\n // Create a promise that rejects in <ms> milliseconds\n const timeout = new Promise((_resolve, reject) => {\n const id = setTimeout(() => {\n clearTimeout(id);\n reject(new Error(`Timed out in ${ms} ms.`));\n }, ms);\n });\n\n // Returns a race between our timeout and the passed in promise\n return Promise.race([promise, timeout])\n .then(result => result as T)\n .catch(err => {\n if (!(err instanceof Error)) {\n throw err;\n }\n if (err.message.startsWith('Timed out')) {\n throw customTimeoutError ?? err;\n }\n throw err;\n });\n}\n\nexport async function poll<T>(\n fn: () => Promise<T>,\n passCondition: (result: T) => boolean,\n delayInMS: number,\n allowedAttempts = 1,\n): Promise<Optional<T>> {\n let result = await fn();\n let attempts = 1;\n while (attempts <= allowedAttempts) {\n if (passCondition(result)) {\n return result;\n }\n await delay(delayInMS);\n result = await fn();\n attempts++;\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"promises.js","sourceRoot":"","sources":["../../src/utils/promises.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,SAAiB,EAAiB,EAAE;IACxD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAC5B,OAAmB,EACnB,EAAU,EACV,kBAA0B;IAE1B,qDAAqD;IACrD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QAC/C,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;YACzB,YAAY,CAAC,EAAE,CAAC,CAAC;YACjB,MAAM,CAAC,IAAI,KAAK,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9C,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;SACpC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAW,CAAC;SAC3B,KAAK,CAAC,GAAG,CAAC,EAAE;QACX,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE;YAC3B,MAAM,GAAG,CAAC;SACX;QACD,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;YACvC,MAAM,kBAAkB,IAAI,GAAG,CAAC;SACjC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,EAAoB,EACpB,aAAqC,EACrC,SAAiB,EACjB,eAAe,GAAG,CAAC;IAEnB,IAAI,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;IACxB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,OAAO,QAAQ,IAAI,eAAe,EAAE;QAClC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;YACzB,OAAO,MAAM,CAAC;SACf;QACD,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;QACvB,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QACpB,QAAQ,EAAE,CAAC;KACZ;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["export const delay = (delayInMS: number): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, delayInMS));\n};\n\nexport function promiseTimeout<T>(\n promise: Promise<T>,\n ms: number,\n customTimeoutError?: Error,\n): Promise<T> {\n // Create a promise that rejects in <ms> milliseconds\n const timeout = new Promise((_resolve, reject) => {\n const id = setTimeout(() => {\n clearTimeout(id);\n reject(new Error(`Timed out in ${ms} ms.`));\n }, ms);\n });\n\n // Returns a race between our timeout and the passed in promise\n return Promise.race([promise, timeout])\n .then(result => result as T)\n .catch(err => {\n if (!(err instanceof Error)) {\n throw err;\n }\n if (err.message.startsWith('Timed out')) {\n throw customTimeoutError ?? err;\n }\n throw err;\n });\n}\n\nexport async function poll<T>(\n fn: () => Promise<T>,\n passCondition: (result: T) => boolean,\n delayInMS: number,\n allowedAttempts = 1,\n): Promise<Optional<T>> {\n let result = await fn();\n let attempts = 1;\n while (attempts <= allowedAttempts) {\n if (passCondition(result)) {\n return result;\n }\n await delay(delayInMS);\n result = await fn();\n attempts++;\n }\n return undefined;\n}\n"]}
@@ -1,12 +1,9 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.versionCompare = void 0;
4
- var versionCompare = function (appVersion, minVersion) {
1
+ export const versionCompare = (appVersion, minVersion) => {
5
2
  if (!appVersion || !minVersion) {
6
3
  throw new Error('Requires two version numbers to compare.');
7
4
  }
8
5
  // Adapted from https://stackoverflow.com/a/6832721
9
- var zeroExtend = true, v1parts = appVersion.split('.'), v2parts = minVersion.split('.');
6
+ const zeroExtend = true, v1parts = appVersion.split('.'), v2parts = minVersion.split('.');
10
7
  function isValidPart(x) {
11
8
  return /^\d+$/.test(x);
12
9
  }
@@ -21,9 +18,9 @@ var versionCompare = function (appVersion, minVersion) {
21
18
  v2parts.push('0');
22
19
  }
23
20
  }
24
- var v1parts_number = v1parts.map(Number);
25
- var v2parts_number = v2parts.map(Number);
26
- for (var i = 0; i < v1parts_number.length; ++i) {
21
+ const v1parts_number = v1parts.map(Number);
22
+ const v2parts_number = v2parts.map(Number);
23
+ for (let i = 0; i < v1parts_number.length; ++i) {
27
24
  if (v2parts_number.length === i) {
28
25
  return 1;
29
26
  }
@@ -42,5 +39,4 @@ var versionCompare = function (appVersion, minVersion) {
42
39
  }
43
40
  return 0;
44
41
  };
45
- exports.versionCompare = versionCompare;
46
42
  //# sourceMappingURL=versions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/utils/versions.ts"],"names":[],"mappings":";;;AAAO,IAAM,cAAc,GAAG,UAC5B,UAAmB,EACnB,UAAmB;IAEnB,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IAED,mDAAmD;IACnD,IAAM,UAAU,GAAG,IAAI,EACrB,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAC/B,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,SAAS,WAAW,CAAC,CAAS;QAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;QAC9D,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,UAAU,EAAE;QACd,OAAO,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,OAAO,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnB;KACF;IAED,IAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAC9C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO,CAAC,CAAC;SACV;QACD,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,EAAE;YAC3C,SAAS;SACV;aAAM,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE;YAChD,OAAO,CAAC,CAAC;SACV;aAAM;YACL,OAAO,CAAC,CAAC,CAAC;SACX;KACF;IACD,IAAI,cAAc,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM,EAAE;QACnD,OAAO,CAAC,CAAC,CAAC;KACX;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAhDW,QAAA,cAAc,kBAgDzB","sourcesContent":["export const versionCompare = (\n appVersion?: string,\n minVersion?: string,\n): number => {\n if (!appVersion || !minVersion) {\n throw new Error('Requires two version numbers to compare.');\n }\n\n // Adapted from https://stackoverflow.com/a/6832721\n const zeroExtend = true,\n v1parts = appVersion.split('.'),\n v2parts = minVersion.split('.');\n\n function isValidPart(x: string) {\n return /^\\d+$/.test(x);\n }\n\n if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {\n return NaN;\n }\n if (zeroExtend) {\n while (v1parts.length < v2parts.length) {\n v1parts.push('0');\n }\n while (v2parts.length < v1parts.length) {\n v2parts.push('0');\n }\n }\n\n const v1parts_number = v1parts.map(Number);\n const v2parts_number = v2parts.map(Number);\n\n for (let i = 0; i < v1parts_number.length; ++i) {\n if (v2parts_number.length === i) {\n return 1;\n }\n if (v1parts_number[i] === v2parts_number[i]) {\n continue;\n } else if (v1parts_number[i] > v2parts_number[i]) {\n return 1;\n } else {\n return -1;\n }\n }\n if (v1parts_number.length !== v2parts_number.length) {\n return -1;\n }\n return 0;\n};\n"]}
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/utils/versions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,UAAmB,EACnB,UAAmB,EACX,EAAE;IACV,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IAED,mDAAmD;IACnD,MAAM,UAAU,GAAG,IAAI,EACrB,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAC/B,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,SAAS,WAAW,CAAC,CAAS;QAC5B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;QAC9D,OAAO,GAAG,CAAC;KACZ;IACD,IAAI,UAAU,EAAE;QACd,OAAO,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,OAAO,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnB;KACF;IAED,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAC9C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,OAAO,CAAC,CAAC;SACV;QACD,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,EAAE;YAC3C,SAAS;SACV;aAAM,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE;YAChD,OAAO,CAAC,CAAC;SACV;aAAM;YACL,OAAO,CAAC,CAAC,CAAC;SACX;KACF;IACD,IAAI,cAAc,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM,EAAE;QACnD,OAAO,CAAC,CAAC,CAAC;KACX;IACD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC","sourcesContent":["export const versionCompare = (\n appVersion?: string,\n minVersion?: string,\n): number => {\n if (!appVersion || !minVersion) {\n throw new Error('Requires two version numbers to compare.');\n }\n\n // Adapted from https://stackoverflow.com/a/6832721\n const zeroExtend = true,\n v1parts = appVersion.split('.'),\n v2parts = minVersion.split('.');\n\n function isValidPart(x: string) {\n return /^\\d+$/.test(x);\n }\n\n if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {\n return NaN;\n }\n if (zeroExtend) {\n while (v1parts.length < v2parts.length) {\n v1parts.push('0');\n }\n while (v2parts.length < v1parts.length) {\n v2parts.push('0');\n }\n }\n\n const v1parts_number = v1parts.map(Number);\n const v2parts_number = v2parts.map(Number);\n\n for (let i = 0; i < v1parts_number.length; ++i) {\n if (v2parts_number.length === i) {\n return 1;\n }\n if (v1parts_number[i] === v2parts_number[i]) {\n continue;\n } else if (v1parts_number[i] > v2parts_number[i]) {\n return 1;\n } else {\n return -1;\n }\n }\n if (v1parts_number.length !== v2parts_number.length) {\n return -1;\n }\n return 0;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railgun-community/shared-models",
3
- "version": "5.0.2",
3
+ "version": "5.1.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -22,12 +22,10 @@
22
22
  "test": "npm run compile-test && mocha 'src/**/__tests__/*.test.ts'"
23
23
  },
24
24
  "peerDependencies": {
25
- "@ethersproject/bignumber": "^5.7.0",
26
- "@ethersproject/providers": "^5.7.1"
25
+ "ethers": "^6.4.0"
27
26
  },
28
27
  "devDependencies": {
29
- "@ethersproject/bignumber": "^5.7.0",
30
- "@ethersproject/providers": "^5.7.1",
28
+ "ethers": "^6.4.0",
31
29
  "@types/chai": "^4.3.4",
32
30
  "@types/chai-as-promised": "^7.1.5",
33
31
  "@types/mocha": "^10.0.1",
@@ -45,9 +43,5 @@
45
43
  "ts-node": "^10.9.1",
46
44
  "tsc-alias": "^1.8.2",
47
45
  "typescript": "^4.8.3"
48
- },
49
- "dependencies": {
50
- "@ethersproject/contracts": "^5.7.0",
51
- "@ethersproject/transactions": "^5.7.0"
52
46
  }
53
47
  }
@@ -1,5 +0,0 @@
1
- /// <reference types="../types/global" />
2
- import { PopulatedTransaction } from '@ethersproject/contracts';
3
- import { TransactionRequest } from '@ethersproject/providers';
4
- export declare const serializeUnsignedTransaction: (transaction: PopulatedTransaction) => string;
5
- export declare const deserializeTransaction: (rawTransaction: string, nonce: Optional<number>, chainId: number) => TransactionRequest;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- exports.__esModule = true;
14
- exports.deserializeTransaction = exports.serializeUnsignedTransaction = void 0;
15
- var transactions_1 = require("@ethersproject/transactions");
16
- var response_types_1 = require("../models/response-types");
17
- var validatePreserialize = function (transaction) {
18
- if (transaction.from) {
19
- throw new Error("Cannot serialize 'from' field on transaction.");
20
- }
21
- if (transaction.type === response_types_1.EVMGasType.Type0 && transaction.accessList) {
22
- throw new Error("Cannot serialize 'accessList' field on Type0 transaction.");
23
- }
24
- };
25
- var serializeUnsignedTransaction = function (transaction) {
26
- validatePreserialize(transaction);
27
- return (0, transactions_1.serialize)(transaction);
28
- };
29
- exports.serializeUnsignedTransaction = serializeUnsignedTransaction;
30
- // export const serializeSignedTransaction = (
31
- // transaction: PopulatedTransaction,
32
- // signature: SignatureLike,
33
- // ): string => {
34
- // validatePreserialize(transaction);
35
- // return serialize(transaction, signature);
36
- // };
37
- var deserializeTransaction = function (rawTransaction, nonce, chainId) {
38
- var _a, _b, _c, _d, _e;
39
- var transaction = (0, transactions_1.parse)(rawTransaction);
40
- return removeUndefinedValues(__assign(__assign({}, transaction), { type: (_a = transaction.type) !== null && _a !== void 0 ? _a : undefined, nonce: nonce, chainId: chainId,
41
- // Set gas-related vars as undefined if they're zero.
42
- gasLimit: ((_b = transaction.gasLimit) === null || _b === void 0 ? void 0 : _b.eq(0)) ? undefined : transaction.gasLimit, gasPrice: ((_c = transaction.gasPrice) === null || _c === void 0 ? void 0 : _c.eq(0)) ? undefined : transaction.gasPrice, maxFeePerGas: ((_d = transaction.maxFeePerGas) === null || _d === void 0 ? void 0 : _d.eq(0))
43
- ? undefined
44
- : transaction.maxFeePerGas, maxPriorityFeePerGas: ((_e = transaction.maxPriorityFeePerGas) === null || _e === void 0 ? void 0 : _e.eq(0))
45
- ? undefined
46
- : transaction.maxPriorityFeePerGas }));
47
- };
48
- exports.deserializeTransaction = deserializeTransaction;
49
- var removeUndefinedValues = function (tx) {
50
- return Object.fromEntries(
51
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
52
- Object.entries(tx).filter(function (_a) {
53
- var _key = _a[0], value = _a[1];
54
- return value !== undefined;
55
- }));
56
- };
57
- //# sourceMappingURL=serializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,4DAA4E;AAE5E,2DAAsD;AAEtD,IAAM,oBAAoB,GAAG,UAAC,WAAiC;IAC7D,IAAI,WAAW,CAAC,IAAI,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,2BAAU,CAAC,KAAK,IAAI,WAAW,CAAC,UAAU,EAAE;QACnE,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;KACH;AACH,CAAC,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,WAAiC;IAEjC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAClC,OAAO,IAAA,wBAAS,EAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC;AALW,QAAA,4BAA4B,gCAKvC;AAEF,8CAA8C;AAC9C,uCAAuC;AACvC,8BAA8B;AAC9B,iBAAiB;AACjB,uCAAuC;AACvC,8CAA8C;AAC9C,KAAK;AAEE,IAAM,sBAAsB,GAAG,UACpC,cAAsB,EACtB,KAAuB,EACvB,OAAe;;IAEf,IAAM,WAAW,GAAgB,IAAA,oBAAK,EAAC,cAAc,CAAC,CAAC;IACvD,OAAO,qBAAqB,uBACvB,WAAW,KACd,IAAI,EAAE,MAAA,WAAW,CAAC,IAAI,mCAAI,SAAS,EACnC,KAAK,OAAA,EACL,OAAO,SAAA;QAEP,qDAAqD;QACrD,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,QAAQ,EAAE,CAAA,MAAA,WAAW,CAAC,QAAQ,0CAAE,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EACxE,YAAY,EAAE,CAAA,MAAA,WAAW,CAAC,YAAY,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3C,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,YAAY,EAC5B,oBAAoB,EAAE,CAAA,MAAA,WAAW,CAAC,oBAAoB,0CAAE,EAAE,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,WAAW,CAAC,oBAAoB,IACpC,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,sBAAsB,0BAsBjC;AAEF,IAAM,qBAAqB,GAAG,UAAC,EAAsB;IACnD,OAAO,MAAM,CAAC,WAAW;IACvB,6DAA6D;IAC7D,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAC,EAAa;YAAZ,IAAI,QAAA,EAAE,KAAK,QAAA;QAAM,OAAA,KAAK,KAAK,SAAS;IAAnB,CAAmB,CAAC,CAClE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { PopulatedTransaction } from '@ethersproject/contracts';\nimport { parse, serialize, Transaction } from '@ethersproject/transactions';\nimport { TransactionRequest } from '@ethersproject/providers';\nimport { EVMGasType } from '../models/response-types';\n\nconst validatePreserialize = (transaction: PopulatedTransaction) => {\n if (transaction.from) {\n throw new Error(`Cannot serialize 'from' field on transaction.`);\n }\n if (transaction.type === EVMGasType.Type0 && transaction.accessList) {\n throw new Error(\n `Cannot serialize 'accessList' field on Type0 transaction.`,\n );\n }\n};\n\nexport const serializeUnsignedTransaction = (\n transaction: PopulatedTransaction,\n): string => {\n validatePreserialize(transaction);\n return serialize(transaction);\n};\n\n// export const serializeSignedTransaction = (\n// transaction: PopulatedTransaction,\n// signature: SignatureLike,\n// ): string => {\n// validatePreserialize(transaction);\n// return serialize(transaction, signature);\n// };\n\nexport const deserializeTransaction = (\n rawTransaction: string,\n nonce: Optional<number>,\n chainId: number,\n): TransactionRequest => {\n const transaction: Transaction = parse(rawTransaction);\n return removeUndefinedValues({\n ...transaction,\n type: transaction.type ?? undefined,\n nonce,\n chainId,\n\n // Set gas-related vars as undefined if they're zero.\n gasLimit: transaction.gasLimit?.eq(0) ? undefined : transaction.gasLimit,\n gasPrice: transaction.gasPrice?.eq(0) ? undefined : transaction.gasPrice,\n maxFeePerGas: transaction.maxFeePerGas?.eq(0)\n ? undefined\n : transaction.maxFeePerGas,\n maxPriorityFeePerGas: transaction.maxPriorityFeePerGas?.eq(0)\n ? undefined\n : transaction.maxPriorityFeePerGas,\n });\n};\n\nconst removeUndefinedValues = (tx: TransactionRequest): TransactionRequest => {\n return Object.fromEntries(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Object.entries(tx).filter(([_key, value]) => value !== undefined),\n );\n};\n"]}