Skip to content

Commit

Permalink
feat: sdk init params
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyu1225 committed Oct 14, 2024
1 parent 8ecb73c commit 4d93d48
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@blocto/dappauth": "^2.1.0",
"@blocto/fcl": "^1.0.0-alpha.1",
"@blocto/sdk": "0.10.3-beta.0",
"@blocto/sdk": "0.10.4",
"@chakra-ui/icons": "^1.1.1",
"@chakra-ui/react": "^1.7.4",
"@emotion/react": "^11",
Expand Down
30 changes: 17 additions & 13 deletions src/services/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,16 @@ export const supportedChains = [
faucet: "https://docs.scroll.io/en/user-guide/faucet/",
environment: "testnet",
},
{
name: "Linea",
chainId: "0xe708",
rpcUrls: ["https://rpc.linea.build"],
environment: "mainnet",
},
/**
* be api (https://api.blocto.app/networks/evm) not be supported
* sdk load supported chains error
*/
// {
// name: "Linea",
// chainId: "0xe708",
// rpcUrls: ["https://rpc.linea.build"],
// environment: "mainnet",
// },
{
name: "zKatana Sepolia Testnet",
chainId: "0x133e40",
Expand Down Expand Up @@ -173,21 +177,21 @@ export const supportedChains = [
},
];

const switchableChains = supportedChains.map((chain) => ({
chainId: chain.chainId,
rpcUrls: chain.rpcUrls,
}));

const bloctoSDK = new BloctoSDK({
ethereum: {
// (required) chainId to be used
chainId: isMainnet ? "0x1" : "0xaa36a7",
// (required for Ethereum) JSON RPC endpoint
rpc: isMainnet
? `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`
: "https://ethereum-sepolia.blockpi.network/v1/rpc/public",
defaultChainId: isMainnet ? "0x1" : "0xaa36a7",
walletServer: process.env.REACT_APP_WALLET_SERVER,
switchableChains,
},
appId: process.env.REACT_APP_DAPP_ID,
}) as ExtendedEvmBloctoSDK;

bloctoSDK.ethereum.loadSwitchableNetwork(supportedChains);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const web3 = new Web3(bloctoSDK.ethereum);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,10 @@
deepmerge "^4.2.2"
sha3 "^2.1.4"

"@blocto/sdk@0.10.3-beta.0":
version "0.10.3-beta.0"
resolved "https://registry.yarnpkg.com/@blocto/sdk/-/sdk-0.10.3-beta.0.tgz#23f46a0a3882897d023d3a8331082df3cf5c9127"
integrity sha512-lp3HAbK7xEY/FOYDAVIS510TquqWud/tMfwDPihtpJGo74ZehFgoat7C+2HgC7S5U+RcaOyDcrvihHEWDlMBRA==
"@blocto/sdk@0.10.4":
version "0.10.4"
resolved "https://registry.yarnpkg.com/@blocto/sdk/-/sdk-0.10.4.tgz#ca78ada9961c86667423b15cda7be6459f8f2e48"
integrity sha512-tLPYS54zM6Rp5GX4QfLm9JUoxtu19kWCljLc6xwRK5zGnca4avnAqqlwowdexG1aAjU9nVyKLedig33AGLKsKg==
dependencies:
buffer "^6.0.3"
eip1193-provider "^1.0.1"
Expand Down

0 comments on commit 4d93d48

Please sign in to comment.