@chainrails/sdk 0.0.13 → 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.
@@ -36,14 +36,11 @@ class r {
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
  }
44
42
  }
45
43
  }
46
- console.log("I am the init implementation");
47
44
  let n = null;
48
45
  function u() {
49
46
  n = o.create({
@@ -119,7 +116,7 @@ class T {
119
116
  return await a().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
120
117
  }
121
118
  }
122
- class E {
119
+ class A {
123
120
  async getSupported(e) {
124
121
  return await a().get("chains", { searchParams: e }).json();
125
122
  }
@@ -133,7 +130,7 @@ const d = {
133
130
  router: new T(),
134
131
  quotes: new l(),
135
132
  intents: new g(),
136
- chains: new E(),
133
+ chains: new A(),
137
134
  client: new h()
138
135
  };
139
136
  export {
@@ -36,14 +36,11 @@ class r {
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
  }
44
42
  }
45
43
  }
46
- console.log("I am the init implementation");
47
44
  let n = null;
48
45
  function u() {
49
46
  n = o.create({
@@ -119,7 +116,7 @@ class T {
119
116
  return await a().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
120
117
  }
121
118
  }
122
- class E {
119
+ class A {
123
120
  async getSupported(e) {
124
121
  return await a().get("chains", { searchParams: e }).json();
125
122
  }
@@ -133,7 +130,7 @@ const d = {
133
130
  router: new T(),
134
131
  quotes: new l(),
135
132
  intents: new g(),
136
- chains: new E(),
133
+ chains: new A(),
137
134
  client: new h()
138
135
  };
139
136
  export {
@@ -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 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";case"internal":return"todo";default:return"https://api.chainrails.io/api/v1"}}}console.log("I am the init implementation");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=p,a.crapi=A,a.environment=o,a.tokens=u,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"})}));
@@ -1 +1 @@
1
- {"version":3,"file":"req.d.ts","sourceRoot":"","sources":["../../src/req.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,EAAE,OAAO,CAAC;KACzB;CACF;AAGD,QAAA,IAAI,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,GAAG,IAAW,CAAC;AAEpD,wBAAgB,UAAU,SAmBzB;AAED,wBAAgB,SAAS,4BAKxB;AAED,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"req.d.ts","sourceRoot":"","sources":["../../src/req.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,EAAE,OAAO,CAAC;KACzB;CACF;AAED,QAAA,IAAI,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,GAAG,IAAW,CAAC;AAEpD,wBAAgB,UAAU,SAmBzB;AAED,wBAAgB,SAAS,4BAKxB;AAED,eAAe,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chainrails/sdk",
3
3
  "sideEffects": false,
4
- "version": "0.0.13",
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": {