Skip to content

Commit

Permalink
update migrate script for zealy stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickwieth committed Jun 23, 2024
1 parent 3b9739f commit b7bc693
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 13 deletions.
56 changes: 43 additions & 13 deletions scripts/migrate_with_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))

gameserver_addr = ["cc1z94z55n2rr4rmjf4ea0m7ykgh9a8urwzrlsxt4", "cc1ch66e3f0szxy8q976rsq5y07esmgdqzj70dfpu"]
early_access_addr = ["cc14km80077s0hch3sh38wh2hfk7kxfau4456r3ej", "cc1tmhtms6ahkrxltx3hkmmf2dteqj4pv0thwhdxa"]
alpha_creator = "cc14km80077s0hch3sh38wh2hfk7kxfau4456r3ej"
del_cards = [] # [370, 346, 258]

file_path_old = args[1]
file_path_new = args[2]


# early access, boosterpacks, airdrop from zealy

airdrop_accs = []
boosterpack_accs = []
early_access_addr = ["cc14km80077s0hch3sh38wh2hfk7kxfau4456r3ej", "cc1tmhtms6ahkrxltx3hkmmf2dteqj4pv0thwhdxa"]
with open(os.path.join(__location__, "./zealy.tsv"), "r", encoding="utf8") as zealy_file:
tsv_reader = csv.DictReader(zealy_file, delimiter="\t")
for entry in tsv_reader:
airdrop_accs.append((entry["CCAddress"], entry["Airdrop"]))
boosterpack_accs.append([entry["CCAddress"], entry["BoosterPacks"]])
if entry["EarlyAccessToGame"] == "TRUE":
early_access_addr.append(entry["CCAddress"])

genesisAccs = []
# here we load the balances of addresses that start with balances on CC
with open(os.path.join(__location__, "./genesis_balances.tsv"), "r", encoding="utf8") as genesis_file:
Expand Down Expand Up @@ -81,12 +94,12 @@
params[param] = old_dict["app_state"]["cardchain"]["params"][param]
new_dict["app_state"]["cardchain"]["params"] = params

# set balanceAnchor, for alpha creator true, for all others false
for key in new_dict["app_state"]["cardchain"]["cardRecords"]:
if key["owner"] == alpha_creator:
key["balanceAnchor"] = True
else:
key["balanceAnchor"] = False
# set balanceAnchor, for alpha creator true, for all others false, deactivated because already fine for most cards
# for key in new_dict["app_state"]["cardchain"]["cardRecords"]:
# if key["owner"] == alpha_creator:
# key["balanceAnchor"] = True
# else:
# key["balanceAnchor"] = False

for idx, addr in enumerate(old_dict["app_state"]["cardchain"]["addresses"]):
# set reportmatches to true for gameserver addresses
Expand All @@ -100,17 +113,27 @@
new_dict["app_state"]["auth"]["accounts"].append(i)
break
# limit balances to 5k for all old accounts (genesis accs + alice and bob will have more)
for i in old_dict["app_state"]["bank"]["balances"]:
for i in old_dict["app_state"]["bank"]["balances"]:
if i["address"] == addr:
for idx, coin in enumerate(i["coins"]):
# adjust BPFs
if coin["denom"] == "ubpf":
# use flat value for all others (TODO ON LAUNCH THIS SHOULD BE 0)
i["coins"][idx]["amount"] = "5000000"
bpf = 0
# use real bpf value for genesisAddresses
for acc in genesisAccs:
if acc[0] == addr:
i["coins"][idx]["amount"] = str(int(acc[1]) * 1000000)
bpf += int(acc[1]) * 1000000
# zealy airdrop
for acc in airdrop_accs:
if acc[0] == addr:
bpf += int(acc[1]) * 1000000

# use flat value for all others (TODO ON LAUNCH THIS SHOULD BE 0)
if bpf < 5000000:
bpf = 5000000

i["coins"][idx]["amount"] = str(bpf)

# give bpf to alpha creator (jannik)
if addr == alpha_creator:
i["coins"][idx]["amount"] = "1000000000"
Expand All @@ -121,11 +144,18 @@
new_dict["app_state"]["bank"]["balances"].append(i)
break

# Remove deprecated voteRights from users
# Remove deprecated voteRights from users and more shenanigans like booster packs and early access
for addr, user in zip(new_dict["app_state"]["cardchain"]["addresses"], new_dict["app_state"]["cardchain"]["users"]):

if "voteRights" in user:
del user["voteRights"]
user["boosterPacks"] = [pack for pack in user["boosterPacks"] if pack["setId"] not in ["0", "2"]] # turn of later

for entry in boosterpack_accs:
if entry[0] == addr:
num_packs = int(entry[1])
for x in range(num_packs):
user["boosterPacks"].append({'dropRatiosPerPack': ['150', '50', '1'], 'raritiesPerPack': ['4', '2', '1'], 'setId': '1', 'timeStamp': '0'})

user["earlyAccess"] = user.get(
"earlyAccess",
{"active": False, "invitedUser": "", "invitedByUser": ""}
Expand Down
39 changes: 39 additions & 0 deletions scripts/zealy.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CCAddress EarlyAccessToGame BoosterPacks Airdrop
cc1xngsk4kdhhaev9mqezzpgqxejcus5xrk8486ay TRUE 2 150
cc1svkkpzsqs6h897emc2q2agnlf2c05a5wuxhtu6 TRUE 2 150
cc1yyc302aevlh8egsvy7fse22ssu3tp7dyuvalsu TRUE 2 150
cc18jd8x7wvewadpcgkhafy9x2vf9zupzdvcs5v0p TRUE 2 150
cc1f283sl8q27j45qskshrysy6n3m9t656ayfl5v5 TRUE 1 100
cc1pm0c5d2fjn9tvd7cpwc28t4xhjuqxvlreg2ml5 TRUE 1 100
cc1vsknh04kly7lntt8lt909qjwfsa7k7hhwn9rxz TRUE 1 100
cc12r9ftz68ze7c7s9ywewy8ug3harnfpy25auj8s TRUE 1 100
cc18htpt4u8ttyxwy090yxjaw27vq2qxfs7lng77d TRUE 1 50
cc1lp7kkawahs5779zqxm78u26x5nyxaddats3l0f TRUE 1 50
cc10vl2ma5mnsalf3nmq3a50njlcccdxzkthpyw6a TRUE 1 50
cc140zwm203xeu885hckvurz46mu00ugsk4cg6wnf TRUE 1 50
cc1q29qepu2ywsyjghg3vh9nljmkzc4mux2lnlcjz TRUE 1 50
cc1wjvl60fy6x39amqfyqnu607sn0f8998a0euvw8 TRUE 1 50
cc1fa3uq6t3stngjpzz8406ygl6jdvayk56j3kyu3 TRUE 1 50
cc1w86yyvxvdzdh2fl296g9v0mvwqdx66d0l0jr92 TRUE 1 50
cc1nvmkqttunypn96qk4yx4eyfepkfppxf7kzrrcc TRUE 1 50
cc13yxz7e07kllz9hzsghrutmvggem9m8xqfajyuh TRUE 1 50
cc1symmz8dn7usd5js5uddf4wfa0g4w3dt9pklnfu TRUE 1 50
cc1fys60cv37pkga725vctp7gekch5jc94w8xnme3 TRUE 1 50
cc1gpzff8zagwcauacgez9fehcwaveewlm2u96tnh TRUE 1 50
cc1szw62mcf646hzj60qxlrfsrx3j57wdz5yvgz7 TRUE 0 30
cc1pxwlx23n5taxttz6x8lkfl3nmvhkp3p77cfzyz TRUE 0 30
cc1nd40jtjv5w463jgl9g6cfpyd3y6aws644p6gjp TRUE 0 30
cc1mwqyt2f7u69wcv7gxspv9m4jlq29gdadyfww0d TRUE 0 30
cc1fgwaqndwpl2hmk6vv98vt07fkefvx46wtdkt2h TRUE 0 30
cc1dn50kpwc8vxajpllam4l62zk4g37x2m0c7qgs9 TRUE 0 20
cc15rhmyuqj2a3qtufcw7zk45wx9gvge07c8585ha TRUE 0 0
cc1rcxy6kk828m48utyyauxg29umxgn6s5pvn0674 TRUE 0 0
cc1cawrg807fk0esn3j8g7dlrraks7ffx9rfp07xy TRUE 0 0
cc1nd37jcen8j7q9kkaf7w852ew3wlmf3s0uxz8nj TRUE 0 0
cc14vsg3gz8q4yvmx3hnuqvh658z6vkyp3z3k03z5 TRUE 0 0
cc183ret5jld325hj0kpsm08wq9nu0nvfl6y3wspa TRUE 0 0
cc1has2wgz58xw0sfaa60z437dl3vs7u52gmury3y TRUE 0 0
cc1m9dwd037y7ma059xsnzwey92xk3v8jmy6lsuys TRUE 0 0
cc1484f0rayg6ackhjqtc786r96sd46fnwgyvgvsp TRUE 0 0
cc1x6ftcjwljlt7rh03j93wtzazqzqeqwc2tlzpas TRUE 0 0
cc12qv7fl840uekmvvxc745048p4ngrn2dyms8j5n TRUE 0 0

0 comments on commit b7bc693

Please sign in to comment.