fix(wallet) returning wrong address identity in filter
This fixes returning address identity after that was changed by the real to/from fix. Previously the address was wrongly used as from Updates status-desktop #11233
This commit is contained in:
parent
1cb1c63e82
commit
0b9555bf31
|
@ -330,6 +330,7 @@ const (
|
|||
|
||||
transfers.tx_from_address AS from_address,
|
||||
transfers.tx_to_address AS to_address,
|
||||
transfers.address AS owner_address,
|
||||
transfers.amount_padded128hex AS tr_amount,
|
||||
NULL AS mt_from_amount,
|
||||
NULL AS mt_to_amount,
|
||||
|
@ -402,6 +403,7 @@ const (
|
|||
|
||||
pending_transactions.from_address AS from_address,
|
||||
pending_transactions.to_address AS to_address,
|
||||
NULL AS owner_address,
|
||||
pending_transactions.value AS tr_amount,
|
||||
NULL AS mt_from_amount,
|
||||
NULL AS mt_to_amount,
|
||||
|
@ -446,6 +448,7 @@ const (
|
|||
NULL as tr_type,
|
||||
multi_transactions.from_address AS from_address,
|
||||
multi_transactions.to_address AS to_address,
|
||||
NULL AS owner_address,
|
||||
NULL AS tr_amount,
|
||||
multi_transactions.from_amount AS mt_from_amount,
|
||||
multi_transactions.to_amount AS mt_to_amount,
|
||||
|
@ -598,14 +601,14 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
|||
var timestamp int64
|
||||
var dbMtType, dbTrType sql.NullByte
|
||||
var toAddress, fromAddress eth.Address
|
||||
var toAddressDB sql.RawBytes
|
||||
var toAddressDB, ownerAddressDB sql.RawBytes
|
||||
var tokenAddress *eth.Address
|
||||
var aggregatedStatus int
|
||||
var dbTrAmount sql.NullString
|
||||
var dbMtFromAmount, dbMtToAmount sql.NullString
|
||||
var tokenCode, fromTokenCode, toTokenCode sql.NullString
|
||||
err := rows.Scan(&transferHash, &pendingHash, &chainID, &multiTxID, ×tamp, &dbMtType, &dbTrType, &fromAddress,
|
||||
&toAddressDB, &dbTrAmount, &dbMtFromAmount, &dbMtToAmount, &aggregatedStatus, &aggregatedCount,
|
||||
&toAddressDB, &ownerAddressDB, &dbTrAmount, &dbMtFromAmount, &dbMtToAmount, &aggregatedStatus, &aggregatedCount,
|
||||
&tokenAddress, &tokenCode, &fromTokenCode, &toTokenCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -633,8 +636,9 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
|||
var entry Entry
|
||||
if transferHash != nil && chainID.Valid {
|
||||
// Extract activity type: SendAT/ReceiveAT
|
||||
activityType, filteredAddress := getActivityType(dbTrType)
|
||||
activityType, _ := getActivityType(dbTrType)
|
||||
|
||||
ownerAddress := eth.BytesToAddress(ownerAddressDB)
|
||||
inAmount, outAmount := getTrInAndOutAmounts(activityType, dbTrAmount)
|
||||
|
||||
// Extract tokens
|
||||
|
@ -651,7 +655,7 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
|||
}
|
||||
|
||||
entry = newActivityEntryWithSimpleTransaction(
|
||||
&transfer.TransactionIdentity{ChainID: common.ChainID(chainID.Int64), Hash: eth.BytesToHash(transferHash), Address: filteredAddress},
|
||||
&transfer.TransactionIdentity{ChainID: common.ChainID(chainID.Int64), Hash: eth.BytesToHash(transferHash), Address: ownerAddress},
|
||||
timestamp, activityType, activityStatus, inAmount, outAmount, tokenOut, tokenIn)
|
||||
} else if pendingHash != nil && chainID.Valid {
|
||||
// Extract activity type: PendingAT
|
||||
|
|
|
@ -184,7 +184,7 @@ func TestGetActivityEntriesAll(t *testing.T) {
|
|||
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: td.tr1.ChainID, Hash: td.tr1.Hash, Address: td.tr1.From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: td.tr1.ChainID, Hash: td.tr1.Hash, Address: td.tr1.To},
|
||||
id: td.tr1.MultiTransactionID,
|
||||
timestamp: td.tr1.Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -267,7 +267,8 @@ func TestGetActivityEntriesWithSameTransactionForSenderAndReceiverInDB(t *testin
|
|||
|
||||
require.Equal(t, SendAT, entries[0].activityType)
|
||||
require.NotEqual(t, eth.Address{}, entries[0].transaction.Address)
|
||||
require.Equal(t, td.tr1.From, entries[0].transaction.Address)
|
||||
// TODO: extract and use to/from Address to compare instead of identity
|
||||
require.Equal(t, td.tr1.To, entries[0].transaction.Address)
|
||||
|
||||
entries, err = getActivityEntries(context.Background(), deps, []eth.Address{}, []common.ChainID{}, filter, 0, 10)
|
||||
require.NoError(t, err)
|
||||
|
@ -302,7 +303,7 @@ func TestGetActivityEntriesFilterByTime(t *testing.T) {
|
|||
// Check start and end content
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[5].ChainID, Hash: trs[5].Hash, Address: trs[5].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[5].ChainID, Hash: trs[5].Hash, Address: trs[5].To},
|
||||
id: 0,
|
||||
timestamp: trs[5].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -333,7 +334,7 @@ func TestGetActivityEntriesFilterByTime(t *testing.T) {
|
|||
// Check start and end content
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[2].ChainID, Hash: trs[2].Hash, Address: trs[2].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[2].ChainID, Hash: trs[2].Hash, Address: trs[2].To},
|
||||
id: 0,
|
||||
timestamp: trs[2].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -364,7 +365,7 @@ func TestGetActivityEntriesFilterByTime(t *testing.T) {
|
|||
// Check start and end content
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[2].ChainID, Hash: trs[2].Hash, Address: trs[2].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[2].ChainID, Hash: trs[2].Hash, Address: trs[2].To},
|
||||
id: 0,
|
||||
timestamp: trs[2].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -376,7 +377,7 @@ func TestGetActivityEntriesFilterByTime(t *testing.T) {
|
|||
}, entries[0])
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: td.tr1.ChainID, Hash: td.tr1.Hash, Address: td.tr1.From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: td.tr1.ChainID, Hash: td.tr1.Hash, Address: td.tr1.To},
|
||||
id: 0,
|
||||
timestamp: td.tr1.Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -415,7 +416,7 @@ func TestGetActivityEntriesCheckOffsetAndLimit(t *testing.T) {
|
|||
// Check start and end content
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[8].ChainID, Hash: trs[8].Hash, Address: trs[8].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[8].ChainID, Hash: trs[8].Hash, Address: trs[8].To},
|
||||
id: 0,
|
||||
timestamp: trs[8].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -427,7 +428,7 @@ func TestGetActivityEntriesCheckOffsetAndLimit(t *testing.T) {
|
|||
}, entries[0])
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[6].ChainID, Hash: trs[6].Hash, Address: trs[6].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[6].ChainID, Hash: trs[6].Hash, Address: trs[6].To},
|
||||
id: 0,
|
||||
timestamp: trs[6].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -445,7 +446,7 @@ func TestGetActivityEntriesCheckOffsetAndLimit(t *testing.T) {
|
|||
// Check start and end content
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[6].ChainID, Hash: trs[6].Hash, Address: trs[6].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[6].ChainID, Hash: trs[6].Hash, Address: trs[6].To},
|
||||
id: 0,
|
||||
timestamp: trs[6].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -457,7 +458,7 @@ func TestGetActivityEntriesCheckOffsetAndLimit(t *testing.T) {
|
|||
}, entries[0])
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[4].ChainID, Hash: trs[4].Hash, Address: trs[4].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[4].ChainID, Hash: trs[4].Hash, Address: trs[4].To},
|
||||
id: 0,
|
||||
timestamp: trs[4].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -475,7 +476,7 @@ func TestGetActivityEntriesCheckOffsetAndLimit(t *testing.T) {
|
|||
// Check start and end content
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[2].ChainID, Hash: trs[2].Hash, Address: trs[2].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[2].ChainID, Hash: trs[2].Hash, Address: trs[2].To},
|
||||
id: 0,
|
||||
timestamp: trs[2].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -602,7 +603,7 @@ func TestGetActivityEntriesFilterByAddresses(t *testing.T) {
|
|||
}, entries[0])
|
||||
require.Equal(t, Entry{
|
||||
payloadType: SimpleTransactionPT,
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[1].ChainID, Hash: trs[1].Hash, Address: trs[1].From},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[1].ChainID, Hash: trs[1].Hash, Address: trs[1].To},
|
||||
id: 0,
|
||||
timestamp: trs[1].Timestamp,
|
||||
activityType: SendAT,
|
||||
|
@ -856,7 +857,8 @@ func TestGetActivityEntriesCheckToAndFrom(t *testing.T) {
|
|||
|
||||
require.Equal(t, SendAT, entries[5].activityType) // td.tr1
|
||||
require.NotEqual(t, eth.Address{}, entries[5].transaction.Address) // td.tr1
|
||||
require.Equal(t, td.tr1.From, entries[5].transaction.Address) // td.tr1
|
||||
// TODO: extract to/from Address and use it for comparison instead of identity address
|
||||
require.Equal(t, td.tr1.To, entries[5].transaction.Address) // td.tr1
|
||||
|
||||
require.Equal(t, SendAT, entries[4].activityType) // td.pendingTr
|
||||
|
||||
|
|
Loading…
Reference in New Issue