@startbahn/startrail-sdk-js 1.29.0-beta.3 → 1.29.0

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.
@@ -168184,51 +168184,35 @@ function extend() {
168184
168184
 
168185
168185
  const constant_1 = __webpack_require__(/*! ../constant */ "./src/constant.ts");
168186
168186
  const util_1 = __webpack_require__(/*! ../util */ "./src/util.ts");
168187
+ function setNetwork(network, rpc) {
168188
+ return {
168189
+ chainId: util_1.convertNumberToHexString(network.chainId),
168190
+ chainName: network.name,
168191
+ rpcUrls: [rpc || network.rpc],
168192
+ nativeCurrency: {
168193
+ name: 'Matic',
168194
+ symbol: 'MATIC',
168195
+ decimals: 18
168196
+ }
168197
+ };
168198
+ }
168187
168199
  class MetamaskConfigContext {
168188
168200
  constructor(config) {
168189
- const devConf = {
168190
- chainId: util_1.convertNumberToHexString(constant_1.ETHEREUM_NETWORK.DEV.chainId),
168191
- chainName: `${constant_1.ETHEREUM_NETWORK.DEV.name} Network`,
168192
- rpcUrls: [(config === null || config === void 0 ? void 0 : config.rpcEndpoint) || constant_1.ETHEREUM_NETWORK.DEV.rpc],
168193
- nativeCurrency: {
168194
- name: 'Matic',
168195
- symbol: 'MATIC',
168196
- decimals: 18
168197
- }
168198
- };
168199
168201
  switch (config === null || config === void 0 ? void 0 : config.env) {
168200
168202
  case 'staging':
168201
- this.ethereumNetwork = devConf;
168203
+ this.ethereumNetwork = setNetwork(constant_1.ETHEREUM_NETWORK.DEV, config === null || config === void 0 ? void 0 : config.rpcEndpoint);
168202
168204
  break;
168203
168205
  case 'lrc':
168204
- this.ethereumNetwork = devConf;
168206
+ this.ethereumNetwork = setNetwork(constant_1.ETHEREUM_NETWORK.DEV, config === null || config === void 0 ? void 0 : config.rpcEndpoint);
168205
168207
  break;
168206
- case 'beta':
168207
- this.ethereumNetwork = devConf;
168208
+ case 'beta': // deprecate
168209
+ this.ethereumNetwork = setNetwork(constant_1.ETHEREUM_NETWORK.DEV, config === null || config === void 0 ? void 0 : config.rpcEndpoint);
168208
168210
  break;
168209
168211
  case 'local':
168210
- this.ethereumNetwork = {
168211
- chainId: util_1.convertNumberToHexString(constant_1.ETHEREUM_NETWORK.LOCAL.chainId),
168212
- chainName: `${constant_1.ETHEREUM_NETWORK.LOCAL.name} Network`,
168213
- rpcUrls: [(config === null || config === void 0 ? void 0 : config.rpcEndpoint) || constant_1.ETHEREUM_NETWORK.LOCAL.rpc],
168214
- nativeCurrency: {
168215
- name: 'Matic',
168216
- symbol: 'MATIC',
168217
- decimals: 18
168218
- }
168219
- };
168212
+ this.ethereumNetwork = setNetwork(constant_1.ETHEREUM_NETWORK.LOCAL, config === null || config === void 0 ? void 0 : config.rpcEndpoint);
168220
168213
  break;
168221
168214
  default: // For Production
168222
- this.ethereumNetwork = {
168223
- chainId: util_1.convertNumberToHexString(constant_1.ETHEREUM_NETWORK.PROD.chainId),
168224
- chainName: `${constant_1.ETHEREUM_NETWORK.PROD.name} Network`,
168225
- rpcUrls: [(config === null || config === void 0 ? void 0 : config.rpcEndpoint) || constant_1.ETHEREUM_NETWORK.PROD.rpc],
168226
- nativeCurrency: {
168227
- name: 'Matic',
168228
- symbol: 'MATIC',
168229
- decimals: 18
168230
- }
168231
- };
168215
+ this.ethereumNetwork = setNetwork(constant_1.ETHEREUM_NETWORK.PROD, config === null || config === void 0 ? void 0 : config.rpcEndpoint);
168232
168216
  }
168233
168217
  }
168234
168218
  }
@@ -168872,7 +168856,7 @@ exports.RPC_URLS = {
168872
168856
  };
168873
168857
  // Host name and chainId pair is defined and validated in torus-website.
168874
168858
  exports.ETHEREUM_NETWORK = {
168875
- PROD: { rpc: exports.RPC_URLS.PROD[0], chainId: 137, name: 'Polygon' },
168859
+ PROD: { rpc: exports.RPC_URLS.PROD[0], chainId: 137, name: 'Polygon Mainnet' },
168876
168860
  DEV: { rpc: exports.RPC_URLS.DEV[0], chainId: 80001, name: 'Mumbai' },
168877
168861
  LOCAL: { rpc: 'https://localhost:8545', chainId: 5777, name: 'Local' }
168878
168862
  };
@@ -170514,7 +170498,7 @@ class Metamask extends base_1.default {
170514
170498
  }
170515
170499
  catch (switchError) {
170516
170500
  // This error code indicates that the chain has not been added to MetaMask.
170517
- if (switchError.code === 4902) {
170501
+ if (switchError.code === 4902 || switchError.message.startsWith('Unrecognized chain ID')) {
170518
170502
  try {
170519
170503
  yield this.provider.request({
170520
170504
  method: 'wallet_addEthereumChain',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startbahn/startrail-sdk-js",
3
- "version": "1.29.0-beta.3",
3
+ "version": "1.29.0",
4
4
  "description": "Startrail Api for JS SDK",
5
5
  "main": "dist/startrail-sdk.js",
6
6
  "unpkg": "dist/startrail-sdk.js",