@sip-protocol/sdk 0.7.3 → 0.7.4
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 +267 -0
- package/dist/{TransportWebUSB-TQ7WZ4LE.mjs → TransportWebUSB-YQMAGJAJ.mjs} +12 -9
- package/dist/browser.d.mts +10 -4
- package/dist/browser.d.ts +10 -4
- package/dist/browser.js +47556 -19603
- package/dist/browser.mjs +628 -48
- package/dist/chunk-4GRJ5MAW.mjs +152 -0
- package/dist/chunk-5D7A3L3W.mjs +717 -0
- package/dist/chunk-64AYA5F5.mjs +7834 -0
- package/dist/chunk-GMDGB22A.mjs +379 -0
- package/dist/chunk-I534WKN7.mjs +328 -0
- package/dist/chunk-IBZVA5Y7.mjs +1003 -0
- package/dist/chunk-PRRZAWJE.mjs +223 -0
- package/dist/{chunk-UJCSKKID.mjs → chunk-XGB3TDIC.mjs} +13 -1
- package/dist/{chunk-3M3HNQCW.mjs → chunk-YWGJ77A2.mjs} +28656 -13103
- package/dist/{chunk-6WGN57S2.mjs → chunk-Z3K7W5S3.mjs} +48 -0
- package/dist/constants-LHAAUC2T.mjs +51 -0
- package/dist/dist-2OGQ7FED.mjs +3957 -0
- package/dist/dist-IFHPYLDX.mjs +254 -0
- package/dist/fulfillment_proof-ANHVPKTB.mjs +21 -0
- package/dist/funding_proof-ICFZ5LHY.mjs +21 -0
- package/dist/{index-DIBZHOOQ.d.ts → index-DXh2IGkz.d.ts} +21239 -10304
- package/dist/{index-8MQz13eJ.d.mts → index-DeE1ZzA4.d.mts} +21239 -10304
- package/dist/index.d.mts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +48396 -19623
- package/dist/index.mjs +537 -19
- package/dist/interface-Bf7w1PLW.d.mts +679 -0
- package/dist/interface-Bf7w1PLW.d.ts +679 -0
- package/dist/{noir-DKfEzWy9.d.mts → noir-kzbLVTei.d.mts} +31 -21
- package/dist/{noir-DKfEzWy9.d.ts → noir-kzbLVTei.d.ts} +31 -21
- package/dist/proofs/halo2.d.mts +151 -0
- package/dist/proofs/halo2.d.ts +151 -0
- package/dist/proofs/halo2.js +350 -0
- package/dist/proofs/halo2.mjs +11 -0
- package/dist/proofs/kimchi.d.mts +160 -0
- package/dist/proofs/kimchi.d.ts +160 -0
- package/dist/proofs/kimchi.js +431 -0
- package/dist/proofs/kimchi.mjs +13 -0
- package/dist/proofs/noir.d.mts +1 -1
- package/dist/proofs/noir.d.ts +1 -1
- package/dist/proofs/noir.js +74 -18
- package/dist/proofs/noir.mjs +84 -24
- package/dist/solana-U3MEGU7W.mjs +280 -0
- package/dist/validity_proof-3POXLPNY.mjs +21 -0
- package/package.json +54 -21
- package/src/adapters/index.ts +41 -0
- package/src/adapters/jupiter.ts +571 -0
- package/src/adapters/near-intents.ts +135 -0
- package/src/advisor/advisor.ts +653 -0
- package/src/advisor/index.ts +54 -0
- package/src/advisor/tools.ts +303 -0
- package/src/advisor/types.ts +164 -0
- package/src/chains/ethereum/announcement.ts +536 -0
- package/src/chains/ethereum/bnb-optimizations.ts +474 -0
- package/src/chains/ethereum/commitment.ts +522 -0
- package/src/chains/ethereum/constants.ts +462 -0
- package/src/chains/ethereum/deployment.ts +596 -0
- package/src/chains/ethereum/gas-estimation.ts +538 -0
- package/src/chains/ethereum/index.ts +268 -0
- package/src/chains/ethereum/optimizations.ts +614 -0
- package/src/chains/ethereum/privacy-adapter.ts +855 -0
- package/src/chains/ethereum/registry.ts +584 -0
- package/src/chains/ethereum/rpc.ts +905 -0
- package/src/chains/ethereum/stealth.ts +491 -0
- package/src/chains/ethereum/token.ts +790 -0
- package/src/chains/ethereum/transfer.ts +637 -0
- package/src/chains/ethereum/types.ts +456 -0
- package/src/chains/ethereum/viewing-key.ts +455 -0
- package/src/chains/near/commitment.ts +608 -0
- package/src/chains/near/constants.ts +284 -0
- package/src/chains/near/function-call.ts +871 -0
- package/src/chains/near/history.ts +654 -0
- package/src/chains/near/implicit-account.ts +840 -0
- package/src/chains/near/index.ts +393 -0
- package/src/chains/near/native-transfer.ts +658 -0
- package/src/chains/near/nep141.ts +775 -0
- package/src/chains/near/privacy-adapter.ts +889 -0
- package/src/chains/near/resolver.ts +971 -0
- package/src/chains/near/rpc.ts +1016 -0
- package/src/chains/near/stealth.ts +419 -0
- package/src/chains/near/types.ts +317 -0
- package/src/chains/near/viewing-key.ts +876 -0
- package/src/chains/solana/anchor-transfer.ts +386 -0
- package/src/chains/solana/commitment.ts +577 -0
- package/src/chains/solana/constants.ts +126 -12
- package/src/chains/solana/ephemeral-keys.ts +543 -0
- package/src/chains/solana/index.ts +252 -1
- package/src/chains/solana/key-derivation.ts +418 -0
- package/src/chains/solana/kit-compat.ts +334 -0
- package/src/chains/solana/optimizations.ts +560 -0
- package/src/chains/solana/privacy-adapter.ts +605 -0
- package/src/chains/solana/providers/generic.ts +47 -6
- package/src/chains/solana/providers/helius-enhanced-types.ts +336 -0
- package/src/chains/solana/providers/helius-enhanced.ts +623 -0
- package/src/chains/solana/providers/helius.ts +186 -33
- package/src/chains/solana/providers/index.ts +31 -0
- package/src/chains/solana/providers/interface.ts +61 -18
- package/src/chains/solana/providers/quicknode.ts +409 -0
- package/src/chains/solana/providers/triton.ts +426 -0
- package/src/chains/solana/providers/webhook.ts +338 -67
- package/src/chains/solana/rpc-client.ts +1150 -0
- package/src/chains/solana/scan.ts +83 -66
- package/src/chains/solana/sol-transfer.ts +732 -0
- package/src/chains/solana/spl-transfer.ts +886 -0
- package/src/chains/solana/stealth-scanner.ts +703 -0
- package/src/chains/solana/sunspot-verifier.ts +453 -0
- package/src/chains/solana/transaction-builder.ts +755 -0
- package/src/chains/solana/transfer.ts +74 -5
- package/src/chains/solana/types.ts +57 -6
- package/src/chains/solana/utils.ts +110 -0
- package/src/chains/solana/viewing-key.ts +807 -0
- package/src/compliance/fireblocks.ts +921 -0
- package/src/compliance/index.ts +23 -0
- package/src/compliance/range-sas.ts +398 -33
- package/src/config/endpoints.ts +100 -0
- package/src/crypto.ts +11 -8
- package/src/errors.ts +82 -0
- package/src/evm/erc4337-relayer.ts +830 -0
- package/src/evm/index.ts +47 -0
- package/src/fees/calculator.ts +396 -0
- package/src/fees/index.ts +87 -0
- package/src/fees/near-contract.ts +429 -0
- package/src/fees/types.ts +268 -0
- package/src/index.ts +686 -1
- package/src/intent.ts +6 -3
- package/src/logger.ts +324 -0
- package/src/network/index.ts +80 -0
- package/src/network/proxy.ts +691 -0
- package/src/optimizations/index.ts +541 -0
- package/src/oracle/types.ts +1 -0
- package/src/privacy-backends/arcium-types.ts +727 -0
- package/src/privacy-backends/arcium.ts +719 -0
- package/src/privacy-backends/combined-privacy.ts +866 -0
- package/src/privacy-backends/cspl-token.ts +595 -0
- package/src/privacy-backends/cspl-types.ts +512 -0
- package/src/privacy-backends/cspl.ts +907 -0
- package/src/privacy-backends/health.ts +488 -0
- package/src/privacy-backends/inco-types.ts +323 -0
- package/src/privacy-backends/inco.ts +616 -0
- package/src/privacy-backends/index.ts +254 -4
- package/src/privacy-backends/interface.ts +649 -6
- package/src/privacy-backends/lru-cache.ts +343 -0
- package/src/privacy-backends/magicblock.ts +458 -0
- package/src/privacy-backends/mock.ts +258 -0
- package/src/privacy-backends/privacycash.ts +13 -17
- package/src/privacy-backends/private-swap.ts +570 -0
- package/src/privacy-backends/rate-limiter.ts +683 -0
- package/src/privacy-backends/registry.ts +414 -2
- package/src/privacy-backends/router.ts +283 -3
- package/src/privacy-backends/shadowwire.ts +449 -0
- package/src/privacy-backends/sip-native.ts +3 -0
- package/src/privacy-logger.ts +191 -0
- package/src/production-safety.ts +373 -0
- package/src/proofs/aggregator.ts +1029 -0
- package/src/proofs/browser-composer.ts +1150 -0
- package/src/proofs/browser.ts +113 -25
- package/src/proofs/cache/index.ts +127 -0
- package/src/proofs/cache/interface.ts +545 -0
- package/src/proofs/cache/key-generator.ts +188 -0
- package/src/proofs/cache/lru-cache.ts +481 -0
- package/src/proofs/cache/multi-tier-cache.ts +575 -0
- package/src/proofs/cache/persistent-cache.ts +788 -0
- package/src/proofs/compliance-proof.ts +872 -0
- package/src/proofs/composer/base.ts +923 -0
- package/src/proofs/composer/index.ts +25 -0
- package/src/proofs/composer/interface.ts +518 -0
- package/src/proofs/composer/types.ts +383 -0
- package/src/proofs/converters/halo2.ts +452 -0
- package/src/proofs/converters/index.ts +208 -0
- package/src/proofs/converters/interface.ts +363 -0
- package/src/proofs/converters/kimchi.ts +462 -0
- package/src/proofs/converters/noir.ts +451 -0
- package/src/proofs/fallback.ts +888 -0
- package/src/proofs/halo2.ts +42 -0
- package/src/proofs/index.ts +471 -0
- package/src/proofs/interface.ts +13 -0
- package/src/proofs/kimchi.ts +42 -0
- package/src/proofs/lazy.ts +1004 -0
- package/src/proofs/mock.ts +25 -1
- package/src/proofs/noir.ts +110 -29
- package/src/proofs/orchestrator.ts +960 -0
- package/src/proofs/parallel/concurrency.ts +297 -0
- package/src/proofs/parallel/dependency-graph.ts +602 -0
- package/src/proofs/parallel/executor.ts +420 -0
- package/src/proofs/parallel/index.ts +131 -0
- package/src/proofs/parallel/interface.ts +685 -0
- package/src/proofs/parallel/worker-pool.ts +644 -0
- package/src/proofs/providers/halo2.ts +560 -0
- package/src/proofs/providers/index.ts +34 -0
- package/src/proofs/providers/kimchi.ts +641 -0
- package/src/proofs/validator.ts +881 -0
- package/src/proofs/verifier.ts +867 -0
- package/src/quantum/index.ts +112 -0
- package/src/quantum/winternitz-vault.ts +639 -0
- package/src/quantum/wots.ts +611 -0
- package/src/settlement/backends/direct-chain.ts +1 -0
- package/src/settlement/index.ts +9 -0
- package/src/settlement/router.ts +732 -46
- package/src/solana/index.ts +72 -0
- package/src/solana/jito-relayer.ts +687 -0
- package/src/solana/noir-verifier-types.ts +430 -0
- package/src/solana/noir-verifier.ts +816 -0
- package/src/stealth/address-derivation.ts +193 -0
- package/src/stealth/ed25519.ts +431 -0
- package/src/stealth/index.ts +233 -0
- package/src/stealth/meta-address.ts +221 -0
- package/src/stealth/secp256k1.ts +368 -0
- package/src/stealth/utils.ts +194 -0
- package/src/stealth.ts +50 -1504
- package/src/sync/index.ts +106 -0
- package/src/sync/manager.ts +504 -0
- package/src/sync/mock-provider.ts +318 -0
- package/src/sync/oblivious.ts +625 -0
- package/src/tokens/index.ts +15 -0
- package/src/tokens/registry.ts +301 -0
- package/src/utils/deprecation.ts +94 -0
- package/src/utils/index.ts +9 -0
- package/src/wallet/ethereum/index.ts +68 -0
- package/src/wallet/ethereum/metamask-privacy.ts +420 -0
- package/src/wallet/ethereum/multi-wallet.ts +646 -0
- package/src/wallet/ethereum/privacy-adapter.ts +700 -0
- package/src/wallet/ethereum/types.ts +3 -1
- package/src/wallet/ethereum/walletconnect-adapter.ts +675 -0
- package/src/wallet/hardware/index.ts +10 -0
- package/src/wallet/hardware/ledger-privacy.ts +414 -0
- package/src/wallet/index.ts +71 -0
- package/src/wallet/near/adapter.ts +626 -0
- package/src/wallet/near/index.ts +86 -0
- package/src/wallet/near/meteor-wallet.ts +1153 -0
- package/src/wallet/near/my-near-wallet.ts +790 -0
- package/src/wallet/near/wallet-selector.ts +702 -0
- package/src/wallet/solana/adapter.ts +6 -4
- package/src/wallet/solana/index.ts +13 -0
- package/src/wallet/solana/privacy-adapter.ts +567 -0
- package/src/wallet/sui/types.ts +6 -4
- package/src/zcash/rpc-client.ts +13 -6
- package/dist/chunk-2XIVXWHA.mjs +0 -1930
- package/dist/chunk-3INS3PR5.mjs +0 -884
- package/dist/chunk-3OVABDRH.mjs +0 -17096
- package/dist/chunk-7RFRWDCW.mjs +0 -1504
- package/dist/chunk-DLDWZFYC.mjs +0 -1495
- package/dist/chunk-E6SZWREQ.mjs +0 -57
- package/dist/chunk-F6F73W35.mjs +0 -16166
- package/dist/chunk-G33LB27A.mjs +0 -16166
- package/dist/chunk-HGU6HZRC.mjs +0 -231
- package/dist/chunk-L2K34JCU.mjs +0 -1496
- package/dist/chunk-OFDBEIEK.mjs +0 -16166
- package/dist/chunk-SF7YSLF5.mjs +0 -1515
- package/dist/chunk-SN4ZDTVW.mjs +0 -16166
- package/dist/chunk-WWUSGOXE.mjs +0 -17129
- package/dist/constants-VOI7BSLK.mjs +0 -27
- package/dist/index-B71aXVzk.d.ts +0 -13264
- package/dist/index-BYZbDjal.d.ts +0 -11390
- package/dist/index-CHB3KuOB.d.mts +0 -11859
- package/dist/index-CzWPI6Le.d.ts +0 -11859
- package/dist/index-pOIIuwfV.d.mts +0 -13264
- package/dist/index-xbWjohNq.d.mts +0 -11390
- package/dist/solana-4O4K45VU.mjs +0 -46
- package/dist/solana-5EMCTPTS.mjs +0 -46
- package/dist/solana-NDABAZ6P.mjs +0 -56
- package/dist/solana-Q4NAVBTS.mjs +0 -46
- package/dist/solana-ZYO63LY5.mjs +0 -46
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ethereum Chain Constants
|
|
3
|
+
*
|
|
4
|
+
* RPC endpoints, token addresses, and configuration for Ethereum same-chain privacy.
|
|
5
|
+
* Supports mainnet and common L2s (Arbitrum, Optimism, Base).
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get environment variable or return default
|
|
12
|
+
* Works in both Node.js and browser environments
|
|
13
|
+
*/
|
|
14
|
+
function getEnvVar(name: string, defaultValue: string): string {
|
|
15
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
16
|
+
return process.env[name] || defaultValue
|
|
17
|
+
}
|
|
18
|
+
return defaultValue
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Ethereum network types
|
|
23
|
+
*/
|
|
24
|
+
export type EthereumNetwork =
|
|
25
|
+
| 'mainnet'
|
|
26
|
+
| 'sepolia'
|
|
27
|
+
| 'goerli'
|
|
28
|
+
| 'arbitrum'
|
|
29
|
+
| 'arbitrum-sepolia'
|
|
30
|
+
| 'optimism'
|
|
31
|
+
| 'optimism-sepolia'
|
|
32
|
+
| 'base'
|
|
33
|
+
| 'base-sepolia'
|
|
34
|
+
| 'polygon'
|
|
35
|
+
| 'polygon-mumbai'
|
|
36
|
+
| 'zksync'
|
|
37
|
+
| 'scroll'
|
|
38
|
+
| 'linea'
|
|
39
|
+
| 'mantle'
|
|
40
|
+
| 'blast'
|
|
41
|
+
| 'bsc'
|
|
42
|
+
| 'bsc-testnet'
|
|
43
|
+
| 'localhost'
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* EVM chain IDs
|
|
47
|
+
*/
|
|
48
|
+
export const EVM_CHAIN_IDS: Record<EthereumNetwork, number> = {
|
|
49
|
+
mainnet: 1,
|
|
50
|
+
sepolia: 11155111,
|
|
51
|
+
goerli: 5,
|
|
52
|
+
arbitrum: 42161,
|
|
53
|
+
'arbitrum-sepolia': 421614,
|
|
54
|
+
optimism: 10,
|
|
55
|
+
'optimism-sepolia': 11155420,
|
|
56
|
+
base: 8453,
|
|
57
|
+
'base-sepolia': 84532,
|
|
58
|
+
polygon: 137,
|
|
59
|
+
'polygon-mumbai': 80001,
|
|
60
|
+
zksync: 324,
|
|
61
|
+
scroll: 534352,
|
|
62
|
+
linea: 59144,
|
|
63
|
+
mantle: 5000,
|
|
64
|
+
blast: 81457,
|
|
65
|
+
bsc: 56,
|
|
66
|
+
'bsc-testnet': 97,
|
|
67
|
+
localhost: 31337,
|
|
68
|
+
} as const
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Ethereum RPC endpoints by network
|
|
72
|
+
* Users should override with their own RPC providers (Alchemy, Infura, etc.)
|
|
73
|
+
*/
|
|
74
|
+
export const ETHEREUM_RPC_ENDPOINTS: Record<EthereumNetwork, string> = {
|
|
75
|
+
mainnet: getEnvVar('ETH_MAINNET_RPC', 'https://eth.llamarpc.com'),
|
|
76
|
+
sepolia: getEnvVar('ETH_SEPOLIA_RPC', 'https://rpc.sepolia.org'),
|
|
77
|
+
goerli: getEnvVar('ETH_GOERLI_RPC', 'https://rpc.goerli.eth.gateway.fm'),
|
|
78
|
+
arbitrum: getEnvVar('ARB_MAINNET_RPC', 'https://arb1.arbitrum.io/rpc'),
|
|
79
|
+
'arbitrum-sepolia': getEnvVar('ARB_SEPOLIA_RPC', 'https://sepolia-rollup.arbitrum.io/rpc'),
|
|
80
|
+
optimism: getEnvVar('OP_MAINNET_RPC', 'https://mainnet.optimism.io'),
|
|
81
|
+
'optimism-sepolia': getEnvVar('OP_SEPOLIA_RPC', 'https://sepolia.optimism.io'),
|
|
82
|
+
base: getEnvVar('BASE_MAINNET_RPC', 'https://mainnet.base.org'),
|
|
83
|
+
'base-sepolia': getEnvVar('BASE_SEPOLIA_RPC', 'https://sepolia.base.org'),
|
|
84
|
+
polygon: getEnvVar('POLYGON_MAINNET_RPC', 'https://polygon-rpc.com'),
|
|
85
|
+
'polygon-mumbai': getEnvVar('POLYGON_MUMBAI_RPC', 'https://rpc-mumbai.maticvigil.com'),
|
|
86
|
+
zksync: getEnvVar('ZKSYNC_MAINNET_RPC', 'https://mainnet.era.zksync.io'),
|
|
87
|
+
scroll: getEnvVar('SCROLL_MAINNET_RPC', 'https://rpc.scroll.io'),
|
|
88
|
+
linea: getEnvVar('LINEA_MAINNET_RPC', 'https://rpc.linea.build'),
|
|
89
|
+
mantle: getEnvVar('MANTLE_MAINNET_RPC', 'https://rpc.mantle.xyz'),
|
|
90
|
+
blast: getEnvVar('BLAST_MAINNET_RPC', 'https://rpc.blast.io'),
|
|
91
|
+
bsc: getEnvVar('BSC_MAINNET_RPC', 'https://bsc-dataseed.binance.org'),
|
|
92
|
+
'bsc-testnet': getEnvVar('BSC_TESTNET_RPC', 'https://data-seed-prebsc-1-s1.binance.org:8545'),
|
|
93
|
+
localhost: getEnvVar('ETH_LOCALHOST_RPC', 'http://localhost:8545'),
|
|
94
|
+
} as const
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Block explorer URLs by network
|
|
98
|
+
*/
|
|
99
|
+
export const ETHEREUM_EXPLORER_URLS: Record<EthereumNetwork, string> = {
|
|
100
|
+
mainnet: 'https://etherscan.io',
|
|
101
|
+
sepolia: 'https://sepolia.etherscan.io',
|
|
102
|
+
goerli: 'https://goerli.etherscan.io',
|
|
103
|
+
arbitrum: 'https://arbiscan.io',
|
|
104
|
+
'arbitrum-sepolia': 'https://sepolia.arbiscan.io',
|
|
105
|
+
optimism: 'https://optimistic.etherscan.io',
|
|
106
|
+
'optimism-sepolia': 'https://sepolia-optimism.etherscan.io',
|
|
107
|
+
base: 'https://basescan.org',
|
|
108
|
+
'base-sepolia': 'https://sepolia.basescan.org',
|
|
109
|
+
polygon: 'https://polygonscan.com',
|
|
110
|
+
'polygon-mumbai': 'https://mumbai.polygonscan.com',
|
|
111
|
+
zksync: 'https://explorer.zksync.io',
|
|
112
|
+
scroll: 'https://scrollscan.com',
|
|
113
|
+
linea: 'https://lineascan.build',
|
|
114
|
+
mantle: 'https://explorer.mantle.xyz',
|
|
115
|
+
blast: 'https://blastscan.io',
|
|
116
|
+
bsc: 'https://bscscan.com',
|
|
117
|
+
'bsc-testnet': 'https://testnet.bscscan.com',
|
|
118
|
+
localhost: 'http://localhost:8545',
|
|
119
|
+
} as const
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Common ERC-20 token addresses on Ethereum mainnet
|
|
123
|
+
*/
|
|
124
|
+
export const ETHEREUM_TOKEN_CONTRACTS = {
|
|
125
|
+
/** Wrapped ETH */
|
|
126
|
+
WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
127
|
+
/** USD Coin */
|
|
128
|
+
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
129
|
+
/** Tether USD */
|
|
130
|
+
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
131
|
+
/** Dai Stablecoin */
|
|
132
|
+
DAI: '0x6B175474E89094C44Da98b954EescdeCB5bE3d830',
|
|
133
|
+
/** Chainlink */
|
|
134
|
+
LINK: '0x514910771AF9Ca656af840dff83E8264EcF986CA',
|
|
135
|
+
/** Uniswap */
|
|
136
|
+
UNI: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
|
|
137
|
+
/** Aave */
|
|
138
|
+
AAVE: '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9',
|
|
139
|
+
} as const
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Token decimals for Ethereum tokens
|
|
143
|
+
*/
|
|
144
|
+
export const ETHEREUM_TOKEN_DECIMALS: Record<string, number> = {
|
|
145
|
+
ETH: 18,
|
|
146
|
+
WETH: 18,
|
|
147
|
+
USDC: 6,
|
|
148
|
+
USDT: 6,
|
|
149
|
+
DAI: 18,
|
|
150
|
+
LINK: 18,
|
|
151
|
+
UNI: 18,
|
|
152
|
+
AAVE: 18,
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Common BEP-20 token addresses on BNB Chain (BSC) mainnet
|
|
157
|
+
*/
|
|
158
|
+
export const BSC_TOKEN_CONTRACTS = {
|
|
159
|
+
/** Wrapped BNB */
|
|
160
|
+
WBNB: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
|
|
161
|
+
/** Binance-Peg USD Coin */
|
|
162
|
+
USDC: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
|
|
163
|
+
/** Binance-Peg Tether USD */
|
|
164
|
+
USDT: '0x55d398326f99059fF775485246999027B3197955',
|
|
165
|
+
/** Binance-Peg DAI */
|
|
166
|
+
DAI: '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3',
|
|
167
|
+
/** Binance-Peg Chainlink */
|
|
168
|
+
LINK: '0xF8A0BF9cF54Bb92F17374d9e9A321E6a111a51bD',
|
|
169
|
+
/** PancakeSwap Token */
|
|
170
|
+
CAKE: '0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82',
|
|
171
|
+
/** Binance-Peg Ethereum */
|
|
172
|
+
ETH: '0x2170Ed0880ac9A755fd29B2688956BD959F933F8',
|
|
173
|
+
/** Binance-Peg BTCB */
|
|
174
|
+
BTCB: '0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c',
|
|
175
|
+
} as const
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Token decimals for BNB Chain tokens
|
|
179
|
+
*/
|
|
180
|
+
export const BSC_TOKEN_DECIMALS: Record<string, number> = {
|
|
181
|
+
BNB: 18,
|
|
182
|
+
WBNB: 18,
|
|
183
|
+
USDC: 18, // Note: BSC USDC uses 18 decimals, not 6
|
|
184
|
+
USDT: 18, // Note: BSC USDT uses 18 decimals, not 6
|
|
185
|
+
DAI: 18,
|
|
186
|
+
LINK: 18,
|
|
187
|
+
CAKE: 18,
|
|
188
|
+
ETH: 18,
|
|
189
|
+
BTCB: 18,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* PancakeSwap contract addresses on BNB Chain (BSC)
|
|
194
|
+
* PancakeSwap is the dominant DEX on BSC (like Uniswap on Ethereum)
|
|
195
|
+
*/
|
|
196
|
+
export const PANCAKESWAP_CONTRACTS = {
|
|
197
|
+
/** PancakeSwap V3 SmartRouter (preferred for best routing) */
|
|
198
|
+
SMART_ROUTER: '0x13f4EA83D0bd40E75C8222255bc855a974568Dd4',
|
|
199
|
+
/** PancakeSwap V3 Router */
|
|
200
|
+
V3_ROUTER: '0x1b81D678ffb9C0263b24A97847620C99d213eB14',
|
|
201
|
+
/** PancakeSwap V2 Router (legacy, still widely used) */
|
|
202
|
+
V2_ROUTER: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
|
|
203
|
+
/** PancakeSwap V3 Factory */
|
|
204
|
+
V3_FACTORY: '0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865',
|
|
205
|
+
/** PancakeSwap V2 Factory */
|
|
206
|
+
V2_FACTORY: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',
|
|
207
|
+
/** PancakeSwap Quoter V2 (for price quotes) */
|
|
208
|
+
QUOTER_V2: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997',
|
|
209
|
+
} as const
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* PancakeSwap contract addresses on BSC Testnet
|
|
213
|
+
*/
|
|
214
|
+
export const PANCAKESWAP_TESTNET_CONTRACTS = {
|
|
215
|
+
/** PancakeSwap V3 SmartRouter */
|
|
216
|
+
SMART_ROUTER: '0x9a489505a00cE272eAa5e07Dba6491314CaE3796',
|
|
217
|
+
/** PancakeSwap V3 Router */
|
|
218
|
+
V3_ROUTER: '0x1b81D678ffb9C0263b24A97847620C99d213eB14',
|
|
219
|
+
/** PancakeSwap V2 Router */
|
|
220
|
+
V2_ROUTER: '0xD99D1c33F9fC3444f8101754aBC46c52416550D1',
|
|
221
|
+
/** PancakeSwap V3 Factory */
|
|
222
|
+
V3_FACTORY: '0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865',
|
|
223
|
+
/** PancakeSwap V2 Factory */
|
|
224
|
+
V2_FACTORY: '0x6725F303b657a9451d8BA641348b6761A6CC7a17',
|
|
225
|
+
/** PancakeSwap Quoter V2 */
|
|
226
|
+
QUOTER_V2: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
|
|
227
|
+
} as const
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* EIP-5564 Stealth Address Announcer contract address
|
|
231
|
+
* Deployed on mainnet and most L2s at the same address
|
|
232
|
+
*/
|
|
233
|
+
export const EIP5564_ANNOUNCER_ADDRESS = '0x55649E01B5Df198D18D95b5cc5051630cfD45564'
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* EIP-5564 Stealth Meta-Address Registry contract address
|
|
237
|
+
*/
|
|
238
|
+
export const EIP5564_REGISTRY_ADDRESS = '0x6538E6bf4B0eBd30A8Ea10e318b7AEb51A8E4b5c'
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* SIP announcement event signature (for log filtering)
|
|
242
|
+
* Announcement(uint256 indexed schemeId, address indexed stealthAddress, address indexed caller, bytes ephemeralPubKey, bytes metadata)
|
|
243
|
+
*/
|
|
244
|
+
export const ANNOUNCEMENT_EVENT_SIGNATURE =
|
|
245
|
+
'0x5f0eab8057630ba7676c49b4f21a0231414e79474595be8e4c432fbf6bf0f4e7'
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* EIP-5564 scheme ID for secp256k1 stealth addresses
|
|
249
|
+
*/
|
|
250
|
+
export const SECP256K1_SCHEME_ID = 1
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* View tag byte position and mask
|
|
254
|
+
*/
|
|
255
|
+
export const VIEW_TAG_MIN = 0
|
|
256
|
+
export const VIEW_TAG_MAX = 255
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Secp256k1 compressed public key length (33 bytes)
|
|
260
|
+
*/
|
|
261
|
+
export const SECP256K1_PUBKEY_LENGTH = 33
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Secp256k1 compressed public key hex length including '0x' prefix
|
|
265
|
+
*/
|
|
266
|
+
export const SECP256K1_PUBKEY_HEX_LENGTH = 68
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Ethereum address length (20 bytes)
|
|
270
|
+
*/
|
|
271
|
+
export const ETH_ADDRESS_LENGTH = 20
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Ethereum address hex length including '0x' prefix
|
|
275
|
+
*/
|
|
276
|
+
export const ETH_ADDRESS_HEX_LENGTH = 42
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Default gas limits for common operations
|
|
280
|
+
*/
|
|
281
|
+
export const DEFAULT_GAS_LIMITS = {
|
|
282
|
+
/** Native ETH transfer */
|
|
283
|
+
ethTransfer: 21000n,
|
|
284
|
+
/** ERC-20 transfer */
|
|
285
|
+
erc20Transfer: 65000n,
|
|
286
|
+
/** ERC-20 approve */
|
|
287
|
+
erc20Approve: 46000n,
|
|
288
|
+
/** Stealth address announcement */
|
|
289
|
+
announcement: 80000n,
|
|
290
|
+
/** Claim from stealth address */
|
|
291
|
+
claim: 100000n,
|
|
292
|
+
/** Registry: register stealth meta-address */
|
|
293
|
+
registryRegister: 150000n,
|
|
294
|
+
/** Registry: update stealth meta-address */
|
|
295
|
+
registryUpdate: 100000n,
|
|
296
|
+
/** Registry: query meta-address (view call) */
|
|
297
|
+
registryQuery: 0n,
|
|
298
|
+
} as const
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* One ETH in wei
|
|
302
|
+
*/
|
|
303
|
+
export const ONE_ETH = 10n ** 18n
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* One Gwei in wei
|
|
307
|
+
*/
|
|
308
|
+
export const ONE_GWEI = 10n ** 9n
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Get explorer URL for a transaction
|
|
312
|
+
*/
|
|
313
|
+
export function getExplorerUrl(
|
|
314
|
+
txHash: string,
|
|
315
|
+
network: EthereumNetwork = 'mainnet'
|
|
316
|
+
): string {
|
|
317
|
+
const baseUrl = ETHEREUM_EXPLORER_URLS[network]
|
|
318
|
+
return `${baseUrl}/tx/${txHash}`
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Get explorer URL for an address
|
|
323
|
+
*/
|
|
324
|
+
export function getAddressExplorerUrl(
|
|
325
|
+
address: string,
|
|
326
|
+
network: EthereumNetwork = 'mainnet'
|
|
327
|
+
): string {
|
|
328
|
+
const baseUrl = ETHEREUM_EXPLORER_URLS[network]
|
|
329
|
+
return `${baseUrl}/address/${address}`
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Get explorer URL for a token
|
|
334
|
+
*/
|
|
335
|
+
export function getTokenExplorerUrl(
|
|
336
|
+
tokenAddress: string,
|
|
337
|
+
network: EthereumNetwork = 'mainnet'
|
|
338
|
+
): string {
|
|
339
|
+
const baseUrl = ETHEREUM_EXPLORER_URLS[network]
|
|
340
|
+
return `${baseUrl}/token/${tokenAddress}`
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Get token contract address from symbol
|
|
345
|
+
*/
|
|
346
|
+
export function getTokenContract(symbol: string): string | undefined {
|
|
347
|
+
return ETHEREUM_TOKEN_CONTRACTS[symbol as keyof typeof ETHEREUM_TOKEN_CONTRACTS]
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Get token decimals from symbol
|
|
352
|
+
*/
|
|
353
|
+
export function getEthereumTokenDecimals(symbol: string): number {
|
|
354
|
+
return ETHEREUM_TOKEN_DECIMALS[symbol] ?? 18
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Get chain ID for a network
|
|
359
|
+
*/
|
|
360
|
+
export function getChainId(network: EthereumNetwork): number {
|
|
361
|
+
return EVM_CHAIN_IDS[network]
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Get network name from chain ID
|
|
366
|
+
*/
|
|
367
|
+
export function getNetworkFromChainId(chainId: number): EthereumNetwork | undefined {
|
|
368
|
+
const entry = Object.entries(EVM_CHAIN_IDS).find(([_, id]) => id === chainId)
|
|
369
|
+
return entry ? (entry[0] as EthereumNetwork) : undefined
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Check if a network is a testnet
|
|
374
|
+
*/
|
|
375
|
+
export function isTestnet(network: EthereumNetwork): boolean {
|
|
376
|
+
return (
|
|
377
|
+
network === 'sepolia' ||
|
|
378
|
+
network === 'goerli' ||
|
|
379
|
+
network === 'arbitrum-sepolia' ||
|
|
380
|
+
network === 'optimism-sepolia' ||
|
|
381
|
+
network === 'base-sepolia' ||
|
|
382
|
+
network === 'polygon-mumbai' ||
|
|
383
|
+
network === 'bsc-testnet' ||
|
|
384
|
+
network === 'localhost'
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Check if a network is an L2
|
|
390
|
+
*/
|
|
391
|
+
export function isL2Network(network: EthereumNetwork): boolean {
|
|
392
|
+
return (
|
|
393
|
+
network === 'arbitrum' ||
|
|
394
|
+
network === 'arbitrum-sepolia' ||
|
|
395
|
+
network === 'optimism' ||
|
|
396
|
+
network === 'optimism-sepolia' ||
|
|
397
|
+
network === 'base' ||
|
|
398
|
+
network === 'base-sepolia' ||
|
|
399
|
+
network === 'polygon' ||
|
|
400
|
+
network === 'polygon-mumbai'
|
|
401
|
+
)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Check if a network is an alternative L1 (non-Ethereum mainnet EVM chain)
|
|
406
|
+
*/
|
|
407
|
+
export function isAltL1Network(network: EthereumNetwork): boolean {
|
|
408
|
+
return network === 'bsc' || network === 'bsc-testnet'
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Validate an Ethereum address format (basic check)
|
|
413
|
+
*/
|
|
414
|
+
export function isValidEthAddress(address: string): boolean {
|
|
415
|
+
return /^0x[0-9a-fA-F]{40}$/.test(address)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Sanitize a URL by masking potential credentials
|
|
420
|
+
*/
|
|
421
|
+
export function sanitizeUrl(url: string): string {
|
|
422
|
+
try {
|
|
423
|
+
const parsed = new URL(url)
|
|
424
|
+
|
|
425
|
+
if (parsed.username || parsed.password) {
|
|
426
|
+
parsed.username = '***'
|
|
427
|
+
parsed.password = ''
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const sensitivePatterns = [
|
|
431
|
+
'api-key',
|
|
432
|
+
'apikey',
|
|
433
|
+
'api_key',
|
|
434
|
+
'key',
|
|
435
|
+
'token',
|
|
436
|
+
'x-token',
|
|
437
|
+
'secret',
|
|
438
|
+
'auth',
|
|
439
|
+
]
|
|
440
|
+
const keysToMask: string[] = []
|
|
441
|
+
for (const [key] of parsed.searchParams) {
|
|
442
|
+
const keyLower = key.toLowerCase()
|
|
443
|
+
if (
|
|
444
|
+
sensitivePatterns.some(
|
|
445
|
+
(pattern) => keyLower === pattern || keyLower.includes(pattern)
|
|
446
|
+
)
|
|
447
|
+
) {
|
|
448
|
+
keysToMask.push(key)
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
for (const key of keysToMask) {
|
|
452
|
+
parsed.searchParams.set(key, '***')
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return parsed.toString()
|
|
456
|
+
} catch {
|
|
457
|
+
return url
|
|
458
|
+
.replace(/api-key=[^&]+/gi, 'api-key=***')
|
|
459
|
+
.replace(/apikey=[^&]+/gi, 'apikey=***')
|
|
460
|
+
.replace(/token=[^&]+/gi, 'token=***')
|
|
461
|
+
}
|
|
462
|
+
}
|