diff --git a/README.md b/README.md index 995fde5..cf87cae 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ import "dotenv/config"; import { initOrionUnit } from "@orionprotocol/sdk"; import { Wallet } from "ethers"; -const chain = process.env.CHAINID; // 0x38 +const chain = process.env.CHAINID; // "56" const env = process.env.ENV; // production const privateKey = process.env.PRIVATE_KEY; // 0x... @@ -42,7 +42,7 @@ import detectEthereumProvider from "@metamask/detect-provider"; import { BaseProvider } from "@metamask/providers"; import { providers } from "ethers"; -const chain = "0x61"; // bsc-testnet +const chain = "97"; // bsc-testnet const env = "testing"; const startApp = async (provider: BaseProvider) => { diff --git a/package.json b/package.json index 73149e1..edf00cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.4.1", + "version": "0.5.0", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/OrionUnit/Exchange/deposit.ts b/src/OrionUnit/Exchange/deposit.ts index 0de7ed2..2ade2da 100644 --- a/src/OrionUnit/Exchange/deposit.ts +++ b/src/OrionUnit/Exchange/deposit.ts @@ -107,7 +107,7 @@ export default async function deposit({ sources: ['wallet'], }); - unsignedTx.chainId = parseInt(chainId, 16); + unsignedTx.chainId = parseInt(chainId, 10); unsignedTx.gasPrice = ethers.BigNumber.from(gasPriceWei); unsignedTx.from = walletAddress; diff --git a/src/OrionUnit/Exchange/swapMarket.ts b/src/OrionUnit/Exchange/swapMarket.ts index facc9e0..eaa43f5 100644 --- a/src/OrionUnit/Exchange/swapMarket.ts +++ b/src/OrionUnit/Exchange/swapMarket.ts @@ -175,7 +175,7 @@ export default async function swapMarket({ type === 'exactSpend', ); - unsignedSwapThroughOrionPoolTx.chainId = parseInt(chainId, 16); + unsignedSwapThroughOrionPoolTx.chainId = parseInt(chainId, 10); unsignedSwapThroughOrionPoolTx.gasPrice = ethers.BigNumber.from(gasPriceWei); unsignedSwapThroughOrionPoolTx.from = walletAddress; diff --git a/src/OrionUnit/Exchange/withdraw.ts b/src/OrionUnit/Exchange/withdraw.ts index 64bc6bd..e04aff4 100644 --- a/src/OrionUnit/Exchange/withdraw.ts +++ b/src/OrionUnit/Exchange/withdraw.ts @@ -98,7 +98,7 @@ export default async function withdraw({ sources: ['wallet'], }); - unsignedTx.chainId = parseInt(chainId, 16); + unsignedTx.chainId = parseInt(chainId, 10); unsignedTx.gasPrice = ethers.BigNumber.from(gasPriceWei); unsignedTx.from = walletAddress; diff --git a/src/config/chains.json b/src/config/chains.json index 4a75146..9dcc6a8 100644 --- a/src/config/chains.json +++ b/src/config/chains.json @@ -1,54 +1,54 @@ { - "0x1": { - "chainId": "0x1", + "1": { + "chainId": "1", "explorer": "https://etherscan.io/", "label": "Ethereum", "code": "eth", "rpc": "https://trade.orionprotocol.io/rpc", "baseCurrencyName": "ETH" }, - "0x38": { - "chainId": "0x38", + "56": { + "chainId": "56", "explorer": "https://bscscan.com/", "label": "Binance Smart Chain", "code": "bsc", "rpc": "https://bsc-dataseed.binance.org/", "baseCurrencyName": "BNB" }, - "0x61": { - "chainId": "0x61", + "97": { + "chainId": "97", "explorer": "https://testnet.bscscan.com/", "label": "Binance Smart Chain Testnet", "code": "bsc", "rpc": "https://bsc-stage.node.orionprotocol.io/", "baseCurrencyName": "BNB" }, - "0x3": { - "chainId": "0x3", + "3": { + "chainId": "3", "explorer": "https://ropsten.etherscan.io/", "label": "Ropsten", "code": "eth", "rpc": "https://testing.orionprotocol.io/eth-ropsten/rpc", "baseCurrencyName": "ETH" }, - "0xfa2": { - "chainId": "0xfa2", + "4002": { + "chainId": "4002", "explorer": "https://testnet.ftmscan.com/", "label": "Fantom Testnet", "code": "ftm", "rpc": "https://testing.orionprotocol.io/ftm-testnet/rpc", "baseCurrencyName": "FTM" }, - "0xfa": { - "chainId": "0xfa", + "250": { + "chainId": "250", "explorer": "https://ftmscan.com/", "label": "Fantom", "code": "ftm", "rpc": "https://rpcapi.fantom.network/", "baseCurrencyName": "FTM" }, - "0x0": { - "chainId": "0x0", + "0": { + "chainId": "0", "explorer": "https://brokenscan.io/", "label": "BrokenChain", "code": "bkn", diff --git a/src/config/envs.json b/src/config/envs.json index 3328052..e13b533 100644 --- a/src/config/envs.json +++ b/src/config/envs.json @@ -1,67 +1,67 @@ { "production": { "networks": { - "0x1": { + "1": { "api": "trade.orionprotocol.io", "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" }, - "0x38": { + "56": { "api": "trade-exp.orionprotocol.io" } } }, "testing": { "networks": { - "0x61": { + "97": { "api": "testing.orionprotocol.io/bsc-testnet", - "liquidityMigratorAddress": "0x01b10dd12478C88A5E18e2707E729906bC25CfF6" + "liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6" }, - "0x3": { + "3": { "api": "testing.orionprotocol.io/eth-ropsten", "liquidityMigratorAddress": "0x36969a25622AE31bA9946e0c8151f0dc08b3A1c8" }, - "0xfa2": { + "4002": { "api": "testing.orionprotocol.io/ftm-testnet" } } }, "staging": { "networks": { - "0x1": { + "1": { "api": "staging.orionprotocol.io" }, - "0x38": { + "56": { "api": "staging-bsc.orionprotocol.io" }, - "0xfa": { + "250": { "api": "staging-ftm.orionprotocol.io" } } }, "broken": { "networks": { - "0x0": { + "0": { "api": "broken0.orionprotocol.io/everything-is-fine/this-url-was-created-for-tests-of-a-partially-broken-environment" }, - "0x61": { + "97": { "api": "broken1.orionprotocol.io/everything-is-fine/this-url-was-created-for-tests-of-a-partially-broken-environment" } } }, "partially-broken": { "networks": { - "0x61": { + "97": { "api": "testing.orionprotocol.io/bsc-testnet", "liquidityMigratorAddress": "0x01b10dd12478C88A5E18e2707E729906bC25CfF6" }, - "0x3": { + "3": { "api": "testing.orionprotocol.io/eth-ropsten", "liquidityMigratorAddress": "0x36969a25622AE31bA9946e0c8151f0dc08b3A1c8" }, - "0xfa2": { + "4002": { "api": "testing.orionprotocol.io/ftm-testnet" }, - "0x0": { + "0": { "api": "broken.orionprotocol.io/everything-is-fine/this-url-was-created-for-tests-of-a-partially-broken-environment" } } diff --git a/src/types.ts b/src/types.ts index d7a92e3..54b0b82 100644 --- a/src/types.ts +++ b/src/types.ts @@ -81,16 +81,16 @@ export type SwapInfoByAmountOut = SwapInfoBase & { export type SwapInfo = SwapInfoByAmountIn | SwapInfoByAmountOut; export enum SupportedChainId { - MAINNET = '0x1', - ROPSTEN = '0x3', - FANTOM_OPERA = '0xfa', + MAINNET = '1', + ROPSTEN = '3', + FANTOM_OPERA = '250', - FANTOM_TESTNET = '0xfa2', - BSC = '0x38', - BSC_TESTNET = '0x61', + FANTOM_TESTNET = '4002', + BSC = '56', + BSC_TESTNET = '97', // For testing and debug purpose - BROKEN = '0x0', + BROKEN = '0', } const balanceTypes = ['exchange', 'wallet'] as const;