@chainrails/common 0.0.19 → 0.0.20

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.
@@ -56,7 +56,7 @@ class e {
56
56
  static getPayModalUrl(a, r, p, i) {
57
57
  if (!e.app)
58
58
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
59
- const o = e.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", s = i ? "/pay/" : "/deposit/", E = `_chain_/${a}/_token_/${r}/_to_/${p}/_amount_/${i && i * 100}`;
59
+ const o = e.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", s = i ? "/pay/" : "/deposit/", E = `_chain_/${a}/_token_/${r}/_to_/${p}${i && "/_amount_/" + i * 100}`;
60
60
  return o + s + E;
61
61
  }
62
62
  }
@@ -56,7 +56,7 @@ class e {
56
56
  static getPayModalUrl(a, r, p, i) {
57
57
  if (!e.app)
58
58
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
59
- const o = e.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", s = i ? "/pay/" : "/deposit/", E = `_chain_/${a}/_token_/${r}/_to_/${p}/_amount_/${i && i * 100}`;
59
+ const o = e.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", s = i ? "/pay/" : "/deposit/", E = `_chain_/${a}/_token_/${r}/_to_/${p}${i && "/_amount_/" + i * 100}`;
60
60
  return o + s + E;
61
61
  }
62
62
  }
@@ -1 +1 @@
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||{}),s=(e=>(e.USDC="USDC",e))(s||{}),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 async 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),await 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",headers:{"content-type":"application/json"},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,T,o){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":"https://app.chainrails.io",c=o?"/pay/":"/deposit/",f=`_chain_/${i}/_token_/${r}/_to_/${T}/_amount_/${o&&o*100}`;return E+c+f}}n.Chainrails=t,n.chains=a,n.environment=p,n.tokens=s,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||{}),s=(e=>(e.USDC="USDC",e))(s||{}),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 async 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),await 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",headers:{"content-type":"application/json"},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,T,o){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":"https://app.chainrails.io",c=o?"/pay/":"/deposit/",f=`_chain_/${i}/_token_/${r}/_to_/${T}${o&&"/_amount_/"+o*100}`;return E+c+f}}n.Chainrails=t,n.chains=a,n.environment=p,n.tokens=s,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
@@ -15,7 +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 | null): string;
18
+ static getPayModalUrl(chain: string, token: string, to: string, amount?: number): string;
19
19
  }
20
20
  export {};
21
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;WAMa,MAAM,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;WAkBrD,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,IAAI,GAAG,MAAM;CAetG"}
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;WAMa,MAAM,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;WAkBrD,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,CAAC,EAAE,MAAM,GAAG,MAAM;CAehG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chainrails/common",
3
3
  "sideEffects": false,
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "main": "./dist/chainrails-common.umd.js",
6
6
  "module": "./dist/chainrails-common.es.mjs",
7
7
  "license": "MIT",