-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathico.py
executable file
·97 lines (69 loc) · 2.54 KB
/
ico.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""
Spotcoin ICO
"""
from spot.txio import get_asset_attachments
from spot.token import *
from spot.tokensale import *
from spot.nep5 import *
from boa.interop.Neo.Runtime import GetTrigger, CheckWitness
from boa.interop.Neo.TriggerType import Application, Verification
from boa.interop.Neo.Storage import *
ctx = GetContext()
NEP5_METHODS = ['name', 'symbol', 'decimals', 'totalSupply', 'balanceOf', 'transfer', 'transferFrom', 'approve', 'allowance']
def Main(operation, args):
trigger = GetTrigger()
if trigger == Verification():
is_owner = CheckWitness(TOKEN_OWNER)
if is_owner:
return True
# Seems cleaner making it explicit
attachments = get_asset_attachments()
sender_addr = attachments[1]
sent_amount_neo = attachments[2]
sent_amount_gas = attachments[3]
return can_exchange(ctx, sender_addr, sent_amount_neo, sent_amount_gas, True)
elif trigger == Application():
for op in NEP5_METHODS:
if operation == op:
return handle_nep51(ctx, operation, args)
if operation == 'deploy':
return deploy()
if operation == 'circulation':
return get_circulation(ctx)
if operation == 'mintTokens':
return perform_exchange(ctx)
if operation == 'tokensale_register':
return register_address(ctx, args)
if operation == 'tokensale_status':
return status_address(ctx, args)
if operation == 'tokensale_available':
return public_sale_available(ctx)
if operation == 'get_attachments':
return get_asset_attachments()
if operation == 'airdrop':
return reserve_tokens(ctx, args)
if operation == 'tokens_sold':
return tokens_sold(ctx)
if operation == 'reached_softcap':
return reached_softcap(ctx)
if operation == 'mint_team':
return mint_team(ctx)
if operation == 'pause_sale':
return pause_sale(ctx)
if operation == 'resume_sale':
return resume_sale(ctx)
return 'unknown operation'
return False
def deploy():
if not CheckWitness(TOKEN_OWNER):
print("You are not asset owner!")
return False
# Can only deploy once
if not Get(ctx, 'initialized'):
Put(ctx, 'initialized', 1)
# Set to zero
Put(ctx, TOKEN_IN_CIRCULATION_KEY, 0)
Put(ctx, ICO_TOKEN_SOLD_KEY, 0)
return True
print("Contract already deployed!")
return False