templates.fa2_lib_test_nft

  1import smartpy as sp
  2
  3from smartpy.templates import fa2_lib as fa2
  4from smartpy.templates import fa2_lib_testing as testing
  5
  6administrator = sp.test_account("Administrator")
  7alice = sp.test_account("Alice")
  8tok0_md = fa2.make_metadata(name="Token Zero", decimals=1, symbol="Tok0")
  9tok1_md = fa2.make_metadata(name="Token One", decimals=1, symbol="Tok1")
 10tok2_md = fa2.make_metadata(name="Token Two", decimals=1, symbol="Tok2")
 11TOKEN_METADATA = [tok0_md, tok1_md, tok2_md]
 12METADATA = sp.scenario_utils.metadata_of_url("ipfs://example")
 13
 14main = fa2.main
 15
 16
 17@sp.module
 18def m():
 19    # Order of inheritance: [Admin], [<policy>], <base class>, [<mixins>]
 20
 21    class NftTestFull(
 22        main.Admin,
 23        main.Nft,
 24        main.ChangeMetadata,
 25        main.WithdrawMutez,
 26        main.MintNft,
 27        main.BurnNft,
 28        main.OffchainviewTokenMetadata,
 29        main.OnchainviewBalanceOf,
 30    ):
 31        def __init__(self, administrator, metadata, ledger, token_metadata):
 32            main.OnchainviewBalanceOf.__init__(self)
 33            main.OffchainviewTokenMetadata.__init__(self)
 34            main.BurnNft.__init__(self)
 35            main.MintNft.__init__(self)
 36            main.WithdrawMutez.__init__(self)
 37            main.ChangeMetadata.__init__(self)
 38            main.Nft.__init__(self, metadata, ledger, token_metadata)
 39            main.Admin.__init__(self, administrator)
 40
 41    class NftTestNoTransfer(main.NoTransfer, main.Nft):
 42        def __init__(self, metadata, ledger, token_metadata):
 43            main.Nft.__init__(self, metadata, ledger, token_metadata)
 44            main.NoTransfer.__init__(self)
 45
 46    class NftTestOwnerTransfer(main.OwnerTransfer, main.Nft):
 47        def __init__(self, metadata, ledger, token_metadata):
 48            main.Nft.__init__(self, metadata, ledger, token_metadata)
 49            main.OwnerTransfer.__init__(self)
 50
 51    class NftTestPauseOwnerOrOperatorTransfer(
 52        main.Admin, main.PauseOwnerOrOperatorTransfer, main.Nft
 53    ):
 54        def __init__(self, administrator, metadata, ledger, token_metadata):
 55            main.Nft.__init__(self, metadata, ledger, token_metadata)
 56            main.PauseOwnerOrOperatorTransfer.__init__(self)
 57            main.Admin.__init__(self, administrator)
 58
 59
 60if "main" in __name__:
 61    ledger = {0: alice.address, 1: alice.address, 2: alice.address}
 62    token_metadata = TOKEN_METADATA
 63
 64    # Default NFT
 65    c1 = [
 66        m.NftTestFull,
 67        {
 68            "administrator": administrator.address,
 69            "metadata": METADATA,
 70            "ledger": ledger,
 71            "token_metadata": token_metadata,
 72        },
 73    ]
 74
 75    # No transfer
 76    c2 = [
 77        m.NftTestNoTransfer,
 78        {
 79            "metadata": METADATA,
 80            "ledger": ledger,
 81            "token_metadata": token_metadata,
 82        },
 83    ]
 84
 85    # Owner transfer
 86    c3 = [
 87        m.NftTestOwnerTransfer,
 88        {
 89            "metadata": METADATA,
 90            "ledger": ledger,
 91            "token_metadata": token_metadata,
 92        },
 93    ]
 94
 95    # Empty NFT
 96    c4 = [
 97        m.NftTestFull,
 98        {
 99            "administrator": administrator.address,
100            "metadata": METADATA,
101            "ledger": {},
102            "token_metadata": [],
103        },
104    ]
105
106    # Pause owner or operator transfer
107    c5 = [
108        m.NftTestPauseOwnerOrOperatorTransfer,
109        {
110            "administrator": administrator.address,
111            "metadata": METADATA,
112            "ledger": ledger,
113            "token_metadata": token_metadata,
114        },
115    ]
116
117    kwargs = {"modules": [fa2.t, fa2.main, m], "ledger_type": "NFT"}
118
119    # Standard features
120    testing.test_core_interfaces(*c1, **kwargs)
121    testing.test_transfer(*c1, **kwargs)
122    testing.test_balance_of(*c1, **kwargs)
123    # Policies
124    testing.test_owner_or_operator_transfer(*c1, **kwargs)
125    testing.test_no_transfer(*c2, **kwargs)
126    testing.test_owner_transfer(*c3, **kwargs)
127
128    # Non standard features
129    testing.NS.test_admin(*c1, **kwargs)
130    testing.NS.test_mint(*c4, **kwargs)
131    testing.NS.test_burn(*c1, supports_transfer=True, supports_operator=True, **kwargs)
132    testing.NS.test_withdraw_mutez(*c1, **kwargs)
133    testing.NS.test_change_metadata(*c1, **kwargs)
134    testing.NS.test_get_balance_of(*c1, **kwargs)
135    # Non standard policies
136    testing.NS.test_pause(*c5, **kwargs)
administrator = <smartpy.TestAccount object>
alice = <smartpy.TestAccount object>
tok0_md = (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 916) map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "decimals")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 918) literal (bytes "0x31"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "name")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 919) literal (bytes "0x546f6b656e205a65726f"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "symbol")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 920) literal (bytes "0x546f6b30"))))
tok1_md = (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 916) map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "decimals")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 918) literal (bytes "0x31"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "name")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 919) literal (bytes "0x546f6b656e204f6e65"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "symbol")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 920) literal (bytes "0x546f6b31"))))
tok2_md = (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 916) map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "decimals")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 918) literal (bytes "0x31"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "name")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 919) literal (bytes "0x546f6b656e2054776f"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "symbol")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 920) literal (bytes "0x546f6b32"))))
TOKEN_METADATA = [(("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 916) map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "decimals")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 918) literal (bytes "0x31"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "name")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 919) literal (bytes "0x546f6b656e205a65726f"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "symbol")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 920) literal (bytes "0x546f6b30")))), (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 916) map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "decimals")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 918) literal (bytes "0x31"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "name")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 919) literal (bytes "0x546f6b656e204f6e65"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "symbol")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 920) literal (bytes "0x546f6b31")))), (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 916) map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "decimals")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 918) literal (bytes "0x31"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "name")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 919) literal (bytes "0x546f6b656e2054776f"))) ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "symbol")) (("test-env/lib/python3.10/site-packages/smartpy/templates/fa2_lib.py" 920) literal (bytes "0x546f6b32"))))]
METADATA = (("templates/fa2_lib_test_nft.py" 12) big_map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "")) (("templates/fa2_lib_test_nft.py" 12) literal (bytes "0x697066733a2f2f6578616d706c65"))))
main = None