Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit d2bae86

Browse files
authored
Merge pull request #435 from blocto/develop
fix: multiplechain setting and update rpc url
2 parents f9eb562 + 8d074d4 commit d2bae86

File tree

20 files changed

+559
-16
lines changed

20 files changed

+559
-16
lines changed

.changeset/cold-eggs-film.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@blocto/sdk': patch
3+
---
4+
5+
fix story tesnet url, fix multiple chain setting, update polygon url
6+

.changeset/nasty-cats-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@blocto/sdk': patch
3+
---
4+
5+
support Story testnet

.changeset/pre.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"mode": "exit",
3+
"tag": "beta",
4+
"initialVersions": {
5+
"@blocto/aptos-wallet-adapter-plugin": "0.2.11-beta.0",
6+
"@blocto/connectkit-connector": "0.2.3",
7+
"@blocto/rainbowkit-connector": "2.0.3-beta.0",
8+
"@blocto/wagmi-connector": "2.0.5-beta.0",
9+
"@blocto/web3-react-connector": "1.0.9-beta.0",
10+
"@blocto/web3modal-connector": "0.1.4",
11+
"@blocto/sdk": "0.10.4-beta.1",
12+
"@blocto/dappauth": "2.2.2",
13+
"eslint-config-custom": "0.0.0",
14+
"tsconfig": "0.0.0"
15+
},
16+
"changesets": [
17+
"nasty-cats-greet",
18+
"yellow-rockets-judge"
19+
]
20+
}

.changeset/yellow-rockets-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@blocto/sdk': patch
3+
---
4+
5+
fix multiple chain setting

adapters/aptos-wallet-adapter-plugin/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @blocto/aptos-wallet-adapter-plugin
22

3+
## 0.2.11-beta.0
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ec87223]
8+
- @blocto/sdk@0.10.4-beta.0
9+
310
## 0.2.10
411

512
### Patch Changes

adapters/aptos-wallet-adapter-plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blocto/aptos-wallet-adapter-plugin",
3-
"version": "0.2.10",
3+
"version": "0.2.11-beta.0",
44
"description": "Blocto Wallet plugin to use with Aptos Wallet Adapter",
55
"author": "Blocto Wallet",
66
"main": "./dist/index.js",
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@aptos-labs/wallet-adapter-core": "^2.2.0",
22-
"@blocto/sdk": "^0.10.3",
22+
"@blocto/sdk": "^0.10.4-beta.0",
2323
"aptos": "^1.9.1"
2424
},
2525
"devDependencies": {

adapters/rainbowkit-connector/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @blocto/rainbowkit-connector
22

3+
## 2.0.3-beta.0
4+
5+
### Patch Changes
6+
7+
- @blocto/wagmi-connector@2.0.5-beta.0
8+
39
## 2.0.2
410

511
### Patch Changes

adapters/rainbowkit-connector/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blocto/rainbowkit-connector",
3-
"version": "2.0.2",
3+
"version": "2.0.3-beta.0",
44
"description": "blocto wallet connector to use rainbowkit",
55
"author": "Blocto Wallet",
66
"main": "./dist/index.js",
@@ -34,7 +34,7 @@
3434
},
3535
"dependencies": {
3636
"@rainbow-me/rainbowkit": "^2.0.5",
37-
"@blocto/wagmi-connector": "^2.0.4"
37+
"@blocto/wagmi-connector": "^2.0.5-beta.0"
3838
},
3939
"devDependencies": {
4040
"@types/jest": "^29.5.2",

adapters/wagmi-connector/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @blocto/wagmi-connector
22

3+
## 2.0.5-beta.0
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ec87223]
8+
- @blocto/sdk@0.10.4-beta.0
9+
310
## 2.0.4
411

512
### Patch Changes

adapters/wagmi-connector/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@blocto/wagmi-connector",
33
"description": "Blocto wallet connector extend from wagmi Connector",
44
"author": "Calvin Chang",
5-
"version": "2.0.4",
5+
"version": "2.0.5-beta.0",
66
"type": "module",
77
"main": "./dist/index.umd.cjs",
88
"module": "./dist/index.js",
@@ -32,7 +32,7 @@
3232
"/dist"
3333
],
3434
"dependencies": {
35-
"@blocto/sdk": "^0.10.3"
35+
"@blocto/sdk": "^0.10.4-beta.0"
3636
},
3737
"peerDependencies": {
3838
"@wagmi/core": "^2.2.0",

adapters/web3-react-connector/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @blocto/web3-react-connector
22

3+
## 1.0.9-beta.0
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [ec87223]
8+
- @blocto/sdk@0.10.4-beta.0
9+
310
## 1.0.8
411

512
### Patch Changes

adapters/web3-react-connector/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blocto/web3-react-connector",
3-
"version": "1.0.8",
3+
"version": "1.0.9-beta.0",
44
"description": "A Blocto SDK connector for web3-react",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",
@@ -43,7 +43,7 @@
4343
"url": "git://github.com/portto/blocto-sdk.git"
4444
},
4545
"dependencies": {
46-
"@blocto/sdk": "^0.10.3",
46+
"@blocto/sdk": "^0.10.4-beta.0",
4747
"@web3-react/types": "^8.1.2-beta.0"
4848
},
4949
"devDependencies": {

packages/blocto-sdk/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @blocto/sdk
22

3+
## 0.10.4-beta.1
4+
5+
### Patch Changes
6+
7+
- 2e2164e: fix multiple chain setting
8+
9+
## 0.10.4-beta.0
10+
11+
### Patch Changes
12+
13+
- ec87223: support Story testnet
14+
315
## 0.10.3
416

517
### Patch Changes

packages/blocto-sdk/jest.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
'^.+\\.(ts|tsx)?$': 'ts-jest',
77
'^.+\\.(js|jsx)$': 'babel-jest',
88
},
9-
transformIgnorePatterns: ['node_modules/(?!variables/.*)'],
9+
testPathIgnorePatterns: ['node_modules/(?!variables/.*)', '/fixtures/', '\\.d\\.ts$'],
1010
automock: false,
1111
resetMocks: false,
1212
};

packages/blocto-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blocto/sdk",
3-
"version": "0.10.3",
3+
"version": "0.10.4-beta.1",
44
"repository": "git@github.com:portto/blocto-sdk.git",
55
"author": "Chiaki.C",
66
"license": "MIT",
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import EthereumProvider from '../providers/ethereum';
2+
import { getEvmSupport } from '../lib/getEvmSupport';
3+
import { getEvmSupportList } from './fixtures/getEvmSupport';
4+
jest.mock('../lib/getEvmSupport');
5+
6+
describe('Testing BloctoSDK ethereum provider initialization and network loading', () => {
7+
beforeEach(() => {
8+
(getEvmSupport as jest.Mock).mockResolvedValue(getEvmSupportList);
9+
});
10+
11+
test('should initialize with unloadedNetwork', () => {
12+
const ethereumWithSwitchable = new EthereumProvider({
13+
defaultChainId: '0xaa36a7',
14+
switchableChains: [
15+
{
16+
chainId: '0xaa36a7',
17+
rpcUrls: ['https://ethereum-sepolia.blockpi.network/v1/rpc/public'],
18+
},
19+
{
20+
chainId: '0x61',
21+
rpcUrls: ['https://data-seed-prebsc-1-s1.binance.org:8545'],
22+
},
23+
],
24+
});
25+
26+
expect(ethereumWithSwitchable['_blocto'].unloadedNetwork).toBeDefined();
27+
expect(
28+
ethereumWithSwitchable['_blocto']?.unloadedNetwork?.[0].chainId
29+
).toBe('0xaa36a7');
30+
expect(
31+
ethereumWithSwitchable['_blocto']?.unloadedNetwork?.[1].chainId
32+
).toBe('0x61');
33+
expect(ethereumWithSwitchable['_blocto'].unloadedNetwork?.length).toBe(2);
34+
});
35+
36+
test('get support chain list', async () => {
37+
const ethereum = new EthereumProvider({
38+
chainId: '0xaa36a7',
39+
rpc: 'https://ethereum-sepolia.blockpi.network/v1/rpc/public',
40+
});
41+
const supportedChains = await ethereum.supportChainList();
42+
expect(supportedChains).toContainEqual({
43+
chainId: '11155111',
44+
chainName: 'Sepolia',
45+
});
46+
});
47+
48+
test('should add chain and switch to it', async () => {
49+
const ethereum = new EthereumProvider({
50+
chainId: '0xaa36a7',
51+
rpc: 'https://ethereum-sepolia.blockpi.network/v1/rpc/public',
52+
});
53+
await expect(
54+
ethereum.request({
55+
method: 'wallet_switchEthereumChain',
56+
params: [{ chainId: '0x61' }],
57+
})
58+
).rejects.toThrow(
59+
'Unrecognized chain ID "97". Try adding the chain using wallet_addEthereumChain first.'
60+
);
61+
62+
await ethereum.request({
63+
method: 'wallet_addEthereumChain',
64+
params: [
65+
{
66+
chainId: '0x61',
67+
rpcUrls: ['https://data-seed-prebsc-1-s1.binance.org:8545'],
68+
},
69+
],
70+
});
71+
await ethereum.request({
72+
method: 'wallet_switchEthereumChain',
73+
params: [{ chainId: '0x61' }],
74+
});
75+
expect(ethereum.chainId).toBe('0x61');
76+
});
77+
78+
test('create sdk instance with switchableChains and switch to it', async () => {
79+
const ethereum = new EthereumProvider({
80+
defaultChainId: '0xaa36a7',
81+
switchableChains: [
82+
{
83+
chainId: '0xaa36a7',
84+
rpcUrls: ['https://ethereum-sepolia.blockpi.network/v1/rpc/public'],
85+
},
86+
{
87+
chainId: '0x61',
88+
rpcUrls: ['https://data-seed-prebsc-1-s1.binance.org:8545'],
89+
},
90+
],
91+
});
92+
await ethereum.request({
93+
method: 'wallet_switchEthereumChain',
94+
params: [{ chainId: '0x61' }],
95+
});
96+
expect(ethereum.chainId).toBe('0x61');
97+
});
98+
test('create sdk instance with switchableChains and call eth_accounts', async () => {
99+
const ethereum = new EthereumProvider({
100+
defaultChainId: '0xaa36a7',
101+
switchableChains: [
102+
{
103+
chainId: '0xaa36a7',
104+
rpcUrls: ['https://ethereum-sepolia.blockpi.network/v1/rpc/public'],
105+
},
106+
{
107+
chainId: '0x61',
108+
rpcUrls: ['https://data-seed-prebsc-1-s1.binance.org:8545'],
109+
},
110+
],
111+
});
112+
// Trigger the loading of switchable networks
113+
await ethereum.request({
114+
method: 'eth_accounts',
115+
});
116+
expect(ethereum.chainId).toBe('0xaa36a7');
117+
// should remove unloadedNetwork after loading
118+
expect(ethereum['_blocto'].unloadedNetwork).toBeUndefined();
119+
});
120+
121+
test('should not call loadSwitchableNetwork if unloadedNetwork is empty', async () => {
122+
const ethereum = new EthereumProvider({
123+
chainId: '0xaa36a7',
124+
rpc: 'https://ethereum-sepolia.blockpi.network/v1/rpc/public',
125+
});
126+
const loadSwitchableNetworkSpy = jest.spyOn(ethereum, 'loadSwitchableNetwork');
127+
128+
await ethereum.request({ method: 'eth_accounts' });
129+
130+
expect(loadSwitchableNetworkSpy).not.toHaveBeenCalled();
131+
});
132+
});

0 commit comments

Comments
 (0)