21 lines
743 B
JavaScript
21 lines
743 B
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
/**
|
||
|
|
* Encode OMNLMirrorReceiver CCIP data field (v2 with merkleRoot).
|
||
|
|
* Usage: node encode-omnl-mirror-payload.mjs <version> <lineId0x> <R> <validUntil> <evidence0x> <merkleRoot0x>
|
||
|
|
*/
|
||
|
|
import { AbiCoder } from 'ethers';
|
||
|
|
|
||
|
|
const [, , v, lineId, R, validUntil, evHash, merkleRoot] = process.argv;
|
||
|
|
if (!merkleRoot) {
|
||
|
|
console.error(
|
||
|
|
'Usage: node encode-omnl-mirror-payload.mjs <version> <lineId0x> <R> <validUntil> <evidence0x> <merkleRoot0x>'
|
||
|
|
);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
const coder = AbiCoder.defaultAbiCoder();
|
||
|
|
const data = coder.encode(
|
||
|
|
['uint256', 'bytes32', 'uint256', 'uint256', 'bytes32', 'bytes32'],
|
||
|
|
[BigInt(v), lineId, BigInt(R), BigInt(validUntil), evHash, merkleRoot]
|
||
|
|
);
|
||
|
|
process.stdout.write(data + '\n');
|