SmartTokenLabs / TokenScript

TokenScript schema, specs and paper
http://tokenscript.org
MIT License
244 stars 71 forks source link

providing ownerAddress implicit attribute and 𝑛𝑜𝑡 providing ownerBalance #164

Open SmartLayer opened 5 years ago

SmartLayer commented 5 years ago

As per meeting note:

There are two opinions. Either we have three implicit attributes under a token:

---------------------------------------
- ownerAddress
- ownerBalance (or native or ether balance)
- tokenId
---------------------------------------

James Brown mentioned that walletBalance should be under window.ethereum. True.

you put the wallet balance under web3.eth (ethereum), which is actually quite good.

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:

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.

  1. adding ownerBalance in the current release alongside ownerAddress, which is what we agreed on the meeting.
  2. carefully modify the UI so that the xDIA to DAI Bridget action doesn't display the current balance.

Since we decided for 1) let's keep doing it. Just be careful that we are going to remove ownerBalance when we re-introduce window.web3 or window.ethereum.

I will close this issue when the API doc is updated to include the reference of ownerAddress but not ownerBalance and in June release the existing TokenScripts are updated to use window.web3 / window.ethereum to look up balance.

SmartLayer commented 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

SmartLayer commented 5 years ago

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).

SmartLayer commented 5 years ago

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)