@jack-kernel/sdk 1.0.0
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 +757 -0
- package/dist/cjs/agent.js +321 -0
- package/dist/cjs/agent.js.map +1 -0
- package/dist/cjs/cache.js +58 -0
- package/dist/cjs/cache.js.map +1 -0
- package/dist/cjs/client.js +196 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/costs.js +104 -0
- package/dist/cjs/costs.js.map +1 -0
- package/dist/cjs/errors.js +287 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/execution.js +385 -0
- package/dist/cjs/execution.js.map +1 -0
- package/dist/cjs/index.js +256 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/intents.js +185 -0
- package/dist/cjs/intents.js.map +1 -0
- package/dist/cjs/serialization.js +164 -0
- package/dist/cjs/serialization.js.map +1 -0
- package/dist/cjs/types.js +31 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/validation.js +114 -0
- package/dist/cjs/validation.js.map +1 -0
- package/dist/esm/agent.js +317 -0
- package/dist/esm/agent.js.map +1 -0
- package/dist/esm/cache.js +54 -0
- package/dist/esm/cache.js.map +1 -0
- package/dist/esm/client.js +192 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/costs.js +100 -0
- package/dist/esm/costs.js.map +1 -0
- package/dist/esm/errors.js +278 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/execution.js +381 -0
- package/dist/esm/execution.js.map +1 -0
- package/dist/esm/index.js +236 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/intents.js +181 -0
- package/dist/esm/intents.js.map +1 -0
- package/dist/esm/serialization.js +159 -0
- package/dist/esm/serialization.js.map +1 -0
- package/dist/esm/types.js +28 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/validation.js +111 -0
- package/dist/esm/validation.js.map +1 -0
- package/dist/types/agent.d.ts +171 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/cache.d.ts +25 -0
- package/dist/types/cache.d.ts.map +1 -0
- package/dist/types/client.d.ts +46 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/costs.d.ts +91 -0
- package/dist/types/costs.d.ts.map +1 -0
- package/dist/types/errors.d.ts +242 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/execution.d.ts +145 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/index.d.ts +205 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/intents.d.ts +158 -0
- package/dist/types/intents.d.ts.map +1 -0
- package/dist/types/serialization.d.ts +82 -0
- package/dist/types/serialization.d.ts.map +1 -0
- package/dist/types/types.d.ts +302 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/validation.d.ts +40 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
export type { IntentParams, Intent, ExecutionStep, Quote, RouteStep, CostEntry, IssueCost, CostsResponse, ClientConfig, RequestOptions, PollOptions, BatchSubmitResult, DryRunResult, ValidationResult, EIP712Domain, TypedData, Subscription, ExecutionWatcher, Policy } from './types.js';
|
|
2
|
+
export { ExecutionStatus } from './types.js';
|
|
3
|
+
export { JackError, NetworkError, APIError, ValidationError, TimeoutError, RetryError } from './errors.js';
|
|
4
|
+
export { getTypedData, serializeIntentParams, parseIntentParams } from './serialization.js';
|
|
5
|
+
export { validateIntentParams } from './validation.js';
|
|
6
|
+
export { IntentManager } from './intents.js';
|
|
7
|
+
export { ExecutionTracker } from './execution.js';
|
|
8
|
+
export { CostTracker } from './costs.js';
|
|
9
|
+
export { AgentUtils } from './agent.js';
|
|
10
|
+
export { JackClient } from './client.js';
|
|
11
|
+
import { IntentManager } from './intents.js';
|
|
12
|
+
import { ExecutionTracker } from './execution.js';
|
|
13
|
+
import { CostTracker } from './costs.js';
|
|
14
|
+
import { AgentUtils } from './agent.js';
|
|
15
|
+
import { type ClientConfig, type IntentParams, type Intent } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Main SDK class for JACK cross-chain execution kernel
|
|
18
|
+
*
|
|
19
|
+
* Provides a comprehensive, type-safe interface for interacting with the JACK system.
|
|
20
|
+
* Initializes all managers (intents, execution, costs, agent) and exposes them as
|
|
21
|
+
* public readonly properties. Also provides convenience methods for common operations.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Initialize SDK
|
|
26
|
+
* const sdk = new JACK_SDK({ baseUrl: 'https://api.jack.example' });
|
|
27
|
+
*
|
|
28
|
+
* // Create and submit intent
|
|
29
|
+
* const typedData = sdk.intents.getTypedData(params);
|
|
30
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
31
|
+
* const intentId = await sdk.submitIntent(params, signature);
|
|
32
|
+
*
|
|
33
|
+
* // Track execution
|
|
34
|
+
* const intent = await sdk.waitForSettlement(intentId);
|
|
35
|
+
* console.log('Settlement tx:', intent.settlementTx);
|
|
36
|
+
*
|
|
37
|
+
* // Access managers directly
|
|
38
|
+
* const costs = await sdk.costs.getCosts();
|
|
39
|
+
* const results = await sdk.agent.batchSubmit([...]);
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* **Validates: Requirements 1.1, 1.2, 1.3, 1.4, 2.5**
|
|
43
|
+
*/
|
|
44
|
+
export declare class JACK_SDK {
|
|
45
|
+
/**
|
|
46
|
+
* Intent management - create, submit, query intents
|
|
47
|
+
*/
|
|
48
|
+
readonly intents: IntentManager;
|
|
49
|
+
/**
|
|
50
|
+
* Execution tracking - poll status, wait for completion
|
|
51
|
+
*/
|
|
52
|
+
readonly execution: ExecutionTracker;
|
|
53
|
+
/**
|
|
54
|
+
* Cost tracking - query costs and budgets
|
|
55
|
+
*/
|
|
56
|
+
readonly costs: CostTracker;
|
|
57
|
+
/**
|
|
58
|
+
* Agent utilities - batch operations, subscriptions
|
|
59
|
+
*/
|
|
60
|
+
readonly agent: AgentUtils;
|
|
61
|
+
/**
|
|
62
|
+
* Internal HTTP client (exposed for advanced use cases)
|
|
63
|
+
*/
|
|
64
|
+
private readonly client;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new JACK_SDK instance
|
|
67
|
+
*
|
|
68
|
+
* Initializes all managers with the provided configuration. The configuration
|
|
69
|
+
* includes the base URL for the API and optional settings for timeout, retries,
|
|
70
|
+
* caching, and custom headers.
|
|
71
|
+
*
|
|
72
|
+
* @param config - Client configuration (baseUrl required, other options optional)
|
|
73
|
+
* @throws ValidationError if configuration is invalid
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // Basic initialization
|
|
78
|
+
* const sdk = new JACK_SDK({ baseUrl: 'https://api.jack.example' });
|
|
79
|
+
*
|
|
80
|
+
* // With custom configuration
|
|
81
|
+
* const sdk = new JACK_SDK({
|
|
82
|
+
* baseUrl: 'https://api.jack.example',
|
|
83
|
+
* timeout: 60000,
|
|
84
|
+
* maxRetries: 5,
|
|
85
|
+
* enableCache: true,
|
|
86
|
+
* cacheTTL: 120000,
|
|
87
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
constructor(config: ClientConfig);
|
|
92
|
+
/**
|
|
93
|
+
* Convenience method: Submit a signed intent
|
|
94
|
+
*
|
|
95
|
+
* Delegates to IntentManager.submit(). This is a convenience method
|
|
96
|
+
* for the most common operation - submitting a signed intent.
|
|
97
|
+
*
|
|
98
|
+
* @param params - Intent parameters
|
|
99
|
+
* @param signature - EIP-712 signature from wallet
|
|
100
|
+
* @returns Promise resolving to the intent ID
|
|
101
|
+
* @throws ValidationError if parameters are invalid
|
|
102
|
+
* @throws APIError if the API returns an error
|
|
103
|
+
* @throws NetworkError if the network request fails
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const intentId = await sdk.submitIntent(params, signature);
|
|
108
|
+
* console.log('Intent submitted:', intentId);
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* **Validates: Requirement 1.2**
|
|
112
|
+
*/
|
|
113
|
+
submitIntent(params: IntentParams, signature: string): Promise<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Convenience method: Get a single intent by ID
|
|
116
|
+
*
|
|
117
|
+
* Delegates to IntentManager.get(). This is a convenience method
|
|
118
|
+
* for querying a single intent's current state.
|
|
119
|
+
*
|
|
120
|
+
* @param intentId - The intent ID to query
|
|
121
|
+
* @returns Promise resolving to the complete Intent object
|
|
122
|
+
* @throws APIError if the intent is not found or other API error
|
|
123
|
+
* @throws NetworkError if the network request fails
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const intent = await sdk.getIntent('JK-ABC123456');
|
|
128
|
+
* console.log('Status:', intent.status);
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* **Validates: Requirement 1.3**
|
|
132
|
+
*/
|
|
133
|
+
getIntent(intentId: string): Promise<Intent>;
|
|
134
|
+
/**
|
|
135
|
+
* Convenience method: List all intents
|
|
136
|
+
*
|
|
137
|
+
* Delegates to IntentManager.list(). This is a convenience method
|
|
138
|
+
* for retrieving all intents.
|
|
139
|
+
*
|
|
140
|
+
* @returns Promise resolving to an array of Intent objects
|
|
141
|
+
* @throws APIError if the API returns an error
|
|
142
|
+
* @throws NetworkError if the network request fails
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const intents = await sdk.listIntents();
|
|
147
|
+
* console.log(`Found ${intents.length} intents`);
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* **Validates: Requirement 1.4**
|
|
151
|
+
*/
|
|
152
|
+
listIntents(): Promise<Intent[]>;
|
|
153
|
+
/**
|
|
154
|
+
* Convenience method: Wait for intent to settle
|
|
155
|
+
*
|
|
156
|
+
* Polls the intent status until it reaches SETTLED status or the timeout
|
|
157
|
+
* is exceeded. This is a convenience method that wraps ExecutionTracker.waitForStatus()
|
|
158
|
+
* with sensible defaults for waiting for settlement.
|
|
159
|
+
*
|
|
160
|
+
* @param intentId - The intent ID to wait for
|
|
161
|
+
* @param timeout - Maximum time to wait in milliseconds (default: 120000 = 2 minutes)
|
|
162
|
+
* @returns Promise resolving to the Intent when settled
|
|
163
|
+
* @throws TimeoutError if timeout is exceeded before settlement
|
|
164
|
+
* @throws APIError if the API returns an error
|
|
165
|
+
* @throws NetworkError if the network request fails
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* // Wait with default timeout (2 minutes)
|
|
170
|
+
* const intent = await sdk.waitForSettlement('JK-ABC123456');
|
|
171
|
+
* console.log('Settlement tx:', intent.settlementTx);
|
|
172
|
+
*
|
|
173
|
+
* // Wait with custom timeout (5 minutes)
|
|
174
|
+
* const intent = await sdk.waitForSettlement('JK-ABC123456', 300000);
|
|
175
|
+
* ```
|
|
176
|
+
*
|
|
177
|
+
* **Validates: Requirement 2.5**
|
|
178
|
+
*/
|
|
179
|
+
waitForSettlement(intentId: string, timeout?: number): Promise<Intent>;
|
|
180
|
+
/**
|
|
181
|
+
* Legacy method: Get execution status
|
|
182
|
+
*
|
|
183
|
+
* @deprecated Use sdk.getIntent() or sdk.execution.getStatus() instead
|
|
184
|
+
*
|
|
185
|
+
* This method is kept for backward compatibility with existing dashboard code.
|
|
186
|
+
* It delegates to the execution tracker's getStatus method.
|
|
187
|
+
*
|
|
188
|
+
* @param intentId - The intent ID to query
|
|
189
|
+
* @returns Promise resolving to the Intent object
|
|
190
|
+
*/
|
|
191
|
+
getExecutionStatus(intentId: string): Promise<Intent>;
|
|
192
|
+
/**
|
|
193
|
+
* Legacy method: Get intent typed data
|
|
194
|
+
*
|
|
195
|
+
* @deprecated Use sdk.intents.getTypedData() instead
|
|
196
|
+
*
|
|
197
|
+
* This method is kept for backward compatibility with existing dashboard code.
|
|
198
|
+
* It delegates to the intent manager's getTypedData method.
|
|
199
|
+
*
|
|
200
|
+
* @param params - Intent parameters
|
|
201
|
+
* @returns EIP-712 TypedData object
|
|
202
|
+
*/
|
|
203
|
+
getIntentTypedData(params: IntentParams): import("./types.js").TypedData;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,YAAY,EACZ,MAAM,EACN,aAAa,EAEb,KAAK,EACL,SAAS,EAET,SAAS,EACT,SAAS,EACT,aAAa,EAEb,YAAY,EACZ,cAAc,EACd,WAAW,EAEX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,YAAY,EACZ,SAAS,EAET,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACP,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,QAAQ;IACnB;;OAEG;IACH,SAAgB,OAAO,EAAE,aAAa,CAAC;IAEvC;;OAEG;IACH,SAAgB,SAAS,EAAE,gBAAgB,CAAC;IAE5C;;OAEG;IACH,SAAgB,KAAK,EAAE,WAAW,CAAC;IAEnC;;OAEG;IACH,SAAgB,KAAK,EAAE,UAAU,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;gBACS,MAAM,EAAE,YAAY;IAWhC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI5E;;;;;;;;;;;;;;;;;;OAkBG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAQpF;;;;;;;;;;OAUG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3D;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY;CAGxC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent management for the JACK SDK
|
|
3
|
+
*
|
|
4
|
+
* This module provides the IntentManager class for creating, submitting,
|
|
5
|
+
* and querying intents through the JACK API.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 1.1, 1.2, 1.3, 1.4
|
|
8
|
+
*/
|
|
9
|
+
import type { IntentParams, Intent, TypedData, ValidationResult } from './types.js';
|
|
10
|
+
import type { JackClient } from './client.js';
|
|
11
|
+
/**
|
|
12
|
+
* Manager for intent operations
|
|
13
|
+
*
|
|
14
|
+
* Provides methods to create EIP-712 typed data, validate parameters,
|
|
15
|
+
* submit signed intents, and query intent status.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const client = new JackClient({ baseUrl: 'https://api.jack.example' });
|
|
20
|
+
* const manager = new IntentManager(client);
|
|
21
|
+
*
|
|
22
|
+
* // Create typed data for signing
|
|
23
|
+
* const typedData = manager.getTypedData(params);
|
|
24
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
25
|
+
*
|
|
26
|
+
* // Submit the signed intent
|
|
27
|
+
* const intentId = await manager.submit(params, signature);
|
|
28
|
+
*
|
|
29
|
+
* // Query the intent
|
|
30
|
+
* const intent = await manager.get(intentId);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class IntentManager {
|
|
34
|
+
private readonly client;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new IntentManager
|
|
37
|
+
*
|
|
38
|
+
* @param client - The JackClient instance to use for API requests
|
|
39
|
+
*/
|
|
40
|
+
constructor(client: JackClient);
|
|
41
|
+
/**
|
|
42
|
+
* Get EIP-712 typed data for intent signing
|
|
43
|
+
*
|
|
44
|
+
* Constructs properly formatted EIP-712 TypedData that can be signed
|
|
45
|
+
* by a wallet. This method delegates to the serialization module.
|
|
46
|
+
*
|
|
47
|
+
* @param params - Intent parameters to serialize
|
|
48
|
+
* @param chainId - Chain ID for the domain separator (default: 1)
|
|
49
|
+
* @param verifyingContract - Address of the verifying contract
|
|
50
|
+
* @returns EIP-712 TypedData object ready for signing
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const typedData = manager.getTypedData({
|
|
55
|
+
* sourceChain: 'arbitrum',
|
|
56
|
+
* destinationChain: 'base',
|
|
57
|
+
* tokenIn: '0xUSDC...',
|
|
58
|
+
* tokenOut: '0xWETH...',
|
|
59
|
+
* amountIn: '1000000',
|
|
60
|
+
* minAmountOut: '42000000000000000',
|
|
61
|
+
* deadline: Date.now() + 3600000
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* **Validates: Requirement 1.1**
|
|
68
|
+
*/
|
|
69
|
+
getTypedData(params: IntentParams, chainId?: number, verifyingContract?: `0x${string}`): TypedData;
|
|
70
|
+
/**
|
|
71
|
+
* Validate intent parameters
|
|
72
|
+
*
|
|
73
|
+
* Checks that all required fields are present, amounts are positive,
|
|
74
|
+
* deadline is in the future, and addresses are valid format.
|
|
75
|
+
* This method delegates to the validation module.
|
|
76
|
+
*
|
|
77
|
+
* @param params - Intent parameters to validate
|
|
78
|
+
* @returns ValidationResult with valid flag and error messages
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const result = manager.validate(params);
|
|
83
|
+
* if (!result.valid) {
|
|
84
|
+
* console.error('Validation errors:', result.errors);
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* **Validates: Requirement 5.4**
|
|
89
|
+
*/
|
|
90
|
+
validate(params: IntentParams): ValidationResult;
|
|
91
|
+
/**
|
|
92
|
+
* Submit a signed intent to the JACK API
|
|
93
|
+
*
|
|
94
|
+
* Validates the intent parameters before submission. If validation fails,
|
|
95
|
+
* throws a ValidationError without making any network request. On success,
|
|
96
|
+
* returns the intent ID.
|
|
97
|
+
*
|
|
98
|
+
* @param params - Intent parameters
|
|
99
|
+
* @param signature - EIP-712 signature from the user's wallet
|
|
100
|
+
* @returns Promise resolving to the intent ID (format: JK-[A-Z0-9]{9})
|
|
101
|
+
* @throws ValidationError if parameters are invalid
|
|
102
|
+
* @throws APIError if the API returns an error
|
|
103
|
+
* @throws NetworkError if the network request fails
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const intentId = await manager.submit(params, signature);
|
|
108
|
+
* console.log('Intent submitted:', intentId); // "JK-ABC123456"
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* **Validates: Requirement 1.2**
|
|
112
|
+
*/
|
|
113
|
+
submit(params: IntentParams, signature: string): Promise<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Get a single intent by ID
|
|
116
|
+
*
|
|
117
|
+
* Queries the JACK API for the complete intent object including
|
|
118
|
+
* current status, execution steps, and settlement transaction (if settled).
|
|
119
|
+
*
|
|
120
|
+
* @param intentId - The intent ID to query (format: JK-[A-Z0-9]{9})
|
|
121
|
+
* @returns Promise resolving to the complete Intent object
|
|
122
|
+
* @throws APIError if the intent is not found (404) or other API error
|
|
123
|
+
* @throws NetworkError if the network request fails
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const intent = await manager.get('JK-ABC123456');
|
|
128
|
+
* console.log('Status:', intent.status);
|
|
129
|
+
* console.log('Settlement tx:', intent.settlementTx);
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* **Validates: Requirement 1.3**
|
|
133
|
+
*/
|
|
134
|
+
get(intentId: string): Promise<Intent>;
|
|
135
|
+
/**
|
|
136
|
+
* List all intents
|
|
137
|
+
*
|
|
138
|
+
* Queries the JACK API for all intents. The API may implement pagination
|
|
139
|
+
* or filtering in the future, but currently returns all intents.
|
|
140
|
+
*
|
|
141
|
+
* @returns Promise resolving to an array of Intent objects
|
|
142
|
+
* @throws APIError if the API returns an error
|
|
143
|
+
* @throws NetworkError if the network request fails
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const intents = await manager.list();
|
|
148
|
+
* console.log(`Found ${intents.length} intents`);
|
|
149
|
+
* intents.forEach(intent => {
|
|
150
|
+
* console.log(`${intent.id}: ${intent.status}`);
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* **Validates: Requirement 1.4**
|
|
155
|
+
*/
|
|
156
|
+
list(): Promise<Intent[]>;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=intents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/intents.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC;;;;OAIG;gBACS,MAAM,EAAE,UAAU;IAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,YAAY,CACV,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,MAAU,EACnB,iBAAiB,GAAE,KAAK,MAAM,EAAiD,GAC9E,SAAS;IAIZ;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB;IAIhD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBtE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI5C;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGhC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EIP-712 serialization for JACK intents
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to construct EIP-712 typed data for intent signing.
|
|
5
|
+
* The typed data follows the EIP-712 standard for structured data hashing and signing.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 1.1, 14.1
|
|
8
|
+
*/
|
|
9
|
+
import type { IntentParams, TypedData } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get EIP-712 typed data for an intent
|
|
12
|
+
*
|
|
13
|
+
* Constructs a properly formatted EIP-712 TypedData object that can be used
|
|
14
|
+
* with wallet signing methods (e.g., eth_signTypedData_v4). The typed data
|
|
15
|
+
* includes the domain separator, type definitions, and the intent message.
|
|
16
|
+
*
|
|
17
|
+
* @param params - Intent parameters to serialize
|
|
18
|
+
* @param chainId - Chain ID for the domain separator (default: 1 for Ethereum mainnet)
|
|
19
|
+
* @param verifyingContract - Address of the verifying contract
|
|
20
|
+
* @returns EIP-712 TypedData object ready for signing
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const params = {
|
|
25
|
+
* sourceChain: 'arbitrum',
|
|
26
|
+
* destinationChain: 'base',
|
|
27
|
+
* tokenIn: '0xUSDC...',
|
|
28
|
+
* tokenOut: '0xWETH...',
|
|
29
|
+
* amountIn: '1000000',
|
|
30
|
+
* minAmountOut: '42000000000000000',
|
|
31
|
+
* deadline: Date.now() + 3600000
|
|
32
|
+
* };
|
|
33
|
+
*
|
|
34
|
+
* const typedData = getTypedData(
|
|
35
|
+
* params,
|
|
36
|
+
* 1,
|
|
37
|
+
* '0x1234567890123456789012345678901234567890'
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* // Sign with wallet
|
|
41
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Validates: Requirements 1.1, 14.1
|
|
45
|
+
*/
|
|
46
|
+
export declare function getTypedData(params: IntentParams, chainId?: number, verifyingContract?: `0x${string}`): TypedData;
|
|
47
|
+
/**
|
|
48
|
+
* Serialize intent parameters to a consistent string representation
|
|
49
|
+
*
|
|
50
|
+
* This function is useful for generating cache keys, logging, or debugging.
|
|
51
|
+
* It produces a deterministic string representation of the intent parameters.
|
|
52
|
+
*
|
|
53
|
+
* @param params - Intent parameters to serialize
|
|
54
|
+
* @returns JSON string representation of the parameters
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const params = { sourceChain: 'arbitrum', ... };
|
|
59
|
+
* const serialized = serializeIntentParams(params);
|
|
60
|
+
* console.log(serialized); // {"sourceChain":"arbitrum",...}
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function serializeIntentParams(params: IntentParams): string;
|
|
64
|
+
/**
|
|
65
|
+
* Parse a serialized intent parameters string back to IntentParams
|
|
66
|
+
*
|
|
67
|
+
* This is the inverse of serializeIntentParams(). It parses a JSON string
|
|
68
|
+
* back into an IntentParams object.
|
|
69
|
+
*
|
|
70
|
+
* @param serialized - JSON string representation of intent parameters
|
|
71
|
+
* @returns Parsed IntentParams object
|
|
72
|
+
* @throws Error if the string cannot be parsed or is missing required fields
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const serialized = '{"sourceChain":"arbitrum",...}';
|
|
77
|
+
* const params = parseIntentParams(serialized);
|
|
78
|
+
* console.log(params.sourceChain); // 'arbitrum'
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function parseIntentParams(serialized: string): IntentParams;
|
|
82
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,MAAU,EACnB,iBAAiB,GAAE,KAAK,MAAM,EAAiD,GAC9E,SAAS,CA0CX;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAclE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CA4BlE"}
|