@orbinum/sdk 0.7.6 → 0.7.8
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/dist/index.d.mts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +77 -2
- package/dist/index.mjs +77 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,20 @@ export { base58 } from '@scure/base';
|
|
|
10
10
|
export { getPolkadotSigner } from 'polkadot-api/signer';
|
|
11
11
|
export { SignPayload, SignRaw, connectInjectedExtension, getInjectedExtensions, getPolkadotSignerFromPjs } from 'polkadot-api/pjs-signer';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Minimal JSON-RPC 2.0 over HTTP — batch transport.
|
|
15
|
+
*
|
|
16
|
+
* Substrate and EVM nodes both serve JSON-RPC over HTTP. PAPI's WebSocket
|
|
17
|
+
* transport (used by `SubstrateClient` for everything else) does not expose
|
|
18
|
+
* batch requests, so high-throughput callers (e.g. indexer backfill) use this
|
|
19
|
+
* to fetch many results in a single round-trip instead of N.
|
|
20
|
+
*/
|
|
21
|
+
/** A single JSON-RPC call: method name plus positional params. */
|
|
22
|
+
interface JsonRpcCall {
|
|
23
|
+
method: string;
|
|
24
|
+
params?: unknown[];
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
type ChainInfo = {
|
|
14
28
|
name: string;
|
|
15
29
|
version: string;
|
|
@@ -87,6 +101,7 @@ type ExtrinsicDecoder = ReturnType<typeof getExtrinsicDecoder>;
|
|
|
87
101
|
*/
|
|
88
102
|
declare class SubstrateClient {
|
|
89
103
|
private readonly _papi;
|
|
104
|
+
private readonly _httpUrl;
|
|
90
105
|
private constructor();
|
|
91
106
|
private _dynamicBuilder;
|
|
92
107
|
private _extDecoder;
|
|
@@ -100,6 +115,17 @@ declare class SubstrateClient {
|
|
|
100
115
|
* (shieldedPool_*, accountMapping_*, privacy_*, etc.).
|
|
101
116
|
*/
|
|
102
117
|
request<T>(method: string, params?: unknown[]): Promise<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Performs multiple JSON-RPC calls in a single HTTP request (batch). Results
|
|
120
|
+
* are returned in the same order as `calls`, as a typed tuple. A `null`
|
|
121
|
+
* result (or per-call error) maps to `null` in that slot — the call itself
|
|
122
|
+
* only rejects on HTTP/transport failure.
|
|
123
|
+
*
|
|
124
|
+
* Uses the HTTP RPC endpoint (derived from the WS URL); PAPI's WS transport
|
|
125
|
+
* does not expose batching. Ideal for high-throughput backfill: fetch many
|
|
126
|
+
* block hashes / blocks / storage reads in one round-trip instead of N.
|
|
127
|
+
*/
|
|
128
|
+
batchRequest<T extends unknown[]>(calls: JsonRpcCall[]): Promise<T>;
|
|
103
129
|
/**
|
|
104
130
|
* Returns basic chain information from the node.
|
|
105
131
|
* Combines `system_name`, `system_chain`, `system_properties`, and `state_getRuntimeVersion`.
|
|
@@ -627,6 +653,7 @@ interface IndexerStats {
|
|
|
627
653
|
};
|
|
628
654
|
extrinsics: {
|
|
629
655
|
total: number;
|
|
656
|
+
signed: number;
|
|
630
657
|
};
|
|
631
658
|
evm: {
|
|
632
659
|
transactions: number;
|
|
@@ -645,6 +672,19 @@ interface IndexerStats {
|
|
|
645
672
|
successful: number;
|
|
646
673
|
};
|
|
647
674
|
}
|
|
675
|
+
/** One hour-bucket of transaction activity from `/stats/activity`. */
|
|
676
|
+
interface ActivityBucket {
|
|
677
|
+
hourStartMs: number;
|
|
678
|
+
transactions: number;
|
|
679
|
+
signedExtrinsics: number;
|
|
680
|
+
evmTransactions: number;
|
|
681
|
+
}
|
|
682
|
+
/** Transaction activity bucketed per hour over the last N hours of chain time. */
|
|
683
|
+
interface IndexerActivity {
|
|
684
|
+
hours: number;
|
|
685
|
+
anchorMs: number | null;
|
|
686
|
+
buckets: ActivityBucket[];
|
|
687
|
+
}
|
|
648
688
|
/** A registered relayer stored by the indexer. */
|
|
649
689
|
interface Relayer {
|
|
650
690
|
evmAddress: string;
|
|
@@ -902,6 +942,11 @@ declare class IndexerClient {
|
|
|
902
942
|
}): Promise<PaginatedResult<IndexedSession>>;
|
|
903
943
|
/** Returns aggregated indexer statistics. */
|
|
904
944
|
getStats(): Promise<IndexerStats>;
|
|
945
|
+
/**
|
|
946
|
+
* Returns transaction activity bucketed per hour over the last `hours` hours
|
|
947
|
+
* of chain time (default 24, max 168). For sparklines / activity charts.
|
|
948
|
+
*/
|
|
949
|
+
getActivity(hours?: number): Promise<IndexerActivity>;
|
|
905
950
|
/** Returns true if the indexer health endpoint responds OK. */
|
|
906
951
|
isHealthy(): Promise<boolean>;
|
|
907
952
|
}
|
|
@@ -2124,6 +2169,14 @@ declare class OrbinumClientProvider {
|
|
|
2124
2169
|
* Waits for the client to be ready before dispatching.
|
|
2125
2170
|
*/
|
|
2126
2171
|
rpcSend<T>(method: string, params?: unknown[]): Promise<T>;
|
|
2172
|
+
/**
|
|
2173
|
+
* Sends multiple Substrate JSON-RPC calls as a single HTTP batch request.
|
|
2174
|
+
* Returns a tuple of typed results in the same order as `calls`.
|
|
2175
|
+
*/
|
|
2176
|
+
rpcBatch<T extends unknown[]>(calls: Array<{
|
|
2177
|
+
method: string;
|
|
2178
|
+
params?: unknown[];
|
|
2179
|
+
}>): Promise<T>;
|
|
2127
2180
|
/**
|
|
2128
2181
|
* Sends a single EVM JSON-RPC request and returns the typed result.
|
|
2129
2182
|
* Throws if `evmRpc` was not configured.
|
|
@@ -4394,4 +4447,4 @@ interface ExtrinsicFailedData {
|
|
|
4394
4447
|
dispatch_info: DispatchInfo;
|
|
4395
4448
|
}
|
|
4396
4449
|
|
|
4397
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
4450
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, type IndexerActivity, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,20 @@ export { base58 } from '@scure/base';
|
|
|
10
10
|
export { getPolkadotSigner } from 'polkadot-api/signer';
|
|
11
11
|
export { SignPayload, SignRaw, connectInjectedExtension, getInjectedExtensions, getPolkadotSignerFromPjs } from 'polkadot-api/pjs-signer';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Minimal JSON-RPC 2.0 over HTTP — batch transport.
|
|
15
|
+
*
|
|
16
|
+
* Substrate and EVM nodes both serve JSON-RPC over HTTP. PAPI's WebSocket
|
|
17
|
+
* transport (used by `SubstrateClient` for everything else) does not expose
|
|
18
|
+
* batch requests, so high-throughput callers (e.g. indexer backfill) use this
|
|
19
|
+
* to fetch many results in a single round-trip instead of N.
|
|
20
|
+
*/
|
|
21
|
+
/** A single JSON-RPC call: method name plus positional params. */
|
|
22
|
+
interface JsonRpcCall {
|
|
23
|
+
method: string;
|
|
24
|
+
params?: unknown[];
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
type ChainInfo = {
|
|
14
28
|
name: string;
|
|
15
29
|
version: string;
|
|
@@ -87,6 +101,7 @@ type ExtrinsicDecoder = ReturnType<typeof getExtrinsicDecoder>;
|
|
|
87
101
|
*/
|
|
88
102
|
declare class SubstrateClient {
|
|
89
103
|
private readonly _papi;
|
|
104
|
+
private readonly _httpUrl;
|
|
90
105
|
private constructor();
|
|
91
106
|
private _dynamicBuilder;
|
|
92
107
|
private _extDecoder;
|
|
@@ -100,6 +115,17 @@ declare class SubstrateClient {
|
|
|
100
115
|
* (shieldedPool_*, accountMapping_*, privacy_*, etc.).
|
|
101
116
|
*/
|
|
102
117
|
request<T>(method: string, params?: unknown[]): Promise<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Performs multiple JSON-RPC calls in a single HTTP request (batch). Results
|
|
120
|
+
* are returned in the same order as `calls`, as a typed tuple. A `null`
|
|
121
|
+
* result (or per-call error) maps to `null` in that slot — the call itself
|
|
122
|
+
* only rejects on HTTP/transport failure.
|
|
123
|
+
*
|
|
124
|
+
* Uses the HTTP RPC endpoint (derived from the WS URL); PAPI's WS transport
|
|
125
|
+
* does not expose batching. Ideal for high-throughput backfill: fetch many
|
|
126
|
+
* block hashes / blocks / storage reads in one round-trip instead of N.
|
|
127
|
+
*/
|
|
128
|
+
batchRequest<T extends unknown[]>(calls: JsonRpcCall[]): Promise<T>;
|
|
103
129
|
/**
|
|
104
130
|
* Returns basic chain information from the node.
|
|
105
131
|
* Combines `system_name`, `system_chain`, `system_properties`, and `state_getRuntimeVersion`.
|
|
@@ -627,6 +653,7 @@ interface IndexerStats {
|
|
|
627
653
|
};
|
|
628
654
|
extrinsics: {
|
|
629
655
|
total: number;
|
|
656
|
+
signed: number;
|
|
630
657
|
};
|
|
631
658
|
evm: {
|
|
632
659
|
transactions: number;
|
|
@@ -645,6 +672,19 @@ interface IndexerStats {
|
|
|
645
672
|
successful: number;
|
|
646
673
|
};
|
|
647
674
|
}
|
|
675
|
+
/** One hour-bucket of transaction activity from `/stats/activity`. */
|
|
676
|
+
interface ActivityBucket {
|
|
677
|
+
hourStartMs: number;
|
|
678
|
+
transactions: number;
|
|
679
|
+
signedExtrinsics: number;
|
|
680
|
+
evmTransactions: number;
|
|
681
|
+
}
|
|
682
|
+
/** Transaction activity bucketed per hour over the last N hours of chain time. */
|
|
683
|
+
interface IndexerActivity {
|
|
684
|
+
hours: number;
|
|
685
|
+
anchorMs: number | null;
|
|
686
|
+
buckets: ActivityBucket[];
|
|
687
|
+
}
|
|
648
688
|
/** A registered relayer stored by the indexer. */
|
|
649
689
|
interface Relayer {
|
|
650
690
|
evmAddress: string;
|
|
@@ -902,6 +942,11 @@ declare class IndexerClient {
|
|
|
902
942
|
}): Promise<PaginatedResult<IndexedSession>>;
|
|
903
943
|
/** Returns aggregated indexer statistics. */
|
|
904
944
|
getStats(): Promise<IndexerStats>;
|
|
945
|
+
/**
|
|
946
|
+
* Returns transaction activity bucketed per hour over the last `hours` hours
|
|
947
|
+
* of chain time (default 24, max 168). For sparklines / activity charts.
|
|
948
|
+
*/
|
|
949
|
+
getActivity(hours?: number): Promise<IndexerActivity>;
|
|
905
950
|
/** Returns true if the indexer health endpoint responds OK. */
|
|
906
951
|
isHealthy(): Promise<boolean>;
|
|
907
952
|
}
|
|
@@ -2124,6 +2169,14 @@ declare class OrbinumClientProvider {
|
|
|
2124
2169
|
* Waits for the client to be ready before dispatching.
|
|
2125
2170
|
*/
|
|
2126
2171
|
rpcSend<T>(method: string, params?: unknown[]): Promise<T>;
|
|
2172
|
+
/**
|
|
2173
|
+
* Sends multiple Substrate JSON-RPC calls as a single HTTP batch request.
|
|
2174
|
+
* Returns a tuple of typed results in the same order as `calls`.
|
|
2175
|
+
*/
|
|
2176
|
+
rpcBatch<T extends unknown[]>(calls: Array<{
|
|
2177
|
+
method: string;
|
|
2178
|
+
params?: unknown[];
|
|
2179
|
+
}>): Promise<T>;
|
|
2127
2180
|
/**
|
|
2128
2181
|
* Sends a single EVM JSON-RPC request and returns the typed result.
|
|
2129
2182
|
* Throws if `evmRpc` was not configured.
|
|
@@ -4394,4 +4447,4 @@ interface ExtrinsicFailedData {
|
|
|
4394
4447
|
dispatch_info: DispatchInfo;
|
|
4395
4448
|
}
|
|
4396
4449
|
|
|
4397
|
-
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
|
4450
|
+
export { type AccountListing, type AccountMappedData, type AccountMappedEvent, type AccountMappingCall, type AccountMappingEvent, AccountMappingModule, AccountMappingPrecompile, type AccountMetadata, type AccountUnmappedEvent, type ActiveVersionSetEvent, type ActivityBucket, type AddChainLinkArgs, type AddChainLinkParams, type AddSupportedChainArgs, type AliasFullIdentity, type AliasInfo, type AliasListedForSaleEvent, type AliasOnSaleData, type AliasRegisteredData, type AliasRegisteredEvent, type AliasReleasedEvent, type AliasSaleCancelledEvent, type AliasSoldData, type AliasSoldEvent, type AliasTransferredData, type AliasTransferredEvent, type AssetRegisteredEvent, type AssetUnverifiedEvent, type AssetVerifiedEvent, BABYJUB_SUBORDER, BN254_R, type BatchRegisterVerificationKeysArgs, type BatchVerificationKeysRegisteredEvent, type BlockInfo, type BuyAliasArgs, type Bytes32, type ChainInfo, type ChainLink, type ChainLinkAddedEvent, type ChainLinkRemovedEvent, CircuitId, CircuitId as CircuitIdType, type ClaimShieldedFeesParams, type ClientProviderConfig, type CommitmentsInsertedEvent, type CommitmentsInsertedEventData, type ConnectionStatus, CryptoPrecompiles, type DecodedAddChainLinkArgs, type DecodedBatchArgs, type DecodedDispatchAsPrivateLinkArgs, type DecodedEthereumTransactArgs, type DecodedEvmCallArgs, type DecodedPrecompile, type DecodedPrivateTransferArgs, type DecodedPutAliasForSaleArgs, type DecodedRegisterAliasArgs, type DecodedRemarkArgs, type DecodedRevealPrivateLinkArgs, type DecodedSetAccountMetadataArgs, type DecodedShieldArgs, type DecodedShieldBatchArgs, type DecodedShieldBatchOperation, type DecodedSudoArgs, type DecodedTransferAllArgs, type DecodedTransferArgs, type DecodedTransferKeepAliveArgs, type DecodedUnshieldArgs, type DecryptedMemo, type DispatchAsLinkedAccountArgs, type DispatchAsLinkedParams, type DispatchAsPrivateLinkArgs, type DispatchError, type DispatchInfo, type DynamicBuilder, ENCRYPTED_MEMO_SIZE, EncryptedMemo, type EncryptedNoteRecord, type EndowedEventData, type EthereumExecutedData, type EventData, type EventPhase, type EventRecord, type EvmAddressInfo, type EvmBlock, EvmClient, type EvmExecutedData, type EvmExitReason, EvmExplorer, type EvmLog, type EvmSigner, type EvmTransaction, type EvmTxRequest, type EvmTxSummary, type ExtrinsicDecoder, type ExtrinsicFailedData, type ExtrinsicSuccessData, type FeeClaimProofInputs, type FormatOptions, type IndexedBlock, type IndexedEvmTx, type IndexedExtrinsic, type IndexedSession, type IndexedValidator, type IndexerActivity, IndexerClient, type IndexerClientConfig, type IndexerStats, KNOWN_PRECOMPILES, type KnownPrecompileInfo, type ListingInfo, type MerkleRoot, type MerkleRootUpdatedData, type MerkleRootUpdatedEvent, type MerkleTreeInfo, type MetadataUpdatedEvent, NoteBuilder, type NoteDisclosure, type NoteInput, type NoteStatusUpdate, type NullifierStatusResult, type NullifiersSpentEvent, type NullifiersSpentEventData, OrbinumClient, type OrbinumClientConfig, OrbinumClientProvider, PRECOMPILE_ADDR, type PaginatedResult, PrivacyKeyManager, type PrivacyMerkleProof, PrivacyModule, type PrivateChainLinkAddedEvent, type PrivateChainLinkRemovedEvent, type PrivateChainLinkRevealedEvent, type PrivateLink, type PrivateLinkDispatchExecutedEvent, type PrivateTransferArgs, type PrivateTransferInput, type PrivateTransferOutput, type PrivateTransferParams, type PrivateTransferProofInputs, type PrivateTransferTimestamp, type ProofVerificationFailedEvent, type ProofVerifiedEvent, type ProxyCallExecutedEvent, type PutAliasOnSaleArgs, type PutOnSaleParams, type RawBlock, type RawBlockHeader, type RawTransferInput, type RawTransferOutput, type RegisterAliasArgs, type RegisterAssetArgs, type RegisterPrivateLinkArgs, type RegisterVerificationKeyArgs, type RegisteredAsset, type RelayFeeEvent, type RelayFeeSummaryEntry, type Relayer, type RelayerInfo, RelayerStatusModule, type RemoveChainLinkArgs, type RemovePrivateLinkArgs, type RemoveSupportedChainArgs, type RemoveVerificationKeyArgs, type ReservedEventData, type ResolvedAlias, type RevealPrivateLinkArgs, type RpcV2MerkleProof, type RpcV2NullifierStatus, type RpcV2PoolAssetBalance, type RpcV2PoolStats, SLIP0044_NAMESPACE, type ScanCommitment, type SetAccountMetadataArgs, type SetActiveVersionArgs, type SetMetadataParams, type ShieldArgs, type ShieldBatchArgs, type ShieldBatchItem, type ShieldBatchParams, type ShieldOperation, type ShieldParams, type ShieldedAddressEvent, type ShieldedCommitment, type ShieldedEvent, type ShieldedEventData, type ShieldedPoolCall, type ShieldedPoolEvent, ShieldedPoolModule, ShieldedPoolPrecompile, SignatureScheme, type SpentNullifier, type StatusChangeEvent, type StatusListener, type StealthScanHint, SubstrateClient, type SupportedChain, type SupportedChainAddedEvent, type SupportedChainRemovedEvent, type SystemHealth, type TokenInfo, type TokenTransfer, type TransferAliasArgs, type TransferEventData, type TransferInputNote, type TransferOutputNote, type TxResult, type UnsafeTxOptions, type Unshield, type UnshieldArgs, type UnshieldParams, type UnshieldProofInputs, type UnshieldedEvent, type UnshieldedEventData, type UnverifyAssetArgs, VaultLockedError, type VerificationKeyRegisteredEvent, type VerificationKeyRemovedEvent, type VerifyAssetArgs, type VerifyProofArgs, type VkEntry, type ZkNote, type ZkVerifierCall, type ZkVerifierCircuitVersionInfo, type ZkVerifierEvent, type ZkVerifierHistoricalVersion, ZkVerifierModule, type ZkVerifierVersionStats, type ZkVerifierVkHash, accountIdHexToSs58, addressToAccountIdHex, applyNoteStatus, bigintTo32Be, bigintTo32Le, bigintTo32LeArr, buildDummyTransferInput, bytesToBigintLE, computeNullifier, computePathIndices, createNoteDisclosureKey, decodeNoteDisclosureKey, decodePrecompileCalldata, decryptJson, decryptNoteRecord, deriveMasterKeyBytes, deriveOwnerPk, deriveSpendingKeyFromSignature, deriveSpendingKeyMessage, deriveStealthOwnerPk, deriveStealthSk, deriveVaultKey, deriveViewingPublicKey, deriveViewingSecretKey, encryptJson, encryptNote, ensureHexPrefix, evmAddressToAccountId, evmToImplicitSubstrate, evmToMappedAccountHex, evmToSubstrate, formatBalance, formatORB, fromBase64, fromHex, generateFeeClaimProof, generateTransferProof, generateUnshieldProof, getPrecompileLabel, hexToBigint, hexToNumber, implicitSubstrateToEvm, isEvmAddress, isImplicitEvmAccount, isSs58, isSubstrateAddress, isUnifiedAddress, leHexToBigint, mapExtrinsicArgs, mapZkEventData, normalizeEvmAddress, randomBlinding, recoverOwnerPkPoint, selectNotes, shortHash, substrateSs58ToAccountIdHex, substrateToEvm, toBase64, toHex, toTxResult, truncateMiddle, tryDecryptNote, tryDecryptNoteVerbose, vaultReplacer, vaultReviver };
|
package/dist/index.js
CHANGED
|
@@ -163,12 +163,59 @@ function hexToBigint(hex) {
|
|
|
163
163
|
return BigInt(hex);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// src/utils/jsonRpcHttp.ts
|
|
167
|
+
var DEFAULT_MAX_RETRIES = 5;
|
|
168
|
+
var DEFAULT_BASE_BACKOFF_MS = 250;
|
|
169
|
+
var DEFAULT_MAX_BACKOFF_MS = 4e3;
|
|
170
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
171
|
+
async function jsonRpcBatch(httpUrl, calls, options = {}) {
|
|
172
|
+
if (calls.length === 0) return [];
|
|
173
|
+
const maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
174
|
+
const baseBackoffMs = options.baseBackoffMs ?? DEFAULT_BASE_BACKOFF_MS;
|
|
175
|
+
const maxBackoffMs = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
176
|
+
const body = calls.map((c, i) => ({
|
|
177
|
+
id: i,
|
|
178
|
+
jsonrpc: "2.0",
|
|
179
|
+
method: c.method,
|
|
180
|
+
params: c.params ?? []
|
|
181
|
+
}));
|
|
182
|
+
const payload = JSON.stringify(body);
|
|
183
|
+
let attempt = 0;
|
|
184
|
+
for (; ; ) {
|
|
185
|
+
const res = await fetch(httpUrl, {
|
|
186
|
+
method: "POST",
|
|
187
|
+
headers: { "Content-Type": "application/json" },
|
|
188
|
+
body: payload
|
|
189
|
+
});
|
|
190
|
+
if (res.ok) {
|
|
191
|
+
const arr = await res.json();
|
|
192
|
+
const byId = new Map(arr.map((r) => [r.id, r]));
|
|
193
|
+
return calls.map((_, i) => byId.get(i)?.result ?? null);
|
|
194
|
+
}
|
|
195
|
+
const retryable = res.status === 429 || res.status === 503;
|
|
196
|
+
if (!retryable || attempt >= maxRetries) {
|
|
197
|
+
throw new Error(`JSON-RPC HTTP ${res.status}: ${res.statusText}`);
|
|
198
|
+
}
|
|
199
|
+
const retryAfter = Number(res.headers.get("retry-after"));
|
|
200
|
+
const delayMs = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1e3 : Math.min(baseBackoffMs * 2 ** attempt, maxBackoffMs);
|
|
201
|
+
await sleep(delayMs);
|
|
202
|
+
attempt++;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function wsUrlToHttp(wsUrl) {
|
|
206
|
+
if (wsUrl.startsWith("wss://")) return "https://" + wsUrl.slice("wss://".length);
|
|
207
|
+
if (wsUrl.startsWith("ws://")) return "http://" + wsUrl.slice("ws://".length);
|
|
208
|
+
return wsUrl;
|
|
209
|
+
}
|
|
210
|
+
|
|
166
211
|
// src/substrate/SubstrateClient.ts
|
|
167
212
|
var SubstrateClient = class _SubstrateClient {
|
|
168
|
-
constructor(_papi) {
|
|
213
|
+
constructor(_papi, _httpUrl) {
|
|
169
214
|
this._papi = _papi;
|
|
215
|
+
this._httpUrl = _httpUrl;
|
|
170
216
|
}
|
|
171
217
|
_papi;
|
|
218
|
+
_httpUrl;
|
|
172
219
|
_dynamicBuilder = null;
|
|
173
220
|
_extDecoder = null;
|
|
174
221
|
/**
|
|
@@ -187,7 +234,7 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
187
234
|
)
|
|
188
235
|
)
|
|
189
236
|
]);
|
|
190
|
-
return new _SubstrateClient(papi);
|
|
237
|
+
return new _SubstrateClient(papi, wsUrlToHttp(wsUrl));
|
|
191
238
|
}
|
|
192
239
|
/**
|
|
193
240
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
@@ -196,6 +243,19 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
196
243
|
async request(method, params = []) {
|
|
197
244
|
return this._papi._request(method, params);
|
|
198
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Performs multiple JSON-RPC calls in a single HTTP request (batch). Results
|
|
248
|
+
* are returned in the same order as `calls`, as a typed tuple. A `null`
|
|
249
|
+
* result (or per-call error) maps to `null` in that slot — the call itself
|
|
250
|
+
* only rejects on HTTP/transport failure.
|
|
251
|
+
*
|
|
252
|
+
* Uses the HTTP RPC endpoint (derived from the WS URL); PAPI's WS transport
|
|
253
|
+
* does not expose batching. Ideal for high-throughput backfill: fetch many
|
|
254
|
+
* block hashes / blocks / storage reads in one round-trip instead of N.
|
|
255
|
+
*/
|
|
256
|
+
async batchRequest(calls) {
|
|
257
|
+
return jsonRpcBatch(this._httpUrl, calls);
|
|
258
|
+
}
|
|
199
259
|
/**
|
|
200
260
|
* Returns basic chain information from the node.
|
|
201
261
|
* Combines `system_name`, `system_chain`, `system_properties`, and `state_getRuntimeVersion`.
|
|
@@ -1363,6 +1423,13 @@ var IndexerClient = class {
|
|
|
1363
1423
|
async getStats() {
|
|
1364
1424
|
return this.get("/stats");
|
|
1365
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Returns transaction activity bucketed per hour over the last `hours` hours
|
|
1428
|
+
* of chain time (default 24, max 168). For sparklines / activity charts.
|
|
1429
|
+
*/
|
|
1430
|
+
async getActivity(hours = 24) {
|
|
1431
|
+
return this.get(`/stats/activity?hours=${hours}`);
|
|
1432
|
+
}
|
|
1366
1433
|
/** Returns true if the indexer health endpoint responds OK. */
|
|
1367
1434
|
async isHealthy() {
|
|
1368
1435
|
try {
|
|
@@ -3695,6 +3762,14 @@ var OrbinumClientProvider = class {
|
|
|
3695
3762
|
const client = await this.getOrbinumClient();
|
|
3696
3763
|
return client.substrate.request(method, params);
|
|
3697
3764
|
}
|
|
3765
|
+
/**
|
|
3766
|
+
* Sends multiple Substrate JSON-RPC calls as a single HTTP batch request.
|
|
3767
|
+
* Returns a tuple of typed results in the same order as `calls`.
|
|
3768
|
+
*/
|
|
3769
|
+
async rpcBatch(calls) {
|
|
3770
|
+
const client = await this.getOrbinumClient();
|
|
3771
|
+
return client.substrate.batchRequest(calls);
|
|
3772
|
+
}
|
|
3698
3773
|
/**
|
|
3699
3774
|
* Sends a single EVM JSON-RPC request and returns the typed result.
|
|
3700
3775
|
* Throws if `evmRpc` was not configured.
|
package/dist/index.mjs
CHANGED
|
@@ -36,12 +36,59 @@ function hexToBigint(hex) {
|
|
|
36
36
|
return BigInt(hex);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// src/utils/jsonRpcHttp.ts
|
|
40
|
+
var DEFAULT_MAX_RETRIES = 5;
|
|
41
|
+
var DEFAULT_BASE_BACKOFF_MS = 250;
|
|
42
|
+
var DEFAULT_MAX_BACKOFF_MS = 4e3;
|
|
43
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
44
|
+
async function jsonRpcBatch(httpUrl, calls, options = {}) {
|
|
45
|
+
if (calls.length === 0) return [];
|
|
46
|
+
const maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
47
|
+
const baseBackoffMs = options.baseBackoffMs ?? DEFAULT_BASE_BACKOFF_MS;
|
|
48
|
+
const maxBackoffMs = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
49
|
+
const body = calls.map((c, i) => ({
|
|
50
|
+
id: i,
|
|
51
|
+
jsonrpc: "2.0",
|
|
52
|
+
method: c.method,
|
|
53
|
+
params: c.params ?? []
|
|
54
|
+
}));
|
|
55
|
+
const payload = JSON.stringify(body);
|
|
56
|
+
let attempt = 0;
|
|
57
|
+
for (; ; ) {
|
|
58
|
+
const res = await fetch(httpUrl, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/json" },
|
|
61
|
+
body: payload
|
|
62
|
+
});
|
|
63
|
+
if (res.ok) {
|
|
64
|
+
const arr = await res.json();
|
|
65
|
+
const byId = new Map(arr.map((r) => [r.id, r]));
|
|
66
|
+
return calls.map((_, i) => byId.get(i)?.result ?? null);
|
|
67
|
+
}
|
|
68
|
+
const retryable = res.status === 429 || res.status === 503;
|
|
69
|
+
if (!retryable || attempt >= maxRetries) {
|
|
70
|
+
throw new Error(`JSON-RPC HTTP ${res.status}: ${res.statusText}`);
|
|
71
|
+
}
|
|
72
|
+
const retryAfter = Number(res.headers.get("retry-after"));
|
|
73
|
+
const delayMs = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1e3 : Math.min(baseBackoffMs * 2 ** attempt, maxBackoffMs);
|
|
74
|
+
await sleep(delayMs);
|
|
75
|
+
attempt++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function wsUrlToHttp(wsUrl) {
|
|
79
|
+
if (wsUrl.startsWith("wss://")) return "https://" + wsUrl.slice("wss://".length);
|
|
80
|
+
if (wsUrl.startsWith("ws://")) return "http://" + wsUrl.slice("ws://".length);
|
|
81
|
+
return wsUrl;
|
|
82
|
+
}
|
|
83
|
+
|
|
39
84
|
// src/substrate/SubstrateClient.ts
|
|
40
85
|
var SubstrateClient = class _SubstrateClient {
|
|
41
|
-
constructor(_papi) {
|
|
86
|
+
constructor(_papi, _httpUrl) {
|
|
42
87
|
this._papi = _papi;
|
|
88
|
+
this._httpUrl = _httpUrl;
|
|
43
89
|
}
|
|
44
90
|
_papi;
|
|
91
|
+
_httpUrl;
|
|
45
92
|
_dynamicBuilder = null;
|
|
46
93
|
_extDecoder = null;
|
|
47
94
|
/**
|
|
@@ -60,7 +107,7 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
60
107
|
)
|
|
61
108
|
)
|
|
62
109
|
]);
|
|
63
|
-
return new _SubstrateClient(papi);
|
|
110
|
+
return new _SubstrateClient(papi, wsUrlToHttp(wsUrl));
|
|
64
111
|
}
|
|
65
112
|
/**
|
|
66
113
|
* Performs a raw JSON-RPC request. Use this for custom Orbinum RPCs
|
|
@@ -69,6 +116,19 @@ var SubstrateClient = class _SubstrateClient {
|
|
|
69
116
|
async request(method, params = []) {
|
|
70
117
|
return this._papi._request(method, params);
|
|
71
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Performs multiple JSON-RPC calls in a single HTTP request (batch). Results
|
|
121
|
+
* are returned in the same order as `calls`, as a typed tuple. A `null`
|
|
122
|
+
* result (or per-call error) maps to `null` in that slot — the call itself
|
|
123
|
+
* only rejects on HTTP/transport failure.
|
|
124
|
+
*
|
|
125
|
+
* Uses the HTTP RPC endpoint (derived from the WS URL); PAPI's WS transport
|
|
126
|
+
* does not expose batching. Ideal for high-throughput backfill: fetch many
|
|
127
|
+
* block hashes / blocks / storage reads in one round-trip instead of N.
|
|
128
|
+
*/
|
|
129
|
+
async batchRequest(calls) {
|
|
130
|
+
return jsonRpcBatch(this._httpUrl, calls);
|
|
131
|
+
}
|
|
72
132
|
/**
|
|
73
133
|
* Returns basic chain information from the node.
|
|
74
134
|
* Combines `system_name`, `system_chain`, `system_properties`, and `state_getRuntimeVersion`.
|
|
@@ -1236,6 +1296,13 @@ var IndexerClient = class {
|
|
|
1236
1296
|
async getStats() {
|
|
1237
1297
|
return this.get("/stats");
|
|
1238
1298
|
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Returns transaction activity bucketed per hour over the last `hours` hours
|
|
1301
|
+
* of chain time (default 24, max 168). For sparklines / activity charts.
|
|
1302
|
+
*/
|
|
1303
|
+
async getActivity(hours = 24) {
|
|
1304
|
+
return this.get(`/stats/activity?hours=${hours}`);
|
|
1305
|
+
}
|
|
1239
1306
|
/** Returns true if the indexer health endpoint responds OK. */
|
|
1240
1307
|
async isHealthy() {
|
|
1241
1308
|
try {
|
|
@@ -3568,6 +3635,14 @@ var OrbinumClientProvider = class {
|
|
|
3568
3635
|
const client = await this.getOrbinumClient();
|
|
3569
3636
|
return client.substrate.request(method, params);
|
|
3570
3637
|
}
|
|
3638
|
+
/**
|
|
3639
|
+
* Sends multiple Substrate JSON-RPC calls as a single HTTP batch request.
|
|
3640
|
+
* Returns a tuple of typed results in the same order as `calls`.
|
|
3641
|
+
*/
|
|
3642
|
+
async rpcBatch(calls) {
|
|
3643
|
+
const client = await this.getOrbinumClient();
|
|
3644
|
+
return client.substrate.batchRequest(calls);
|
|
3645
|
+
}
|
|
3571
3646
|
/**
|
|
3572
3647
|
* Sends a single EVM JSON-RPC request and returns the typed result.
|
|
3573
3648
|
* Throws if `evmRpc` was not configured.
|