Open SmartLayer opened 5 years ago
James -> walletBalance - if available - should be obtained in a fixed manner eg web3.wallet.walletBalance.
If the token is fungible, there is only one implicit attribute
If the token is non-fungible, there are two implicit attribute
Agree with the comment from James. @JamesSmartCell As per meeting discussion, native tokens don't have an implicit attribute for this iteration (until we can figure out the design for native tokens).
This issue will be closed when the tutorial and javascript api document is updated. Either @James-Sangalli or @hboon can do the task (I would too, given a bit of time)
As per meeting note:
James Brown mentioned that
walletBalance
should be underwindow.ethereum
. True.The attribute we used in the discussion for the Ethereum address that holds a token is called ownerAddress, not walletAddress. It sits under token object, not web3.eth. At the surface it is less clear than walletBalance, but think about user-case like OpenSEA (or our own magic-link preview web page), which renders the tokens that are not owned by the renderer (our own magic-link preview web page is in dmz, meaning it doesn't hold any keys, not to mention wallet), the word 'walletAddress' would be wrong. There are other cases:
You have a BookToken in your wallet which you borrowed from your friend. ownerAddress != walletAddress.
You are a book retailer and you are looking at the book tokens you sold today. You can see these book tokens but they are not yours (although they are created out of the transactions of yours.
However, we will not be providing a window.web3.eth or window.ethereum object in its entirety in May. So how do we proceed on?
There are 2 solutions.
ownerBalance
in the current release alongsideownerAddress
, which is what we agreed on the meeting.Since we decided for 1) let's keep doing it. Just be careful that we are going to remove
ownerBalance
when we re-introducewindow.web3
orwindow.ethereum
.I will close this issue when the API doc is updated to include the reference of
ownerAddress
but notownerBalance
and in June release the existing TokenScripts are updated to usewindow.web3
/window.ethereum
to look up balance.