@chainrails/common 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,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 || {}), T = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(T || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
1
+ var o = /* @__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))(o || {}), s = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(s || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
2
2
  class e {
3
- constructor({ api_key: a, env: o }) {
4
- this.api_key = a, this.jwt = "", this.env = o ?? i.PRODUCTION;
3
+ constructor({ api_key: a, env: r }) {
4
+ this.api_key = a, this.jwt = "", this.env = r ?? i.PRODUCTION;
5
5
  }
6
6
  static config(a) {
7
7
  if (!e.app) {
@@ -13,20 +13,17 @@ class e {
13
13
  }
14
14
  static async updateJWT() {
15
15
  try {
16
- const a = await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
16
+ const r = await (await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
17
17
  method: "POST",
18
- headers: {
19
- Authorization: `Bearer ${e.app.api_key}`
20
- },
18
+ // headers: {
19
+ // Authorization: `Bearer ${Chainrails.app.api_key}`,
20
+ // },
21
21
  body: JSON.stringify({
22
22
  apiKey: e.app.api_key
23
23
  })
24
- });
25
- console.log(a, this.getBaseUrl() + "/client/api-keys/session-token");
26
- const o = await a.json();
27
- console.log(o), this.app.jwt = o.token;
28
- } catch (a) {
29
- console.log(a);
24
+ })).json();
25
+ this.app.jwt = r.token;
26
+ } catch {
30
27
  }
31
28
  }
32
29
  static getApiKey() {
@@ -35,12 +32,12 @@ class e {
35
32
  return e.app.api_key;
36
33
  }
37
34
  static getSessionKey() {
38
- return console.log("jwttt"), this.updateJWT(), console.log("jwttt2"), e.app.jwt;
35
+ return e.app.jwt;
39
36
  }
40
37
  static getEnv() {
41
38
  if (!e.app)
42
39
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
43
- return e.app.env;
40
+ return e.app.env === "internal" ? "staging" : e.app.env;
44
41
  }
45
42
  static getBaseUrl() {
46
43
  if (!e.app)
@@ -50,14 +47,22 @@ class e {
50
47
  return "https://api.chainrails.io/api/v1";
51
48
  case "staging":
52
49
  return "https://dev.chainrails.io/api/v1";
50
+ case "internal":
51
+ return "https://dev.chainrails.io/api/v1";
53
52
  default:
54
53
  return "https://api.chainrails.io/api/v1";
55
54
  }
56
55
  }
56
+ static getPayModalUrl(a, r, n, p) {
57
+ if (!e.app)
58
+ throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
59
+ const E = e.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app/pay/" : "https://app.chainrails.io/pay/", T = `${a}/_token_/${r}/_to_/${n}/_amount_/${p * 100}`;
60
+ return E + T;
61
+ }
57
62
  }
58
63
  export {
59
64
  e as Chainrails,
60
- r as chains,
65
+ o as chains,
61
66
  i as environment,
62
- T as tokens
67
+ s as tokens
63
68
  };
@@ -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 || {}), T = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(T || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
1
+ var o = /* @__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))(o || {}), s = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(s || {}), i = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(i || {});
2
2
  class e {
3
- constructor({ api_key: a, env: o }) {
4
- this.api_key = a, this.jwt = "", this.env = o ?? i.PRODUCTION;
3
+ constructor({ api_key: a, env: r }) {
4
+ this.api_key = a, this.jwt = "", this.env = r ?? i.PRODUCTION;
5
5
  }
6
6
  static config(a) {
7
7
  if (!e.app) {
@@ -13,20 +13,17 @@ class e {
13
13
  }
14
14
  static async updateJWT() {
15
15
  try {
16
- const a = await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
16
+ const r = await (await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
17
17
  method: "POST",
18
- headers: {
19
- Authorization: `Bearer ${e.app.api_key}`
20
- },
18
+ // headers: {
19
+ // Authorization: `Bearer ${Chainrails.app.api_key}`,
20
+ // },
21
21
  body: JSON.stringify({
22
22
  apiKey: e.app.api_key
23
23
  })
24
- });
25
- console.log(a, this.getBaseUrl() + "/client/api-keys/session-token");
26
- const o = await a.json();
27
- console.log(o), this.app.jwt = o.token;
28
- } catch (a) {
29
- console.log(a);
24
+ })).json();
25
+ this.app.jwt = r.token;
26
+ } catch {
30
27
  }
31
28
  }
32
29
  static getApiKey() {
@@ -35,12 +32,12 @@ class e {
35
32
  return e.app.api_key;
36
33
  }
37
34
  static getSessionKey() {
38
- return console.log("jwttt"), this.updateJWT(), console.log("jwttt2"), e.app.jwt;
35
+ return e.app.jwt;
39
36
  }
40
37
  static getEnv() {
41
38
  if (!e.app)
42
39
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
43
- return e.app.env;
40
+ return e.app.env === "internal" ? "staging" : e.app.env;
44
41
  }
45
42
  static getBaseUrl() {
46
43
  if (!e.app)
@@ -50,14 +47,22 @@ class e {
50
47
  return "https://api.chainrails.io/api/v1";
51
48
  case "staging":
52
49
  return "https://dev.chainrails.io/api/v1";
50
+ case "internal":
51
+ return "https://dev.chainrails.io/api/v1";
53
52
  default:
54
53
  return "https://api.chainrails.io/api/v1";
55
54
  }
56
55
  }
56
+ static getPayModalUrl(a, r, n, p) {
57
+ if (!e.app)
58
+ throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
59
+ const E = e.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app/pay/" : "https://app.chainrails.io/pay/", T = `${a}/_token_/${r}/_to_/${n}/_amount_/${p * 100}`;
60
+ return E + T;
61
+ }
57
62
  }
58
63
  export {
59
64
  e as Chainrails,
60
- r as chains,
65
+ o as chains,
61
66
  i as environment,
62
- T as tokens
67
+ s as tokens
63
68
  };
@@ -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",{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
+ (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.Chainrails={}))})(this,(function(n){"use strict";var a=(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))(a||{}),o=(e=>(e.USDC="USDC",e))(o||{}),p=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(p||{});class t{constructor({api_key:i,env:r}){this.api_key=i,this.jwt="",this.env=r??p.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 r=await(await fetch(this.getBaseUrl()+"/client/api-keys/session-token",{method:"POST",body:JSON.stringify({apiKey:t.app.api_key})})).json();this.app.jwt=r.token}catch{}}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 t.app.jwt}static getEnv(){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return t.app.env==="internal"?"staging":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";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(i,r,s,T){if(!t.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const E=t.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app/pay/":"https://app.chainrails.io/pay/",c=`${i}/_token_/${r}/_to_/${s}/_amount_/${T*100}`;return E+c}}n.Chainrails=t,n.chains=a,n.environment=p,n.tokens=o,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
@@ -15,6 +15,7 @@ export declare class Chainrails {
15
15
  static getSessionKey(): string;
16
16
  static getEnv(): EnvType;
17
17
  static getBaseUrl(): string;
18
+ static getPayModalUrl(chain: string, token: string, to: string, amount: number): string;
18
19
  }
19
20
  export {};
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -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;WAoBf,SAAS,IAAI,MAAM;WAMnB,aAAa,IAAI,MAAM;WAOvB,MAAM,IAAI,OAAO;WAOjB,UAAU,IAAI,MAAM;CAanC"}
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;WAgBf,SAAS,IAAI,MAAM;WAOnB,aAAa,IAAI,MAAM;WAIvB,MAAM,IAAI,OAAO;WAQjB,UAAU,IAAI,MAAM;WAgBpB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;CAa/F"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chainrails/common",
3
3
  "sideEffects": false,
4
- "version": "0.0.14",
4
+ "version": "0.0.15",
5
5
  "main": "./dist/chainrails-common.umd.js",
6
6
  "module": "./dist/chainrails-common.es.mjs",
7
7
  "license": "MIT",