Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"peerDependencies": {
"@0xsequence/design-system": "2.1.11",
"@0xsequence/network": "*",
"wagmi": "^2.15.0"
"wagmi": "^2.19.5"
},
"private": true
}
4 changes: 2 additions & 2 deletions examples/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tailwindcss": "^4.1.11",
"viem": "^2.28.1",
"wagmi": "^2.15.1"
"viem": "^2.44.4",
"wagmi": "^2.19.5"
},
"devDependencies": {
"@types/node": "^20.17.32",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"react-router-dom": "^7.5.3",
"tailwindcss": "^4.1.11",
"typescript": "^5.8.3",
"viem": "^2.28.1",
"wagmi": "^2.15.1"
"viem": "^2.44.4",
"wagmi": "^2.19.5"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.4",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"turbo": "2.0.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.31.1",
"viem": "^2.28.1",
"wagmi": "^2.15.1"
"viem": "^2.44.4",
"wagmi": "^2.19.5"
},
"resolutions": {},
"packageManager": "pnpm@10.24.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/checkout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"ethers": ">= 6.13.0",
"react": ">= 17",
"react-dom": ">= 17",
"viem": ">= 2.28.0",
"wagmi": ">= 2.15.0"
"viem": ">= 2.44.0",
"wagmi": ">= 2.19.0"
},
"devDependencies": {
"@0xsequence/connect": "workspace:*",
Expand All @@ -61,8 +61,8 @@
"ethers": "^6.13.7",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"viem": "^2.28.1",
"viem": "^2.44.4",
"vite": "^5.4.19",
"wagmi": "^2.15.1"
"wagmi": "^2.19.5"
}
}
8 changes: 4 additions & 4 deletions packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"react": ">= 17",
"react-apple-signin-auth": "^1.1.0",
"react-dom": ">= 17",
"viem": ">= 2.28.0",
"wagmi": ">= 2.15.0"
"viem": ">= 2.44.0",
"wagmi": ">= 2.19.0"
},
"devDependencies": {
"0xsequence": "^2.3.38",
Expand All @@ -79,7 +79,7 @@
"ethers": "^6.13.7",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"viem": "^2.28.1",
"wagmi": "^2.15.1"
"viem": "^2.44.4",
"wagmi": "^2.19.5"
}
}
23 changes: 14 additions & 9 deletions packages/connect/src/connectors/ecosystem/ecosystemWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ export function ecosystemWallet(params: BaseEcosystemConnectorOptions) {
}
},

async connect(_connectInfo) {
const provider = await this.getProvider()
async connect({ withCapabilities, ..._connectInfo } = {}) {
const provider = (await this.getProvider()) as EcosystemWalletTransportProvider
let walletAddress = provider.transport.getWalletAddress()

if (!walletAddress) {
try {
const res = await provider.transport.connect(this.auxData)
const res = await provider.transport.connect(this.auxData as Record<string, unknown> | undefined)
walletAddress = res.walletAddress
} catch (e) {
console.log(e)
Expand All @@ -67,19 +67,24 @@ export function ecosystemWallet(params: BaseEcosystemConnectorOptions) {
}
}

const account = getAddress(walletAddress)

return {
accounts: [getAddress(walletAddress)],
// TODO(wagmi v3): `as never` can be removed when wagmi makes `withCapabilities: true` the default
// see: https://github.com/wevm/wagmi/blob/main/packages/core/src/connectors/createConnector.ts
// ref: https://github.com/wevm/wagmi/blob/main/packages/connectors/src/safe.ts
accounts: (withCapabilities ? [{ address: account, capabilities: {} }] : [account]) as never,
chainId: await this.getChainId()
}
},

async disconnect() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as EcosystemWalletTransportProvider
provider.transport.disconnect()
},

async getAccounts() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as EcosystemWalletTransportProvider
const address = provider.transport.getWalletAddress()

if (address) {
Expand All @@ -94,12 +99,12 @@ export function ecosystemWallet(params: BaseEcosystemConnectorOptions) {
},

async isAuthorized() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as EcosystemWalletTransportProvider
return provider.transport.getWalletAddress() !== undefined
},

async switchChain({ chainId }) {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as EcosystemWalletTransportProvider
const chain = config.chains.find(c => c.id === chainId) || config.chains[0]

await provider.request({
Expand All @@ -113,7 +118,7 @@ export function ecosystemWallet(params: BaseEcosystemConnectorOptions) {
},

async getChainId() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as EcosystemWalletTransportProvider
return Number(provider.getChainId())
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
},

async setup() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceProvider
provider.on('chainChanged', (chainIdHex: string) => {
config.emitter.emit('change', { chainId: normalizeChainId(chainIdHex) })
})
Expand All @@ -79,8 +79,8 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
})
},

async connect() {
const provider = await this.getProvider()
async connect({ withCapabilities } = {}) {
const provider = (await this.getProvider()) as SequenceProvider

if (!provider.isConnected()) {
const localStorageTheme = await config.storage?.getItem(LocalStorageKey.Theme)
Expand Down Expand Up @@ -123,21 +123,24 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
const accounts = await this.getAccounts()

return {
accounts: [...accounts],
// TODO(wagmi v3): `as never` can be removed when wagmi makes `withCapabilities: true` the default
// see: https://github.com/wevm/wagmi/blob/main/packages/core/src/connectors/createConnector.ts
// ref: https://github.com/wevm/wagmi/blob/main/packages/connectors/src/safe.ts
accounts: (withCapabilities ? accounts.map(address => ({ address, capabilities: {} })) : accounts) as never,
chainId: provider.getChainId()
}
},

async disconnect() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceProvider

provider.disconnect()

await config.storage?.removeItem(LocalStorageKey.WaasSignInEmail)
},

async getAccounts() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceProvider
const signer = provider.getSigner()
const account = getAddress(await signer.getAddress())

Expand Down Expand Up @@ -180,7 +183,7 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
},

async switchChain({ chainId }) {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceProvider

const chain = config.chains.find(c => c.id === chainId) || config.chains[0]
provider.setDefaultChainId(normalizeChainId(chainId))
Expand All @@ -191,7 +194,7 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
},

async getChainId() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceProvider
const chainId = provider.getChainId()

return chainId
Expand All @@ -202,7 +205,7 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
},

async onChainChanged(chain) {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceProvider

config.emitter.emit('change', { chainId: normalizeChainId(chain) })
provider.setDefaultChainId(normalizeChainId(chain))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
})
},

async connect(_connectInfo) {
const provider = await this.getProvider()
async connect({ withCapabilities, ..._connectInfo } = {}) {
const provider = (await this.getProvider()) as SequenceWaasProvider
const isSignedIn = await provider.sequenceWaas.isSignedIn()

if (!isSignedIn) {
Expand Down Expand Up @@ -181,13 +181,16 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
}

return {
accounts,
// TODO(wagmi v3): `as never` can be removed when wagmi makes `withCapabilities: true` the default
// see: https://github.com/wevm/wagmi/blob/main/packages/core/src/connectors/createConnector.ts
// ref: https://github.com/wevm/wagmi/blob/main/packages/connectors/src/safe.ts
accounts: (withCapabilities ? accounts.map(address => ({ address, capabilities: {} })) : accounts) as never,
chainId: await this.getChainId()
}
},

async disconnect() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceWaasProvider

try {
await provider.sequenceWaas.dropSession({ sessionId: await provider.sequenceWaas.getSessionId(), strict: false })
Expand All @@ -202,7 +205,7 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
},

async getAccounts() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceWaasProvider

try {
const isSignedIn = await provider.sequenceWaas.isSignedIn()
Expand All @@ -223,7 +226,7 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
},

async isAuthorized() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceWaasProvider

const activeWaasOption = await config.storage?.getItem(LocalStorageKey.WaasActiveLoginType)
if (params.loginType !== activeWaasOption) {
Expand All @@ -237,7 +240,7 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
},

async switchChain({ chainId }) {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceWaasProvider
const chain = config.chains.find(c => c.id === chainId) || config.chains[0]

await provider.request({
Expand All @@ -251,7 +254,7 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
},

async getChainId() {
const provider = await this.getProvider()
const provider = (await this.getProvider()) as SequenceWaasProvider
return Number(provider.getChainId())
},

Expand Down
60 changes: 29 additions & 31 deletions packages/connect/src/connectors/walletConnect/walletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,40 @@ export const walletConnect = (options: WalletConnectOptions): Wallet => ({
return createConnector(config => {
const connector = baseConnector(config)

const connect = async (params?: { chainId?: number }) => {
const targetChainId = params?.chainId ?? defaultNetwork ?? config.chains[0]?.id
if (!targetChainId) {
throw new Error('No target chain ID available')
}

if (!connector.connect || !connector.switchChain) {
throw new Error('WalletConnect connector not properly initialized')
}

// First establish the basic connection
const result = await connector.connect()
return {
...connector,
async connect(params = {}) {
const targetChainId = params?.chainId ?? defaultNetwork ?? config.chains[0]?.id
if (!targetChainId) {
throw new Error('No target chain ID available')
}

// Only attempt to switch chains if we're not already on the target chain
if (result.chainId !== targetChainId) {
try {
// Switch to the target chain
await connector.switchChain({ chainId: targetChainId })
if (!connector.connect || !connector.switchChain) {
throw new Error('WalletConnect connector not properly initialized')
}

// Return the connection with the updated chain
return {
accounts: result.accounts,
chainId: targetChainId
// First establish the basic connection
const result = await connector.connect(params)

// Only attempt to switch chains if we're not already on the target chain
if (result.chainId !== targetChainId) {
try {
// Switch to the target chain
await connector.switchChain({ chainId: targetChainId })

// Return the connection with the updated chain
return {
accounts: result.accounts,
chainId: targetChainId
}
} catch (error) {
console.warn('Failed to switch chain:', error)
return result
}
} catch (error) {
console.warn('Failed to switch chain:', error)
return result
}
}

return result
}

return {
...connector,
connect
return result
}
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@tanstack/react-query": ">= 5",
"react": ">= 17",
"react-dom": ">= 17",
"viem": ">= 2.28.0"
"viem": ">= 2.44.0"
},
"devDependencies": {
"@0xsequence/api": "^2.3.38",
Expand All @@ -55,7 +55,7 @@
"react": "^19.1.0",
"react-dom": "^19.1.0",
"typescript": "^5.8.3",
"viem": "^2.28.1",
"viem": "^2.44.4",
"vite": "^6.3.4",
"vitest": "^2.1.9"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/immutable-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ethers": "^6.13.0",
"react": ">= 17 < 19",
"react-dom": ">= 17 < 19",
"viem": "^2.28.0",
"wagmi": "^2.15.0"
"viem": "^2.44.4",
"wagmi": "^2.19.5"
}
}
Loading