@sip-protocol/sdk 0.7.2 → 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 +48874 -18336
- package/dist/browser.mjs +674 -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-YWGJ77A2.mjs +33806 -0
- 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-DXh2IGkz.d.ts +24681 -0
- package/dist/index-DeE1ZzA4.d.mts +24681 -0
- package/dist/index.d.mts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +48676 -17318
- package/dist/index.mjs +583 -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 +276 -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 +201 -0
- 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 +402 -0
- package/src/chains/solana/providers/index.ts +85 -0
- package/src/chains/solana/providers/interface.ts +221 -0
- 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 +790 -0
- package/src/chains/solana/rpc-client.ts +1150 -0
- package/src/chains/solana/scan.ts +170 -73
- 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 +77 -7
- 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 +37 -0
- package/src/compliance/range-sas.ts +956 -0
- 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 +785 -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 +336 -0
- package/src/privacy-backends/interface.ts +906 -0
- 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-types.ts +278 -0
- package/src/privacy-backends/privacycash.ts +456 -0
- package/src/privacy-backends/private-swap.ts +570 -0
- package/src/privacy-backends/rate-limiter.ts +683 -0
- package/src/privacy-backends/registry.ts +690 -0
- package/src/privacy-backends/router.ts +626 -0
- package/src/privacy-backends/shadowwire.ts +449 -0
- package/src/privacy-backends/sip-native.ts +256 -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 +111 -30
- 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/surveillance/algorithms/address-reuse.ts +143 -0
- package/src/surveillance/algorithms/cluster.ts +247 -0
- package/src/surveillance/algorithms/exchange.ts +295 -0
- package/src/surveillance/algorithms/temporal.ts +337 -0
- package/src/surveillance/analyzer.ts +442 -0
- package/src/surveillance/index.ts +64 -0
- package/src/surveillance/scoring.ts +372 -0
- package/src/surveillance/types.ts +264 -0
- 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-3INS3PR5.mjs +0 -884
- package/dist/chunk-3OVABDRH.mjs +0 -17096
- package/dist/chunk-DLDWZFYC.mjs +0 -1495
- package/dist/chunk-E6SZWREQ.mjs +0 -57
- package/dist/chunk-G33LB27A.mjs +0 -16166
- package/dist/chunk-HGU6HZRC.mjs +0 -231
- package/dist/chunk-L2K34JCU.mjs +0 -1496
- package/dist/chunk-SN4ZDTVW.mjs +0 -16166
- package/dist/constants-VOI7BSLK.mjs +0 -27
- 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-xbWjohNq.d.mts +0 -11390
- package/dist/solana-5EMCTPTS.mjs +0 -46
- package/dist/solana-Q4NAVBTS.mjs +0 -46
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Solana RPC Provider
|
|
3
|
+
*
|
|
4
|
+
* Uses standard Solana RPC methods, works with any RPC endpoint
|
|
5
|
+
* including self-hosted nodes. No API key required.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { GenericProvider } from '@sip-protocol/sdk'
|
|
10
|
+
* import { Connection } from '@solana/web3.js'
|
|
11
|
+
*
|
|
12
|
+
* // With existing connection
|
|
13
|
+
* const connection = new Connection('https://api.devnet.solana.com')
|
|
14
|
+
* const generic = new GenericProvider({ connection })
|
|
15
|
+
*
|
|
16
|
+
* // With endpoint string
|
|
17
|
+
* const devnet = new GenericProvider({
|
|
18
|
+
* endpoint: 'https://api.devnet.solana.com'
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* const assets = await generic.getAssetsByOwner('7xK9...')
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
Connection,
|
|
27
|
+
PublicKey,
|
|
28
|
+
} from '@solana/web3.js'
|
|
29
|
+
import {
|
|
30
|
+
TOKEN_PROGRAM_ID,
|
|
31
|
+
getAssociatedTokenAddress,
|
|
32
|
+
getAccount,
|
|
33
|
+
TokenAccountNotFoundError,
|
|
34
|
+
TokenInvalidAccountOwnerError,
|
|
35
|
+
} from '@solana/spl-token'
|
|
36
|
+
import type { SolanaRPCProvider, TokenAsset, GenericProviderConfig } from './interface'
|
|
37
|
+
import { NetworkError, ValidationError, ErrorCode } from '../../../errors'
|
|
38
|
+
import { sanitizeUrl } from '../constants'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* RPC endpoint URLs by cluster
|
|
42
|
+
*/
|
|
43
|
+
const CLUSTER_ENDPOINTS: Record<string, string> = {
|
|
44
|
+
'mainnet-beta': 'https://api.mainnet-beta.solana.com',
|
|
45
|
+
devnet: 'https://api.devnet.solana.com',
|
|
46
|
+
testnet: 'https://api.testnet.solana.com',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Validate and parse a Solana address (base58)
|
|
51
|
+
*
|
|
52
|
+
* Attempts to create a PublicKey from the address string.
|
|
53
|
+
*
|
|
54
|
+
* @param address - Solana address in base58 format
|
|
55
|
+
* @param paramName - Parameter name for error message context
|
|
56
|
+
* @returns Validated PublicKey instance
|
|
57
|
+
* @throws Error if address is invalid base58 or wrong length
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
function validateSolanaAddress(address: string, paramName: string): PublicKey {
|
|
61
|
+
try {
|
|
62
|
+
return new PublicKey(address)
|
|
63
|
+
} catch {
|
|
64
|
+
throw new ValidationError('invalid Solana address format', paramName, undefined, ErrorCode.INVALID_ADDRESS)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generic RPC Provider implementation
|
|
70
|
+
*
|
|
71
|
+
* Uses standard Solana RPC methods. Works with any RPC endpoint.
|
|
72
|
+
* Recommended for development, testing, or self-hosted nodes.
|
|
73
|
+
*/
|
|
74
|
+
export class GenericProvider implements SolanaRPCProvider {
|
|
75
|
+
readonly name = 'generic'
|
|
76
|
+
private connection: Connection
|
|
77
|
+
|
|
78
|
+
constructor(config: GenericProviderConfig) {
|
|
79
|
+
// Use provided connection or create one
|
|
80
|
+
if (config.connection) {
|
|
81
|
+
this.connection = config.connection as Connection
|
|
82
|
+
} else {
|
|
83
|
+
const endpoint = config.endpoint ?? CLUSTER_ENDPOINTS[config.cluster ?? 'mainnet-beta']
|
|
84
|
+
this.connection = new Connection(endpoint, 'confirmed')
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get all token assets owned by an address using getParsedTokenAccountsByOwner
|
|
90
|
+
*
|
|
91
|
+
* Note: This is less efficient than Helius DAS API for large wallets,
|
|
92
|
+
* but works with any RPC endpoint.
|
|
93
|
+
*/
|
|
94
|
+
async getAssetsByOwner(owner: string): Promise<TokenAsset[]> {
|
|
95
|
+
const ownerPubkey = validateSolanaAddress(owner, 'owner')
|
|
96
|
+
|
|
97
|
+
const accounts = await this.connection.getParsedTokenAccountsByOwner(
|
|
98
|
+
ownerPubkey,
|
|
99
|
+
{ programId: TOKEN_PROGRAM_ID }
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
const assets: TokenAsset[] = []
|
|
103
|
+
|
|
104
|
+
for (const { account } of accounts.value) {
|
|
105
|
+
const parsed = account.data.parsed
|
|
106
|
+
if (parsed.type !== 'account') continue
|
|
107
|
+
|
|
108
|
+
const info = parsed.info
|
|
109
|
+
const amount = BigInt(info.tokenAmount.amount)
|
|
110
|
+
|
|
111
|
+
// Skip zero balances
|
|
112
|
+
if (amount === 0n) continue
|
|
113
|
+
|
|
114
|
+
assets.push({
|
|
115
|
+
mint: info.mint,
|
|
116
|
+
amount,
|
|
117
|
+
decimals: info.tokenAmount.decimals,
|
|
118
|
+
// Generic RPC doesn't provide symbol/name, those need metadata lookup
|
|
119
|
+
symbol: undefined,
|
|
120
|
+
name: undefined,
|
|
121
|
+
logoUri: undefined,
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return assets
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get token balance for a specific mint
|
|
130
|
+
*
|
|
131
|
+
* Uses getAccount on the associated token address.
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* Get token balance for a specific mint
|
|
135
|
+
*
|
|
136
|
+
* M1 FIX: Properly differentiate between missing accounts (return 0n)
|
|
137
|
+
* and actual RPC errors (throw NetworkError)
|
|
138
|
+
*/
|
|
139
|
+
async getTokenBalance(owner: string, mint: string): Promise<bigint> {
|
|
140
|
+
// Validate addresses before trying to fetch (these errors should propagate)
|
|
141
|
+
const ownerPubkey = validateSolanaAddress(owner, 'owner')
|
|
142
|
+
const mintPubkey = validateSolanaAddress(mint, 'mint')
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const ata = await getAssociatedTokenAddress(
|
|
146
|
+
mintPubkey,
|
|
147
|
+
ownerPubkey,
|
|
148
|
+
true // allowOwnerOffCurve for PDAs
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
const account = await getAccount(this.connection, ata)
|
|
152
|
+
return account.amount
|
|
153
|
+
} catch (error) {
|
|
154
|
+
// M1 FIX: Only return 0n for "account not found" errors
|
|
155
|
+
// Throw for actual RPC/network errors
|
|
156
|
+
if (
|
|
157
|
+
error instanceof TokenAccountNotFoundError ||
|
|
158
|
+
error instanceof TokenInvalidAccountOwnerError
|
|
159
|
+
) {
|
|
160
|
+
// Account doesn't exist - this is expected, return 0n
|
|
161
|
+
return 0n
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Check for common RPC error patterns
|
|
165
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
166
|
+
if (
|
|
167
|
+
errorMessage.includes('could not find account') ||
|
|
168
|
+
errorMessage.includes('Account does not exist')
|
|
169
|
+
) {
|
|
170
|
+
return 0n
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Actual RPC/network error - throw
|
|
174
|
+
// H-2 FIX: Sanitize endpoint URL to prevent credential exposure
|
|
175
|
+
throw new NetworkError(
|
|
176
|
+
`Failed to get token balance: ${errorMessage}`,
|
|
177
|
+
undefined,
|
|
178
|
+
{ endpoint: sanitizeUrl(this.connection.rpcEndpoint) }
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Check if provider supports real-time subscriptions
|
|
185
|
+
*
|
|
186
|
+
* Generic RPC supports WebSocket subscriptions but they're not
|
|
187
|
+
* efficient for monitoring token transfers. Returns false.
|
|
188
|
+
*/
|
|
189
|
+
supportsSubscriptions(): boolean {
|
|
190
|
+
return false
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get the underlying Connection object
|
|
195
|
+
*
|
|
196
|
+
* Useful for advanced operations that need direct RPC access.
|
|
197
|
+
*/
|
|
198
|
+
getConnection(): Connection {
|
|
199
|
+
return this.connection
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helius Enhanced Transactions API Types
|
|
3
|
+
*
|
|
4
|
+
* Types for the Enhanced Transactions API which provides human-readable
|
|
5
|
+
* transaction data with token metadata enrichment.
|
|
6
|
+
*
|
|
7
|
+
* @see https://docs.helius.dev/solana-apis/enhanced-transactions
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Transaction types supported by Helius Enhanced Transactions API
|
|
12
|
+
*
|
|
13
|
+
* This is a subset of the most common types. The full list includes
|
|
14
|
+
* 200+ types covering DeFi, NFTs, and protocol-specific operations.
|
|
15
|
+
*/
|
|
16
|
+
export type EnhancedTransactionType =
|
|
17
|
+
// Common transaction types
|
|
18
|
+
| 'TRANSFER'
|
|
19
|
+
| 'SWAP'
|
|
20
|
+
| 'BURN'
|
|
21
|
+
| 'MINT'
|
|
22
|
+
// NFT operations
|
|
23
|
+
| 'NFT_SALE'
|
|
24
|
+
| 'NFT_LISTING'
|
|
25
|
+
| 'NFT_CANCEL_LISTING'
|
|
26
|
+
| 'NFT_BID'
|
|
27
|
+
| 'NFT_MINT'
|
|
28
|
+
| 'NFT_BURN'
|
|
29
|
+
| 'COMPRESSED_NFT_MINT'
|
|
30
|
+
| 'COMPRESSED_NFT_TRANSFER'
|
|
31
|
+
| 'COMPRESSED_NFT_BURN'
|
|
32
|
+
// DeFi operations
|
|
33
|
+
| 'ADD_LIQUIDITY'
|
|
34
|
+
| 'REMOVE_LIQUIDITY'
|
|
35
|
+
| 'STAKE'
|
|
36
|
+
| 'UNSTAKE'
|
|
37
|
+
| 'BORROW'
|
|
38
|
+
| 'REPAY'
|
|
39
|
+
| 'CLAIM_REWARDS'
|
|
40
|
+
// Governance
|
|
41
|
+
| 'VOTE'
|
|
42
|
+
| 'CREATE_PROPOSAL'
|
|
43
|
+
// Generic
|
|
44
|
+
| 'UNKNOWN'
|
|
45
|
+
| string // Allow for new types not yet defined
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Native SOL transfer details
|
|
49
|
+
*/
|
|
50
|
+
export interface NativeTransfer {
|
|
51
|
+
/** Sender address */
|
|
52
|
+
fromUserAccount: string
|
|
53
|
+
/** Recipient address */
|
|
54
|
+
toUserAccount: string
|
|
55
|
+
/** Amount in lamports */
|
|
56
|
+
amount: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* SPL token transfer details
|
|
61
|
+
*/
|
|
62
|
+
export interface TokenTransfer {
|
|
63
|
+
/** Sender address */
|
|
64
|
+
fromUserAccount: string
|
|
65
|
+
/** Recipient address */
|
|
66
|
+
toUserAccount: string
|
|
67
|
+
/** Sender's token account */
|
|
68
|
+
fromTokenAccount: string
|
|
69
|
+
/** Recipient's token account */
|
|
70
|
+
toTokenAccount: string
|
|
71
|
+
/** Token mint address */
|
|
72
|
+
mint: string
|
|
73
|
+
/** Amount in smallest units */
|
|
74
|
+
tokenAmount: number
|
|
75
|
+
/** Token symbol (e.g., 'USDC') */
|
|
76
|
+
tokenSymbol?: string
|
|
77
|
+
/** Token name (e.g., 'USD Coin') */
|
|
78
|
+
tokenName?: string
|
|
79
|
+
/** Token decimals */
|
|
80
|
+
decimals?: number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* NFT transfer details
|
|
85
|
+
*/
|
|
86
|
+
export interface NftTransfer {
|
|
87
|
+
/** NFT mint address */
|
|
88
|
+
mint: string
|
|
89
|
+
/** NFT name */
|
|
90
|
+
name?: string
|
|
91
|
+
/** NFT image URL */
|
|
92
|
+
imageUrl?: string
|
|
93
|
+
/** Collection name */
|
|
94
|
+
collectionName?: string
|
|
95
|
+
/** Sender address */
|
|
96
|
+
fromUserAccount: string
|
|
97
|
+
/** Recipient address */
|
|
98
|
+
toUserAccount: string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Swap event details
|
|
103
|
+
*/
|
|
104
|
+
export interface SwapEvent {
|
|
105
|
+
/** Native SOL involved in swap */
|
|
106
|
+
nativeInput?: {
|
|
107
|
+
account: string
|
|
108
|
+
amount: number
|
|
109
|
+
}
|
|
110
|
+
nativeOutput?: {
|
|
111
|
+
account: string
|
|
112
|
+
amount: number
|
|
113
|
+
}
|
|
114
|
+
/** Token inputs */
|
|
115
|
+
tokenInputs: Array<{
|
|
116
|
+
userAccount: string
|
|
117
|
+
tokenAccount: string
|
|
118
|
+
mint: string
|
|
119
|
+
rawTokenAmount: {
|
|
120
|
+
tokenAmount: string
|
|
121
|
+
decimals: number
|
|
122
|
+
}
|
|
123
|
+
}>
|
|
124
|
+
/** Token outputs */
|
|
125
|
+
tokenOutputs: Array<{
|
|
126
|
+
userAccount: string
|
|
127
|
+
tokenAccount: string
|
|
128
|
+
mint: string
|
|
129
|
+
rawTokenAmount: {
|
|
130
|
+
tokenAmount: string
|
|
131
|
+
decimals: number
|
|
132
|
+
}
|
|
133
|
+
}>
|
|
134
|
+
/** Program that executed the swap */
|
|
135
|
+
innerSwaps?: Array<{
|
|
136
|
+
programInfo: {
|
|
137
|
+
source: string
|
|
138
|
+
account: string
|
|
139
|
+
programName: string
|
|
140
|
+
instructionName: string
|
|
141
|
+
}
|
|
142
|
+
tokenInputs: Array<{
|
|
143
|
+
mint: string
|
|
144
|
+
rawTokenAmount: {
|
|
145
|
+
tokenAmount: string
|
|
146
|
+
decimals: number
|
|
147
|
+
}
|
|
148
|
+
}>
|
|
149
|
+
tokenOutputs: Array<{
|
|
150
|
+
mint: string
|
|
151
|
+
rawTokenAmount: {
|
|
152
|
+
tokenAmount: string
|
|
153
|
+
decimals: number
|
|
154
|
+
}
|
|
155
|
+
}>
|
|
156
|
+
}>
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Enhanced transaction event data
|
|
161
|
+
*/
|
|
162
|
+
export interface EnhancedTransactionEvents {
|
|
163
|
+
/** Swap events */
|
|
164
|
+
swap?: SwapEvent
|
|
165
|
+
/** NFT-specific events */
|
|
166
|
+
nft?: {
|
|
167
|
+
seller?: string
|
|
168
|
+
buyer?: string
|
|
169
|
+
nfts?: Array<{
|
|
170
|
+
mint: string
|
|
171
|
+
name?: string
|
|
172
|
+
imageUrl?: string
|
|
173
|
+
}>
|
|
174
|
+
saleType?: string
|
|
175
|
+
amount?: number
|
|
176
|
+
}
|
|
177
|
+
/** Compressed NFT events */
|
|
178
|
+
compressed?: Array<{
|
|
179
|
+
type: string
|
|
180
|
+
treeId: string
|
|
181
|
+
leafIndex: number
|
|
182
|
+
assetId: string
|
|
183
|
+
newLeafOwner?: string
|
|
184
|
+
oldLeafOwner?: string
|
|
185
|
+
}>
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Account data from enhanced transaction
|
|
190
|
+
*/
|
|
191
|
+
export interface EnhancedAccountData {
|
|
192
|
+
/** Account address */
|
|
193
|
+
account: string
|
|
194
|
+
/** Native SOL change in lamports */
|
|
195
|
+
nativeBalanceChange: number
|
|
196
|
+
/** Token balance changes */
|
|
197
|
+
tokenBalanceChanges: Array<{
|
|
198
|
+
mint: string
|
|
199
|
+
rawTokenAmount: {
|
|
200
|
+
tokenAmount: string
|
|
201
|
+
decimals: number
|
|
202
|
+
}
|
|
203
|
+
userAccount: string
|
|
204
|
+
tokenAccount: string
|
|
205
|
+
}>
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Enhanced transaction returned by parseTransaction API
|
|
210
|
+
*/
|
|
211
|
+
export interface EnhancedTransaction {
|
|
212
|
+
/** Transaction signature */
|
|
213
|
+
signature: string
|
|
214
|
+
/** Human-readable description */
|
|
215
|
+
description: string
|
|
216
|
+
/** Transaction type */
|
|
217
|
+
type: EnhancedTransactionType
|
|
218
|
+
/** Source of the transaction (program/protocol name) */
|
|
219
|
+
source: string
|
|
220
|
+
/** Fee in lamports */
|
|
221
|
+
fee: number
|
|
222
|
+
/** Fee payer address */
|
|
223
|
+
feePayer: string
|
|
224
|
+
/** Slot number */
|
|
225
|
+
slot: number
|
|
226
|
+
/** Block timestamp (Unix seconds) */
|
|
227
|
+
timestamp: number
|
|
228
|
+
/** Native SOL transfers */
|
|
229
|
+
nativeTransfers: NativeTransfer[]
|
|
230
|
+
/** SPL token transfers */
|
|
231
|
+
tokenTransfers: TokenTransfer[]
|
|
232
|
+
/** Account data with balance changes */
|
|
233
|
+
accountData: EnhancedAccountData[]
|
|
234
|
+
/** Transaction-specific events */
|
|
235
|
+
events?: EnhancedTransactionEvents
|
|
236
|
+
/** Transaction error if failed */
|
|
237
|
+
transactionError?: {
|
|
238
|
+
error: string
|
|
239
|
+
} | null
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Options for parsing transactions
|
|
244
|
+
*/
|
|
245
|
+
export interface ParseTransactionsOptions {
|
|
246
|
+
/** Transaction signatures to parse */
|
|
247
|
+
signatures: string[]
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Options for getting transaction history
|
|
252
|
+
*/
|
|
253
|
+
export interface GetTransactionHistoryOptions {
|
|
254
|
+
/** Filter by transaction type */
|
|
255
|
+
type?: EnhancedTransactionType
|
|
256
|
+
/** Limit number of results (default: 100, max: 100) */
|
|
257
|
+
limit?: number
|
|
258
|
+
/** Pagination cursor for next page */
|
|
259
|
+
before?: string
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* SIP-specific transaction metadata
|
|
264
|
+
*
|
|
265
|
+
* Extracted from memo program instructions in SIP transactions.
|
|
266
|
+
* Used for privacy-preserving display to viewing key holders.
|
|
267
|
+
*/
|
|
268
|
+
export interface SIPTransactionMetadata {
|
|
269
|
+
/** Whether this is a SIP shielded transaction */
|
|
270
|
+
isSIPTransaction: boolean
|
|
271
|
+
/** Ephemeral public key for stealth address derivation */
|
|
272
|
+
ephemeralPubKey?: string
|
|
273
|
+
/** View tag for fast scanning (1 byte) */
|
|
274
|
+
viewTag?: number
|
|
275
|
+
/** Encrypted amount (for viewing key holders only) */
|
|
276
|
+
encryptedAmount?: string
|
|
277
|
+
/** Stealth address recipient */
|
|
278
|
+
stealthAddress?: string
|
|
279
|
+
/** Token mint involved */
|
|
280
|
+
tokenMint?: string
|
|
281
|
+
/** Raw memo data */
|
|
282
|
+
rawMemo?: string
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Enhanced transaction with SIP-specific metadata
|
|
287
|
+
*/
|
|
288
|
+
export interface SIPEnhancedTransaction extends EnhancedTransaction {
|
|
289
|
+
/** SIP-specific metadata extracted from transaction */
|
|
290
|
+
sipMetadata: SIPTransactionMetadata
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Privacy-preserving display options
|
|
295
|
+
*/
|
|
296
|
+
export interface PrivacyDisplayOptions {
|
|
297
|
+
/** Viewing private key for decryption (hex) */
|
|
298
|
+
viewingPrivateKey?: string
|
|
299
|
+
/** Show amounts only to authorized viewers */
|
|
300
|
+
hideAmountsForUnauthorized?: boolean
|
|
301
|
+
/** Mask addresses for unauthorized viewers */
|
|
302
|
+
maskAddresses?: boolean
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Human-readable transaction summary
|
|
307
|
+
*
|
|
308
|
+
* Provides a clean summary for UI display while respecting privacy.
|
|
309
|
+
*/
|
|
310
|
+
export interface TransactionSummary {
|
|
311
|
+
/** Transaction signature */
|
|
312
|
+
signature: string
|
|
313
|
+
/** Human-readable title */
|
|
314
|
+
title: string
|
|
315
|
+
/** Detailed description */
|
|
316
|
+
description: string
|
|
317
|
+
/** Transaction type for categorization */
|
|
318
|
+
type: EnhancedTransactionType
|
|
319
|
+
/** Timestamp */
|
|
320
|
+
timestamp: Date
|
|
321
|
+
/** Fee in SOL */
|
|
322
|
+
feeInSol: number
|
|
323
|
+
/** Whether viewer is authorized to see full details */
|
|
324
|
+
isAuthorizedViewer: boolean
|
|
325
|
+
/** Tokens involved (with amounts if authorized) */
|
|
326
|
+
tokens: Array<{
|
|
327
|
+
symbol: string
|
|
328
|
+
name?: string
|
|
329
|
+
amount?: string // Formatted amount (hidden if not authorized)
|
|
330
|
+
direction: 'in' | 'out'
|
|
331
|
+
}>
|
|
332
|
+
/** Status */
|
|
333
|
+
status: 'success' | 'failed'
|
|
334
|
+
/** Explorer URL */
|
|
335
|
+
explorerUrl?: string
|
|
336
|
+
}
|