@jack-kernel/sdk 1.2.1 → 1.2.2
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 +128 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# JACK TypeScript SDK
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@jack/sdk)
|
|
3
|
+
[](https://www.npmjs.com/package/@jack-kernel/sdk)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
6
|
TypeScript SDK for the JACK cross-chain execution kernel. Provides a comprehensive, type-safe interface for creating and managing cross-chain intents, tracking execution, and monitoring costs.
|
|
@@ -14,17 +14,19 @@ TypeScript SDK for the JACK cross-chain execution kernel. Provides a comprehensi
|
|
|
14
14
|
- 🚀 **Batch Operations**: Submit and track multiple intents efficiently
|
|
15
15
|
- 🛡️ **Error Handling**: Detailed error types with context for debugging
|
|
16
16
|
- 📦 **Dual Module Support**: Works with both ESM and CommonJS
|
|
17
|
+
- 🌐 **Dual Provider Support**: LI.FI for DEX aggregation + Yellow Network for state channels
|
|
18
|
+
- ⚡ **Cross-Chain Routing**: Seamless token swaps across Arbitrum, Optimism, Base, and Polygon
|
|
17
19
|
|
|
18
20
|
## Installation
|
|
19
21
|
|
|
20
22
|
```bash
|
|
21
|
-
npm install @jack/sdk
|
|
23
|
+
npm install @jack-kernel/sdk
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
Or with pnpm:
|
|
25
27
|
|
|
26
28
|
```bash
|
|
27
|
-
pnpm add @jack/sdk
|
|
29
|
+
pnpm add @jack-kernel/sdk
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
### Peer Dependencies
|
|
@@ -35,12 +37,21 @@ The SDK requires `viem` for EIP-712 signing:
|
|
|
35
37
|
npm install viem
|
|
36
38
|
```
|
|
37
39
|
|
|
40
|
+
### Optional Dependencies
|
|
41
|
+
|
|
42
|
+
For LI.FI cross-chain routing (included by default):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Already included as a dependency
|
|
46
|
+
@lifi/sdk
|
|
47
|
+
```
|
|
48
|
+
|
|
38
49
|
## Quick Start
|
|
39
50
|
|
|
40
51
|
### Basic Usage
|
|
41
52
|
|
|
42
53
|
```typescript
|
|
43
|
-
import { JACK_SDK } from '@jack/sdk';
|
|
54
|
+
import { JACK_SDK } from '@jack-kernel/sdk';
|
|
44
55
|
|
|
45
56
|
// Initialize the SDK
|
|
46
57
|
const sdk = new JACK_SDK({
|
|
@@ -73,10 +84,92 @@ const intent = await sdk.waitForSettlement(intentId);
|
|
|
73
84
|
console.log('Settlement tx:', intent.settlementTx);
|
|
74
85
|
```
|
|
75
86
|
|
|
87
|
+
### LI.FI Integration (Cross-Chain Routing)
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { JACK_SDK } from '@jack-kernel/sdk';
|
|
91
|
+
|
|
92
|
+
// Initialize with LI.FI support
|
|
93
|
+
const sdk = new JACK_SDK({
|
|
94
|
+
baseUrl: 'https://api.jack.example',
|
|
95
|
+
lifi: {
|
|
96
|
+
integrator: 'jackkernel',
|
|
97
|
+
maxRetries: 3
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Get cross-chain quote
|
|
102
|
+
const quote = await sdk.getLifiQuote({
|
|
103
|
+
sourceChain: 'arbitrum',
|
|
104
|
+
destinationChain: 'optimism',
|
|
105
|
+
tokenIn: 'USDC',
|
|
106
|
+
tokenOut: 'WETH',
|
|
107
|
+
amountIn: '100',
|
|
108
|
+
minAmountOut: '0.035',
|
|
109
|
+
deadline: Date.now() + 3600000
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
console.log(`Quote: ${quote.quote.amountOut} WETH`);
|
|
113
|
+
console.log(`Provider: ${quote.provider}`); // 'lifi' or 'fallback'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Yellow Network Integration (State Channels)
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { JACK_SDK } from '@jack-kernel/sdk';
|
|
120
|
+
|
|
121
|
+
// Initialize with Yellow Network support
|
|
122
|
+
const sdk = new JACK_SDK({
|
|
123
|
+
baseUrl: 'https://api.jack.example',
|
|
124
|
+
yellow: {
|
|
125
|
+
custodyAddress: '0x...',
|
|
126
|
+
adjudicatorAddress: '0x...',
|
|
127
|
+
chainId: 1,
|
|
128
|
+
walletClient: myWalletClient
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Create state channel
|
|
133
|
+
const channel = await sdk.yellow?.createChannel({
|
|
134
|
+
counterparty: '0x...',
|
|
135
|
+
asset: '0xUSDC...',
|
|
136
|
+
amount: '1000000'
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.log('Channel created:', channel.channelId);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Dual Provider Architecture
|
|
143
|
+
|
|
144
|
+
Both LI.FI and Yellow Network work together:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const sdk = new JACK_SDK({
|
|
148
|
+
baseUrl: 'https://api.jack.example',
|
|
149
|
+
|
|
150
|
+
// Yellow Network for state channels
|
|
151
|
+
yellow: {
|
|
152
|
+
custodyAddress: '0x...',
|
|
153
|
+
adjudicatorAddress: '0x...',
|
|
154
|
+
chainId: 1,
|
|
155
|
+
walletClient: myWalletClient
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// LI.FI for cross-chain routing
|
|
159
|
+
lifi: {
|
|
160
|
+
integrator: 'jackkernel'
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Use both providers
|
|
165
|
+
await sdk.yellow?.createChannel(...);
|
|
166
|
+
await sdk.lifi?.fetchQuote(...);
|
|
167
|
+
```
|
|
168
|
+
|
|
76
169
|
### Track Execution Progress
|
|
77
170
|
|
|
78
171
|
```typescript
|
|
79
|
-
import { ExecutionStatus } from '@jack/sdk';
|
|
172
|
+
import { ExecutionStatus } from '@jack-kernel/sdk';
|
|
80
173
|
|
|
81
174
|
// Poll until specific status is reached
|
|
82
175
|
const intent = await sdk.execution.waitForStatus(
|
|
@@ -195,7 +288,7 @@ import {
|
|
|
195
288
|
ValidationError,// Client-side validation failed
|
|
196
289
|
TimeoutError, // Operation timed out
|
|
197
290
|
RetryError // All retry attempts exhausted
|
|
198
|
-
} from '@jack/sdk';
|
|
291
|
+
} from '@jack-kernel/sdk';
|
|
199
292
|
```
|
|
200
293
|
|
|
201
294
|
### Handling Errors
|
|
@@ -310,7 +403,7 @@ subscription.unsubscribe();
|
|
|
310
403
|
Enforce custom policies on intent parameters:
|
|
311
404
|
|
|
312
405
|
```typescript
|
|
313
|
-
import { Policy } from '@jack/sdk';
|
|
406
|
+
import { Policy } from '@jack-kernel/sdk';
|
|
314
407
|
|
|
315
408
|
const policy: Policy = {
|
|
316
409
|
maxAmountIn: '1000000000', // Max 1000 USDC
|
|
@@ -452,14 +545,28 @@ import type {
|
|
|
452
545
|
ExecutionWatcher,
|
|
453
546
|
|
|
454
547
|
// Policy Types
|
|
455
|
-
Policy
|
|
456
|
-
|
|
548
|
+
Policy,
|
|
549
|
+
|
|
550
|
+
// LI.FI Types
|
|
551
|
+
LifiProvider,
|
|
552
|
+
LifiConfig,
|
|
553
|
+
LifiQuotePayload,
|
|
554
|
+
LifiRoutePayload,
|
|
555
|
+
LifiStatusPayload,
|
|
556
|
+
|
|
557
|
+
// Yellow Network Types
|
|
558
|
+
YellowProvider,
|
|
559
|
+
YellowConfig,
|
|
560
|
+
ChannelState,
|
|
561
|
+
YellowQuote,
|
|
562
|
+
ClearingResult
|
|
563
|
+
} from '@jack-kernel/sdk';
|
|
457
564
|
```
|
|
458
565
|
|
|
459
566
|
### Type-Safe Intent Creation
|
|
460
567
|
|
|
461
568
|
```typescript
|
|
462
|
-
import type { IntentParams } from '@jack/sdk';
|
|
569
|
+
import type { IntentParams } from '@jack-kernel/sdk';
|
|
463
570
|
|
|
464
571
|
function createIntent(
|
|
465
572
|
sourceChain: string,
|
|
@@ -481,7 +588,7 @@ function createIntent(
|
|
|
481
588
|
### Type Guards
|
|
482
589
|
|
|
483
590
|
```typescript
|
|
484
|
-
import { ExecutionStatus } from '@jack/sdk';
|
|
591
|
+
import { ExecutionStatus } from '@jack-kernel/sdk';
|
|
485
592
|
|
|
486
593
|
function isTerminalStatus(status: ExecutionStatus): boolean {
|
|
487
594
|
return [
|
|
@@ -612,7 +719,7 @@ class AgentUtils {
|
|
|
612
719
|
### Complete Intent Lifecycle
|
|
613
720
|
|
|
614
721
|
```typescript
|
|
615
|
-
import { JACK_SDK, ExecutionStatus } from '@jack/sdk';
|
|
722
|
+
import { JACK_SDK, ExecutionStatus } from '@jack-kernel/sdk';
|
|
616
723
|
|
|
617
724
|
async function executeIntent() {
|
|
618
725
|
const sdk = new JACK_SDK({ baseUrl: 'https://api.jack.example' });
|
|
@@ -671,7 +778,7 @@ async function executeIntent() {
|
|
|
671
778
|
### Agent with Batch Processing
|
|
672
779
|
|
|
673
780
|
```typescript
|
|
674
|
-
import { JACK_SDK } from '@jack/sdk';
|
|
781
|
+
import { JACK_SDK } from '@jack-kernel/sdk';
|
|
675
782
|
|
|
676
783
|
async function processIntentBatch(intentRequests: IntentRequest[]) {
|
|
677
784
|
const sdk = new JACK_SDK({ baseUrl: 'https://api.jack.example' });
|
|
@@ -721,9 +828,9 @@ If you're upgrading from an older version of the SDK:
|
|
|
721
828
|
import JACK_SDK from '@jack/sdk';
|
|
722
829
|
|
|
723
830
|
// New (both work)
|
|
724
|
-
import { JACK_SDK } from '@jack/sdk';
|
|
831
|
+
import { JACK_SDK } from '@jack-kernel/sdk';
|
|
725
832
|
// or
|
|
726
|
-
import JACK_SDK from '@jack/sdk';
|
|
833
|
+
import JACK_SDK from '@jack-kernel/sdk';
|
|
727
834
|
```
|
|
728
835
|
|
|
729
836
|
### Method Changes
|
|
@@ -748,10 +855,12 @@ MIT © JACK Team
|
|
|
748
855
|
|
|
749
856
|
## Support
|
|
750
857
|
|
|
751
|
-
- **Documentation**: [
|
|
752
|
-
- **
|
|
753
|
-
- **
|
|
858
|
+
- **Documentation**: [https://jack.hashpass.tech/docs](https://jack.hashpass.tech/docs)
|
|
859
|
+
- **Repository**: [https://github.com/hashpass-tech/JACK](https://github.com/hashpass-tech/JACK)
|
|
860
|
+
- **Issues**: [GitHub Issues](https://github.com/hashpass-tech/JACK/issues)
|
|
861
|
+
- **Discord**: [Join our community](https://discord.gg/7k8CdmYHpn)
|
|
862
|
+
- **X (Twitter)**: [@Jack_kernel](https://x.com/Jack_kernel)
|
|
754
863
|
|
|
755
864
|
## Changelog
|
|
756
865
|
|
|
757
|
-
See [CHANGELOG.md](
|
|
866
|
+
See [CHANGELOG.md](../../CHANGELOG.md) for release history and migration guides.
|