buidl-labs / crypto-code-school-inside-tezos

Interactive Code School for onboarding newcomers to build DApps on Tezos using SmartPy
https://cryptocodeschool.in/tezos
MIT License
47 stars 20 forks source link

end of cryptowars chapter three: Crypto-primitives.sodium_hash: TypeError: Cannot read property 'from_hex' of undefined #339

Open michaelkernaghan opened 3 years ago

michaelkernaghan commented 3 years ago

The script I have for chapter four of crypto wars FA2 module shows no errors when you show the answer, but when you check it gives an error:

import smartpy as sp

Import FA2 template

FA2 = sp.import_script_from_url("https://smartpy.io/dev/templates/FA2.py")

Define Cryber_Token

class Cyber_Token(FA2.FA2): pass

@sp.add_test(name = "Fungible Token") def test(): scenario = sp.test_scenario()

admin = sp.test_account("Decentralized Dictator")
mark = sp.test_account("Mark")
elon = sp.test_account("tesla")

# Initialize Cyber_Token as cyber_token with single_asset = True
cyber_token = Cyber_Token(FA2.FA2_config(single_asset=True, assume_consecutive_token_ids = False), admin = admin.address, metadata = sp.big_map({"": sp.bytes_of_string("tezos-storage:content"),"content": sp.bytes_of_string("""{"name" : "Cyber Token"}""")}))
scenario += cyber_token
# mint 5 tokens to mark
scenario += cyber_token.mint(address = mark.address, 
                            amount = 5,
                            metadata= Cyber_Token.make_metadata(
                                decimals = 4,
                                name = "Crypto Bucks",
                                symbol = "CB"
                            ),
                            token_id= 0).run(sender = admin)
#mint 10 tokens to elon
scenario += cyber_token.mint(address = elon.address,
                            amount = 10,
                            metadata = Cyber_Token.make_metadata(
                                decimals = 4,
                                name = "Crypto Bucks",
                                symbol = "CB"
                            ),
                            token_id = 0).run(sender = admin)

#transfer 2 tokens from elon to mark.
scenario += cyber_token.transfer([
    cyber_token.batch_transfer.item(from_ = elon.address, 
        txs = [
            sp.record(amount = 2,
                to_ = mark.address,
                token_id = 0) 
        ])
    ]).run(sender = elon)

# create the FA2.View_consumer and add it to the scenario.
consumer = FA2.View_consumer(cyber_token)
scenario += consumer

def arguments_for_balance_of(receiver, reqs):
    return (sp.record(
        callback = sp.contract(
                FA2.Balance_of.response_type(),
                sp.contract_address(receiver),
                entry_point = "receive_balances").open_some(),
            requests = reqs))

# call the entry point balance_of to check elon's balance.
scenario += cyber_token.balance_of(arguments_for_balance_of(consumer, [
        sp.record(owner = elon.address, token_id = 0)
]))

The error is:

Error: Error in Scenario
Contract_id format error: (storage(record 710(last_sum(literal(intOrNat 0)710))(operator_support(literal(bool False)710)))storage_type(())messages((receive_balances True((set_type(params 719)(list(record((balance nat)(request(record((owner address)(token_id nat))(Some((owner)(token_id))))))(Some((request)(balance)))))720)(set(attr(data)last_sum 721)(literal(intOrNat 0)721)721)(forGroup resp(params 719)((set(attr(data)last_sum 721)(add(attr(data)last_sum 721)(attr(iter resp 722)balance 723)723)723))722)))(reinit True((set(attr(data)last_sum 721)(literal(intOrNat 0)715)715))))flags()globals()views()entry_points_layout()initial_metadata()balance())
Error Click on "Show Answer" for reference. Compiled Code

but there Is noting indicated in "Show Answer" as wrong