Skip to content

Commit f993e3b

Browse files
committed
fix: small number parsing improvements
1 parent 05cb7e5 commit f993e3b

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

internal/xrp/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (c *xrpClient) GetLatestBlockInfo(ctx context.Context) (*indexer.BlockInfo,
122122
// GetBlockTimestamp returns the Unix close time of the ledger at blockNum.
123123
func (c *xrpClient) GetBlockTimestamp(ctx context.Context, blockNum uint64) (uint64, error) {
124124
getBlockParams := ledgerParams{
125-
LedgerIndex: strconv.Itoa(int(blockNum)),
125+
LedgerIndex: strconv.FormatUint(blockNum, 10),
126126
Transactions: false,
127127
Expand: false,
128128
OwnerFunds: false,
@@ -138,7 +138,7 @@ func (c *xrpClient) GetBlockTimestamp(ctx context.Context, blockNum uint64) (uin
138138
// GetBlockResult returns the block header and all transactions for the ledger at blockNum.
139139
func (c *xrpClient) GetBlockResult(ctx context.Context, blockNum uint64) (*indexer.BlockResult[*Block, Transaction, struct{}], error) {
140140
getBlockParams := ledgerParams{
141-
LedgerIndex: strconv.Itoa(int(blockNum)),
141+
LedgerIndex: strconv.FormatUint(blockNum, 10),
142142
Transactions: true,
143143
Expand: true,
144144
OwnerFunds: false,

internal/xrp/transaction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ func (tx *transaction) isNativePayment() (bool, error) {
8383
if err := json.Unmarshal(tx.Amount, &amountStr); err != nil {
8484
return false, fmt.Errorf("unmarshal amount string: %w", err)
8585
}
86-
_, err := strconv.Atoi(amountStr)
86+
87+
_, err := strconv.ParseUint(amountStr, 10, 64)
8788
return err == nil, nil
8889
}
8990

@@ -98,7 +99,7 @@ func (tx *transaction) isNativePayment() (bool, error) {
9899
// Destination address, or nil if no destination is set.
99100
func (tx *transaction) destinationAddressHash() *string {
100101
if len(tx.Destination) > 0 {
101-
hash := crypto.Keccak256Hash([]byte(tx.Destination)).Hex()[2:]
102+
hash := strings.ToLower(crypto.Keccak256Hash([]byte(tx.Destination)).Hex()[2:])
102103
return &hash
103104
}
104105

0 commit comments

Comments
 (0)