Merge pull request 'fixed balance fetch' (#428) from tron-428 into main
Reviewed-on: #428
This commit was merged in pull request #428.
This commit is contained in:
@@ -155,7 +155,11 @@ func Balance(ctx context.Context, deps driver.Deps, network shared.Network, wall
|
|||||||
return nil, merrors.Internal("network rpc url is not configured")
|
return nil, merrors.Internal("network rpc url is not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
contract := strings.TrimSpace(wallet.ContractAddress)
|
contract, err := tronBase58ToHex(strings.TrimSpace(wallet.ContractAddress))
|
||||||
|
if err != nil {
|
||||||
|
logger.Warn("Failed to convert contract address", zap.String("contract_address", wallet.ContractAddress))
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if contract == "" {
|
if contract == "" {
|
||||||
logger.Debug("Native balance requested", logFields...)
|
logger.Debug("Native balance requested", logFields...)
|
||||||
return NativeBalance(ctx, deps, network, wallet, normalizedAddress)
|
return NativeBalance(ctx, deps, network, wallet, normalizedAddress)
|
||||||
|
|||||||
@@ -200,12 +200,11 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
|
|||||||
query = query.And(endpointFilter)
|
query = query.And(endpointFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ref := strings.TrimSpace(filter.OrganizationRef); ref != "" {
|
if orgRef, err := bson.ObjectIDFromHex(strings.TrimSpace(filter.OrganizationRef)); err != nil {
|
||||||
orgRef, err := bson.ObjectIDFromHex(ref)
|
p.logger.Warn("Failed to decode organization reference", zap.Error(err),
|
||||||
if err != nil {
|
zap.String("provided_org_ref", filter.OrganizationRef))
|
||||||
p.logger.Warn("Failed to decode organization reference", zap.Error(err), zap.String("provided_org_ref", ref))
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
} else {
|
||||||
query.And(repository.OrgFilter(orgRef))
|
query.And(repository.OrgFilter(orgRef))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +230,7 @@ func (p *Payments) List(ctx context.Context, filter *model.PaymentFilter) (*mode
|
|||||||
decoder := func(cur *mongo.Cursor) error {
|
decoder := func(cur *mongo.Cursor) error {
|
||||||
item := &model.Payment{}
|
item := &model.Payment{}
|
||||||
if err := cur.Decode(item); err != nil {
|
if err := cur.Decode(item); err != nil {
|
||||||
p.logger.Warn("Failed to decode item", zap.Error(err), zap.Any("item", cur.Current))
|
p.logger.Warn("Failed to decode item", zap.Error(err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
payments = append(payments, item)
|
payments = append(payments, item)
|
||||||
|
|||||||
Reference in New Issue
Block a user