Skip to content

MetaTransaction V2 Packages #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2023
Merged

Conversation

abls
Copy link
Contributor

@abls abls commented Apr 20, 2023

Description

Accompanying typescript utilities for #665

Testing instructions

cd packages/protocol-utils
yarn test --fgrep "mtxs v2"

@abls abls requested review from patrick-dowell and Haozhuo April 20, 2023 17:44
@abls abls requested review from dekz and dextracker as code owners April 20, 2023 17:44
@abls abls force-pushed the feat/MetaTransactionV2-packages branch from bc14382 to 48ba16a Compare April 20, 2023 19:20

it('can get the EIP712 hash', () => {
const actual = mtx.getHash();
const expected = '0xfc85ef2149bd49fcc8fee2571ed8f0ecd671dec03845637ab1ded3d891ac3386';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the original metatransaction v1 typescript tests, this is done by comparing mtx.getHash() to the MetaTransactionsFeatureContract getMetaTransactionHash() function. Not sure if that'd be valuable here, but I thought I'd share the code:

const mtx = getRandomMetaTransaction();
const expected = mtx.getHash();
const actual = await feature.getMetaTransactionHash(mtx).callAsync();
expect(actual).to.eq(expected);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is designed to test MetaTransactionsFeature's solidity mtx hash implementation using this package's implementation as a baseline. We shouldn't also circularly use that solidity code as the baseline for this test, because that makes it easier for both implementations to be wrong. The tests here use hashes generated by a third-party implementation as their baseline, just like the v1 package tests in meta_transactions_test.ts.

);
}

public getEIP712TypedData(): EIP712TypedData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can test this function for correctness?


it('can get the struct hash', () => {
const actual = mtx.getStructHash();
const expected = '0x57db4055edfed82a6d86103197c21390bf29412fb4585e08c708454e03d92516';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: how are the expected hash generated? If it's computed via ethers or solidity then we are good. Just want to make sure the expected hash is computed in a different method so that we can make sure our method implementation is correct. Same for other hashes in the test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's computed via ethers, so hopefully we are fine

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Yeah should be fine 👍

Copy link
Contributor

@patrick-dowell patrick-dowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@abls abls force-pushed the feat/MetaTransactionV2-packages branch from 48ba16a to 2338b28 Compare April 24, 2023 09:31
@abls abls merged commit a7acf29 into development Apr 24, 2023
@abls abls deleted the feat/MetaTransactionV2-packages branch April 24, 2023 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants