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