@ryanrfox/sdk 0.0.2 → 2.0.3
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
|
+
* WebSocket transport for Radius SDK.
|
|
3
|
+
* Provides a wrapper around viem's WebSocket transport with Radius-specific configuration.
|
|
4
|
+
*/
|
|
5
|
+
import { type Chain, type Transport } from 'viem';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for creating a WebSocket transport.
|
|
8
|
+
*/
|
|
9
|
+
export interface WebSocketTransportConfig {
|
|
10
|
+
/** The WebSocket URL (defaults to chain's WebSocket RPC URL) */
|
|
11
|
+
url?: string;
|
|
12
|
+
/** Maximum number of reconnection attempts (defaults to 3) */
|
|
13
|
+
reconnectAttempts?: number;
|
|
14
|
+
/** Reconnection delay in milliseconds (defaults to 1000) */
|
|
15
|
+
reconnectDelay?: number;
|
|
16
|
+
/** Keep-alive interval in milliseconds (optional) */
|
|
17
|
+
keepAlive?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a WebSocket transport for use with Radius clients.
|
|
21
|
+
* Uses viem's webSocket transport under the hood with Radius-specific defaults.
|
|
22
|
+
*
|
|
23
|
+
* @param chain - The chain configuration (used to determine default WebSocket URL)
|
|
24
|
+
* @param config - Optional configuration for the WebSocket transport
|
|
25
|
+
* @returns A viem Transport configured for WebSocket connections
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { createPublicClient } from 'viem';
|
|
30
|
+
* import { createWebSocketTransport } from '@radiustechsystems/sdk/transport';
|
|
31
|
+
* import { radiusTestnet } from '@radiustechsystems/sdk/chains';
|
|
32
|
+
*
|
|
33
|
+
* const transport = createWebSocketTransport(radiusTestnet, {
|
|
34
|
+
* reconnectAttempts: 5,
|
|
35
|
+
* reconnectDelay: 2000,
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* const client = createPublicClient({
|
|
39
|
+
* chain: radiusTestnet,
|
|
40
|
+
* transport,
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - The default WebSocket URL is derived from the chain configuration
|
|
46
|
+
* - For Radius Testnet, the default is: wss://rpc.testnet.radiustech.xyz
|
|
47
|
+
* - WebSocket connections are automatically managed by viem
|
|
48
|
+
* - Subscriptions are cleaned up automatically on disconnect
|
|
49
|
+
*/
|
|
50
|
+
export declare function createWebSocketTransport(chain: Chain, config?: WebSocketTransportConfig): Transport;
|
|
51
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../transport/websocket.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAa,MAAM,MAAM,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,wBAAwB,GAC/B,SAAS,CAiCX"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket transport for Radius SDK.
|
|
3
|
+
* Provides a wrapper around viem's WebSocket transport with Radius-specific configuration.
|
|
4
|
+
*/
|
|
5
|
+
import { webSocket } from 'viem';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a WebSocket transport for use with Radius clients.
|
|
8
|
+
* Uses viem's webSocket transport under the hood with Radius-specific defaults.
|
|
9
|
+
*
|
|
10
|
+
* @param chain - The chain configuration (used to determine default WebSocket URL)
|
|
11
|
+
* @param config - Optional configuration for the WebSocket transport
|
|
12
|
+
* @returns A viem Transport configured for WebSocket connections
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { createPublicClient } from 'viem';
|
|
17
|
+
* import { createWebSocketTransport } from '@radiustechsystems/sdk/transport';
|
|
18
|
+
* import { radiusTestnet } from '@radiustechsystems/sdk/chains';
|
|
19
|
+
*
|
|
20
|
+
* const transport = createWebSocketTransport(radiusTestnet, {
|
|
21
|
+
* reconnectAttempts: 5,
|
|
22
|
+
* reconnectDelay: 2000,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const client = createPublicClient({
|
|
26
|
+
* chain: radiusTestnet,
|
|
27
|
+
* transport,
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - The default WebSocket URL is derived from the chain configuration
|
|
33
|
+
* - For Radius Testnet, the default is: wss://rpc.testnet.radiustech.xyz
|
|
34
|
+
* - WebSocket connections are automatically managed by viem
|
|
35
|
+
* - Subscriptions are cleaned up automatically on disconnect
|
|
36
|
+
*/
|
|
37
|
+
export function createWebSocketTransport(chain, config) {
|
|
38
|
+
// Determine WebSocket URL
|
|
39
|
+
let wsUrl = config?.url;
|
|
40
|
+
if (!wsUrl) {
|
|
41
|
+
// Try to get WebSocket URL from chain config
|
|
42
|
+
const chainWsUrl = chain.rpcUrls.default.webSocket?.[0];
|
|
43
|
+
if (chainWsUrl) {
|
|
44
|
+
wsUrl = chainWsUrl;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Fallback: convert HTTP URL to WebSocket URL
|
|
48
|
+
const httpUrl = chain.rpcUrls.default.http[0];
|
|
49
|
+
if (!httpUrl) {
|
|
50
|
+
throw new Error('No RPC URL configured for chain');
|
|
51
|
+
}
|
|
52
|
+
// Simple http(s) -> ws(s) conversion
|
|
53
|
+
wsUrl = httpUrl.replace(/^http/, 'ws');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Create viem WebSocket transport with configuration
|
|
57
|
+
return webSocket(wsUrl, {
|
|
58
|
+
// Viem's webSocket transport accepts these options
|
|
59
|
+
reconnect: {
|
|
60
|
+
attempts: config?.reconnectAttempts ?? 3,
|
|
61
|
+
delay: config?.reconnectDelay ?? 1000,
|
|
62
|
+
},
|
|
63
|
+
keepAlive: config?.keepAlive
|
|
64
|
+
? {
|
|
65
|
+
interval: config.keepAlive,
|
|
66
|
+
}
|
|
67
|
+
: false,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=websocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../transport/websocket.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA8B,SAAS,EAAE,MAAM,MAAM,CAAC;AAgB7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,wBAAwB,CACvC,KAAY,EACZ,MAAiC;IAEjC,0BAA0B;IAC1B,IAAI,KAAK,GAAG,MAAM,EAAE,GAAG,CAAC;IAExB,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,6CAA6C;QAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QACxD,IAAI,UAAU,EAAE,CAAC;YAChB,KAAK,GAAG,UAAU,CAAC;QACpB,CAAC;aAAM,CAAC;YACP,8CAA8C;YAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACpD,CAAC;YACD,qCAAqC;YACrC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;IAED,qDAAqD;IACrD,OAAO,SAAS,CAAC,KAAK,EAAE;QACvB,mDAAmD;QACnD,SAAS,EAAE;YACV,QAAQ,EAAE,MAAM,EAAE,iBAAiB,IAAI,CAAC;YACxC,KAAK,EAAE,MAAM,EAAE,cAAc,IAAI,IAAI;SACrC;QACD,SAAS,EAAE,MAAM,EAAE,SAAS;YAC3B,CAAC,CAAC;gBACA,QAAQ,EAAE,MAAM,CAAC,SAAS;aAC1B;YACF,CAAC,CAAC,KAAK;KACR,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius SDK Actions
|
|
3
|
+
*
|
|
4
|
+
* Standalone action functions that can be used with viem clients.
|
|
5
|
+
* These follow viem's action pattern and are composed into decorators.
|
|
6
|
+
*/
|
|
7
|
+
export { type SendTransactionBatchParameters, type SendTransactionBatchReturnType, sendTransactionBatch, } from './sendTransactionBatch.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,oBAAoB,GACpB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sendTransactionBatch action - sends multiple transactions in a single JSON-RPC batch request.
|
|
3
|
+
*
|
|
4
|
+
* Radius does not queue future-nonce transactions like Ethereum. This action ensures
|
|
5
|
+
* all transactions arrive in nonce order by using JSON-RPC batching.
|
|
6
|
+
*/
|
|
7
|
+
import type { Account, Address, Chain, Client, Hash, Hex, Transport } from 'viem';
|
|
8
|
+
/** Default maximum number of transactions in a single batch */
|
|
9
|
+
export declare const DEFAULT_MAX_BATCH_SIZE = 100;
|
|
10
|
+
/** Default timeout for batch fetch requests in milliseconds (30 seconds) */
|
|
11
|
+
export declare const DEFAULT_BATCH_TIMEOUT = 30000;
|
|
12
|
+
/**
|
|
13
|
+
* Transaction request for batch submission.
|
|
14
|
+
*/
|
|
15
|
+
export interface SendTransactionBatchParameters {
|
|
16
|
+
/** Array of transactions to send in the batch */
|
|
17
|
+
transactions: Array<{
|
|
18
|
+
/** The recipient address */
|
|
19
|
+
to: Address;
|
|
20
|
+
/** The amount to send in wei (default: 0n) */
|
|
21
|
+
value?: bigint;
|
|
22
|
+
/** The transaction data (for contract calls) */
|
|
23
|
+
data?: Hex;
|
|
24
|
+
/** Gas limit (if not provided, will be estimated) */
|
|
25
|
+
gas?: bigint;
|
|
26
|
+
}>;
|
|
27
|
+
/** Maximum number of transactions allowed in the batch (default: 100) */
|
|
28
|
+
maxBatchSize?: number;
|
|
29
|
+
/** Timeout in milliseconds for the batch fetch request (default: 30000) */
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Return type for sendTransactionBatch action.
|
|
34
|
+
*/
|
|
35
|
+
export type SendTransactionBatchReturnType = Hash[];
|
|
36
|
+
/**
|
|
37
|
+
* Send multiple transactions in a single JSON-RPC batch request.
|
|
38
|
+
* Transactions are automatically assigned sequential nonces and sent atomically.
|
|
39
|
+
*
|
|
40
|
+
* @param client - The viem client (must have an account attached)
|
|
41
|
+
* @param params - The batch transaction parameters
|
|
42
|
+
* @param params.transactions - Array of transaction objects to send
|
|
43
|
+
* @param params.maxBatchSize - Maximum batch size (default: 100)
|
|
44
|
+
* @param params.timeout - Fetch timeout in milliseconds (default: 30000)
|
|
45
|
+
* @returns Array of transaction hashes in the same order as input
|
|
46
|
+
* @throws {BatchTransactionError} If any transaction in the batch fails
|
|
47
|
+
* @throws {GasEstimationError} If gas estimation fails for any transaction
|
|
48
|
+
* @throws {RadiusError} If input validation fails, HTTP request fails, or request times out
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* **Transport Note:** This function uses a direct `fetch()` call rather than
|
|
52
|
+
* the client's configured transport. Custom transport interceptors, retry logic,
|
|
53
|
+
* or middleware will not be applied to batch requests. This is necessary because
|
|
54
|
+
* viem's transport layer does not expose batch JSON-RPC capabilities.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { createWalletClient, http } from 'viem';
|
|
59
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
60
|
+
* import { radiusTestnet, radiusWalletActions } from '@radiustechsystems/sdk';
|
|
61
|
+
*
|
|
62
|
+
* const client = createWalletClient({
|
|
63
|
+
* account: privateKeyToAccount('0x...'),
|
|
64
|
+
* chain: radiusTestnet,
|
|
65
|
+
* transport: http(),
|
|
66
|
+
* }).extend(radiusWalletActions());
|
|
67
|
+
*
|
|
68
|
+
* const hashes = await client.sendTransactionBatch({
|
|
69
|
+
* transactions: [
|
|
70
|
+
* { to: '0x...', value: 1000000000000000000n },
|
|
71
|
+
* { to: '0x...', data: '0x...' },
|
|
72
|
+
* ],
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function sendTransactionBatch<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, params: SendTransactionBatchParameters): Promise<SendTransactionBatchReturnType>;
|
|
77
|
+
//# sourceMappingURL=sendTransactionBatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendTransactionBatch.d.ts","sourceRoot":"","sources":["../../actions/sendTransactionBatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AASlF,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C,iDAAiD;IACjD,YAAY,EAAE,KAAK,CAAC;QACnB,4BAA4B;QAC5B,EAAE,EAAE,OAAO,CAAC;QACZ,8CAA8C;QAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gDAAgD;QAChD,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,qDAAqD;QACrD,GAAG,CAAC,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;IACH,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,IAAI,EAAE,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,oBAAoB,CACzC,KAAK,SAAS,KAAK,GAAG,SAAS,EAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,EAEnC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,MAAM,EAAE,8BAA8B,GACpC,OAAO,CAAC,8BAA8B,CAAC,CAgNzC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared chain configuration constants for Radius.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Maximum gas limit for transactions on Radius.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: This constant is required because:
|
|
8
|
+
* - Radius returns gasLimit: 0 for all blocks (intentionally)
|
|
9
|
+
* - This differs from Ethereum where block.gasLimit is ~30,000,000
|
|
10
|
+
* - Dynamic fetching from blocks is not possible
|
|
11
|
+
*
|
|
12
|
+
* This value (0x13333333332) is a Radius protocol constant used to:
|
|
13
|
+
* 1. Cap gas estimates to prevent unexpectedly high values
|
|
14
|
+
* 2. Provide a safety bound for transaction gas limits
|
|
15
|
+
*
|
|
16
|
+
* Similar to how Arbitrum and zkSync SDKs use custom gas handling
|
|
17
|
+
* rather than relying on block.gasLimit.
|
|
18
|
+
*
|
|
19
|
+
* @see _research/sdk-walkthrough/GASLIMIT-ECOSYSTEM.md for full ecosystem impact analysis
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { MAX_GAS } from '@radiustechsystems/sdk';
|
|
24
|
+
*
|
|
25
|
+
* // Cap gas estimate at MAX_GAS
|
|
26
|
+
* const cappedGas = estimatedGas > MAX_GAS ? MAX_GAS : estimatedGas;
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const MAX_GAS = 1319413953330n;
|
|
30
|
+
//# sourceMappingURL=chainConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chainConfig.d.ts","sourceRoot":"","sources":["../../chains/chainConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,OAAO,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../chains/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius Mainnet chain configuration.
|
|
3
|
+
*
|
|
4
|
+
* Chain ID: 723
|
|
5
|
+
* RPC: https://rpc.radiustech.xyz
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { radius } from '@radiustechsystems/sdk/chains';
|
|
10
|
+
*
|
|
11
|
+
* const client = createPublicClient({
|
|
12
|
+
* chain: radius,
|
|
13
|
+
* transport: http(),
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const radius: {
|
|
18
|
+
blockExplorers: {
|
|
19
|
+
readonly default: {
|
|
20
|
+
readonly name: "Radius Explorer";
|
|
21
|
+
readonly url: "https://explorer.radiustech.xyz";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
blockTime?: number | undefined | undefined;
|
|
25
|
+
contracts?: {
|
|
26
|
+
[x: string]: import("viem").ChainContract | {
|
|
27
|
+
[sourceId: number]: import("viem").ChainContract | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
ensRegistry?: import("viem").ChainContract | undefined;
|
|
30
|
+
ensUniversalResolver?: import("viem").ChainContract | undefined;
|
|
31
|
+
multicall3?: import("viem").ChainContract | undefined;
|
|
32
|
+
erc6492Verifier?: import("viem").ChainContract | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
ensTlds?: readonly string[] | undefined;
|
|
35
|
+
id: 723;
|
|
36
|
+
name: "Radius";
|
|
37
|
+
nativeCurrency: {
|
|
38
|
+
readonly decimals: 18;
|
|
39
|
+
readonly name: "USD";
|
|
40
|
+
readonly symbol: "USD";
|
|
41
|
+
};
|
|
42
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
43
|
+
rpcUrls: {
|
|
44
|
+
readonly default: {
|
|
45
|
+
readonly http: readonly ["https://rpc.radiustech.xyz"];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
sourceId?: number | undefined | undefined;
|
|
49
|
+
testnet: false;
|
|
50
|
+
custom?: Record<string, unknown> | undefined;
|
|
51
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
52
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
53
|
+
formatters?: undefined;
|
|
54
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
55
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
56
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
57
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
58
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
59
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
60
|
+
}] | undefined;
|
|
61
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
62
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=radius.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radius.d.ts","sourceRoot":"","sources":["../../chains/radius.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBjB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius Testnet chain configuration.
|
|
3
|
+
*
|
|
4
|
+
* Chain ID: 1223953 (0x12ad11)
|
|
5
|
+
* RPC: https://rpc.testnet.radiustech.xyz
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { radiusTestnet } from '@radiustechsystems/sdk/chains';
|
|
10
|
+
*
|
|
11
|
+
* const client = createPublicClient({
|
|
12
|
+
* chain: radiusTestnet,
|
|
13
|
+
* transport: http(),
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const radiusTestnet: {
|
|
18
|
+
blockExplorers: {
|
|
19
|
+
readonly default: {
|
|
20
|
+
readonly name: "Radius Explorer";
|
|
21
|
+
readonly url: "https://explorer.testnet.radiustech.xyz";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
blockTime?: number | undefined | undefined;
|
|
25
|
+
contracts: {
|
|
26
|
+
readonly multicall3: {
|
|
27
|
+
readonly address: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
28
|
+
readonly blockCreated: 1768594222351;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
ensTlds?: readonly string[] | undefined;
|
|
32
|
+
id: 1223953;
|
|
33
|
+
name: "Radius Testnet";
|
|
34
|
+
nativeCurrency: {
|
|
35
|
+
readonly decimals: 18;
|
|
36
|
+
readonly name: "USD";
|
|
37
|
+
readonly symbol: "USD";
|
|
38
|
+
};
|
|
39
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
40
|
+
rpcUrls: {
|
|
41
|
+
readonly default: {
|
|
42
|
+
readonly http: readonly ["https://rpc.testnet.radiustech.xyz"];
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
sourceId?: number | undefined | undefined;
|
|
46
|
+
testnet: true;
|
|
47
|
+
custom?: Record<string, unknown> | undefined;
|
|
48
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
49
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
50
|
+
formatters?: undefined;
|
|
51
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
52
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
53
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
54
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
55
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
56
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
57
|
+
}] | undefined;
|
|
58
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
59
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=radiusTestnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radiusTestnet.d.ts","sourceRoot":"","sources":["../../chains/radiusTestnet.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BxB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius SDK Decorators
|
|
3
|
+
*
|
|
4
|
+
* Client decorators that extend viem clients with Radius-specific functionality.
|
|
5
|
+
* Follows viem's decorator pattern for composition.
|
|
6
|
+
*/
|
|
7
|
+
export { type RadiusWalletActions, radiusWalletActions } from './radius.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius wallet actions decorator.
|
|
3
|
+
*
|
|
4
|
+
* Extends viem wallet clients with Radius-specific functionality.
|
|
5
|
+
* Follows viem's decorator pattern (see: viem/src/zksync/decorators/walletL2.ts)
|
|
6
|
+
*/
|
|
7
|
+
import type { Account, Chain, Client, Transport } from 'viem';
|
|
8
|
+
import { type SendTransactionBatchParameters, type SendTransactionBatchReturnType } from '../actions/sendTransactionBatch.js';
|
|
9
|
+
/**
|
|
10
|
+
* Radius-specific wallet actions added by the radiusWalletActions decorator.
|
|
11
|
+
*/
|
|
12
|
+
export type RadiusWalletActions<_chain extends Chain | undefined = Chain | undefined, _account extends Account | undefined = Account | undefined> = {
|
|
13
|
+
/**
|
|
14
|
+
* Send multiple transactions in a single JSON-RPC batch request.
|
|
15
|
+
* Transactions are automatically assigned sequential nonces and sent atomically.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Radius does not queue future-nonce transactions like Ethereum.
|
|
19
|
+
* This method ensures all transactions arrive in nonce order by using JSON-RPC batching.
|
|
20
|
+
*
|
|
21
|
+
* @param params - The batch transaction parameters
|
|
22
|
+
* @returns Array of transaction hashes in the same order as input
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const hashes = await client.sendTransactionBatch({
|
|
27
|
+
* transactions: [
|
|
28
|
+
* { to: '0x...', value: 1000000000000000000n },
|
|
29
|
+
* { to: '0x...', data: '0x...' },
|
|
30
|
+
* ],
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
sendTransactionBatch: (params: SendTransactionBatchParameters) => Promise<SendTransactionBatchReturnType>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Decorator that extends a viem wallet client with Radius-specific actions.
|
|
38
|
+
*
|
|
39
|
+
* @returns A decorator function that adds Radius wallet actions to a client
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import { createWalletClient, http } from 'viem';
|
|
44
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
45
|
+
* import { radiusTestnet, radiusWalletActions } from '@radiustechsystems/sdk';
|
|
46
|
+
*
|
|
47
|
+
* const client = createWalletClient({
|
|
48
|
+
* account: privateKeyToAccount('0x...'),
|
|
49
|
+
* chain: radiusTestnet,
|
|
50
|
+
* transport: http(),
|
|
51
|
+
* }).extend(radiusWalletActions());
|
|
52
|
+
*
|
|
53
|
+
* // Standard viem for simple operations
|
|
54
|
+
* const hash = await client.sendTransaction({ to, value });
|
|
55
|
+
*
|
|
56
|
+
* // Radius-specific for batching
|
|
57
|
+
* const hashes = await client.sendTransactionBatch({
|
|
58
|
+
* transactions: [
|
|
59
|
+
* { to: addr1, value: 1n },
|
|
60
|
+
* { to: addr2, value: 2n },
|
|
61
|
+
* ],
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function radiusWalletActions(): <transport extends Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined>(client: Client<transport, chain, account>) => RadiusWalletActions<chain, account>;
|
|
66
|
+
//# sourceMappingURL=radius.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radius.d.ts","sourceRoot":"","sources":["../../decorators/radius.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,EACN,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EAEnC,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAC9B,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACvD;IACH;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,oBAAoB,EAAE,CACrB,MAAM,EAAE,8BAA8B,KAClC,OAAO,CAAC,8BAA8B,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,mBAAmB,KAEjC,SAAS,SAAS,SAAS,EAC3B,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EAEzD,QAAQ,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,KACvC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAGtC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account and signer-related errors
|
|
3
|
+
*/
|
|
4
|
+
import type { Address } from 'viem';
|
|
5
|
+
import { RadiusError, type RadiusErrorOptions } from './base';
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when a signer is required but not available.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* try {
|
|
12
|
+
* // Attempting to send without an account configured
|
|
13
|
+
* await walletClient.sendTransaction({ to, value });
|
|
14
|
+
* } catch (error) {
|
|
15
|
+
* if (error instanceof SignerNotFoundError) {
|
|
16
|
+
* console.log('Please connect a wallet');
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class SignerNotFoundError extends RadiusError {
|
|
22
|
+
readonly name = "SignerNotFoundError";
|
|
23
|
+
constructor(message?: string, options?: RadiusErrorOptions);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error thrown when account balance is insufficient for an operation.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* try {
|
|
31
|
+
* await walletClient.sendTransaction({ to, value });
|
|
32
|
+
* } catch (error) {
|
|
33
|
+
* if (error instanceof InsufficientBalanceError) {
|
|
34
|
+
* console.log(`Need ${error.required}, have ${error.balance}`);
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class InsufficientBalanceError extends RadiusError {
|
|
40
|
+
readonly name = "InsufficientBalanceError";
|
|
41
|
+
/** The account address */
|
|
42
|
+
readonly address?: Address;
|
|
43
|
+
/** Current balance (in wei) */
|
|
44
|
+
readonly balance?: bigint;
|
|
45
|
+
/** Required balance (in wei) */
|
|
46
|
+
readonly required?: bigint;
|
|
47
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
48
|
+
address?: Address;
|
|
49
|
+
balance?: bigint;
|
|
50
|
+
required?: bigint;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Error thrown when signing a message or transaction fails.
|
|
55
|
+
*/
|
|
56
|
+
export declare class SigningError extends RadiusError {
|
|
57
|
+
readonly name = "SigningError";
|
|
58
|
+
constructor(message: string, options?: RadiusErrorOptions);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Error thrown when an invalid private key is provided.
|
|
62
|
+
*/
|
|
63
|
+
export declare class InvalidPrivateKeyError extends RadiusError {
|
|
64
|
+
readonly name = "InvalidPrivateKeyError";
|
|
65
|
+
constructor(message?: string, options?: RadiusErrorOptions);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Error thrown when address validation fails.
|
|
69
|
+
*/
|
|
70
|
+
export declare class InvalidAddressError extends RadiusError {
|
|
71
|
+
readonly name = "InvalidAddressError";
|
|
72
|
+
/** The invalid address value */
|
|
73
|
+
readonly invalidAddress?: string;
|
|
74
|
+
constructor(message: string, options?: RadiusErrorOptions & {
|
|
75
|
+
invalidAddress?: string;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../errors/account.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IACnD,SAAkB,IAAI,yBAAyB;gBAEnC,OAAO,SAAuB,EAAE,OAAO,GAAE,kBAAuB;CAM5E;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;IACxD,SAAkB,IAAI,8BAA8B;IAEpD,0BAA0B;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,gCAAgC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAG1B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAkB,GAAG;QAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACb;CAUP;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC5C,SAAkB,IAAI,kBAAkB;gBAE5B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;CAM7D;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACtD,SAAkB,IAAI,4BAA4B;gBAEtC,OAAO,SAAwB,EAAE,OAAO,GAAE,kBAAuB;CAM7E;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IACnD,SAAkB,IAAI,yBAAyB;IAE/C,gCAAgC;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;gBAGhC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAkB,GAAG;QAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;KACnB;CAQP"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radius SDK Error Hierarchy
|
|
3
|
+
*
|
|
4
|
+
* Extends viem's BaseError for ecosystem compatibility.
|
|
5
|
+
* All Radius errors can be caught using `instanceof BaseError` from viem.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseError } from 'viem';
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a RadiusError
|
|
10
|
+
*/
|
|
11
|
+
export interface RadiusErrorOptions {
|
|
12
|
+
/** Detailed error information */
|
|
13
|
+
details?: string;
|
|
14
|
+
/** URL path to relevant documentation */
|
|
15
|
+
docsPath?: string;
|
|
16
|
+
/** The underlying cause of this error */
|
|
17
|
+
cause?: BaseError | Error | undefined;
|
|
18
|
+
/** Additional hint messages to help resolve the error */
|
|
19
|
+
metaMessages?: string[];
|
|
20
|
+
/** Additional metadata about the error (Radius-specific extension) */
|
|
21
|
+
meta?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Base error class for all Radius SDK errors.
|
|
25
|
+
*
|
|
26
|
+
* Extends viem's BaseError for ecosystem compatibility. This means:
|
|
27
|
+
* - `error instanceof BaseError` from viem will catch Radius errors
|
|
28
|
+
* - Compatible with wagmi error handling
|
|
29
|
+
* - Inherits viem's error formatting and walk() method
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { BaseError } from 'viem';
|
|
34
|
+
*
|
|
35
|
+
* try {
|
|
36
|
+
* await walletClient.sendTransaction({ to, value });
|
|
37
|
+
* } catch (error) {
|
|
38
|
+
* if (error instanceof RadiusError) {
|
|
39
|
+
* console.log(error.shortMessage); // Quick description
|
|
40
|
+
* console.log(error.details); // Full details
|
|
41
|
+
* console.log(error.docsPath); // Link to docs
|
|
42
|
+
* }
|
|
43
|
+
* // Also works with viem's BaseError check
|
|
44
|
+
* if (error instanceof BaseError) {
|
|
45
|
+
* console.log('Caught viem-compatible error');
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare class RadiusError extends BaseError {
|
|
51
|
+
/** Additional metadata (Radius-specific extension) */
|
|
52
|
+
readonly meta?: Record<string, unknown>;
|
|
53
|
+
name: string;
|
|
54
|
+
constructor(shortMessage: string, options?: RadiusErrorOptions);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../errors/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,KAAK,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,SAAS,CAAC;IACtC,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACzC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B,IAAI,SAAiB;gBAElB,YAAY,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;CAYlE"}
|