Skip to content

Commit

Permalink
Use tokenId for getReceiveAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Dec 12, 2023
1 parent 2ceade6 commit c859e2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/core/currency/wallet/currency-wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,16 @@ export function makeCurrencyWalletApi(

// Addresses:
async getReceiveAddress(
opts: EdgeGetReceiveAddressOptions = {}
opts: EdgeGetReceiveAddressOptions = { tokenId: null }
): Promise<EdgeReceiveAddress> {
const { tokenId } = opts
const allTokens =
input.props.state.accounts[accountId].allTokens[pluginId]
const { currencyCode } =
tokenId == null ? this.currencyInfo : allTokens[tokenId]

// @ts-expect-error XXX Hack to maintain plugin compatibility
opts.currencyCode = currencyCode
const freshAddress = await engine.getFreshAddress(opts)
const receiveAddress: EdgeReceiveAddress = {
...freshAddress,
Expand Down
6 changes: 1 addition & 5 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,6 @@ export interface EdgeEncodeUri {

// options -------------------------------------------------------------

export interface EdgeCurrencyCodeOptions {
currencyCode?: string
}

export interface EdgeTokenIdOptions {
tokenId: string | null
}
Expand Down Expand Up @@ -798,7 +794,7 @@ export interface EdgeStreamTransactionOptions {
tokenId: string | null
}

export type EdgeGetReceiveAddressOptions = EdgeCurrencyCodeOptions & {
export type EdgeGetReceiveAddressOptions = EdgeTokenIdOptions & {
forceIndex?: number
}

Expand Down

0 comments on commit c859e2a

Please sign in to comment.