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