Update docs

This commit is contained in:
github-actions
2025-04-22 16:39:54 +00:00
parent 0dda004024
commit da7fd0d3e5
230 changed files with 11375 additions and 1714 deletions

View File

@ -19,14 +19,16 @@ describe('MessageHashUtils', function () {
const message = ethers.randomBytes(32);
const expectedHash = ethers.hashMessage(message);
expect(await this.mock.getFunction('$toEthSignedMessageHash(bytes32)')(message)).to.equal(expectedHash);
await expect(this.mock.getFunction('$toEthSignedMessageHash(bytes32)')(message)).to.eventually.equal(
expectedHash,
);
});
it('prefixes dynamic length data correctly', async function () {
const message = ethers.randomBytes(128);
const expectedHash = ethers.hashMessage(message);
expect(await this.mock.getFunction('$toEthSignedMessageHash(bytes)')(message)).to.equal(expectedHash);
await expect(this.mock.getFunction('$toEthSignedMessageHash(bytes)')(message)).to.eventually.equal(expectedHash);
});
it('version match for bytes32', async function () {
@ -39,7 +41,20 @@ describe('MessageHashUtils', function () {
});
describe('toDataWithIntendedValidatorHash', function () {
it('returns the digest correctly', async function () {
it('returns the digest of `bytes32 messageHash` correctly', async function () {
const verifier = ethers.Wallet.createRandom().address;
const message = ethers.randomBytes(32);
const expectedHash = ethers.solidityPackedKeccak256(
['string', 'address', 'bytes32'],
['\x19\x00', verifier, message],
);
await expect(
this.mock.getFunction('$toDataWithIntendedValidatorHash(address,bytes32)')(verifier, message),
).to.eventually.equal(expectedHash);
});
it('returns the digest of `bytes memory message` correctly', async function () {
const verifier = ethers.Wallet.createRandom().address;
const message = ethers.randomBytes(128);
const expectedHash = ethers.solidityPackedKeccak256(
@ -47,7 +62,21 @@ describe('MessageHashUtils', function () {
['\x19\x00', verifier, message],
);
expect(await this.mock.$toDataWithIntendedValidatorHash(verifier, message)).to.equal(expectedHash);
await expect(
this.mock.getFunction('$toDataWithIntendedValidatorHash(address,bytes)')(verifier, message),
).to.eventually.equal(expectedHash);
});
it('version match for bytes32', async function () {
const verifier = ethers.Wallet.createRandom().address;
const message = ethers.randomBytes(32);
const fixed = await this.mock.getFunction('$toDataWithIntendedValidatorHash(address,bytes)')(verifier, message);
const dynamic = await this.mock.getFunction('$toDataWithIntendedValidatorHash(address,bytes32)')(
verifier,
message,
);
expect(fixed).to.equal(dynamic);
});
});
@ -62,7 +91,7 @@ describe('MessageHashUtils', function () {
const structhash = ethers.randomBytes(32);
const expectedHash = hashTypedData(domain, structhash);
expect(await this.mock.$toTypedDataHash(domainSeparator(domain), structhash)).to.equal(expectedHash);
await expect(this.mock.$toTypedDataHash(domainSeparator(domain), structhash)).to.eventually.equal(expectedHash);
});
});
});