fix_: Add pending tx for collectibles
This commit is contained in:
parent
58a3cc1127
commit
094d26dc66
|
@ -557,7 +557,7 @@ func getActivityEntries(ctx context.Context, deps FilterDependencies, addresses
|
|||
} else if trType.Byte == toTrType {
|
||||
at := ReceiveAT
|
||||
if fromAddress == ZeroAddress && transferType != nil {
|
||||
if *transferType == TransferTypeErc721 || (*transferType == TransferTypeErc20 && methodHash.Valid && (communityMintEvent || sliceContains(inputDataMethods, methodHash.String))) {
|
||||
if *transferType == TransferTypeErc721 || *transferType == TransferTypeErc1155 || (*transferType == TransferTypeErc20 && methodHash.Valid && (communityMintEvent || sliceContains(inputDataMethods, methodHash.String))) {
|
||||
at = MintAT
|
||||
}
|
||||
}
|
||||
|
@ -776,6 +776,8 @@ func contractTypeFromDBType(dbType string) (transferType *TransferType) {
|
|||
*transferType = TransferTypeErc20
|
||||
case common.Erc721Transfer:
|
||||
*transferType = TransferTypeErc721
|
||||
case common.Erc1155Transfer:
|
||||
*transferType = TransferTypeErc1155
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -344,9 +344,10 @@ func (s *CelerBridgeProcessor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, s
|
|||
return nil, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
|
||||
var tx *ethTypes.Transaction
|
||||
txOpts := sendArgs.CbridgeTx.ToTransactOpts(signerFn)
|
||||
if token.IsNative() {
|
||||
return contract.SendNative(
|
||||
tx, err = contract.SendNative(
|
||||
txOpts,
|
||||
sendArgs.CbridgeTx.Recipient,
|
||||
(*big.Int)(sendArgs.CbridgeTx.Amount),
|
||||
|
@ -354,17 +355,25 @@ func (s *CelerBridgeProcessor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, s
|
|||
uint64(time.Now().UnixMilli()),
|
||||
maxSlippage,
|
||||
)
|
||||
} else {
|
||||
tx, err = contract.Send(
|
||||
txOpts,
|
||||
sendArgs.CbridgeTx.Recipient,
|
||||
token.Address,
|
||||
(*big.Int)(sendArgs.CbridgeTx.Amount),
|
||||
sendArgs.CbridgeTx.ChainID,
|
||||
uint64(time.Now().UnixMilli()),
|
||||
maxSlippage,
|
||||
)
|
||||
}
|
||||
|
||||
return contract.Send(
|
||||
txOpts,
|
||||
sendArgs.CbridgeTx.Recipient,
|
||||
token.Address,
|
||||
(*big.Int)(sendArgs.CbridgeTx.Amount),
|
||||
sendArgs.CbridgeTx.ChainID,
|
||||
uint64(time.Now().UnixMilli()),
|
||||
maxSlippage,
|
||||
)
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
err = s.transactor.StoreAndTrackPendingTx(txOpts.From, sendArgs.CbridgeTx.Symbol, sendArgs.ChainID, sendArgs.CbridgeTx.MultiTransactionID, tx)
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
func (s *CelerBridgeProcessor) Send(sendArgs *MultipathProcessorTxArgs, verifiedAccount *account.SelectedExtKey) (types.Hash, error) {
|
||||
|
|
|
@ -341,18 +341,26 @@ func (h *HopBridgeProcessor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, sig
|
|||
|
||||
switch contractType {
|
||||
case hop.CctpL1Bridge:
|
||||
return h.sendCctpL1BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
tx, err = h.sendCctpL1BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
case hop.L1Bridge:
|
||||
return h.sendL1BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, token, bonderFee)
|
||||
tx, err = h.sendL1BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, token, bonderFee)
|
||||
case hop.L2AmmWrapper:
|
||||
return h.sendL2AmmWrapperTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
tx, err = h.sendL2AmmWrapperTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
case hop.CctpL2Bridge:
|
||||
return h.sendCctpL2BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
tx, err = h.sendCctpL2BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
case hop.L2Bridge:
|
||||
return h.sendL2BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
tx, err = h.sendL2BridgeTx(contractAddress, ethClient, sendArgs.HopTx.ChainID, sendArgs.HopTx.Recipient, txOpts, bonderFee)
|
||||
default:
|
||||
return tx, ErrContractTypeNotSupported
|
||||
}
|
||||
|
||||
return tx, ErrContractTypeNotSupported
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
err = h.transactor.StoreAndTrackPendingTx(txOpts.From, sendArgs.HopTx.Symbol, sendArgs.ChainID, sendArgs.HopTx.MultiTransactionID, tx)
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
func (h *HopBridgeProcessor) Send(sendArgs *MultipathProcessorTxArgs, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error) {
|
||||
|
|
|
@ -151,8 +151,9 @@ func (s *ERC1155Processor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, signe
|
|||
argNonce := hexutil.Uint64(nonce)
|
||||
sendArgs.ERC1155TransferTx.Nonce = &argNonce
|
||||
txOpts := sendArgs.ERC1155TransferTx.ToTransactOpts(signerFn)
|
||||
from := common.Address(sendArgs.ERC1155TransferTx.From)
|
||||
tx, err = contract.SafeTransferFrom(
|
||||
txOpts, common.Address(sendArgs.ERC1155TransferTx.From),
|
||||
txOpts, from,
|
||||
sendArgs.ERC1155TransferTx.Recipient,
|
||||
sendArgs.ERC1155TransferTx.TokenID.ToInt(),
|
||||
sendArgs.ERC1155TransferTx.Amount.ToInt(),
|
||||
|
@ -161,7 +162,10 @@ func (s *ERC1155Processor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, signe
|
|||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
|
||||
err = s.transactor.StoreAndTrackPendingTx(from, sendArgs.ERC1155TransferTx.Symbol, sendArgs.ChainID, sendArgs.ERC1155TransferTx.MultiTransactionID, tx)
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -148,13 +148,17 @@ func (s *ERC721Processor) sendOrBuild(sendArgs *MultipathProcessorTxArgs, signer
|
|||
argNonce := hexutil.Uint64(nonce)
|
||||
sendArgs.ERC721TransferTx.Nonce = &argNonce
|
||||
txOpts := sendArgs.ERC721TransferTx.ToTransactOpts(signerFn)
|
||||
|
||||
tx, err = contract.SafeTransferFrom(txOpts, common.Address(sendArgs.ERC721TransferTx.From),
|
||||
from := common.Address(sendArgs.ERC721TransferTx.From)
|
||||
tx, err = contract.SafeTransferFrom(txOpts, from,
|
||||
sendArgs.ERC721TransferTx.Recipient,
|
||||
sendArgs.ERC721TransferTx.TokenID.ToInt())
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
err = s.transactor.StoreAndTrackPendingTx(from, sendArgs.ERC721TransferTx.Symbol, sendArgs.ChainID, sendArgs.ERC721TransferTx.MultiTransactionID, tx)
|
||||
if err != nil {
|
||||
return tx, statusErrors.CreateErrorResponseFromError(err)
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -162,6 +162,20 @@ func (mr *MockTransactorIfaceMockRecorder) SendTransactionWithSignature(from, sy
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendTransactionWithSignature", reflect.TypeOf((*MockTransactorIface)(nil).SendTransactionWithSignature), from, symbol, multiTransactionID, tx)
|
||||
}
|
||||
|
||||
// StoreAndTrackPendingTx mocks base method.
|
||||
func (m *MockTransactorIface) StoreAndTrackPendingTx(from common.Address, symbol string, chainID uint64, multiTransactionID common0.MultiTransactionIDType, tx *types.Transaction) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StoreAndTrackPendingTx", from, symbol, chainID, multiTransactionID, tx)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// StoreAndTrackPendingTx indicates an expected call of StoreAndTrackPendingTx.
|
||||
func (mr *MockTransactorIfaceMockRecorder) StoreAndTrackPendingTx(from, symbol, chainID, multiTransactionID, tx interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreAndTrackPendingTx", reflect.TypeOf((*MockTransactorIface)(nil).StoreAndTrackPendingTx), from, symbol, chainID, multiTransactionID, tx)
|
||||
}
|
||||
|
||||
// ValidateAndBuildTransaction mocks base method.
|
||||
func (m *MockTransactorIface) ValidateAndBuildTransaction(chainID uint64, sendArgs transactions.SendTxArgs) (*types.Transaction, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
|
|
@ -55,6 +55,7 @@ type TransactorIface interface {
|
|||
SendRawTransaction(chainID uint64, rawTx string) error
|
||||
BuildTransactionWithSignature(chainID uint64, args SendTxArgs, sig []byte) (*gethtypes.Transaction, error)
|
||||
SendTransactionWithSignature(from common.Address, symbol string, multiTransactionID wallet_common.MultiTransactionIDType, tx *gethtypes.Transaction) (hash types.Hash, err error)
|
||||
StoreAndTrackPendingTx(from common.Address, symbol string, chainID uint64, multiTransactionID wallet_common.MultiTransactionIDType, tx *gethtypes.Transaction) error
|
||||
}
|
||||
|
||||
// Transactor validates, signs transactions.
|
||||
|
@ -202,6 +203,15 @@ func createPendingTransaction(from common.Address, symbol string, chainID uint64
|
|||
return
|
||||
}
|
||||
|
||||
func (t *Transactor) StoreAndTrackPendingTx(from common.Address, symbol string, chainID uint64, multiTransactionID wallet_common.MultiTransactionIDType, tx *gethtypes.Transaction) error {
|
||||
if t.pendingTracker == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
pTx := createPendingTransaction(from, symbol, chainID, multiTransactionID, tx)
|
||||
return t.pendingTracker.StoreAndTrackPendingTx(pTx)
|
||||
}
|
||||
|
||||
func (t *Transactor) sendTransaction(rpcWrapper *rpcWrapper, from common.Address, symbol string,
|
||||
multiTransactionID wallet_common.MultiTransactionIDType, tx *gethtypes.Transaction) (hash types.Hash, err error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), t.rpcCallTimeout)
|
||||
|
@ -211,14 +221,9 @@ func (t *Transactor) sendTransaction(rpcWrapper *rpcWrapper, from common.Address
|
|||
return hash, err
|
||||
}
|
||||
|
||||
if t.pendingTracker != nil {
|
||||
|
||||
tx := createPendingTransaction(from, symbol, rpcWrapper.chainID, multiTransactionID, tx)
|
||||
|
||||
err := t.pendingTracker.StoreAndTrackPendingTx(tx)
|
||||
if err != nil {
|
||||
return hash, err
|
||||
}
|
||||
err = t.StoreAndTrackPendingTx(from, symbol, rpcWrapper.chainID, multiTransactionID, tx)
|
||||
if err != nil {
|
||||
return hash, err
|
||||
}
|
||||
|
||||
return types.Hash(tx.Hash()), nil
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/params"
|
||||
"github.com/status-im/status-go/rpc"
|
||||
wallet_common "github.com/status-im/status-go/services/wallet/common"
|
||||
"github.com/status-im/status-go/sqlite"
|
||||
"github.com/status-im/status-go/t/utils"
|
||||
"github.com/status-im/status-go/transactions/fake"
|
||||
|
@ -371,3 +372,11 @@ func (s *TransactorSuite) TestHashTransaction() {
|
|||
|
||||
s.NotEqual(common.Hash{}, hash)
|
||||
}
|
||||
|
||||
func (s *TransactorSuite) TestStoreAndTrackPendingTx() {
|
||||
s.Nil(s.manager.pendingTracker)
|
||||
|
||||
// Empty tracker doesn't produce error
|
||||
err := s.manager.StoreAndTrackPendingTx(common.Address{}, "", 0, wallet_common.MultiTransactionIDType(0), nil)
|
||||
s.NoError(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue