Skip to content
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

fix: Receive funds to implicit account address #8260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e73bd56
feat: Sync SDK types
marc2332 Mar 22, 2024
4d28457
feat: stop generating txs out of outputs
marc2332 Mar 22, 2024
71f88e7
fix: tx history: include account output in average txs
cpl121 Mar 22, 2024
eb19a90
Merge branch 'develop-iota2.0' into feat/sync-sdk-types
cpl121 Mar 22, 2024
a850bb8
Merge branch 'feat/sync-sdk-types' into feat/stop-generating-txs-out-…
cpl121 Mar 22, 2024
3cedefe
Merge branch 'feat/stop-generating-txs-out-of-outputs' into fix/tx-hi…
cpl121 Mar 22, 2024
e499fa4
fix: Fix incorrect timestamp in Incoming txs
marc2332 Mar 25, 2024
4098672
fix: Receive funds to implicit account address
marc2332 Mar 25, 2024
07cf0a4
Merge branches 'fix/tx-history-include-account-output-in-avg-txs' and…
cpl121 Mar 25, 2024
c3f486e
Merge branch 'develop-iota2.0' into fix/tx-history-include-account-ou…
cpl121 Mar 25, 2024
a501aa2
Merge branch 'fix/tx-history-include-account-output-in-avg-txs' into …
cpl121 Mar 25, 2024
ea52b1c
Merge branch 'fix/incorrect-timestamp-incoming-txs' into fix/receive-…
cpl121 Mar 25, 2024
de89392
Merge branch 'develop-iota2.0' into fix/tx-history-include-account-ou…
cpl121 Mar 25, 2024
278543c
Merge branch 'fix/tx-history-include-account-output-in-avg-txs' into …
cpl121 Mar 25, 2024
f3f4e32
Merge branch 'fix/incorrect-timestamp-incoming-txs' into fix/receive-…
cpl121 Mar 25, 2024
e07821c
Merge branches 'fix/incorrect-timestamp-incoming-txs' and 'develop-io…
cpl121 Mar 25, 2024
c1d22a9
Merge branch 'fix/incorrect-timestamp-incoming-txs' into fix/receive-…
cpl121 Mar 25, 2024
541013a
Merge branch 'develop-iota2.0' into fix/incorrect-timestamp-incoming-txs
cpl121 Mar 27, 2024
8d3126b
Merge branch 'fix/incorrect-timestamp-incoming-txs' into fix/receive-…
cpl121 Mar 27, 2024
b2ecdce
Merge branch 'develop-iota2.0' into fix/receive-funds-to-implicit-acc…
cpl121 Mar 27, 2024
e9e832b
feat: add mana to txs in tx activities and activity details (#8263)
cpl121 Mar 27, 2024
a067fc1
Revert "feat: add mana to txs in tx activities and activity details (…
marc2332 Mar 28, 2024
3fa985c
Merge branch 'develop-iota2.0' into fix/receive-funds-to-implicit-acc…
begonaalvarezd Mar 28, 2024
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,5 +1,5 @@
import { IWalletState } from '@core/wallet/interfaces'
import { ActivityAction, ActivityType, IProcessedTransaction } from '@core/wallet'
import { ActivityAction, ActivityType, IProcessedTransaction, getSenderAddressFromInputs } from '@core/wallet'
import { Activity } from '@core/wallet/types'
import { isParticipationOutput } from '@contexts/governance/utils'
import { generateSingleAccountActivity } from './generateSingleAccountActivity'
Expand Down Expand Up @@ -33,6 +33,8 @@ async function generateActivitiesFromProcessedTransactionsWithInputs(
wallet: IWalletState
): Promise<Activity[]> {
const { outputs, wrappedInputs } = processedTransaction
const sender = getSenderAddressFromInputs(wrappedInputs)
const isSentToImplicitAccountCreationAddress = sender === (await wallet.implicitAccountCreationAddress())
const activities: Activity[] = []

const containsFoundryActivity = outputs.some((output) => output.output.type === OutputType.Foundry)
Expand Down Expand Up @@ -75,7 +77,11 @@ async function generateActivitiesFromProcessedTransactionsWithInputs(
const anchorActivities = await generateActivitiesFromAnchorOutputs(processedTransaction, wallet)
activities.push(...anchorActivities)
}
if (!containsFoundryActivity && !containsNftActivity && !containsAccountActivity && !governanceOutput) {

if (
(!containsFoundryActivity && !containsNftActivity && !containsAccountActivity && !governanceOutput) ||
isSentToImplicitAccountCreationAddress
) {
const basicActivities = await generateActivitiesFromBasicOutputs(processedTransaction, wallet)
activities.push(...basicActivities)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function generateActivitiesFromBasicOutputs(

const basicOutputs = getNonRemainderBasicOutputsFromTransaction(
processedTransaction.outputs,
wallet.depositAddress,
[wallet.depositAddress, await wallet.implicitAccountCreationAddress()],
processedTransaction.direction
)
const burnedNftInputs = getBurnedNftInputs(processedTransaction)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IProcessedTransaction, IWrappedOutput } from '../../interfaces'
import { Output, OutputType, OutputWithMetadata, TransactionWithMetadata, UTXOInput } from '@iota/sdk/out/types'
// import { computeOutputId } from './computeOutputId'
import { getOutputIdFromTransactionIdAndIndex } from './getOutputIdFromTransactionIdAndIndex'
import { ActivityDirection } from '../../enums'
import { getUnixTimestampFromNodeInfoAndSlotIndex, nodeInfoProtocolParameters } from '@core/network'
Expand All @@ -18,21 +17,20 @@ export function preprocessIncomingTransaction(transaction: TransactionWithMetada
const outputs = convertTransactionsOutputTypesToWrappedOutputs(transactionId, regularTransactionEssence.outputs)

const utxoInputs = regularTransactionEssence.inputs.map((i) => i as UTXOInput)
// const inputIds = utxoInputs.map((input) => {
// const transactionId = input.transactionId
// const transactionOutputIndex = input.transactionOutputIndex
// return computeOutputId(transactionId, transactionOutputIndex)
// })
// const inputs = await Promise.all(inputIds.map((inputId) => wallet.getOutput(inputId)))
const inputs = transaction.inputs.map((input) => ({
output: input.output,
outputId: input.metadata.outputId,
metadata: input.metadata,
remainder: true,
}))

return {
outputs: outputs,
outputs,
transactionId,
direction: ActivityDirection.Incoming,
time: new Date(slotUnixTimestamp * MILLISECONDS_PER_SECOND),
inclusionState: transaction.inclusionState,
wrappedInputs: [],
// wrappedInputs: <IWrappedOutput[]>inputs,
wrappedInputs: <IWrappedOutput[]>inputs,
utxoInputs,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { CommonOutput } from '@iota/sdk/out/types'

export function getNonRemainderBasicOutputsFromTransaction(
wrappedOutputs: IWrappedOutput[],
walletDepositAddress: string,
validAddresses: string[],
direction: ActivityDirection
): IWrappedOutput[] {
return wrappedOutputs.filter((outputData) => {
const recipientAddress = getRecipientAddressFromOutput(outputData.output as CommonOutput)

if (direction === ActivityDirection.Incoming || direction === ActivityDirection.SelfTransaction) {
return !outputData.remainder && walletDepositAddress === recipientAddress
return !outputData.remainder && validAddresses.includes(recipientAddress)
} else {
return walletDepositAddress !== recipientAddress
return !validAddresses.includes(recipientAddress)
}
})
}
Loading