Skip to content

Commit

Permalink
fix(code standards): a few wrongly formatted error objects (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Apr 15, 2024
1 parent 4e1d383 commit b4921cb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions da/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *DataAvailabilityLayerClient) submitBatchLoop(dataBlob []byte) da.Result
func (c *DataAvailabilityLayerClient) broadcastTx(tx []byte) (uint64, error) {
meta, err := c.client.GetMetadataLatest()
if err != nil {
return 0, fmt.Errorf("%s: %s", "failed to GetMetadataLatest", err)
return 0, fmt.Errorf("GetMetadataLatest: %w", err)
}
newCall, err := availtypes.NewCall(meta, DataCallSection+"."+DataCallMethod, availtypes.NewBytes(tx))
if err != nil {
Expand All @@ -320,11 +320,11 @@ func (c *DataAvailabilityLayerClient) broadcastTx(tx []byte) (uint64, error) {
ext := availtypes.NewExtrinsic(newCall)
genesisHash, err := c.client.GetBlockHash(0)
if err != nil {
return 0, fmt.Errorf("%s: %s", "failed to GetBlockHash", err)
return 0, fmt.Errorf("GetBlockHash: %w", err)
}
rv, err := c.client.GetRuntimeVersionLatest()
if err != nil {
return 0, fmt.Errorf("%s: %s", "failed to GetRuntimeVersionLatest", err)
return 0, fmt.Errorf("GetRuntimeVersionLatest: %w", err)
}
keyringPair, err := signature.KeyringPairFromSecret(c.config.Seed, keyringNetworkID)
if err != nil {
Expand All @@ -339,7 +339,7 @@ func (c *DataAvailabilityLayerClient) broadcastTx(tx []byte) (uint64, error) {
var accountInfo availtypes.AccountInfo
ok, err := c.client.GetStorageLatest(key, &accountInfo)
if err != nil || !ok {
return 0, fmt.Errorf("%s: %s", "failed to GetStorageLatest", err)
return 0, fmt.Errorf("GetStorageLatest: %w", err)
}

nonce := uint32(accountInfo.Nonce)
Expand Down Expand Up @@ -385,7 +385,7 @@ func (c *DataAvailabilityLayerClient) broadcastTx(tx []byte) (uint64, error) {
hash := status.AsFinalized
blockHeight, err := c.getHeightFromHash(hash)
if err != nil {
return 0, fmt.Errorf("%s: %s", "failed to getHeightFromHash", err)
return 0, fmt.Errorf("getHeightFromHash: %w", err)
}
return blockHeight, nil
} else if status.IsInBlock {
Expand All @@ -395,7 +395,7 @@ func (c *DataAvailabilityLayerClient) broadcastTx(tx []byte) (uint64, error) {
} else {
recievedStatus, err := status.MarshalJSON()
if err != nil {
return 0, fmt.Errorf("%s: %s", "failed to MarshalJSON of received status", err)
return 0, fmt.Errorf("MarshalJSON of received status: %w", err)
}
c.logger.Debug("unsupported status, still waiting for inclusion", "status", string(recievedStatus))
continue
Expand Down
2 changes: 1 addition & 1 deletion p2p/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func getAddr(sk crypto.PrivKey) (multiaddr.Multiaddr, error) {
copy(ip[net.IPv6len-len(suffix):], suffix)
a, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip6/%s/tcp/4242", ip))
if err != nil {
return nil, fmt.Errorf("create test multiaddr: %s", err)
return nil, fmt.Errorf("create test multiaddr: %w", err)
}
return a, nil
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (c *Client) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.Re
}, mempool.TxInfo{})
if err != nil {
c.Logger.Error("Error on broadcastTxCommit", "err", err)
return nil, fmt.Errorf("error on broadcastTxCommit: %v", err)
return nil, fmt.Errorf("error on broadcastTxCommit: %w", err)
}
select {
case <-ctx.Done():
Expand Down
2 changes: 1 addition & 1 deletion state/txindex/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (txi *TxIndex) Get(hash []byte) (*abci.TxResult, error) {
txResult := new(abci.TxResult)
err = proto.Unmarshal(rawBytes, txResult)
if err != nil {
return nil, fmt.Errorf("error reading TxResult: %v", err)
return nil, fmt.Errorf("error reading TxResult: %w", err)
}

return txResult, nil
Expand Down

0 comments on commit b4921cb

Please sign in to comment.