[BREAKING] - Create get token standard method / Standardize ERC721/1155/20 method names - #667
Conversation
5ac4d99 to
93fecae
Compare
|
Random ideas:
|
417171d to
8fd61c5
Compare
mcmire
left a comment
There was a problem hiding this comment.
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
76e1b9c to
f5ae2a9
Compare
f1825ad to
9591559
Compare
mcmire
left a comment
There was a problem hiding this comment.
Looks better, just a few suggestions.
9591559 to
3e48605
Compare
|
Can you add "[BREAKING]" to the title of the PR so it's easier to identify? |
mcmire
left a comment
There was a problem hiding this comment.
Did another pass and there were a few things I noticed.
| private web3: any; | ||
|
|
||
| constructor(web3?: any) { | ||
| this.web3 = web3; |
There was a problem hiding this comment.
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.
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.
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.
Can this be logged somewhere for tech debt purposes, though?
There was a problem hiding this comment.
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.
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.
@mcmire @gantunesr take a look and let me know what you think
|
LGTM. I'll wait for the other comments to be resolved before approving. |
8fe5ccc to
086ecdf
Compare
086ecdf to
c9abc81
Compare
|
Hey @adonesky1, I just noticed that you added the method |
You mean to the |
Yes |
CHANGED:
ADDED:
getTokenStandardAndDetailsto 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.