diff --git a/packages/core/src/controllers/BlockchainApiController.ts b/packages/core/src/controllers/BlockchainApiController.ts index 7e7ee2d44a..1568d1da43 100644 --- a/packages/core/src/controllers/BlockchainApiController.ts +++ b/packages/core/src/controllers/BlockchainApiController.ts @@ -33,6 +33,7 @@ import type { } from '../utils/TypeUtil.js' import { OptionsController } from './OptionsController.js' import { proxy } from 'valtio/vanilla' +import { AccountController } from './AccountController.js' const DEFAULT_OPTIONS = { purchaseCurrencies: [ @@ -130,7 +131,8 @@ export const BlockchainApiController = { return state.api.get({ path: `/v1/identity/${address}`, params: { - projectId: OptionsController.state.projectId + projectId: OptionsController.state.projectId, + sender: AccountController.state.address } }) }, @@ -143,13 +145,13 @@ export const BlockchainApiController = { signal, cache }: BlockchainApiTransactionsRequest) { - const queryParams = cursor ? { cursor } : {} - return state.api.get({ - path: `/v1/account/${account}/history?projectId=${projectId}${ - onramp ? `&onramp=${onramp}` : '' - }`, - params: queryParams, + path: `/v1/account/${account}/history`, + params: { + projectId, + cursor, + onramp + }, signal, cache }) @@ -181,7 +183,11 @@ export const BlockchainApiController = { fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) { return state.api.get({ - path: `/v1/convert/tokens?projectId=${projectId}&chainId=${chainId}` + path: `/v1/convert/tokens`, + params: { + projectId, + chainId + } }) }, @@ -203,7 +209,12 @@ export const BlockchainApiController = { const { sdkType, sdkVersion } = OptionsController.state return state.api.get({ - path: `/v1/convert/allowance?projectId=${projectId}&tokenAddress=${tokenAddress}&userAddress=${userAddress}`, + path: `/v1/convert/allowance`, + params: { + projectId, + tokenAddress, + userAddress + }, headers: { 'Content-Type': 'application/json', 'x-sdk-type': sdkType, @@ -298,19 +309,29 @@ export const BlockchainApiController = { async lookupEnsName(name: string) { return state.api.get({ - path: `/v1/profile/account/${name}${CommonConstantsUtil.WC_NAME_SUFFIX}?projectId=${OptionsController.state.projectId}` + path: `/v1/profile/account/${name}${CommonConstantsUtil.WC_NAME_SUFFIX}`, + params: { + projectId: OptionsController.state.projectId + } }) }, async reverseLookupEnsName({ address }: { address: string }) { return state.api.get({ - path: `/v1/profile/reverse/${address}?projectId=${OptionsController.state.projectId}` + path: `/v1/profile/reverse/${address}`, + params: { + sender: AccountController.state.address, + projectId: OptionsController.state.projectId + } }) }, async getEnsNameSuggestions(name: string) { return state.api.get({ - path: `/v1/profile/suggestions/${name}?projectId=${OptionsController.state.projectId}` + path: `/v1/profile/suggestions/${name}`, + params: { + projectId: OptionsController.state.projectId + } }) }, @@ -337,7 +358,10 @@ export const BlockchainApiController = { paymentAmount }: GenerateOnRampUrlArgs) { const response = await state.api.post<{ url: string }>({ - path: `/v1/generators/onrampurl?projectId=${OptionsController.state.projectId}`, + path: `/v1/generators/onrampurl`, + params: { + projectId: OptionsController.state.projectId + }, body: { destinationWallets, defaultNetwork, @@ -357,7 +381,10 @@ export const BlockchainApiController = { paymentCurrencies: PaymentCurrency[] purchaseCurrencies: PurchaseCurrency[] }>({ - path: `/v1/onramp/options?projectId=${OptionsController.state.projectId}` + path: `/v1/onramp/options`, + params: { + projectId: OptionsController.state.projectId + } }) return response @@ -369,7 +396,10 @@ export const BlockchainApiController = { async getOnrampQuote({ purchaseCurrency, paymentCurrency, amount, network }: GetQuoteArgs) { try { const response = await state.api.post({ - path: `/v1/onramp/quote?projectId=${OptionsController.state.projectId}`, + path: `/v1/onramp/quote`, + params: { + projectId: OptionsController.state.projectId + }, body: { purchaseCurrency, paymentCurrency,