@chainrails/sdk 0.0.14 → 0.0.15

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,43 +1,41 @@
1
1
  import o from "ky";
2
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
- class a {
3
+ class r {
4
4
  constructor({ api_key: e, env: s }) {
5
5
  this.api_key = e, this.env = s ?? i.PRODUCTION;
6
6
  }
7
7
  static config(e) {
8
- if (!a.app) {
8
+ if (!r.app) {
9
9
  if (!e)
10
10
  throw new Error("Please provide an api_key");
11
- a.app = new a(e);
11
+ r.app = new r(e);
12
12
  }
13
- return e && (a.app.api_key = e.api_key, e.env !== void 0 && (a.app.env = e.env)), a.app;
13
+ return e && (r.app.api_key = e.api_key, e.env !== void 0 && (r.app.env = e.env)), r.app;
14
14
  }
15
15
  static getApiKey() {
16
- if (!a.app)
16
+ if (!r.app)
17
17
  throw new Error(
18
18
  "Chainrails SDK not configured. Please call Chainrails.config() first."
19
19
  );
20
- return a.app.api_key;
20
+ return r.app.api_key;
21
21
  }
22
22
  static getEnv() {
23
- if (!a.app)
23
+ if (!r.app)
24
24
  throw new Error(
25
25
  "Chainrails SDK not configured. Please call Chainrails.config() first."
26
26
  );
27
- return a.app.env;
27
+ return r.app.env;
28
28
  }
29
29
  static getBaseUrl() {
30
- if (!a.app)
30
+ if (!r.app)
31
31
  throw new Error(
32
32
  "Chainrails SDK not configured. Please call Chainrails.config() first."
33
33
  );
34
- switch (a.app.env) {
34
+ switch (r.app.env) {
35
35
  case "production":
36
36
  return "https://api.chainrails.io/api/v1";
37
37
  case "staging":
38
38
  return "https://dev.chainrails.io/api/v1";
39
- case "internal":
40
- return "todo";
41
39
  default:
42
40
  return "https://api.chainrails.io/api/v1";
43
41
  }
@@ -46,14 +44,14 @@ class a {
46
44
  let n = null;
47
45
  function u() {
48
46
  n = o.create({
49
- prefixUrl: a.getBaseUrl(),
47
+ prefixUrl: r.getBaseUrl(),
50
48
  headers: {
51
49
  "Content-Type": "application/json"
52
50
  },
53
51
  hooks: {
54
52
  beforeRequest: [
55
53
  (t) => {
56
- const e = a.getApiKey();
54
+ const e = r.getApiKey();
57
55
  t.headers.set("Authorization", `Bearer ${e}`);
58
56
  }
59
57
  ],
@@ -64,79 +62,79 @@ function u() {
64
62
  }
65
63
  });
66
64
  }
67
- function r() {
65
+ function a() {
68
66
  return n || u(), n;
69
67
  }
70
68
  class g {
71
69
  async getById(e) {
72
- return await r().get("intents/" + e).json();
70
+ return await a().get("intents/" + e).json();
73
71
  }
74
72
  async getForSender(e) {
75
- return await r().get("intents/user/" + e).json();
73
+ return await a().get("intents/user/" + e).json();
76
74
  }
77
75
  async getForAddress(e) {
78
- return await r().get("intents/address/" + e).json();
76
+ return await a().get("intents/address/" + e).json();
79
77
  }
80
78
  async getAll(e) {
81
- return await r().get("intents", { searchParams: e }).json();
79
+ return await a().get("intents", { searchParams: e }).json();
82
80
  }
83
81
  async create(e) {
84
- return await r().post("intents", { json: e }).json();
82
+ return await a().post("intents", { json: e }).json();
85
83
  }
86
84
  async update(e, s) {
87
- return await r().post("intents", { json: s }).json();
85
+ return await a().post("intents", { json: s }).json();
88
86
  }
89
87
  async triggerProcessing(e) {
90
- return await r().post(`intents/${e}/trigger-processing`).json();
88
+ return await a().post(`intents/${e}/trigger-processing`).json();
91
89
  }
92
90
  }
93
91
  class l {
94
92
  async getFromSpecificBridge(e) {
95
- return await r().get("quotes/single", { searchParams: e }).json();
93
+ return await a().get("quotes/single", { searchParams: e }).json();
96
94
  }
97
95
  async getFromAllBridges(e) {
98
- return await r().get("quotes/multiple", { searchParams: e }).json();
96
+ return await a().get("quotes/multiple", { searchParams: e }).json();
99
97
  }
100
98
  async getBestAcrossBridges(e) {
101
- return await r().get("quotes/best", { searchParams: e }).json();
99
+ return await a().get("quotes/best", { searchParams: e }).json();
102
100
  }
103
101
  async getAll(e) {
104
- return await r().get("quotes/multi-source", { searchParams: e }).json();
102
+ return await a().get("quotes/multi-source", { searchParams: e }).json();
105
103
  }
106
104
  }
107
105
  class T {
108
106
  async getOptimalRoutes(e) {
109
- return await r().get("router/optimal-route", { searchParams: e }).json();
107
+ return await a().get("router/optimal-route", { searchParams: e }).json();
110
108
  }
111
109
  async getAllSupportedBridges() {
112
- return await r().get("router/supported-bridges/all").json();
110
+ return await a().get("router/supported-bridges/all").json();
113
111
  }
114
112
  async getSupportedBridges(e) {
115
- return await r().get("router/supported-bridges/route", { searchParams: e }).json();
113
+ return await a().get("router/supported-bridges/route", { searchParams: e }).json();
116
114
  }
117
115
  async getSupportedRoutes(e, s) {
118
- return await r().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
116
+ return await a().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
119
117
  }
120
118
  }
121
- class E {
119
+ class A {
122
120
  async getSupported(e) {
123
- return await r().get("chains", { searchParams: e }).json();
121
+ return await a().get("chains", { searchParams: e }).json();
124
122
  }
125
123
  }
126
- class A {
124
+ class h {
127
125
  async getClientInfo() {
128
- return await r().get("client/auth/client-info").json();
126
+ return await a().get("client/auth/client-info").json();
129
127
  }
130
128
  }
131
129
  const d = {
132
130
  router: new T(),
133
131
  quotes: new l(),
134
132
  intents: new g(),
135
- chains: new E(),
136
- client: new A()
133
+ chains: new A(),
134
+ client: new h()
137
135
  };
138
136
  export {
139
- a as Chainrails,
137
+ r as Chainrails,
140
138
  c as chains,
141
139
  d as crapi,
142
140
  i as environment,
@@ -1,43 +1,41 @@
1
1
  import o from "ky";
2
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
- class a {
3
+ class r {
4
4
  constructor({ api_key: e, env: s }) {
5
5
  this.api_key = e, this.env = s ?? i.PRODUCTION;
6
6
  }
7
7
  static config(e) {
8
- if (!a.app) {
8
+ if (!r.app) {
9
9
  if (!e)
10
10
  throw new Error("Please provide an api_key");
11
- a.app = new a(e);
11
+ r.app = new r(e);
12
12
  }
13
- return e && (a.app.api_key = e.api_key, e.env !== void 0 && (a.app.env = e.env)), a.app;
13
+ return e && (r.app.api_key = e.api_key, e.env !== void 0 && (r.app.env = e.env)), r.app;
14
14
  }
15
15
  static getApiKey() {
16
- if (!a.app)
16
+ if (!r.app)
17
17
  throw new Error(
18
18
  "Chainrails SDK not configured. Please call Chainrails.config() first."
19
19
  );
20
- return a.app.api_key;
20
+ return r.app.api_key;
21
21
  }
22
22
  static getEnv() {
23
- if (!a.app)
23
+ if (!r.app)
24
24
  throw new Error(
25
25
  "Chainrails SDK not configured. Please call Chainrails.config() first."
26
26
  );
27
- return a.app.env;
27
+ return r.app.env;
28
28
  }
29
29
  static getBaseUrl() {
30
- if (!a.app)
30
+ if (!r.app)
31
31
  throw new Error(
32
32
  "Chainrails SDK not configured. Please call Chainrails.config() first."
33
33
  );
34
- switch (a.app.env) {
34
+ switch (r.app.env) {
35
35
  case "production":
36
36
  return "https://api.chainrails.io/api/v1";
37
37
  case "staging":
38
38
  return "https://dev.chainrails.io/api/v1";
39
- case "internal":
40
- return "todo";
41
39
  default:
42
40
  return "https://api.chainrails.io/api/v1";
43
41
  }
@@ -46,14 +44,14 @@ class a {
46
44
  let n = null;
47
45
  function u() {
48
46
  n = o.create({
49
- prefixUrl: a.getBaseUrl(),
47
+ prefixUrl: r.getBaseUrl(),
50
48
  headers: {
51
49
  "Content-Type": "application/json"
52
50
  },
53
51
  hooks: {
54
52
  beforeRequest: [
55
53
  (t) => {
56
- const e = a.getApiKey();
54
+ const e = r.getApiKey();
57
55
  t.headers.set("Authorization", `Bearer ${e}`);
58
56
  }
59
57
  ],
@@ -64,79 +62,79 @@ function u() {
64
62
  }
65
63
  });
66
64
  }
67
- function r() {
65
+ function a() {
68
66
  return n || u(), n;
69
67
  }
70
68
  class g {
71
69
  async getById(e) {
72
- return await r().get("intents/" + e).json();
70
+ return await a().get("intents/" + e).json();
73
71
  }
74
72
  async getForSender(e) {
75
- return await r().get("intents/user/" + e).json();
73
+ return await a().get("intents/user/" + e).json();
76
74
  }
77
75
  async getForAddress(e) {
78
- return await r().get("intents/address/" + e).json();
76
+ return await a().get("intents/address/" + e).json();
79
77
  }
80
78
  async getAll(e) {
81
- return await r().get("intents", { searchParams: e }).json();
79
+ return await a().get("intents", { searchParams: e }).json();
82
80
  }
83
81
  async create(e) {
84
- return await r().post("intents", { json: e }).json();
82
+ return await a().post("intents", { json: e }).json();
85
83
  }
86
84
  async update(e, s) {
87
- return await r().post("intents", { json: s }).json();
85
+ return await a().post("intents", { json: s }).json();
88
86
  }
89
87
  async triggerProcessing(e) {
90
- return await r().post(`intents/${e}/trigger-processing`).json();
88
+ return await a().post(`intents/${e}/trigger-processing`).json();
91
89
  }
92
90
  }
93
91
  class l {
94
92
  async getFromSpecificBridge(e) {
95
- return await r().get("quotes/single", { searchParams: e }).json();
93
+ return await a().get("quotes/single", { searchParams: e }).json();
96
94
  }
97
95
  async getFromAllBridges(e) {
98
- return await r().get("quotes/multiple", { searchParams: e }).json();
96
+ return await a().get("quotes/multiple", { searchParams: e }).json();
99
97
  }
100
98
  async getBestAcrossBridges(e) {
101
- return await r().get("quotes/best", { searchParams: e }).json();
99
+ return await a().get("quotes/best", { searchParams: e }).json();
102
100
  }
103
101
  async getAll(e) {
104
- return await r().get("quotes/multi-source", { searchParams: e }).json();
102
+ return await a().get("quotes/multi-source", { searchParams: e }).json();
105
103
  }
106
104
  }
107
105
  class T {
108
106
  async getOptimalRoutes(e) {
109
- return await r().get("router/optimal-route", { searchParams: e }).json();
107
+ return await a().get("router/optimal-route", { searchParams: e }).json();
110
108
  }
111
109
  async getAllSupportedBridges() {
112
- return await r().get("router/supported-bridges/all").json();
110
+ return await a().get("router/supported-bridges/all").json();
113
111
  }
114
112
  async getSupportedBridges(e) {
115
- return await r().get("router/supported-bridges/route", { searchParams: e }).json();
113
+ return await a().get("router/supported-bridges/route", { searchParams: e }).json();
116
114
  }
117
115
  async getSupportedRoutes(e, s) {
118
- return await r().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
116
+ return await a().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
119
117
  }
120
118
  }
121
- class E {
119
+ class A {
122
120
  async getSupported(e) {
123
- return await r().get("chains", { searchParams: e }).json();
121
+ return await a().get("chains", { searchParams: e }).json();
124
122
  }
125
123
  }
126
- class A {
124
+ class h {
127
125
  async getClientInfo() {
128
- return await r().get("client/auth/client-info").json();
126
+ return await a().get("client/auth/client-info").json();
129
127
  }
130
128
  }
131
129
  const d = {
132
130
  router: new T(),
133
131
  quotes: new l(),
134
132
  intents: new g(),
135
- chains: new E(),
136
- client: new A()
133
+ chains: new A(),
134
+ client: new h()
137
135
  };
138
136
  export {
139
- a as Chainrails,
137
+ r as Chainrails,
140
138
  c as chains,
141
139
  d as crapi,
142
140
  i as environment,
@@ -1 +1 @@
1
- (function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.Chainrails={},a.Ky))})(this,(function(a,i){"use strict";var u=(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))(u||{}),p=(t=>(t.USDC="USDC",t))(p||{}),o=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(o||{});class r{constructor({api_key:e,env:s}){this.api_key=e,this.env=s??o.PRODUCTION}static config(e){if(!r.app){if(!e)throw new Error("Please provide an api_key");r.app=new r(e)}return e&&(r.app.api_key=e.api_key,e.env!==void 0&&(r.app.env=e.env)),r.app}static getApiKey(){if(!r.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return r.app.api_key}static getEnv(){if(!r.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return r.app.env}static getBaseUrl(){if(!r.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(r.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"todo";default:return"https://api.chainrails.io/api/v1"}}}let c=null;function l(){c=i.create({prefixUrl:r.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=r.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},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,s){return await n().post("intents",{json:s}).json()}async triggerProcessing(e){return await n().post(`intents/${e}/trigger-processing`).json()}}class T{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,s){return await n().get("router/supported-bridges/bridge/"+e,{searchParams:s}).json()}}class E{async getSupported(e){return await n().get("chains",{searchParams:e}).json()}}class h{async getClientInfo(){return await n().get("client/auth/client-info").json()}}const A={router:new d,quotes:new T,intents:new g,chains:new E,client:new h};a.Chainrails=r,a.chains=u,a.crapi=A,a.environment=o,a.tokens=p,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("ky")):typeof define=="function"&&define.amd?define(["exports","ky"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.Chainrails={},a.Ky))})(this,(function(a,i){"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 r{constructor({api_key:e,env:s}){this.api_key=e,this.env=s??o.PRODUCTION}static config(e){if(!r.app){if(!e)throw new Error("Please provide an api_key");r.app=new r(e)}return e&&(r.app.api_key=e.api_key,e.env!==void 0&&(r.app.env=e.env)),r.app}static getApiKey(){if(!r.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return r.app.api_key}static getEnv(){if(!r.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return r.app.env}static getBaseUrl(){if(!r.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(r.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 g(){c=i.create({prefixUrl:r.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=r.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function n(){return c||g(),c}class l{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,s){return await n().post("intents",{json:s}).json()}async triggerProcessing(e){return await n().post(`intents/${e}/trigger-processing`).json()}}class T{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,s){return await n().get("router/supported-bridges/bridge/"+e,{searchParams:s}).json()}}class h{async getSupported(e){return await n().get("chains",{searchParams:e}).json()}}class A{async getClientInfo(){return await n().get("client/auth/client-info").json()}}const f={router:new d,quotes:new T,intents:new l,chains:new h,client:new A};a.Chainrails=r,a.chains=p,a.crapi=f,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.14",
4
+ "version": "0.0.15",
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.7",
38
+ "@chainrails/common": "^0.0.9",
39
39
  "ky": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {