Repository navigation
Expand file tree
/
Copy pathupdate.py
More file actions
47 lines (36 loc) · 1.73 KB
/
Copy pathupdate.py
File metadata and controls
47 lines (36 loc) · 1.73 KB
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
import os
from neo_toolbox.create_update_invocation_file import create_update_invocation_file
from boa3.boa3 import Boa3
WALLET = 'odd'
CONTRACT = 'Diamond.NFT'
# ------------- ################################# ------------- #
# ------------- # # ------------- #
# ------------- # Do not edit under this line # ------------- #
# ------------- # # ------------- #
# ------------- ################################# ------------- #
contact_path = f'./contracts/{CONTRACT}.py'
compiled_contract = f'./contracts/{CONTRACT}.nef'
manifest_path = f'./contracts/{CONTRACT}.manifest.json'
contract_name = CONTRACT
deployed_contracts = os.popen('neoxp contract list').read()
deployed_contracts = deployed_contracts.split(')')
deployed_contracts = [x.strip() for x in deployed_contracts]
deployed_contracts = [x.split(' ')[0] for x in deployed_contracts]
Boa3.compile_and_save(contact_path)
invoke_file = create_update_invocation_file(contract_name, compiled_contract, manifest_path, 'update_sc')
with open('update.neo-invoke.json', 'w+', encoding='utf-8') as f:
f.write(invoke_file)
if contract_name not in deployed_contracts:
print('Deploying contract')
invoke_call = os.system(f'neoxp contract deploy {compiled_contract} {WALLET}')
if int(invoke_call) == 1:
print('Error in deploy')
if int(invoke_call) == 0:
print('Deployed successfully')
if contract_name in deployed_contracts:
print('Updating contract')
invoke_call = os.system(f'neoxp contract invoke update.neo-invoke.json {WALLET}')
if int(invoke_call) == 1:
print('Error in update')
if int(invoke_call) == 0:
print('Updated successfully')