forked from kkrt-labs/kakarot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_kakarot.py
90 lines (77 loc) · 2.52 KB
/
deploy_kakarot.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
# %% Imports
import logging
from asyncio import run
from kakarot_scripts.constants import (
BLOCK_GAS_LIMIT,
COINBASE,
DECLARED_CONTRACTS,
ETH_TOKEN_ADDRESS,
EVM_ADDRESS,
NETWORK,
RPC_CLIENT,
)
from kakarot_scripts.utils.starknet import (
declare,
deploy,
dump_declarations,
dump_deployments,
get_declarations,
get_deployments,
get_starknet_account,
invoke,
)
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
# %% Main
async def main():
# %% Declarations
account = await get_starknet_account()
logger.info(f"ℹ️ Using account {hex(account.address)} as deployer")
class_hash = {
contract["contract_name"]: await declare(contract)
for contract in DECLARED_CONTRACTS
}
dump_declarations(class_hash)
# %% Deployments
class_hash = get_declarations()
deployments = get_deployments()
if deployments.get("kakarot") and not NETWORK["devnet"]:
logger.info("ℹ️ Kakarot already deployed, checking version.")
deployed_class_hash = await RPC_CLIENT.get_class_hash_at(
deployments["kakarot"]["address"]
)
if deployed_class_hash != class_hash["kakarot"]:
await invoke("kakarot", "upgrade", class_hash["kakarot"])
else:
logger.info("✅ Kakarot already up to date.")
else:
deployments["kakarot"] = await deploy(
"kakarot",
account.address, # owner
ETH_TOKEN_ADDRESS, # native_token_address_
class_hash["account_contract"], # account_contract_class_hash_
class_hash["uninitialized_account"], # uninitialized_account_class_hash_
class_hash["Cairo1Helpers"],
COINBASE,
BLOCK_GAS_LIMIT,
)
if NETWORK["devnet"]:
deployments["EVM"] = await deploy(
"EVM",
ETH_TOKEN_ADDRESS, # native_token_address_
class_hash["account_contract"], # account_contract_class_hash_
class_hash["uninitialized_account"], # uninitialized_account_class_hash_
class_hash["Cairo1Helpers"],
COINBASE,
BLOCK_GAS_LIMIT,
)
dump_deployments(deployments)
if EVM_ADDRESS:
logger.info(f"ℹ️ Found default EVM address {EVM_ADDRESS}")
from kakarot_scripts.utils.kakarot import get_eoa
amount = 0.02 if not NETWORK["devnet"] else 100
await get_eoa(amount=amount)
# %% Run
if __name__ == "__main__":
run(main())