Skip to content

Commit

Permalink
Merge branch 'V4' into feat/email-state-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xzilja authored Feb 13, 2024
2 parents 65d3185 + 03b17b9 commit dbfe3c5
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 6 deletions.
5 changes: 3 additions & 2 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-await-in-loop */
import { danger, fail, message, warn } from 'danger'
import corePackageJson from './packages/core/package.json' assert { type: 'json' }
import coreScaffoldUtilsJson from './packages/scaffold-utils/package.json' assert { type: 'json' }
import { ConstantsUtil } from './packages/scaffold-utils/src/ConstantsUtil'

// -- Constants ---------------------------------------------------------------
const TYPE_COMMENT = `// -- Types --------------------------------------------- //`
Expand All @@ -10,6 +10,7 @@ const CONTROLLER_COMMENT = `// -- Controller -----------------------------------
const RENDER_COMMENT = `// -- Render -------------------------------------------- //`
const STATE_PROPERTIES_COMMENT = `// -- State & Properties -------------------------------- //`
const PRIVATE_COMMENT = `// -- Private ------------------------------------------- //`
const PACKAGE_VERSION = ConstantsUtil.VERSION

// -- Data --------------------------------------------------------------------
const { modified_files, created_files, deleted_files, diffForFile } = danger.git
Expand Down Expand Up @@ -283,7 +284,7 @@ checkClientPackages()

// -- Check sdkVersion ------------------------------------------------------------
function checkSdkVersion() {
if (coreScaffoldUtilsJson.version !== corePackageJson.version) {
if (PACKAGE_VERSION !== corePackageJson.version) {
fail(`VERSION in utils/constants does't match core package.json version`)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/CoreHelperUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const CoreHelperUtil = {
}
}

return formattedBalance ? `${formattedBalance} ${symbol ?? ''}` : '0.000'
return formattedBalance ? `${formattedBalance} ${symbol ?? ''}` : `0.000 ${symbol ?? ''}`
},

formatBalance2(balance: string | undefined, symbol: string | undefined) {
Expand Down
10 changes: 10 additions & 0 deletions packages/ethers/exports/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export function useDisconnect() {
}
}

export function useSwitchNetwork() {
async function switchNetwork(chainId: number) {
await modal?.switchNetwork(chainId)
}

return {
switchNetwork
}
}

export function useWeb3ModalAccount() {
const { address, isConnected, chainId } = useSnapshot(EthersStoreUtil.state)

Expand Down
10 changes: 10 additions & 0 deletions packages/ethers/exports/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ export function useDisconnect() {
}
}

export function useSwitchNetwork() {
async function switchNetwork(chainId: number) {
await modal?.switchNetwork(chainId)
}

return {
switchNetwork
}
}

export function useWeb3ModalAccount() {
if (!modal) {
throw new Error('Please call "createWeb3Modal" before using "useWeb3ModalAccount" composition')
Expand Down
3 changes: 2 additions & 1 deletion packages/ethers/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,13 +860,14 @@ export class Web3Modal extends Web3ModalScaffold {
if (jsonRpcProvider) {
const balance = await jsonRpcProvider.getBalance(address)
const formattedBalance = formatEther(balance)

this.setBalance(formattedBalance, chain.currency)
}
}
}
}

private async switchNetwork(chainId: number) {
public async switchNetwork(chainId: number) {
const provider = EthersStoreUtil.state.provider
const providerType = EthersStoreUtil.state.providerType
if (this.chains) {
Expand Down
10 changes: 10 additions & 0 deletions packages/ethers5/exports/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export function useDisconnect() {
}
}

export function useSwitchNetwork() {
async function switchNetwork(chainId: number) {
await modal?.switchNetwork(chainId)
}

return {
switchNetwork
}
}

export function useWeb3ModalAccount() {
const { address, isConnected, chainId } = useSnapshot(EthersStoreUtil.state)

Expand Down
10 changes: 10 additions & 0 deletions packages/ethers5/exports/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export function useDisconnect() {
}
}

export function useSwitchNetwork() {
async function switchNetwork(chainId: number) {
await modal?.switchNetwork(chainId)
}

return {
switchNetwork
}
}

export function useWeb3ModalAccount() {
if (!modal) {
throw new Error('Please call "createWeb3Modal" before using "useWeb3ModalAccount" composition')
Expand Down
2 changes: 1 addition & 1 deletion packages/ethers5/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ export class Web3Modal extends Web3ModalScaffold {
}
}

private async switchNetwork(chainId: number) {
public async switchNetwork(chainId: number) {
const provider = EthersStoreUtil.state.provider
const providerType = EthersStoreUtil.state.providerType
if (this.chains) {
Expand Down
2 changes: 1 addition & 1 deletion packages/scaffold-utils/src/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export const ConstantsUtil = {
ADD_CHAIN_METHOD: 'wallet_addEthereumChain',
EIP6963_ANNOUNCE_EVENT: 'eip6963:announceProvider',
EIP6963_REQUEST_EVENT: 'eip6963:requestProvider',
VERSION: '4.0.3'
VERSION: '4.0.4'
}

0 comments on commit dbfe3c5

Please sign in to comment.