@chainrails/sdk 0.0.3 → 0.0.5
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 +618 -0
- package/dist/chainrails-sdk.es.js +56 -37
- package/dist/chainrails-sdk.es.mjs +56 -37
- package/dist/chainrails-sdk.umd.js +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/src/Chains/index.d.ts +6 -0
- package/dist/src/Chains/index.d.ts.map +1 -0
- package/dist/src/Chains/types.d.ts +6 -0
- package/dist/src/Chains/types.d.ts.map +1 -0
- package/dist/src/Intents/index.d.ts +2 -1
- package/dist/src/Intents/index.d.ts.map +1 -1
- package/dist/src/Intents/types.d.ts +1 -48
- package/dist/src/Intents/types.d.ts.map +1 -1
- package/dist/src/Quotes/index.d.ts +4 -1
- package/dist/src/Quotes/index.d.ts.map +1 -1
- package/dist/src/Quotes/types.d.ts +45 -16
- package/dist/src/Quotes/types.d.ts.map +1 -1
- package/dist/src/Router/index.d.ts +2 -1
- package/dist/src/Router/index.d.ts.map +1 -1
- package/dist/src/Router/types.d.ts +1 -1
- package/dist/src/Router/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +52 -0
- package/dist/src/types.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/src/index.d.ts +0 -12
- package/dist/src/index.d.ts.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
# @chainrails/sdk
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with the Chainrails API - enabling seamless cross-chain token transfers, bridge routing, and intent management across multiple blockchain networks.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔗 **Cross-Chain Transfers** - Facilitate token transfers between multiple blockchain networks
|
|
8
|
+
- 🌉 **Bridge Routing** - Find optimal routes and pricing across multiple bridge protocols
|
|
9
|
+
- 💰 **Quote Management** - Get real-time quotes from various bridge providers
|
|
10
|
+
- 📋 **Intent Management** - Create and manage cross-chain transfer intents
|
|
11
|
+
- ⛓️ **Chain Support** - Support for 11+ blockchain networks including Ethereum, Arbitrum, Base, Starknet, and more
|
|
12
|
+
- 🔐 **Secure** - API key-based authentication with automatic header injection
|
|
13
|
+
- 📦 **Tree-shakeable** - Built with ES modules for optimal bundle sizes
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @chainrails/sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @chainrails/sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
yarn add @chainrails/sdk
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Initialize the SDK
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import crapi, {Chainrails} from "@chainrails/sdk"
|
|
35
|
+
|
|
36
|
+
// Configure with your API key
|
|
37
|
+
Chainrails.config({
|
|
38
|
+
api_key: "your_api_key_here"
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
// Now use the SDK
|
|
42
|
+
const chains = await crapi.chains.getSupported()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Get Supported Chains
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// Get all supported chains
|
|
49
|
+
const allChains = await crapi.chains.getSupported()
|
|
50
|
+
|
|
51
|
+
// Get only mainnet chains
|
|
52
|
+
const mainnetChains = await crapi.chains.getSupported({ network: "mainnet" })
|
|
53
|
+
|
|
54
|
+
// Get only testnet chains
|
|
55
|
+
const testnetChains = await crapi.chains.getSupported({ network: "testnet" })
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Supported chains include:
|
|
59
|
+
- **Ethereum**: `ETHEREUM_MAINNET`, `ETHEREUM_TESTNET`
|
|
60
|
+
- **Arbitrum**: `ARBITRUM_MAINNET`, `ARBITRUM_TESTNET`
|
|
61
|
+
- **Base**: `BASE_MAINNET`, `BASE_TESTNET`
|
|
62
|
+
- **Avalanche**: `AVALANCHE_MAINNET`, `AVALANCHE_TESTNET`
|
|
63
|
+
- **BSC**: `BSC_MAINNET`
|
|
64
|
+
- **Starknet**: `STARKNET_MAINNET`, `STARKNET_TESTNET`
|
|
65
|
+
|
|
66
|
+
## API Reference
|
|
67
|
+
|
|
68
|
+
### Intents Module
|
|
69
|
+
|
|
70
|
+
Manage cross-chain transfer intents.
|
|
71
|
+
|
|
72
|
+
#### Create Intent
|
|
73
|
+
|
|
74
|
+
Creates a new payment intent with cross-chain transfer parameters.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const intent = await crapi.intents.create({
|
|
78
|
+
sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
|
|
79
|
+
amount: 1000000,
|
|
80
|
+
tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
81
|
+
source_chain: "ETHEREUM_MAINNET",
|
|
82
|
+
destination_chain: "STARKNET_MAINNET",
|
|
83
|
+
recipient: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
84
|
+
refund_address: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
|
|
85
|
+
metadata: {
|
|
86
|
+
orderId: "12345",
|
|
87
|
+
userId: "user-abc"
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Parameters:**
|
|
93
|
+
- `sender` (required): Sender wallet address on the source chain
|
|
94
|
+
- `amount` (required): Amount to transfer in smallest unit (e.g., wei for ETH)
|
|
95
|
+
- `tokenIn` (required): Token address on the source chain
|
|
96
|
+
- `source_chain` (required): Source blockchain network
|
|
97
|
+
- `destination_chain` (required): Destination blockchain network
|
|
98
|
+
- `recipient` (required): Recipient wallet address on the destination chain
|
|
99
|
+
- `refund_address` (optional): Refund address if intent fails (defaults to sender)
|
|
100
|
+
- `metadata` (optional): Additional metadata for the intent
|
|
101
|
+
|
|
102
|
+
**Response:**
|
|
103
|
+
```typescript
|
|
104
|
+
interface Intent {
|
|
105
|
+
id: number
|
|
106
|
+
client_id: string
|
|
107
|
+
sender: string
|
|
108
|
+
initialAmount: number
|
|
109
|
+
fees: number
|
|
110
|
+
totalAmount: number
|
|
111
|
+
tokenIn: string
|
|
112
|
+
tokenOut: string
|
|
113
|
+
intent_address: string
|
|
114
|
+
source_chain: string
|
|
115
|
+
destination_chain: string
|
|
116
|
+
recipient: string
|
|
117
|
+
refund_address: string
|
|
118
|
+
relayer: string
|
|
119
|
+
coordinator: string
|
|
120
|
+
bridger: string
|
|
121
|
+
bridgeExtraData: string
|
|
122
|
+
intent_nonce: number
|
|
123
|
+
intent_status: "PENDING" | "PROCESSING" | "COMPLETED" | "FAILED"
|
|
124
|
+
tx_hash: string | null
|
|
125
|
+
needs_relay: boolean
|
|
126
|
+
expires_at: string
|
|
127
|
+
metadata: object
|
|
128
|
+
created_at: string
|
|
129
|
+
updated_at: string
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Get Intent by ID
|
|
134
|
+
|
|
135
|
+
Retrieves information about a specific intent.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const intent = await crapi.intents.getById("123")
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Get All Client Intents
|
|
142
|
+
|
|
143
|
+
Retrieves all intents for the authenticated client with pagination and filtering.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const intents = await crapi.intents.getAll({
|
|
147
|
+
limit: 50,
|
|
148
|
+
offset: 0,
|
|
149
|
+
status: "PENDING"
|
|
150
|
+
})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Parameters:**
|
|
154
|
+
- `limit` (optional): Number of intents to return (default: 50, max: 100)
|
|
155
|
+
- `offset` (optional): Number of intents to skip (default: 0)
|
|
156
|
+
- `status` (optional): Filter by intent status ("pending", "processing", "completed", "failed")
|
|
157
|
+
|
|
158
|
+
#### Get Intents for Sender
|
|
159
|
+
|
|
160
|
+
Retrieves all intents created by a specific user address.
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
const userIntents = await crapi.intents.getForSender("0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### Get Intent by Address
|
|
167
|
+
|
|
168
|
+
Retrieves an intent using its contract address.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const intent = await crapi.intents.getForAddress("0x4E60e01263E750eD9D087157e19D2480Fd86A900")
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Update Intent Status
|
|
175
|
+
|
|
176
|
+
Updates the status of an existing intent.
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
const updated = await crapi.intents.update("123", {
|
|
180
|
+
status: "COMPLETED"
|
|
181
|
+
})
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Status values:** `"PENDING"`, `"FUNDED"`, `"INITIATED"`, `"COMPLETED"`, `"EXPIRED"`
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### Router Module
|
|
189
|
+
|
|
190
|
+
Find optimal routes and analyze bridge availability for cross-chain transfers.
|
|
191
|
+
|
|
192
|
+
#### Find Optimal Route
|
|
193
|
+
|
|
194
|
+
Analyzes available bridges and returns the optimal route with best pricing.
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const route = await crapi.router.getOptimalRoutes({
|
|
198
|
+
tokenIn: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
|
|
199
|
+
tokenOut: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
|
|
200
|
+
sourceChain: "BASE_MAINNET",
|
|
201
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
202
|
+
amount: "1000000000000000000",
|
|
203
|
+
recipient: "0x742d35cc6634c0532925a3b8d7389d8c5b7cf15b"
|
|
204
|
+
})
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Parameters:**
|
|
208
|
+
- `tokenIn` (required): Input token contract address
|
|
209
|
+
- `tokenOut` (required): Output token contract address
|
|
210
|
+
- `sourceChain` (required): Source blockchain
|
|
211
|
+
- `destinationChain` (required): Destination blockchain
|
|
212
|
+
- `amount` (required): Transfer amount in token units (wei for ETH)
|
|
213
|
+
- `recipient` (optional): Recipient address (required for some bridges like RhinoFi)
|
|
214
|
+
|
|
215
|
+
#### Get All Supported Bridges
|
|
216
|
+
|
|
217
|
+
Returns all bridges and their supported routes.
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
const bridges = await crapi.router.getAllSupportedBridges()
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Supported bridges:** `ACROSS`, `CCTP`, `GATEWAY`, `RHINOFI`
|
|
224
|
+
|
|
225
|
+
#### Get Supported Bridges for Route
|
|
226
|
+
|
|
227
|
+
Returns all bridges that support transfers between specific source and destination chains.
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
const supportedBridges = await crapi.router.getSupportedBridges({
|
|
231
|
+
sourceChain: "BASE_MAINNET",
|
|
232
|
+
destinationChain: "ARBITRUM_MAINNET"
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### Get Supported Routes for Bridge
|
|
237
|
+
|
|
238
|
+
Returns all source/destination chain pairs supported by a specific bridge.
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
const routes = await crapi.router.getSupportedRoutes("ACROSS", {
|
|
242
|
+
sourceChain: "BASE_MAINNET",
|
|
243
|
+
destinationChain: "ARBITRUM_MAINNET"
|
|
244
|
+
})
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### Quotes Module
|
|
250
|
+
|
|
251
|
+
Get real-time quotes for cross-chain transfers from various bridge providers.
|
|
252
|
+
|
|
253
|
+
#### Get Quote from Specific Bridge
|
|
254
|
+
|
|
255
|
+
Retrieves a cross-chain transfer quote from a specific bridge protocol.
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
const quote = await crapi.quotes.getFromSpecificBridge({
|
|
259
|
+
tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
260
|
+
tokenOut: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
261
|
+
sourceChain: "BASE_MAINNET",
|
|
262
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
263
|
+
amount: "10000000",
|
|
264
|
+
bridge: "ACROSS",
|
|
265
|
+
recipient: "0x742d35Cc6635C0532925a3b8D62A7fe7B58123D1"
|
|
266
|
+
})
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Parameters:**
|
|
270
|
+
- `tokenIn` (required): Input token address
|
|
271
|
+
- `tokenOut` (required): Output token address
|
|
272
|
+
- `sourceChain` (required): Source blockchain
|
|
273
|
+
- `destinationChain` (required): Destination blockchain
|
|
274
|
+
- `amount` (required): Amount in token units
|
|
275
|
+
- `bridge` (required): Bridge to use for the quote (`ACROSS`, `CCTP`, `GATEWAY`, `RHINOFI`)
|
|
276
|
+
- `recipient` (optional): Recipient address
|
|
277
|
+
|
|
278
|
+
#### Get Quotes from All Bridges
|
|
279
|
+
|
|
280
|
+
Retrieves quotes from all supported bridge protocols for comparison.
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
const quotes = await crapi.quotes.getFromAllBridges({
|
|
284
|
+
tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
285
|
+
tokenOut: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
286
|
+
sourceChain: "BASE_MAINNET",
|
|
287
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
288
|
+
amount: "10000000",
|
|
289
|
+
excludeBridges: "GATEWAY,CCTP",
|
|
290
|
+
recipient: "0x742d35Cc6635C0532925a3b8D62A7fe7B58123D1"
|
|
291
|
+
})
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Parameters:**
|
|
295
|
+
- `tokenIn` (required): Input token address
|
|
296
|
+
- `tokenOut` (required): Output token address
|
|
297
|
+
- `sourceChain` (required): Source blockchain
|
|
298
|
+
- `destinationChain` (required): Destination blockchain
|
|
299
|
+
- `amount` (required): Amount in token units
|
|
300
|
+
- `excludeBridges` (optional): Comma-separated bridges to exclude
|
|
301
|
+
- `recipient` (optional): Recipient address
|
|
302
|
+
|
|
303
|
+
#### Get Best Quote Across All Bridges
|
|
304
|
+
|
|
305
|
+
Retrieves the best quote (lowest total fee) from all supported bridge protocols.
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
const bestQuote = await crapi.quotes.getBestAcrossBridges({
|
|
309
|
+
tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
310
|
+
tokenOut: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
311
|
+
sourceChain: "BASE_MAINNET",
|
|
312
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
313
|
+
amount: "10000000",
|
|
314
|
+
excludeBridges: "GATEWAY",
|
|
315
|
+
recipient: "0x742d35Cc6635C0532925a3b8D62A7fe7B58123D1"
|
|
316
|
+
})
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### Get Quotes from All Source Chains
|
|
320
|
+
|
|
321
|
+
Shows all options to send money to a specific destination chain, including same-chain transfers.
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
const multiSourceQuotes = await crapi.quotes.getAll({
|
|
325
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
326
|
+
amount: "1.5",
|
|
327
|
+
tokenOut: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
328
|
+
recipient: "0x742d35Cc6635C0532925a3b8D62A7fe7B58123D1"
|
|
329
|
+
})
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Parameters:**
|
|
333
|
+
- `destinationChain` (required): Destination blockchain
|
|
334
|
+
- `amount` (required): Amount in human readable format (supports decimals like "1.5", "100", "0.001")
|
|
335
|
+
- `tokenOut` (required): Output token address
|
|
336
|
+
- `recipient` (optional): Recipient address
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
### Chains Module
|
|
341
|
+
|
|
342
|
+
Retrieve information about supported blockchain networks and tokens.
|
|
343
|
+
|
|
344
|
+
#### Get Supported Chains
|
|
345
|
+
|
|
346
|
+
Retrieves all supported blockchain networks, optionally filtered by network type.
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
// Get all chains
|
|
350
|
+
const allChains = await crapi.chains.getSupported()
|
|
351
|
+
|
|
352
|
+
// Get only mainnet chains
|
|
353
|
+
const mainnetChains = await crapi.chains.getSupported({ network: "mainnet" })
|
|
354
|
+
|
|
355
|
+
// Get only testnet chains
|
|
356
|
+
const testnetChains = await crapi.chains.getSupported({ network: "testnet" })
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### Get Supported Tokens for Chain
|
|
360
|
+
|
|
361
|
+
Retrieves all supported tokens available on a specified blockchain network.
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
const tokens = await crapi.chains.getSupported({
|
|
365
|
+
chain: "BASE_MAINNET"
|
|
366
|
+
})
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
### Client Module
|
|
372
|
+
|
|
373
|
+
Retrieve authenticated client information.
|
|
374
|
+
|
|
375
|
+
#### Get Client Info
|
|
376
|
+
|
|
377
|
+
Retrieves information about the authenticated client.
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
const clientInfo = await crapi.client.getClientInfo()
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Type Definitions
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
// Status types
|
|
389
|
+
type Status = "PENDING" | "FUNDED" | "INITIATED" | "COMPLETED" | "EXPIRED"
|
|
390
|
+
|
|
391
|
+
// Bridge types
|
|
392
|
+
type Bridge = "ACROSS" | "CCTP" | "GATEWAY" | "RHINOFI"
|
|
393
|
+
|
|
394
|
+
// Network types
|
|
395
|
+
type Network = "mainnet" | "testnet"
|
|
396
|
+
|
|
397
|
+
// Supported chains
|
|
398
|
+
type Chain =
|
|
399
|
+
| "ARBITRUM_MAINNET"
|
|
400
|
+
| "ARBITRUM_TESTNET"
|
|
401
|
+
| "AVALANCHE_MAINNET"
|
|
402
|
+
| "AVALANCHE_TESTNET"
|
|
403
|
+
| "BASE_MAINNET"
|
|
404
|
+
| "BASE_TESTNET"
|
|
405
|
+
| "STARKNET_MAINNET"
|
|
406
|
+
| "STARKNET_TESTNET"
|
|
407
|
+
| "BSC_MAINNET"
|
|
408
|
+
| "ETHEREUM_MAINNET"
|
|
409
|
+
| "ETHEREUM_TESTNET"
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Error Handling
|
|
415
|
+
|
|
416
|
+
The SDK uses the `ky` HTTP client which throws errors for failed requests. Wrap SDK calls in try-catch blocks:
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
try {
|
|
420
|
+
const intent = await crapi.intents.create({
|
|
421
|
+
sender: "0x...",
|
|
422
|
+
amount: 1000000,
|
|
423
|
+
tokenIn: "0x...",
|
|
424
|
+
source_chain: "ETHEREUM_MAINNET",
|
|
425
|
+
destination_chain: "ARBITRUM_MAINNET",
|
|
426
|
+
recipient: "0x..."
|
|
427
|
+
})
|
|
428
|
+
} catch (error) {
|
|
429
|
+
if (error instanceof Error) {
|
|
430
|
+
console.error("Failed to create intent:", error.message)
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## Authentication
|
|
438
|
+
|
|
439
|
+
The SDK uses API key-based authentication. Configure your API key once at startup:
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
import { Chainrails } from "@chainrails/sdk"
|
|
443
|
+
|
|
444
|
+
Chainrails.config({
|
|
445
|
+
api_key: process.env.CHAINRAILS_API_KEY
|
|
446
|
+
})
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
The API key is automatically included in all requests via the `Authorization: Bearer` header.
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Configuration
|
|
454
|
+
|
|
455
|
+
### Base URL
|
|
456
|
+
|
|
457
|
+
The SDK defaults to the development API:
|
|
458
|
+
```
|
|
459
|
+
https://dev.chainrails.io/api/v1
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
To use a different endpoint, you can modify the request configuration in `src/req.ts`.
|
|
463
|
+
|
|
464
|
+
### Retry Policy
|
|
465
|
+
|
|
466
|
+
The SDK automatically retries failed requests up to 2 times.
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## Examples
|
|
471
|
+
|
|
472
|
+
### Example 1: Create Intent and Monitor Status
|
|
473
|
+
|
|
474
|
+
```typescript
|
|
475
|
+
import crapi, { Chainrails } from "@chainrails/sdk"
|
|
476
|
+
|
|
477
|
+
Chainrails.config({ api_key: "your_api_key" })
|
|
478
|
+
|
|
479
|
+
const intent = await crapi.intents.create({
|
|
480
|
+
sender: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
|
|
481
|
+
amount: 1000000,
|
|
482
|
+
tokenIn: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
483
|
+
source_chain: "ETHEREUM_MAINNET",
|
|
484
|
+
destination_chain: "ARBITRUM_MAINNET",
|
|
485
|
+
recipient: "0xb79541Be080a59fdcE6C0b43219ba56c725eC65e"
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
console.log("Intent created:", intent.id, intent.intent_status)
|
|
489
|
+
|
|
490
|
+
// Retrieve updated intent
|
|
491
|
+
const updated = await crapi.intents.getById(String(intent.id))
|
|
492
|
+
console.log("Updated status:", updated.intent_status)
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Example 2: Compare Quotes Across Bridges
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
import crapi from "@chainrails/sdk"
|
|
499
|
+
|
|
500
|
+
const quotes = await crapi.quotes.getFromAllBridges({
|
|
501
|
+
tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
502
|
+
tokenOut: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
503
|
+
sourceChain: "BASE_MAINNET",
|
|
504
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
505
|
+
amount: "10000000"
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
// Get the best quote
|
|
509
|
+
const best = await crapi.quotes.getBestAcrossBridges({
|
|
510
|
+
tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
511
|
+
tokenOut: "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
|
|
512
|
+
sourceChain: "BASE_MAINNET",
|
|
513
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
514
|
+
amount: "10000000"
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
console.log("Best quote total fee:", best.bestQuote.totalFeeFormatted)
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### Example 3: Find Optimal Route
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
import crapi from "@chainrails/sdk"
|
|
524
|
+
|
|
525
|
+
const route = await crapi.router.getOptimalRoutes({
|
|
526
|
+
tokenIn: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
|
|
527
|
+
tokenOut: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
|
|
528
|
+
sourceChain: "BASE_MAINNET",
|
|
529
|
+
destinationChain: "ARBITRUM_MAINNET",
|
|
530
|
+
amount: "1000000000000000000"
|
|
531
|
+
})
|
|
532
|
+
|
|
533
|
+
console.log("Optimal route:", route)
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### Example 4: List All User Intents
|
|
537
|
+
|
|
538
|
+
```typescript
|
|
539
|
+
import crapi from "@chainrails/sdk"
|
|
540
|
+
|
|
541
|
+
const userAddress = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
|
|
542
|
+
const intents = await crapi.intents.getForSender(userAddress)
|
|
543
|
+
|
|
544
|
+
intents.forEach(intent => {
|
|
545
|
+
console.log(`Intent ${intent.id}:`, {
|
|
546
|
+
status: intent.intent_status,
|
|
547
|
+
amount: intent.totalAmount,
|
|
548
|
+
from: intent.source_chain,
|
|
549
|
+
to: intent.destination_chain,
|
|
550
|
+
created: intent.created_at
|
|
551
|
+
})
|
|
552
|
+
})
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## Development
|
|
558
|
+
|
|
559
|
+
### Build
|
|
560
|
+
|
|
561
|
+
```bash
|
|
562
|
+
pnpm run build
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### Type Checking
|
|
566
|
+
|
|
567
|
+
```bash
|
|
568
|
+
pnpm run check-types
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### Linting
|
|
572
|
+
|
|
573
|
+
```bash
|
|
574
|
+
pnpm run lint
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Clean
|
|
578
|
+
|
|
579
|
+
```bash
|
|
580
|
+
pnpm run clean
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
## Browser Support
|
|
586
|
+
|
|
587
|
+
The SDK works in modern browsers that support:
|
|
588
|
+
- ES2020+ features
|
|
589
|
+
- Fetch API
|
|
590
|
+
- LocalStorage/SessionStorage
|
|
591
|
+
|
|
592
|
+
For older browser support, use appropriate transpilation with your bundler.
|
|
593
|
+
|
|
594
|
+
---
|
|
595
|
+
|
|
596
|
+
## API Documentation
|
|
597
|
+
|
|
598
|
+
For complete API documentation, visit:
|
|
599
|
+
https://dev.chainrails.io/api/v1
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## License
|
|
604
|
+
|
|
605
|
+
MIT
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## Support
|
|
610
|
+
|
|
611
|
+
For issues, questions, or feature requests, please visit:
|
|
612
|
+
https://github.com/horuslabsio/chainrails-sdk
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## Changelog
|
|
617
|
+
|
|
618
|
+
See [CHANGELOG.md](./CHANGELOG.md) for version history and updates.
|
|
@@ -1,89 +1,108 @@
|
|
|
1
1
|
import n from "ky";
|
|
2
|
-
|
|
2
|
+
var i = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(i || {}), o = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(o || {});
|
|
3
|
+
class a {
|
|
3
4
|
constructor({ api_key: e }) {
|
|
4
5
|
this.api_key = e;
|
|
5
6
|
}
|
|
6
7
|
static config(e) {
|
|
7
|
-
if (!
|
|
8
|
+
if (!a.app) {
|
|
8
9
|
if (!e)
|
|
9
10
|
throw new Error("Please provide an api_key");
|
|
10
|
-
|
|
11
|
+
a.app = new a(e);
|
|
11
12
|
}
|
|
12
|
-
return e && (this.app.api_key = e.api_key),
|
|
13
|
+
return e && (this.app.api_key = e.api_key), a.app;
|
|
13
14
|
}
|
|
14
15
|
static getApiKey() {
|
|
15
|
-
return
|
|
16
|
+
return a.app.api_key;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
+
const s = n.create({
|
|
19
20
|
prefixUrl: "https://dev.chainrails.io/api/v1",
|
|
20
21
|
headers: {
|
|
21
22
|
"Content-Type": "application/json"
|
|
22
23
|
},
|
|
23
24
|
hooks: {
|
|
24
25
|
beforeRequest: [
|
|
25
|
-
(
|
|
26
|
-
const e =
|
|
27
|
-
|
|
26
|
+
(t) => {
|
|
27
|
+
const e = a.getApiKey();
|
|
28
|
+
t.headers.set("Authorization", `Bearer ${e}`);
|
|
28
29
|
}
|
|
29
30
|
],
|
|
30
|
-
afterResponse: [(
|
|
31
|
+
afterResponse: [(t, e, r) => r]
|
|
31
32
|
},
|
|
32
33
|
retry: {
|
|
33
34
|
limit: 2
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
|
-
class
|
|
37
|
-
async getClientInfo() {
|
|
38
|
-
return await t.get("client/auth/client-info").json();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
class o {
|
|
37
|
+
class c {
|
|
42
38
|
async getById(e) {
|
|
43
|
-
return await
|
|
39
|
+
return await s.get("intents/" + e).json();
|
|
44
40
|
}
|
|
45
41
|
async getForSender(e) {
|
|
46
|
-
return await
|
|
42
|
+
return await s.get("intents/user/" + e).json();
|
|
47
43
|
}
|
|
48
44
|
async getForAddress(e) {
|
|
49
|
-
return await
|
|
45
|
+
return await s.get("intents/address/" + e).json();
|
|
50
46
|
}
|
|
51
47
|
async getAll(e) {
|
|
52
|
-
return await
|
|
48
|
+
return await s.get("intents", { searchParams: e }).json();
|
|
53
49
|
}
|
|
54
50
|
async create(e) {
|
|
55
|
-
return await
|
|
51
|
+
return await s.post("intents", { json: e }).json();
|
|
56
52
|
}
|
|
57
|
-
async update(e,
|
|
58
|
-
return await
|
|
53
|
+
async update(e, r) {
|
|
54
|
+
return await s.post("intents", { json: r }).json();
|
|
59
55
|
}
|
|
60
56
|
//Calculate Destination
|
|
61
57
|
}
|
|
62
|
-
class
|
|
58
|
+
class u {
|
|
59
|
+
async getFromSpecificBridge(e) {
|
|
60
|
+
return await s.get("quotes/single", { searchParams: e }).json();
|
|
61
|
+
}
|
|
62
|
+
async getFromAllBridges(e) {
|
|
63
|
+
return await s.get("quotes/multiple", { searchParams: e }).json();
|
|
64
|
+
}
|
|
65
|
+
async getBestAcrossBridges(e) {
|
|
66
|
+
return await s.get("quotes/best", { searchParams: e }).json();
|
|
67
|
+
}
|
|
63
68
|
async getAll(e) {
|
|
64
|
-
return await
|
|
69
|
+
return await s.get("quotes/multi-source", { searchParams: e }).json();
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
|
-
class
|
|
72
|
+
class p {
|
|
68
73
|
async getOptimalRoutes(e) {
|
|
69
|
-
return await
|
|
74
|
+
return await s.get("router/optimal-route", { searchParams: e }).json();
|
|
70
75
|
}
|
|
71
76
|
async getAllSupportedBridges() {
|
|
72
|
-
return await
|
|
77
|
+
return await s.get("router/supported-bridges/all").json();
|
|
73
78
|
}
|
|
74
79
|
async getSupportedBridges(e) {
|
|
75
|
-
return await
|
|
80
|
+
return await s.get("router/supported-bridges/route", { searchParams: e }).json();
|
|
76
81
|
}
|
|
77
|
-
async getSupportedRoutes(e,
|
|
78
|
-
return await
|
|
82
|
+
async getSupportedRoutes(e, r) {
|
|
83
|
+
return await s.get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
class g {
|
|
87
|
+
async getSupported(e) {
|
|
88
|
+
return await s.get("chains", { searchParams: e }).json();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
class T {
|
|
92
|
+
async getClientInfo() {
|
|
93
|
+
return await s.get("client/auth/client-info").json();
|
|
79
94
|
}
|
|
80
95
|
}
|
|
81
|
-
const
|
|
82
|
-
router: new
|
|
83
|
-
quotes: new
|
|
84
|
-
intents: new
|
|
85
|
-
|
|
96
|
+
const E = {
|
|
97
|
+
router: new p(),
|
|
98
|
+
quotes: new u(),
|
|
99
|
+
intents: new c(),
|
|
100
|
+
chains: new g(),
|
|
101
|
+
client: new T()
|
|
86
102
|
};
|
|
87
103
|
export {
|
|
88
|
-
|
|
104
|
+
a as Chainrails,
|
|
105
|
+
i as chains,
|
|
106
|
+
E as default,
|
|
107
|
+
o as tokens
|
|
89
108
|
};
|
|
@@ -1,89 +1,108 @@
|
|
|
1
1
|
import n from "ky";
|
|
2
|
-
|
|
2
|
+
var i = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(i || {}), o = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(o || {});
|
|
3
|
+
class a {
|
|
3
4
|
constructor({ api_key: e }) {
|
|
4
5
|
this.api_key = e;
|
|
5
6
|
}
|
|
6
7
|
static config(e) {
|
|
7
|
-
if (!
|
|
8
|
+
if (!a.app) {
|
|
8
9
|
if (!e)
|
|
9
10
|
throw new Error("Please provide an api_key");
|
|
10
|
-
|
|
11
|
+
a.app = new a(e);
|
|
11
12
|
}
|
|
12
|
-
return e && (this.app.api_key = e.api_key),
|
|
13
|
+
return e && (this.app.api_key = e.api_key), a.app;
|
|
13
14
|
}
|
|
14
15
|
static getApiKey() {
|
|
15
|
-
return
|
|
16
|
+
return a.app.api_key;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
+
const s = n.create({
|
|
19
20
|
prefixUrl: "https://dev.chainrails.io/api/v1",
|
|
20
21
|
headers: {
|
|
21
22
|
"Content-Type": "application/json"
|
|
22
23
|
},
|
|
23
24
|
hooks: {
|
|
24
25
|
beforeRequest: [
|
|
25
|
-
(
|
|
26
|
-
const e =
|
|
27
|
-
|
|
26
|
+
(t) => {
|
|
27
|
+
const e = a.getApiKey();
|
|
28
|
+
t.headers.set("Authorization", `Bearer ${e}`);
|
|
28
29
|
}
|
|
29
30
|
],
|
|
30
|
-
afterResponse: [(
|
|
31
|
+
afterResponse: [(t, e, r) => r]
|
|
31
32
|
},
|
|
32
33
|
retry: {
|
|
33
34
|
limit: 2
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
|
-
class
|
|
37
|
-
async getClientInfo() {
|
|
38
|
-
return await t.get("client/auth/client-info").json();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
class o {
|
|
37
|
+
class c {
|
|
42
38
|
async getById(e) {
|
|
43
|
-
return await
|
|
39
|
+
return await s.get("intents/" + e).json();
|
|
44
40
|
}
|
|
45
41
|
async getForSender(e) {
|
|
46
|
-
return await
|
|
42
|
+
return await s.get("intents/user/" + e).json();
|
|
47
43
|
}
|
|
48
44
|
async getForAddress(e) {
|
|
49
|
-
return await
|
|
45
|
+
return await s.get("intents/address/" + e).json();
|
|
50
46
|
}
|
|
51
47
|
async getAll(e) {
|
|
52
|
-
return await
|
|
48
|
+
return await s.get("intents", { searchParams: e }).json();
|
|
53
49
|
}
|
|
54
50
|
async create(e) {
|
|
55
|
-
return await
|
|
51
|
+
return await s.post("intents", { json: e }).json();
|
|
56
52
|
}
|
|
57
|
-
async update(e,
|
|
58
|
-
return await
|
|
53
|
+
async update(e, r) {
|
|
54
|
+
return await s.post("intents", { json: r }).json();
|
|
59
55
|
}
|
|
60
56
|
//Calculate Destination
|
|
61
57
|
}
|
|
62
|
-
class
|
|
58
|
+
class u {
|
|
59
|
+
async getFromSpecificBridge(e) {
|
|
60
|
+
return await s.get("quotes/single", { searchParams: e }).json();
|
|
61
|
+
}
|
|
62
|
+
async getFromAllBridges(e) {
|
|
63
|
+
return await s.get("quotes/multiple", { searchParams: e }).json();
|
|
64
|
+
}
|
|
65
|
+
async getBestAcrossBridges(e) {
|
|
66
|
+
return await s.get("quotes/best", { searchParams: e }).json();
|
|
67
|
+
}
|
|
63
68
|
async getAll(e) {
|
|
64
|
-
return await
|
|
69
|
+
return await s.get("quotes/multi-source", { searchParams: e }).json();
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
|
-
class
|
|
72
|
+
class p {
|
|
68
73
|
async getOptimalRoutes(e) {
|
|
69
|
-
return await
|
|
74
|
+
return await s.get("router/optimal-route", { searchParams: e }).json();
|
|
70
75
|
}
|
|
71
76
|
async getAllSupportedBridges() {
|
|
72
|
-
return await
|
|
77
|
+
return await s.get("router/supported-bridges/all").json();
|
|
73
78
|
}
|
|
74
79
|
async getSupportedBridges(e) {
|
|
75
|
-
return await
|
|
80
|
+
return await s.get("router/supported-bridges/route", { searchParams: e }).json();
|
|
76
81
|
}
|
|
77
|
-
async getSupportedRoutes(e,
|
|
78
|
-
return await
|
|
82
|
+
async getSupportedRoutes(e, r) {
|
|
83
|
+
return await s.get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
class g {
|
|
87
|
+
async getSupported(e) {
|
|
88
|
+
return await s.get("chains", { searchParams: e }).json();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
class T {
|
|
92
|
+
async getClientInfo() {
|
|
93
|
+
return await s.get("client/auth/client-info").json();
|
|
79
94
|
}
|
|
80
95
|
}
|
|
81
|
-
const
|
|
82
|
-
router: new
|
|
83
|
-
quotes: new
|
|
84
|
-
intents: new
|
|
85
|
-
|
|
96
|
+
const E = {
|
|
97
|
+
router: new p(),
|
|
98
|
+
quotes: new u(),
|
|
99
|
+
intents: new c(),
|
|
100
|
+
chains: new g(),
|
|
101
|
+
client: new T()
|
|
86
102
|
};
|
|
87
103
|
export {
|
|
88
|
-
|
|
104
|
+
a as Chainrails,
|
|
105
|
+
i as chains,
|
|
106
|
+
E as default,
|
|
107
|
+
o as tokens
|
|
89
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(a,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],n):(a=typeof globalThis<"u"?globalThis:a||self,n(a.Chainrails={},a.Ky))})(this,(function(a,n){"use strict";var o=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(o||{}),u=(t=>(t.USDC="USDC",t))(u||{});class r{constructor({api_key:e}){this.api_key=e}static config(e){if(!r.app){if(!e)throw new Error("Please provide an api_key");r.app=new r(e)}return e&&(this.app.api_key=e.api_key),r.app}static getApiKey(){return r.app.api_key}}const s=n.create({prefixUrl:"https://dev.chainrails.io/api/v1",headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=r.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,i)=>i]},retry:{limit:2}});class c{async getById(e){return await s.get("intents/"+e).json()}async getForSender(e){return await s.get("intents/user/"+e).json()}async getForAddress(e){return await s.get("intents/address/"+e).json()}async getAll(e){return await s.get("intents",{searchParams:e}).json()}async create(e){return await s.post("intents",{json:e}).json()}async update(e,i){return await s.post("intents",{json:i}).json()}}class p{async getFromSpecificBridge(e){return await s.get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await s.get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await s.get("quotes/best",{searchParams:e}).json()}async getAll(e){return await s.get("quotes/multi-source",{searchParams:e}).json()}}class T{async getOptimalRoutes(e){return await s.get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await s.get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await s.get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,i){return await s.get("router/supported-bridges/bridge/"+e,{searchParams:i}).json()}}class g{async getSupported(e){return await s.get("chains",{searchParams:e}).json()}}class d{async getClientInfo(){return await s.get("client/auth/client-info").json()}}const l={router:new T,quotes:new p,intents:new c,chains:new g,client:new d};a.Chainrails=r,a.chains=o,a.default=l,a.tokens=u,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import Intents from "./src/Intents";
|
|
2
|
+
import Quotes from "./src/Quotes";
|
|
3
|
+
import Router from "./src/Router";
|
|
4
|
+
import Chains from "./src/Chains";
|
|
5
|
+
import Client from "./src/Client";
|
|
6
|
+
declare const cr: {
|
|
7
|
+
router: Router;
|
|
8
|
+
quotes: Quotes;
|
|
9
|
+
intents: Intents;
|
|
10
|
+
chains: Chains;
|
|
11
|
+
client: Client;
|
|
12
|
+
};
|
|
13
|
+
export * from "./src/types";
|
|
14
|
+
export { chains, tokens, Chainrails } from "@chainrails/common";
|
|
15
|
+
export default cr;
|
|
3
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,QAAA,MAAM,EAAE;;;;;;CAMP,CAAA;AAED,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Chains/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,MAAM,CAAC,OAAO,OAAO,MAAM;IACnB,YAAY,CAAC,KAAK,EAAE,iBAAiB;CAG5C;AAED,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Chains/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Intent, Status } from "src/types";
|
|
2
|
+
import { createIntentInput, getAllIntentsInput, getAllIntentsOutput } from "./types";
|
|
2
3
|
export default class Intents {
|
|
3
4
|
getById(id: string): Promise<Intent>;
|
|
4
5
|
getForSender(sender: `0x${string}`): Promise<Intent[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Intents/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Intents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEpF,MAAM,CAAC,OAAO,OAAO,OAAO;IACpB,OAAO,CAAC,EAAE,EAAE,MAAM;IAGlB,YAAY,CAAC,MAAM,EAAE,KAAK,MAAM,EAAE;IAGlC,aAAa,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE;IAGpC,MAAM,CAAC,YAAY,EAAE,kBAAkB;IAGvC,MAAM,CAAC,IAAI,EAAE,iBAAiB;IAG9B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;CAIlD;AAED,cAAc,SAAS,CAAA"}
|
|
@@ -1,51 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export interface Quote {
|
|
3
|
-
sourceChain: string;
|
|
4
|
-
destinationChain: string;
|
|
5
|
-
bestQuote: {
|
|
6
|
-
bridgeFeeDetails: {
|
|
7
|
-
maxFee: string;
|
|
8
|
-
};
|
|
9
|
-
totalFee: string;
|
|
10
|
-
totalFeeFormatted: string;
|
|
11
|
-
route: {
|
|
12
|
-
tokenIn: `0x${string}`;
|
|
13
|
-
tokenOut: `0x${string}`;
|
|
14
|
-
sourceChain: string;
|
|
15
|
-
destinationChain: string;
|
|
16
|
-
amount: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export interface Intent {
|
|
21
|
-
id: number;
|
|
22
|
-
sender: `0x${string}`;
|
|
23
|
-
initialAmount: number;
|
|
24
|
-
fees: number;
|
|
25
|
-
totalAmount: number;
|
|
26
|
-
tokenIn: `0x${string}`;
|
|
27
|
-
tokenOut: `0x${string}`;
|
|
28
|
-
intent_address: `0x${string}`;
|
|
29
|
-
source_chain: string;
|
|
30
|
-
destination_chain: string;
|
|
31
|
-
recipient: `0x${string}`;
|
|
32
|
-
refund_address: `0x${string}`;
|
|
33
|
-
relayer: string;
|
|
34
|
-
coordinator: `0x${string}`;
|
|
35
|
-
bridger: `0x${string}`;
|
|
36
|
-
bridgeExtraData: `0x${string}`;
|
|
37
|
-
intent_nonce: number;
|
|
38
|
-
intent_status: "DECLARED" | Status;
|
|
39
|
-
tx_hash: string;
|
|
40
|
-
needs_relay: true;
|
|
41
|
-
expires_at: string;
|
|
42
|
-
metadata: {
|
|
43
|
-
description: string;
|
|
44
|
-
reference: string;
|
|
45
|
-
};
|
|
46
|
-
created_at: string;
|
|
47
|
-
updated_at: string;
|
|
48
|
-
}
|
|
1
|
+
import { Intent } from "src/types";
|
|
49
2
|
export type getAllIntentsInput = {
|
|
50
3
|
limit?: number;
|
|
51
4
|
offset?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Intents/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Intents/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,WAAW,CAAA;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAA;CAC3D,CAAA;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,KAAK,EAAE,GAAG,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,cAAc,EAAE,KAAK,MAAM,EAAE,CAAA;IAC7B,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { getAllInput, getAllOutput } from "./types";
|
|
1
|
+
import { getAllInput, getAllOutput, getBestAcrossBridgesInput, getBestAcrossBridgesOutput, getFromAllBridgesInput, getFromAllBridgesOutput, getFromSpecificBridgeInput, getFromSpecificBridgeOutput } from "./types";
|
|
2
2
|
export default class Quotes {
|
|
3
|
+
getFromSpecificBridge(input: getFromSpecificBridgeInput): Promise<getFromSpecificBridgeOutput>;
|
|
4
|
+
getFromAllBridges(input: getFromAllBridgesInput): Promise<getFromAllBridgesOutput>;
|
|
5
|
+
getBestAcrossBridges(input: getBestAcrossBridgesInput): Promise<getBestAcrossBridgesOutput>;
|
|
3
6
|
getAll(input: getAllInput): Promise<getAllOutput>;
|
|
4
7
|
}
|
|
5
8
|
export * from "./types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Quotes/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Quotes/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,SAAS,CAAA;AAEhB,MAAM,CAAC,OAAO,OAAO,MAAM;IACnB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B;IAIvD,iBAAiB,CAAC,KAAK,EAAE,sBAAsB;IAI/C,oBAAoB,CAAC,KAAK,EAAE,yBAAyB;IAIrD,MAAM,CAAC,KAAK,EAAE,WAAW;CAGhC;AAED,cAAc,SAAS,CAAA"}
|
|
@@ -1,20 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
import { chains } from "@chainrails/common";
|
|
2
|
+
import { Bridge, Quote } from "src/types";
|
|
3
|
+
export interface getFromSpecificBridgeInput {
|
|
4
|
+
destinationChain: string;
|
|
5
|
+
sourceChain: string;
|
|
6
|
+
tokenIn: `0x${string}`;
|
|
7
|
+
tokenOut: `0x${string}`;
|
|
8
|
+
amount: string;
|
|
9
|
+
bridge: Bridge;
|
|
10
|
+
recipient: `0x${string}`;
|
|
11
|
+
[key: string]: string | number | boolean | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface getFromSpecificBridgeOutput {
|
|
14
|
+
destinationChain: chains;
|
|
15
|
+
quotes: Quote[];
|
|
16
|
+
cheapestOption: Quote;
|
|
17
|
+
}
|
|
18
|
+
export interface getFromAllBridgesInput {
|
|
19
|
+
destinationChain: string;
|
|
2
20
|
sourceChain: string;
|
|
21
|
+
tokenIn: `0x${string}`;
|
|
22
|
+
tokenOut: `0x${string}`;
|
|
23
|
+
amount: string;
|
|
24
|
+
excludeBridges: string;
|
|
25
|
+
recipient: `0x${string}`;
|
|
26
|
+
[key: string]: string | number | boolean | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface getFromAllBridgesOutput {
|
|
29
|
+
destinationChain: chains;
|
|
30
|
+
quotes: Quote[];
|
|
31
|
+
cheapestOption: Quote;
|
|
32
|
+
}
|
|
33
|
+
export interface getBestAcrossBridgesInput {
|
|
3
34
|
destinationChain: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
};
|
|
35
|
+
sourceChain: string;
|
|
36
|
+
tokenIn: `0x${string}`;
|
|
37
|
+
tokenOut: `0x${string}`;
|
|
38
|
+
amount: string;
|
|
39
|
+
excludeBridges: string;
|
|
40
|
+
recipient: `0x${string}`;
|
|
41
|
+
[key: string]: string | number | boolean | undefined;
|
|
42
|
+
}
|
|
43
|
+
export interface getBestAcrossBridgesOutput {
|
|
44
|
+
destinationChain: chains;
|
|
45
|
+
quotes: Quote[];
|
|
46
|
+
cheapestOption: Quote;
|
|
18
47
|
}
|
|
19
48
|
export interface getAllInput {
|
|
20
49
|
destinationChain: string;
|
|
@@ -24,7 +53,7 @@ export interface getAllInput {
|
|
|
24
53
|
[key: string]: string | number | boolean | undefined;
|
|
25
54
|
}
|
|
26
55
|
export interface getAllOutput {
|
|
27
|
-
destinationChain:
|
|
56
|
+
destinationChain: chains;
|
|
28
57
|
quotes: Quote[];
|
|
29
58
|
cheapestOption: Quote;
|
|
30
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Quotes/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Quotes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEzC,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD;AAED,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,cAAc,EAAE,KAAK,CAAA;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD;AAED,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,cAAc,EAAE,KAAK,CAAA;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD;AAED,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,cAAc,EAAE,KAAK,CAAA;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD;AAED,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,cAAc,EAAE,KAAK,CAAA;CACtB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Bridge
|
|
1
|
+
import { Bridge } from "src/types";
|
|
2
|
+
import { getAllSupportedBridgesOutput, getOptimalRoutesInput, getOptimalRoutesOutput, getSupportedBridgesInput, getSupportedBridgesOutput } from "./types";
|
|
2
3
|
export default class Router {
|
|
3
4
|
getOptimalRoutes(input: getOptimalRoutesInput): Promise<getOptimalRoutesOutput>;
|
|
4
5
|
getAllSupportedBridges(): Promise<getAllSupportedBridgesOutput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Router/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAEhB,MAAM,CAAC,OAAO,OAAO,MAAM;IACnB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB;IAI7C,sBAAsB;IAItB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB;IAInD,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,wBAAwB;CAGzE;AAED,cAAc,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Router/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Router/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,KAAK,MAAM,EAAE,CAAA;IAC5B,eAAe,EAAE,KAAK,MAAM,EAAE,CAAA;IAC9B,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE;SACN,GAAG,IAAI,MAAM,GAAG,CAAC;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,gBAAgB,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACvE,CAAA;IACD,QAAQ,EAAE;QACR,YAAY,EAAE,MAAM,CAAA;QACpB,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;CACF;AAED,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACrD;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,SAAS,EAAE;QACT,WAAW,EAAE,MAAM,CAAA;QACnB,gBAAgB,EAAE,MAAM,CAAA;QACxB,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,EAAE,IAAI,CAAA;KAClB,CAAA;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { chains } from "@chainrails/common";
|
|
2
|
+
export type Status = "PENDING" | "FUNDED" | "INITIATED" | "COMPLETED" | "EXPIRED";
|
|
3
|
+
export type Bridge = "ACROSS" | "CCTP" | "GATEWAY" | "RHINOFI";
|
|
4
|
+
export type Network = "mainnet" | "testnet";
|
|
5
|
+
export interface Quote {
|
|
6
|
+
sourceChain: chains;
|
|
7
|
+
destinationChain: chains;
|
|
8
|
+
bestQuote: {
|
|
9
|
+
bridgeFeeDetails: {
|
|
10
|
+
maxFee: string;
|
|
11
|
+
};
|
|
12
|
+
totalFee: string;
|
|
13
|
+
totalFeeFormatted: string;
|
|
14
|
+
route: {
|
|
15
|
+
tokenIn: `0x${string}`;
|
|
16
|
+
tokenOut: `0x${string}`;
|
|
17
|
+
sourceChain: chains;
|
|
18
|
+
destinationChain: chains;
|
|
19
|
+
amount: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface Intent {
|
|
24
|
+
id: number;
|
|
25
|
+
sender: `0x${string}`;
|
|
26
|
+
initialAmount: number;
|
|
27
|
+
fees: number;
|
|
28
|
+
totalAmount: number;
|
|
29
|
+
tokenIn: `0x${string}`;
|
|
30
|
+
tokenOut: `0x${string}`;
|
|
31
|
+
intent_address: `0x${string}`;
|
|
32
|
+
source_chain: string;
|
|
33
|
+
destination_chain: string;
|
|
34
|
+
recipient: `0x${string}`;
|
|
35
|
+
refund_address: `0x${string}`;
|
|
36
|
+
relayer: string;
|
|
37
|
+
coordinator: `0x${string}`;
|
|
38
|
+
bridger: `0x${string}`;
|
|
39
|
+
bridgeExtraData: `0x${string}`;
|
|
40
|
+
intent_nonce: number;
|
|
41
|
+
intent_status: "DECLARED" | Status;
|
|
42
|
+
tx_hash: string;
|
|
43
|
+
needs_relay: true;
|
|
44
|
+
expires_at: string;
|
|
45
|
+
metadata: {
|
|
46
|
+
description: string;
|
|
47
|
+
reference: string;
|
|
48
|
+
};
|
|
49
|
+
created_at: string;
|
|
50
|
+
updated_at: string;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAA;AAEjF,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAE9D,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAE3C,MAAM,WAAW,KAAK;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE;QACT,gBAAgB,EAAE;YAChB,MAAM,EAAE,MAAM,CAAA;SACf,CAAA;QACD,QAAQ,EAAE,MAAM,CAAA;QAChB,iBAAiB,EAAE,MAAM,CAAA;QACzB,KAAK,EAAE;YACL,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;YACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;YACvB,WAAW,EAAE,MAAM,CAAA;YACnB,gBAAgB,EAAE,MAAM,CAAA;YACxB,MAAM,EAAE,MAAM,CAAA;SACf,CAAA;KACF,CAAA;CACF;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;IACvB,cAAc,EAAE,KAAK,MAAM,EAAE,CAAA;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAA;IACxB,cAAc,EAAE,KAAK,MAAM,EAAE,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,KAAK,MAAM,EAAE,CAAA;IAC1B,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,eAAe,EAAE,KAAK,MAAM,EAAE,CAAA;IAC9B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,UAAU,GAAG,MAAM,CAAA;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,IAAI,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainrails/sdk",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "./dist/chainrails-sdk.umd.js",
|
|
6
6
|
"module": "./dist/chainrails-sdk.es.mjs",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@chainrails/common": "^0.0.
|
|
39
|
-
"ky": "^1.14.0"
|
|
40
|
-
"vite": "^7.1.9"
|
|
38
|
+
"@chainrails/common": "^0.0.4",
|
|
39
|
+
"ky": "^1.14.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"eslint": "^8.57.0",
|
|
44
|
-
"typescript": "5.5.4"
|
|
43
|
+
"typescript": "5.5.4",
|
|
44
|
+
"vite": "^7.1.9"
|
|
45
45
|
}
|
|
46
46
|
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Client from "./Client";
|
|
2
|
-
import Intents from "./Intents";
|
|
3
|
-
import Quotes from "./Quotes";
|
|
4
|
-
import Router from "./Router";
|
|
5
|
-
declare const cr: {
|
|
6
|
-
router: Router;
|
|
7
|
-
quotes: Quotes;
|
|
8
|
-
intents: Intents;
|
|
9
|
-
client: Client;
|
|
10
|
-
};
|
|
11
|
-
export default cr;
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,QAAA,MAAM,EAAE;;;;;CAKP,CAAA;AAED,eAAe,EAAE,CAAA"}
|