-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: fix decimals issue with l2 dest chains (#315) * chore: fix decimals issue with l2 dest chains chore: delete unused test * 0.16.0-alpha.1 * chore: improve convertTokenAmount impl * chore: refactor bignumber amount conversion --------- Co-authored-by: npty <[email protected]> * chore: fix commandId generation (#321) * chore: fix gas limit function doc (#316) * chore: fix gas limit function doc * chore: remove mantle * chore: fix commandId generation * chore: update comment * chore: remove unused var * chore: update testnet rpc * chore: bump axelar-cgp-solidity to 6.3.0 (#324) * chore: fix gas limit function doc (#316) * chore: fix gas limit function doc * chore: remove mantle * chore: change executeData type from `0x${string}` to `string` (#317) * chore: change executeData type from `0x${string}` to `string` * chore: fix build error * chore: fix testnet rpc * Update issue templates * chore: bump axelar-cgp-solidity to 6.3.0 --------- Co-authored-by: Canh Trinh <[email protected]> * 0.16.0 * chore: update changelog for 0.16.0 * chore: remove unused import * chore: update changelog date --------- Co-authored-by: Canh Trinh <[email protected]>
- Loading branch information
Showing
10 changed files
with
130 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
import { arrayify, keccak256 } from "ethers/lib/utils"; | ||
import { Environment } from "src/libs/types"; | ||
import { RPCInfoType } from "../constants/chain"; | ||
import { arrayify, concat, hexlify, hexZeroPad, keccak256 } from "ethers/lib/utils"; | ||
|
||
export const getCommandId = ( | ||
chainName: string, | ||
txHash: string, | ||
sourceEventIndex: number, | ||
environment: Environment, | ||
rpcInfo: RPCInfoType | ||
) => { | ||
const chainID: number = rpcInfo[environment].networkInfo[chainName.toLowerCase()]?.chainId; | ||
if (!chainID) return ""; | ||
const seiArr = arrayify(sourceEventIndex).reverse(); | ||
const txHashWithEventIndex = new Uint8Array([ | ||
...arrayify(txHash), | ||
...new Uint8Array(8).map((a, i) => seiArr[i] || a), | ||
]); | ||
const chainIdByteArray = arrayify(chainID); | ||
const dataToHash = new Uint8Array(txHashWithEventIndex.length + chainIdByteArray.length); | ||
dataToHash.set(txHashWithEventIndex, 0); | ||
dataToHash.set(chainIdByteArray, txHashWithEventIndex.length); | ||
return keccak256(dataToHash).slice(2); // remove 0x prefix | ||
const stringToCharcodeArray = (text: string) => Array.from(text, (char) => char.charCodeAt(0)); | ||
|
||
// This function is specifically designed for use with EVM-based chains. Its behavior may not be as expected if used with Cosmos-based chains or other types of chains. | ||
export const getCommandId = (messageId: string, sourceEventIndex: number, chainId: number) => { | ||
if (messageId.includes("-")) { | ||
return keccak256(concat([stringToCharcodeArray(messageId), hexlify(chainId)])); | ||
} else { | ||
return keccak256( | ||
concat([ | ||
messageId, | ||
arrayify(hexZeroPad(hexlify(sourceEventIndex), 8)).reverse(), | ||
hexlify(chainId), | ||
]) | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters