Skip to content

Commit

Permalink
feat: add sender to identity and reverse resolution (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir authored Aug 8, 2024
1 parent 78b1d58 commit e3e267e
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions packages/core/src/controllers/BlockchainApiController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -130,7 +131,8 @@ export const BlockchainApiController = {
return state.api.get<BlockchainApiIdentityResponse>({
path: `/v1/identity/${address}`,
params: {
projectId: OptionsController.state.projectId
projectId: OptionsController.state.projectId,
sender: AccountController.state.address
}
})
},
Expand All @@ -143,13 +145,13 @@ export const BlockchainApiController = {
signal,
cache
}: BlockchainApiTransactionsRequest) {
const queryParams = cursor ? { cursor } : {}

return state.api.get<BlockchainApiTransactionsResponse>({
path: `/v1/account/${account}/history?projectId=${projectId}${
onramp ? `&onramp=${onramp}` : ''
}`,
params: queryParams,
path: `/v1/account/${account}/history`,
params: {
projectId,
cursor,
onramp
},
signal,
cache
})
Expand Down Expand Up @@ -181,7 +183,11 @@ export const BlockchainApiController = {

fetchSwapTokens({ projectId, chainId }: BlockchainApiSwapTokensRequest) {
return state.api.get<BlockchainApiSwapTokensResponse>({
path: `/v1/convert/tokens?projectId=${projectId}&chainId=${chainId}`
path: `/v1/convert/tokens`,
params: {
projectId,
chainId
}
})
},

Expand All @@ -203,7 +209,12 @@ export const BlockchainApiController = {
const { sdkType, sdkVersion } = OptionsController.state

return state.api.get<BlockchainApiSwapAllowanceResponse>({
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,
Expand Down Expand Up @@ -298,19 +309,29 @@ export const BlockchainApiController = {

async lookupEnsName(name: string) {
return state.api.get<BlockchainApiLookupEnsName>({
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<BlockchainApiLookupEnsName[]>({
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<BlockchainApiSuggestionResponse>({
path: `/v1/profile/suggestions/${name}?projectId=${OptionsController.state.projectId}`
path: `/v1/profile/suggestions/${name}`,
params: {
projectId: OptionsController.state.projectId
}
})
},

Expand All @@ -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,
Expand All @@ -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
Expand All @@ -369,7 +396,10 @@ export const BlockchainApiController = {
async getOnrampQuote({ purchaseCurrency, paymentCurrency, amount, network }: GetQuoteArgs) {
try {
const response = await state.api.post<OnrampQuote>({
path: `/v1/onramp/quote?projectId=${OptionsController.state.projectId}`,
path: `/v1/onramp/quote`,
params: {
projectId: OptionsController.state.projectId
},
body: {
purchaseCurrency,
paymentCurrency,
Expand Down

0 comments on commit e3e267e

Please sign in to comment.