neo-mamba icon indicating copy to clipboard operation
neo-mamba copied to clipboard

wallet - token support

Open ixje opened this issue 3 years ago • 2 comments

from https://github.com/CityOfZion/neo-mamba/pull/80#issuecomment-828387475

    def token_add(self, token_hash: UInt160) -> bool:
        # true if added, false if already exists

    def token_delete(self, token_hash: UInt160) -> bool:
        # true if deleted, false if failed if not found

    def token_delete_by_name(self, token_name: str) -> bool:
        # true if deleted, false if e.g. not found

My current view is that a Wallet is merely as a container holding Accounts. Therefore adding these functions to account means an Account is associated with 0 or more tokens. There can be helpers for Wallet to aggregate balances of a certain token in all available accounts, but that is beyond the scope. The extra field of the Account can be used for storing the token hashes when exporting.

ixje avatar Jun 01 '21 12:06 ixje

The alternative is to add these functions to Wallet. The upside is that from a wallet you do a single import/add/delete. The downside is you're forced to use a Wallet and it has to search all accounts for balance every time, even though you might know certain accounts will never have any.

ixje avatar Jun 02 '21 07:06 ixje

How should the token_delete_by_name(self, token_name: str) method be implemented? Currently, the only way to add a token is using token_add(self, token_hash: UInt160).

luc10921 avatar Jul 06 '21 18:07 luc10921