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 packages/checkout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"peerDependencies": {
"0xsequence": ">= 2.2.13",
"@0xsequence/api": ">= 2.2.13",
"@0xsequence/api": "^2.3.4",
"@0xsequence/indexer": ">= 2.2.13",
"@0xsequence/metadata": ">= 2.2.13",
"@0xsequence/network": ">= 2.2.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@0xsequence/api": ">= 2.2.13",
"@0xsequence/api": "^2.3.4",
"@0xsequence/auth": ">= 2.2.13",
"@0xsequence/core": ">= 2.2.13",
"@0xsequence/design-system": "^2.0.11",
Expand Down
1 change: 0 additions & 1 deletion packages/connect/src/connectors/ecosystem/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class EcosystemWalletTransportProvider extends ethers.AbstractProvider im
this.currentNetwork = ethers.Network.from(initialChainId)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
async request({ method, params }: { method: string; params?: any[] }) {
if (method === 'wallet_switchEthereumChain') {
const chainId = normalizeChainId(params?.[0].chainId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const isBrowser = typeof window !== 'undefined'
export class ProviderTransport {
private walletOrigin: string
private walletWindow: Window | null = null
// eslint-disable-next-line @typescript-eslint/no-explicit-any

private callbacks: Map<string, (response: any) => void> = new Map()
private connectionState: ConnectionState = 'disconnected'
private session: SessionData | undefined
Expand Down Expand Up @@ -134,7 +134,6 @@ export class ProviderTransport {
})
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
async sendRequest(method: string, params: any[], chainId: number): Promise<any> {
if (!isBrowser) {
throw new Error('ProviderTransport is only available in browser environment')
Expand Down Expand Up @@ -180,7 +179,6 @@ export class ProviderTransport {
})
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private openWalletAndPostMessage(message: any): Promise<void> {
if (!isBrowser) {
return Promise.reject(new Error('ProviderTransport is only available in browser environment'))
Expand Down Expand Up @@ -211,7 +209,6 @@ export class ProviderTransport {
})
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
private postMessageToWallet(message: any) {
console.log('Posting message to wallet:', message)
this.walletWindow!.postMessage(message, {
Expand All @@ -232,7 +229,9 @@ export class ProviderTransport {
}

private handleMessage = (event: MessageEvent) => {
if (event.origin !== this.walletOrigin) return
if (event.origin !== this.walletOrigin) {
return
}

const response = event.data
const callback = this.callbacks.get(response.id)
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"test:watch": "vitest"
},
"peerDependencies": {
"@0xsequence/api": ">=2.2.13",
"@0xsequence/api": "^2.3.4",
"@0xsequence/indexer": ">=2.2.13",
"@0xsequence/metadata": ">=2.2.13",
"@0xsequence/network": ">=2.2.13",
Expand All @@ -39,7 +39,7 @@
"react-dom": ">= 17"
},
"devDependencies": {
"@0xsequence/api": "^2.2.13",
"@0xsequence/api": "^2.3.4",
"@0xsequence/indexer": "^2.2.13",
"@0xsequence/metadata": "^2.2.13",
"@0xsequence/network": "^2.2.13",
Expand Down
14 changes: 7 additions & 7 deletions packages/hooks/src/hooks/Combination/useGetSwapQuote.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { GetSwapQuoteArgs } from '@0xsequence/api'
import { GetSwapQuoteV2Args } from '@0xsequence/api'
import { useQuery } from '@tanstack/react-query'

import { NATIVE_TOKEN_ADDRESS_0X_SWAP, QUERY_KEYS, ZERO_ADDRESS, time } from '../../constants'
import { QUERY_KEYS, ZERO_ADDRESS, time } from '../../constants'
import { HooksOptions } from '../../types'
import { compareAddress } from '../../utils/helpers'
import { useAPIClient } from '../API/useAPIClient'

/**
* @description Gets the swap quote for a given currency pair
*/
export const useGetSwapQuote = (getSwapQuoteArgs: GetSwapQuoteArgs, options?: HooksOptions) => {
export const useGetSwapQuote = (getSwapQuoteArgs: GetSwapQuoteV2Args, options?: HooksOptions) => {
const apiClient = useAPIClient()

return useQuery({
queryKey: [QUERY_KEYS.useGetSwapQuote, getSwapQuoteArgs, options],
queryFn: async () => {
const res = await apiClient.getSwapQuote({
const res = await apiClient.getSwapQuoteV2({
...getSwapQuoteArgs,
buyCurrencyAddress: compareAddress(getSwapQuoteArgs.buyCurrencyAddress, ZERO_ADDRESS)
? NATIVE_TOKEN_ADDRESS_0X_SWAP
? ZERO_ADDRESS
: getSwapQuoteArgs.buyCurrencyAddress,
sellCurrencyAddress: compareAddress(getSwapQuoteArgs.sellCurrencyAddress, ZERO_ADDRESS)
? NATIVE_TOKEN_ADDRESS_0X_SWAP
? ZERO_ADDRESS
: getSwapQuoteArgs.sellCurrencyAddress
})

return {
...res.swapQuote,
currencyAddress: compareAddress(res.swapQuote.currencyAddress, NATIVE_TOKEN_ADDRESS_0X_SWAP)
currencyAddress: compareAddress(res.swapQuote.currencyAddress, ZERO_ADDRESS)
? ZERO_ADDRESS
: res.swapQuote.currencyAddress
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { renderHook, waitFor } from '@testing-library/react'
import { HttpResponse, http } from 'msw'
import { describe, expect, it } from 'vitest'

import { ACCOUNT_ADDRESS, NATIVE_TOKEN_ADDRESS_0X_SWAP } from '../../constants'
import { ACCOUNT_ADDRESS, ZERO_ADDRESS } from '../../constants'
import { useGetSwapQuote } from '../../hooks/Combination/useGetSwapQuote'
import { createWrapper } from '../createWrapper'
import { server } from '../setup'

const getSwapQuoteArgs = {
userAddress: ACCOUNT_ADDRESS,
buyCurrencyAddress: NATIVE_TOKEN_ADDRESS_0X_SWAP,
sellCurrencyAddress: NATIVE_TOKEN_ADDRESS_0X_SWAP,
buyCurrencyAddress: ZERO_ADDRESS,
sellCurrencyAddress: ZERO_ADDRESS,
buyAmount: '20000',
chainId: 1,
includeApprove: true
}

describe('useGetSwapQuote', () => {
describe('useGetSwapQuoteV2', () => {
it('should return data with a balance', async () => {
const { result } = renderHook(() => useGetSwapQuote(getSwapQuoteArgs), {
wrapper: createWrapper()
Expand Down
18 changes: 18 additions & 0 deletions packages/hooks/src/tests/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,23 @@ export const handlers = [
},
{ status: 200 }
)
}),

http.post('*/GetSwapQuoteV2', async () => {
return HttpResponse.json(
{
swapQuote: {
currencyAddress: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
currencyBalance: '180000000000000',
price: '7351402238115',
maxPrice: '7718972350021',
to: '0x0000000000000000000000000000000000000000',
transactionData: '0x0000000000000000000000000000000000000000000000000000000000000000',
transactionValue: '0',
approveData: '0x0000000000000000000000000000000000000000000000000000000000000000'
}
},
{ status: 200 }
)
})
]
2 changes: 1 addition & 1 deletion packages/wallet-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"motion": "^12.3.1"
},
"peerDependencies": {
"@0xsequence/api": ">= 2.2.13",
"@0xsequence/api": "^2.3.4",
"@0xsequence/indexer": ">= 2.2.13",
"@0xsequence/metadata": ">= 2.2.13",
"@0xsequence/network": ">= 2.2.13",
Expand Down
21 changes: 13 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.