Skip to content

Commit 140b3a6

Browse files
committed
add vote_offer_btc_teleport
1 parent 806c7e6 commit 140b3a6

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

modules/btc_teleport.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
class BtcTeleportModule(MtcModule):
1111

12+
COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo'
13+
CONFIGURATOR_ADDRESS = 'kQBV_cc8tD2lr2oogPOp1VCyP5m1xzdAZ77H3oM_Tix60dPP'
14+
1215
def __init__(self, ton, local, *args, **kwargs):
1316
super().__init__(ton, local, *args, **kwargs)
1417
self.keystore_path = self.ton.local.buffer.my_work_dir + '/btc_oracle_keystore'
@@ -36,7 +39,7 @@ def create_env_file(self, reinit=False):
3639
self.local.add_log(warning_text, 'warning')
3740
text = f"""
3841
COMMON_TON_CONFIG={config_path}
39-
COMMON_TON_CONTRACT_COORDINATOR=EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo
42+
COMMON_TON_CONTRACT_COORDINATOR={self.COORDINATOR_ADDRESS}
4043
ORACLE_STANDALONE_MODE=false
4144
ORACLE_KEYSTORE_PATH={self.keystore_path}
4245
ORACLE_VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath}

modules/validator.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ def vote_offer(self, args):
2020
self.ton.VoteOffer(offerHash)
2121
color_print("VoteOffer - {green}OK{endc}")
2222

23+
def vote_offer_btc_teleport(self, args):
24+
if len(args) == 0:
25+
color_print("{red}Bad args. Usage:{endc} vote_offer_btc_teleport <offer-hash> [offer-hash-2 offer-hash-3 ...]")
26+
return
27+
from modules.btc_teleport import BtcTeleportModule
28+
coordinator_addr = BtcTeleportModule.CONFIGURATOR_ADDRESS
29+
wallet = self.ton.GetValidatorWallet(mode="vote")
30+
validator_key = self.ton.GetValidatorKey()
31+
validator_pubkey_b64 = self.ton.GetPubKeyBase64(validator_key)
32+
validator_index = self.ton.GetValidatorIndex()
33+
for offer_hash in args:
34+
# offer = self.GetOffer(offerHash)
35+
# if validatorIndex in offer.get("votedValidators"):
36+
# self.local.add_log("Proposal already has been voted", "debug")
37+
# return
38+
request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index)
39+
validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash)
40+
path = self.ton.SignProposalVoteRequestWithValidator(offer_hash, validator_index, validator_pubkey_b64,
41+
validator_signature)
42+
path = self.ton.SignBocWithWallet(wallet, path, coordinator_addr, 1.5)
43+
self.ton.SendFile(path, wallet)
44+
2345
def vote_election_entry(self, args):
2446
from mytoncore.functions import Elections
2547
Elections(self.ton.local, self.ton)
@@ -104,6 +126,7 @@ def get_my_complaint(self):
104126

105127
def add_console_commands(self, console):
106128
console.AddItem("vo", self.vote_offer, self.local.translate("vo_cmd"))
129+
console.AddItem("vote_offer_btc_teleport", self.vote_offer_btc_teleport, self.local.translate("vote_offer_btc_teleport_cmd"))
107130
console.AddItem("ve", self.vote_election_entry, self.local.translate("ve_cmd"))
108131
console.AddItem("vc", self.vote_complaint, self.local.translate("vc_cmd"))
109132
console.AddItem("check_ef", self.check_efficiency, self.local.translate("check_ef_cmd"))

mytonctrl/resources/translate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@
139139
"ru": "Голосовать за предложение",
140140
"zh_TW": "投票支持優惠"
141141
},
142+
"vote_offer_btc_teleport_cmd": {
143+
"en": "Vote for BTC teleport offer",
144+
"ru": "Голосовать за предложение BTC Teleport",
145+
"zh_TW": "投票支持 BTC Teleport 優惠"
146+
},
142147
"od_cmd": {
143148
"en": "Show offer diff",
144149
"ru": "Показать разницу предложений",

0 commit comments

Comments
 (0)