@railgun-community/shared-models 5.1.11 → 5.1.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-types.js","sourceRoot":"","sources":["../../src/models/response-types.ts"],"names":[],"mappings":";;;AAUA;;;GAGG;AACH,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,6CAAS,CAAA;IACT,6CAAS,CAAA;AACX,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB;AA+BD,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,uCAAO,CAAA;AACT,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB;AAyDD;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAqED,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,GAA9B,sCAA8B,KAA9B,sCAA8B,QAMzC","sourcesContent":["/// <reference types=\"../types/global\" />\nimport { ContractTransaction } 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 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 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: ContractTransaction;\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 NFTAmount = {\n nftAddress: string;\n nftTokenType: NFTTokenType;\n tokenSubID: string;\n amountString:
|
|
1
|
+
{"version":3,"file":"response-types.js","sourceRoot":"","sources":["../../src/models/response-types.ts"],"names":[],"mappings":";;;AAUA;;;GAGG;AACH,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6CAAS,CAAA;IACT,6CAAS,CAAA;IACT,6CAAS,CAAA;AACX,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB;AA+BD,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,uCAAO,CAAA;AACT,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB;AAyDD;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,mDAAU,CAAA;IACV,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAqED,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,GAA9B,sCAA8B,KAA9B,sCAA8B,QAMzC","sourcesContent":["/// <reference types=\"../types/global\" />\nimport { ContractTransaction } 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 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 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: ContractTransaction;\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 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 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"]}
|
|
@@ -5,16 +5,23 @@ const ethers_1 = require("ethers");
|
|
|
5
5
|
const polling_json_rpc_provider_1 = require("./polling-json-rpc-provider");
|
|
6
6
|
const createFallbackProviderFromJsonConfig = (config) => {
|
|
7
7
|
try {
|
|
8
|
+
const totalWeight = config.providers.reduce((acc, { weight }) => acc + weight, 0);
|
|
9
|
+
if (totalWeight < 2) {
|
|
10
|
+
throw new Error('Total weight across providers must be >= 2 for fallback quorum.');
|
|
11
|
+
}
|
|
8
12
|
const network = ethers_1.Network.from(Number(config.chainId));
|
|
9
|
-
const providers = config.providers.map(
|
|
10
|
-
const isWebsocket =
|
|
13
|
+
const providers = config.providers.map(({ provider: providerURL, priority, weight, stallTimeout, disableBatching, }) => {
|
|
14
|
+
const isWebsocket = providerURL.startsWith('wss');
|
|
11
15
|
const provider = isWebsocket
|
|
12
|
-
? new ethers_1.WebSocketProvider(
|
|
13
|
-
: new polling_json_rpc_provider_1.PollingJsonRpcProvider(
|
|
14
|
-
|
|
15
|
-
...json,
|
|
16
|
+
? new ethers_1.WebSocketProvider(providerURL, network)
|
|
17
|
+
: new polling_json_rpc_provider_1.PollingJsonRpcProvider(providerURL, network, disableBatching);
|
|
18
|
+
const fallbackProviderConfig = {
|
|
16
19
|
provider,
|
|
20
|
+
priority,
|
|
21
|
+
weight,
|
|
22
|
+
stallTimeout,
|
|
17
23
|
};
|
|
24
|
+
return fallbackProviderConfig;
|
|
18
25
|
});
|
|
19
26
|
return new ethers_1.FallbackProvider(providers, network);
|
|
20
27
|
}
|
|
@@ -22,7 +29,7 @@ const createFallbackProviderFromJsonConfig = (config) => {
|
|
|
22
29
|
if (!(err instanceof Error)) {
|
|
23
30
|
throw err;
|
|
24
31
|
}
|
|
25
|
-
throw new Error(`Invalid fallback provider config: ${err.message}`);
|
|
32
|
+
throw new Error(`Invalid fallback provider config for chain ${config.chainId}: ${err.message}`);
|
|
26
33
|
}
|
|
27
34
|
};
|
|
28
35
|
exports.createFallbackProviderFromJsonConfig = createFallbackProviderFromJsonConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/utils/fallback-provider.ts"],"names":[],"mappings":";;;AAAA,mCAAsE;AACtE,2EAAqE;
|
|
1
|
+
{"version":3,"file":"fallback-provider.js","sourceRoot":"","sources":["../../src/utils/fallback-provider.ts"],"names":[],"mappings":";;;AAAA,mCAAsE;AACtE,2EAAqE;AAgB9D,MAAM,oCAAoC,GAAG,CAClD,MAAkC,EAChB,EAAE;IACpB,IAAI;QACF,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CACzC,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,EACjC,CAAC,CACF,CAAC;QACF,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;SACH;QAED,MAAM,OAAO,GAAG,gBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAErD,MAAM,SAAS,GAA6B,MAAM,CAAC,SAAS,CAAC,GAAG,CAC9D,CAAC,EACC,QAAQ,EAAE,WAAW,EACrB,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,eAAe,GAChB,EAAE,EAAE;YACH,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAClD,MAAM,QAAQ,GAAG,WAAW;gBAC1B,CAAC,CAAC,IAAI,0BAAiB,CAAC,WAAW,EAAE,OAAO,CAAC;gBAC7C,CAAC,CAAC,IAAI,kDAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;YAEtE,MAAM,sBAAsB,GAA2B;gBACrD,QAAQ;gBACR,QAAQ;gBACR,MAAM;gBACN,YAAY;aACb,CAAC;YACF,OAAO,sBAAsB,CAAC;QAChC,CAAC,CACF,CAAC;QAEF,OAAO,IAAI,yBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;KACjD;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE;YAC3B,MAAM,GAAG,CAAC;SACX;QACD,MAAM,IAAI,KAAK,CACb,8CAA8C,MAAM,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO,EAAE,CAC/E,CAAC;KACH;AACH,CAAC,CAAC;AAhDW,QAAA,oCAAoC,wCAgD/C","sourcesContent":["import { FallbackProvider, Network, WebSocketProvider } from 'ethers';\nimport { PollingJsonRpcProvider } from './polling-json-rpc-provider';\nimport { FallbackProviderConfig } from 'ethers/lib.commonjs/providers/provider-fallback';\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 stallTimeout?: number;\n disableBatching?: boolean;\n};\n\nexport const createFallbackProviderFromJsonConfig = (\n config: FallbackProviderJsonConfig,\n): FallbackProvider => {\n try {\n const totalWeight = config.providers.reduce(\n (acc, { weight }) => acc + weight,\n 0,\n );\n if (totalWeight < 2) {\n throw new Error(\n 'Total weight across providers must be >= 2 for fallback quorum.',\n );\n }\n\n const network = Network.from(Number(config.chainId));\n\n const providers: FallbackProviderConfig[] = config.providers.map(\n ({\n provider: providerURL,\n priority,\n weight,\n stallTimeout,\n disableBatching,\n }) => {\n const isWebsocket = providerURL.startsWith('wss');\n const provider = isWebsocket\n ? new WebSocketProvider(providerURL, network)\n : new PollingJsonRpcProvider(providerURL, network, disableBatching);\n\n const fallbackProviderConfig: FallbackProviderConfig = {\n provider,\n priority,\n weight,\n stallTimeout,\n };\n return fallbackProviderConfig;\n },\n );\n\n return new FallbackProvider(providers, network);\n } catch (err) {\n if (!(err instanceof Error)) {\n throw err;\n }\n throw new Error(\n `Invalid fallback provider config for chain ${config.chainId}: ${err.message}`,\n );\n }\n};\n"]}
|