@towns-labs/relayer-client 2.0.1

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.
Files changed (102) hide show
  1. package/README.md +752 -0
  2. package/dist/actions/checkHealth.d.ts +17 -0
  3. package/dist/actions/checkHealth.d.ts.map +1 -0
  4. package/dist/actions/checkHealth.js +45 -0
  5. package/dist/actions/checkHealth.js.map +1 -0
  6. package/dist/actions/createAccount.d.ts +151 -0
  7. package/dist/actions/createAccount.d.ts.map +1 -0
  8. package/dist/actions/createAccount.js +203 -0
  9. package/dist/actions/createAccount.js.map +1 -0
  10. package/dist/actions/executeIntent.d.ts +119 -0
  11. package/dist/actions/executeIntent.d.ts.map +1 -0
  12. package/dist/actions/executeIntent.js +118 -0
  13. package/dist/actions/executeIntent.js.map +1 -0
  14. package/dist/actions/getBundleStatus.d.ts +21 -0
  15. package/dist/actions/getBundleStatus.d.ts.map +1 -0
  16. package/dist/actions/getBundleStatus.js +73 -0
  17. package/dist/actions/getBundleStatus.js.map +1 -0
  18. package/dist/actions/getCapabilities.d.ts +24 -0
  19. package/dist/actions/getCapabilities.d.ts.map +1 -0
  20. package/dist/actions/getCapabilities.js +72 -0
  21. package/dist/actions/getCapabilities.js.map +1 -0
  22. package/dist/actions/index.d.ts +17 -0
  23. package/dist/actions/index.d.ts.map +1 -0
  24. package/dist/actions/index.js +17 -0
  25. package/dist/actions/index.js.map +1 -0
  26. package/dist/actions/prepareIntent.d.ts +59 -0
  27. package/dist/actions/prepareIntent.d.ts.map +1 -0
  28. package/dist/actions/prepareIntent.js +87 -0
  29. package/dist/actions/prepareIntent.js.map +1 -0
  30. package/dist/actions/signIntent.d.ts +244 -0
  31. package/dist/actions/signIntent.d.ts.map +1 -0
  32. package/dist/actions/signIntent.js +319 -0
  33. package/dist/actions/signIntent.js.map +1 -0
  34. package/dist/actions/signPayment.d.ts +71 -0
  35. package/dist/actions/signPayment.d.ts.map +1 -0
  36. package/dist/actions/signPayment.js +81 -0
  37. package/dist/actions/signPayment.js.map +1 -0
  38. package/dist/actions/submitIntent.d.ts +53 -0
  39. package/dist/actions/submitIntent.d.ts.map +1 -0
  40. package/dist/actions/submitIntent.js +122 -0
  41. package/dist/actions/submitIntent.js.map +1 -0
  42. package/dist/actions/waitForBundle.d.ts +36 -0
  43. package/dist/actions/waitForBundle.d.ts.map +1 -0
  44. package/dist/actions/waitForBundle.js +55 -0
  45. package/dist/actions/waitForBundle.js.map +1 -0
  46. package/dist/chains.d.ts +24 -0
  47. package/dist/chains.d.ts.map +1 -0
  48. package/dist/chains.js +68 -0
  49. package/dist/chains.js.map +1 -0
  50. package/dist/client.d.ts +27 -0
  51. package/dist/client.d.ts.map +1 -0
  52. package/dist/client.js +28 -0
  53. package/dist/client.js.map +1 -0
  54. package/dist/decorators/index.d.ts +2 -0
  55. package/dist/decorators/index.d.ts.map +1 -0
  56. package/dist/decorators/index.js +2 -0
  57. package/dist/decorators/index.js.map +1 -0
  58. package/dist/decorators/relayer.d.ts +80 -0
  59. package/dist/decorators/relayer.d.ts.map +1 -0
  60. package/dist/decorators/relayer.js +66 -0
  61. package/dist/decorators/relayer.js.map +1 -0
  62. package/dist/index.d.ts +52 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +58 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/transport.d.ts +81 -0
  67. package/dist/transport.d.ts.map +1 -0
  68. package/dist/transport.js +95 -0
  69. package/dist/transport.js.map +1 -0
  70. package/dist/types.d.ts +359 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +42 -0
  73. package/dist/types.js.map +1 -0
  74. package/dist/utils/constants.d.ts +47 -0
  75. package/dist/utils/constants.d.ts.map +1 -0
  76. package/dist/utils/constants.js +46 -0
  77. package/dist/utils/constants.js.map +1 -0
  78. package/dist/utils/erc1271.d.ts +43 -0
  79. package/dist/utils/erc1271.d.ts.map +1 -0
  80. package/dist/utils/erc1271.js +50 -0
  81. package/dist/utils/erc1271.js.map +1 -0
  82. package/dist/utils/errors.d.ts +54 -0
  83. package/dist/utils/errors.d.ts.map +1 -0
  84. package/dist/utils/errors.js +60 -0
  85. package/dist/utils/errors.js.map +1 -0
  86. package/dist/utils/index.d.ts +7 -0
  87. package/dist/utils/index.d.ts.map +1 -0
  88. package/dist/utils/index.js +7 -0
  89. package/dist/utils/index.js.map +1 -0
  90. package/dist/utils/keyHash.d.ts +50 -0
  91. package/dist/utils/keyHash.d.ts.map +1 -0
  92. package/dist/utils/keyHash.js +52 -0
  93. package/dist/utils/keyHash.js.map +1 -0
  94. package/dist/utils/serialize.d.ts +51 -0
  95. package/dist/utils/serialize.d.ts.map +1 -0
  96. package/dist/utils/serialize.js +52 -0
  97. package/dist/utils/serialize.js.map +1 -0
  98. package/dist/utils/wallet.d.ts +9 -0
  99. package/dist/utils/wallet.d.ts.map +1 -0
  100. package/dist/utils/wallet.js +25 -0
  101. package/dist/utils/wallet.js.map +1 -0
  102. package/package.json +35 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Submit a signed intent to the relayer
3
+ */
4
+ import { createJsonRpcTransport } from '../transport';
5
+ /**
6
+ * Submit a pre-signed intent to the relayer
7
+ *
8
+ * Uses JSON-RPC `wallet_sendPreparedCalls` method.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const intent = await signIntent(client, { ... })
13
+ * const result = await submitIntent(client, { intent })
14
+ *
15
+ * if (result.success) {
16
+ * console.log('Transaction hash:', result.txHash)
17
+ * }
18
+ * ```
19
+ */
20
+ export async function submitIntent(client, params) {
21
+ try {
22
+ const transport = createJsonRpcTransport(client.relayerConfig.relayerUrl);
23
+ // Build context from intent if not provided (JSON-RPC format)
24
+ const context = params.context ?? {
25
+ eoa: params.intent.eoa,
26
+ calls: params.intent.calls.map((call) => ({
27
+ to: call.target,
28
+ value: `0x${call.value.toString(16)}`,
29
+ data: call.data,
30
+ })),
31
+ nonce: params.intent.nonce.toString(),
32
+ combinedGas: params.intent.combinedGas.toString(),
33
+ expiry: params.intent.expiry.toString(),
34
+ payer: params.intent.payer,
35
+ paymentToken: params.intent.paymentToken,
36
+ paymentMaxAmount: params.intent.paymentMaxAmount?.toString(),
37
+ paymentAmount: params.intent.paymentAmount?.toString(),
38
+ paymentSignature: params.intent.paymentSignature,
39
+ };
40
+ const rpcParams = {
41
+ context,
42
+ signature: params.intent.signature,
43
+ };
44
+ const result = await transport.request('wallet_sendPreparedCalls', rpcParams);
45
+ return {
46
+ success: true,
47
+ bundleId: result.id,
48
+ };
49
+ }
50
+ catch (error) {
51
+ return {
52
+ success: false,
53
+ error: error instanceof Error ? error.message : 'Unknown error',
54
+ };
55
+ }
56
+ }
57
+ /**
58
+ * Submit multiple intents as a batch
59
+ *
60
+ * Uses JSON-RPC batch requests to submit all intents in a single HTTP call.
61
+ * The relayer optimizes homogeneous batches of wallet_sendPreparedCalls into
62
+ * a single on-chain transaction for gas efficiency.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const intents = await Promise.all([
67
+ * signIntent(client, { eoa: addr1, ... }),
68
+ * signIntent(client, { eoa: addr2, ... })
69
+ * ])
70
+ *
71
+ * const result = await submitBatch(client, { intents })
72
+ * if (result.success) {
73
+ * // All intents executed in a single transaction
74
+ * console.log('Bundle IDs:', result.bundleIds)
75
+ * }
76
+ * ```
77
+ */
78
+ export async function submitBatch(client, params) {
79
+ if (params.intents.length === 0) {
80
+ return { success: true, bundleIds: [], succeeded: 0, failed: 0 };
81
+ }
82
+ try {
83
+ const transport = createJsonRpcTransport(client.relayerConfig.relayerUrl);
84
+ // Build batch request - each intent becomes a wallet_sendPreparedCalls request
85
+ const requests = params.intents.map((intent) => ({
86
+ method: 'wallet_sendPreparedCalls',
87
+ params: {
88
+ context: {
89
+ eoa: intent.eoa,
90
+ calls: intent.calls.map((call) => ({
91
+ to: call.target,
92
+ value: `0x${call.value.toString(16)}`,
93
+ data: call.data,
94
+ })),
95
+ nonce: intent.nonce.toString(),
96
+ combinedGas: intent.combinedGas.toString(),
97
+ expiry: intent.expiry.toString(),
98
+ payer: intent.payer,
99
+ paymentToken: intent.paymentToken,
100
+ paymentMaxAmount: intent.paymentMaxAmount?.toString(),
101
+ paymentAmount: intent.paymentAmount?.toString(),
102
+ paymentSignature: intent.paymentSignature,
103
+ },
104
+ signature: intent.signature,
105
+ },
106
+ }));
107
+ const results = await transport.requestBatch(requests);
108
+ return {
109
+ success: true,
110
+ bundleIds: results.map((r) => r.id),
111
+ succeeded: results.length,
112
+ failed: 0,
113
+ };
114
+ }
115
+ catch (error) {
116
+ return {
117
+ success: false,
118
+ error: error instanceof Error ? error.message : 'Unknown error',
119
+ };
120
+ }
121
+ }
122
+ //# sourceMappingURL=submitIntent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submitIntent.js","sourceRoot":"","sources":["../../src/actions/submitIntent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAqBrD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,MAA2B,EAC3B,MAA0B;IAE1B,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;QAEzE,8DAA8D;QAC9D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI;YAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtC,EAAE,EAAE,IAAI,CAAC,MAAM;gBACf,KAAK,EAAE,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;gBACrC,IAAI,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC,CAAC;YACH,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,Q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,EAAE,CAAC;YACnC,SAAS,EAAE,OAAO,CAAC,MAAM;YACzB,MAAM,EAAE,CAAC;SACZ,CAAA;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAClE,CAAA;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Wait for bundle to reach final status
3
+ *
4
+ * Polls wallet_getCallsStatus at intervals until the bundle reaches a final status.
5
+ */
6
+ import type { RelayerPublicClient, BundleStatusResponse } from '../types';
7
+ export interface WaitForBundleParams {
8
+ /** Bundle ID to wait for */
9
+ bundleId: string;
10
+ /** Polling interval in milliseconds (default: 500ms) */
11
+ intervalMs?: number;
12
+ /** Timeout in milliseconds (default: 30000ms = 30 seconds) */
13
+ timeoutMs?: number;
14
+ }
15
+ /**
16
+ * Wait for bundle to reach final status
17
+ *
18
+ * Polls the relayer until the bundle reaches a final status (confirmed, failed, or reverted).
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const result = await client.submitIntent({ intent })
23
+ * const status = await client.waitForBundle({
24
+ * bundleId: result.bundleId!,
25
+ * timeoutMs: 60_000
26
+ * })
27
+ *
28
+ * if (status.status === 'confirmed') {
29
+ * console.log('Success!', status.receipt?.transactionHash)
30
+ * } else if (status.status === 'reverted') {
31
+ * console.log('Intent failed on-chain:', status.receipt?.intentError)
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function waitForBundle(client: RelayerPublicClient, params: WaitForBundleParams): Promise<BundleStatusResponse>;
36
+ //# sourceMappingURL=waitForBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitForBundle.d.ts","sourceRoot":"","sources":["../../src/actions/waitForBundle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAGzE,MAAM,WAAW,mBAAmB;IAChC,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CAC/B,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,mBAAmB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CA2B/B"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Wait for bundle to reach final status
3
+ *
4
+ * Polls wallet_getCallsStatus at intervals until the bundle reaches a final status.
5
+ */
6
+ import { getBundleStatus } from './getBundleStatus';
7
+ /**
8
+ * Final status codes that indicate the bundle is complete
9
+ * - 200: Confirmed
10
+ * - 201: PreConfirmed
11
+ * - 300: Failed (offchain)
12
+ * - 400: Reverted (on-chain intent failure)
13
+ * - 500: PartiallyReverted
14
+ */
15
+ const FINAL_STATUS_CODES = [200, 201, 300, 400, 500];
16
+ /**
17
+ * Wait for bundle to reach final status
18
+ *
19
+ * Polls the relayer until the bundle reaches a final status (confirmed, failed, or reverted).
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const result = await client.submitIntent({ intent })
24
+ * const status = await client.waitForBundle({
25
+ * bundleId: result.bundleId!,
26
+ * timeoutMs: 60_000
27
+ * })
28
+ *
29
+ * if (status.status === 'confirmed') {
30
+ * console.log('Success!', status.receipt?.transactionHash)
31
+ * } else if (status.status === 'reverted') {
32
+ * console.log('Intent failed on-chain:', status.receipt?.intentError)
33
+ * }
34
+ * ```
35
+ */
36
+ export async function waitForBundle(client, params) {
37
+ const { bundleId, intervalMs = 500, timeoutMs = 30000 } = params;
38
+ const startTime = Date.now();
39
+ while (true) {
40
+ const status = await getBundleStatus(client, { bundleId });
41
+ if (!status.success) {
42
+ throw new Error(`Failed to get bundle status: ${status.error ?? 'Unknown error'}`);
43
+ }
44
+ if (status.statusCode &&
45
+ FINAL_STATUS_CODES.includes(status.statusCode)) {
46
+ return status;
47
+ }
48
+ const elapsed = Date.now() - startTime;
49
+ if (elapsed >= timeoutMs) {
50
+ throw new Error(`Timeout waiting for bundle ${bundleId} to reach final status. Current status: ${status.statusCode ?? 'unknown'}`);
51
+ }
52
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
53
+ }
54
+ }
55
+ //# sourceMappingURL=waitForBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitForBundle.js","sourceRoot":"","sources":["../../src/actions/waitForBundle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAWnD;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAC/B,MAA2B,EAC3B,MAA2B;IAE3B,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,GAAG,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAChE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAE5B,OAAO,IAAI,EAAE,CAAC;QACV,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QAE1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,CAAC,CAAA;QACtF,CAAC;QAED,IACI,MAAM,CAAC,UAAU;YACjB,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAiD,CAAC,EACvF,CAAC;YACC,OAAO,MAAM,CAAA;QACjB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;QACtC,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACX,8BAA8B,QAAQ,2CAA2C,MAAM,CAAC,UAAU,IAAI,SAAS,EAAE,CACpH,CAAA;QACL,CAAC;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;IACnE,CAAC;AACL,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Chain configuration helper for the client
3
+ *
4
+ * Provides proper chain configuration for any supported EVM chain,
5
+ * with fallback for unknown chains.
6
+ */
7
+ import type { Chain } from 'viem';
8
+ /**
9
+ * Get chain configuration for a specific chainId
10
+ *
11
+ * @param chainId - The chain ID
12
+ * @param rpcUrl - The RPC URL to use (overrides default)
13
+ * @returns Chain configuration compatible with viem
14
+ */
15
+ export declare function getChain(chainId: number, rpcUrl: string): Chain;
16
+ /**
17
+ * Check if a chain is explicitly supported (has full config)
18
+ */
19
+ export declare function isKnownChain(chainId: number): boolean;
20
+ /**
21
+ * Get list of known chain IDs
22
+ */
23
+ export declare function getKnownChainIds(): number[];
24
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAuBjC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CA0B/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C"}
package/dist/chains.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Chain configuration helper for the client
3
+ *
4
+ * Provides proper chain configuration for any supported EVM chain,
5
+ * with fallback for unknown chains.
6
+ */
7
+ import { anvil, baseSepolia, base, mainnet, sepolia, optimism, arbitrum } from 'viem/chains';
8
+ /**
9
+ * Supported chains with full configuration
10
+ */
11
+ const SUPPORTED_CHAINS = {
12
+ // Local development
13
+ 31337: anvil,
14
+ // Ethereum
15
+ 1: mainnet,
16
+ 11155111: sepolia,
17
+ // Base
18
+ 8453: base,
19
+ 84532: baseSepolia,
20
+ // Other L2s (add as needed)
21
+ 10: optimism,
22
+ 42161: arbitrum,
23
+ };
24
+ /**
25
+ * Get chain configuration for a specific chainId
26
+ *
27
+ * @param chainId - The chain ID
28
+ * @param rpcUrl - The RPC URL to use (overrides default)
29
+ * @returns Chain configuration compatible with viem
30
+ */
31
+ export function getChain(chainId, rpcUrl) {
32
+ const baseChain = SUPPORTED_CHAINS[chainId];
33
+ if (baseChain) {
34
+ // Use known chain config but override RPC URL
35
+ return {
36
+ ...baseChain,
37
+ rpcUrls: {
38
+ default: { http: [rpcUrl] },
39
+ },
40
+ };
41
+ }
42
+ // Fallback: create minimal chain config for unknown chains
43
+ return {
44
+ id: chainId,
45
+ name: `Chain ${chainId}`,
46
+ nativeCurrency: {
47
+ name: 'Ether',
48
+ symbol: 'ETH',
49
+ decimals: 18,
50
+ },
51
+ rpcUrls: {
52
+ default: { http: [rpcUrl] },
53
+ },
54
+ };
55
+ }
56
+ /**
57
+ * Check if a chain is explicitly supported (has full config)
58
+ */
59
+ export function isKnownChain(chainId) {
60
+ return chainId in SUPPORTED_CHAINS;
61
+ }
62
+ /**
63
+ * Get list of known chain IDs
64
+ */
65
+ export function getKnownChainIds() {
66
+ return Object.keys(SUPPORTED_CHAINS).map(Number);
67
+ }
68
+ //# sourceMappingURL=chains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.js","sourceRoot":"","s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G,CAAC,MAAM,CAAC,CAAA;AACpD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Relayer SDK Configuration
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { createPublicClient, http } from 'viem'
7
+ * import { baseSepolia } from 'viem/chains'
8
+ * import { relayerActions } from '@towns-labs/relayer-client'
9
+ *
10
+ * const client = createPublicClient({
11
+ * chain: baseSepolia,
12
+ * transport: http('https://sepolia.base.org')
13
+ * }).extend(relayerActions({
14
+ * relayerUrl: 'https://relayer.example.com'
15
+ * }))
16
+ *
17
+ * // Same client for viem and relayer operations
18
+ * await client.getBalance({...}) // viem
19
+ * await client.submitIntent({...}) // relayer
20
+ * ```
21
+ */
22
+ import type { RelayerClientConfig } from './types';
23
+ /**
24
+ * Create a relayer config
25
+ */
26
+ export declare function createConfig(relayerUrl: string): RelayerClientConfig;
27
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAEpE"}
package/dist/client.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Relayer SDK Configuration
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { createPublicClient, http } from 'viem'
7
+ * import { baseSepolia } from 'viem/chains'
8
+ * import { relayerActions } from '@towns-labs/relayer-client'
9
+ *
10
+ * const client = createPublicClient({
11
+ * chain: baseSepolia,
12
+ * transport: http('https://sepolia.base.org')
13
+ * }).extend(relayerActions({
14
+ * relayerUrl: 'https://relayer.example.com'
15
+ * }))
16
+ *
17
+ * // Same client for viem and relayer operations
18
+ * await client.getBalance({...}) // viem
19
+ * await client.submitIntent({...}) // relayer
20
+ * ```
21
+ */
22
+ /**
23
+ * Create a relayer config
24
+ */
25
+ export function createConfig(relayerUrl) {
26
+ return { relayerUrl };
27
+ }
28
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC3C,OAAO,EAAE,UAAU,EAAE,CAAA;AACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { relayerActions, type RelayerActions } from './relayer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { relayerActions } from './relayer';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,WAAW,CAAA"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Relayer actions decorator
3
+ *
4
+ * Adds all relayer actions as methods on a viem PublicClient.
5
+ */
6
+ import type { PublicClient } from 'viem';
7
+ import type { Hex } from 'viem';
8
+ import type { RelayerClientConfig, HealthResponse, CapabilitiesResponse, BundleStatusResponse, CreateAccountResponse, PrepareIntentResponse, ExecuteIntentResponse, BatchIntentsResponse, SignedIntent } from '../types';
9
+ import { type GetBundleStatusParams } from '../actions/getBundleStatus';
10
+ import { type CreateAccountParams, type CreateAccountWithWalletParams } from '../actions/createAccount';
11
+ import { type PrepareIntentParams } from '../actions/prepareIntent';
12
+ import { type SubmitIntentParams, type SubmitBatchParams } from '../actions/submitIntent';
13
+ import { type SignIntentParams, type SignIntentWithWalletParams, type SignIntentAsDelegateParams } from '../actions/signIntent';
14
+ import { type WaitForBundleParams } from '../actions/waitForBundle';
15
+ import { type ExecuteIntentParams, type ExecuteIntentWithWalletParams, type ExecuteIntentResult } from '../actions/executeIntent';
16
+ import { type SignPaymentParams, type SignPaymentWithWalletParams } from '../actions/signPayment';
17
+ /**
18
+ * Actions added by relayerActions decorator
19
+ */
20
+ export type RelayerActions = {
21
+ /** Relayer configuration (attached to client) */
22
+ relayerConfig: RelayerClientConfig;
23
+ /** Check relayer health */
24
+ checkHealth: () => Promise<HealthResponse>;
25
+ /** Get relayer capabilities */
26
+ getCapabilities: () => Promise<CapabilitiesResponse>;
27
+ /** Get bundle status */
28
+ getBundleStatus: (params: GetBundleStatusParams) => Promise<BundleStatusResponse>;
29
+ /** Wait for bundle to reach final status */
30
+ waitForBundle: (params: WaitForBundleParams) => Promise<BundleStatusResponse>;
31
+ /** Create a delegated account */
32
+ createAccount: (params: CreateAccountParams) => Promise<CreateAccountResponse>;
33
+ /** Create a delegated account with a wallet client */
34
+ createAccountWithWallet: (params: CreateAccountWithWalletParams) => Promise<CreateAccountResponse>;
35
+ /** Prepare an intent for signing (also provides gas estimation - use instead of simulateIntent) */
36
+ prepareIntent: (params: PrepareIntentParams) => Promise<PrepareIntentResponse>;
37
+ /** Submit a signed intent */
38
+ submitIntent: (params: SubmitIntentParams) => Promise<ExecuteIntentResponse>;
39
+ /** Submit a batch of intents */
40
+ submitBatch: (params: SubmitBatchParams) => Promise<BatchIntentsResponse>;
41
+ /** Sign an intent */
42
+ signIntent: (params: SignIntentParams) => Promise<SignedIntent>;
43
+ /** Sign an intent with a wallet client */
44
+ signIntentWithWallet: (params: SignIntentWithWalletParams) => Promise<SignedIntent>;
45
+ /** Sign an intent as a delegated signer (smart contract account) */
46
+ signIntentAsDelegate: (params: SignIntentAsDelegateParams) => Promise<SignedIntent>;
47
+ /** Sign a payment authorization for third-party gas sponsorship */
48
+ signPayment: (params: SignPaymentParams) => Promise<Hex>;
49
+ /** Sign a payment authorization with a wallet client */
50
+ signPaymentWithWallet: (params: SignPaymentWithWalletParams) => Promise<Hex>;
51
+ /** Execute an intent (sign + submit + wait) */
52
+ executeIntent: (params: ExecuteIntentParams) => Promise<ExecuteIntentResult>;
53
+ /** Execute an intent with a wallet client */
54
+ executeIntentWithWallet: (params: ExecuteIntentWithWalletParams) => Promise<ExecuteIntentResult>;
55
+ };
56
+ /**
57
+ * Add all relayer actions to a viem PublicClient
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * import { createPublicClient, http } from 'viem'
62
+ * import { baseSepolia } from 'viem/chains'
63
+ * import { relayerActions } from '@towns-labs/relayer-client'
64
+ *
65
+ * const client = createPublicClient({
66
+ * chain: baseSepolia,
67
+ * transport: http('https://sepolia.base.org')
68
+ * }).extend(relayerActions({
69
+ * relayerUrl: 'https://relayer.example.com'
70
+ * }))
71
+ *
72
+ * // Now you can use:
73
+ * await client.checkHealth()
74
+ * await client.createAccount({ ... })
75
+ * await client.signIntent({ ... })
76
+ * await client.submitIntent({ ... })
77
+ * ```
78
+ */
79
+ export declare function relayerActions(config: RelayerClientConfig): (client: PublicClient) => RelayerActions;
80
+ //# sourceMappingURL=relayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relayer.d.ts","sourceRoot":"","sources":["../../src/decorators/relayer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EACR,mBAAmB,EAEnB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACf,MAAM,UAAU,CAAA;AAIjB,OAAO,EAAmB,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACxF,OAAO,EAGH,KAAK,mBAAmB,E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C,qBAAqB,CAAC,CAAA;IAC9E,6BAA6B;IAC7B,YAAY,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAC5E,gCAAgC;IAChC,WAAW,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACzE,qBAAqB;IACrB,UAAU,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IAC/D,0CAA0C;IAC1C,oBAAoB,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IACnF,oEAAoE;IACpE,oBAAoB,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;IACnF,mEAAmE;IACnE,WAAW,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACxD,wDAAwD;IACxD,qBAAqB,EAAE,CAAC,MAAM,EAAE,2BAA2B,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC5E,+CAA+C;IAC/C,aAAa,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAC5E,6CAA6C;IAC7C,uBAAuB,EAAE,CAAC,MAAM,EAAE,6BAA6B,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAA;CACnG,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB,IAC9C,QAAQ,YAAY,KAAG,cAAc,CA0BhD"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Relayer actions decorator
3
+ *
4
+ * Adds all relayer actions as methods on a viem PublicClient.
5
+ */
6
+ import { checkHealth } from '../actions/checkHealth';
7
+ import { getCapabilities } from '../actions/getCapabilities';
8
+ import { getBundleStatus } from '../actions/getBundleStatus';
9
+ import { createAccount, createAccountWithWallet, } from '../actions/createAccount';
10
+ import { prepareIntent } from '../actions/prepareIntent';
11
+ import { submitIntent, submitBatch, } from '../actions/submitIntent';
12
+ import { signIntent, signIntentWithWallet, signIntentAsDelegate, } from '../actions/signIntent';
13
+ import { waitForBundle } from '../actions/waitForBundle';
14
+ import { executeIntent, executeIntentWithWallet, } from '../actions/executeIntent';
15
+ import { signPayment, signPaymentWithWallet, } from '../actions/signPayment';
16
+ /**
17
+ * Add all relayer actions to a viem PublicClient
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { createPublicClient, http } from 'viem'
22
+ * import { baseSepolia } from 'viem/chains'
23
+ * import { relayerActions } from '@towns-labs/relayer-client'
24
+ *
25
+ * const client = createPublicClient({
26
+ * chain: baseSepolia,
27
+ * transport: http('https://sepolia.base.org')
28
+ * }).extend(relayerActions({
29
+ * relayerUrl: 'https://relayer.example.com'
30
+ * }))
31
+ *
32
+ * // Now you can use:
33
+ * await client.checkHealth()
34
+ * await client.createAccount({ ... })
35
+ * await client.signIntent({ ... })
36
+ * await client.submitIntent({ ... })
37
+ * ```
38
+ */
39
+ export function relayerActions(config) {
40
+ return (client) => {
41
+ // Attach config to client (viem pattern)
42
+ const relayerClient = Object.assign(client, {
43
+ relayerConfig: config,
44
+ });
45
+ return {
46
+ relayerConfig: config,
47
+ checkHealth: () => checkHealth(relayerClient),
48
+ getCapabilities: () => getCapabilities(relayerClient),
49
+ getBundleStatus: (params) => getBundleStatus(relayerClient, params),
50
+ waitForBundle: (params) => waitForBundle(relayerClient, params),
51
+ createAccount: (params) => createAccount(relayerClient, params),
52
+ createAccountWithWallet: (params) => createAccountWithWallet(relayerClient, params),
53
+ prepareIntent: (params) => prepareIntent(relayerClient, params),
54
+ submitIntent: (params) => submitIntent(relayerClient, params),
55
+ submitBatch: (params) => submitBatch(relayerClient, params),
56
+ signIntent: (params) => signIntent(relayerClient, params),
57
+ signIntentWithWallet: (params) => signIntentWithWallet(relayerClient, params),
58
+ signIntentAsDelegate: (params) => signIntentAsDelegate(relayerClient, params),
59
+ signPayment: (params) => signPayment(relayerClient, params),
60
+ signPaymentWithWallet: (params) => signPaymentWithWallet(relayerClient, params),
61
+ executeIntent: (params) => executeIntent(relayerClient, params),
62
+ executeIntentWithWallet: (params) => executeIntentWithWallet(relayerClient, params),
63
+ };
64
+ };
65
+ }
66
+ //# sourceMappingURL=relayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relayer.js","sourceRoot":"","sources":["../../src/decorators/relayer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAA8B,MAAM,4BAA4B,CAAA;AACxF,OAAO,EACH,aAAa,EACb,uBAAuB,GAG1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,aAAa,EAA4B,MAAM,0BAA0B,CAAA;AAClF,OAAO,EACH,YAAY,EACZ,WAAW,GAGd,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACH,UAAU,EACV,oBAAoB,EACpB,oBAAoB,GAIvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAA4B,MAAM,0BAA0B,CAAA;AAClF,OAAO,EACH,aAAa,EACb,uBAAuB,GAI1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACH,WAAW,EACX,qBAAqB,GAGxB,MAAM,wBAAwB,CAAA;AA4C/B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,cAAc,CAAC,MAA2B;IACtD,OAAO,CAAC,MAAoB,EAAkB,EAAE;QAC5C,yCAAyC;QACzC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;YACxC,aAAa,EAAE,MAAM;SACxB,CAAwB,CAAA;QAEzB,OAAO;YACH,aAAa,EAAE,MAAM;YACrB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AM,CAAC;YAC/D,uBAAuB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,aAAa,EAAE,MAAM,CAAC;SACtF,CAAA;IACL,CAAC,CAAA;AACL,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @towns-labs/relayer-client
3
+ *
4
+ * Slim, Viem-style SDK for the EIP-7702 Relayer Orchestrator system.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { createPublicClient, http } from 'viem'
9
+ * import { baseSepolia } from 'viem/chains'
10
+ * import { relayerActions } from '@towns-labs/relayer-client'
11
+ * import { generatePrivateKey } from 'viem/accounts'
12
+ *
13
+ * // Create client with relayer actions
14
+ * const client = createPublicClient({
15
+ * chain: baseSepolia,
16
+ * transport: http('https://sepolia.base.org')
17
+ * }).extend(relayerActions({
18
+ * relayerUrl: 'https://relayer.example.com'
19
+ * }))
20
+ *
21
+ * // Same client for viem and relayer operations
22
+ * await client.getBalance({ address }) // viem
23
+ * await client.checkHealth() // relayer
24
+ *
25
+ * // Generate a private key
26
+ * const privateKey = generatePrivateKey()
27
+ *
28
+ * // Create delegated account via relayer (two-step flow handled internally)
29
+ * await client.createAccount({
30
+ * accountAddress: account.address,
31
+ * signerKey: privateKey
32
+ * })
33
+ *
34
+ * // Sign and submit intent
35
+ * const intent = await client.signIntent({
36
+ * accountAddress: account.address,
37
+ * signerKey: privateKey,
38
+ * calls: [{ target, value: 0n, data }]
39
+ * })
40
+ *
41
+ * await client.submitIntent({ intent })
42
+ * ```
43
+ */
44
+ export { createConfig } from './client';
45
+ export { checkHealth, getCapabilities, getBundleStatus, waitForBundle, createAccount, createAccountWithWallet, prepareIntent, submitIntent, submitBatch, signIntent, signIntentWithWallet, signIntentAsDelegate, wrapSignature, signPayment, signPaymentWithWallet, executeIntent, executeIntentWithWallet, type GetBundleStatusParams, type WaitForBundleParams, type CreateAccountParams, type CreateAccountWithWalletParams, type PrepareIntentParams, type SubmitIntentParams, type SubmitBatchParams, type SignIntentParams, type SignIntentWithWalletParams, type SignIntentAsDelegateParams, type SignPaymentParams, type SignPaymentWithWalletParams, type ExecuteIntentParams, type ExecuteIntentWithWalletParams, type ExecuteIntentResult, type AuthorizeKey, type CallPermission, type SpendPermission, type Permission, type SpendPeriod, } from './actions';
46
+ export { relayerActions, type RelayerActions } from './decorators';
47
+ export { createJsonRpcTransport, JsonRpcClientError, type JsonRpcTransport, type JsonRpcRequest, type JsonRpcResponse, type JsonRpcError, } from './transport';
48
+ export { bigIntReplacer, serializeCall, serializeIntent, computeKeyHash, encodeSecp256k1Key, decodeIntentError, isKnownIntentError, INTENT_ERRORS, ANY_TARGET, EMPTY_CALLDATA_SELECTOR, ERC20_SELECTORS, computeErc1271Digest, ERC1271_SIGN_TYPEHASH, DOMAIN_TYPEHASH_ONLY_VERIFYING_CONTRACT, type SerializedCall, type SerializedIntent, type KeyType, type IntentErrorName, } from './utils';
49
+ export type { RelayerClientConfig, RelayerPublicClient, Keypair, AccountInfo, Call, Intent, SignedIntent, Transfer, SignedAuthorization, EIP712Domain, CreateAccountRequest, ExecuteIntentRequest, PrepareIntentRequest, BatchIntentsRequest, CreateAccountResponse, ExecuteIntentResponse, PrepareIntentResponse, BatchIntentsResponse, HealthResponse, GetNonceResponse, FunderBalanceResponse, CapabilitiesResponse, BundleStatusResponse, } from './types';
50
+ export { INTENT_TYPES, FUNDING_TYPES } from './types';
51
+ export { getChain, isKnownChain, getKnownChainIds } from './chains';
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC,OAAO,EACH,WAAW,EACX,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,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