Skip to content

feat: update getDefaultTransactionOptions interface #8079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { AddressType, TransactionOptions } from '@iota/sdk/out/types'
import { AccountAddress, TransactionOptions } from '@iota/sdk/out/types'
import { getSelectedWallet } from '../stores'

export function getDefaultTransactionOptions(accountId?: string): TransactionOptions | undefined {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, right?

Suggested change
export function getDefaultTransactionOptions(accountId?: string): TransactionOptions | undefined {
export function getDefaultTransactionOptions(accountId?: string = getSelectedWallet()?.mainAccountId): TransactionOptions | undefined {
return {
remainderValueStrategy: {
strategy: 'CustomAddress',
value,
value: new AccountAddress(accountId),
},
allowMicroAmount: true,
}
}

if (!accountId) {
const wallet = getSelectedWallet()
if (!wallet) return
if (!wallet || !wallet.mainAccountId) return
accountId = wallet.mainAccountId
}

// TODO: update interface when https://github.com/iotaledger/iota-sdk/issues/1975 is merged
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const value: any = {
type: AddressType.Account,
accountId,
}
return {
remainderValueStrategy: {
strategy: 'CustomAddress',
value,
value: new AccountAddress(accountId),
},
allowMicroAmount: true,
}
Expand Down