-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
[BREAKING] - Create get token standard method / Standardize ERC721/1155/20 method names #667
Conversation
5ac4d99
to
93fecae
Compare
Random ideas:
|
417171d
to
8fd61c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of cleanup things and a question.
febe905
to
e3f606f
Compare
Another idea for the future: make the standard class extend a base standard class that has |
5ed0370
to
6f2e400
Compare
getERC721AssetName, | ||
getERC721AssetSymbol, | ||
getERC721TokenURI, | ||
getERC721OwnerOf, | ||
getERC1155BalanceOf, | ||
getERC1155TokenURI, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so much better 👌
76e1b9c
to
f5ae2a9
Compare
f1825ad
to
9591559
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, just a few suggestions.
src/assets/Standards/CollectibleStandards/ERC1155/ERC1155Standard.test.ts
Show resolved
Hide resolved
9591559
to
3e48605
Compare
Can you add "[BREAKING]" to the title of the PR so it's easier to identify? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did another pass and there were a few things I noticed.
src/assets/Standards/CollectibleStandards/ERC1155/ERC1155Standard.ts
Outdated
Show resolved
Hide resolved
private web3: any; | ||
|
||
constructor(web3?: any) { | ||
this.web3 = web3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a type for this instead of any
? And why is web3
optional? It seems that everything in this class relies on web3
being provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you @mcmire, but I think for this we have to upgrade the web3 dependence, which could be done in another PR. But I'm not against this if @adonesky1 wants to upgrade the module in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, does web3
provide types now? I agree that we probably wouldn't want to upgrade it in this PR, but I was thinking in the meantime we could give this property a type on the spot based on how we end up using it in this class. For instance:
type ERC1155ABI = ...;
type Address = `0x${string}`
type Contract = {
at: Address
}
type Web3 = {
eth: {
contract: (abi: ERC1155ABI): Contract
}
}
That said, I don't believe that abiERC1155
in @metamask/metamask-eth-abis
has the right type on it. My feeling is that all of the objects that that module exports should have as const
on them. Right now it's possible to pass an ABI that has the same shape but isn't exactly the ERC-1155 ABI. Maybe we could have a generic ABI type to get around this, but then we'd be repeating work that is probably elsewhere. So maybe this is fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be logged somewhere for tech debt purposes, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a good point, I think that could work in the meantime for this PR. For future development we should upgrade this module and use the types provided by web3
or start using the ethers
dependence. I remember that extension changed from web3
to ethers
, would be easier if we all use the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am definitely a fan of using ethers
. It feels a lot more maintained at this point and is fully typed, and I think we can avoid the pain that we've been experiencing with web3
. Of course that's a larger change but that'd be my recommendation for new code going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcmire @gantunesr take a look and let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
src/assets/Standards/CollectibleStandards/ERC721/ERC721Standard.ts
Outdated
Show resolved
Hide resolved
LGTM. I'll wait for the other comments to be resolved before approving. |
8fe5ccc
to
086ecdf
Compare
086ecdf
to
c9abc81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me! Thanks for enduring all of the feedback 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hey @adonesky1, I just noticed that you added the method |
You mean to the |
Yes |
…55/20 method names (#667) * add getTokenStandard method * standardize method name patterns * improve typing
…55/20 method names (#667) * add getTokenStandard method * standardize method name patterns * improve typing
CHANGED:
ADDED:
getTokenStandardAndDetails
to determine whether the input contract confirms to particular known token standard (ERC20, ERC721 or ERC1155) and return the detected standard along with some key values/details about that the contract that pertain to that standard. These additional details may include, in the case of an ERC721, for example, details about a specific tokenId within that contract, or, in the case of ERC20, the balance of the current user in the contract.