@chainrails/common 0.0.13 → 0.0.14
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,7 +1,7 @@
|
|
|
1
|
-
var r = /* @__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))(r || {}),
|
|
1
|
+
var r = /* @__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))(r || {}), T = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(T || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
|
|
2
2
|
class e {
|
|
3
|
-
constructor({ api_key: a, env:
|
|
4
|
-
this.api_key = a, this.jwt = "", this.env =
|
|
3
|
+
constructor({ api_key: a, env: o }) {
|
|
4
|
+
this.api_key = a, this.jwt = "", this.env = o ?? i.PRODUCTION;
|
|
5
5
|
}
|
|
6
6
|
static config(a) {
|
|
7
7
|
if (!e.app) {
|
|
@@ -14,6 +14,7 @@ class e {
|
|
|
14
14
|
static async updateJWT() {
|
|
15
15
|
try {
|
|
16
16
|
const a = await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
|
|
17
|
+
method: "POST",
|
|
17
18
|
headers: {
|
|
18
19
|
Authorization: `Bearer ${e.app.api_key}`
|
|
19
20
|
},
|
|
@@ -22,8 +23,8 @@ class e {
|
|
|
22
23
|
})
|
|
23
24
|
});
|
|
24
25
|
console.log(a, this.getBaseUrl() + "/client/api-keys/session-token");
|
|
25
|
-
const
|
|
26
|
-
console.log(
|
|
26
|
+
const o = await a.json();
|
|
27
|
+
console.log(o), this.app.jwt = o.token;
|
|
27
28
|
} catch (a) {
|
|
28
29
|
console.log(a);
|
|
29
30
|
}
|
|
@@ -57,6 +58,6 @@ class e {
|
|
|
57
58
|
export {
|
|
58
59
|
e as Chainrails,
|
|
59
60
|
r as chains,
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
i as environment,
|
|
62
|
+
T as tokens
|
|
62
63
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var r = /* @__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))(r || {}),
|
|
1
|
+
var r = /* @__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))(r || {}), T = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(T || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
|
|
2
2
|
class e {
|
|
3
|
-
constructor({ api_key: a, env:
|
|
4
|
-
this.api_key = a, this.jwt = "", this.env =
|
|
3
|
+
constructor({ api_key: a, env: o }) {
|
|
4
|
+
this.api_key = a, this.jwt = "", this.env = o ?? i.PRODUCTION;
|
|
5
5
|
}
|
|
6
6
|
static config(a) {
|
|
7
7
|
if (!e.app) {
|
|
@@ -14,6 +14,7 @@ class e {
|
|
|
14
14
|
static async updateJWT() {
|
|
15
15
|
try {
|
|
16
16
|
const a = await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
|
|
17
|
+
method: "POST",
|
|
17
18
|
headers: {
|
|
18
19
|
Authorization: `Bearer ${e.app.api_key}`
|
|
19
20
|
},
|
|
@@ -22,8 +23,8 @@ class e {
|
|
|
22
23
|
})
|
|
23
24
|
});
|
|
24
25
|
console.log(a, this.getBaseUrl() + "/client/api-keys/session-token");
|
|
25
|
-
const
|
|
26
|
-
console.log(
|
|
26
|
+
const o = await a.json();
|
|
27
|
+
console.log(o), this.app.jwt = o.token;
|
|
27
28
|
} catch (a) {
|
|
28
29
|
console.log(a);
|
|
29
30
|
}
|
|
@@ -57,6 +58,6 @@ class e {
|
|
|
57
58
|
export {
|
|
58
59
|
e as Chainrails,
|
|
59
60
|
r as chains,
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
i as environment,
|
|
62
|
+
T as tokens
|
|
62
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.Chainrails={}))})(this,(function(n){"use strict";var o=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.BSC="BSC_MAINNET",e.ETHEREUM="ETHEREUM_MAINNET",e.ETHEREUM_TESTNET="ETHEREUM_TESTNET",e.STARKNET="STARKNET_MAINNET",e))(o||{}),T=(e=>(e.USDC="USDC",e))(T||{}),r=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(r||{});class t{constructor({api_key:i,env:a}){this.api_key=i,this.jwt="",this.env=a??r.PRODUCTION}static config(i){if(!t.app){if(!i)throw new Error("Please provide an api_key");t.app=new t(i)}return i&&(t.app.api_key=i.api_key,i.env!==void 0&&(t.app.env=i.env),this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),t.app}static async updateJWT(){try{const i=await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{headers:{Authorization:`Bearer ${t.app.api_key}`},body:JSON.stringify({apiKey:t.app.api_key})});console.log(i,this.getBaseUrl()+"/client/api-keys/session-token");const a=await i.json();console.log(a),this.app.jwt=a.token}catch(i){console.log(i)}}static getApiKey(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return t.app.api_key}static getSessionKey(){return console.log("jwttt"),this.updateJWT(),console.log("jwttt2"),t.app.jwt}static getEnv(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return t.app.env}static getBaseUrl(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(t.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"}}}n.Chainrails=t,n.chains=o,n.environment=r,n.tokens=T,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.Chainrails={}))})(this,(function(n){"use strict";var o=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.BSC="BSC_MAINNET",e.ETHEREUM="ETHEREUM_MAINNET",e.ETHEREUM_TESTNET="ETHEREUM_TESTNET",e.STARKNET="STARKNET_MAINNET",e))(o||{}),T=(e=>(e.USDC="USDC",e))(T||{}),r=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(r||{});class t{constructor({api_key:i,env:a}){this.api_key=i,this.jwt="",this.env=a??r.PRODUCTION}static config(i){if(!t.app){if(!i)throw new Error("Please provide an api_key");t.app=new t(i)}return i&&(t.app.api_key=i.api_key,i.env!==void 0&&(t.app.env=i.env),this.updateJWT(),setInterval(this.updateJWT.bind(this),1500*1e3)),t.app}static async updateJWT(){try{const i=await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",headers:{Authorization:`Bearer ${t.app.api_key}`},body:JSON.stringify({apiKey:t.app.api_key})});console.log(i,this.getBaseUrl()+"/client/api-keys/session-token");const a=await i.json();console.log(a),this.app.jwt=a.token}catch(i){console.log(i)}}static getApiKey(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return t.app.api_key}static getSessionKey(){return console.log("jwttt"),this.updateJWT(),console.log("jwttt2"),t.app.jwt}static getEnv(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return t.app.env}static getBaseUrl(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(t.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"}}}n.Chainrails=t,n.chains=o,n.environment=r,n.tokens=T,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtD,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAa;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO;WAMO,MAAM,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,UAAU;WAkBtC,SAAS;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEtD,UAAU,gBAAgB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAa;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IAEZ,OAAO;WAMO,MAAM,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,UAAU;WAkBtC,SAAS;WAoBf,SAAS,IAAI,MAAM;WAMnB,aAAa,IAAI,MAAM;WAOvB,MAAM,IAAI,OAAO;WAOjB,UAAU,IAAI,MAAM;CAanC"}
|