@ryanrfox/sdk 0.0.2 → 2.0.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/README.md +145 -29
- package/package.json +84 -8
- package/src/_esm/actions/index.d.ts +8 -0
- package/src/_esm/actions/index.d.ts.map +1 -0
- package/src/_esm/actions/index.js +8 -0
- package/src/_esm/actions/index.js.map +1 -0
- package/src/_esm/actions/sendTransactionBatch.d.ts +77 -0
- package/src/_esm/actions/sendTransactionBatch.d.ts.map +1 -0
- package/src/_esm/actions/sendTransactionBatch.js +245 -0
- package/src/_esm/actions/sendTransactionBatch.js.map +1 -0
- package/src/_esm/chains/chainConfig.d.ts +30 -0
- package/src/_esm/chains/chainConfig.d.ts.map +1 -0
- package/src/_esm/chains/chainConfig.js +30 -0
- package/src/_esm/chains/chainConfig.js.map +1 -0
- package/src/_esm/chains/index.d.ts +4 -0
- package/src/_esm/chains/index.d.ts.map +1 -0
- package/src/_esm/chains/index.js +4 -0
- package/src/_esm/chains/index.js.map +1 -0
- package/src/_esm/chains/radius.d.ts +64 -0
- package/src/_esm/chains/radius.d.ts.map +1 -0
- package/src/_esm/chains/radius.js +39 -0
- package/src/_esm/chains/radius.js.map +1 -0
- package/src/_esm/chains/radiusTestnet.d.ts +61 -0
- package/src/_esm/chains/radiusTestnet.d.ts.map +1 -0
- package/src/_esm/chains/radiusTestnet.js +45 -0
- package/src/_esm/chains/radiusTestnet.js.map +1 -0
- package/src/_esm/decorators/index.d.ts +8 -0
- package/src/_esm/decorators/index.d.ts.map +1 -0
- package/src/_esm/decorators/index.js +8 -0
- package/src/_esm/decorators/index.js.map +1 -0
- package/src/_esm/decorators/radius.d.ts +66 -0
- package/src/_esm/decorators/radius.d.ts.map +1 -0
- package/src/_esm/decorators/radius.js +36 -0
- package/src/_esm/decorators/radius.js.map +1 -0
- package/src/_esm/errors/account.d.ts +78 -0
- package/src/_esm/errors/account.d.ts.map +1 -0
- package/src/_esm/errors/account.js +97 -0
- package/src/_esm/errors/account.js.map +1 -0
- package/src/_esm/errors/base.d.ts +56 -0
- package/src/_esm/errors/base.d.ts.map +1 -0
- package/src/_esm/errors/base.js +51 -0
- package/src/_esm/errors/base.js.map +1 -0
- package/src/_esm/errors/contract.d.ts +51 -0
- package/src/_esm/errors/contract.d.ts.map +1 -0
- package/src/_esm/errors/contract.js +65 -0
- package/src/_esm/errors/contract.js.map +1 -0
- package/src/_esm/errors/index.d.ts +63 -0
- package/src/_esm/errors/index.d.ts.map +1 -0
- package/src/_esm/errors/index.js +40 -0
- package/src/_esm/errors/index.js.map +1 -0
- package/src/_esm/errors/transaction.d.ts +132 -0
- package/src/_esm/errors/transaction.d.ts.map +1 -0
- package/src/_esm/errors/transaction.js +143 -0
- package/src/_esm/errors/transaction.js.map +1 -0
- package/src/_esm/events/decodeEventLogs.d.ts +136 -0
- package/src/_esm/events/decodeEventLogs.d.ts.map +1 -0
- package/src/_esm/events/decodeEventLogs.js +93 -0
- package/src/_esm/events/decodeEventLogs.js.map +1 -0
- package/src/_esm/events/getLogs.d.ts +137 -0
- package/src/_esm/events/getLogs.d.ts.map +1 -0
- package/src/_esm/events/getLogs.js +171 -0
- package/src/_esm/events/getLogs.js.map +1 -0
- package/src/_esm/events/index.d.ts +17 -0
- package/src/_esm/events/index.d.ts.map +1 -0
- package/src/_esm/events/index.js +24 -0
- package/src/_esm/events/index.js.map +1 -0
- package/src/_esm/events/watchApproval.d.ts +184 -0
- package/src/_esm/events/watchApproval.d.ts.map +1 -0
- package/src/_esm/events/watchApproval.js +254 -0
- package/src/_esm/events/watchApproval.js.map +1 -0
- package/src/_esm/events/watchBlock.d.ts +192 -0
- package/src/_esm/events/watchBlock.d.ts.map +1 -0
- package/src/_esm/events/watchBlock.js +162 -0
- package/src/_esm/events/watchBlock.js.map +1 -0
- package/src/_esm/events/watchLogs.d.ts +128 -0
- package/src/_esm/events/watchLogs.d.ts.map +1 -0
- package/src/_esm/events/watchLogs.js +100 -0
- package/src/_esm/events/watchLogs.js.map +1 -0
- package/src/_esm/events/watchTransfer.d.ts +164 -0
- package/src/_esm/events/watchTransfer.d.ts.map +1 -0
- package/src/_esm/events/watchTransfer.js +234 -0
- package/src/_esm/events/watchTransfer.js.map +1 -0
- package/src/_esm/index.d.ts +16 -0
- package/src/_esm/index.d.ts.map +1 -0
- package/src/_esm/index.js +22 -0
- package/src/_esm/index.js.map +1 -0
- package/src/_esm/package.json +1 -0
- package/src/_esm/transport/index.d.ts +9 -0
- package/src/_esm/transport/index.d.ts.map +1 -0
- package/src/_esm/transport/index.js +9 -0
- package/src/_esm/transport/index.js.map +1 -0
- package/src/_esm/transport/interceptor.d.ts +48 -0
- package/src/_esm/transport/interceptor.d.ts.map +1 -0
- package/src/_esm/transport/interceptor.js +209 -0
- package/src/_esm/transport/interceptor.js.map +1 -0
- package/src/_esm/transport/types.d.ts +29 -0
- package/src/_esm/transport/types.d.ts.map +1 -0
- package/src/_esm/transport/types.js +2 -0
- package/src/_esm/transport/types.js.map +1 -0
- package/src/_esm/transport/websocket.d.ts +51 -0
- package/src/_esm/transport/websocket.d.ts.map +1 -0
- package/src/_esm/transport/websocket.js +70 -0
- package/src/_esm/transport/websocket.js.map +1 -0
- package/src/_types/actions/index.d.ts +8 -0
- package/src/_types/actions/index.d.ts.map +1 -0
- package/src/_types/actions/sendTransactionBatch.d.ts +77 -0
- package/src/_types/actions/sendTransactionBatch.d.ts.map +1 -0
- package/src/_types/chains/chainConfig.d.ts +30 -0
- package/src/_types/chains/chainConfig.d.ts.map +1 -0
- package/src/_types/chains/index.d.ts +4 -0
- package/src/_types/chains/index.d.ts.map +1 -0
- package/src/_types/chains/radius.d.ts +64 -0
- package/src/_types/chains/radius.d.ts.map +1 -0
- package/src/_types/chains/radiusTestnet.d.ts +61 -0
- package/src/_types/chains/radiusTestnet.d.ts.map +1 -0
- package/src/_types/decorators/index.d.ts +8 -0
- package/src/_types/decorators/index.d.ts.map +1 -0
- package/src/_types/decorators/radius.d.ts +66 -0
- package/src/_types/decorators/radius.d.ts.map +1 -0
- package/src/_types/errors/account.d.ts +78 -0
- package/src/_types/errors/account.d.ts.map +1 -0
- package/src/_types/errors/base.d.ts +56 -0
- package/src/_types/errors/base.d.ts.map +1 -0
- package/src/_types/errors/contract.d.ts +51 -0
- package/src/_types/errors/contract.d.ts.map +1 -0
- package/src/_types/errors/index.d.ts +63 -0
- package/src/_types/errors/index.d.ts.map +1 -0
- package/src/_types/errors/transaction.d.ts +132 -0
- package/src/_types/errors/transaction.d.ts.map +1 -0
- package/src/_types/events/decodeEventLogs.d.ts +136 -0
- package/src/_types/events/decodeEventLogs.d.ts.map +1 -0
- package/src/_types/events/getLogs.d.ts +137 -0
- package/src/_types/events/getLogs.d.ts.map +1 -0
- package/src/_types/events/index.d.ts +17 -0
- package/src/_types/events/index.d.ts.map +1 -0
- package/src/_types/events/watchApproval.d.ts +184 -0
- package/src/_types/events/watchApproval.d.ts.map +1 -0
- package/src/_types/events/watchBlock.d.ts +192 -0
- package/src/_types/events/watchBlock.d.ts.map +1 -0
- package/src/_types/events/watchLogs.d.ts +128 -0
- package/src/_types/events/watchLogs.d.ts.map +1 -0
- package/src/_types/events/watchTransfer.d.ts +164 -0
- package/src/_types/events/watchTransfer.d.ts.map +1 -0
- package/src/_types/index.d.ts +16 -0
- package/src/_types/index.d.ts.map +1 -0
- package/src/_types/transport/index.d.ts +9 -0
- package/src/_types/transport/index.d.ts.map +1 -0
- package/src/_types/transport/interceptor.d.ts +48 -0
- package/src/_types/transport/interceptor.d.ts.map +1 -0
- package/src/_types/transport/types.d.ts +29 -0
- package/src/_types/transport/types.d.ts.map +1 -0
- package/src/_types/transport/websocket.d.ts +51 -0
- package/src/_types/transport/websocket.d.ts.map +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract-related errors
|
|
3
|
+
*/
|
|
4
|
+
import type { Address, Hex } from 'viem';
|
|
5
|
+
import { RadiusError, type RadiusErrorOptions } from './base';
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when a contract call fails.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ContractCallError extends RadiusError {
|
|
10
|
+
readonly name = "ContractCallError";
|
|
11
|
+
/** The contract address */
|
|
12
|
+
readonly contractAddress?: Address;
|
|
13
|
+
/** The function name that was called */
|
|
14
|
+
readonly functionName?: string;
|
|
15
|
+
/** The arguments passed to the function */
|
|
16
|
+
readonly args?: readonly unknown[];
|
|
17
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
18
|
+
contractAddress?: Address;
|
|
19
|
+
functionName?: string;
|
|
20
|
+
args?: readonly unknown[];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when contract deployment fails.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ContractDeploymentError extends RadiusError {
|
|
27
|
+
readonly name = "ContractDeploymentError";
|
|
28
|
+
/** The contract bytecode */
|
|
29
|
+
readonly bytecode?: Hex;
|
|
30
|
+
/** The constructor arguments */
|
|
31
|
+
readonly constructorArgs?: readonly unknown[];
|
|
32
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
33
|
+
bytecode?: Hex;
|
|
34
|
+
constructorArgs?: readonly unknown[];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when ABI encoding/decoding fails.
|
|
39
|
+
*/
|
|
40
|
+
export declare class AbiError extends RadiusError {
|
|
41
|
+
readonly name = "AbiError";
|
|
42
|
+
constructor(message: string, options?: RadiusErrorOptions);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when a required contract ABI is missing.
|
|
46
|
+
*/
|
|
47
|
+
export declare class MissingAbiError extends RadiusError {
|
|
48
|
+
readonly name = "MissingAbiError";
|
|
49
|
+
constructor(message?: string, options?: RadiusErrorOptions);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|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SAAQ,WAAW;IAC/C,SAAkB,IAAI,qBAAqB;gBAE/B,OAAO,SAA6B,EAAE,OAAO,GAAE,kBAAuB;CAMlF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius SDK Error Types
|
|
3
|
+
*
|
|
4
|
+
* This module provides a rich error hierarchy for better error handling
|
|
5
|
+
* and debugging. All errors extend RadiusError which provides:
|
|
6
|
+
* - Short messages for quick understanding
|
|
7
|
+
* - Detailed error information
|
|
8
|
+
* - Documentation links
|
|
9
|
+
* - Error cause chain traversal via .walk()
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import {
|
|
14
|
+
* RadiusError,
|
|
15
|
+
* TransactionFailedError,
|
|
16
|
+
* InsufficientBalanceError,
|
|
17
|
+
* } from '@radiustechsystems/sdk';
|
|
18
|
+
*
|
|
19
|
+
* try {
|
|
20
|
+
* await client.sendTransaction({ to, value });
|
|
21
|
+
* } catch (error) {
|
|
22
|
+
* if (error instanceof InsufficientBalanceError) {
|
|
23
|
+
* console.log('Not enough funds:', error.balance, 'required:', error.required);
|
|
24
|
+
* } else if (error instanceof TransactionFailedError) {
|
|
25
|
+
* console.log('Transaction failed:', error.transactionHash);
|
|
26
|
+
* } else if (error instanceof RadiusError) {
|
|
27
|
+
* console.log('SDK error:', error.shortMessage);
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export { InsufficientBalanceError, InvalidAddressError, InvalidPrivateKeyError, SignerNotFoundError, SigningError, } from './account.js';
|
|
33
|
+
export { RadiusError, type RadiusErrorOptions } from './base.js';
|
|
34
|
+
export { AbiError, ContractCallError, ContractDeploymentError, MissingAbiError, } from './contract.js';
|
|
35
|
+
export { BatchTransactionError, type BatchTransactionResult, GasEstimationError, NonceError, TransactionFailedError, TransactionRevertedError, TransactionTimeoutError, } from './transaction.js';
|
|
36
|
+
/**
|
|
37
|
+
* Error types that can be thrown by sendTransaction operations.
|
|
38
|
+
*/
|
|
39
|
+
export type SendTransactionErrorType = InsufficientBalanceError | TransactionFailedError | TransactionRevertedError | TransactionTimeoutError | SignerNotFoundError | GasEstimationError | NonceError;
|
|
40
|
+
/**
|
|
41
|
+
* Error types that can be thrown by batch transaction operations.
|
|
42
|
+
*/
|
|
43
|
+
export type BatchTransactionErrorType = BatchTransactionError | GasEstimationError | NonceError;
|
|
44
|
+
/**
|
|
45
|
+
* Error types that can be thrown by contract call operations.
|
|
46
|
+
*/
|
|
47
|
+
export type CallContractErrorType = ContractCallError | MissingAbiError | AbiError;
|
|
48
|
+
/**
|
|
49
|
+
* Error types that can be thrown by contract execution operations.
|
|
50
|
+
*/
|
|
51
|
+
export type ExecuteContractErrorType = ContractCallError | TransactionFailedError | TransactionRevertedError | SignerNotFoundError | GasEstimationError | MissingAbiError | AbiError;
|
|
52
|
+
/**
|
|
53
|
+
* Error types that can be thrown by contract deployment operations.
|
|
54
|
+
*/
|
|
55
|
+
export type DeployContractErrorType = ContractDeploymentError | TransactionFailedError | TransactionRevertedError | SignerNotFoundError | GasEstimationError | AbiError;
|
|
56
|
+
/**
|
|
57
|
+
* Error types that can be thrown by signing operations.
|
|
58
|
+
*/
|
|
59
|
+
export type SigningErrorType = SigningError | SignerNotFoundError | InvalidPrivateKeyError;
|
|
60
|
+
import type { InsufficientBalanceError, InvalidPrivateKeyError, SignerNotFoundError, SigningError } from './account.js';
|
|
61
|
+
import type { AbiError, ContractCallError, ContractDeploymentError, MissingAbiError } from './contract.js';
|
|
62
|
+
import type { BatchTransactionError, GasEstimationError, NonceError, TransactionFailedError, TransactionRevertedError, TransactionTimeoutError } from './transaction.js';
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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,uBAAuB,EACvB,eAAe,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACX,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction-related errors
|
|
3
|
+
*/
|
|
4
|
+
import type { Address, Hash, Hex } from 'viem';
|
|
5
|
+
import { RadiusError, type RadiusErrorOptions } from './base';
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when a transaction fails to execute.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* try {
|
|
12
|
+
* await walletClient.sendTransaction({ to, value });
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* if (error instanceof TransactionFailedError) {
|
|
15
|
+
* console.log('Transaction failed:', error.transactionHash);
|
|
16
|
+
* console.log('Reason:', error.shortMessage);
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class TransactionFailedError extends RadiusError {
|
|
22
|
+
readonly name = "TransactionFailedError";
|
|
23
|
+
/** The transaction hash (if available) */
|
|
24
|
+
readonly transactionHash?: Hash;
|
|
25
|
+
/** The reason for failure */
|
|
26
|
+
readonly reason?: string;
|
|
27
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
28
|
+
transactionHash?: Hash;
|
|
29
|
+
reason?: string;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when a transaction reverts on-chain.
|
|
34
|
+
*/
|
|
35
|
+
export declare class TransactionRevertedError extends RadiusError {
|
|
36
|
+
readonly name = "TransactionRevertedError";
|
|
37
|
+
/** The transaction hash (if available) */
|
|
38
|
+
readonly transactionHash?: Hash;
|
|
39
|
+
/** The reason for failure */
|
|
40
|
+
readonly reason?: string;
|
|
41
|
+
/** The revert reason (decoded if available) */
|
|
42
|
+
readonly revertReason?: string;
|
|
43
|
+
/** The raw revert data */
|
|
44
|
+
readonly revertData?: Hex;
|
|
45
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
46
|
+
transactionHash?: Hash;
|
|
47
|
+
reason?: string;
|
|
48
|
+
revertReason?: string;
|
|
49
|
+
revertData?: Hex;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Error thrown when gas estimation fails.
|
|
54
|
+
*/
|
|
55
|
+
export declare class GasEstimationError extends RadiusError {
|
|
56
|
+
readonly name = "GasEstimationError";
|
|
57
|
+
/** The address being called */
|
|
58
|
+
readonly to?: Address;
|
|
59
|
+
/** The call data */
|
|
60
|
+
readonly data?: Hex;
|
|
61
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
62
|
+
to?: Address;
|
|
63
|
+
data?: Hex;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error thrown when transaction nonce is invalid.
|
|
68
|
+
*/
|
|
69
|
+
export declare class NonceError extends RadiusError {
|
|
70
|
+
readonly name = "NonceError";
|
|
71
|
+
/** The nonce that was used */
|
|
72
|
+
readonly nonce?: number;
|
|
73
|
+
/** The expected nonce */
|
|
74
|
+
readonly expectedNonce?: number;
|
|
75
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
76
|
+
nonce?: number;
|
|
77
|
+
expectedNonce?: number;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Error thrown when a transaction times out waiting for confirmation.
|
|
82
|
+
*/
|
|
83
|
+
export declare class TransactionTimeoutError extends RadiusError {
|
|
84
|
+
readonly name = "TransactionTimeoutError";
|
|
85
|
+
/** The transaction hash */
|
|
86
|
+
readonly transactionHash?: Hash;
|
|
87
|
+
/** How long we waited (in ms) */
|
|
88
|
+
readonly timeout?: number;
|
|
89
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
90
|
+
transactionHash?: Hash;
|
|
91
|
+
timeout?: number;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Result of a single transaction in a batch.
|
|
96
|
+
*/
|
|
97
|
+
export interface BatchTransactionResult {
|
|
98
|
+
/** The index of this transaction in the batch */
|
|
99
|
+
index: number;
|
|
100
|
+
/** The transaction hash (if successful) */
|
|
101
|
+
hash?: Hash;
|
|
102
|
+
/** The error message (if failed) */
|
|
103
|
+
error?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Error thrown when one or more transactions in a batch fail.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* try {
|
|
111
|
+
* await walletClient.sendTransactionBatch({ transactions });
|
|
112
|
+
* } catch (error) {
|
|
113
|
+
* if (error instanceof BatchTransactionError) {
|
|
114
|
+
* console.log('Batch failed:', error.message);
|
|
115
|
+
* error.results.forEach((r, i) => {
|
|
116
|
+
* if (r.error) {
|
|
117
|
+
* console.log(` Transaction ${i} failed: ${r.error}`);
|
|
118
|
+
* } else {
|
|
119
|
+
* console.log(` Transaction ${i} succeeded: ${r.hash}`);
|
|
120
|
+
* }
|
|
121
|
+
* });
|
|
122
|
+
* }
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare class BatchTransactionError extends RadiusError {
|
|
127
|
+
readonly name = "BatchTransactionError";
|
|
128
|
+
/** Results for each transaction in the batch */
|
|
129
|
+
readonly results: BatchTransactionResult[];
|
|
130
|
+
constructor(message: string, results: BatchTransactionResult[], options?: RadiusErrorOptions);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../errors/transaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,IA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ACjC,OAAO,GAAE,kBAAuB;CAQjC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event log decoding utilities for Radius SDK.
|
|
3
|
+
* Provides convenient wrappers around viem's decodeEventLog.
|
|
4
|
+
*/
|
|
5
|
+
import { type Abi, type DecodeEventLogReturnType, type Log } from 'viem';
|
|
6
|
+
/**
|
|
7
|
+
* A decoded event log with the original log data preserved.
|
|
8
|
+
*/
|
|
9
|
+
export interface DecodedEventLog<TAbi extends Abi = Abi> {
|
|
10
|
+
/** The decoded event name */
|
|
11
|
+
eventName: string;
|
|
12
|
+
/** The decoded event arguments */
|
|
13
|
+
args: DecodeEventLogReturnType<TAbi>['args'];
|
|
14
|
+
/** The original raw log */
|
|
15
|
+
log: Log;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parameters for decodeEventLogs.
|
|
19
|
+
*/
|
|
20
|
+
export interface DecodeEventLogsParameters<TAbi extends Abi = Abi> {
|
|
21
|
+
/** The contract ABI containing event definitions */
|
|
22
|
+
abi: TAbi;
|
|
23
|
+
/** The logs to decode */
|
|
24
|
+
logs: Log[];
|
|
25
|
+
/** If true, skip logs that fail to decode instead of throwing (default: false) */
|
|
26
|
+
strict?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Result when strict mode is disabled and some logs fail to decode.
|
|
30
|
+
*/
|
|
31
|
+
export interface DecodeEventLogsResult<TAbi extends Abi = Abi> {
|
|
32
|
+
/** Successfully decoded logs */
|
|
33
|
+
decoded: DecodedEventLog<TAbi>[];
|
|
34
|
+
/** Logs that failed to decode (only present when strict: false) */
|
|
35
|
+
failed?: Array<{
|
|
36
|
+
log: Log;
|
|
37
|
+
error: Error;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decodes an array of event logs using the provided ABI.
|
|
42
|
+
*
|
|
43
|
+
* This is a convenience wrapper around viem's `decodeEventLog` that handles
|
|
44
|
+
* multiple logs at once and provides options for error handling.
|
|
45
|
+
*
|
|
46
|
+
* @param params - The parameters for decoding
|
|
47
|
+
* @returns Array of decoded event logs (or result object if strict: false)
|
|
48
|
+
* @throws Error if any log fails to decode and strict mode is enabled (default)
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { decodeEventLogs } from '@radiustechsystems/sdk/events';
|
|
53
|
+
*
|
|
54
|
+
* const erc20Abi = [
|
|
55
|
+
* {
|
|
56
|
+
* type: 'event',
|
|
57
|
+
* name: 'Transfer',
|
|
58
|
+
* inputs: [
|
|
59
|
+
* { indexed: true, name: 'from', type: 'address' },
|
|
60
|
+
* { indexed: true, name: 'to', type: 'address' },
|
|
61
|
+
* { indexed: false, name: 'value', type: 'uint256' },
|
|
62
|
+
* ],
|
|
63
|
+
* },
|
|
64
|
+
* ] as const;
|
|
65
|
+
*
|
|
66
|
+
* // Decode logs from a transaction receipt
|
|
67
|
+
* const decoded = decodeEventLogs({
|
|
68
|
+
* abi: erc20Abi,
|
|
69
|
+
* logs: receipt.logs,
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* for (const event of decoded) {
|
|
73
|
+
* if (event.eventName === 'Transfer') {
|
|
74
|
+
* console.log(`Transfer: ${event.args.from} -> ${event.args.to}: ${event.args.value}`);
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // With strict: false to handle mixed logs from multiple contracts
|
|
82
|
+
* const result = decodeEventLogs({
|
|
83
|
+
* abi: erc20Abi,
|
|
84
|
+
* logs: mixedLogs,
|
|
85
|
+
* strict: false,
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* console.log(`Decoded ${result.decoded.length} logs`);
|
|
89
|
+
* console.log(`Failed to decode ${result.failed?.length ?? 0} logs`);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function decodeEventLogs<TAbi extends Abi>(params: DecodeEventLogsParameters<TAbi> & {
|
|
93
|
+
strict: false;
|
|
94
|
+
}): DecodeEventLogsResult<TAbi>;
|
|
95
|
+
export declare function decodeEventLogs<TAbi extends Abi>(params: DecodeEventLogsParameters<TAbi> & {
|
|
96
|
+
strict?: true;
|
|
97
|
+
}): DecodedEventLog<TAbi>[];
|
|
98
|
+
export declare function decodeEventLogs<TAbi extends Abi>(params: DecodeEventLogsParameters<TAbi>): DecodedEventLog<TAbi>[] | DecodeEventLogsResult<TAbi>;
|
|
99
|
+
/**
|
|
100
|
+
* Parameters for filterEventLogs.
|
|
101
|
+
*/
|
|
102
|
+
export interface FilterEventLogsParameters<TAbi extends Abi = Abi, TEventName extends string = string> {
|
|
103
|
+
/** The contract ABI containing event definitions */
|
|
104
|
+
abi: TAbi;
|
|
105
|
+
/** The logs to filter and decode */
|
|
106
|
+
logs: Log[];
|
|
107
|
+
/** The event name to filter for */
|
|
108
|
+
eventName: TEventName;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Filters and decodes logs for a specific event type.
|
|
112
|
+
*
|
|
113
|
+
* This is useful when you only care about a specific event from a receipt
|
|
114
|
+
* or log array that may contain multiple event types.
|
|
115
|
+
*
|
|
116
|
+
* @param params - The parameters for filtering
|
|
117
|
+
* @returns Array of decoded logs matching the event name
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { filterEventLogs } from '@radiustechsystems/sdk/events';
|
|
122
|
+
*
|
|
123
|
+
* // Get only Transfer events from a receipt
|
|
124
|
+
* const transfers = filterEventLogs({
|
|
125
|
+
* abi: erc20Abi,
|
|
126
|
+
* logs: receipt.logs,
|
|
127
|
+
* eventName: 'Transfer',
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* for (const transfer of transfers) {
|
|
131
|
+
* console.log(`${transfer.args.from} sent ${transfer.args.value} to ${transfer.args.to}`);
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function filterEventLogs<TAbi extends Abi, TEventName extends string>(params: FilterEventLogsParameters<TAbi, TEventName>): DecodedEventLog<TAbi>[];
|
|
136
|
+
//# sourceMappingURL=decodeEventLogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decodeEventLogs.d.ts","sourceRoot":"","sources":["../../events/decodeEventLogs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,KAAK,GAAG,EAER,KAAK,wBAAwB,EAE7B,KAAK,GAAG,EACR,MAAM,MAAM,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,GAAG,GAAG,GAAG;IACtD,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,IAAI,EAAE,wBAAwB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7C,2BAA2B;IAC3B,GAAG,EAAE,GAAG,CAAC;CACT;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB,CAAC,IAAI,SAAS,GAAG,GAAG,GAAG;IAChE,oDAAoD;IACpD,GAAG,EAAE,IAAI,CAAC;IACV,yBAAyB;IACzB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,IAAI,SAAS,GAAG,GAAG,GAAG;IAC5D,gCAAgC;IAChC,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;IACjC,mEAAmE;IACnE,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,eAAe,CAAC,IAAI,SAAS,GAAG,EAC/C,MAAM,EAAE,yBAAyB,CAAC,IAAI,CAAC,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GACzD,qBAAqB,CAAC,IAAI,CAAC,CAAC;AAC/B,wBAAgB,eAAe,CAAC,IAAI,SAAS,GAAG,EAC/C,MAAM,EAAE,yBAAyB,CAAC,IAAI,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,GACzD,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;AAC3B,wBAAgB,eAAe,CAAC,IAAI,SAAS,GAAG,EAC/C,MAAM,EAAE,yBAAyB,CAAC,IAAI,CAAC,GACrC,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;AA2CzD;;GAEG;AACH,MAAM,WAAW,yBAAyB,CACzC,IAAI,SAAS,GAAG,GAAG,GAAG,EACtB,UAAU,SAAS,MAAM,GAAG,MAAM;IAElC,oDAAoD;IACpD,GAAG,EAAE,IAAI,CAAC;IACV,oCAAoC;IACpC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,mCAAmC;IACnC,SAAS,EAAE,UAAU,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,IAAI,SAAS,GAAG,EAAE,UAAU,SAAS,MAAM,EAC1E,MAAM,EAAE,yBAAyB,CAAC,IAAI,EAAE,UAAU,CAAC,GACjD,eAAe,CAAC,IAAI,CAAC,EAAE,CAiCzB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Historical log querying utilities for Radius SDK.
|
|
3
|
+
* Provides pagination helpers for eth_getLogs with Radius-specific block range handling.
|
|
4
|
+
*/
|
|
5
|
+
import type { Address, Log, PublicClient } from 'viem';
|
|
6
|
+
/**
|
|
7
|
+
* Parameters for paginated log retrieval.
|
|
8
|
+
*/
|
|
9
|
+
export interface GetLogsParams {
|
|
10
|
+
/** The contract address(es) to query logs from (required on Radius) */
|
|
11
|
+
address: Address | Address[];
|
|
12
|
+
/** Starting block number (inclusive) */
|
|
13
|
+
fromBlock: bigint;
|
|
14
|
+
/** Ending block number (inclusive) */
|
|
15
|
+
toBlock: bigint;
|
|
16
|
+
/** Maximum number of blocks to query per request (default: 1000) */
|
|
17
|
+
chunkSize?: number;
|
|
18
|
+
/** Callback invoked after each chunk is fetched (for progress tracking) */
|
|
19
|
+
onProgress?: (params: {
|
|
20
|
+
/** Current block being processed */
|
|
21
|
+
currentBlock: bigint;
|
|
22
|
+
/** Total blocks to process */
|
|
23
|
+
totalBlocks: bigint;
|
|
24
|
+
/** Number of chunks processed so far */
|
|
25
|
+
chunksProcessed: number;
|
|
26
|
+
/** Logs fetched so far */
|
|
27
|
+
logsFetched: number;
|
|
28
|
+
}) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetches historical logs from Radius with automatic pagination.
|
|
32
|
+
* Handles Radius's block range restrictions by splitting large queries into smaller chunks.
|
|
33
|
+
*
|
|
34
|
+
* @param client - The PublicClient to use
|
|
35
|
+
* @param params - Log query parameters with pagination
|
|
36
|
+
* @returns Array of all logs matching the query
|
|
37
|
+
* @throws Error if any chunk request fails
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { createPublicClient, http } from 'viem';
|
|
42
|
+
* import { getLogs } from '@radiustechsystems/sdk/events';
|
|
43
|
+
* import { radiusTestnet } from '@radiustechsystems/sdk/chains';
|
|
44
|
+
*
|
|
45
|
+
* const client = createPublicClient({
|
|
46
|
+
* chain: radiusTestnet,
|
|
47
|
+
* transport: http(),
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Fetch logs for a large block range
|
|
51
|
+
* const logs = await getLogs(client, {
|
|
52
|
+
* address: '0x...', // Contract address (required)
|
|
53
|
+
* fromBlock: 1000000n,
|
|
54
|
+
* toBlock: 1010000n, // 10,000 blocks
|
|
55
|
+
* chunkSize: 1000, // Query 1000 blocks at a time
|
|
56
|
+
* onProgress: ({ currentBlock, totalBlocks, logsFetched }) => {
|
|
57
|
+
* const percent = (Number(currentBlock) / Number(totalBlocks) * 100).toFixed(1);
|
|
58
|
+
* console.log(`Progress: ${percent}% (${logsFetched} logs)`);
|
|
59
|
+
* },
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* console.log(`Found ${logs.length} total logs`);
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* - Radius requires the address parameter (cannot query all contracts)
|
|
67
|
+
* - Radius restricts eth_getLogs to narrow block ranges
|
|
68
|
+
* - This function automatically splits large queries into smaller chunks
|
|
69
|
+
* - Default chunk size is 1000 blocks (adjust based on your needs)
|
|
70
|
+
* - If you get "block range is too wide" errors, reduce chunkSize
|
|
71
|
+
* - Progress callback is optional but useful for long-running queries
|
|
72
|
+
* - All requests are sequential to avoid rate limiting
|
|
73
|
+
* - Consider using WebSocket subscriptions for real-time monitoring instead
|
|
74
|
+
*/
|
|
75
|
+
export declare function getLogs(client: PublicClient, params: GetLogsParams): Promise<Log[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Parameters for fetching logs with automatic chunk size detection.
|
|
78
|
+
*/
|
|
79
|
+
export interface GetLogsAdaptiveParams {
|
|
80
|
+
/** The contract address(es) to query logs from (required on Radius) */
|
|
81
|
+
address: Address | Address[];
|
|
82
|
+
/** Starting block number (inclusive) */
|
|
83
|
+
fromBlock: bigint;
|
|
84
|
+
/** Ending block number (inclusive) */
|
|
85
|
+
toBlock: bigint;
|
|
86
|
+
/** Initial chunk size to try (default: 1000) */
|
|
87
|
+
initialChunkSize?: number;
|
|
88
|
+
/** Minimum chunk size (default: 10) */
|
|
89
|
+
minChunkSize?: number;
|
|
90
|
+
/** Callback invoked after each chunk is fetched (for progress tracking) */
|
|
91
|
+
onProgress?: (params: {
|
|
92
|
+
currentBlock: bigint;
|
|
93
|
+
totalBlocks: bigint;
|
|
94
|
+
chunksProcessed: number;
|
|
95
|
+
logsFetched: number;
|
|
96
|
+
currentChunkSize: number;
|
|
97
|
+
}) => void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Fetches historical logs with adaptive chunk sizing.
|
|
101
|
+
* Automatically reduces chunk size if "block range too wide" errors occur.
|
|
102
|
+
*
|
|
103
|
+
* @param client - The PublicClient to use
|
|
104
|
+
* @param params - Log query parameters with adaptive sizing
|
|
105
|
+
* @returns Array of all logs matching the query
|
|
106
|
+
* @throws Error if minimum chunk size is reached or other errors occur
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* import { createPublicClient, http } from 'viem';
|
|
111
|
+
* import { getLogsAdaptive } from '@radiustechsystems/sdk/events';
|
|
112
|
+
* import { radiusTestnet } from '@radiustechsystems/sdk/chains';
|
|
113
|
+
*
|
|
114
|
+
* const client = createPublicClient({
|
|
115
|
+
* chain: radiusTestnet,
|
|
116
|
+
* transport: http(),
|
|
117
|
+
* });
|
|
118
|
+
*
|
|
119
|
+
* // Fetch logs with automatic chunk size adjustment
|
|
120
|
+
* const logs = await getLogsAdaptive(client, {
|
|
121
|
+
* address: '0x...',
|
|
122
|
+
* fromBlock: 1000000n,
|
|
123
|
+
* toBlock: 1010000n,
|
|
124
|
+
* onProgress: ({ currentBlock, totalBlocks, currentChunkSize }) => {
|
|
125
|
+
* console.log(`Block ${currentBlock}/${totalBlocks} (chunk: ${currentChunkSize})`);
|
|
126
|
+
* },
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* - Starts with a large chunk size and reduces it if errors occur
|
|
132
|
+
* - Useful when you don't know the optimal chunk size for a network
|
|
133
|
+
* - Slower than getLogs with a known good chunk size
|
|
134
|
+
* - Use getLogs directly if you know a reliable chunk size
|
|
135
|
+
*/
|
|
136
|
+
export declare function getLogsAdaptive(client: PublicClient, params: GetLogsAdaptiveParams): Promise<Log[]>;
|
|
137
|
+
//# sourceMappingURL=getLogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLogs.d.ts","sourceRoot":"","sources":["../../events/getLogs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,OAAO,EAAqB,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,uEAAuE;IACvE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAC7B,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QACrB,oCAAoC;QACpC,YAAY,EAAE,MAAM,CAAC;QACrB,8BAA8B;QAC9B,WAAW,EAAE,MAAM,CAAC;QACpB,wCAAwC;QACxC,eAAe,EAAE,MAAM,CAAC;QACxB,0BAA0B;QAC1B,WAAW,EAAE,MAAM,CAAC;KACpB,KAAK,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAgEzF;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,uEAAuE;IACvE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAC7B,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,MAAM,CAAC;KACzB,KAAK,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,qBAAqB,GAC3B,OAAO,CAAC,GAAG,EAAE,CAAC,CA8ChB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event subscription and log querying utilities for Radius SDK.
|
|
3
|
+
*
|
|
4
|
+
* This module provides WebSocket-based event subscriptions and historical log queries
|
|
5
|
+
* with Radius-specific optimizations and limitations handling.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module events
|
|
9
|
+
*/
|
|
10
|
+
export { createWebSocketTransport, type WebSocketTransportConfig, } from '../transport/websocket.js';
|
|
11
|
+
export { type DecodedEventLog, type DecodeEventLogsParameters, type DecodeEventLogsResult, decodeEventLogs, type FilterEventLogsParameters, filterEventLogs, } from './decodeEventLogs.js';
|
|
12
|
+
export { type GetLogsAdaptiveParams, type GetLogsParams, getLogs, getLogsAdaptive, } from './getLogs.js';
|
|
13
|
+
export { type ApprovalEvent, type WatchApprovalForAddressParameters, type WatchApprovalParameters, watchApproval, watchApprovalForAddress, } from './watchApproval.js';
|
|
14
|
+
export { DEFAULT_POLLING_INTERVAL_MS, type WatchBlockNumberParams, type WatchBlocksParams, type WatchPendingTransactionsParams, watchBlockNumber, watchBlocks, watchPendingTransactions, } from './watchBlock.js';
|
|
15
|
+
export { type WatchRawLogsParameters, watchLogs, watchRawLogs, } from './watchLogs.js';
|
|
16
|
+
export { type TransferEvent, type WatchTransferForAddressParameters, type WatchTransferParameters, watchTransfer, watchTransferForAddress, } from './watchTransfer.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../events/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACN,wBAAwB,EACxB,KAAK,wBAAwB,GAC7B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,eAAe,EACf,KAAK,yBAAyB,EAC9B,eAAe,GACf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,OAAO,EACP,eAAe,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,EAC5B,aAAa,EACb,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACN,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,EACnC,gBAAgB,EAChB,WAAW,EACX,wBAAwB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACN,KAAK,sBAAsB,EAC3B,SAAS,EACT,YAAY,GACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,EAC5B,aAAa,EACb,uBAAuB,GACvB,MAAM,oBAAoB,CAAC"}
|