TokenScript icon indicating copy to clipboard operation
TokenScript copied to clipboard

providing ownerAddress implicit attribute and 𝑛𝑜𝑡 providing ownerBalance

Open SmartLayer opened this issue 6 years ago • 3 comments

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:

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

  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 avatar May 21 '19 11:05 SmartLayer

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

  • ownerAddress

If the token is non-fungible, there are two implicit attribute

  • ownerAddress
  • tokenId

SmartLayer avatar May 21 '19 12:05 SmartLayer

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 avatar May 21 '19 13:05 SmartLayer

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)

SmartLayer avatar May 22 '19 04:05 SmartLayer