@sudobility/types 1.8.21
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/CLAUDE.md +285 -0
- package/README.md +310 -0
- package/dist/index.cjs +62 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/types/blockchain/common.cjs +102 -0
- package/dist/types/blockchain/common.d.ts +262 -0
- package/dist/types/blockchain/common.d.ts.map +1 -0
- package/dist/types/blockchain/common.js +102 -0
- package/dist/types/blockchain/common.js.map +1 -0
- package/dist/types/blockchain/index.cjs +18 -0
- package/dist/types/blockchain/index.d.ts +4 -0
- package/dist/types/blockchain/index.d.ts.map +1 -0
- package/dist/types/blockchain/index.js +18 -0
- package/dist/types/blockchain/index.js.map +1 -0
- package/dist/types/blockchain/validation.cjs +88 -0
- package/dist/types/blockchain/validation.d.ts +9 -0
- package/dist/types/blockchain/validation.d.ts.map +1 -0
- package/dist/types/blockchain/validation.js +88 -0
- package/dist/types/blockchain/validation.js.map +1 -0
- package/dist/types/business/enums.cjs +314 -0
- package/dist/types/business/enums.d.ts +227 -0
- package/dist/types/business/enums.d.ts.map +1 -0
- package/dist/types/business/enums.js +314 -0
- package/dist/types/business/enums.js.map +1 -0
- package/dist/types/business/index.cjs +33 -0
- package/dist/types/business/index.d.ts +5 -0
- package/dist/types/business/index.d.ts.map +1 -0
- package/dist/types/business/index.js +33 -0
- package/dist/types/business/index.js.map +1 -0
- package/dist/types/business/wallet-status.cjs +38 -0
- package/dist/types/business/wallet-status.d.ts +32 -0
- package/dist/types/business/wallet-status.d.ts.map +1 -0
- package/dist/types/business/wallet-status.js +38 -0
- package/dist/types/business/wallet-status.js.map +1 -0
- package/dist/types/common.cjs +6 -0
- package/dist/types/common.d.ts +142 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +6 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/config/app-config.cjs +6 -0
- package/dist/types/config/app-config.d.ts +67 -0
- package/dist/types/config/app-config.d.ts.map +1 -0
- package/dist/types/config/app-config.js +6 -0
- package/dist/types/config/app-config.js.map +1 -0
- package/dist/types/config/environment.cjs +24 -0
- package/dist/types/config/environment.d.ts +68 -0
- package/dist/types/config/environment.d.ts.map +1 -0
- package/dist/types/config/environment.js +24 -0
- package/dist/types/config/environment.js.map +1 -0
- package/dist/types/config/index.cjs +6 -0
- package/dist/types/config/index.d.ts +4 -0
- package/dist/types/config/index.d.ts.map +1 -0
- package/dist/types/config/index.js +6 -0
- package/dist/types/config/index.js.map +1 -0
- package/dist/types/index.cjs +35 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +35 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/indexer/index.cjs +19 -0
- package/dist/types/indexer/index.d.ts +3 -0
- package/dist/types/indexer/index.d.ts.map +1 -0
- package/dist/types/indexer/index.js +19 -0
- package/dist/types/indexer/index.js.map +1 -0
- package/dist/types/indexer/indexer-guards.cjs +145 -0
- package/dist/types/indexer/indexer-guards.d.ts +26 -0
- package/dist/types/indexer/indexer-guards.d.ts.map +1 -0
- package/dist/types/indexer/indexer-guards.js +145 -0
- package/dist/types/indexer/indexer-guards.js.map +1 -0
- package/dist/types/indexer/indexer-responses.cjs +8 -0
- package/dist/types/indexer/indexer-responses.d.ts +136 -0
- package/dist/types/indexer/indexer-responses.d.ts.map +1 -0
- package/dist/types/indexer/indexer-responses.js +8 -0
- package/dist/types/indexer/indexer-responses.js.map +1 -0
- package/dist/types/infrastructure/analytics.cjs +212 -0
- package/dist/types/infrastructure/analytics.d.ts +449 -0
- package/dist/types/infrastructure/analytics.d.ts.map +1 -0
- package/dist/types/infrastructure/analytics.js +212 -0
- package/dist/types/infrastructure/analytics.js.map +1 -0
- package/dist/types/infrastructure/api.cjs +17 -0
- package/dist/types/infrastructure/api.d.ts +152 -0
- package/dist/types/infrastructure/api.d.ts.map +1 -0
- package/dist/types/infrastructure/api.js +17 -0
- package/dist/types/infrastructure/api.js.map +1 -0
- package/dist/types/infrastructure/index.cjs +14 -0
- package/dist/types/infrastructure/index.d.ts +9 -0
- package/dist/types/infrastructure/index.d.ts.map +1 -0
- package/dist/types/infrastructure/index.js +14 -0
- package/dist/types/infrastructure/index.js.map +1 -0
- package/dist/types/infrastructure/navigation.cjs +3 -0
- package/dist/types/infrastructure/navigation.d.ts +56 -0
- package/dist/types/infrastructure/navigation.d.ts.map +1 -0
- package/dist/types/infrastructure/navigation.js +3 -0
- package/dist/types/infrastructure/navigation.js.map +1 -0
- package/dist/types/infrastructure/network.cjs +18 -0
- package/dist/types/infrastructure/network.d.ts +48 -0
- package/dist/types/infrastructure/network.d.ts.map +1 -0
- package/dist/types/infrastructure/network.js +18 -0
- package/dist/types/infrastructure/network.js.map +1 -0
- package/dist/types/infrastructure/wallet.cjs +37 -0
- package/dist/types/infrastructure/wallet.d.ts +33 -0
- package/dist/types/infrastructure/wallet.d.ts.map +1 -0
- package/dist/types/infrastructure/wallet.js +37 -0
- package/dist/types/infrastructure/wallet.js.map +1 -0
- package/dist/types/kyc/index.cjs +19 -0
- package/dist/types/kyc/index.d.ts +2 -0
- package/dist/types/kyc/index.d.ts.map +1 -0
- package/dist/types/kyc/index.js +19 -0
- package/dist/types/kyc/index.js.map +1 -0
- package/dist/types/kyc/kyc-types.cjs +12 -0
- package/dist/types/kyc/kyc-types.d.ts +260 -0
- package/dist/types/kyc/kyc-types.d.ts.map +1 -0
- package/dist/types/kyc/kyc-types.js +12 -0
- package/dist/types/kyc/kyc-types.js.map +1 -0
- package/dist/types/mailer/index.cjs +19 -0
- package/dist/types/mailer/index.d.ts +2 -0
- package/dist/types/mailer/index.d.ts.map +1 -0
- package/dist/types/mailer/index.js +19 -0
- package/dist/types/mailer/index.js.map +1 -0
- package/dist/types/mailer/mail-types.cjs +38 -0
- package/dist/types/mailer/mail-types.d.ts +296 -0
- package/dist/types/mailer/mail-types.d.ts.map +1 -0
- package/dist/types/mailer/mail-types.js +38 -0
- package/dist/types/mailer/mail-types.js.map +1 -0
- package/dist/types/wildduck/index.cjs +19 -0
- package/dist/types/wildduck/index.d.ts +2 -0
- package/dist/types/wildduck/index.d.ts.map +1 -0
- package/dist/types/wildduck/index.js +19 -0
- package/dist/types/wildduck/index.js.map +1 -0
- package/dist/types/wildduck/wildduck-types.cjs +48 -0
- package/dist/types/wildduck/wildduck-types.d.ts +1239 -0
- package/dist/types/wildduck/wildduck-types.d.ts.map +1 -0
- package/dist/types/wildduck/wildduck-types.js +48 -0
- package/dist/types/wildduck/wildduck-types.js.map +1 -0
- package/dist/utils/async-helpers.cjs +130 -0
- package/dist/utils/async-helpers.d.ts +35 -0
- package/dist/utils/async-helpers.d.ts.map +1 -0
- package/dist/utils/async-helpers.js +130 -0
- package/dist/utils/async-helpers.js.map +1 -0
- package/dist/utils/auth/auth.cjs +96 -0
- package/dist/utils/auth/auth.d.ts +40 -0
- package/dist/utils/auth/auth.d.ts.map +1 -0
- package/dist/utils/auth/auth.js +96 -0
- package/dist/utils/auth/auth.js.map +1 -0
- package/dist/utils/auth/index.cjs +14 -0
- package/dist/utils/auth/index.d.ts +2 -0
- package/dist/utils/auth/index.d.ts.map +1 -0
- package/dist/utils/auth/index.js +14 -0
- package/dist/utils/auth/index.js.map +1 -0
- package/dist/utils/blockchain/address.cjs +231 -0
- package/dist/utils/blockchain/address.d.ts +65 -0
- package/dist/utils/blockchain/address.d.ts.map +1 -0
- package/dist/utils/blockchain/address.js +231 -0
- package/dist/utils/blockchain/address.js.map +1 -0
- package/dist/utils/blockchain/event-helpers.cjs +143 -0
- package/dist/utils/blockchain/event-helpers.d.ts +87 -0
- package/dist/utils/blockchain/event-helpers.d.ts.map +1 -0
- package/dist/utils/blockchain/event-helpers.js +143 -0
- package/dist/utils/blockchain/event-helpers.js.map +1 -0
- package/dist/utils/blockchain/index.cjs +30 -0
- package/dist/utils/blockchain/index.d.ts +8 -0
- package/dist/utils/blockchain/index.d.ts.map +1 -0
- package/dist/utils/blockchain/index.js +30 -0
- package/dist/utils/blockchain/index.js.map +1 -0
- package/dist/utils/blockchain/rpc-helpers.cjs +865 -0
- package/dist/utils/blockchain/rpc-helpers.d.ts +251 -0
- package/dist/utils/blockchain/rpc-helpers.d.ts.map +1 -0
- package/dist/utils/blockchain/rpc-helpers.js +865 -0
- package/dist/utils/blockchain/rpc-helpers.js.map +1 -0
- package/dist/utils/constants/application.cjs +158 -0
- package/dist/utils/constants/application.d.ts +119 -0
- package/dist/utils/constants/application.d.ts.map +1 -0
- package/dist/utils/constants/application.js +158 -0
- package/dist/utils/constants/application.js.map +1 -0
- package/dist/utils/constants/index.cjs +30 -0
- package/dist/utils/constants/index.d.ts +7 -0
- package/dist/utils/constants/index.d.ts.map +1 -0
- package/dist/utils/constants/index.js +30 -0
- package/dist/utils/constants/index.js.map +1 -0
- package/dist/utils/constants/status-values.cjs +14 -0
- package/dist/utils/constants/status-values.d.ts +12 -0
- package/dist/utils/constants/status-values.d.ts.map +1 -0
- package/dist/utils/constants/status-values.js +14 -0
- package/dist/utils/constants/status-values.js.map +1 -0
- package/dist/utils/formatting/currency.cjs +36 -0
- package/dist/utils/formatting/currency.d.ts +26 -0
- package/dist/utils/formatting/currency.d.ts.map +1 -0
- package/dist/utils/formatting/currency.js +36 -0
- package/dist/utils/formatting/currency.js.map +1 -0
- package/dist/utils/formatting/date.cjs +138 -0
- package/dist/utils/formatting/date.d.ts +33 -0
- package/dist/utils/formatting/date.d.ts.map +1 -0
- package/dist/utils/formatting/date.js +138 -0
- package/dist/utils/formatting/date.js.map +1 -0
- package/dist/utils/formatting/index.cjs +37 -0
- package/dist/utils/formatting/index.d.ts +4 -0
- package/dist/utils/formatting/index.d.ts.map +1 -0
- package/dist/utils/formatting/index.js +37 -0
- package/dist/utils/formatting/index.js.map +1 -0
- package/dist/utils/formatting/string.cjs +193 -0
- package/dist/utils/formatting/string.d.ts +69 -0
- package/dist/utils/formatting/string.d.ts.map +1 -0
- package/dist/utils/formatting/string.js +193 -0
- package/dist/utils/formatting/string.js.map +1 -0
- package/dist/utils/index.cjs +28 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +28 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logging/index.cjs +16 -0
- package/dist/utils/logging/index.d.ts +5 -0
- package/dist/utils/logging/index.d.ts.map +1 -0
- package/dist/utils/logging/index.js +16 -0
- package/dist/utils/logging/index.js.map +1 -0
- package/dist/utils/logging/logger.cjs +92 -0
- package/dist/utils/logging/logger.d.ts +70 -0
- package/dist/utils/logging/logger.d.ts.map +1 -0
- package/dist/utils/logging/logger.js +92 -0
- package/dist/utils/logging/logger.js.map +1 -0
- package/dist/utils/url/index.cjs +13 -0
- package/dist/utils/url/index.d.ts +5 -0
- package/dist/utils/url/index.d.ts.map +1 -0
- package/dist/utils/url/index.js +13 -0
- package/dist/utils/url/index.js.map +1 -0
- package/dist/utils/url/url-params.cjs +128 -0
- package/dist/utils/url/url-params.d.ts +36 -0
- package/dist/utils/url/url-params.d.ts.map +1 -0
- package/dist/utils/url/url-params.js +128 -0
- package/dist/utils/url/url-params.js.map +1 -0
- package/dist/utils/validation/index.cjs +25 -0
- package/dist/utils/validation/index.d.ts +5 -0
- package/dist/utils/validation/index.d.ts.map +1 -0
- package/dist/utils/validation/index.js +25 -0
- package/dist/utils/validation/index.js.map +1 -0
- package/dist/utils/validation/type-validation.cjs +167 -0
- package/dist/utils/validation/type-validation.d.ts +68 -0
- package/dist/utils/validation/type-validation.d.ts.map +1 -0
- package/dist/utils/validation/type-validation.js +167 -0
- package/dist/utils/validation/type-validation.js.map +1 -0
- package/dist/utils/validation/web3-username-validator.cjs +132 -0
- package/dist/utils/validation/web3-username-validator.d.ts +43 -0
- package/dist/utils/validation/web3-username-validator.d.ts.map +1 -0
- package/dist/utils/validation/web3-username-validator.js +132 -0
- package/dist/utils/validation/web3-username-validator.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC and API endpoint helper utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides helper functions to build RPC endpoints and block explorer API URLs
|
|
5
|
+
* from API keys and chain identifiers.
|
|
6
|
+
*/
|
|
7
|
+
import { Chain, ChainType } from '../../types/business/enums';
|
|
8
|
+
import { Optional } from '../../types/common';
|
|
9
|
+
import type { ChainConfig } from '../../types/blockchain/common';
|
|
10
|
+
/**
|
|
11
|
+
* Blockchain API keys configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface BlockchainApis {
|
|
14
|
+
/** Alchemy API key for RPC access (supports both EVM and Solana) */
|
|
15
|
+
alchemyApiKey: string;
|
|
16
|
+
/** Etherscan Multichain API key for block explorer API access (EVM only) */
|
|
17
|
+
etherscanApiKey: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Helper class for building RPC endpoints and block explorer API URLs
|
|
21
|
+
*/
|
|
22
|
+
export declare class RpcHelpers {
|
|
23
|
+
/**
|
|
24
|
+
* Check if a chain is an EVM chain
|
|
25
|
+
* @param chain - Chain identifier to check
|
|
26
|
+
* @returns True if the chain is an EVM chain
|
|
27
|
+
*/
|
|
28
|
+
static isEvmChain(chain: Chain): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a chain is a Solana chain
|
|
31
|
+
* @param chain - Chain identifier to check
|
|
32
|
+
* @returns True if the chain is a Solana chain
|
|
33
|
+
*/
|
|
34
|
+
static isSolanaChain(chain: Chain): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get the chain type (EVM or Solana) for a given chain
|
|
37
|
+
* @param chain - Chain identifier
|
|
38
|
+
* @returns ChainType.EVM or ChainType.SOLANA
|
|
39
|
+
* @throws Error if the chain is not recognized
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const type = RpcHelpers.getChainType(Chain.ETH_MAINNET);
|
|
43
|
+
* // Returns: ChainType.EVM
|
|
44
|
+
*
|
|
45
|
+
* const solanaType = RpcHelpers.getChainType(Chain.SOLANA_MAINNET);
|
|
46
|
+
* // Returns: ChainType.SOLANA
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
static getChainType(chain: Chain): ChainType;
|
|
50
|
+
/**
|
|
51
|
+
* Get the chain ID for a given chain
|
|
52
|
+
* @param chain - Chain identifier
|
|
53
|
+
* @returns Numeric chain ID for EVM chains, or negative ID for Solana chains
|
|
54
|
+
* @throws Error if the chain is not recognized or has no chain ID
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const ethChainId = RpcHelpers.getChainId(Chain.ETH_MAINNET);
|
|
58
|
+
* // Returns: 1
|
|
59
|
+
*
|
|
60
|
+
* const polygonChainId = RpcHelpers.getChainId(Chain.POLYGON_MAINNET);
|
|
61
|
+
* // Returns: 137
|
|
62
|
+
*
|
|
63
|
+
* const solanaChainId = RpcHelpers.getChainId(Chain.SOLANA_MAINNET);
|
|
64
|
+
* // Returns: -101
|
|
65
|
+
*
|
|
66
|
+
* const localChainId = RpcHelpers.getChainId(Chain.EVM_LOCAL);
|
|
67
|
+
* // Returns: 31337
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
static getChainId(chain: Chain): number;
|
|
71
|
+
/**
|
|
72
|
+
* Get the USDC address/mint for a given chain
|
|
73
|
+
* @param chain - Chain identifier
|
|
74
|
+
* @returns USDC contract address for EVM chains, or mint address for Solana chains
|
|
75
|
+
* @throws Error if the chain is not recognized
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const ethUSDC = RpcHelpers.getUSDCAddress(Chain.ETH_MAINNET);
|
|
79
|
+
* // Returns: '0xA0b86a33E6441146a8A8e27c01f0D9B1F5E42E92'
|
|
80
|
+
*
|
|
81
|
+
* const polygonUSDC = RpcHelpers.getUSDCAddress(Chain.POLYGON_MAINNET);
|
|
82
|
+
* // Returns: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174'
|
|
83
|
+
*
|
|
84
|
+
* const solanaUSDC = RpcHelpers.getUSDCAddress(Chain.SOLANA_MAINNET);
|
|
85
|
+
* // Returns: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static getUSDCAddress(chain: Chain): string;
|
|
89
|
+
/**
|
|
90
|
+
* Get the user-friendly display name for a chain
|
|
91
|
+
* @param chain - Chain identifier
|
|
92
|
+
* @returns Human-readable chain name
|
|
93
|
+
* @throws Error if the chain is not recognized
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const ethName = RpcHelpers.getUserFriendlyName(Chain.ETH_MAINNET);
|
|
97
|
+
* // Returns: 'Ethereum'
|
|
98
|
+
*
|
|
99
|
+
* const polygonName = RpcHelpers.getUserFriendlyName(Chain.POLYGON_MAINNET);
|
|
100
|
+
* // Returns: 'Polygon'
|
|
101
|
+
*
|
|
102
|
+
* const sepoliaName = RpcHelpers.getUserFriendlyName(Chain.ETH_SEPOLIA);
|
|
103
|
+
* // Returns: 'Ethereum Sepolia'
|
|
104
|
+
*
|
|
105
|
+
* const localName = RpcHelpers.getUserFriendlyName(Chain.EVM_LOCAL);
|
|
106
|
+
* // Returns: 'Local EVM'
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
static getUserFriendlyName(chain: Chain): string;
|
|
110
|
+
/**
|
|
111
|
+
* Get the list of visible chains for the application
|
|
112
|
+
* @param isDev - Whether to include development/testnet chains
|
|
113
|
+
* @returns Array of Chain values to display
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const prodChains = RpcHelpers.getVisibleChains(false);
|
|
117
|
+
* // Returns: [Chain.ETH_MAINNET, Chain.BASE_MAINNET, Chain.POLYGON_MAINNET, Chain.OPTIMISM_MAINNET]
|
|
118
|
+
*
|
|
119
|
+
* const devChains = RpcHelpers.getVisibleChains(true);
|
|
120
|
+
* // Returns: [Chain.ETH_MAINNET, Chain.BASE_MAINNET, Chain.POLYGON_MAINNET, Chain.OPTIMISM_MAINNET, Chain.ETH_SEPOLIA]
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
static getVisibleChains(isDev: boolean): Chain[];
|
|
124
|
+
/**
|
|
125
|
+
* Derive all chain information from a ChainConfig
|
|
126
|
+
* @param config - Chain configuration with API keys
|
|
127
|
+
* @returns Object with all derived chain information
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const config: ChainConfig = {
|
|
131
|
+
* chain: Chain.ETH_MAINNET,
|
|
132
|
+
* alchemyApiKey: 'your-alchemy-key',
|
|
133
|
+
* etherscanApiKey: 'your-etherscan-key'
|
|
134
|
+
* };
|
|
135
|
+
*
|
|
136
|
+
* const info = RpcHelpers.getChainInfo(config);
|
|
137
|
+
* // Returns: {
|
|
138
|
+
* // chain: Chain.ETH_MAINNET,
|
|
139
|
+
* // chainId: 1,
|
|
140
|
+
* // chainType: ChainType.EVM,
|
|
141
|
+
* // name: 'Ethereum',
|
|
142
|
+
* // rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/your-alchemy-key',
|
|
143
|
+
* // explorerApiUrl: 'https://api.etherscan.io/api?apikey=your-etherscan-key',
|
|
144
|
+
* // explorerUrl: 'https://etherscan.io',
|
|
145
|
+
* // usdcAddress: '0xA0b86a33E6441146a8A8e27c01f0D9B1F5E42E92'
|
|
146
|
+
* // }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
static getChainInfo(config: ChainConfig): {
|
|
150
|
+
chain: Chain;
|
|
151
|
+
chainId: number;
|
|
152
|
+
chainType: ChainType;
|
|
153
|
+
name: string;
|
|
154
|
+
rpcUrl: Optional<string>;
|
|
155
|
+
explorerApiUrl: Optional<string>;
|
|
156
|
+
explorerUrl: Optional<string>;
|
|
157
|
+
usdcAddress: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Build Alchemy RPC URL for any supported chain
|
|
161
|
+
*
|
|
162
|
+
* @param alchemyApiKey - Your Alchemy API key
|
|
163
|
+
* @param chain - Chain identifier from Chain enum
|
|
164
|
+
* @returns Complete RPC URL, or undefined if API key is empty or chain is unsupported
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const rpcUrl = RpcHelpers.getRpcUrl('your-api-key', Chain.ETH_MAINNET);
|
|
169
|
+
* // Returns: https://eth-mainnet.g.alchemy.com/v2/your-api-key
|
|
170
|
+
*
|
|
171
|
+
* const solanaUrl = RpcHelpers.getRpcUrl('your-api-key', Chain.SOLANA_MAINNET);
|
|
172
|
+
* // Returns: https://solana-mainnet.g.alchemy.com/v2/your-api-key
|
|
173
|
+
*
|
|
174
|
+
* const invalidUrl = RpcHelpers.getRpcUrl('', Chain.ETH_MAINNET);
|
|
175
|
+
* // Returns: undefined
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
static getRpcUrl(alchemyApiKey: string, chain: Chain): Optional<string>;
|
|
179
|
+
/**
|
|
180
|
+
* Get RPC URL using BlockchainApis configuration
|
|
181
|
+
*
|
|
182
|
+
* Convenience overload that uses the BlockchainApis structure.
|
|
183
|
+
*
|
|
184
|
+
* @param apis - Blockchain API keys configuration
|
|
185
|
+
* @param chain - Chain identifier from Chain enum
|
|
186
|
+
* @returns Complete RPC URL, or undefined if invalid
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const apis = {
|
|
191
|
+
* alchemyApiKey: 'your-alchemy-key',
|
|
192
|
+
* etherscanApiKey: 'your-etherscan-key'
|
|
193
|
+
* };
|
|
194
|
+
*
|
|
195
|
+
* const ethRpcUrl = RpcHelpers.getRpcUrl(apis, Chain.ETH_MAINNET);
|
|
196
|
+
* // Returns: https://eth-mainnet.g.alchemy.com/v2/your-alchemy-key
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
static getRpcUrl(apis: BlockchainApis, chain: Chain): Optional<string>;
|
|
200
|
+
/**
|
|
201
|
+
* Get block explorer API URL
|
|
202
|
+
*
|
|
203
|
+
* Uses the Etherscan Multichain API key which works across 60+ EVM networks.
|
|
204
|
+
* The API key is included as a query parameter in the URL.
|
|
205
|
+
* Note: Solana chains don't have Etherscan-style API endpoints and will return undefined.
|
|
206
|
+
*
|
|
207
|
+
* @param etherscanApiKey - Your Etherscan Multichain API key (or BlockchainApis object)
|
|
208
|
+
* @param chain - Chain identifier from Chain enum
|
|
209
|
+
* @returns Complete API endpoint URL with API key, or undefined if API key is empty, chain is Solana, or no explorer API available
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* // With API key string
|
|
214
|
+
* const etherscanUrl = RpcHelpers.getExplorerApiUrl('your-api-key', Chain.ETH_MAINNET);
|
|
215
|
+
* // Returns: https://api.etherscan.io/api?apikey=your-api-key
|
|
216
|
+
*
|
|
217
|
+
* // With BlockchainApis object
|
|
218
|
+
* const apis = {
|
|
219
|
+
* alchemyApiKey: 'your-alchemy-key',
|
|
220
|
+
* etherscanApiKey: 'your-etherscan-key'
|
|
221
|
+
* };
|
|
222
|
+
* const explorerApiUrl = RpcHelpers.getExplorerApiUrl(apis, Chain.POLYGON_MAINNET);
|
|
223
|
+
* // Returns: https://api.polygonscan.com/api?apikey=your-etherscan-key
|
|
224
|
+
*
|
|
225
|
+
* const solanaUrl = RpcHelpers.getExplorerApiUrl('your-api-key', Chain.SOLANA_MAINNET);
|
|
226
|
+
* // Returns: undefined (Solana doesn't have Etherscan-style API)
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
static getExplorerApiUrl(etherscanApiKey: string, chain: Chain): Optional<string>;
|
|
230
|
+
static getExplorerApiUrl(apis: BlockchainApis, chain: Chain): Optional<string>;
|
|
231
|
+
/**
|
|
232
|
+
* Get block explorer browser URL
|
|
233
|
+
*
|
|
234
|
+
* @param chain - Chain identifier from Chain enum
|
|
235
|
+
* @returns Browser URL for the explorer, or undefined if no explorer available
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const etherscanUrl = RpcHelpers.getBlockExplorerUrl(Chain.ETH_MAINNET);
|
|
240
|
+
* // Returns: https://etherscan.io
|
|
241
|
+
*
|
|
242
|
+
* const basescanUrl = RpcHelpers.getBlockExplorerUrl(Chain.BASE_MAINNET);
|
|
243
|
+
* // Returns: https://basescan.org
|
|
244
|
+
*
|
|
245
|
+
* const solanaUrl = RpcHelpers.getBlockExplorerUrl(Chain.SOLANA_MAINNET);
|
|
246
|
+
* // Returns: https://explorer.solana.com
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
static getBlockExplorerUrl(chain: Chain): Optional<string>;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=rpc-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/blockchain/rpc-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAC;CACzB;AA0wBD;;GAEG;AACH,qBAAa,UAAU;IACrB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAIxC;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAI3C;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS;IAU5C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAQvC;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAQ3C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAQhD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE;IAehD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW;;;;;;;;;;IAgBvC;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;IACvE;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;IA0BtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAC,iBAAiB,CACtB,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,KAAK,GACX,QAAQ,CAAC,MAAM,CAAC;IACnB,MAAM,CAAC,iBAAiB,CACtB,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,KAAK,GACX,QAAQ,CAAC,MAAM,CAAC;IA0BnB;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;CAQ3D"}
|