@web3modal/wagmi
Advanced tools
Comparing version 5.0.11-57abd61b5.0 to 5.0.11
@@ -1,11 +0,13 @@ | ||
import { connect, disconnect, getAccount, getBalance, getEnsName, prepareTransactionRequest, reconnect, signMessage, switchChain, estimateGas as wagmiEstimateGas, getEnsAddress as wagmiGetEnsAddress, getEnsAvatar as wagmiGetEnsAvatar, sendTransaction as wagmiSendTransaction, writeContract as wagmiWriteContract, waitForTransactionReceipt, watchAccount, watchConnectors } from '@wagmi/core'; | ||
import { EthereumProvider, OPTIONAL_METHODS } from '@walletconnect/ethereum-provider'; | ||
import { ConstantsUtil as CommonConstantsUtil, NetworkUtil } from '@web3modal/common'; | ||
import { connect, disconnect, signMessage, getBalance, getEnsAvatar as wagmiGetEnsAvatar, getEnsName, switchChain, watchAccount, watchConnectors, waitForTransactionReceipt, estimateGas as wagmiEstimateGas, writeContract as wagmiWriteContract, getAccount, getEnsAddress as wagmiGetEnsAddress, reconnect, getConnections, switchAccount } from '@wagmi/core'; | ||
import { mainnet } from 'viem/chains'; | ||
import { prepareTransactionRequest, sendTransaction as wagmiSendTransaction } from '@wagmi/core'; | ||
import { formatUnits, parseUnits } from 'viem'; | ||
import { Web3ModalScaffold } from '@web3modal/scaffold'; | ||
import { ConstantsUtil, HelpersUtil, PresetsUtil } from '@web3modal/scaffold-utils'; | ||
import { ConstantsUtil, PresetsUtil, HelpersUtil } from '@web3modal/scaffold-utils'; | ||
import { ConstantsUtil as CommonConstantsUtil } from '@web3modal/common'; | ||
import { getCaipDefaultChain, getEmailCaipNetworks, getWalletConnectCaipNetworks } from './utils/helpers.js'; | ||
import { W3mFrameConstants, W3mFrameHelpers, W3mFrameRpcConstants } from '@web3modal/wallet'; | ||
import { formatUnits, parseUnits } from 'viem'; | ||
import { mainnet } from 'viem/chains'; | ||
import { NetworkUtil } from '@web3modal/common'; | ||
import { normalize } from 'viem/ens'; | ||
import { getCaipDefaultChain, getEmailCaipNetworks, getWalletConnectCaipNetworks } from './utils/helpers.js'; | ||
export class Web3Modal extends Web3ModalScaffold { | ||
@@ -54,22 +56,18 @@ constructor(options) { | ||
} | ||
let chainId = NetworkUtil.caipNetworkIdToNumber(this.getCaipNetwork()?.id); | ||
if (this.getIsSiweEnabled() && typeof provider?.authenticate === 'function') { | ||
const chainId = NetworkUtil.caipNetworkIdToNumber(this.getCaipNetwork()?.id); | ||
const siweParams = await siweConfig?.getMessageParams?.(); | ||
if (siweConfig?.options?.enabled && | ||
typeof provider?.authenticate === 'function' && | ||
siweParams && | ||
Object.keys(siweParams || {}).length > 0) { | ||
const { SIWEController, getDidChainId, getDidAddress } = await import('@web3modal/siwe'); | ||
if (!SIWEController.state._client) { | ||
return; | ||
} | ||
const params = await SIWEController?.getMessageParams?.(); | ||
console.log({ params }); | ||
if (!params || !Object.keys(params || {}).length) { | ||
return; | ||
} | ||
let reorderedChains = this.wagmiConfig.chains.map(c => c.id); | ||
await connector.setRequestedChainsIds(reorderedChains); | ||
await connector.setRequestedChainsIds(siweParams.chains); | ||
let reorderedChains = siweParams.chains; | ||
if (chainId) { | ||
reorderedChains = [chainId, ...reorderedChains.filter(c => c !== chainId)]; | ||
reorderedChains = [chainId, ...siweParams.chains.filter(c => c !== chainId)]; | ||
} | ||
const result = await provider.authenticate({ | ||
nonce: await SIWEController.getNonce(), | ||
nonce: await siweConfig.getNonce(), | ||
methods: [...OPTIONAL_METHODS], | ||
...params, | ||
...siweParams, | ||
chains: reorderedChains | ||
@@ -82,7 +80,6 @@ }); | ||
const address = getDidAddress(p.iss); | ||
chainId = parseInt(cacaoChainId, 10); | ||
if (address && cacaoChainId) { | ||
SIWEController.setSession({ | ||
address, | ||
chainId | ||
chainId: parseInt(cacaoChainId, 10) | ||
}); | ||
@@ -98,4 +95,3 @@ } | ||
signature: s.s, | ||
cacao: signedCacao, | ||
clientId | ||
cacao: signedCacao | ||
}); | ||
@@ -109,4 +105,4 @@ } | ||
} | ||
this.wagmiConfig.state.current = ''; | ||
} | ||
this.wagmiConfig.state.current = ''; | ||
} | ||
@@ -149,7 +145,6 @@ await connect(this.wagmiConfig, { connector, chainId }); | ||
await disconnect(this.wagmiConfig); | ||
this.setClientId(null); | ||
if (siweConfig?.options?.signOutOnDisconnect) { | ||
const { SIWEController } = await import('@web3modal/siwe'); | ||
if (SIWEController.state._client?.options?.signOutOnDisconnect) { | ||
await SIWEController.signOut(); | ||
} | ||
await SIWEController.signOut(); | ||
} | ||
@@ -257,2 +252,20 @@ }, | ||
}); | ||
this.setEIP6963Enabled(w3mOptions.enableEIP6963 !== false); | ||
this.subscribeShouldUpdateToAddress((newAddress) => { | ||
if (newAddress) { | ||
const connections = getConnections(this.wagmiConfig); | ||
const connector = connections[0]?.connector; | ||
if (connector) { | ||
switchAccount(this.wagmiConfig, { | ||
connector | ||
}).then(response => this.syncAccount({ | ||
address: newAddress, | ||
isConnected: true, | ||
addresses: response.accounts, | ||
connector, | ||
chainId: response.chainId | ||
})); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -568,9 +581,9 @@ getState() { | ||
} | ||
const chainId = NetworkUtil.caipNetworkIdToNumber(this.getCaipNetwork()?.id); | ||
this.setPreferredAccountType(type, this.chain); | ||
this.syncAccount({ | ||
address: address, | ||
chainId, | ||
isConnected: true, | ||
chainId: NetworkUtil.caipNetworkIdToNumber(this.getCaipNetwork()?.id), | ||
connector | ||
}).then(() => this.setPreferredAccountType(type)); | ||
}); | ||
}); | ||
@@ -577,0 +590,0 @@ } |
@@ -0,3 +1,3 @@ | ||
import type { Chain } from '@wagmi/core/chains'; | ||
import type { Config } from '@wagmi/core'; | ||
import type { Chain } from '@wagmi/core/chains'; | ||
import type { LibraryOptions, PublicStateControllerState, Token } from '@web3modal/scaffold'; | ||
@@ -4,0 +4,0 @@ import { Web3ModalScaffold } from '@web3modal/scaffold'; |
@@ -14,5 +14,5 @@ import type { CreateConfigParameters } from '@wagmi/core'; | ||
}; | ||
export declare function authConnector(parameters: AuthParameters): import("@wagmi/core").CreateConnectorFn<import("packages/wallet/dist/types/index.js").W3mFrameProvider, { | ||
provider?: import("packages/wallet/dist/types/index.js").W3mFrameProvider | undefined; | ||
export declare function authConnector(parameters: AuthParameters): import("@wagmi/core").CreateConnectorFn<import("packages/wallet/index.js").W3mFrameProvider, { | ||
provider?: import("packages/wallet/index.js").W3mFrameProvider | undefined; | ||
}, Record<string, unknown>>; | ||
export {}; |
{ | ||
"name": "@web3modal/wagmi", | ||
"version": "5.0.11-57abd61b5.0", | ||
"version": "5.0.11", | ||
"type": "module", | ||
@@ -49,10 +49,10 @@ "main": "./dist/esm/exports/index.js", | ||
"@walletconnect/utils": "2.14.0", | ||
"@web3modal/polyfills": "5.0.11-57abd61b5.0", | ||
"@web3modal/wallet": "5.0.11-57abd61b5.0", | ||
"@web3modal/scaffold": "5.0.11-57abd61b5.0", | ||
"@web3modal/common": "5.0.11-57abd61b5.0", | ||
"@web3modal/scaffold-react": "5.0.11-57abd61b5.0", | ||
"@web3modal/scaffold-utils": "5.0.11-57abd61b5.0", | ||
"@web3modal/scaffold-vue": "5.0.11-57abd61b5.0", | ||
"@web3modal/siwe": "5.0.11-57abd61b5.0" | ||
"@web3modal/polyfills": "5.0.11", | ||
"@web3modal/wallet": "5.0.11", | ||
"@web3modal/scaffold": "5.0.11", | ||
"@web3modal/scaffold-react": "5.0.11", | ||
"@web3modal/common": "5.0.11", | ||
"@web3modal/scaffold-utils": "5.0.11", | ||
"@web3modal/scaffold-vue": "5.0.11", | ||
"@web3modal/siwe": "5.0.11" | ||
}, | ||
@@ -59,0 +59,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
760330
1071
0
+ Added@noble/ciphers@1.2.0(transitive)
+ Added@noble/curves@1.8.0(transitive)
+ Added@noble/hashes@1.7.0(transitive)
+ Added@safe-global/safe-gateway-typescript-sdk@3.22.6(transitive)
+ Added@scure/base@1.2.1(transitive)
+ Added@scure/bip32@1.6.1(transitive)
+ Added@scure/bip39@1.5.1(transitive)
+ Added@tanstack/query-core@5.64.1(transitive)
+ Added@tanstack/react-query@5.64.1(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Added@web3modal/common@5.0.11(transitive)
+ Added@web3modal/core@5.0.11(transitive)
+ Added@web3modal/polyfills@5.0.11(transitive)
+ Added@web3modal/scaffold@5.0.11(transitive)
+ Added@web3modal/scaffold-react@5.0.11(transitive)
+ Added@web3modal/scaffold-ui@5.0.11(transitive)
+ Added@web3modal/scaffold-utils@5.0.11(transitive)
+ Added@web3modal/scaffold-vue@5.0.11(transitive)
+ Added@web3modal/siwe@5.0.11(transitive)
+ Added@web3modal/ui@5.0.11(transitive)
+ Added@web3modal/wallet@5.0.11(transitive)
+ Addednode-fetch-native@1.6.4(transitive)
+ Addedviem@2.22.9(transitive)
- Removed@noble/ciphers@1.2.1(transitive)
- Removed@noble/curves@1.8.1(transitive)
- Removed@noble/hashes@1.7.1(transitive)
- Removed@safe-global/safe-gateway-typescript-sdk@3.22.7(transitive)
- Removed@scure/base@1.2.4(transitive)
- Removed@scure/bip32@1.6.2(transitive)
- Removed@scure/bip39@1.5.4(transitive)
- Removed@tanstack/query-core@5.64.2(transitive)
- Removed@tanstack/react-query@5.64.2(transitive)
- Removed@types/ms@2.1.0(transitive)
- Removed@web3modal/common@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/core@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/polyfills@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/scaffold@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/scaffold-react@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/scaffold-ui@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/scaffold-utils@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/scaffold-vue@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/siwe@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/ui@5.0.11-57abd61b5.0(transitive)
- Removed@web3modal/wallet@5.0.11-57abd61b5.0(transitive)
- Removednode-fetch-native@1.6.6(transitive)
- Removedviem@2.22.10(transitive)
Updated@web3modal/common@5.0.11
Updated@web3modal/polyfills@5.0.11
Updated@web3modal/scaffold@5.0.11
Updated@web3modal/siwe@5.0.11
Updated@web3modal/wallet@5.0.11