-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: Fixed binance web3 wallet disconnect after refresh page (#151) * test: Test binance web3 wallet * test: Test binance web3 wallet * test: Test binance web3 wallet * test: Test * test: Test * test: Test * test: Test binance web3 wallet * test: Test * test: Test binance web3 wallet * docs: Add log * test: Test binance web3 wallet * test: Test * test: Test * test: Test * Dev (#153) * test: Test binance web3 wallet * test: Test binance web3 wallet * test: Test binance web3 wallet * test: Test * test: Test * test: Test * test: Test binance web3 wallet * test: Test * test: Test binance web3 wallet * docs: Add log * test: Test binance web3 wallet * test: Test * test: Test * test: Test * refactor: Remove unused code * docs: Add log * chore: update versions (alpha) (#154) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
024f91f
commit b11c309
Showing
12 changed files
with
95 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@node-real/walletkit": patch | ||
--- | ||
|
||
Fixed binance web3 wallet disconnect after refresh page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@node-real/walletkit": patch | ||
--- | ||
|
||
Remove unused code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"mode": "pre", | ||
"tag": "alpha", | ||
"initialVersions": { | ||
"example-nextjs": "0.0.1", | ||
"example-vite": "0.0.1", | ||
"@node-real/walletkit": "1.0.12", | ||
"website": "0.0.1" | ||
}, | ||
"changesets": [ | ||
"gold-doors-check", | ||
"nervous-badgers-raise" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
branches: | ||
- main | ||
- alpha | ||
- dev | ||
|
||
jobs: | ||
release: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/walletkit/src/wallets/binanceWeb3Wallet/connector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { sleep } from '@/utils/common'; | ||
import { Chain } from 'wagmi'; | ||
import { InjectedConnector } from 'wagmi/connectors/injected'; | ||
import { BINANCE_WEB3_WALLET_ID, BINANCE_WEB3_WALLET_NAME } from '.'; | ||
import { isMobile } from '@/base/utils/mobile'; | ||
|
||
export type BinanceWeb3WalletConnectorOptions = Required< | ||
ConstructorParameters<typeof InjectedConnector> | ||
>[0]['options']; | ||
|
||
export interface CustomConstructorParams { | ||
chains?: Chain[]; | ||
options?: BinanceWeb3WalletConnectorOptions; | ||
} | ||
|
||
export class BinanceWeb3WalletConnector extends InjectedConnector { | ||
public id = BINANCE_WEB3_WALLET_ID; | ||
protected shimDisconnectKey = `${this.id}.shimDisconnect`; | ||
|
||
constructor(props: CustomConstructorParams) { | ||
const { chains, options: _options } = props ?? {}; | ||
|
||
const options = { | ||
name: BINANCE_WEB3_WALLET_NAME, | ||
shimDisconnect: true, | ||
getProvider, | ||
..._options, | ||
}; | ||
|
||
if (typeof window !== 'undefined') { | ||
(window.ethereum as any)?.enable?.(); | ||
} | ||
|
||
super({ | ||
chains, | ||
options, | ||
}); | ||
} | ||
|
||
public async getProvider() { | ||
await sleep(); | ||
return this.options.getProvider(); | ||
} | ||
} | ||
|
||
function getProvider() { | ||
if (typeof window === 'undefined') return; | ||
|
||
if (isMobile()) { | ||
return window.ethereum; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters