feat: make activity check optional

This commit is contained in:
Anthony Laibe 2023-07-25 10:48:03 +02:00 committed by Anthony Laibe
parent 20bc27619b
commit e5ce2c7c03
1 changed files with 13 additions and 13 deletions

View File

@ -471,28 +471,28 @@ func (api *API) AddressExists(ctx context.Context, address types.Address) (bool,
// Returns details for the passed address (response doesn't include derivation path) // Returns details for the passed address (response doesn't include derivation path)
func (api *API) GetAddressDetails(ctx context.Context, chainID uint64, address string) (*DerivedAddress, error) { func (api *API) GetAddressDetails(ctx context.Context, chainID uint64, address string) (*DerivedAddress, error) {
commonAddr := common.HexToAddress(address) result := &DerivedAddress{
addressExists, err := api.s.accountsDB.AddressExists(types.Address(commonAddr)) Address: common.HexToAddress(address),
if err != nil {
return nil, err
} }
addressExists, err := api.s.accountsDB.AddressExists(types.Address(result.Address))
if err != nil {
return result, err
}
result.AlreadyCreated = addressExists
chainClient, err := api.s.rpcClient.EthClient(chainID) chainClient, err := api.s.rpcClient.EthClient(chainID)
if err != nil { if err != nil {
return nil, err return result, err
} }
balance, err := api.s.tokenManager.GetChainBalance(ctx, chainClient, commonAddr) balance, err := api.s.tokenManager.GetChainBalance(ctx, chainClient, result.Address)
if err != nil { if err != nil {
return nil, err return result, err
} }
return &DerivedAddress{ result.HasActivity = balance.Cmp(big.NewInt(0)) != 0
Address: commonAddr, return result, nil
Path: "",
AlreadyCreated: addressExists,
HasActivity: balance.Cmp(big.NewInt(0)) != 0,
}, nil
} }
func (api *API) CreateMultiTransaction(ctx context.Context, multiTransactionCommand *transfer.MultiTransactionCommand, data []*bridge.TransactionBridge, password string) (*transfer.MultiTransactionCommandResult, error) { func (api *API) CreateMultiTransaction(ctx context.Context, multiTransactionCommand *transfer.MultiTransactionCommand, data []*bridge.TransactionBridge, password string) (*transfer.MultiTransactionCommandResult, error) {