chore(wallet)_: Fix tests after wallet api sign and send clean up
- Get rid of InsertTestMultiTransaction function in test utils and use InsertMultiTransaction method of transaction manager - Use MultiTransaction type instead of TestMultiTransaction Added a missing wallet DB migration file for multi transactions
This commit is contained in:
parent
ed164e4ac5
commit
3b6b38a414
|
@ -96,6 +96,7 @@ func setupTestActivityDBStorageChoice(tb testing.TB, inMemory bool) (deps Filter
|
|||
}
|
||||
|
||||
func setupTestActivityDB(tb testing.TB) (deps FilterDependencies, close func()) {
|
||||
transfer.SetMultiTransactionIDGenerator(transfer.StaticIDCounter()) // to have different multi-transaction IDs even with fast execution
|
||||
return setupTestActivityDBStorageChoice(tb, true)
|
||||
}
|
||||
|
||||
|
@ -108,10 +109,10 @@ type testData struct {
|
|||
multiTx2Tr2 transfer.TestTransfer // index 6, SNT/Mainnet
|
||||
multiTx2PendingTr transfer.TestTransfer // index 7, DAI/Mainnet
|
||||
|
||||
multiTx1 transfer.TestMultiTransaction
|
||||
multiTx1 transfer.MultiTransaction
|
||||
multiTx1ID common.MultiTransactionIDType
|
||||
|
||||
multiTx2 transfer.TestMultiTransaction
|
||||
multiTx2 transfer.MultiTransaction
|
||||
multiTx2ID common.MultiTransactionIDType
|
||||
|
||||
nextIndex int
|
||||
|
@ -136,7 +137,7 @@ func fillTestData(t *testing.T, db *sql.DB) (td testData, fromAddresses, toAddre
|
|||
td.multiTx1Tr2 = trs[4]
|
||||
|
||||
td.multiTx1 = transfer.GenerateTestSendMultiTransaction(td.multiTx1Tr1)
|
||||
td.multiTx1.ToToken = testutils.DaiSymbol
|
||||
td.multiTx1.ToAsset = testutils.DaiSymbol
|
||||
td.multiTx1ID = transfer.InsertTestMultiTransaction(t, db, &td.multiTx1)
|
||||
|
||||
td.multiTx1Tr1.MultiTransactionID = td.multiTx1ID
|
||||
|
@ -151,7 +152,8 @@ func fillTestData(t *testing.T, db *sql.DB) (td testData, fromAddresses, toAddre
|
|||
td.multiTx2PendingTr = trs[6]
|
||||
|
||||
td.multiTx2 = transfer.GenerateTestSendMultiTransaction(td.multiTx2Tr1)
|
||||
td.multiTx2.ToToken = testutils.SntSymbol
|
||||
td.multiTx2.ToAsset = testutils.SntSymbol
|
||||
|
||||
td.multiTx2ID = transfer.InsertTestMultiTransaction(t, db, &td.multiTx2)
|
||||
|
||||
td.multiTx2Tr1.MultiTransactionID = td.multiTx2ID
|
||||
|
@ -250,13 +252,13 @@ func TestGetActivityEntriesAll(t *testing.T) {
|
|||
payloadType: MultiTransactionPT,
|
||||
transaction: nil,
|
||||
id: td.multiTx1ID,
|
||||
timestamp: td.multiTx1.Timestamp,
|
||||
timestamp: int64(td.multiTx1.Timestamp),
|
||||
activityType: SendAT,
|
||||
activityStatus: FinalizedAS,
|
||||
amountOut: (*hexutil.Big)(big.NewInt(td.multiTx1.FromAmount)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(td.multiTx1.ToAmount)),
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx1.FromToken),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx1.ToToken),
|
||||
amountOut: td.multiTx1.FromAmount,
|
||||
amountIn: td.multiTx1.ToAmount,
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx1.FromAsset),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx1.ToAsset),
|
||||
symbolOut: common.NewAndSet("USDC"),
|
||||
symbolIn: common.NewAndSet("DAI"),
|
||||
sender: &td.multiTx1.FromAddress,
|
||||
|
@ -266,15 +268,15 @@ func TestGetActivityEntriesAll(t *testing.T) {
|
|||
payloadType: MultiTransactionPT,
|
||||
transaction: nil,
|
||||
id: td.multiTx2ID,
|
||||
timestamp: td.multiTx2.Timestamp,
|
||||
timestamp: int64(td.multiTx2.Timestamp),
|
||||
activityType: SendAT,
|
||||
activityStatus: PendingAS,
|
||||
amountOut: (*hexutil.Big)(big.NewInt(td.multiTx2.FromAmount)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(td.multiTx2.ToAmount)),
|
||||
amountOut: td.multiTx2.FromAmount,
|
||||
amountIn: td.multiTx2.ToAmount,
|
||||
symbolOut: common.NewAndSet("USDC"),
|
||||
symbolIn: common.NewAndSet("SNT"),
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx2.FromToken),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx2.ToToken),
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx2.FromAsset),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx2.ToAsset),
|
||||
sender: &td.multiTx2.FromAddress,
|
||||
recipient: &td.multiTx2.ToAddress,
|
||||
}, entries[0])
|
||||
|
@ -331,43 +333,44 @@ func TestGetActivityEntriesFilterByTime(t *testing.T) {
|
|||
|
||||
// Test start only
|
||||
var filter Filter
|
||||
filter.Period.StartTimestamp = td.multiTx1.Timestamp
|
||||
filter.Period.StartTimestamp = int64(td.multiTx1.Timestamp)
|
||||
filter.Period.EndTimestamp = NoLimitTimestampForPeriod
|
||||
entries, err := getActivityEntries(context.Background(), deps, allAddresses, true, []common.ChainID{}, filter, 0, 15)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 8, len(entries))
|
||||
|
||||
const simpleTrIndex = 5
|
||||
// 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].To},
|
||||
transaction: &transfer.TransactionIdentity{ChainID: trs[simpleTrIndex].ChainID, Hash: trs[simpleTrIndex].Hash, Address: trs[simpleTrIndex].To},
|
||||
id: 0,
|
||||
timestamp: trs[5].Timestamp,
|
||||
timestamp: trs[simpleTrIndex].Timestamp,
|
||||
activityType: ReceiveAT,
|
||||
activityStatus: FinalizedAS,
|
||||
amountOut: (*hexutil.Big)(big.NewInt(0)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(trs[5].Value)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(trs[simpleTrIndex].Value)),
|
||||
tokenOut: nil,
|
||||
tokenIn: TTrToToken(t, &trs[5].TestTransaction),
|
||||
tokenIn: TTrToToken(t, &trs[simpleTrIndex].TestTransaction),
|
||||
symbolOut: nil,
|
||||
symbolIn: common.NewAndSet("USDC"),
|
||||
sender: &trs[5].From,
|
||||
recipient: &trs[5].To,
|
||||
sender: &trs[simpleTrIndex].From,
|
||||
recipient: &trs[simpleTrIndex].To,
|
||||
chainIDOut: nil,
|
||||
chainIDIn: &trs[5].ChainID,
|
||||
transferType: expectedTokenType(trs[5].Token.Address),
|
||||
chainIDIn: &trs[simpleTrIndex].ChainID,
|
||||
transferType: expectedTokenType(trs[simpleTrIndex].Token.Address),
|
||||
}, entries[0])
|
||||
require.Equal(t, Entry{
|
||||
payloadType: MultiTransactionPT,
|
||||
transaction: nil,
|
||||
id: td.multiTx1ID,
|
||||
timestamp: td.multiTx1.Timestamp,
|
||||
timestamp: int64(td.multiTx1.Timestamp),
|
||||
activityType: SendAT,
|
||||
activityStatus: FinalizedAS,
|
||||
amountOut: (*hexutil.Big)(big.NewInt(td.multiTx1.FromAmount)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(td.multiTx1.ToAmount)),
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx1.FromToken),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx1.ToToken),
|
||||
amountOut: td.multiTx1.FromAmount,
|
||||
amountIn: td.multiTx1.ToAmount,
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx1.FromAsset),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx1.ToAsset),
|
||||
symbolOut: common.NewAndSet("USDC"),
|
||||
symbolIn: common.NewAndSet("DAI"),
|
||||
sender: &td.multiTx1.FromAddress,
|
||||
|
@ -407,13 +410,13 @@ func TestGetActivityEntriesFilterByTime(t *testing.T) {
|
|||
payloadType: MultiTransactionPT,
|
||||
transaction: nil,
|
||||
id: td.multiTx1ID,
|
||||
timestamp: td.multiTx1.Timestamp,
|
||||
timestamp: int64(td.multiTx1.Timestamp),
|
||||
activityType: SendAT,
|
||||
activityStatus: FinalizedAS,
|
||||
amountOut: (*hexutil.Big)(big.NewInt(td.multiTx1.FromAmount)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(td.multiTx1.ToAmount)),
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx1.FromToken),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx1.ToToken),
|
||||
amountOut: td.multiTx1.FromAmount,
|
||||
amountIn: td.multiTx1.ToAmount,
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx1.FromAsset),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx1.ToAsset),
|
||||
symbolOut: common.NewAndSet("USDC"),
|
||||
symbolIn: common.NewAndSet("DAI"),
|
||||
sender: &td.multiTx1.FromAddress,
|
||||
|
@ -632,7 +635,7 @@ func TestGetActivityEntriesFilterByType(t *testing.T) {
|
|||
// Adds 4 extractable transactions
|
||||
td, tdFromAdds, tdToAddrs := fillTestData(t, deps.db)
|
||||
// Add 5 extractable transactions: one MultiTransactionSwap, two MultiTransactionBridge and two MultiTransactionSend
|
||||
multiTxs := make([]transfer.TestMultiTransaction, 5)
|
||||
multiTxs := make([]transfer.MultiTransaction, 5)
|
||||
trs, fromAddrs, toAddrs := transfer.GenerateTestTransfers(t, deps.db, td.nextIndex, len(multiTxs)*2)
|
||||
multiTxs[0] = transfer.GenerateTestBridgeMultiTransaction(trs[0], trs[1])
|
||||
multiTxs[1] = transfer.GenerateTestSwapMultiTransaction(trs[2], testutils.SntSymbol, 100) // trs[3]
|
||||
|
@ -874,13 +877,13 @@ func TestGetActivityEntriesFilterByAddresses(t *testing.T) {
|
|||
payloadType: MultiTransactionPT,
|
||||
transaction: nil,
|
||||
id: td.multiTx2ID,
|
||||
timestamp: td.multiTx2.Timestamp,
|
||||
timestamp: int64(td.multiTx2.Timestamp),
|
||||
activityType: SendAT,
|
||||
activityStatus: PendingAS,
|
||||
amountOut: (*hexutil.Big)(big.NewInt(td.multiTx2.FromAmount)),
|
||||
amountIn: (*hexutil.Big)(big.NewInt(td.multiTx2.ToAmount)),
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx2.FromToken),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx2.ToToken),
|
||||
amountOut: td.multiTx2.FromAmount,
|
||||
amountIn: td.multiTx2.ToAmount,
|
||||
tokenOut: tokenFromSymbol(nil, td.multiTx2.FromAsset),
|
||||
tokenIn: tokenFromSymbol(nil, td.multiTx2.ToAsset),
|
||||
symbolOut: common.NewAndSet("USDC"),
|
||||
symbolIn: common.NewAndSet("SNT"),
|
||||
sender: &td.multiTx2.FromAddress,
|
||||
|
@ -1206,14 +1209,14 @@ func TestGetActivityEntriesFilterByNetworksOfSubTransactions(t *testing.T) {
|
|||
trs[2].ChainID = 1233
|
||||
mt1 := transfer.GenerateTestBridgeMultiTransaction(trs[0], trs[1])
|
||||
trs[0].MultiTransactionID = transfer.InsertTestMultiTransaction(t, deps.db, &mt1)
|
||||
trs[1].MultiTransactionID = mt1.MultiTransactionID
|
||||
trs[2].MultiTransactionID = mt1.MultiTransactionID
|
||||
trs[1].MultiTransactionID = mt1.ID
|
||||
trs[2].MultiTransactionID = mt1.ID
|
||||
|
||||
trs[3].ChainID = 1234
|
||||
mt2 := transfer.GenerateTestSwapMultiTransaction(trs[3], testutils.SntSymbol, 100)
|
||||
// insertMultiTransaction will insert 0 instead of NULL
|
||||
mt2.FromNetworkID = common.NewAndSet(uint64(0))
|
||||
mt2.ToNetworkID = common.NewAndSet(uint64(0))
|
||||
mt2.FromNetworkID = 0
|
||||
mt2.ToNetworkID = 0
|
||||
trs[3].MultiTransactionID = transfer.InsertTestMultiTransaction(t, deps.db, &mt2)
|
||||
|
||||
for i := range trs {
|
||||
|
@ -1234,20 +1237,20 @@ func TestGetActivityEntriesFilterByNetworksOfSubTransactions(t *testing.T) {
|
|||
entries, err = getActivityEntries(context.Background(), deps, toTrs, false, chainIDs, filter, 0, 15)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(entries))
|
||||
require.Equal(t, entries[0].id, mt1.MultiTransactionID)
|
||||
require.Equal(t, entries[0].id, mt1.ID)
|
||||
|
||||
// Filter by pending_transactions sub-transacitons
|
||||
chainIDs = []common.ChainID{trs[2].ChainID}
|
||||
entries, err = getActivityEntries(context.Background(), deps, toTrs, false, chainIDs, filter, 0, 15)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(entries))
|
||||
require.Equal(t, entries[0].id, mt1.MultiTransactionID)
|
||||
require.Equal(t, entries[0].id, mt1.ID)
|
||||
|
||||
chainIDs = []common.ChainID{trs[3].ChainID}
|
||||
entries, err = getActivityEntries(context.Background(), deps, toTrs, false, chainIDs, filter, 0, 15)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(entries))
|
||||
require.Equal(t, entries[0].id, mt2.MultiTransactionID)
|
||||
require.Equal(t, entries[0].id, mt2.ID)
|
||||
}
|
||||
|
||||
func TestGetActivityEntriesCheckToAndFrom(t *testing.T) {
|
||||
|
@ -1366,11 +1369,11 @@ func TestGetMultiTxDetails(t *testing.T) {
|
|||
_, err := getMultiTxDetails(context.Background(), deps.db, 0)
|
||||
require.EqualError(t, err, "invalid tx id")
|
||||
|
||||
details, err := getMultiTxDetails(context.Background(), deps.db, int(td.multiTx1.MultiTransactionID))
|
||||
details, err := getMultiTxDetails(context.Background(), deps.db, int(td.multiTx1.ID))
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "", details.ID)
|
||||
require.Equal(t, int(td.multiTx1.MultiTransactionID), details.MultiTxID)
|
||||
require.Equal(t, int(td.multiTx1.ID), details.MultiTxID)
|
||||
require.Equal(t, td.multiTx1Tr2.Nonce, details.Nonce)
|
||||
require.Equal(t, 2, len(details.ChainDetails))
|
||||
require.Equal(t, td.multiTx1Tr1.ChainID, common.ChainID(details.ChainDetails[0].ChainID))
|
||||
|
|
|
@ -36,17 +36,17 @@ func setupBenchmark(b *testing.B, accountsCount int, inMemory bool) (deps Filter
|
|||
}
|
||||
|
||||
i := 0
|
||||
multiTxs := make([]transfer.TestMultiTransaction, mtSendCount+mtSwapCount+mtBridgeCount)
|
||||
multiTxs := make([]transfer.MultiTransaction, mtSendCount+mtSwapCount+mtBridgeCount)
|
||||
for ; i < mtSendCount; i++ {
|
||||
multiTxs[i] = transfer.GenerateTestSendMultiTransaction(trs[i])
|
||||
trs[i].From = accounts[i%len(accounts)]
|
||||
multiTxs[i].FromAddress = trs[i].From
|
||||
// Currently the network ID is not filled in for send transactions
|
||||
multiTxs[i].FromNetworkID = nil
|
||||
multiTxs[i].ToNetworkID = nil
|
||||
multiTxs[i].FromNetworkID = 0
|
||||
multiTxs[i].ToNetworkID = 0
|
||||
|
||||
multiTxs[i].MultiTransactionID = transfer.InsertTestMultiTransaction(b, deps.db, &multiTxs[i])
|
||||
trs[i].MultiTransactionID = multiTxs[i].MultiTransactionID
|
||||
multiTxs[i].ID = transfer.InsertTestMultiTransaction(b, deps.db, &multiTxs[i])
|
||||
trs[i].MultiTransactionID = multiTxs[i].ID
|
||||
}
|
||||
|
||||
for j := 0; j < mtSwapCount; i, j = i+1, j+1 {
|
||||
|
@ -54,8 +54,8 @@ func setupBenchmark(b *testing.B, accountsCount int, inMemory bool) (deps Filter
|
|||
trs[i].From = accounts[i%len(accounts)]
|
||||
multiTxs[i].FromAddress = trs[i].From
|
||||
|
||||
multiTxs[i].MultiTransactionID = transfer.InsertTestMultiTransaction(b, deps.db, &multiTxs[i])
|
||||
trs[i].MultiTransactionID = multiTxs[i].MultiTransactionID
|
||||
multiTxs[i].ID = transfer.InsertTestMultiTransaction(b, deps.db, &multiTxs[i])
|
||||
trs[i].MultiTransactionID = multiTxs[i].ID
|
||||
}
|
||||
|
||||
for mtIdx := 0; mtIdx < mtBridgeCount; i, mtIdx = i+2, mtIdx+1 {
|
||||
|
@ -68,9 +68,9 @@ func setupBenchmark(b *testing.B, accountsCount int, inMemory bool) (deps Filter
|
|||
multiTxs[mtIdx].ToAddress = trs[secondTrIdx].To
|
||||
multiTxs[mtIdx].FromAddress = trs[i].From
|
||||
|
||||
multiTxs[mtIdx].MultiTransactionID = transfer.InsertTestMultiTransaction(b, deps.db, &multiTxs[mtIdx])
|
||||
trs[firstTrIdx].MultiTransactionID = multiTxs[mtIdx].MultiTransactionID
|
||||
trs[secondTrIdx].MultiTransactionID = multiTxs[mtIdx].MultiTransactionID
|
||||
multiTxs[mtIdx].ID = transfer.InsertTestMultiTransaction(b, deps.db, &multiTxs[mtIdx])
|
||||
trs[firstTrIdx].MultiTransactionID = multiTxs[mtIdx].ID
|
||||
trs[secondTrIdx].MultiTransactionID = multiTxs[mtIdx].ID
|
||||
}
|
||||
|
||||
for i = 0; i < transactionCount-pendingCount; i++ {
|
||||
|
|
|
@ -29,10 +29,10 @@ func setupTestFilterDB(t *testing.T) (db *sql.DB, close func()) {
|
|||
}
|
||||
|
||||
// insertTestData inserts 6 extractable activity entries: 2 transfers, 2 pending transactions and 2 multi transactions
|
||||
func insertTestData(t *testing.T, db *sql.DB, nullifyToForIndexes []int) (trs []transfer.TestTransfer, toTrs []eth.Address, multiTxs []transfer.TestMultiTransaction) {
|
||||
func insertTestData(t *testing.T, db *sql.DB, nullifyToForIndexes []int) (trs []transfer.TestTransfer, toTrs []eth.Address, multiTxs []transfer.MultiTransaction) {
|
||||
// Add 6 extractable transactions
|
||||
trs, _, toTrs = transfer.GenerateTestTransfers(t, db, 0, 10)
|
||||
multiTxs = []transfer.TestMultiTransaction{
|
||||
multiTxs = []transfer.MultiTransaction{
|
||||
transfer.GenerateTestBridgeMultiTransaction(trs[0], trs[1]),
|
||||
transfer.GenerateTestSwapMultiTransaction(trs[2], testutils.SntSymbol, 100),
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func TestGetRecipients(t *testing.T) {
|
|||
dupTrs, _, _ := transfer.GenerateTestTransfers(t, db, 8, 4)
|
||||
dupTrs[0].To = trs[1].To
|
||||
dupTrs[2].To = trs[2].To
|
||||
dupMultiTxs := []transfer.TestMultiTransaction{
|
||||
dupMultiTxs := []transfer.MultiTransaction{
|
||||
transfer.GenerateTestSendMultiTransaction(dupTrs[0]),
|
||||
transfer.GenerateTestSwapMultiTransaction(dupTrs[2], testutils.SntSymbol, 100),
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func TestGetOldestTimestampEmptyDB(t *testing.T) {
|
|||
|
||||
timestamp, err := GetOldestTimestamp(context.Background(), db, []eth.Address{eth.HexToAddress("0x1")})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(0), timestamp)
|
||||
require.Equal(t, uint64(0), timestamp)
|
||||
}
|
||||
|
||||
func TestGetOldestTimestamp(t *testing.T) {
|
||||
|
@ -178,14 +178,14 @@ func TestGetOldestTimestamp(t *testing.T) {
|
|||
trs[3].To,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, trs[3].Timestamp, timestamp)
|
||||
require.Equal(t, uint64(trs[3].Timestamp), timestamp)
|
||||
|
||||
// Test from filter
|
||||
timestamp, err = GetOldestTimestamp(context.Background(), db, []eth.Address{
|
||||
trs[4].From,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, trs[4].Timestamp, timestamp)
|
||||
require.Equal(t, uint64(trs[4].Timestamp), timestamp)
|
||||
|
||||
// Test MT
|
||||
timestamp, err = GetOldestTimestamp(context.Background(), db, []eth.Address{
|
||||
|
@ -199,7 +199,7 @@ func TestGetOldestTimestamp(t *testing.T) {
|
|||
trs[6].To,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, trs[6].Timestamp, timestamp)
|
||||
require.Equal(t, uint64(trs[6].Timestamp), timestamp)
|
||||
}
|
||||
|
||||
func TestGetOldestTimestamp_NullAddresses(t *testing.T) {
|
||||
|
@ -219,21 +219,21 @@ func TestGetOldestTimestamp_NullAddresses(t *testing.T) {
|
|||
// Extract oldest timestamp, no filter
|
||||
timestamp, err := GetOldestTimestamp(context.Background(), db, []eth.Address{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, trs[0].Timestamp, timestamp)
|
||||
require.Equal(t, uint64(trs[0].Timestamp), timestamp)
|
||||
|
||||
// Test to filter
|
||||
timestamp, err = GetOldestTimestamp(context.Background(), db, []eth.Address{
|
||||
trs[1].To, trs[2].To,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, trs[1].Timestamp, timestamp)
|
||||
require.Equal(t, uint64(trs[1].Timestamp), timestamp)
|
||||
|
||||
// Test from filter
|
||||
timestamp, err = GetOldestTimestamp(context.Background(), db, []eth.Address{
|
||||
trs[1].From,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int64(0), timestamp)
|
||||
require.Equal(t, uint64(0), timestamp)
|
||||
}
|
||||
|
||||
func TestGetActivityCollectiblesEmptyDB(t *testing.T) {
|
||||
|
|
|
@ -35,6 +35,7 @@ func TestController_watchAccountsChanges(t *testing.T) {
|
|||
accountFeed := &event.Feed{}
|
||||
|
||||
bcstate := blockchainstate.NewBlockChainState()
|
||||
SetMultiTransactionIDGenerator(StaticIDCounter()) // to have different multi-transaction IDs even with fast execution
|
||||
transactionManager := NewTransactionManager(walletDB, nil, nil, nil, accountsDB, nil, nil)
|
||||
c := NewTransferController(
|
||||
walletDB,
|
||||
|
|
|
@ -38,17 +38,17 @@ type TestTransfer struct {
|
|||
}
|
||||
|
||||
type TestMultiTransaction struct {
|
||||
MultiTransactionID common.MultiTransactionIDType
|
||||
MultiTransactionType MultiTransactionType
|
||||
FromAddress eth_common.Address
|
||||
ToAddress eth_common.Address
|
||||
FromToken string
|
||||
ToToken string
|
||||
FromAmount int64
|
||||
ToAmount int64
|
||||
Timestamp int64
|
||||
FromNetworkID *uint64
|
||||
ToNetworkID *uint64
|
||||
MultiTransactionID common.MultiTransactionIDType
|
||||
Type MultiTransactionType
|
||||
FromAddress eth_common.Address
|
||||
ToAddress eth_common.Address
|
||||
FromAsset string
|
||||
ToToken string
|
||||
FromAmount int64
|
||||
ToAmount int64
|
||||
Timestamp int64
|
||||
FromNetworkID *uint64
|
||||
ToNetworkID *uint64
|
||||
}
|
||||
|
||||
func SeedToToken(seed int) *token.Token {
|
||||
|
@ -93,42 +93,42 @@ func generateTestTransfer(seed int) TestTransfer {
|
|||
}
|
||||
}
|
||||
|
||||
func GenerateTestSendMultiTransaction(tr TestTransfer) TestMultiTransaction {
|
||||
return TestMultiTransaction{
|
||||
MultiTransactionType: MultiTransactionSend,
|
||||
FromAddress: tr.From,
|
||||
ToAddress: tr.To,
|
||||
FromToken: tr.Token.Symbol,
|
||||
ToToken: tr.Token.Symbol,
|
||||
FromAmount: tr.Value,
|
||||
ToAmount: 0,
|
||||
Timestamp: tr.Timestamp,
|
||||
func GenerateTestSendMultiTransaction(tr TestTransfer) MultiTransaction {
|
||||
return MultiTransaction{
|
||||
Type: MultiTransactionSend,
|
||||
FromAddress: tr.From,
|
||||
ToAddress: tr.To,
|
||||
FromAsset: tr.Token.Symbol,
|
||||
ToAsset: tr.Token.Symbol,
|
||||
FromAmount: (*hexutil.Big)(big.NewInt(tr.Value)),
|
||||
ToAmount: (*hexutil.Big)(big.NewInt(0)),
|
||||
Timestamp: uint64(tr.Timestamp),
|
||||
}
|
||||
}
|
||||
|
||||
func GenerateTestSwapMultiTransaction(tr TestTransfer, toToken string, toAmount int64) TestMultiTransaction {
|
||||
return TestMultiTransaction{
|
||||
MultiTransactionType: MultiTransactionSwap,
|
||||
FromAddress: tr.From,
|
||||
ToAddress: tr.To,
|
||||
FromToken: tr.Token.Symbol,
|
||||
ToToken: toToken,
|
||||
FromAmount: tr.Value,
|
||||
ToAmount: toAmount,
|
||||
Timestamp: tr.Timestamp,
|
||||
func GenerateTestSwapMultiTransaction(tr TestTransfer, toToken string, toAmount int64) MultiTransaction {
|
||||
return MultiTransaction{
|
||||
Type: MultiTransactionSwap,
|
||||
FromAddress: tr.From,
|
||||
ToAddress: tr.To,
|
||||
FromAsset: tr.Token.Symbol,
|
||||
ToAsset: toToken,
|
||||
FromAmount: (*hexutil.Big)(big.NewInt(tr.Value)),
|
||||
ToAmount: (*hexutil.Big)(big.NewInt(toAmount)),
|
||||
Timestamp: uint64(tr.Timestamp),
|
||||
}
|
||||
}
|
||||
|
||||
func GenerateTestBridgeMultiTransaction(fromTr, toTr TestTransfer) TestMultiTransaction {
|
||||
return TestMultiTransaction{
|
||||
MultiTransactionType: MultiTransactionBridge,
|
||||
FromAddress: fromTr.From,
|
||||
ToAddress: toTr.To,
|
||||
FromToken: fromTr.Token.Symbol,
|
||||
ToToken: toTr.Token.Symbol,
|
||||
FromAmount: fromTr.Value,
|
||||
ToAmount: toTr.Value,
|
||||
Timestamp: fromTr.Timestamp,
|
||||
func GenerateTestBridgeMultiTransaction(fromTr, toTr TestTransfer) MultiTransaction {
|
||||
return MultiTransaction{
|
||||
Type: MultiTransactionBridge,
|
||||
FromAddress: fromTr.From,
|
||||
ToAddress: toTr.To,
|
||||
FromAsset: fromTr.Token.Symbol,
|
||||
ToAsset: toTr.Token.Symbol,
|
||||
FromAmount: (*hexutil.Big)(big.NewInt(fromTr.Value)),
|
||||
ToAmount: (*hexutil.Big)(big.NewInt(toTr.Value)),
|
||||
Timestamp: uint64(fromTr.Timestamp),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,30 +367,34 @@ func InsertTestPendingTransaction(tb testing.TB, db *sql.DB, tr *TestTransfer) {
|
|||
require.NoError(tb, err)
|
||||
}
|
||||
|
||||
func InsertTestMultiTransaction(tb testing.TB, db *sql.DB, tr *TestMultiTransaction) common.MultiTransactionIDType {
|
||||
fromTokenType := tr.FromToken
|
||||
if tr.FromToken == "" {
|
||||
fromTokenType = testutils.EthSymbol
|
||||
func InsertTestMultiTransaction(tb testing.TB, db *sql.DB, tr *MultiTransaction) common.MultiTransactionIDType {
|
||||
if tr.FromAsset == "" {
|
||||
tr.FromAsset = testutils.EthSymbol
|
||||
}
|
||||
toTokenType := tr.ToToken
|
||||
if tr.ToToken == "" {
|
||||
toTokenType = testutils.EthSymbol
|
||||
if tr.ToAsset == "" {
|
||||
tr.ToAsset = testutils.EthSymbol
|
||||
}
|
||||
fromAmount := (*hexutil.Big)(big.NewInt(tr.FromAmount))
|
||||
toAmount := (*hexutil.Big)(big.NewInt(tr.ToAmount))
|
||||
|
||||
result, err := db.Exec(`
|
||||
INSERT INTO multi_transactions (from_address, from_asset, from_amount, to_address, to_asset, to_amount, type, timestamp, from_network_id, to_network_id
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
tr.FromAddress, fromTokenType, fromAmount.String(), tr.ToAddress, toTokenType, toAmount.String(), tr.MultiTransactionType, tr.Timestamp, tr.FromNetworkID, tr.ToNetworkID)
|
||||
tr.ID = multiTransactionIDGenerator()
|
||||
err := insertMultiTransaction(db, tr)
|
||||
require.NoError(tb, err)
|
||||
rowID, err := result.LastInsertId()
|
||||
require.NoError(tb, err)
|
||||
tr.MultiTransactionID = common.MultiTransactionIDType(rowID)
|
||||
return tr.MultiTransactionID
|
||||
return tr.ID
|
||||
}
|
||||
|
||||
// For using in tests only outside the package
|
||||
func SaveTransfersMarkBlocksLoaded(database *Database, chainID uint64, address eth_common.Address, transfers []Transfer, blocks []*big.Int) error {
|
||||
return saveTransfersMarkBlocksLoaded(database.client, chainID, address, transfers, blocks)
|
||||
}
|
||||
|
||||
func SetMultiTransactionIDGenerator(f func() common.MultiTransactionIDType) {
|
||||
multiTransactionIDGenerator = f
|
||||
}
|
||||
|
||||
func StaticIDCounter() (f func() common.MultiTransactionIDType) {
|
||||
var i int
|
||||
f = func() common.MultiTransactionIDType {
|
||||
i++
|
||||
return common.MultiTransactionIDType(i)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
func setupTestTransactionDB(t *testing.T) (*TransactionManager, func()) {
|
||||
db, err := helpers.SetupTestMemorySQLDB(walletdatabase.DbInitializer{})
|
||||
require.NoError(t, err)
|
||||
SetMultiTransactionIDGenerator(StaticIDCounter()) // to have different multi-transaction IDs even with fast execution
|
||||
return &TransactionManager{db, nil, nil, nil, nil, nil, nil, nil, nil, nil}, func() {
|
||||
require.NoError(t, db.Close())
|
||||
}
|
||||
|
@ -80,9 +81,8 @@ func TestBridgeMultiTransactions(t *testing.T) {
|
|||
var err error
|
||||
ids := make([]wallet_common.MultiTransactionIDType, len(trxs))
|
||||
for i, trx := range trxs {
|
||||
ids[i], err = insertMultiTransaction(manager.db, trx)
|
||||
ids[i], err = manager.InsertMultiTransaction(trx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, wallet_common.MultiTransactionIDType(i+1), ids[i])
|
||||
}
|
||||
|
||||
rst, err := manager.GetBridgeOriginMultiTransaction(context.Background(), trx1.ToNetworkID, trx1.CrossTxID)
|
||||
|
@ -126,7 +126,7 @@ func TestMultiTransactions(t *testing.T) {
|
|||
trx2 := trx1
|
||||
trx2.FromAmount = (*hexutil.Big)(big.NewInt(456))
|
||||
trx2.ToAmount = (*hexutil.Big)(big.NewInt(567))
|
||||
trx2.ID = generateMultiTransactionID()
|
||||
trx2.ID = multiTransactionIDGenerator()
|
||||
|
||||
require.NotEqual(t, trx1.ID, trx2.ID)
|
||||
|
||||
|
@ -135,9 +135,8 @@ func TestMultiTransactions(t *testing.T) {
|
|||
var err error
|
||||
ids := make([]wallet_common.MultiTransactionIDType, len(trxs))
|
||||
for i, trx := range trxs {
|
||||
ids[i], err = insertMultiTransaction(manager.db, trx)
|
||||
ids[i], err = manager.InsertMultiTransaction(trx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, wallet_common.MultiTransactionIDType(i+1), ids[i])
|
||||
}
|
||||
|
||||
rst, err := manager.GetMultiTransactions(context.Background(), []wallet_common.MultiTransactionIDType{ids[0], 555})
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
// 1708089811_add_nullable_fiesl_blocks_ranges.up.sql (450B)
|
||||
// 1710189541_add_nonce_to_pending_transactions.up.sql (54B)
|
||||
// 1712567001_add_soulbound_collectible_cache.up.sql (75B)
|
||||
// 1714670633_add_id_to_multi_transaction_table.up.sql (1.15kB)
|
||||
// doc.go (94B)
|
||||
|
||||
package migrations
|
||||
|
@ -35,6 +36,7 @@ import (
|
|||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -44,7 +46,7 @@ import (
|
|||
func bindataRead(data []byte, name string) ([]byte, error) {
|
||||
gz, err := gzip.NewReader(bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %q: %w", name, err)
|
||||
return nil, fmt.Errorf("read %q: %v", name, err)
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
@ -52,7 +54,7 @@ func bindataRead(data []byte, name string) ([]byte, error) {
|
|||
clErr := gz.Close()
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %q: %w", name, err)
|
||||
return nil, fmt.Errorf("read %q: %v", name, err)
|
||||
}
|
||||
if clErr != nil {
|
||||
return nil, err
|
||||
|
@ -593,6 +595,26 @@ func _1712567001_add_soulbound_collectible_cacheUpSql() (*asset, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var __1714670633_add_id_to_multi_transaction_tableUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x53\xc1\x6e\x1a\x31\x14\xbc\xef\x57\x8c\x72\x6a\x24\xf3\x05\x3d\x19\xd6\x49\x56\x5d\x76\x23\x63\x1a\xe5\xb4\x72\xb1\x29\x56\x58\x7b\x65\x1b\x01\x7f\x5f\x79\x93\x12\x93\x12\x72\xed\xd5\x9e\x37\xef\xbd\x99\x37\x93\x09\x66\x5e\xcb\xa8\x21\xb1\x72\xc3\x11\x6e\x8d\x7e\xb7\x8d\xa6\x8b\x5e\xda\x20\x57\xd1\x38\x1b\x10\xe5\xaf\xad\xc6\xde\xc4\x0d\xa4\x85\x54\xca\xa4\x77\xb9\xc5\xca\x6d\x77\xbd\xc5\xda\x79\xc4\x8d\xc6\xe0\x4d\x2f\xfd\x11\x2f\xfa\x58\xcc\x38\xa3\x82\x41\xd0\x69\xcd\x60\xf5\xbe\x7b\x25\xf9\x56\x00\x80\x51\xa8\x1a\xc1\xee\x19\xc7\x23\xaf\xe6\x94\x3f\xe3\x07\x7b\x26\x98\x4c\x40\x95\x82\x4c\x05\xd7\xc8\x13\xc7\xda\xbb\xbe\x93\x4a\x79\x1d\x02\x7e\x52\x3e\x7b\xa0\x1c\x4d\x2b\xd0\x2c\xeb\x9a\x64\x90\x10\x74\xbc\x0a\xe8\xdd\xce\x7e\x86\x88\xee\x8b\x1e\x09\x70\xa5\x43\x3c\x0e\xfa\xb3\x2f\xd3\xeb\x10\x65\x3f\x60\xd9\x2c\xaa\xfb\x86\x95\x98\x56\xf7\x55\x23\x2e\x74\x38\x1b\x31\x9b\xdd\xea\xb8\x77\xfe\xa5\x33\xea\x23\xc9\xa9\xf6\x2b\xc8\xca\xbb\x10\xba\x78\x48\x80\xbf\x83\x96\xec\x8e\x2e\x6b\x81\x9b\x9b\xac\x57\x3c\x74\x1b\x19\x36\x98\xd6\xed\xf4\xc4\x9e\x3f\x16\xb7\x78\xaa\xc4\x43\xbb\x14\xe0\xed\x53\x55\x7e\x2f\x8a\x74\x60\xe9\xae\x94\x8c\xb2\xa8\x9a\x05\xe3\x22\x39\xdf\xe6\x17\x61\x14\x39\x33\x93\x64\xbe\x91\xdc\x22\x92\xb9\x41\x4e\xc2\x93\x51\x63\xf2\x2e\x27\x79\x57\x8c\x7c\x54\x89\x9c\x2b\x42\xf2\xed\xc9\xd9\x9a\x24\xdb\xee\x76\xdc\x76\xc1\x6a\x36\x13\xf0\x6e\xff\xff\x4f\x3c\x0e\x7c\xc7\xdb\xf9\x85\x38\xbf\xda\x52\x7a\x37\x8c\xb9\xd2\x07\x13\xa2\xb1\xbf\xdf\x52\x2e\xad\x82\xd7\x56\xf6\x7a\xfc\x4d\x41\x1c\x3f\x8a\x92\xb7\x8f\x6f\x71\xbe\xc4\x49\x6b\xc1\xf8\x3f\x71\xe7\xac\xa1\x73\x06\xd1\x5e\xaa\xf9\x13\x00\x00\xff\xff\xaa\xa3\x4b\x14\x7e\x04\x00\x00")
|
||||
|
||||
func _1714670633_add_id_to_multi_transaction_tableUpSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
__1714670633_add_id_to_multi_transaction_tableUpSql,
|
||||
"1714670633_add_id_to_multi_transaction_table.up.sql",
|
||||
)
|
||||
}
|
||||
|
||||
func _1714670633_add_id_to_multi_transaction_tableUpSql() (*asset, error) {
|
||||
bytes, err := _1714670633_add_id_to_multi_transaction_tableUpSqlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1714670633_add_id_to_multi_transaction_table.up.sql", size: 1150, mode: os.FileMode(0644), modTime: time.Unix(1700000000, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa2, 0x17, 0x7e, 0x5a, 0x17, 0x7c, 0xf8, 0x9c, 0x60, 0xe4, 0xca, 0xd9, 0x32, 0xe5, 0x37, 0xd1, 0xa5, 0xcb, 0x56, 0xf4, 0x1e, 0x9e, 0x8d, 0x1b, 0x8d, 0x66, 0xaa, 0xd9, 0xce, 0x68, 0x3e, 0xcd}}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2c\xcb\x41\x0e\x02\x31\x08\x05\xd0\x7d\x4f\xf1\x2f\x00\xe8\xca\xc4\xc4\xc3\xa0\x43\x08\x19\x5b\xc6\x96\xfb\xc7\x4d\xdf\xfe\x5d\xfa\x39\xd5\x0d\xeb\xf7\x6d\x4d\xc4\xf3\xe9\x36\x6c\x6a\x19\x3c\xe9\x1d\xe3\xd0\x52\x50\xcf\xa3\xa2\xdb\xeb\xfe\xb8\x6d\xa0\xeb\x74\xf4\xf0\xa9\x15\x39\x16\x28\xc1\x2c\x7b\xb0\x27\x58\xda\x3f\x00\x00\xff\xff\x57\xd4\xd5\x90\x5e\x00\x00\x00")
|
||||
|
||||
func docGoBytes() ([]byte, error) {
|
||||
|
@ -704,48 +726,70 @@ func AssetNames() []string {
|
|||
|
||||
// _bindata is a table, holding each asset generator, mapped to its name.
|
||||
var _bindata = map[string]func() (*asset, error){
|
||||
"1691753758_initial.up.sql": _1691753758_initialUpSql,
|
||||
"1692701329_add_collectibles_and_collections_data_cache.up.sql": _1692701329_add_collectibles_and_collections_data_cacheUpSql,
|
||||
"1692701339_add_scope_to_pending.up.sql": _1692701339_add_scope_to_pendingUpSql,
|
||||
"1694540071_add_collectibles_ownership_update_timestamp.up.sql": _1694540071_add_collectibles_ownership_update_timestampUpSql,
|
||||
"1694692748_add_raw_balance_to_token_balances.up.sql": _1694692748_add_raw_balance_to_token_balancesUpSql,
|
||||
"1691753758_initial.up.sql": _1691753758_initialUpSql,
|
||||
|
||||
"1692701329_add_collectibles_and_collections_data_cache.up.sql": _1692701329_add_collectibles_and_collections_data_cacheUpSql,
|
||||
|
||||
"1692701339_add_scope_to_pending.up.sql": _1692701339_add_scope_to_pendingUpSql,
|
||||
|
||||
"1694540071_add_collectibles_ownership_update_timestamp.up.sql": _1694540071_add_collectibles_ownership_update_timestampUpSql,
|
||||
|
||||
"1694692748_add_raw_balance_to_token_balances.up.sql": _1694692748_add_raw_balance_to_token_balancesUpSql,
|
||||
|
||||
"1695133989_add_community_id_to_collectibles_and_collections_data_cache.up.sql": _1695133989_add_community_id_to_collectibles_and_collections_data_cacheUpSql,
|
||||
"1695932536_balance_history_v2.up.sql": _1695932536_balance_history_v2UpSql,
|
||||
"1696853635_input_data.up.sql": _1696853635_input_dataUpSql,
|
||||
"1698117918_add_community_id_to_tokens.up.sql": _1698117918_add_community_id_to_tokensUpSql,
|
||||
"1698257443_add_community_metadata_to_wallet_db.up.sql": _1698257443_add_community_metadata_to_wallet_dbUpSql,
|
||||
"1699987075_add_timestamp_and_state_to_community_data_cache.up.sql": _1699987075_add_timestamp_and_state_to_community_data_cacheUpSql,
|
||||
"1700414564_add_wallet_connect_pairings_table.up.sql": _1700414564_add_wallet_connect_pairings_tableUpSql,
|
||||
"1701101493_add_token_blocks_range.up.sql": _1701101493_add_token_blocks_rangeUpSql,
|
||||
"1702467441_wallet_connect_sessions_instead_of_pairings.up.sql": _1702467441_wallet_connect_sessions_instead_of_pairingsUpSql,
|
||||
"1702577524_add_community_collections_and_collectibles_images_cache.up.sql": _1702577524_add_community_collections_and_collectibles_images_cacheUpSql,
|
||||
"1702867707_add_balance_to_collectibles_ownership_cache.up.sql": _1702867707_add_balance_to_collectibles_ownership_cacheUpSql,
|
||||
"1703686612_add_color_to_saved_addresses.up.sql": _1703686612_add_color_to_saved_addressesUpSql,
|
||||
|
||||
"1695932536_balance_history_v2.up.sql": _1695932536_balance_history_v2UpSql,
|
||||
|
||||
"1696853635_input_data.up.sql": _1696853635_input_dataUpSql,
|
||||
|
||||
"1698117918_add_community_id_to_tokens.up.sql": _1698117918_add_community_id_to_tokensUpSql,
|
||||
|
||||
"1698257443_add_community_metadata_to_wallet_db.up.sql": _1698257443_add_community_metadata_to_wallet_dbUpSql,
|
||||
|
||||
"1699987075_add_timestamp_and_state_to_community_data_cache.up.sql": _1699987075_add_timestamp_and_state_to_community_data_cacheUpSql,
|
||||
|
||||
"1700414564_add_wallet_connect_pairings_table.up.sql": _1700414564_add_wallet_connect_pairings_tableUpSql,
|
||||
|
||||
"1701101493_add_token_blocks_range.up.sql": _1701101493_add_token_blocks_rangeUpSql,
|
||||
|
||||
"1702467441_wallet_connect_sessions_instead_of_pairings.up.sql": _1702467441_wallet_connect_sessions_instead_of_pairingsUpSql,
|
||||
|
||||
"1702577524_add_community_collections_and_collectibles_images_cache.up.sql": _1702577524_add_community_collections_and_collectibles_images_cacheUpSql,
|
||||
|
||||
"1702867707_add_balance_to_collectibles_ownership_cache.up.sql": _1702867707_add_balance_to_collectibles_ownership_cacheUpSql,
|
||||
|
||||
"1703686612_add_color_to_saved_addresses.up.sql": _1703686612_add_color_to_saved_addressesUpSql,
|
||||
|
||||
"1704701942_remove_favourite_and_change_primary_key_for_saved_addresses.up.sql": _1704701942_remove_favourite_and_change_primary_key_for_saved_addressesUpSql,
|
||||
"1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cache.up.sql": _1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cacheUpSql,
|
||||
"1705664490_add_balance_check_fields_blocks_ranges_sequential.up.sql": _1705664490_add_balance_check_fields_blocks_ranges_sequentialUpSql,
|
||||
"1706531789_remove_gasfee-only-eth-transfers.up.sql": _1706531789_remove_gasfeeOnlyEthTransfersUpSql,
|
||||
"1707160323_add_contract_type_table.up.sql": _1707160323_add_contract_type_tableUpSql,
|
||||
"1708089811_add_nullable_fiesl_blocks_ranges.up.sql": _1708089811_add_nullable_fiesl_blocks_rangesUpSql,
|
||||
"1710189541_add_nonce_to_pending_transactions.up.sql": _1710189541_add_nonce_to_pending_transactionsUpSql,
|
||||
"1712567001_add_soulbound_collectible_cache.up.sql": _1712567001_add_soulbound_collectible_cacheUpSql,
|
||||
|
||||
"1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cache.up.sql": _1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cacheUpSql,
|
||||
|
||||
"1705664490_add_balance_check_fields_blocks_ranges_sequential.up.sql": _1705664490_add_balance_check_fields_blocks_ranges_sequentialUpSql,
|
||||
|
||||
"1706531789_remove_gasfee-only-eth-transfers.up.sql": _1706531789_remove_gasfeeOnlyEthTransfersUpSql,
|
||||
|
||||
"1707160323_add_contract_type_table.up.sql": _1707160323_add_contract_type_tableUpSql,
|
||||
|
||||
"1708089811_add_nullable_fiesl_blocks_ranges.up.sql": _1708089811_add_nullable_fiesl_blocks_rangesUpSql,
|
||||
|
||||
"1710189541_add_nonce_to_pending_transactions.up.sql": _1710189541_add_nonce_to_pending_transactionsUpSql,
|
||||
|
||||
"1712567001_add_soulbound_collectible_cache.up.sql": _1712567001_add_soulbound_collectible_cacheUpSql,
|
||||
|
||||
"1714670633_add_id_to_multi_transaction_table.up.sql": _1714670633_add_id_to_multi_transaction_tableUpSql,
|
||||
|
||||
"doc.go": docGo,
|
||||
}
|
||||
|
||||
// AssetDebug is true if the assets were built with the debug flag enabled.
|
||||
const AssetDebug = false
|
||||
|
||||
// AssetDir returns the file names below a certain
|
||||
// directory embedded in the file by go-bindata.
|
||||
// For example if you run go-bindata on data/... and data contains the
|
||||
// following hierarchy:
|
||||
//
|
||||
// data/
|
||||
// foo.txt
|
||||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
//
|
||||
// data/
|
||||
// foo.txt
|
||||
// img/
|
||||
// a.png
|
||||
// b.png
|
||||
// then AssetDir("data") would return []string{"foo.txt", "img"},
|
||||
// AssetDir("data/img") would return []string{"a.png", "b.png"},
|
||||
// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and
|
||||
|
@ -778,32 +822,33 @@ type bintree struct {
|
|||
}
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"1691753758_initial.up.sql": {_1691753758_initialUpSql, map[string]*bintree{}},
|
||||
"1692701329_add_collectibles_and_collections_data_cache.up.sql": {_1692701329_add_collectibles_and_collections_data_cacheUpSql, map[string]*bintree{}},
|
||||
"1692701339_add_scope_to_pending.up.sql": {_1692701339_add_scope_to_pendingUpSql, map[string]*bintree{}},
|
||||
"1694540071_add_collectibles_ownership_update_timestamp.up.sql": {_1694540071_add_collectibles_ownership_update_timestampUpSql, map[string]*bintree{}},
|
||||
"1694692748_add_raw_balance_to_token_balances.up.sql": {_1694692748_add_raw_balance_to_token_balancesUpSql, map[string]*bintree{}},
|
||||
"1695133989_add_community_id_to_collectibles_and_collections_data_cache.up.sql": {_1695133989_add_community_id_to_collectibles_and_collections_data_cacheUpSql, map[string]*bintree{}},
|
||||
"1695932536_balance_history_v2.up.sql": {_1695932536_balance_history_v2UpSql, map[string]*bintree{}},
|
||||
"1696853635_input_data.up.sql": {_1696853635_input_dataUpSql, map[string]*bintree{}},
|
||||
"1698117918_add_community_id_to_tokens.up.sql": {_1698117918_add_community_id_to_tokensUpSql, map[string]*bintree{}},
|
||||
"1698257443_add_community_metadata_to_wallet_db.up.sql": {_1698257443_add_community_metadata_to_wallet_dbUpSql, map[string]*bintree{}},
|
||||
"1699987075_add_timestamp_and_state_to_community_data_cache.up.sql": {_1699987075_add_timestamp_and_state_to_community_data_cacheUpSql, map[string]*bintree{}},
|
||||
"1700414564_add_wallet_connect_pairings_table.up.sql": {_1700414564_add_wallet_connect_pairings_tableUpSql, map[string]*bintree{}},
|
||||
"1701101493_add_token_blocks_range.up.sql": {_1701101493_add_token_blocks_rangeUpSql, map[string]*bintree{}},
|
||||
"1702467441_wallet_connect_sessions_instead_of_pairings.up.sql": {_1702467441_wallet_connect_sessions_instead_of_pairingsUpSql, map[string]*bintree{}},
|
||||
"1702577524_add_community_collections_and_collectibles_images_cache.up.sql": {_1702577524_add_community_collections_and_collectibles_images_cacheUpSql, map[string]*bintree{}},
|
||||
"1702867707_add_balance_to_collectibles_ownership_cache.up.sql": {_1702867707_add_balance_to_collectibles_ownership_cacheUpSql, map[string]*bintree{}},
|
||||
"1703686612_add_color_to_saved_addresses.up.sql": {_1703686612_add_color_to_saved_addressesUpSql, map[string]*bintree{}},
|
||||
"1704701942_remove_favourite_and_change_primary_key_for_saved_addresses.up.sql": {_1704701942_remove_favourite_and_change_primary_key_for_saved_addressesUpSql, map[string]*bintree{}},
|
||||
"1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cache.up.sql": {_1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cacheUpSql, map[string]*bintree{}},
|
||||
"1705664490_add_balance_check_fields_blocks_ranges_sequential.up.sql": {_1705664490_add_balance_check_fields_blocks_ranges_sequentialUpSql, map[string]*bintree{}},
|
||||
"1706531789_remove_gasfee-only-eth-transfers.up.sql": {_1706531789_remove_gasfeeOnlyEthTransfersUpSql, map[string]*bintree{}},
|
||||
"1707160323_add_contract_type_table.up.sql": {_1707160323_add_contract_type_tableUpSql, map[string]*bintree{}},
|
||||
"1708089811_add_nullable_fiesl_blocks_ranges.up.sql": {_1708089811_add_nullable_fiesl_blocks_rangesUpSql, map[string]*bintree{}},
|
||||
"1710189541_add_nonce_to_pending_transactions.up.sql": {_1710189541_add_nonce_to_pending_transactionsUpSql, map[string]*bintree{}},
|
||||
"1712567001_add_soulbound_collectible_cache.up.sql": {_1712567001_add_soulbound_collectible_cacheUpSql, map[string]*bintree{}},
|
||||
"doc.go": {docGo, map[string]*bintree{}},
|
||||
"1691753758_initial.up.sql": &bintree{_1691753758_initialUpSql, map[string]*bintree{}},
|
||||
"1692701329_add_collectibles_and_collections_data_cache.up.sql": &bintree{_1692701329_add_collectibles_and_collections_data_cacheUpSql, map[string]*bintree{}},
|
||||
"1692701339_add_scope_to_pending.up.sql": &bintree{_1692701339_add_scope_to_pendingUpSql, map[string]*bintree{}},
|
||||
"1694540071_add_collectibles_ownership_update_timestamp.up.sql": &bintree{_1694540071_add_collectibles_ownership_update_timestampUpSql, map[string]*bintree{}},
|
||||
"1694692748_add_raw_balance_to_token_balances.up.sql": &bintree{_1694692748_add_raw_balance_to_token_balancesUpSql, map[string]*bintree{}},
|
||||
"1695133989_add_community_id_to_collectibles_and_collections_data_cache.up.sql": &bintree{_1695133989_add_community_id_to_collectibles_and_collections_data_cacheUpSql, map[string]*bintree{}},
|
||||
"1695932536_balance_history_v2.up.sql": &bintree{_1695932536_balance_history_v2UpSql, map[string]*bintree{}},
|
||||
"1696853635_input_data.up.sql": &bintree{_1696853635_input_dataUpSql, map[string]*bintree{}},
|
||||
"1698117918_add_community_id_to_tokens.up.sql": &bintree{_1698117918_add_community_id_to_tokensUpSql, map[string]*bintree{}},
|
||||
"1698257443_add_community_metadata_to_wallet_db.up.sql": &bintree{_1698257443_add_community_metadata_to_wallet_dbUpSql, map[string]*bintree{}},
|
||||
"1699987075_add_timestamp_and_state_to_community_data_cache.up.sql": &bintree{_1699987075_add_timestamp_and_state_to_community_data_cacheUpSql, map[string]*bintree{}},
|
||||
"1700414564_add_wallet_connect_pairings_table.up.sql": &bintree{_1700414564_add_wallet_connect_pairings_tableUpSql, map[string]*bintree{}},
|
||||
"1701101493_add_token_blocks_range.up.sql": &bintree{_1701101493_add_token_blocks_rangeUpSql, map[string]*bintree{}},
|
||||
"1702467441_wallet_connect_sessions_instead_of_pairings.up.sql": &bintree{_1702467441_wallet_connect_sessions_instead_of_pairingsUpSql, map[string]*bintree{}},
|
||||
"1702577524_add_community_collections_and_collectibles_images_cache.up.sql": &bintree{_1702577524_add_community_collections_and_collectibles_images_cacheUpSql, map[string]*bintree{}},
|
||||
"1702867707_add_balance_to_collectibles_ownership_cache.up.sql": &bintree{_1702867707_add_balance_to_collectibles_ownership_cacheUpSql, map[string]*bintree{}},
|
||||
"1703686612_add_color_to_saved_addresses.up.sql": &bintree{_1703686612_add_color_to_saved_addressesUpSql, map[string]*bintree{}},
|
||||
"1704701942_remove_favourite_and_change_primary_key_for_saved_addresses.up.sql": &bintree{_1704701942_remove_favourite_and_change_primary_key_for_saved_addressesUpSql, map[string]*bintree{}},
|
||||
"1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cache.up.sql": &bintree{_1704913491_add_type_and_tx_timestamp_to_collectibles_ownership_cacheUpSql, map[string]*bintree{}},
|
||||
"1705664490_add_balance_check_fields_blocks_ranges_sequential.up.sql": &bintree{_1705664490_add_balance_check_fields_blocks_ranges_sequentialUpSql, map[string]*bintree{}},
|
||||
"1706531789_remove_gasfee-only-eth-transfers.up.sql": &bintree{_1706531789_remove_gasfeeOnlyEthTransfersUpSql, map[string]*bintree{}},
|
||||
"1707160323_add_contract_type_table.up.sql": &bintree{_1707160323_add_contract_type_tableUpSql, map[string]*bintree{}},
|
||||
"1708089811_add_nullable_fiesl_blocks_ranges.up.sql": &bintree{_1708089811_add_nullable_fiesl_blocks_rangesUpSql, map[string]*bintree{}},
|
||||
"1710189541_add_nonce_to_pending_transactions.up.sql": &bintree{_1710189541_add_nonce_to_pending_transactionsUpSql, map[string]*bintree{}},
|
||||
"1712567001_add_soulbound_collectible_cache.up.sql": &bintree{_1712567001_add_soulbound_collectible_cacheUpSql, map[string]*bintree{}},
|
||||
"1714670633_add_id_to_multi_transaction_table.up.sql": &bintree{_1714670633_add_id_to_multi_transaction_tableUpSql, map[string]*bintree{}},
|
||||
"doc.go": &bintree{docGo, map[string]*bintree{}},
|
||||
}}
|
||||
|
||||
// RestoreAsset restores an asset under the given directory.
|
||||
|
@ -820,7 +865,7 @@ func RestoreAsset(dir, name string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
-- Create a copy of multi_transactions table with an additional column for the primary key
|
||||
CREATE TABLE new_table (
|
||||
id INTEGER PRIMARY KEY, -- Add a new column for the primary key
|
||||
from_address VARCHAR NOT NULL,
|
||||
from_asset VARCHAR NOT NULL,
|
||||
from_amount VARCHAR NOT NULL,
|
||||
to_address VARCHAR NOT NULL,
|
||||
to_asset VARCHAR NOT NULL,
|
||||
type VARCHAR NOT NULL,
|
||||
timestamp UNSIGNED BIGINT NOT NULL,
|
||||
to_amount VARCHAR,
|
||||
from_network_id UNSIGNED BIGINT,
|
||||
to_network_id UNSIGNED BIGINT,
|
||||
cross_tx_id VARCHAR DEFAULT "",
|
||||
from_tx_hash BLOB,
|
||||
to_tx_hash BLOB
|
||||
) WITHOUT ROWID;
|
||||
|
||||
-- Copy data
|
||||
INSERT INTO new_table (id, from_address, from_asset, from_amount, to_address, to_asset, type, timestamp, to_amount, from_network_id, to_network_id, cross_tx_id, from_tx_hash, to_tx_hash)
|
||||
SELECT rowid, from_address, from_asset, from_amount, to_address, to_asset, type, timestamp, to_amount, from_network_id, to_network_id, cross_tx_id, from_tx_hash, to_tx_hash
|
||||
FROM multi_transactions;
|
||||
|
||||
-- Drop the existing table and rename the new table
|
||||
DROP TABLE multi_transactions;
|
||||
ALTER TABLE new_table RENAME TO multi_transactions;
|
Loading…
Reference in New Issue