Skip to content

Commit

Permalink
fix: optionalMessage and optionalGas encoding (#536)
Browse files Browse the repository at this point in the history
## Description
`optionalGas` when set to 0 is not encoded by evm SDK. This PR fixes the
encoding issue

## Related Issue Or Context
#535 

Closes: #535 

## How Has This Been Tested? Testing details.
- [ ] Add encoding unit test 

## Types of changes
- [X] Bug fix (non-breaking change which fixes an issue)

## Checklist:
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [X] I have ensured that all acceptance criteria (or expected behavior)
from issue are met
- [X] I have updated the documentation locally and in chainbridge-docs.
- [X] I have added tests to cover my changes.
- [ ] I have ensured that all the checks are passing and green, I've
signed the CLA bot
  • Loading branch information
saadahmsiddiqui authored Sep 12, 2024
1 parent 48e84d5 commit ebc8885
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/evm/src/utils/assetTransferHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ export function createFungibleDepositData(depositParams: FungbileDepositParams):
const zeroPaddedAddrLen = hexZeroPad(addressLenInHex, HEX_PADDING);
let depositData = concat([zeroPaddedAmount, zeroPaddedAddrLen, recipientAddressSerialized]);

if (optionalGas) {
if (optionalMessage !== undefined && optionalGas !== undefined) {
const optionalGasInHex = BigNumber.from(optionalGas).toHexString();
const zeroPaddedOptionalGas = hexZeroPad(optionalGasInHex, HEX_PADDING);
depositData = concat([depositData, zeroPaddedOptionalGas]);
}

if (optionalMessage) {
const { transactionId, actions, receiver } = optionalMessage;
const abiCoder = new AbiCoder();

Expand Down

0 comments on commit ebc8885

Please sign in to comment.