Skip to content

Commit

Permalink
fix: handling 0x prefix encoding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
praetoriansentry committed Dec 10, 2024
1 parent d4875fc commit 7319e96
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmd/ulxly/ulxly.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func bridgeAsset(cmd *cobra.Command) error {

value, _ := big.NewInt(0).SetString(amount, 0)
tokenAddress := common.HexToAddress(tokenAddr)
callData := common.Hex2Bytes(callDataString)
callData := common.Hex2Bytes(strings.TrimPrefix(callDataString, "0x"))

if tokenAddress == common.HexToAddress("0x0000000000000000000000000000000000000000") {
auth.Value = value
Expand Down Expand Up @@ -281,7 +281,7 @@ func bridgeMessage(cmd *cobra.Command) error {

value, _ := big.NewInt(0).SetString(amount, 0)
tokenAddress := common.HexToAddress(tokenAddr)
callData := common.Hex2Bytes(callDataString)
callData := common.Hex2Bytes(strings.TrimPrefix(callDataString, "0x"))

if tokenAddress == common.HexToAddress("0x0000000000000000000000000000000000000000") {
auth.Value = value
Expand Down Expand Up @@ -332,7 +332,7 @@ func bridgeWETHMessage(cmd *cobra.Command) error {
}

value, _ := big.NewInt(0).SetString(amount, 0)
callData := common.Hex2Bytes(callDataString)
callData := common.Hex2Bytes(strings.TrimPrefix(callDataString, "0x"))

bridgeTxn, err := bridgeV2.BridgeMessageWETH(auth, destinationNetwork, toAddress, value, isForced, callData)
if err != nil {
Expand Down Expand Up @@ -889,10 +889,20 @@ func getDeposit(bridgeServiceDepositsEndpoint string) (globalIndex *big.Int, ori
originAddress = common.HexToAddress(bridgeDeposit.Deposit.OrigAddr)
globalIndex.SetString(bridgeDeposit.Deposit.GlobalIndex, 10)
amount.SetString(bridgeDeposit.Deposit.Amount, 10)
metadata = common.Hex2Bytes(bridgeDeposit.Deposit.Metadata)

metadata = common.Hex2Bytes(strings.TrimPrefix(bridgeDeposit.Deposit.Metadata, "0x"))
leafType = bridgeDeposit.Deposit.LeafType
claimDestNetwork = bridgeDeposit.Deposit.DestNet
claimOriginalNetwork = bridgeDeposit.Deposit.OrigNet
log.Info().
Stringer("globalIndex", globalIndex).
Stringer("originAddress", originAddress).
Stringer("amount", amount).
Str("metadata", bridgeDeposit.Deposit.Metadata).
Uint8("leafType", leafType).
Uint32("claimDestNetwork", claimDestNetwork).
Uint32("claimOriginalNetwork", claimOriginalNetwork).
Msg("Got Deposit")
return globalIndex, originAddress, amount, metadata, leafType, claimDestNetwork, claimOriginalNetwork, nil
}

Expand Down

0 comments on commit 7319e96

Please sign in to comment.