@chainrails/sdk 0.0.19 → 0.0.20
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/dist/chainrails-sdk.es.js +15 -15
- package/dist/chainrails-sdk.es.mjs +15 -15
- package/dist/chainrails-sdk.umd.js +1 -1
- package/package.json +2 -2
|
@@ -34,7 +34,7 @@ class s {
|
|
|
34
34
|
return s.app.api_key;
|
|
35
35
|
}
|
|
36
36
|
static getSessionKey() {
|
|
37
|
-
return s.app.jwt;
|
|
37
|
+
return console.log("jwttt"), this.updateJWT(), s.app.jwt;
|
|
38
38
|
}
|
|
39
39
|
static getEnv() {
|
|
40
40
|
if (!s.app)
|
|
@@ -55,7 +55,7 @@ class s {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
let n = null;
|
|
58
|
-
function
|
|
58
|
+
function l() {
|
|
59
59
|
n = o.create({
|
|
60
60
|
prefixUrl: s.getBaseUrl(),
|
|
61
61
|
headers: {
|
|
@@ -76,9 +76,9 @@ function u() {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
function a() {
|
|
79
|
-
return n ||
|
|
79
|
+
return n || l(), n;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class u {
|
|
82
82
|
async getById(e) {
|
|
83
83
|
return await a().get("intents/" + e).json();
|
|
84
84
|
}
|
|
@@ -101,7 +101,7 @@ class g {
|
|
|
101
101
|
return await a().post(`intents/${e}/trigger-processing`).json();
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
class
|
|
104
|
+
class g {
|
|
105
105
|
async getFromSpecificBridge(e) {
|
|
106
106
|
return await a().get("quotes/single", { searchParams: e }).json();
|
|
107
107
|
}
|
|
@@ -115,7 +115,7 @@ class l {
|
|
|
115
115
|
return await a().get("quotes/multi-source", { searchParams: e }).json();
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class T {
|
|
119
119
|
async getOptimalRoutes(e) {
|
|
120
120
|
return await a().get("router/optimal-route", { searchParams: e }).json();
|
|
121
121
|
}
|
|
@@ -129,27 +129,27 @@ class E {
|
|
|
129
129
|
return await a().get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
class
|
|
132
|
+
class h {
|
|
133
133
|
async getSupported(e) {
|
|
134
134
|
return await a().get("chains", { searchParams: e }).json();
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class E {
|
|
138
138
|
async getClientInfo() {
|
|
139
139
|
return await a().get("client/auth/client-info").json();
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
router: new
|
|
144
|
-
quotes: new
|
|
145
|
-
intents: new
|
|
146
|
-
chains: new
|
|
147
|
-
client: new
|
|
142
|
+
const y = {
|
|
143
|
+
router: new T(),
|
|
144
|
+
quotes: new g(),
|
|
145
|
+
intents: new u(),
|
|
146
|
+
chains: new h(),
|
|
147
|
+
client: new E()
|
|
148
148
|
};
|
|
149
149
|
export {
|
|
150
150
|
s as Chainrails,
|
|
151
151
|
p as chains,
|
|
152
|
-
|
|
152
|
+
y as crapi,
|
|
153
153
|
i as environment,
|
|
154
154
|
c as tokens
|
|
155
155
|
};
|
|
@@ -34,7 +34,7 @@ class s {
|
|
|
34
34
|
return s.app.api_key;
|
|
35
35
|
}
|
|
36
36
|
static getSessionKey() {
|
|
37
|
-
return s.app.jwt;
|
|
37
|
+
return console.log("jwttt"), this.updateJWT(), s.app.jwt;
|
|
38
38
|
}
|
|
39
39
|
static getEnv() {
|
|
40
40
|
if (!s.app)
|
|
@@ -55,7 +55,7 @@ class s {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
let n = null;
|
|
58
|
-
function
|
|
58
|
+
function l() {
|
|
59
59
|
n = o.create({
|
|
60
60
|
prefixUrl: s.getBaseUrl(),
|
|
61
61
|
headers: {
|
|
@@ -76,9 +76,9 @@ function u() {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
function a() {
|
|
79
|
-
return n ||
|
|
79
|
+
return n || l(), n;
|
|
80
80
|
}
|
|
81
|
-
class
|
|
81
|
+
class u {
|
|
82
82
|
async getById(e) {
|
|
83
83
|
return await a().get("intents/" + e).json();
|
|
84
84
|
}
|
|
@@ -101,7 +101,7 @@ class g {
|
|
|
101
101
|
return await a().post(`intents/${e}/trigger-processing`).json();
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
class
|
|
104
|
+
class g {
|
|
105
105
|
async getFromSpecificBridge(e) {
|
|
106
106
|
return await a().get("quotes/single", { searchParams: e }).json();
|
|
107
107
|
}
|
|
@@ -115,7 +115,7 @@ class l {
|
|
|
115
115
|
return await a().get("quotes/multi-source", { searchParams: e }).json();
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class T {
|
|
119
119
|
async getOptimalRoutes(e) {
|
|
120
120
|
return await a().get("router/optimal-route", { searchParams: e }).json();
|
|
121
121
|
}
|
|
@@ -129,27 +129,27 @@ class E {
|
|
|
129
129
|
return await a().get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
class
|
|
132
|
+
class h {
|
|
133
133
|
async getSupported(e) {
|
|
134
134
|
return await a().get("chains", { searchParams: e }).json();
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class E {
|
|
138
138
|
async getClientInfo() {
|
|
139
139
|
return await a().get("client/auth/client-info").json();
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
router: new
|
|
144
|
-
quotes: new
|
|
145
|
-
intents: new
|
|
146
|
-
chains: new
|
|
147
|
-
client: new
|
|
142
|
+
const y = {
|
|
143
|
+
router: new T(),
|
|
144
|
+
quotes: new g(),
|
|
145
|
+
intents: new u(),
|
|
146
|
+
chains: new h(),
|
|
147
|
+
client: new E()
|
|
148
148
|
};
|
|
149
149
|
export {
|
|
150
150
|
s as Chainrails,
|
|
151
151
|
p as chains,
|
|
152
|
-
|
|
152
|
+
y as crapi,
|
|
153
153
|
i as environment,
|
|
154
154
|
c as tokens
|
|
155
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.Chainrails={},a.Ky))})(this,(function(a,r){"use strict";var p=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(p||{}),u=(t=>(t.USDC="USDC",t))(u||{}),o=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(o||{});class s{constructor({api_key:e,env:i}){this.api_key=e,this.jwt="",this.env=i??o.PRODUCTION}static config(e){if(!s.app){if(!e)throw new Error("Please provide an api_key");s.app=new s(e)}return e&&(s.app.api_key=e.api_key,e.env!==void 0&&(s.app.env=e.env),this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),s.app}static async updateJWT(){try{const e=await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{headers:{Authorization:`Bearer ${s.app.api_key}`},body:JSON.stringify({apiKey:s.app.api_key})});console.log(e,this.getBaseUrl()+"/client/api-keys/session-token");const i=await e.json();console.log(i),this.app.jwt=i.token}catch{}}static getApiKey(){if(!s.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return s.app.api_key}static getSessionKey(){return s.app.jwt}static getEnv(){if(!s.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return s.app.env}static getBaseUrl(){if(!s.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(s.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}}let c=null;function l(){c=r.create({prefixUrl:s.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=s.getSessionKey();console.log({Chainrails:s},s.getApiKey(),s.getSessionKey()),t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,i)=>i]},retry:{limit:2}})}function n(){return c||l(),c}class g{async getById(e){return await n().get("intents/"+e).json()}async getForSender(e){return await n().get("intents/user/"+e).json()}async getForAddress(e){return await n().get("intents/address/"+e).json()}async getAll(e){return await n().get("intents",{searchParams:e}).json()}async create(e){return await n().post("intents",{json:e}).json()}async update(e,i){return await n().post("intents",{json:i}).json()}async triggerProcessing(e){return await n().post(`intents/${e}/trigger-processing`).json()}}class h{async getFromSpecificBridge(e){return await n().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await n().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await n().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await n().get("quotes/multi-source",{searchParams:e}).json()}}class T{async getOptimalRoutes(e){return await n().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await n().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await n().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,i){return await n().get("router/supported-bridges/bridge/"+e,{searchParams:i}).json()}}class d{async getSupported(e){return await n().get("chains",{searchParams:e}).json()}}class E{async getClientInfo(){return await n().get("client/auth/client-info").json()}}const y={router:new T,quotes:new h,intents:new g,chains:new d,client:new E};a.Chainrails=s,a.chains=p,a.crapi=y,a.environment=o,a.tokens=u,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a.Chainrails={},a.Ky))})(this,(function(a,r){"use strict";var p=(t=>(t.ARBITRUM="ARBITRUM_MAINNET",t.ARBITRUM_TESTNET="ARBITRUM_TESTNET",t.AVALANCHE="AVALANCHE_MAINNET",t.AVALANCHE_TESTNET="AVALANCHE_TESTNET",t.BASE="BASE_MAINNET",t.BASE_TESTNET="BASE_TESTNET",t.BSC="BSC_MAINNET",t.ETHEREUM="ETHEREUM_MAINNET",t.ETHEREUM_TESTNET="ETHEREUM_TESTNET",t.STARKNET="STARKNET_MAINNET",t))(p||{}),u=(t=>(t.USDC="USDC",t))(u||{}),o=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(o||{});class s{constructor({api_key:e,env:i}){this.api_key=e,this.jwt="",this.env=i??o.PRODUCTION}static config(e){if(!s.app){if(!e)throw new Error("Please provide an api_key");s.app=new s(e)}return e&&(s.app.api_key=e.api_key,e.env!==void 0&&(s.app.env=e.env),this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),s.app}static async updateJWT(){try{const e=await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{headers:{Authorization:`Bearer ${s.app.api_key}`},body:JSON.stringify({apiKey:s.app.api_key})});console.log(e,this.getBaseUrl()+"/client/api-keys/session-token");const i=await e.json();console.log(i),this.app.jwt=i.token}catch{}}static getApiKey(){if(!s.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return s.app.api_key}static getSessionKey(){return console.log("jwttt"),this.updateJWT(),s.app.jwt}static getEnv(){if(!s.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return s.app.env}static getBaseUrl(){if(!s.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(s.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}}let c=null;function l(){c=r.create({prefixUrl:s.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=s.getSessionKey();console.log({Chainrails:s},s.getApiKey(),s.getSessionKey()),t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,i)=>i]},retry:{limit:2}})}function n(){return c||l(),c}class g{async getById(e){return await n().get("intents/"+e).json()}async getForSender(e){return await n().get("intents/user/"+e).json()}async getForAddress(e){return await n().get("intents/address/"+e).json()}async getAll(e){return await n().get("intents",{searchParams:e}).json()}async create(e){return await n().post("intents",{json:e}).json()}async update(e,i){return await n().post("intents",{json:i}).json()}async triggerProcessing(e){return await n().post(`intents/${e}/trigger-processing`).json()}}class h{async getFromSpecificBridge(e){return await n().get("quotes/single",{searchParams:e}).json()}async getFromAllBridges(e){return await n().get("quotes/multiple",{searchParams:e}).json()}async getBestAcrossBridges(e){return await n().get("quotes/best",{searchParams:e}).json()}async getAll(e){return await n().get("quotes/multi-source",{searchParams:e}).json()}}class T{async getOptimalRoutes(e){return await n().get("router/optimal-route",{searchParams:e}).json()}async getAllSupportedBridges(){return await n().get("router/supported-bridges/all").json()}async getSupportedBridges(e){return await n().get("router/supported-bridges/route",{searchParams:e}).json()}async getSupportedRoutes(e,i){return await n().get("router/supported-bridges/bridge/"+e,{searchParams:i}).json()}}class d{async getSupported(e){return await n().get("chains",{searchParams:e}).json()}}class E{async getClientInfo(){return await n().get("client/auth/client-info").json()}}const y={router:new T,quotes:new h,intents:new g,chains:new d,client:new E};a.Chainrails=s,a.chains=p,a.crapi=y,a.environment=o,a.tokens=u,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
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.20",
|
|
5
5
|
"main": "./dist/chainrails-sdk.umd.js",
|
|
6
6
|
"module": "./dist/chainrails-sdk.es.mjs",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@chainrails/common": "^0.0.
|
|
38
|
+
"@chainrails/common": "^0.0.12",
|
|
39
39
|
"ky": "^1.14.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|