templates.fa2_lib_test_single_asset
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 SingleAssetTestNoTransfer(main.NoTransfer, main.SingleAsset): 22 def __init__(self, metadata, ledger, token_metadata): 23 main.SingleAsset.__init__(self, metadata, ledger, token_metadata) 24 main.NoTransfer.__init__(self) 25 26 class SingleAssetTestOwnerTransfer(main.OwnerTransfer, main.SingleAsset): 27 def __init__(self, metadata, ledger, token_metadata): 28 main.SingleAsset.__init__(self, metadata, ledger, token_metadata) 29 main.OwnerTransfer.__init__(self) 30 31 class SingleAssetTestPauseOwnerOrOperatorTransfer( 32 main.Admin, main.PauseOwnerOrOperatorTransfer, main.SingleAsset 33 ): 34 def __init__(self, administrator, metadata, ledger, token_metadata): 35 main.SingleAsset.__init__(self, metadata, ledger, token_metadata) 36 main.PauseOwnerOrOperatorTransfer.__init__(self) 37 main.Admin.__init__(self, administrator) 38 39 class SingleAssetTestFull( 40 main.Admin, 41 main.SingleAsset, 42 main.ChangeMetadata, 43 main.WithdrawMutez, 44 main.MintSingleAsset, 45 main.BurnSingleAsset, 46 main.OffchainviewTokenMetadata, 47 main.OnchainviewBalanceOf, 48 ): 49 def __init__(self, administrator, metadata, ledger, token_metadata): 50 main.OnchainviewBalanceOf.__init__(self) 51 main.OffchainviewTokenMetadata.__init__(self) 52 main.BurnSingleAsset.__init__(self) 53 main.MintSingleAsset.__init__(self) 54 main.WithdrawMutez.__init__(self) 55 main.ChangeMetadata.__init__(self) 56 main.SingleAsset.__init__(self, metadata, ledger, token_metadata) 57 main.Admin.__init__(self, administrator) 58 59 60if "main" in __name__: 61 ledger = {alice.address: 42} 62 token_metadata = tok0_md 63 64 # Default SingleAsset 65 c1 = [ 66 m.SingleAssetTestFull, 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.SingleAssetTestNoTransfer, 78 { 79 "metadata": METADATA, 80 "ledger": ledger, 81 "token_metadata": token_metadata, 82 }, 83 ] 84 85 # Owner transfer 86 c3 = [ 87 m.SingleAssetTestOwnerTransfer, 88 { 89 "metadata": METADATA, 90 "ledger": ledger, 91 "token_metadata": token_metadata, 92 }, 93 ] 94 95 # Empty SingleAsset 96 c4 = [ 97 m.SingleAssetTestFull, 98 { 99 "administrator": administrator.address, 100 "metadata": METADATA, 101 "ledger": {}, 102 "token_metadata": token_metadata, 103 }, 104 ] 105 106 # Pause owner or operator transfer 107 c5 = [ 108 m.SingleAssetTestPauseOwnerOrOperatorTransfer, 109 { 110 "administrator": administrator.address, 111 "metadata": METADATA, 112 "ledger": ledger, 113 "token_metadata": token_metadata, 114 }, 115 ] 116 117 kwargs = { 118 "modules": [fa2.t, fa2.main, m], 119 "ledger_type": "SingleAsset", 120 } 121 122 # Standard features 123 testing.test_core_interfaces(*c1, **kwargs) 124 testing.test_transfer(*c1, **kwargs) 125 testing.test_balance_of(*c1, **kwargs) 126 # Policies 127 testing.test_owner_or_operator_transfer(*c1, **kwargs) 128 testing.test_no_transfer(*c2, **kwargs) 129 testing.test_owner_transfer(*c3, **kwargs) 130 131 # Non standard features 132 testing.NS.test_admin(*c1, **kwargs) 133 testing.NS.test_mint(*c4, **kwargs) 134 testing.NS.test_burn(*c1, supports_transfer=True, supports_operator=True, **kwargs) 135 testing.NS.test_withdraw_mutez(*c1, **kwargs) 136 testing.NS.test_change_metadata(*c1, **kwargs) 137 testing.NS.test_get_balance_of(*c1, **kwargs) 138 # Non standard policies 139 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_single_asset.py" 12) big_map ((("test-env/lib/python3.10/site-packages/pdoc/doc.py" 1110) literal (string "")) (("templates/fa2_lib_test_single_asset.py" 12) literal (bytes "0x697066733a2f2f6578616d706c65"))))
main =
None