btoi txnas Assets itxn_field XferAsset global CurrentApplicationAddress itxn_field AssetReceiver itxn_submit next0: end: int 1 """ create_app = goal.app_create(joe, goal.assemble(app_teal)) start_app = goal.app_call(joe, funder) [asa_info, app_info, start_info], err = goal.send_group([create_asa, create_app, start_app]) assert not err, err goal.autosend = True import json asa_id = asa_info['asset-index'] app_id = app_info['application-index'] assert asa_id + 1 == app_id app_account = logic.get_application_address(app_id) # Check balance on app account is right (1m - 1 optin fee)
""" txinfo, err = goal.app_create(joe, goal.assemble(teal)) assert not err, err joeb = joeb - 1000 app_id = txinfo['application-index'] assert app_id app_addr = goal.app_address(app_id) # flo rekeys her account to the app, app spends from it, then rekeys it back txinfo, err = goal.pay(flo, joe, amt=1, rekey_to=app_addr) assert not err, err assert goal.balance(joe) == joeb + 1, goal.balance(joe) # can no longer spend txinfo, err = goal.pay(flo, joe, amt=1) assert err assert goal.balance(joe) == joeb + 1, goal.balance(joe) txinfo, err = goal.app_call(joe, app_id, accounts=[flo]) assert not err, err joeb = joeb - 1000 assert goal.balance(joe) == joeb + 6, goal.balance(joe) # can spend again txinfo, err = goal.pay(flo, joe, amt=1) assert not err, err assert goal.balance(joe) == joeb + 7, goal.balance(joe) print(f"{os.path.basename(sys.argv[0])} OK {stamp}")
app3ID = txinfo3['application-index'] assert app3ID # fund app1 _, err = goal.pay(goal.account, goal.app_address(app1ID), amt=4_000_000) assert not err, err # fund app2 _, err = goal.pay(goal.account, goal.app_address(app2ID), amt=4_000_000) assert not err, err # execute c2c to opt app1 into app2 and verify that the response is structured as # expected for a successful execution of all 3 apps. txinfo, err = goal.app_call(joe, app1ID, app_args=[0x00], foreign_apps=[int(app2ID), int(app3ID)]) assert not err, err assert len(txinfo["inner-txns"]) == 1 assert len(txinfo["inner-txns"][0]["inner-txns"]) == 1 assert len(txinfo["inner-txns"][0]["inner-txns"][0]["logs"]) == 1 # execute c2c w/ CSP to opt app1 out of app2. Note that the CSP of app2 attempts # to issue an inner app call, which is not allowed. The expected behavior is for # the CSP to fail (so app3 won't be called) but for the Clear State operation to # succeed. txinfo, err = goal.app_call(joe, app1ID, app_args=[0x01], foreign_apps=[int(app2ID),