ethers/lib/utils#BytesLike TypeScript Examples
The following examples show how to use
ethers/lib/utils#BytesLike.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From hubble-contracts with MIT License | 7 votes |
export function computeRoot(
leafInput: BytesLike,
path: number,
witness: BytesLike[]
) {
let leaf = leafInput;
for (let i = 0; i < witness.length; i++) {
if (((path >> i) & 1) == 0) {
leaf = solidityKeccak256(
["bytes32", "bytes32"],
[leaf, witness[i]]
);
} else {
leaf = solidityKeccak256(
["bytes32", "bytes32"],
[witness[i], leaf]
);
}
}
return leaf;
}
Example #2
Source File: pubkey.ts From hubble-contracts with MIT License | 6 votes |
static fromEncoded(data: BytesLike): Pubkey {
const pubkeyDecoded = defaultAbiCoder.decode(solidityPubkeyType, data);
const pubkeySolG2: solG2 = [
pubkeyDecoded[0].toHexString(),
pubkeyDecoded[1].toHexString(),
pubkeyDecoded[2].toHexString(),
pubkeyDecoded[3].toHexString()
];
return new this(pubkeySolG2);
}
Example #3
Source File: state.ts From hubble-contracts with MIT License | 6 votes |
static fromEncoded(data: BytesLike): State {
const [
pubkeyID,
tokenID,
balance,
nonce
] = ethers.utils.defaultAbiCoder.decode(
["uint256", "uint256", "uint256", "uint256"],
data
);
return new this(pubkeyID, tokenID, balance, nonce);
}