chain network name display fixed
This commit is contained in:
@@ -28,16 +28,16 @@ func (d *Driver) Name() string {
|
||||
}
|
||||
|
||||
func (d *Driver) FormatAddress(address string) (string, error) {
|
||||
d.logger.Debug("format address", zap.String("address", address))
|
||||
d.logger.Debug("Format address", zap.String("address", address))
|
||||
normalized, err := normalizeAddress(address)
|
||||
if err != nil {
|
||||
d.logger.Warn("format address failed", zap.String("address", address), zap.Error(err))
|
||||
d.logger.Warn("Format address failed", zap.String("address", address), zap.Error(err))
|
||||
}
|
||||
return normalized, err
|
||||
}
|
||||
|
||||
func (d *Driver) NormalizeAddress(address string) (string, error) {
|
||||
d.logger.Debug("normalize address", zap.String("address", address))
|
||||
d.logger.Debug("Normalize address", zap.String("address", address))
|
||||
normalized, err := normalizeAddress(address)
|
||||
if err != nil {
|
||||
d.logger.Warn("normalize address failed", zap.String("address", address), zap.Error(err))
|
||||
@@ -49,16 +49,12 @@ func (d *Driver) Balance(ctx context.Context, deps driver.Deps, network shared.N
|
||||
if wallet == nil {
|
||||
return nil, merrors.InvalidArgument("wallet is required")
|
||||
}
|
||||
d.logger.Debug("balance request",
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("network", network.Name),
|
||||
)
|
||||
d.logger.Debug("Balance request", zap.String("wallet_ref", wallet.WalletRef), zap.String("network", network.Name))
|
||||
rpcAddr, err := rpcAddress(wallet.DepositAddress)
|
||||
if err != nil {
|
||||
d.logger.Warn("balance address conversion failed",
|
||||
d.logger.Warn("Balance address conversion failed", zap.Error(err),
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("address", wallet.DepositAddress),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
@@ -66,10 +62,9 @@ func (d *Driver) Balance(ctx context.Context, deps driver.Deps, network shared.N
|
||||
driverDeps.Logger = d.logger
|
||||
result, err := evm.Balance(ctx, driverDeps, network, wallet, rpcAddr)
|
||||
if err != nil {
|
||||
d.logger.Warn("balance failed",
|
||||
d.logger.Warn("Balance failed", zap.Error(err),
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else if result != nil {
|
||||
d.logger.Debug("balance result",
|
||||
@@ -86,26 +81,24 @@ func (d *Driver) EstimateFee(ctx context.Context, deps driver.Deps, network shar
|
||||
if wallet == nil {
|
||||
return nil, merrors.InvalidArgument("wallet is required")
|
||||
}
|
||||
d.logger.Debug("estimate fee request",
|
||||
d.logger.Debug("Estimate fee request",
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.String("destination", destination),
|
||||
)
|
||||
rpcFrom, err := rpcAddress(wallet.DepositAddress)
|
||||
if err != nil {
|
||||
d.logger.Warn("estimate fee address conversion failed",
|
||||
d.logger.Warn("Estimate fee address conversion failed", zap.Error(err),
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("address", wallet.DepositAddress),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
rpcTo, err := rpcAddress(destination)
|
||||
if err != nil {
|
||||
d.logger.Warn("estimate fee destination conversion failed",
|
||||
d.logger.Warn("Estimate fee destination conversion failed", zap.Error(err),
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("destination", destination),
|
||||
zap.Error(err),
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
@@ -113,13 +106,12 @@ func (d *Driver) EstimateFee(ctx context.Context, deps driver.Deps, network shar
|
||||
driverDeps.Logger = d.logger
|
||||
result, err := evm.EstimateFee(ctx, driverDeps, network, wallet, rpcFrom, rpcTo, amount)
|
||||
if err != nil {
|
||||
d.logger.Warn("estimate fee failed",
|
||||
d.logger.Warn("Estimate fee failed", zap.Error(err),
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else if result != nil {
|
||||
d.logger.Debug("estimate fee result",
|
||||
d.logger.Debug("Estimate fee result",
|
||||
zap.String("wallet_ref", wallet.WalletRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.String("amount", result.Amount),
|
||||
@@ -133,26 +125,24 @@ func (d *Driver) SubmitTransfer(ctx context.Context, deps driver.Deps, network s
|
||||
if source == nil {
|
||||
return "", merrors.InvalidArgument("source wallet is required")
|
||||
}
|
||||
d.logger.Debug("submit transfer request",
|
||||
d.logger.Debug("Submit transfer request",
|
||||
zap.String("transfer_ref", transfer.TransferRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.String("destination", destination),
|
||||
)
|
||||
rpcFrom, err := rpcAddress(source.DepositAddress)
|
||||
if err != nil {
|
||||
d.logger.Warn("submit transfer address conversion failed",
|
||||
d.logger.Warn("Submit transfer address conversion failed", zap.Error(err),
|
||||
zap.String("wallet_ref", source.WalletRef),
|
||||
zap.String("address", source.DepositAddress),
|
||||
zap.Error(err),
|
||||
)
|
||||
return "", err
|
||||
}
|
||||
rpcTo, err := rpcAddress(destination)
|
||||
if err != nil {
|
||||
d.logger.Warn("submit transfer destination conversion failed",
|
||||
d.logger.Warn("Submit transfer destination conversion failed", zap.Error(err),
|
||||
zap.String("transfer_ref", transfer.TransferRef),
|
||||
zap.String("destination", destination),
|
||||
zap.Error(err),
|
||||
)
|
||||
return "", err
|
||||
}
|
||||
@@ -160,13 +150,12 @@ func (d *Driver) SubmitTransfer(ctx context.Context, deps driver.Deps, network s
|
||||
driverDeps.Logger = d.logger
|
||||
txHash, err := evm.SubmitTransfer(ctx, driverDeps, network, transfer, source, rpcFrom, rpcTo)
|
||||
if err != nil {
|
||||
d.logger.Warn("submit transfer failed",
|
||||
d.logger.Warn("submit transfer failed", zap.Error(err),
|
||||
zap.String("transfer_ref", transfer.TransferRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else {
|
||||
d.logger.Debug("submit transfer result",
|
||||
d.logger.Debug("Submit transfer result",
|
||||
zap.String("transfer_ref", transfer.TransferRef),
|
||||
zap.String("network", network.Name),
|
||||
zap.String("tx_hash", txHash),
|
||||
@@ -176,7 +165,7 @@ func (d *Driver) SubmitTransfer(ctx context.Context, deps driver.Deps, network s
|
||||
}
|
||||
|
||||
func (d *Driver) AwaitConfirmation(ctx context.Context, deps driver.Deps, network shared.Network, txHash string) (*types.Receipt, error) {
|
||||
d.logger.Debug("await confirmation",
|
||||
d.logger.Debug("Awaiting confirmation",
|
||||
zap.String("tx_hash", txHash),
|
||||
zap.String("network", network.Name),
|
||||
)
|
||||
@@ -184,13 +173,12 @@ func (d *Driver) AwaitConfirmation(ctx context.Context, deps driver.Deps, networ
|
||||
driverDeps.Logger = d.logger
|
||||
receipt, err := evm.AwaitConfirmation(ctx, driverDeps, network, txHash)
|
||||
if err != nil {
|
||||
d.logger.Warn("await confirmation failed",
|
||||
d.logger.Warn("Awaiting of confirmation failed", zap.Error(err),
|
||||
zap.String("tx_hash", txHash),
|
||||
zap.String("network", network.Name),
|
||||
zap.Error(err),
|
||||
)
|
||||
} else if receipt != nil {
|
||||
d.logger.Debug("await confirmation result",
|
||||
d.logger.Debug("Await confirmation result",
|
||||
zap.String("tx_hash", txHash),
|
||||
zap.String("network", network.Name),
|
||||
zap.Uint64("block_number", receipt.BlockNumber.Uint64()),
|
||||
|
||||
@@ -180,9 +180,6 @@ func (l *loggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, erro
|
||||
}
|
||||
if resp.StatusCode >= 400 {
|
||||
l.logger.Warn("RPC response error", respFields...)
|
||||
} else {
|
||||
// Log response content so downstream parse failures can be inspected without debug logs.
|
||||
l.logger.Warn("RPC response", respFields...)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
||||
@@ -79,7 +79,7 @@ func toWallet(w *chainv1.ManagedWallet) wallet {
|
||||
token := ""
|
||||
contract := ""
|
||||
if asset != nil {
|
||||
chain = asset.GetChain().String()
|
||||
chain = chainNetworkValue(asset.GetChain())
|
||||
token = asset.GetTokenSymbol()
|
||||
contract = asset.GetContractAddress()
|
||||
}
|
||||
@@ -141,3 +141,15 @@ func tsToString(ts *timestamppb.Timestamp) string {
|
||||
}
|
||||
return ts.AsTime().UTC().Format(time.RFC3339)
|
||||
}
|
||||
|
||||
func chainNetworkValue(chain chainv1.ChainNetwork) string {
|
||||
name := chain.String()
|
||||
if !strings.HasPrefix(name, "CHAIN_NETWORK_") {
|
||||
return "unspecified"
|
||||
}
|
||||
trimmed := strings.TrimPrefix(name, "CHAIN_NETWORK_")
|
||||
if trimmed == "" {
|
||||
return "unspecified"
|
||||
}
|
||||
return strings.ToLower(trimmed)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user