@chainrails/sdk 0.0.5 → 0.0.7
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 +5 -5
- package/dist/chainrails-sdk.es.js +6 -6
- package/dist/chainrails-sdk.es.mjs +6 -6
- package/dist/chainrails-sdk.umd.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ yarn add @chainrails/sdk
|
|
|
31
31
|
### 1. Initialize the SDK
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import crapi,
|
|
34
|
+
import { crapi, Chainrails} from "@chainrails/sdk"
|
|
35
35
|
|
|
36
36
|
// Configure with your API key
|
|
37
37
|
Chainrails.config({
|
|
@@ -472,7 +472,7 @@ The SDK automatically retries failed requests up to 2 times.
|
|
|
472
472
|
### Example 1: Create Intent and Monitor Status
|
|
473
473
|
|
|
474
474
|
```typescript
|
|
475
|
-
import crapi,
|
|
475
|
+
import { crapi, Chainrails } from "@chainrails/sdk"
|
|
476
476
|
|
|
477
477
|
Chainrails.config({ api_key: "your_api_key" })
|
|
478
478
|
|
|
@@ -495,7 +495,7 @@ console.log("Updated status:", updated.intent_status)
|
|
|
495
495
|
### Example 2: Compare Quotes Across Bridges
|
|
496
496
|
|
|
497
497
|
```typescript
|
|
498
|
-
import crapi from "@chainrails/sdk"
|
|
498
|
+
import { crapi } from "@chainrails/sdk"
|
|
499
499
|
|
|
500
500
|
const quotes = await crapi.quotes.getFromAllBridges({
|
|
501
501
|
tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
@@ -520,7 +520,7 @@ console.log("Best quote total fee:", best.bestQuote.totalFeeFormatted)
|
|
|
520
520
|
### Example 3: Find Optimal Route
|
|
521
521
|
|
|
522
522
|
```typescript
|
|
523
|
-
import crapi from "@chainrails/sdk"
|
|
523
|
+
import { crapi } from "@chainrails/sdk"
|
|
524
524
|
|
|
525
525
|
const route = await crapi.router.getOptimalRoutes({
|
|
526
526
|
tokenIn: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
|
|
@@ -536,7 +536,7 @@ console.log("Optimal route:", route)
|
|
|
536
536
|
### Example 4: List All User Intents
|
|
537
537
|
|
|
538
538
|
```typescript
|
|
539
|
-
import crapi from "@chainrails/sdk"
|
|
539
|
+
import { crapi } from "@chainrails/sdk"
|
|
540
540
|
|
|
541
541
|
const userAddress = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
|
|
542
542
|
const intents = await crapi.intents.getForSender(userAddress)
|
|
@@ -55,7 +55,7 @@ class c {
|
|
|
55
55
|
}
|
|
56
56
|
//Calculate Destination
|
|
57
57
|
}
|
|
58
|
-
class
|
|
58
|
+
class p {
|
|
59
59
|
async getFromSpecificBridge(e) {
|
|
60
60
|
return await s.get("quotes/single", { searchParams: e }).json();
|
|
61
61
|
}
|
|
@@ -69,7 +69,7 @@ class u {
|
|
|
69
69
|
return await s.get("quotes/multi-source", { searchParams: e }).json();
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class u {
|
|
73
73
|
async getOptimalRoutes(e) {
|
|
74
74
|
return await s.get("router/optimal-route", { searchParams: e }).json();
|
|
75
75
|
}
|
|
@@ -93,9 +93,9 @@ class T {
|
|
|
93
93
|
return await s.get("client/auth/client-info").json();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const
|
|
97
|
-
router: new
|
|
98
|
-
quotes: new
|
|
96
|
+
const l = {
|
|
97
|
+
router: new u(),
|
|
98
|
+
quotes: new p(),
|
|
99
99
|
intents: new c(),
|
|
100
100
|
chains: new g(),
|
|
101
101
|
client: new T()
|
|
@@ -103,6 +103,6 @@ const E = {
|
|
|
103
103
|
export {
|
|
104
104
|
a as Chainrails,
|
|
105
105
|
i as chains,
|
|
106
|
-
|
|
106
|
+
l as crapi,
|
|
107
107
|
o as tokens
|
|
108
108
|
};
|
|
@@ -55,7 +55,7 @@ class c {
|
|
|
55
55
|
}
|
|
56
56
|
//Calculate Destination
|
|
57
57
|
}
|
|
58
|
-
class
|
|
58
|
+
class p {
|
|
59
59
|
async getFromSpecificBridge(e) {
|
|
60
60
|
return await s.get("quotes/single", { searchParams: e }).json();
|
|
61
61
|
}
|
|
@@ -69,7 +69,7 @@ class u {
|
|
|
69
69
|
return await s.get("quotes/multi-source", { searchParams: e }).json();
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class u {
|
|
73
73
|
async getOptimalRoutes(e) {
|
|
74
74
|
return await s.get("router/optimal-route", { searchParams: e }).json();
|
|
75
75
|
}
|
|
@@ -93,9 +93,9 @@ class T {
|
|
|
93
93
|
return await s.get("client/auth/client-info").json();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const
|
|
97
|
-
router: new
|
|
98
|
-
quotes: new
|
|
96
|
+
const l = {
|
|
97
|
+
router: new u(),
|
|
98
|
+
quotes: new p(),
|
|
99
99
|
intents: new c(),
|
|
100
100
|
chains: new g(),
|
|
101
101
|
client: new T()
|
|
@@ -103,6 +103,6 @@ const E = {
|
|
|
103
103
|
export {
|
|
104
104
|
a as Chainrails,
|
|
105
105
|
i as chains,
|
|
106
|
-
|
|
106
|
+
l as crapi,
|
|
107
107
|
o as tokens
|
|
108
108
|
};
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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.crapi=l,a.tokens=u,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import Quotes from "./src/Quotes";
|
|
|
3
3
|
import Router from "./src/Router";
|
|
4
4
|
import Chains from "./src/Chains";
|
|
5
5
|
import Client from "./src/Client";
|
|
6
|
-
|
|
6
|
+
import { chains, tokens, Chainrails } from "@chainrails/common";
|
|
7
|
+
declare const crapi: {
|
|
7
8
|
router: Router;
|
|
8
9
|
quotes: Quotes;
|
|
9
10
|
intents: Intents;
|
|
@@ -11,6 +12,5 @@ declare const cr: {
|
|
|
11
12
|
client: Client;
|
|
12
13
|
};
|
|
13
14
|
export * from "./src/types";
|
|
14
|
-
export { chains, tokens, Chainrails }
|
|
15
|
-
export default cr;
|
|
15
|
+
export { crapi, chains, tokens, Chainrails };
|
|
16
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,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,
|
|
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,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D,QAAA,MAAM,KAAK;;;;;;CAMV,CAAA;AAED,cAAc,aAAa,CAAA;AAE3B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA"}
|