コード例 #1
0
 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)
assert 1_000_000 - 1000 == goal.balance(app_account), goal.balance(app_account)
assert 0 == goal.balance(app_account, asa_id)
# Check min-balance on app account is right (base + 1 asa)
assert 200_000 == goal.min_balance(app_account), goal.min_balance(app_account)

# Ensure creator can send asa to app
txinfo, err = goal.axfer(joe, app_account, 10, asa_id)
assert not err, err
assert 10 == goal.balance(app_account, asa_id)

print(f"{os.path.basename(sys.argv[0])} OK {stamp}")
コード例 #2
0
tx = txinfo['txn']['txn']
assert tx['amt'] == 500_000
assert tx['fee'] == 1000
assert goal.balance(joe) == 500_000

# Asset creation
acfg = goal.acfg(joe,
                 total=10_000, unit_name='oz', asset_name='Gold',
                 freeze=flo)
txinfo, err = goal.send(acfg)
assert not err, err
gold = txinfo['asset-index']
assert goal.balance(joe, gold) == 10_000

# Asset transfer
axfer = goal.axfer(joe, goal.account, 50, gold)
txinfo, err = goal.send(axfer)
assert err
assert goal.balance(joe, gold) == 10_000

optin = goal.axfer(goal.account, goal.account, 0, gold)
txinfo, err = goal.send(optin)
assert not err, err

axfer = goal.axfer(joe, goal.account, 50, gold)
txinfo, err = goal.send(axfer)
assert not err, err
assert goal.balance(joe, gold) == 9_950
assert goal.balance(goal.account, gold) == 50

txinfo, err = goal.send(goal.pay(goal.account, receiver=flo, amt=1500_000))
コード例 #3
0
    )
    assets[asset] = txinfo["asset-index"]
    assert not err, err

expected_goal_mb += 2 * 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

# joe opts into Gold and Silver:
txinfo, err = goal.axfer(joe, joe, 0, assets["Gold"], send=True)
txinfo, err = goal.axfer(joe, joe, 0, assets["Silver"], send=True)
assert not err, err

expected_mb = CONSENSUS_MIN_BALANCE + 2 * ASSET_MIN_BALANCE
expected_goal_mb += APP_MIN_BALANCE
assert_min_balance(goal, joe, expected_mb, expected_goal_mb)

# next, destroy Gold and Silver
txinfo, err = goal.acfg(flo, index=assets["Gold"], send=True)
assert not err, err
expected_mb = CONSENSUS_MIN_BALANCE
expected_goal_mb += APP_MIN_BALANCE
assert_min_balance(goal, flo, expected_mb, expected_goal_mb)

txinfo, err = goal.acfg(goal.account, index=assets["Silver"], send=True)