@chainrails/sdk 0.0.20 → 0.0.22

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) {
@@ -15,6 +15,7 @@ class s {
15
15
  static async updateJWT() {
16
16
  try {
17
17
  const e = await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
18
+ method: "POST",
18
19
  headers: {
19
20
  Authorization: `Bearer ${s.app.api_key}`
20
21
  },
@@ -23,9 +24,10 @@ class s {
23
24
  })
24
25
  });
25
26
  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 {
27
+ const n = await e.json();
28
+ console.log(n), this.app.jwt = n.token;
29
+ } catch (e) {
30
+ console.log(e);
29
31
  }
30
32
  }
31
33
  static getApiKey() {
@@ -34,7 +36,7 @@ class s {
34
36
  return s.app.api_key;
35
37
  }
36
38
  static getSessionKey() {
37
- return console.log("jwttt"), this.updateJWT(), s.app.jwt;
39
+ return console.log("jwttt"), this.updateJWT(), console.log("jwttt2"), s.app.jwt;
38
40
  }
39
41
  static getEnv() {
40
42
  if (!s.app)
@@ -54,9 +56,9 @@ class s {
54
56
  }
55
57
  }
56
58
  }
57
- let n = null;
59
+ let r = null;
58
60
  function l() {
59
- n = o.create({
61
+ r = o.create({
60
62
  prefixUrl: s.getBaseUrl(),
61
63
  headers: {
62
64
  "Content-Type": "application/json"
@@ -68,7 +70,7 @@ function l() {
68
70
  console.log({ Chainrails: s }, s.getApiKey(), s.getSessionKey()), t.headers.set("Authorization", `Bearer ${e}`);
69
71
  }
70
72
  ],
71
- afterResponse: [(t, e, r) => r]
73
+ afterResponse: [(t, e, n) => n]
72
74
  },
73
75
  retry: {
74
76
  limit: 2
@@ -76,9 +78,9 @@ function l() {
76
78
  });
77
79
  }
78
80
  function a() {
79
- return n || l(), n;
81
+ return r || l(), r;
80
82
  }
81
- class u {
83
+ class g {
82
84
  async getById(e) {
83
85
  return await a().get("intents/" + e).json();
84
86
  }
@@ -94,14 +96,14 @@ class u {
94
96
  async create(e) {
95
97
  return await a().post("intents", { json: e }).json();
96
98
  }
97
- async update(e, r) {
98
- return await a().post("intents", { json: r }).json();
99
+ async update(e, n) {
100
+ return await a().post("intents", { json: n }).json();
99
101
  }
100
102
  async triggerProcessing(e) {
101
103
  return await a().post(`intents/${e}/trigger-processing`).json();
102
104
  }
103
105
  }
104
- class g {
106
+ class u {
105
107
  async getFromSpecificBridge(e) {
106
108
  return await a().get("quotes/single", { searchParams: e }).json();
107
109
  }
@@ -125,8 +127,8 @@ class T {
125
127
  async getSupportedBridges(e) {
126
128
  return await a().get("router/supported-bridges/route", { searchParams: e }).json();
127
129
  }
128
- async getSupportedRoutes(e, r) {
129
- return await a().get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
130
+ async getSupportedRoutes(e, n) {
131
+ return await a().get("router/supported-bridges/bridge/" + e, { searchParams: n }).json();
130
132
  }
131
133
  }
132
134
  class h {
@@ -141,15 +143,15 @@ class E {
141
143
  }
142
144
  const y = {
143
145
  router: new T(),
144
- quotes: new g(),
145
- intents: new u(),
146
+ quotes: new u(),
147
+ intents: new g(),
146
148
  chains: new h(),
147
149
  client: new E()
148
150
  };
149
151
  export {
150
152
  s as Chainrails,
151
- p as chains,
153
+ c as chains,
152
154
  y as crapi,
153
155
  i as environment,
154
- c as tokens
156
+ p as tokens
155
157
  };
@@ -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) {
@@ -15,6 +15,7 @@ class s {
15
15
  static async updateJWT() {
16
16
  try {
17
17
  const e = await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
18
+ method: "POST",
18
19
  headers: {
19
20
  Authorization: `Bearer ${s.app.api_key}`
20
21
  },
@@ -23,9 +24,10 @@ class s {
23
24
  })
24
25
  });
25
26
  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 {
27
+ const n = await e.json();
28
+ console.log(n), this.app.jwt = n.token;
29
+ } catch (e) {
30
+ console.log(e);
29
31
  }
30
32
  }
31
33
  static getApiKey() {
@@ -34,7 +36,7 @@ class s {
34
36
  return s.app.api_key;
35
37
  }
36
38
  static getSessionKey() {
37
- return console.log("jwttt"), this.updateJWT(), s.app.jwt;
39
+ return console.log("jwttt"), this.updateJWT(), console.log("jwttt2"), s.app.jwt;
38
40
  }
39
41
  static getEnv() {
40
42
  if (!s.app)
@@ -54,9 +56,9 @@ class s {
54
56
  }
55
57
  }
56
58
  }
57
- let n = null;
59
+ let r = null;
58
60
  function l() {
59
- n = o.create({
61
+ r = o.create({
60
62
  prefixUrl: s.getBaseUrl(),
61
63
  headers: {
62
64
  "Content-Type": "application/json"
@@ -68,7 +70,7 @@ function l() {
68
70
  console.log({ Chainrails: s }, s.getApiKey(), s.getSessionKey()), t.headers.set("Authorization", `Bearer ${e}`);
69
71
  }
70
72
  ],
71
- afterResponse: [(t, e, r) => r]
73
+ afterResponse: [(t, e, n) => n]
72
74
  },
73
75
  retry: {
74
76
  limit: 2
@@ -76,9 +78,9 @@ function l() {
76
78
  });
77
79
  }
78
80
  function a() {
79
- return n || l(), n;
81
+ return r || l(), r;
80
82
  }
81
- class u {
83
+ class g {
82
84
  async getById(e) {
83
85
  return await a().get("intents/" + e).json();
84
86
  }
@@ -94,14 +96,14 @@ class u {
94
96
  async create(e) {
95
97
  return await a().post("intents", { json: e }).json();
96
98
  }
97
- async update(e, r) {
98
- return await a().post("intents", { json: r }).json();
99
+ async update(e, n) {
100
+ return await a().post("intents", { json: n }).json();
99
101
  }
100
102
  async triggerProcessing(e) {
101
103
  return await a().post(`intents/${e}/trigger-processing`).json();
102
104
  }
103
105
  }
104
- class g {
106
+ class u {
105
107
  async getFromSpecificBridge(e) {
106
108
  return await a().get("quotes/single", { searchParams: e }).json();
107
109
  }
@@ -125,8 +127,8 @@ class T {
125
127
  async getSupportedBridges(e) {
126
128
  return await a().get("router/supported-bridges/route", { searchParams: e }).json();
127
129
  }
128
- async getSupportedRoutes(e, r) {
129
- return await a().get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
130
+ async getSupportedRoutes(e, n) {
131
+ return await a().get("router/supported-bridges/bridge/" + e, { searchParams: n }).json();
130
132
  }
131
133
  }
132
134
  class h {
@@ -141,15 +143,15 @@ class E {
141
143
  }
142
144
  const y = {
143
145
  router: new T(),
144
- quotes: new g(),
145
- intents: new u(),
146
+ quotes: new u(),
147
+ intents: new g(),
146
148
  chains: new h(),
147
149
  client: new E()
148
150
  };
149
151
  export {
150
152
  s as Chainrails,
151
- p as chains,
153
+ c as chains,
152
154
  y as crapi,
153
155
  i as environment,
154
- c as tokens
156
+ p as tokens
155
157
  };
@@ -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",{method:"POST",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 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.20",
4
+ "version": "0.0.22",
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.14",
39
39
  "ky": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {