예제 #1
0
  txn Accounts 0
  itxn_field Receiver

  int 5
  itxn_field Amount

  txn Accounts 1
  itxn_field RekeyTo
 itxn_submit

end:
 int 1
"""

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)
예제 #2
0
txinfo, err = goal.send(goal.pay(goal.account, receiver=flo, amt=1500_000))
assert not err, err

# Freezing, and txgroup
assert not goal.holding(goal.account, gold)[1]
freeze1 = goal.afrz(flo, gold, goal.account, True)
freeze2 = goal.afrz(flo, gold, joe, True)
txinfo, err = goal.send_group([freeze1, freeze2])
assert not err, err
assert goal.holding(goal.account, gold)[1]
assert goal.holding(joe, gold)[1]

# App create
teal = "test/scripts/e2e_subs/tealprogs"
approval = goal.assemble(os.path.join(teal, "app-escrow.teal"))
yes = goal.assemble("#pragma version 2\nint 28")  # 28 is just to uniquify
create = goal.appl(flo, 0,
                   local_schema=(1, 0),
                   global_schema=(0, 4),
                   approval_program=approval,
                   clear_program=yes)
txinfo, err = goal.send(create)
app_id = txinfo['application-index']
assert app_id

# app_create is a convenience wrapper around appl
create = goal.app_create(flo, approval, local_schema=(1, 0))
txinfo, err = goal.send(create)
assert not err, err
예제 #3
0
 end:
  int 1
"""

app3 = """
#pragma version 6
pushbytes "success"
log
int 1
"""

goal.autosend = True

# app1 creation
txinfo1, err = goal.app_create(joe, goal.assemble(app1))
assert not err, err
app1ID = txinfo1['application-index']
assert app1ID

# insert clear state program with inner app call
txinfo2, err = goal.app_create(joe, goal.assemble(app2), goal.assemble(app2))
assert not err, err
app2ID = txinfo2['application-index']
assert app2ID

# dummy destination app
txinfo3, err = goal.app_create(joe, goal.assemble(app3))
assert not err, err
app3ID = txinfo3['application-index']
assert app3ID
예제 #4
0
  gtxns CreatedAssetID
  itxn_field Assets

  method "start(asset)"
  itxn_field ApplicationArgs

  byte 0x00
  itxn_field ApplicationArgs
 itxn_submit


end:
 int 1
"""

txinfo, err = goal.app_create(joe, goal.assemble(fund_previous))
assert not err, err
funder = txinfo['application-index']
assert funder

# Fund the funder
txinfo, err = goal.pay(goal.account, goal.app_address(funder), amt=4_000_000)
assert not err, err

# Construct a group that creates an ASA and an app, then "starts" the
# new app by funding and invoking "start(asset)" on it. Inside the new
# app's start() method, there will be yet another inner transaction:
# it opts into the supplied asset.

goal.autosend = False
create_asa = goal.asset_create(joe,
예제 #5
0
txinfo, err = goal.acfg(goal.account, index=assets["Silver"], send=True)
assert not err, err
expected_goal_mb -= ASSET_MIN_BALANCE
assert_min_balance(
    goal,
    goal.account,
    expected_goal_mb,
    expected_goal_mb + APP_MIN_BALANCE,
    goal_only=True,
)
expected_goal_mb += APP_MIN_BALANCE

# flo creates an app with 2 global schema ints, 10 global schema bytes, 1 extra page
txinfo, err = goal.app_create(
    flo,
    goal.assemble(TEAL),
    local_schema=(2, 0),
    global_schema=(0, 10),
    extra_pages=1,
    send=True,
)
assert not err, err
expected_mb = (
    CONSENSUS_MIN_BALANCE + APP_MIN_BALANCE
    # Not these local var requirements because not opting in
    # + 2 * APP_KV_MIN_BALANCE
    # + 2 * APP_INTS_MIN_BALANCE
    + 10 * APP_KV_MIN_BALANCE + 10 * APP_BYTES_MIN_BALANCE +
    EXTRA_PAGE_MIN_BALANCE)
expected_goal_mb += APP_MIN_BALANCE
assert_min_balance(goal, flo, expected_mb, expected_goal_mb)