@chainrails/sdk 0.0.20 → 0.0.21

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.
@@ -1,8 +1,8 @@
1
1
  import o from "ky";
2
- var p = /* @__PURE__ */ ((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 || {}), c = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(c || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
2
+ var c = /* @__PURE__ */ ((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))(c || {}), p = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(p || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
3
3
  class s {
4
- constructor({ api_key: e, env: r }) {
5
- this.api_key = e, this.jwt = "", this.env = r ?? i.PRODUCTION;
4
+ constructor({ api_key: e, env: n }) {
5
+ this.api_key = e, this.jwt = "", this.env = n ?? i.PRODUCTION;
6
6
  }
7
7
  static config(e) {
8
8
  if (!s.app) {
@@ -23,9 +23,10 @@ class s {
23
23
  })
24
24
  });
25
25
  console.log(e, this.getBaseUrl() + "/client/api-keys/session-token");
26
- const r = await e.json();
27
- console.log(r), this.app.jwt = r.token;
28
- } catch {
26
+ const n = await e.json();
27
+ console.log(n), this.app.jwt = n.token;
28
+ } catch (e) {
29
+ console.log(e);
29
30
  }
30
31
  }
31
32
  static getApiKey() {
@@ -34,7 +35,7 @@ class s {
34
35
  return s.app.api_key;
35
36
  }
36
37
  static getSessionKey() {
37
- return console.log("jwttt"), this.updateJWT(), s.app.jwt;
38
+ return console.log("jwttt"), this.updateJWT(), console.log("jwttt2"), s.app.jwt;
38
39
  }
39
40
  static getEnv() {
40
41
  if (!s.app)
@@ -54,9 +55,9 @@ class s {
54
55
  }
55
56
  }
56
57
  }
57
- let n = null;
58
+ let r = null;
58
59
  function l() {
59
- n = o.create({
60
+ r = o.create({
60
61
  prefixUrl: s.getBaseUrl(),
61
62
  headers: {
62
63
  "Content-Type": "application/json"
@@ -68,7 +69,7 @@ function l() {
68
69
  console.log({ Chainrails: s }, s.getApiKey(), s.getSessionKey()), t.headers.set("Authorization", `Bearer ${e}`);
69
70
  }
70
71
  ],
71
- afterResponse: [(t, e, r) => r]
72
+ afterResponse: [(t, e, n) => n]
72
73
  },
73
74
  retry: {
74
75
  limit: 2
@@ -76,9 +77,9 @@ function l() {
76
77
  });
77
78
  }
78
79
  function a() {
79
- return n || l(), n;
80
+ return r || l(), r;
80
81
  }
81
- class u {
82
+ class g {
82
83
  async getById(e) {
83
84
  return await a().get("intents/" + e).json();
84
85
  }
@@ -94,14 +95,14 @@ class u {
94
95
  async create(e) {
95
96
  return await a().post("intents", { json: e }).json();
96
97
  }
97
- async update(e, r) {
98
- return await a().post("intents", { json: r }).json();
98
+ async update(e, n) {
99
+ return await a().post("intents", { json: n }).json();
99
100
  }
100
101
  async triggerProcessing(e) {
101
102
  return await a().post(`intents/${e}/trigger-processing`).json();
102
103
  }
103
104
  }
104
- class g {
105
+ class u {
105
106
  async getFromSpecificBridge(e) {
106
107
  return await a().get("quotes/single", { searchParams: e }).json();
107
108
  }
@@ -115,7 +116,7 @@ class g {
115
116
  return await a().get("quotes/multi-source", { searchParams: e }).json();
116
117
  }
117
118
  }
118
- class T {
119
+ class h {
119
120
  async getOptimalRoutes(e) {
120
121
  return await a().get("router/optimal-route", { searchParams: e }).json();
121
122
  }
@@ -125,31 +126,31 @@ class T {
125
126
  async getSupportedBridges(e) {
126
127
  return await a().get("router/supported-bridges/route", { searchParams: e }).json();
127
128
  }
128
- async getSupportedRoutes(e, r) {
129
- return await a().get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
129
+ async getSupportedRoutes(e, n) {
130
+ return await a().get("router/supported-bridges/bridge/" + e, { searchParams: n }).json();
130
131
  }
131
132
  }
132
- class h {
133
+ class E {
133
134
  async getSupported(e) {
134
135
  return await a().get("chains", { searchParams: e }).json();
135
136
  }
136
137
  }
137
- class E {
138
+ class T {
138
139
  async getClientInfo() {
139
140
  return await a().get("client/auth/client-info").json();
140
141
  }
141
142
  }
142
143
  const y = {
143
- router: new T(),
144
- quotes: new g(),
145
- intents: new u(),
146
- chains: new h(),
147
- client: new E()
144
+ router: new h(),
145
+ quotes: new u(),
146
+ intents: new g(),
147
+ chains: new E(),
148
+ client: new T()
148
149
  };
149
150
  export {
150
151
  s as Chainrails,
151
- p as chains,
152
+ c as chains,
152
153
  y as crapi,
153
154
  i as environment,
154
- c as tokens
155
+ p as tokens
155
156
  };
@@ -1,8 +1,8 @@
1
1
  import o from "ky";
2
- var p = /* @__PURE__ */ ((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 || {}), c = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(c || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
2
+ var c = /* @__PURE__ */ ((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))(c || {}), p = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(p || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
3
3
  class s {
4
- constructor({ api_key: e, env: r }) {
5
- this.api_key = e, this.jwt = "", this.env = r ?? i.PRODUCTION;
4
+ constructor({ api_key: e, env: n }) {
5
+ this.api_key = e, this.jwt = "", this.env = n ?? i.PRODUCTION;
6
6
  }
7
7
  static config(e) {
8
8
  if (!s.app) {
@@ -23,9 +23,10 @@ class s {
23
23
  })
24
24
  });
25
25
  console.log(e, this.getBaseUrl() + "/client/api-keys/session-token");
26
- const r = await e.json();
27
- console.log(r), this.app.jwt = r.token;
28
- } catch {
26
+ const n = await e.json();
27
+ console.log(n), this.app.jwt = n.token;
28
+ } catch (e) {
29
+ console.log(e);
29
30
  }
30
31
  }
31
32
  static getApiKey() {
@@ -34,7 +35,7 @@ class s {
34
35
  return s.app.api_key;
35
36
  }
36
37
  static getSessionKey() {
37
- return console.log("jwttt"), this.updateJWT(), s.app.jwt;
38
+ return console.log("jwttt"), this.updateJWT(), console.log("jwttt2"), s.app.jwt;
38
39
  }
39
40
  static getEnv() {
40
41
  if (!s.app)
@@ -54,9 +55,9 @@ class s {
54
55
  }
55
56
  }
56
57
  }
57
- let n = null;
58
+ let r = null;
58
59
  function l() {
59
- n = o.create({
60
+ r = o.create({
60
61
  prefixUrl: s.getBaseUrl(),
61
62
  headers: {
62
63
  "Content-Type": "application/json"
@@ -68,7 +69,7 @@ function l() {
68
69
  console.log({ Chainrails: s }, s.getApiKey(), s.getSessionKey()), t.headers.set("Authorization", `Bearer ${e}`);
69
70
  }
70
71
  ],
71
- afterResponse: [(t, e, r) => r]
72
+ afterResponse: [(t, e, n) => n]
72
73
  },
73
74
  retry: {
74
75
  limit: 2
@@ -76,9 +77,9 @@ function l() {
76
77
  });
77
78
  }
78
79
  function a() {
79
- return n || l(), n;
80
+ return r || l(), r;
80
81
  }
81
- class u {
82
+ class g {
82
83
  async getById(e) {
83
84
  return await a().get("intents/" + e).json();
84
85
  }
@@ -94,14 +95,14 @@ class u {
94
95
  async create(e) {
95
96
  return await a().post("intents", { json: e }).json();
96
97
  }
97
- async update(e, r) {
98
- return await a().post("intents", { json: r }).json();
98
+ async update(e, n) {
99
+ return await a().post("intents", { json: n }).json();
99
100
  }
100
101
  async triggerProcessing(e) {
101
102
  return await a().post(`intents/${e}/trigger-processing`).json();
102
103
  }
103
104
  }
104
- class g {
105
+ class u {
105
106
  async getFromSpecificBridge(e) {
106
107
  return await a().get("quotes/single", { searchParams: e }).json();
107
108
  }
@@ -115,7 +116,7 @@ class g {
115
116
  return await a().get("quotes/multi-source", { searchParams: e }).json();
116
117
  }
117
118
  }
118
- class T {
119
+ class h {
119
120
  async getOptimalRoutes(e) {
120
121
  return await a().get("router/optimal-route", { searchParams: e }).json();
121
122
  }
@@ -125,31 +126,31 @@ class T {
125
126
  async getSupportedBridges(e) {
126
127
  return await a().get("router/supported-bridges/route", { searchParams: e }).json();
127
128
  }
128
- async getSupportedRoutes(e, r) {
129
- return await a().get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
129
+ async getSupportedRoutes(e, n) {
130
+ return await a().get("router/supported-bridges/bridge/" + e, { searchParams: n }).json();
130
131
  }
131
132
  }
132
- class h {
133
+ class E {
133
134
  async getSupported(e) {
134
135
  return await a().get("chains", { searchParams: e }).json();
135
136
  }
136
137
  }
137
- class E {
138
+ class T {
138
139
  async getClientInfo() {
139
140
  return await a().get("client/auth/client-info").json();
140
141
  }
141
142
  }
142
143
  const y = {
143
- router: new T(),
144
- quotes: new g(),
145
- intents: new u(),
146
- chains: new h(),
147
- client: new E()
144
+ router: new h(),
145
+ quotes: new u(),
146
+ intents: new g(),
147
+ chains: new E(),
148
+ client: new T()
148
149
  };
149
150
  export {
150
151
  s as Chainrails,
151
- p as chains,
152
+ c as chains,
152
153
  y as crapi,
153
154
  i as environment,
154
- c as tokens
155
+ p as tokens
155
156
  };
@@ -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 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"})}));
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(e){console.log(e)}}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(),console.log("jwttt2"),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 d{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 T{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 d,quotes:new h,intents:new g,chains:new T,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.20",
4
+ "version": "0.0.21",
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.12",
38
+ "@chainrails/common": "^0.0.13",
39
39
  "ky": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {