@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.
- package/README.md +2 -0
- package/dist/index.js +2 -18
- package/dist/index.js.map +1 -1
- package/dist/models/artifact.js +2 -5
- package/dist/models/artifact.js.map +1 -1
- package/dist/models/blocked-address.js +1 -4
- package/dist/models/blocked-address.js.map +1 -1
- package/dist/models/fee-token.js +1 -2
- package/dist/models/function-types.js +1 -2
- package/dist/models/index.js +11 -27
- package/dist/models/index.js.map +1 -1
- package/dist/models/merkletree-scan.js +2 -5
- package/dist/models/merkletree-scan.js.map +1 -1
- package/dist/models/network-config.js +72 -76
- package/dist/models/network-config.js.map +1 -1
- package/dist/models/proof.js +2 -5
- package/dist/models/proof.js.map +1 -1
- package/dist/models/relayer.js +2 -5
- package/dist/models/relayer.js.map +1 -1
- package/dist/models/response-types.d.ts +15 -35
- package/dist/models/response-types.js +8 -11
- package/dist/models/response-types.js.map +1 -1
- package/dist/models/transaction.js +1 -2
- package/dist/models/wallet.js +2 -5
- package/dist/models/wallet.js.map +1 -1
- package/dist/utils/artifact-v2.js +8 -18
- package/dist/utils/artifact-v2.js.map +1 -1
- package/dist/utils/available-rpc.js +38 -98
- package/dist/utils/available-rpc.js.map +1 -1
- package/dist/utils/compare.js +1 -5
- package/dist/utils/compare.js.map +1 -1
- package/dist/utils/error.js +5 -9
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/fallback-provider.d.ts +2 -2
- package/dist/utils/fallback-provider.js +15 -36
- package/dist/utils/fallback-provider.js.map +1 -1
- package/dist/utils/format.d.ts +1 -2
- package/dist/utils/format.js +2 -11
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/gas.d.ts +5 -9
- package/dist/utils/gas.js +20 -79
- package/dist/utils/gas.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +10 -27
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/median.js +3 -7
- package/dist/utils/median.js.map +1 -1
- package/dist/utils/network.js +3 -9
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/polling-json-rpc-provider.d.ts +8 -0
- package/dist/utils/polling-json-rpc-provider.js +11 -0
- package/dist/utils/polling-json-rpc-provider.js.map +1 -0
- package/dist/utils/promises.js +21 -78
- package/dist/utils/promises.js.map +1 -1
- package/dist/utils/versions.js +5 -9
- package/dist/utils/versions.js.map +1 -1
- package/package.json +3 -9
- package/dist/utils/serializer.d.ts +0 -5
- package/dist/utils/serializer.js +0 -57
- package/dist/utils/serializer.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="../types/global" />
|
|
2
|
-
import {
|
|
2
|
+
import { PreparedTransactionRequest } from 'ethers';
|
|
3
3
|
import { MerkletreeScanStatus } from './merkletree-scan';
|
|
4
4
|
import { FeesSerialized } from './network-config';
|
|
5
5
|
export declare type RailgunAPICiphertext = {
|
|
@@ -18,36 +18,19 @@ export declare enum EVMGasType {
|
|
|
18
18
|
export declare type TransactionGasDetails = TransactionGasDetailsType0 | TransactionGasDetailsType1 | TransactionGasDetailsType2;
|
|
19
19
|
export declare type TransactionGasDetailsType0 = {
|
|
20
20
|
evmGasType: EVMGasType.Type0;
|
|
21
|
-
gasEstimate:
|
|
22
|
-
gasPrice:
|
|
21
|
+
gasEstimate: bigint;
|
|
22
|
+
gasPrice: bigint;
|
|
23
23
|
};
|
|
24
24
|
export declare type TransactionGasDetailsType1 = {
|
|
25
25
|
evmGasType: EVMGasType.Type1;
|
|
26
|
-
gasEstimate:
|
|
27
|
-
gasPrice:
|
|
26
|
+
gasEstimate: bigint;
|
|
27
|
+
gasPrice: bigint;
|
|
28
28
|
};
|
|
29
29
|
export declare type TransactionGasDetailsType2 = {
|
|
30
30
|
evmGasType: EVMGasType.Type2;
|
|
31
|
-
gasEstimate:
|
|
32
|
-
maxFeePerGas:
|
|
33
|
-
maxPriorityFeePerGas:
|
|
34
|
-
};
|
|
35
|
-
export declare type TransactionGasDetailsSerialized = TransactionGasDetailsSerializedType0 | TransactionGasDetailsSerializedType1 | TransactionGasDetailsSerializedType2;
|
|
36
|
-
export declare type TransactionGasDetailsSerializedType0 = {
|
|
37
|
-
evmGasType: EVMGasType.Type0;
|
|
38
|
-
gasEstimateString: string;
|
|
39
|
-
gasPriceString: string;
|
|
40
|
-
};
|
|
41
|
-
export declare type TransactionGasDetailsSerializedType1 = {
|
|
42
|
-
evmGasType: EVMGasType.Type1;
|
|
43
|
-
gasEstimateString: string;
|
|
44
|
-
gasPriceString: string;
|
|
45
|
-
};
|
|
46
|
-
export declare type TransactionGasDetailsSerializedType2 = {
|
|
47
|
-
evmGasType: EVMGasType.Type2;
|
|
48
|
-
gasEstimateString: string;
|
|
49
|
-
maxFeePerGasString: string;
|
|
50
|
-
maxPriorityFeePerGasString: string;
|
|
31
|
+
gasEstimate: bigint;
|
|
32
|
+
maxFeePerGas: bigint;
|
|
33
|
+
maxPriorityFeePerGas: bigint;
|
|
51
34
|
};
|
|
52
35
|
export declare enum ChainType {
|
|
53
36
|
EVM = 0
|
|
@@ -74,24 +57,24 @@ export declare type RailgunWalletInfo = {
|
|
|
74
57
|
id: string;
|
|
75
58
|
railgunAddress: string;
|
|
76
59
|
};
|
|
77
|
-
export declare type
|
|
78
|
-
masterPublicKey:
|
|
79
|
-
viewingPublicKey:
|
|
60
|
+
export declare type RailgunWalletAddressData = {
|
|
61
|
+
masterPublicKey: bigint;
|
|
62
|
+
viewingPublicKey: bigint;
|
|
80
63
|
};
|
|
81
64
|
export declare type RailgunTxidFromNullifiersResponse = {
|
|
82
65
|
txid?: string;
|
|
83
66
|
};
|
|
84
67
|
export declare type RailgunPopulateTransactionResponse = {
|
|
85
|
-
|
|
68
|
+
transaction: PreparedTransactionRequest;
|
|
86
69
|
nullifiers?: string[];
|
|
87
70
|
};
|
|
88
71
|
export declare type RailgunTransactionGasEstimateResponse = {
|
|
89
|
-
|
|
72
|
+
gasEstimate: bigint;
|
|
90
73
|
relayerFeeCommitment?: CommitmentSummary;
|
|
91
74
|
};
|
|
92
75
|
export declare type RailgunERC20Amount = {
|
|
93
76
|
tokenAddress: string;
|
|
94
|
-
|
|
77
|
+
amount: bigint;
|
|
95
78
|
};
|
|
96
79
|
export declare type RailgunERC20AmountRecipient = RailgunERC20Amount & {
|
|
97
80
|
recipientAddress: string;
|
|
@@ -107,7 +90,7 @@ export declare type RailgunNFTAmount = {
|
|
|
107
90
|
nftAddress: string;
|
|
108
91
|
nftTokenType: NFTTokenType;
|
|
109
92
|
tokenSubID: string;
|
|
110
|
-
|
|
93
|
+
amount: bigint;
|
|
111
94
|
};
|
|
112
95
|
export declare type RailgunNFTAmountRecipient = RailgunNFTAmount & {
|
|
113
96
|
recipientAddress: string;
|
|
@@ -164,9 +147,6 @@ export declare type TransactionHistoryItem = {
|
|
|
164
147
|
unshieldNFTAmounts: RailgunUnshieldNFTAmount[];
|
|
165
148
|
category: TransactionHistoryItemCategory;
|
|
166
149
|
};
|
|
167
|
-
export declare type TransactionHistorySerializedResponse = {
|
|
168
|
-
items: TransactionHistoryItem[];
|
|
169
|
-
};
|
|
170
150
|
declare type Ciphertext = {
|
|
171
151
|
iv: string;
|
|
172
152
|
tag: string;
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.TransactionHistoryItemCategory = exports.NFTTokenType = exports.ChainType = exports.EVMGasType = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Type0 / Type1 = non-EIP-1559 (gasPrice).
|
|
6
3
|
* Type2 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).
|
|
7
4
|
*/
|
|
8
|
-
var EVMGasType;
|
|
5
|
+
export var EVMGasType;
|
|
9
6
|
(function (EVMGasType) {
|
|
10
7
|
EVMGasType[EVMGasType["Type0"] = 0] = "Type0";
|
|
11
8
|
EVMGasType[EVMGasType["Type1"] = 1] = "Type1";
|
|
12
9
|
EVMGasType[EVMGasType["Type2"] = 2] = "Type2";
|
|
13
|
-
})(EVMGasType
|
|
14
|
-
var ChainType;
|
|
10
|
+
})(EVMGasType || (EVMGasType = {}));
|
|
11
|
+
export var ChainType;
|
|
15
12
|
(function (ChainType) {
|
|
16
13
|
ChainType[ChainType["EVM"] = 0] = "EVM";
|
|
17
|
-
})(ChainType
|
|
14
|
+
})(ChainType || (ChainType = {}));
|
|
18
15
|
/**
|
|
19
16
|
* Synced NFT types from TokenType (@railgun-community/engine).
|
|
20
17
|
*/
|
|
21
|
-
var NFTTokenType;
|
|
18
|
+
export var NFTTokenType;
|
|
22
19
|
(function (NFTTokenType) {
|
|
23
20
|
NFTTokenType[NFTTokenType["ERC721"] = 1] = "ERC721";
|
|
24
21
|
NFTTokenType[NFTTokenType["ERC1155"] = 2] = "ERC1155";
|
|
25
|
-
})(NFTTokenType
|
|
26
|
-
var TransactionHistoryItemCategory;
|
|
22
|
+
})(NFTTokenType || (NFTTokenType = {}));
|
|
23
|
+
export var TransactionHistoryItemCategory;
|
|
27
24
|
(function (TransactionHistoryItemCategory) {
|
|
28
25
|
TransactionHistoryItemCategory["ShieldERC20s"] = "ShieldERC20s";
|
|
29
26
|
TransactionHistoryItemCategory["UnshieldERC20s"] = "UnshieldERC20s";
|
|
30
27
|
TransactionHistoryItemCategory["TransferSendERC20s"] = "TransferSendERC20s";
|
|
31
28
|
TransactionHistoryItemCategory["TransferReceiveERC20s"] = "TransferReceiveERC20s";
|
|
32
29
|
TransactionHistoryItemCategory["Unknown"] = "Unknown";
|
|
33
|
-
})(TransactionHistoryItemCategory
|
|
30
|
+
})(TransactionHistoryItemCategory || (TransactionHistoryItemCategory = {}));
|
|
34
31
|
//# sourceMappingURL=response-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-types.js","sourceRoot":"","sources":["../../src/models/response-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"response-types.js","sourceRoot":"","sources":["../../src/models/response-types.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,6CAAS,CAAA;IACT,6CAAS,CAAA;AACX,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AA0BD,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,uCAAO,CAAA;AACT,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB;AAyDD;;GAEG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AA0DD,MAAM,CAAN,IAAY,8BAMX;AAND,WAAY,8BAA8B;IACxC,+DAA6B,CAAA;IAC7B,mEAAiC,CAAA;IACjC,2EAAyC,CAAA;IACzC,iFAA+C,CAAA;IAC/C,qDAAmB,CAAA;AACrB,CAAC,EANW,8BAA8B,KAA9B,8BAA8B,QAMzC","sourcesContent":["/// <reference types=\"../types/global\" />\nimport { PreparedTransactionRequest } from 'ethers';\nimport { MerkletreeScanStatus } from './merkletree-scan';\nimport { FeesSerialized } from './network-config';\n\nexport type RailgunAPICiphertext = {\n iv: string;\n data: string[];\n};\n\n/**\n * Type0 / Type1 = non-EIP-1559 (gasPrice).\n * Type2 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).\n */\nexport enum EVMGasType {\n Type0 = 0,\n Type1 = 1,\n Type2 = 2,\n}\n\nexport type TransactionGasDetails =\n | TransactionGasDetailsType0\n | TransactionGasDetailsType1\n | TransactionGasDetailsType2;\n\nexport type TransactionGasDetailsType0 = {\n evmGasType: EVMGasType.Type0;\n gasEstimate: bigint;\n gasPrice: bigint;\n};\n\nexport type TransactionGasDetailsType1 = {\n evmGasType: EVMGasType.Type1;\n gasEstimate: bigint;\n gasPrice: bigint;\n};\n\nexport type TransactionGasDetailsType2 = {\n evmGasType: EVMGasType.Type2;\n gasEstimate: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n};\n\nexport enum ChainType {\n EVM = 0,\n}\n\nexport type Chain = {\n type: ChainType;\n id: number;\n};\n\nexport type RailgunBalancesEvent = {\n chain: Chain;\n erc20Amounts: RailgunERC20Amount[];\n nftAmounts: RailgunNFTAmount[];\n railgunWalletID: string;\n};\n\nexport type MerkletreeScanUpdateEvent = {\n chain: Chain;\n scanStatus: MerkletreeScanStatus;\n progress: number;\n};\n\nexport type LoadProviderResponse = {\n feesSerialized: FeesSerialized;\n};\n\nexport type RailgunWalletInfo = {\n id: string;\n railgunAddress: string;\n};\n\nexport type RailgunWalletAddressData = {\n masterPublicKey: bigint;\n viewingPublicKey: bigint;\n};\n\nexport type RailgunTxidFromNullifiersResponse = {\n txid?: string;\n};\n\nexport type RailgunPopulateTransactionResponse = {\n transaction: PreparedTransactionRequest;\n nullifiers?: string[];\n};\n\nexport type RailgunTransactionGasEstimateResponse = {\n gasEstimate: bigint;\n relayerFeeCommitment?: CommitmentSummary;\n};\n\nexport type RailgunERC20Amount = {\n tokenAddress: string;\n amount: bigint;\n};\n\nexport type RailgunERC20AmountRecipient = RailgunERC20Amount & {\n recipientAddress: string;\n};\n\n/**\n * Synced NFT types from TokenType (@railgun-community/engine).\n */\nexport enum NFTTokenType {\n ERC721 = 1,\n ERC1155 = 2,\n}\n\nexport type RailgunNFTAmount = {\n nftAddress: string;\n nftTokenType: NFTTokenType;\n tokenSubID: string;\n amount: bigint;\n};\n\nexport type RailgunNFTAmountRecipient = RailgunNFTAmount & {\n recipientAddress: string;\n};\n\nexport type EncryptDataWithSharedKeyResponse = {\n encryptedData: [string, string];\n randomPubKey: string;\n sharedKey: Uint8Array;\n};\n\nexport type EncryptDataWithSharedKeySerialized = {\n encryptedData: [string, string];\n randomPubKey: string;\n sharedKey: string;\n};\n\nexport type Pbkdf2Response = string;\n\ntype SendAdditionalData = {\n recipientAddress: Optional<string>;\n walletSource: Optional<string>;\n memoText: Optional<string>;\n};\n\nexport type RailgunSendERC20Amount = RailgunERC20Amount & SendAdditionalData;\n\nexport type RailgunSendNFTAmount = RailgunNFTAmount & SendAdditionalData;\n\ntype UnshieldAdditonalData = {\n unshieldFee: Optional<string>;\n};\n\nexport type RailgunUnshieldERC20Amount = RailgunSendERC20Amount &\n UnshieldAdditonalData;\n\nexport type RailgunUnshieldNFTAmount = RailgunSendNFTAmount &\n UnshieldAdditonalData;\n\ntype ReceiveAdditionalData = {\n senderAddress: Optional<string>;\n memoText: Optional<string>;\n shieldFee: Optional<string>;\n};\n\nexport type RailgunReceiveERC20Amount = RailgunERC20Amount &\n ReceiveAdditionalData;\n\nexport type RailgunReceiveNFTAmount = RailgunNFTAmount & ReceiveAdditionalData;\n\nexport enum TransactionHistoryItemCategory {\n ShieldERC20s = 'ShieldERC20s',\n UnshieldERC20s = 'UnshieldERC20s',\n TransferSendERC20s = 'TransferSendERC20s',\n TransferReceiveERC20s = 'TransferReceiveERC20s',\n Unknown = 'Unknown',\n}\n\nexport type TransactionHistoryItem = {\n txid: string;\n version: number;\n timestamp: Optional<number>;\n blockNumber: Optional<number>;\n receiveERC20Amounts: RailgunReceiveERC20Amount[];\n transferERC20Amounts: RailgunSendERC20Amount[];\n changeERC20Amounts: RailgunERC20Amount[];\n relayerFeeERC20Amount?: RailgunERC20Amount;\n unshieldERC20Amounts: RailgunUnshieldERC20Amount[];\n receiveNFTAmounts: RailgunReceiveNFTAmount[];\n transferNFTAmounts: RailgunSendNFTAmount[];\n unshieldNFTAmounts: RailgunUnshieldNFTAmount[];\n category: TransactionHistoryItemCategory;\n};\n\ntype Ciphertext = {\n iv: string;\n tag: string;\n data: string[];\n};\n\nexport type CommitmentCiphertext = {\n ciphertext: Ciphertext;\n blindedSenderViewingKey: string;\n blindedReceiverViewingKey: string;\n annotationData: string;\n memo: string;\n};\n\nexport type CommitmentSummary = {\n commitmentCiphertext: CommitmentCiphertext;\n commitmentHash: string;\n};\n"]}
|
package/dist/models/wallet.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.WalletCreationType = void 0;
|
|
4
|
-
var WalletCreationType;
|
|
1
|
+
export var WalletCreationType;
|
|
5
2
|
(function (WalletCreationType) {
|
|
6
3
|
WalletCreationType["Import"] = "Import";
|
|
7
4
|
WalletCreationType["Create"] = "Create";
|
|
8
5
|
WalletCreationType["AddViewOnly"] = "AddViewOnly";
|
|
9
6
|
WalletCreationType["ImportFromBackup"] = "ImportFromBackup";
|
|
10
|
-
})(WalletCreationType
|
|
7
|
+
})(WalletCreationType || (WalletCreationType = {}));
|
|
11
8
|
//# sourceMappingURL=wallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/models/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/models/wallet.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,iDAA2B,CAAA;IAC3B,2DAAqC,CAAA;AACvC,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B","sourcesContent":["export enum WalletCreationType {\n Import = 'Import',\n Create = 'Create',\n AddViewOnly = 'AddViewOnly',\n ImportFromBackup = 'ImportFromBackup',\n}\n"]}
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.assertArtifactExists = exports.artifactExists = void 0;
|
|
7
|
-
var artifacts_json_1 = __importDefault(require("../json/artifacts.json"));
|
|
8
|
-
var artifactExists = function (nullifiers, commitments) {
|
|
9
|
-
var found = artifacts_json_1["default"].find(function (artifact) {
|
|
10
|
-
return artifact.nullifiers === nullifiers &&
|
|
11
|
-
artifact.commitments === commitments;
|
|
12
|
-
});
|
|
1
|
+
import ArtifactsMetadata from '../json/artifacts.json';
|
|
2
|
+
export const artifactExists = (nullifiers, commitments) => {
|
|
3
|
+
const found = ArtifactsMetadata.find(artifact => artifact.nullifiers === nullifiers &&
|
|
4
|
+
artifact.commitments === commitments);
|
|
13
5
|
return found != null;
|
|
14
6
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return new Error("No artifacts for inputs: ".concat(nullifiers, "-").concat(commitments));
|
|
7
|
+
const artifactError = (nullifiers, commitments) => {
|
|
8
|
+
return new Error(`No artifacts for inputs: ${nullifiers}-${commitments}`);
|
|
18
9
|
};
|
|
19
|
-
|
|
20
|
-
if (
|
|
10
|
+
export const assertArtifactExists = (nullifiers, commitments) => {
|
|
11
|
+
if (artifactExists(nullifiers, commitments)) {
|
|
21
12
|
return;
|
|
22
13
|
}
|
|
23
14
|
throw artifactError(nullifiers, commitments);
|
|
24
15
|
};
|
|
25
|
-
exports.assertArtifactExists = assertArtifactExists;
|
|
26
16
|
//# sourceMappingURL=artifact-v2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-v2.js","sourceRoot":"","sources":["../../src/utils/artifact-v2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"artifact-v2.js","sourceRoot":"","sources":["../../src/utils/artifact-v2.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,UAAkB,EAClB,WAAmB,EACV,EAAE;IACX,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAClC,QAAQ,CAAC,EAAE,CACT,QAAQ,CAAC,UAAU,KAAK,UAAU;QAClC,QAAQ,CAAC,WAAW,KAAK,WAAW,CACvC,CAAC;IACF,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,WAAmB,EAAE,EAAE;IAChE,OAAO,IAAI,KAAK,CAAC,4BAA4B,UAAU,IAAI,WAAW,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAAkB,EAClB,WAAmB,EACnB,EAAE;IACF,IAAI,cAAc,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE;QAC3C,OAAO;KACR;IACD,MAAM,aAAa,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import ArtifactsMetadata from '../json/artifacts.json';\n\nexport const artifactExists = (\n nullifiers: number,\n commitments: number,\n): boolean => {\n const found = ArtifactsMetadata.find(\n artifact =>\n artifact.nullifiers === nullifiers &&\n artifact.commitments === commitments,\n );\n return found != null;\n};\n\nconst artifactError = (nullifiers: number, commitments: number) => {\n return new Error(`No artifacts for inputs: ${nullifiers}-${commitments}`);\n};\n\nexport const assertArtifactExists = (\n nullifiers: number,\n commitments: number,\n) => {\n if (artifactExists(nullifiers, commitments)) {\n return;\n }\n throw artifactError(nullifiers, commitments);\n};\n"]}
|
|
@@ -1,106 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.getAvailableProviderJSONs = void 0;
|
|
40
|
-
var providers_1 = require("@ethersproject/providers");
|
|
41
|
-
var median_1 = require("./median");
|
|
42
|
-
var promises_1 = require("./promises");
|
|
43
|
-
var BLOCK_NUMBER_TIMEOUT_MS = 5000;
|
|
1
|
+
import { JsonRpcProvider } from 'ethers';
|
|
2
|
+
import { getUpperBoundMedian } from './median';
|
|
3
|
+
import { promiseTimeout } from './promises';
|
|
4
|
+
const BLOCK_NUMBER_TIMEOUT_MS = 5000;
|
|
44
5
|
/**
|
|
45
6
|
* Health checks ProviderJson inputs, and returns an array of available RPC providers.
|
|
46
7
|
* Available means that they respond to getBlockNumber(), and they are +/- 100 blocks from the median.
|
|
47
8
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
blockNumbers = _a.sent();
|
|
60
|
-
nonZeroBlockNumbers = blockNumbers.filter(function (blockNumber) { return blockNumber != null && blockNumber > 0; });
|
|
61
|
-
medianBlockNumber = (0, median_1.getUpperBoundMedian)(nonZeroBlockNumbers);
|
|
62
|
-
lowerBoundRange = medianBlockNumber - 100;
|
|
63
|
-
upperBoundRange = medianBlockNumber + 100;
|
|
64
|
-
return [2 /*return*/, providerJsons.filter(function (providerJson, index) {
|
|
65
|
-
var blockNumber = blockNumbers[index];
|
|
66
|
-
if (blockNumber == null) {
|
|
67
|
-
logError("RPC Health Check failed for ".concat(providerJson.provider, ": No Block Number"));
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
if (blockNumber < lowerBoundRange) {
|
|
71
|
-
logError("RPC Health Check failed for ".concat(providerJson.provider, ": Block Number -").concat(medianBlockNumber - blockNumber, " from median"));
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
if (blockNumber > upperBoundRange) {
|
|
75
|
-
logError("RPC Health Check failed for ".concat(providerJson.provider, ": Block Number +").concat(blockNumber - medianBlockNumber, " from median"));
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
})];
|
|
9
|
+
export const getAvailableProviderJSONs = async (providerJsons, logError) => {
|
|
10
|
+
const blockNumbers = await Promise.all(providerJsons.map(async (providerJson) => await getBlockNumber(providerJson.provider, logError)));
|
|
11
|
+
const nonZeroBlockNumbers = blockNumbers.filter(blockNumber => blockNumber != null && blockNumber > 0);
|
|
12
|
+
const medianBlockNumber = getUpperBoundMedian(nonZeroBlockNumbers);
|
|
13
|
+
const lowerBoundRange = medianBlockNumber - 100;
|
|
14
|
+
const upperBoundRange = medianBlockNumber + 100;
|
|
15
|
+
return providerJsons.filter((providerJson, index) => {
|
|
16
|
+
const blockNumber = blockNumbers[index];
|
|
17
|
+
if (blockNumber == null) {
|
|
18
|
+
logError(`RPC Health Check failed for ${providerJson.provider}: No Block Number`);
|
|
19
|
+
return false;
|
|
80
20
|
}
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 0:
|
|
89
|
-
_a.trys.push([0, 2, , 3]);
|
|
90
|
-
rpcProvider = new providers_1.JsonRpcProvider(provider);
|
|
91
|
-
return [4 /*yield*/, (0, promises_1.promiseTimeout)(rpcProvider.getBlockNumber(), BLOCK_NUMBER_TIMEOUT_MS)];
|
|
92
|
-
case 1:
|
|
93
|
-
blockNumber = _a.sent();
|
|
94
|
-
return [2 /*return*/, blockNumber];
|
|
95
|
-
case 2:
|
|
96
|
-
err_1 = _a.sent();
|
|
97
|
-
if (!(err_1 instanceof Error)) {
|
|
98
|
-
throw err_1;
|
|
99
|
-
}
|
|
100
|
-
logError(err_1.message);
|
|
101
|
-
return [2 /*return*/, undefined];
|
|
102
|
-
case 3: return [2 /*return*/];
|
|
21
|
+
if (blockNumber < lowerBoundRange) {
|
|
22
|
+
logError(`RPC Health Check failed for ${providerJson.provider}: Block Number -${medianBlockNumber - blockNumber} from median`);
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (blockNumber > upperBoundRange) {
|
|
26
|
+
logError(`RPC Health Check failed for ${providerJson.provider}: Block Number +${blockNumber - medianBlockNumber} from median`);
|
|
27
|
+
return false;
|
|
103
28
|
}
|
|
29
|
+
return true;
|
|
104
30
|
});
|
|
105
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const getBlockNumber = async (provider, logError) => {
|
|
33
|
+
try {
|
|
34
|
+
const rpcProvider = new JsonRpcProvider(provider);
|
|
35
|
+
const blockNumber = await promiseTimeout(rpcProvider.getBlockNumber(), BLOCK_NUMBER_TIMEOUT_MS);
|
|
36
|
+
return blockNumber;
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (!(err instanceof Error)) {
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
logError(err.message);
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
106
46
|
//# sourceMappingURL=available-rpc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"available-rpc.js","sourceRoot":"","sources":["../../src/utils/available-rpc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"available-rpc.js","sourceRoot":"","sources":["../../src/utils/available-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI5C,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAC5C,aAA6B,EAC7B,QAAkB,EACO,EAAE;IAC3B,MAAM,YAAY,GAAuB,MAAM,OAAO,CAAC,GAAG,CACxD,aAAa,CAAC,GAAG,CACf,KAAK,EAAC,YAAY,EAAC,EAAE,CACnB,MAAM,cAAc,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACxD,CACF,CAAC;IAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC,MAAM,CAC7C,WAAW,CAAC,EAAE,CAAC,WAAW,IAA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C,OAAO,CAAC,CAAC;QACtB,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC","sourcesContent":["import { JsonRpcProvider } from 'ethers';\nimport { ProviderJson } from './fallback-provider';\nimport { getUpperBoundMedian } from './median';\nimport { promiseTimeout } from './promises';\n\ntype LogError = (err: string) => void;\n\nconst BLOCK_NUMBER_TIMEOUT_MS = 5000;\n\n/**\n * Health checks ProviderJson inputs, and returns an array of available RPC providers.\n * Available means that they respond to getBlockNumber(), and they are +/- 100 blocks from the median.\n */\nexport const getAvailableProviderJSONs = async (\n providerJsons: ProviderJson[],\n logError: LogError,\n): Promise<ProviderJson[]> => {\n const blockNumbers: Optional<number>[] = await Promise.all(\n providerJsons.map(\n async providerJson =>\n await getBlockNumber(providerJson.provider, logError),\n ),\n );\n\n const nonZeroBlockNumbers = blockNumbers.filter(\n blockNumber => blockNumber != null && blockNumber > 0,\n ) as number[];\n const medianBlockNumber = getUpperBoundMedian(nonZeroBlockNumbers);\n const lowerBoundRange = medianBlockNumber - 100;\n const upperBoundRange = medianBlockNumber + 100;\n\n return providerJsons.filter((providerJson, index) => {\n const blockNumber = blockNumbers[index];\n if (blockNumber == null) {\n logError(\n `RPC Health Check failed for ${providerJson.provider}: No Block Number`,\n );\n return false;\n }\n if (blockNumber < lowerBoundRange) {\n logError(\n `RPC Health Check failed for ${providerJson.provider}: Block Number -${\n medianBlockNumber - blockNumber\n } from median`,\n );\n return false;\n }\n if (blockNumber > upperBoundRange) {\n logError(\n `RPC Health Check failed for ${providerJson.provider}: Block Number +${\n blockNumber - medianBlockNumber\n } from median`,\n );\n return false;\n }\n return true;\n });\n};\n\nconst getBlockNumber = async (\n provider: string,\n logError: LogError,\n): Promise<Optional<number>> => {\n try {\n const rpcProvider = new JsonRpcProvider(provider);\n const blockNumber = await promiseTimeout(\n rpcProvider.getBlockNumber(),\n BLOCK_NUMBER_TIMEOUT_MS,\n );\n return blockNumber;\n } catch (err) {\n if (!(err instanceof Error)) {\n throw err;\n }\n logError(err.message);\n return undefined;\n }\n};\n"]}
|
package/dist/utils/compare.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.compareChains = void 0;
|
|
4
|
-
var compareChains = function (chainA, chainB) {
|
|
1
|
+
export const compareChains = (chainA, chainB) => {
|
|
5
2
|
return chainA.type === chainB.type && chainA.id === chainB.id;
|
|
6
3
|
};
|
|
7
|
-
exports.compareChains = compareChains;
|
|
8
4
|
//# sourceMappingURL=compare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/utils/compare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/utils/compare.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAa,EAAE,MAAa,EAAE,EAAE;IAC5D,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC;AAChE,CAAC,CAAC","sourcesContent":["import { Chain } from '../models/response-types';\n\nexport const compareChains = (chainA: Chain, chainB: Chain) => {\n return chainA.type === chainB.type && chainA.id === chainB.id;\n};\n"]}
|
package/dist/utils/error.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.sanitizeError = void 0;
|
|
4
|
-
var STRING_PREFIX_AFTER_UNICODE_REPLACEMENT = 'y %';
|
|
5
|
-
var validAscii = function (str) {
|
|
1
|
+
const STRING_PREFIX_AFTER_UNICODE_REPLACEMENT = 'y %';
|
|
2
|
+
const validAscii = (str) => {
|
|
6
3
|
return str.replace(
|
|
7
4
|
// eslint-disable-next-line no-useless-escape
|
|
8
5
|
/[^A-Za-z 0-9 \.,\?""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]*/g, '');
|
|
9
6
|
};
|
|
10
|
-
|
|
7
|
+
export const sanitizeError = (err) => {
|
|
11
8
|
if (err && err.message) {
|
|
12
|
-
|
|
9
|
+
const lowercaseMsg = err.message.toLowerCase();
|
|
13
10
|
if (lowercaseMsg.includes('quorum') ||
|
|
14
11
|
lowercaseMsg.includes('could not connect to')) {
|
|
15
12
|
return new Error('Could not connect.');
|
|
@@ -73,9 +70,8 @@ var sanitizeError = function (err) {
|
|
|
73
70
|
return new Error('RailgunSmartWallet: Invalid Snark Proof. Please re-prove your transaction.');
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
|
-
return new Error(validAscii(err.message).replace(
|
|
73
|
+
return new Error(validAscii(err.message).replace(`:${STRING_PREFIX_AFTER_UNICODE_REPLACEMENT}`, ': '));
|
|
77
74
|
}
|
|
78
75
|
return new Error('Unknown error. Please try again.');
|
|
79
76
|
};
|
|
80
|
-
exports.sanitizeError = sanitizeError;
|
|
81
77
|
//# sourceMappingURL=error.js.map
|
package/dist/utils/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA,MAAM,uCAAuC,GAAG,KAAK,CAAC;AAEtD,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;IACjC,OAAO,GAAG,CAAC,OAAO;IAChB,6CAA6C;IAC7C,iEAAiE,EACjE,EAAE,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAU,EAAS,EAAE;IACjD,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;QACtB,MAAM,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC/C,IACE,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC/B,YAAY,C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MENT = 'y %';\n\nconst validAscii = (str: string) => {\n return str.replace(\n // eslint-disable-next-line no-useless-escape\n /[^A-Za-z 0-9 \\.,\\?\"\"!@#\\$%\\^&\\*\\(\\)-_=\\+;:<>\\/\\\\\\|\\}\\{\\[\\]`~]*/g,\n '',\n );\n};\n\nexport const sanitizeError = (err: Error): Error => {\n if (err && err.message) {\n const lowercaseMsg = err.message.toLowerCase();\n if (\n lowercaseMsg.includes('quorum') ||\n lowercaseMsg.includes('could not connect to')\n ) {\n return new Error('Could not connect.');\n }\n if (lowercaseMsg.includes('call revert exception')) {\n return new Error('Failed to connect to RPC.');\n }\n if (lowercaseMsg.includes('missing revert data')) {\n return new Error('RPC connection error.');\n }\n if (\n lowercaseMsg.includes(\n 'transaction may fail or may require manual gas limit',\n )\n ) {\n return new Error('Unknown error. Transaction failed.');\n }\n if (lowercaseMsg.includes('replacement fee too low')) {\n return new Error(\n 'Nonce is used in a pending transaction, and replacement fee is too low. Please increase your network fee to replace the pending transaction.',\n );\n }\n if (lowercaseMsg.includes('intrinsic gas too low')) {\n return new Error(\n 'Gas price rejected. Please select a higher gas price or resubmit.',\n );\n }\n if (lowercaseMsg.includes('transaction underpriced')) {\n return new Error(\n 'Gas fee too low. Please select a higher gas price and resubmit.',\n );\n }\n if (lowercaseMsg.includes('insufficient funds for intrinsic')) {\n return new Error('Insufficient gas to process transaction.');\n }\n if (lowercaseMsg.includes('nonce has already been used')) {\n return new Error(\n // Do not change 'Nonce already used' string of Error message.\n 'Nonce already used: the transaction was already completed.',\n );\n }\n if (lowercaseMsg.includes('error while dialing dial tcp')) {\n return new Error(\n 'Error while connecting to RPC provider. Please try again.',\n );\n }\n\n // Custom RAILGUN contract error messages\n if (lowercaseMsg.includes('railgunsmartwallet')) {\n if (lowercaseMsg.includes('invalid nft note value')) {\n return new Error('RailgunSmartWallet: Invalid NFT Note Value.');\n }\n if (lowercaseMsg.includes('unsupported token')) {\n return new Error(\n 'RailgunSmartWallet: Unsupported Token. This token cannot interact with the RAILGUN contract.',\n );\n }\n if (lowercaseMsg.includes('invalid note value')) {\n return new Error(\n 'RailgunSmartWallet: Invalid Note Value. Please submit transaction with a corrected amount.',\n );\n }\n if (lowercaseMsg.includes('invalid adapt contract as sender')) {\n return new Error(\n 'RailgunSmartWallet: Invalid Adapt Contract as Sender. Please update your frontend to current Adapt module versions.',\n );\n }\n if (lowercaseMsg.includes('invalid merkle root')) {\n return new Error(\n 'RailgunSmartWallet: Invalid Merkle Root. Please sync your balances and try again.',\n );\n }\n if (lowercaseMsg.includes('note already spent')) {\n return new Error(\n 'RailgunSmartWallet: Note Already Spent. Please sync your balances and try again.',\n );\n }\n if (lowercaseMsg.includes('invalid note ciphertext array length')) {\n return new Error(\n 'RailgunSmartWallet: Invalid Note Ciphertext Array Length. Please sync balances and re-prove your transaction.',\n );\n }\n if (lowercaseMsg.includes('invalid withdraw note')) {\n return new Error(\n 'RailgunSmartWallet: Invalid Unshield Note. Please sync balances and re-prove your transaction.',\n );\n }\n if (lowercaseMsg.includes('invalid snark proof')) {\n return new Error(\n 'RailgunSmartWallet: Invalid Snark Proof. Please re-prove your transaction.',\n );\n }\n }\n\n return new Error(\n validAscii(err.message).replace(\n `:${STRING_PREFIX_AFTER_UNICODE_REPLACEMENT}`,\n ': ',\n ),\n );\n }\n\n return new Error('Unknown error. Please try again.');\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FallbackProvider } from '
|
|
1
|
+
import { FallbackProvider } from 'ethers';
|
|
2
2
|
export declare type FallbackProviderJsonConfig = {
|
|
3
3
|
chainId: number;
|
|
4
4
|
providers: ProviderJson[];
|
|
@@ -8,4 +8,4 @@ export declare type ProviderJson = {
|
|
|
8
8
|
weight: number;
|
|
9
9
|
provider: string;
|
|
10
10
|
};
|
|
11
|
-
export declare const createFallbackProviderFromJsonConfig: (config: FallbackProviderJsonConfig
|
|
11
|
+
export declare const createFallbackProviderFromJsonConfig: (config: FallbackProviderJsonConfig) => FallbackProvider;
|
|
@@ -1,46 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.createFallbackProviderFromJsonConfig = void 0;
|
|
15
|
-
var providers_1 = require("@ethersproject/providers");
|
|
16
|
-
var createFallbackProviderFromJsonConfig = function (config, debugMessage) {
|
|
1
|
+
import { FallbackProvider, WebSocketProvider } from 'ethers';
|
|
2
|
+
import { PollingJsonRpcProvider } from './polling-json-rpc-provider';
|
|
3
|
+
export const createFallbackProviderFromJsonConfig = (config) => {
|
|
17
4
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
? new
|
|
22
|
-
: new
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
debugMessage("Provider connection: ".concat(debug.backend.provider
|
|
28
|
-
? debug.backend.provider.connection
|
|
29
|
-
: undefined));
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return __assign(__assign({}, json), { provider: provider });
|
|
5
|
+
const providers = config.providers.map(json => {
|
|
6
|
+
const isWebsocket = json.provider.startsWith('wss');
|
|
7
|
+
const provider = isWebsocket
|
|
8
|
+
? new WebSocketProvider(json.provider, Number(config.chainId))
|
|
9
|
+
: new PollingJsonRpcProvider(json.provider, Number(config.chainId));
|
|
10
|
+
return {
|
|
11
|
+
...json,
|
|
12
|
+
provider,
|
|
13
|
+
};
|
|
34
14
|
});
|
|
35
|
-
|
|
36
|
-
return new
|
|
15
|
+
const quorum = 1;
|
|
16
|
+
return new FallbackProvider(providers, quorum);
|
|
37
17
|
}
|
|
38
18
|
catch (err) {
|
|
39
19
|
if (!(err instanceof Error)) {
|
|
40
20
|
throw err;
|
|
41
21
|
}
|
|
42
|
-
throw new Error(
|
|
22
|
+
throw new Error(`Invalid fallback provider config: ${err.message}`);
|
|
43
23
|
}
|
|
44
24
|
};
|
|
45
|
-
exports.createFallbackProviderFromJsonConfig = createFallbackProviderFromJsonConfig;
|
|
46
25
|
//# sourceMappingURL=fallback-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/utils/fallback-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/utils/fallback-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAarE,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAClD,MAAkC,EAChB,EAAE;IACpB,IAAI;QACF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACpD,MAAM,QAAQ,GAAG,WAAW;gBAC1B,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC9D,CAAC,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;YACtE,OAAO;gBACL,GAAG,IAAI;gBACP,QAAQ;aACT,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,CAAC,CAAC;QACjB,OAAO,IAAI,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;KAChD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE;YAC3B,MAAM,GAAG,CAAC;SACX;QACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;KACrE;AACH,CAAC,CAAC","sourcesContent":["import { FallbackProvider, WebSocketProvider } from 'ethers';\nimport { PollingJsonRpcProvider } from './polling-json-rpc-provider';\n\nexport type FallbackProviderJsonConfig = {\n chainId: number;\n providers: ProviderJson[];\n};\n\nexport type ProviderJson = {\n priority: number;\n weight: number;\n provider: string;\n};\n\nexport const createFallbackProviderFromJsonConfig = (\n config: FallbackProviderJsonConfig,\n): FallbackProvider => {\n try {\n const providers = config.providers.map(json => {\n const isWebsocket = json.provider.startsWith('wss');\n const provider = isWebsocket\n ? new WebSocketProvider(json.provider, Number(config.chainId))\n : new PollingJsonRpcProvider(json.provider, Number(config.chainId));\n return {\n ...json,\n provider,\n };\n });\n\n const quorum = 1;\n return new FallbackProvider(providers, quorum);\n } catch (err) {\n if (!(err instanceof Error)) {\n throw err;\n }\n throw new Error(`Invalid fallback provider config: ${err.message}`);\n }\n};\n"]}
|
package/dist/utils/format.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const decimalToHexString: (dec: number) => string;
|
|
1
|
+
export declare const decimalToHexString: (dec: string | number) => string;
|