@matrix-privacy/shared-models 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/json/artifacts.json +218 -0
- package/dist/models/artifact.d.ts +19 -0
- package/dist/models/artifact.js +11 -0
- package/dist/models/artifact.js.map +1 -0
- package/dist/models/balance.d.ts +6 -0
- package/dist/models/balance.js +11 -0
- package/dist/models/balance.js.map +1 -0
- package/dist/models/function-types.d.ts +3 -0
- package/dist/models/function-types.js +3 -0
- package/dist/models/function-types.js.map +1 -0
- package/dist/models/index.d.ts +9 -0
- package/dist/models/index.js +26 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/merkletree-scan.d.ts +6 -0
- package/dist/models/merkletree-scan.js +11 -0
- package/dist/models/merkletree-scan.js.map +1 -0
- package/dist/models/network-config.d.ts +34 -0
- package/dist/models/network-config.js +36 -0
- package/dist/models/network-config.js.map +1 -0
- package/dist/models/proof.d.ts +6 -0
- package/dist/models/proof.js +11 -0
- package/dist/models/proof.js.map +1 -0
- package/dist/models/response-types.d.ts +200 -0
- package/dist/models/response-types.js +40 -0
- package/dist/models/response-types.js.map +1 -0
- package/dist/models/transaction.d.ts +4 -0
- package/dist/models/transaction.js +3 -0
- package/dist/models/transaction.js.map +1 -0
- package/dist/models/wallet.d.ts +6 -0
- package/dist/models/wallet.js +11 -0
- package/dist/models/wallet.js.map +1 -0
- package/dist/types/global.d.ts +2 -0
- package/dist/types/global.js +3 -0
- package/dist/types/global.js.map +1 -0
- package/dist/utils/artifact-v2.d.ts +2 -0
- package/dist/utils/artifact-v2.js +24 -0
- package/dist/utils/artifact-v2.js.map +1 -0
- package/dist/utils/available-rpc.d.ts +8 -0
- package/dist/utils/available-rpc.js +65 -0
- package/dist/utils/available-rpc.js.map +1 -0
- package/dist/utils/compare.d.ts +2 -0
- package/dist/utils/compare.js +8 -0
- package/dist/utils/compare.js.map +1 -0
- package/dist/utils/configured-json-rpc-provider.d.ts +4 -0
- package/dist/utils/configured-json-rpc-provider.js +15 -0
- package/dist/utils/configured-json-rpc-provider.js.map +1 -0
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +93 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/fallback-provider.d.ts +13 -0
- package/dist/utils/fallback-provider.js +36 -0
- package/dist/utils/fallback-provider.js.map +1 -0
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.js +8 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/gas.d.ts +7 -0
- package/dist/utils/gas.js +46 -0
- package/dist/utils/gas.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +28 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/median.d.ts +1 -0
- package/dist/utils/median.js +13 -0
- package/dist/utils/median.js.map +1 -0
- package/dist/utils/network.d.ts +5 -0
- package/dist/utils/network.js +16 -0
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/promises.d.ts +4 -0
- package/dist/utils/promises.js +44 -0
- package/dist/utils/promises.js.map +1 -0
- package/dist/utils/util.d.ts +3 -0
- package/dist/utils/util.js +18 -0
- package/dist/utils/util.js.map +1 -0
- package/dist/utils/versions.d.ts +1 -0
- package/dist/utils/versions.js +47 -0
- package/dist/utils/versions.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { ContractTransaction } from 'ethers';
|
|
2
|
+
import { MerkletreeScanStatus } from './merkletree-scan';
|
|
3
|
+
import { FeesSerialized } from './network-config';
|
|
4
|
+
import { MatrixWalletBalanceBucket } from './balance';
|
|
5
|
+
import type { Optional } from '../types/global';
|
|
6
|
+
/**
|
|
7
|
+
* Type0 / Type1 = non-EIP-1559 (gasPrice).
|
|
8
|
+
* Type2 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).
|
|
9
|
+
*/
|
|
10
|
+
export declare enum EVMGasType {
|
|
11
|
+
Type0 = 0,
|
|
12
|
+
Type1 = 1,
|
|
13
|
+
Type2 = 2,
|
|
14
|
+
Type4 = 4
|
|
15
|
+
}
|
|
16
|
+
export type TransactionGasDetails = TransactionGasDetailsType0 | TransactionGasDetailsType1 | TransactionGasDetailsType2 | TransactionGasDetailsType4;
|
|
17
|
+
export type TransactionGasDetailsType0 = {
|
|
18
|
+
evmGasType: EVMGasType.Type0;
|
|
19
|
+
gasEstimate: bigint;
|
|
20
|
+
gasPrice: bigint;
|
|
21
|
+
};
|
|
22
|
+
export type TransactionGasDetailsType1 = {
|
|
23
|
+
evmGasType: EVMGasType.Type1;
|
|
24
|
+
gasEstimate: bigint;
|
|
25
|
+
gasPrice: bigint;
|
|
26
|
+
};
|
|
27
|
+
export type TransactionGasDetailsType2 = {
|
|
28
|
+
evmGasType: EVMGasType.Type2;
|
|
29
|
+
gasEstimate: bigint;
|
|
30
|
+
maxFeePerGas: bigint;
|
|
31
|
+
maxPriorityFeePerGas: bigint;
|
|
32
|
+
};
|
|
33
|
+
export type TransactionGasDetailsType4 = {
|
|
34
|
+
evmGasType: EVMGasType.Type4;
|
|
35
|
+
gasEstimate: bigint;
|
|
36
|
+
maxFeePerGas: bigint;
|
|
37
|
+
maxPriorityFeePerGas: bigint;
|
|
38
|
+
};
|
|
39
|
+
export type FeeTokenDetails = {
|
|
40
|
+
tokenAddress: string;
|
|
41
|
+
feePerUnitGas: bigint;
|
|
42
|
+
};
|
|
43
|
+
export declare enum ChainType {
|
|
44
|
+
EVM = 0
|
|
45
|
+
}
|
|
46
|
+
export type Chain = {
|
|
47
|
+
type: ChainType;
|
|
48
|
+
id: number;
|
|
49
|
+
};
|
|
50
|
+
export type MatrixBalancesEvent = {
|
|
51
|
+
chain: Chain;
|
|
52
|
+
matrixWalletID: string;
|
|
53
|
+
balanceBucket: MatrixWalletBalanceBucket;
|
|
54
|
+
erc20Amounts: MatrixERC20Amount[];
|
|
55
|
+
nftAmounts: MatrixNFTAmount[];
|
|
56
|
+
};
|
|
57
|
+
export type ProofProgressEvent = {
|
|
58
|
+
progress: number;
|
|
59
|
+
status: string;
|
|
60
|
+
};
|
|
61
|
+
export type MerkletreeScanUpdateEvent = {
|
|
62
|
+
chain: Chain;
|
|
63
|
+
scanStatus: MerkletreeScanStatus;
|
|
64
|
+
progress: number;
|
|
65
|
+
};
|
|
66
|
+
export type LoadProviderResponse = {
|
|
67
|
+
feesSerialized: FeesSerialized;
|
|
68
|
+
};
|
|
69
|
+
export type MatrixWalletInfo = {
|
|
70
|
+
id: string;
|
|
71
|
+
matrixAddress: string;
|
|
72
|
+
};
|
|
73
|
+
export type MatrixWalletAddressData = {
|
|
74
|
+
masterPublicKey: bigint;
|
|
75
|
+
viewingPublicKey: bigint;
|
|
76
|
+
};
|
|
77
|
+
export type MatrixTxidFromNullifiersResponse = {
|
|
78
|
+
txid?: string;
|
|
79
|
+
};
|
|
80
|
+
export type Proof = {
|
|
81
|
+
pi_a: [string, string];
|
|
82
|
+
pi_b: [[string, string], [string, string]];
|
|
83
|
+
pi_c: [string, string];
|
|
84
|
+
};
|
|
85
|
+
export type MatrixPopulateTransactionResponse = {
|
|
86
|
+
transaction: ContractTransaction;
|
|
87
|
+
nullifiers?: string[];
|
|
88
|
+
};
|
|
89
|
+
export type MatrixTransactionGasEstimateResponse = {
|
|
90
|
+
gasEstimate: bigint;
|
|
91
|
+
};
|
|
92
|
+
export type MatrixERC20Recipient = {
|
|
93
|
+
tokenAddress: string;
|
|
94
|
+
recipientAddress: string;
|
|
95
|
+
};
|
|
96
|
+
export type MatrixERC20Amount = {
|
|
97
|
+
tokenAddress: string;
|
|
98
|
+
amount: bigint;
|
|
99
|
+
};
|
|
100
|
+
export type MatrixERC20AmountRecipient = MatrixERC20Amount & {
|
|
101
|
+
recipientAddress: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Synced NFT types from TokenType (@matrix/engine).
|
|
105
|
+
*/
|
|
106
|
+
export declare enum NFTTokenType {
|
|
107
|
+
ERC721 = 1,
|
|
108
|
+
ERC1155 = 2
|
|
109
|
+
}
|
|
110
|
+
export type NFTAmount = {
|
|
111
|
+
nftAddress: string;
|
|
112
|
+
nftTokenType: NFTTokenType;
|
|
113
|
+
tokenSubID: string;
|
|
114
|
+
amountString: string;
|
|
115
|
+
};
|
|
116
|
+
export type NFTAmountRecipient = NFTAmount & {
|
|
117
|
+
recipientAddress: string;
|
|
118
|
+
};
|
|
119
|
+
export type MatrixNFTAmount = {
|
|
120
|
+
nftAddress: string;
|
|
121
|
+
nftTokenType: NFTTokenType;
|
|
122
|
+
tokenSubID: string;
|
|
123
|
+
amount: bigint;
|
|
124
|
+
};
|
|
125
|
+
export type MatrixNFTAmountRecipient = MatrixNFTAmount & {
|
|
126
|
+
recipientAddress: string;
|
|
127
|
+
};
|
|
128
|
+
export type EncryptDataWithSharedKeyResponse = {
|
|
129
|
+
encryptedData: [string, string];
|
|
130
|
+
randomPubKey: string;
|
|
131
|
+
sharedKey: Uint8Array;
|
|
132
|
+
};
|
|
133
|
+
export type EncryptDataWithSharedKeySerialized = {
|
|
134
|
+
encryptedData: [string, string];
|
|
135
|
+
randomPubKey: string;
|
|
136
|
+
sharedKey: string;
|
|
137
|
+
};
|
|
138
|
+
export type Pbkdf2Response = string;
|
|
139
|
+
type SendAdditionalData = {
|
|
140
|
+
recipientAddress: Optional<string>;
|
|
141
|
+
walletSource: Optional<string>;
|
|
142
|
+
memoText: Optional<string>;
|
|
143
|
+
};
|
|
144
|
+
export type MatrixHistoryERC20Amount = MatrixERC20Amount;
|
|
145
|
+
export type MatrixHistoryNFTAmount = MatrixNFTAmount;
|
|
146
|
+
export type MatrixHistorySendERC20Amount = MatrixHistoryERC20Amount & SendAdditionalData;
|
|
147
|
+
export type MatrixHistorySendNFTAmount = MatrixHistoryNFTAmount & SendAdditionalData;
|
|
148
|
+
type UnshieldAdditionalData = {
|
|
149
|
+
unshieldFee: Optional<string>;
|
|
150
|
+
};
|
|
151
|
+
export type MatrixHistoryUnshieldERC20Amount = MatrixHistorySendERC20Amount & UnshieldAdditionalData;
|
|
152
|
+
export type MatrixHistoryUnshieldNFTAmount = MatrixHistorySendNFTAmount & UnshieldAdditionalData;
|
|
153
|
+
type ReceiveAdditionalData = {
|
|
154
|
+
senderAddress: Optional<string>;
|
|
155
|
+
memoText: Optional<string>;
|
|
156
|
+
shieldFee: Optional<string>;
|
|
157
|
+
balanceBucket: MatrixWalletBalanceBucket;
|
|
158
|
+
};
|
|
159
|
+
export type MatrixHistoryReceiveERC20Amount = MatrixHistoryERC20Amount & ReceiveAdditionalData;
|
|
160
|
+
export type MatrixHistoryReceiveNFTAmount = MatrixHistoryNFTAmount & ReceiveAdditionalData;
|
|
161
|
+
export declare enum TransactionHistoryItemCategory {
|
|
162
|
+
ShieldERC20s = "ShieldERC20s",
|
|
163
|
+
UnshieldERC20s = "UnshieldERC20s",
|
|
164
|
+
TransferSendERC20s = "TransferSendERC20s",
|
|
165
|
+
TransferReceiveERC20s = "TransferReceiveERC20s",
|
|
166
|
+
Unknown = "Unknown"
|
|
167
|
+
}
|
|
168
|
+
export type TransactionHistoryItem = {
|
|
169
|
+
txid: string;
|
|
170
|
+
version: number;
|
|
171
|
+
timestamp: Optional<number>;
|
|
172
|
+
blockNumber: Optional<number>;
|
|
173
|
+
receiveERC20Amounts: MatrixHistoryReceiveERC20Amount[];
|
|
174
|
+
transferERC20Amounts: MatrixHistorySendERC20Amount[];
|
|
175
|
+
changeERC20Amounts: MatrixHistoryERC20Amount[];
|
|
176
|
+
unshieldERC20Amounts: MatrixHistoryUnshieldERC20Amount[];
|
|
177
|
+
receiveNFTAmounts: MatrixHistoryReceiveNFTAmount[];
|
|
178
|
+
transferNFTAmounts: MatrixHistorySendNFTAmount[];
|
|
179
|
+
unshieldNFTAmounts: MatrixHistoryUnshieldNFTAmount[];
|
|
180
|
+
category: TransactionHistoryItemCategory;
|
|
181
|
+
};
|
|
182
|
+
export declare enum XChaChaEncryptionAlgorithm {
|
|
183
|
+
XChaCha = "XChaCha",
|
|
184
|
+
XChaChaPoly1305 = "XChaChaPoly1305"
|
|
185
|
+
}
|
|
186
|
+
export type CiphertextXChaCha = {
|
|
187
|
+
algorithm: XChaChaEncryptionAlgorithm;
|
|
188
|
+
nonce: string;
|
|
189
|
+
bundle: string;
|
|
190
|
+
};
|
|
191
|
+
export type CommitmentCiphertextV3 = {
|
|
192
|
+
ciphertext: CiphertextXChaCha;
|
|
193
|
+
blindedSenderViewingKey: string;
|
|
194
|
+
blindedReceiverViewingKey: string;
|
|
195
|
+
};
|
|
196
|
+
export type CommitmentSummary = {
|
|
197
|
+
commitmentCiphertext: CommitmentCiphertextV3;
|
|
198
|
+
commitmentHash: string;
|
|
199
|
+
};
|
|
200
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XChaChaEncryptionAlgorithm = exports.TransactionHistoryItemCategory = exports.NFTTokenType = exports.ChainType = exports.EVMGasType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Type0 / Type1 = non-EIP-1559 (gasPrice).
|
|
6
|
+
* Type2 = EIP-1559 (maxFeePerGas and maxPriorityFeePerGas).
|
|
7
|
+
*/
|
|
8
|
+
var EVMGasType;
|
|
9
|
+
(function (EVMGasType) {
|
|
10
|
+
EVMGasType[EVMGasType["Type0"] = 0] = "Type0";
|
|
11
|
+
EVMGasType[EVMGasType["Type1"] = 1] = "Type1";
|
|
12
|
+
EVMGasType[EVMGasType["Type2"] = 2] = "Type2";
|
|
13
|
+
EVMGasType[EVMGasType["Type4"] = 4] = "Type4";
|
|
14
|
+
})(EVMGasType || (exports.EVMGasType = EVMGasType = {}));
|
|
15
|
+
var ChainType;
|
|
16
|
+
(function (ChainType) {
|
|
17
|
+
ChainType[ChainType["EVM"] = 0] = "EVM";
|
|
18
|
+
})(ChainType || (exports.ChainType = ChainType = {}));
|
|
19
|
+
/**
|
|
20
|
+
* Synced NFT types from TokenType (@matrix/engine).
|
|
21
|
+
*/
|
|
22
|
+
var NFTTokenType;
|
|
23
|
+
(function (NFTTokenType) {
|
|
24
|
+
NFTTokenType[NFTTokenType["ERC721"] = 1] = "ERC721";
|
|
25
|
+
NFTTokenType[NFTTokenType["ERC1155"] = 2] = "ERC1155";
|
|
26
|
+
})(NFTTokenType || (exports.NFTTokenType = NFTTokenType = {}));
|
|
27
|
+
var TransactionHistoryItemCategory;
|
|
28
|
+
(function (TransactionHistoryItemCategory) {
|
|
29
|
+
TransactionHistoryItemCategory["ShieldERC20s"] = "ShieldERC20s";
|
|
30
|
+
TransactionHistoryItemCategory["UnshieldERC20s"] = "UnshieldERC20s";
|
|
31
|
+
TransactionHistoryItemCategory["TransferSendERC20s"] = "TransferSendERC20s";
|
|
32
|
+
TransactionHistoryItemCategory["TransferReceiveERC20s"] = "TransferReceiveERC20s";
|
|
33
|
+
TransactionHistoryItemCategory["Unknown"] = "Unknown";
|
|
34
|
+
})(TransactionHistoryItemCategory || (exports.TransactionHistoryItemCategory = TransactionHistoryItemCategory = {}));
|
|
35
|
+
var XChaChaEncryptionAlgorithm;
|
|
36
|
+
(function (XChaChaEncryptionAlgorithm) {
|
|
37
|
+
XChaChaEncryptionAlgorithm["XChaCha"] = "XChaCha";
|
|
38
|
+
XChaChaEncryptionAlgorithm["XChaChaPoly1305"] = "XChaChaPoly1305";
|
|
39
|
+
})(XChaChaEncryptionAlgorithm || (exports.XChaChaEncryptionAlgorithm = XChaChaEncryptionAlgorithm = {}));
|
|
40
|
+
//# sourceMappingURL=response-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-types.js","sourceRoot":"","sources":["../../src/models/response-types.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,6CAAS,CAAA;IACT,6CAAS,CAAA;IACT,6CAAS,CAAA;AACX,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAuCD,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,uCAAO,CAAA;AACT,CAAC,EAFW,SAAS,yBAAT,SAAS,QAEpB;AAyED;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AA6ED,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,8CAA9B,8BAA8B,QAMzC;AAiBD,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,iDAAmB,CAAA;IACnB,iEAAmC,CAAA;AACrC,CAAC,EAHW,0BAA0B,0CAA1B,0BAA0B,QAGrC","sourcesContent":["import { ContractTransaction } from 'ethers';\nimport { MerkletreeScanStatus } from './merkletree-scan';\nimport { FeesSerialized } from './network-config';\nimport { MatrixWalletBalanceBucket } from './balance';\nimport type { Optional } from '../types/global';\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 Type4 = 4,\n}\n\nexport type TransactionGasDetails =\n | TransactionGasDetailsType0\n | TransactionGasDetailsType1\n | TransactionGasDetailsType2\n | TransactionGasDetailsType4;\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 type TransactionGasDetailsType4 = {\n evmGasType: EVMGasType.Type4;\n gasEstimate: bigint;\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n};\n\nexport type FeeTokenDetails = {\n tokenAddress: string;\n feePerUnitGas: bigint;\n};\n\nexport enum ChainType {\n EVM = 0,\n}\n\nexport type Chain = {\n type: ChainType;\n id: number;\n};\n\nexport type MatrixBalancesEvent = {\n chain: Chain;\n matrixWalletID: string;\n balanceBucket: MatrixWalletBalanceBucket;\n erc20Amounts: MatrixERC20Amount[];\n nftAmounts: MatrixNFTAmount[];\n};\n\nexport type ProofProgressEvent = {\n progress: number;\n status: 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 MatrixWalletInfo = {\n id: string;\n matrixAddress: string;\n};\n\nexport type MatrixWalletAddressData = {\n masterPublicKey: bigint;\n viewingPublicKey: bigint;\n};\n\nexport type MatrixTxidFromNullifiersResponse = {\n txid?: string;\n};\n\nexport type Proof = {\n pi_a: [string, string];\n pi_b: [[string, string], [string, string]];\n pi_c: [string, string];\n};\n\nexport type MatrixPopulateTransactionResponse = {\n transaction: ContractTransaction;\n nullifiers?: string[];\n};\n\nexport type MatrixTransactionGasEstimateResponse = {\n gasEstimate: bigint;\n};\n\nexport type MatrixERC20Recipient = {\n tokenAddress: string;\n recipientAddress: string;\n};\n\nexport type MatrixERC20Amount = {\n tokenAddress: string;\n amount: bigint;\n};\n\nexport type MatrixERC20AmountRecipient = MatrixERC20Amount & {\n recipientAddress: string;\n};\n\n/**\n * Synced NFT types from TokenType (@matrix/engine).\n */\nexport enum NFTTokenType {\n ERC721 = 1,\n ERC1155 = 2,\n}\n\nexport type NFTAmount = {\n nftAddress: string;\n nftTokenType: NFTTokenType;\n tokenSubID: string;\n amountString: string;\n};\n\nexport type NFTAmountRecipient = NFTAmount & {\n recipientAddress: string;\n};\n\nexport type MatrixNFTAmount = {\n nftAddress: string;\n nftTokenType: NFTTokenType;\n tokenSubID: string;\n amount: bigint;\n};\n\nexport type MatrixNFTAmountRecipient = MatrixNFTAmount & {\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 MatrixHistoryERC20Amount = MatrixERC20Amount;\n\nexport type MatrixHistoryNFTAmount = MatrixNFTAmount;\n\nexport type MatrixHistorySendERC20Amount = MatrixHistoryERC20Amount &\n SendAdditionalData;\n\nexport type MatrixHistorySendNFTAmount = MatrixHistoryNFTAmount &\n SendAdditionalData;\n\ntype UnshieldAdditionalData = {\n unshieldFee: Optional<string>;\n};\n\nexport type MatrixHistoryUnshieldERC20Amount = MatrixHistorySendERC20Amount &\n UnshieldAdditionalData;\n\nexport type MatrixHistoryUnshieldNFTAmount = MatrixHistorySendNFTAmount &\n UnshieldAdditionalData;\n\ntype ReceiveAdditionalData = {\n senderAddress: Optional<string>;\n memoText: Optional<string>;\n shieldFee: Optional<string>;\n balanceBucket: MatrixWalletBalanceBucket;\n};\n\nexport type MatrixHistoryReceiveERC20Amount = MatrixHistoryERC20Amount &\n ReceiveAdditionalData;\n\nexport type MatrixHistoryReceiveNFTAmount = MatrixHistoryNFTAmount &\n 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: MatrixHistoryReceiveERC20Amount[];\n transferERC20Amounts: MatrixHistorySendERC20Amount[];\n changeERC20Amounts: MatrixHistoryERC20Amount[];\n unshieldERC20Amounts: MatrixHistoryUnshieldERC20Amount[];\n receiveNFTAmounts: MatrixHistoryReceiveNFTAmount[];\n transferNFTAmounts: MatrixHistorySendNFTAmount[];\n unshieldNFTAmounts: MatrixHistoryUnshieldNFTAmount[];\n category: TransactionHistoryItemCategory;\n};\n\nexport enum XChaChaEncryptionAlgorithm {\n XChaCha = 'XChaCha',\n XChaChaPoly1305 = 'XChaChaPoly1305',\n}\n\nexport type CiphertextXChaCha = {\n algorithm: XChaChaEncryptionAlgorithm;\n nonce: string;\n bundle: string;\n};\n\nexport type CommitmentCiphertextV3 = {\n ciphertext: CiphertextXChaCha;\n blindedSenderViewingKey: string;\n blindedReceiverViewingKey: string;\n};\n\nexport type CommitmentSummary = {\n commitmentCiphertext: CommitmentCiphertextV3;\n commitmentHash: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":"","sourcesContent":["export type TransactionReceiptLog = {\n topics: string[];\n data: string;\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WalletCreationType = void 0;
|
|
4
|
+
var WalletCreationType;
|
|
5
|
+
(function (WalletCreationType) {
|
|
6
|
+
WalletCreationType["Import"] = "Import";
|
|
7
|
+
WalletCreationType["Create"] = "Create";
|
|
8
|
+
WalletCreationType["AddViewOnly"] = "AddViewOnly";
|
|
9
|
+
WalletCreationType["ImportFromBackup"] = "ImportFromBackup";
|
|
10
|
+
})(WalletCreationType || (exports.WalletCreationType = WalletCreationType = {}));
|
|
11
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/models/wallet.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,uCAAiB,CAAA;IACjB,iDAA2B,CAAA;IAC3B,2DAAqC,CAAA;AACvC,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B","sourcesContent":["export enum WalletCreationType {\n Import = 'Import',\n Create = 'Create',\n AddViewOnly = 'AddViewOnly',\n ImportFromBackup = 'ImportFromBackup',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/types/global.ts"],"names":[],"mappings":"","sourcesContent":["export type Optional<T> = T | undefined;\nexport type MapType<T> = Partial<Record<string, T>>;\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.assertArtifactExists = exports.artifactExists = void 0;
|
|
7
|
+
const artifacts_json_1 = __importDefault(require("../json/artifacts.json"));
|
|
8
|
+
const artifactExists = (nullifiers, commitments) => {
|
|
9
|
+
const found = artifacts_json_1.default.find(artifact => artifact.nullifiers === nullifiers &&
|
|
10
|
+
artifact.commitments === commitments);
|
|
11
|
+
return found != null;
|
|
12
|
+
};
|
|
13
|
+
exports.artifactExists = artifactExists;
|
|
14
|
+
const artifactError = (nullifiers, commitments) => {
|
|
15
|
+
return new Error(`No artifacts for inputs: ${nullifiers}-${commitments}`);
|
|
16
|
+
};
|
|
17
|
+
const assertArtifactExists = (nullifiers, commitments) => {
|
|
18
|
+
if ((0, exports.artifactExists)(nullifiers, commitments)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
throw artifactError(nullifiers, commitments);
|
|
22
|
+
};
|
|
23
|
+
exports.assertArtifactExists = assertArtifactExists;
|
|
24
|
+
//# sourceMappingURL=artifact-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-v2.js","sourceRoot":"","sources":["../../src/utils/artifact-v2.ts"],"names":[],"mappings":";;;;;;AAAA,4EAAuD;AAEhD,MAAM,cAAc,GAAG,CAC5B,UAAkB,EAClB,WAAmB,EACV,EAAE;IACX,MAAM,KAAK,GAAG,wBAAiB,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;AAVW,QAAA,cAAc,kBAUzB;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;AAEK,MAAM,oBAAoB,GAAG,CAClC,UAAkB,EAClB,WAAmB,EACnB,EAAE;IACF,IAAI,IAAA,sBAAc,EAAC,UAAU,EAAE,WAAW,CAAC,EAAE;QAC3C,OAAO;KACR;IACD,MAAM,aAAa,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC,CAAC;AARW,QAAA,oBAAoB,wBAQ/B","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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ProviderJson } from './fallback-provider';
|
|
2
|
+
type LogError = (err: string) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Health checks ProviderJson inputs, and returns an array of available RPC providers.
|
|
5
|
+
* Available means that they respond to getBlockNumber(), and they are +/- 100 blocks from the median.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getAvailableProviderJSONs: (chainId: number, providerJsons: ProviderJson[], logError: LogError) => Promise<ProviderJson[]>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAvailableProviderJSONs = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const median_1 = require("./median");
|
|
6
|
+
const promises_1 = require("./promises");
|
|
7
|
+
const BLOCK_NUMBER_TIMEOUT_MS = 5000;
|
|
8
|
+
/**
|
|
9
|
+
* Health checks ProviderJson inputs, and returns an array of available RPC providers.
|
|
10
|
+
* Available means that they respond to getBlockNumber(), and they are +/- 100 blocks from the median.
|
|
11
|
+
*/
|
|
12
|
+
const getAvailableProviderJSONs = async (chainId, providerJsons, logError) => {
|
|
13
|
+
const blockNumbers = await Promise.all(providerJsons.map(async (providerJson) => await getBlockNumber(chainId, providerJson.provider, logError)));
|
|
14
|
+
const nonZeroBlockNumbers = blockNumbers.filter(blockNumber => blockNumber != null && blockNumber > 0);
|
|
15
|
+
const medianBlockNumber = (0, median_1.getUpperBoundMedian)(nonZeroBlockNumbers);
|
|
16
|
+
const lowerBoundRange = medianBlockNumber - 100;
|
|
17
|
+
const upperBoundRange = medianBlockNumber + 100;
|
|
18
|
+
return providerJsons.filter((providerJson, index) => {
|
|
19
|
+
const blockNumber = blockNumbers[index];
|
|
20
|
+
if (blockNumber == null) {
|
|
21
|
+
logError(`RPC Health Check failed for ${providerJson.provider}: No Block Number`);
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (blockNumber < lowerBoundRange) {
|
|
25
|
+
logError(`RPC Health Check failed for ${providerJson.provider}: Block Number -${medianBlockNumber - blockNumber} from median`);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (blockNumber > upperBoundRange) {
|
|
29
|
+
logError(`RPC Health Check failed for ${providerJson.provider}: Block Number +${blockNumber - medianBlockNumber} from median`);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.getAvailableProviderJSONs = getAvailableProviderJSONs;
|
|
36
|
+
const getBlockNumber = async (chainId, provider, logError) => {
|
|
37
|
+
const network = ethers_1.Network.from(chainId);
|
|
38
|
+
// Conditionally handle what type of provider is being passed
|
|
39
|
+
let rpcProvider;
|
|
40
|
+
// If URL starts with wss, use WebSocketProvider
|
|
41
|
+
if (provider.startsWith('wss')) {
|
|
42
|
+
rpcProvider = new ethers_1.WebSocketProvider(provider, network);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
rpcProvider = new ethers_1.JsonRpcProvider(provider, network, {
|
|
46
|
+
staticNetwork: network,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const block = await (0, promises_1.promiseTimeout)(rpcProvider.getBlock('latest'), BLOCK_NUMBER_TIMEOUT_MS);
|
|
51
|
+
if (block == null) {
|
|
52
|
+
throw new Error('Block is null');
|
|
53
|
+
}
|
|
54
|
+
return block.number;
|
|
55
|
+
}
|
|
56
|
+
catch (cause) {
|
|
57
|
+
if (!(cause instanceof Error)) {
|
|
58
|
+
throw new Error('Non-error thrown from getBlockNumber', { cause });
|
|
59
|
+
}
|
|
60
|
+
rpcProvider.destroy();
|
|
61
|
+
logError(cause.message);
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=available-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"available-rpc.js","sourceRoot":"","sources":["../../src/utils/available-rpc.ts"],"names":[],"mappings":";;;AAAA,mCAKgB;AAEhB,qCAA+C;AAC/C,yCAA4C;AAK5C,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;GAGG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAC5C,OAAe,EACf,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,OAAO,EAAE,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACjE,CACF,CAAC;IAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC,MAAM,CAC7C,WAAW,CAAC,EAAE,CAAC,WAAW,IAAI,IAAI,IAAI,WAAW,GAAG,CAAC,CAC1C,CAAC;IACd,MAAM,iBAAiB,GAAG,IAAA,4BAAmB,EAAC,mBAAmB,CAAC,CAAC;IACnE,MAAM,eAAe,GAAG,iBAAiB,GAAG,GAAG,CAAC;IAChD,MAAM,eAAe,GAAG,iBAAiB,GAAG,GAAG,CAAC;IAEhD,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;QAClD,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,QAAQ,CACN,+BAA+B,YAAY,CAAC,QAAQ,mBAAmB,CACxE,CAAC;YACF,OAAO,KAAK,CAAC;SACd;QACD,IAAI,WAAW,GAAG,eAAe,EAAE;YACjC,QAAQ,CACN,+BAA+B,YAAY,CAAC,Q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QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC","sourcesContent":["import {\n JsonRpcProvider,\n Network,\n type Provider,\n WebSocketProvider,\n} from 'ethers';\nimport { ProviderJson } from './fallback-provider';\nimport { getUpperBoundMedian } from './median';\nimport { promiseTimeout } from './promises';\nimport type { Optional } from '../types/global';\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 chainId: number,\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(chainId, 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 chainId: number,\n provider: string,\n logError: LogError,\n): Promise<Optional<number>> => {\n const network = Network.from(chainId);\n\n // Conditionally handle what type of provider is being passed\n let rpcProvider: Provider;\n\n // If URL starts with wss, use WebSocketProvider\n if (provider.startsWith('wss')) {\n rpcProvider = new WebSocketProvider(provider, network);\n } else {\n rpcProvider = new JsonRpcProvider(provider, network, {\n staticNetwork: network,\n });\n }\n\n try {\n const block = await promiseTimeout(\n rpcProvider.getBlock('latest'),\n BLOCK_NUMBER_TIMEOUT_MS,\n );\n if (block == null) {\n throw new Error('Block is null');\n }\n return block.number;\n } catch (cause) {\n if (!(cause instanceof Error)) {\n throw new Error('Non-error thrown from getBlockNumber', { cause });\n }\n rpcProvider.destroy();\n logError(cause.message);\n return undefined;\n }\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareChains = void 0;
|
|
4
|
+
const compareChains = (chainA, chainB) => {
|
|
5
|
+
return chainA.type === chainB.type && chainA.id === chainB.id;
|
|
6
|
+
};
|
|
7
|
+
exports.compareChains = compareChains;
|
|
8
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/utils/compare.ts"],"names":[],"mappings":";;;AAEO,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;AAFW,QAAA,aAAa,iBAExB","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"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfiguredJsonRpcProvider = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
class ConfiguredJsonRpcProvider extends ethers_1.JsonRpcProvider {
|
|
6
|
+
constructor(url, network, maxLogsPerBatch = 100) {
|
|
7
|
+
const options = {
|
|
8
|
+
staticNetwork: network,
|
|
9
|
+
batchMaxCount: maxLogsPerBatch,
|
|
10
|
+
};
|
|
11
|
+
super(url, network, options);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ConfiguredJsonRpcProvider = ConfiguredJsonRpcProvider;
|
|
15
|
+
//# sourceMappingURL=configured-json-rpc-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configured-json-rpc-provider.js","sourceRoot":"","sources":["../../src/utils/configured-json-rpc-provider.ts"],"names":[],"mappings":";;;AAAA,mCAA6E;AAE7E,MAAa,yBAA0B,SAAQ,wBAAe;IAC5D,YAAY,GAAW,EAAE,OAAgB,EAAE,eAAe,GAAG,GAAG;QAC9D,MAAM,OAAO,GAA8B;YACzC,aAAa,EAAE,OAAO;YACtB,aAAa,EAAE,eAAe;SAC/B,CAAC;QACF,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF;AARD,8DAQC","sourcesContent":["import { JsonRpcProvider, JsonRpcApiProviderOptions, Network } from 'ethers';\n\nexport class ConfiguredJsonRpcProvider extends JsonRpcProvider {\n constructor(url: string, network: Network, maxLogsPerBatch = 100) {\n const options: JsonRpcApiProviderOptions = {\n staticNetwork: network,\n batchMaxCount: maxLogsPerBatch,\n };\n super(url, network, options);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sanitizeError: (cause: Error) => Error;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeError = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
const STRING_PREFIX_AFTER_UNICODE_REPLACEMENT = 'y %';
|
|
6
|
+
const validAscii = (str) => {
|
|
7
|
+
return str.replace(
|
|
8
|
+
// eslint-disable-next-line no-useless-escape
|
|
9
|
+
/[^A-Za-z 0-9 \.,\?""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]*/g, '');
|
|
10
|
+
};
|
|
11
|
+
const sanitizeError = (cause) => {
|
|
12
|
+
if ((0, util_1.isDefined)(cause) && cause.message) {
|
|
13
|
+
const lowercaseMsg = cause.message.toLowerCase();
|
|
14
|
+
if (lowercaseMsg.includes('quorum') ||
|
|
15
|
+
lowercaseMsg.includes('could not connect to')) {
|
|
16
|
+
return new Error('Could not connect.', { cause });
|
|
17
|
+
}
|
|
18
|
+
if (lowercaseMsg.includes('call revert exception')) {
|
|
19
|
+
return new Error('Failed to connect to RPC.', { cause });
|
|
20
|
+
}
|
|
21
|
+
if (lowercaseMsg.includes('already known')) {
|
|
22
|
+
return new Error('Transaction successful but ethers request for TXID failed.', { cause });
|
|
23
|
+
}
|
|
24
|
+
if (lowercaseMsg.includes('missing revert data')) {
|
|
25
|
+
return new Error('RPC connection error.', { cause });
|
|
26
|
+
}
|
|
27
|
+
if (lowercaseMsg.includes('transaction may fail or may require manual gas limit')) {
|
|
28
|
+
return new Error('Unknown error. Transaction failed.', { cause });
|
|
29
|
+
}
|
|
30
|
+
if (lowercaseMsg.includes('replacement fee too low')) {
|
|
31
|
+
return new Error('Nonce is used in a pending transaction, and replacement fee is too low. Please increase your network fee to replace the pending transaction.', { cause });
|
|
32
|
+
}
|
|
33
|
+
if (lowercaseMsg.includes('intrinsic gas too low')) {
|
|
34
|
+
return new Error('Gas price rejected. Please select a higher gas price or resubmit.', { cause });
|
|
35
|
+
}
|
|
36
|
+
if (lowercaseMsg.includes('transaction underpriced')) {
|
|
37
|
+
return new Error('Gas fee too low. Please select a higher gas price and resubmit.', { cause });
|
|
38
|
+
}
|
|
39
|
+
if (lowercaseMsg.includes('insufficient funds for intrinsic')) {
|
|
40
|
+
return new Error('Insufficient gas to process transaction.', { cause });
|
|
41
|
+
}
|
|
42
|
+
if (lowercaseMsg.includes('nonce has already been used')) {
|
|
43
|
+
return new Error(
|
|
44
|
+
// Do not change 'Nonce already used' string of Error message.
|
|
45
|
+
'Nonce already used: the transaction was already completed.', { cause });
|
|
46
|
+
}
|
|
47
|
+
if (lowercaseMsg.includes('error while dialing dial tcp')) {
|
|
48
|
+
return new Error('Error while connecting to RPC provider. Please try again.', { cause });
|
|
49
|
+
}
|
|
50
|
+
if (lowercaseMsg.includes('spendable private balance too low') &&
|
|
51
|
+
lowercaseMsg.includes('relayer fee')) {
|
|
52
|
+
return new Error('Private balance too low to pay relayer fee.', {
|
|
53
|
+
cause,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// Custom Matrix contract error messages
|
|
57
|
+
if (lowercaseMsg.includes('matrix')) {
|
|
58
|
+
if (lowercaseMsg.includes('invalid nft note value')) {
|
|
59
|
+
return new Error('Matrix: Invalid NFT Note Value.', {
|
|
60
|
+
cause,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (lowercaseMsg.includes('unsupported token')) {
|
|
64
|
+
return new Error('Matrix: Unsupported Token. This token cannot interact with the Matrix contract.', { cause });
|
|
65
|
+
}
|
|
66
|
+
if (lowercaseMsg.includes('invalid note value')) {
|
|
67
|
+
return new Error('Matrix: Invalid Note Value. Please submit transaction with a corrected amount.', { cause });
|
|
68
|
+
}
|
|
69
|
+
if (lowercaseMsg.includes('invalid adapt contract as sender')) {
|
|
70
|
+
return new Error('Matrix: Invalid Adapt Contract as Sender. Please update your frontend to current Adapt module versions.', { cause });
|
|
71
|
+
}
|
|
72
|
+
if (lowercaseMsg.includes('invalid merkle root')) {
|
|
73
|
+
return new Error('Matrix: Invalid Merkle Root. Please sync your balances and try again.', { cause });
|
|
74
|
+
}
|
|
75
|
+
if (lowercaseMsg.includes('note already spent')) {
|
|
76
|
+
return new Error('Matrix: Note Already Spent. Please sync your balances and try again.', { cause });
|
|
77
|
+
}
|
|
78
|
+
if (lowercaseMsg.includes('invalid ciphertext array length')) {
|
|
79
|
+
return new Error('Matrix: Invalid Ciphertext Array Length. Please sync balances and re-prove your transaction.', { cause });
|
|
80
|
+
}
|
|
81
|
+
if (lowercaseMsg.includes('invalid unshield commitment')) {
|
|
82
|
+
return new Error('Matrix: Invalid Unshield Commitment. Please sync balances and re-prove your transaction.', { cause });
|
|
83
|
+
}
|
|
84
|
+
if (lowercaseMsg.includes('invalid snark proof')) {
|
|
85
|
+
return new Error('Matrix: Invalid Snark Proof. Please re-prove your transaction.', { cause });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return new Error(validAscii(cause.message).replace(`:${STRING_PREFIX_AFTER_UNICODE_REPLACEMENT}`, ': '));
|
|
89
|
+
}
|
|
90
|
+
return new Error('Unknown error. Please try again.', { cause });
|
|
91
|
+
};
|
|
92
|
+
exports.sanitizeError = sanitizeError;
|
|
93
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AAEnC,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;AAEK,MAAM,aAAa,GAAG,CAAC,KAAY,EAAS,EAAE;IACnD,IAAI,IAAA,gBAAS,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE;QACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACjD,IACE,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC/B,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAC7C;YACA,OAAO,IAAI,KAAK,CAAC,oBAAoB,EAAE,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AAC;aACH;YACD,IAAI,YAAY,CAAC,QAAQ,CAAC,iCAAiC,CAAC,EAAE;gBAC5D,OAAO,IAAI,KAAK,CACd,8FAA8F,EAC9F,EAAE,KAAK,EAAE,CACV,CAAC;aACH;YACD,IAAI,YAAY,CAAC,QAAQ,CAAC,6BAA6B,CAAC,EAAE;gBACxD,OAAO,IAAI,KAAK,CACd,0FAA0F,EAC1F,EAAE,KAAK,EAAE,CACV,CAAC;aACH;YACD,IAAI,YAAY,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE;gBAChD,OAAO,IAAI,KAAK,CACd,gEAAgE,EAChE,EAAE,KAAK,EAAE,CACV,CAAC;aACH;SACF;QAED,OAAO,IAAI,KAAK,CACd,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAC/B,IAAI,uCAAuC,EAAE,EAC7C,IAAI,CACL,CACF,CAAC;KACH;IAED,OAAO,IAAI,KAAK,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC;AAzIW,QAAA,aAAa,iBAyIxB","sourcesContent":["import { isDefined } from './util';\n\nconst STRING_PREFIX_AFTER_UNICODE_REPLACEMENT = '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 = (cause: Error): Error => {\n if (isDefined(cause) && cause.message) {\n const lowercaseMsg = cause.message.toLowerCase();\n if (\n lowercaseMsg.includes('quorum') ||\n lowercaseMsg.includes('could not connect to')\n ) {\n return new Error('Could not connect.', { cause });\n }\n if (lowercaseMsg.includes('call revert exception')) {\n return new Error('Failed to connect to RPC.', { cause });\n }\n if (lowercaseMsg.includes('already known')) {\n return new Error(\n 'Transaction successful but ethers request for TXID failed.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('missing revert data')) {\n return new Error('RPC connection error.', { cause });\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.', { cause });\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 { cause },\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 { cause },\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 { cause },\n );\n }\n if (lowercaseMsg.includes('insufficient funds for intrinsic')) {\n return new Error('Insufficient gas to process transaction.', { cause });\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 { cause },\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 { cause },\n );\n }\n if (\n lowercaseMsg.includes('spendable private balance too low') &&\n lowercaseMsg.includes('relayer fee')\n ) {\n return new Error('Private balance too low to pay relayer fee.', {\n cause,\n });\n }\n\n // Custom Matrix contract error messages\n if (lowercaseMsg.includes('matrix')) {\n if (lowercaseMsg.includes('invalid nft note value')) {\n return new Error('Matrix: Invalid NFT Note Value.', {\n cause,\n });\n }\n if (lowercaseMsg.includes('unsupported token')) {\n return new Error(\n 'Matrix: Unsupported Token. This token cannot interact with the Matrix contract.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('invalid note value')) {\n return new Error(\n 'Matrix: Invalid Note Value. Please submit transaction with a corrected amount.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('invalid adapt contract as sender')) {\n return new Error(\n 'Matrix: Invalid Adapt Contract as Sender. Please update your frontend to current Adapt module versions.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('invalid merkle root')) {\n return new Error(\n 'Matrix: Invalid Merkle Root. Please sync your balances and try again.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('note already spent')) {\n return new Error(\n 'Matrix: Note Already Spent. Please sync your balances and try again.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('invalid ciphertext array length')) {\n return new Error(\n 'Matrix: Invalid Ciphertext Array Length. Please sync balances and re-prove your transaction.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('invalid unshield commitment')) {\n return new Error(\n 'Matrix: Invalid Unshield Commitment. Please sync balances and re-prove your transaction.',\n { cause },\n );\n }\n if (lowercaseMsg.includes('invalid snark proof')) {\n return new Error(\n 'Matrix: Invalid Snark Proof. Please re-prove your transaction.',\n { cause },\n );\n }\n }\n\n return new Error(\n validAscii(cause.message).replace(\n `:${STRING_PREFIX_AFTER_UNICODE_REPLACEMENT}`,\n ': ',\n ),\n );\n }\n\n return new Error('Unknown error. Please try again.', { cause });\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FallbackProvider } from 'ethers';
|
|
2
|
+
export type FallbackProviderJsonConfig = {
|
|
3
|
+
chainId: number;
|
|
4
|
+
providers: ProviderJson[];
|
|
5
|
+
};
|
|
6
|
+
export type ProviderJson = {
|
|
7
|
+
priority: number;
|
|
8
|
+
weight: number;
|
|
9
|
+
provider: string;
|
|
10
|
+
stallTimeout?: number;
|
|
11
|
+
maxLogsPerBatch?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const createFallbackProviderFromJsonConfig: (config: FallbackProviderJsonConfig) => FallbackProvider;
|