Skip to content

Commit 62cfb02

Browse files
committed
rm nominationController
1 parent 6cb38f1 commit 62cfb02

File tree

1 file changed

+2
-105
lines changed

1 file changed

+2
-105
lines changed

mytoncore/mytoncore.py

Lines changed: 2 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,48 +1363,10 @@ def GetMaxFactor(self):
13631363
return maxFactor
13641364
#end define
13651365

1366-
def GetNominationControllerLastSentStakeTime(self, addrB64):
1367-
cmd = f"runmethodfull {addrB64} all_data"
1368-
result = self.liteClient.Run(cmd)
1369-
buff = self.Result2List(result)
1370-
return buff[-1]
1371-
#end define
1372-
1373-
def IsNominationControllerReadyToStake(self, addrB64):
1374-
now = get_timestamp()
1375-
config15 = self.GetConfig15()
1376-
lastSentStakeTime = self.GetNominationControllerLastSentStakeTime(addrB64)
1377-
stakeFreezeDelay = config15["validatorsElectedFor"] + config15["stakeHeldFor"]
1378-
result = lastSentStakeTime + stakeFreezeDelay < now
1379-
return result
1380-
#end define
1381-
1382-
def IsNominationControllerReadyToVote(self, addrB64):
1383-
vwl = self.GetValidatorsWalletsList()
1384-
result = addrB64 in vwl
1385-
return result
1386-
#end define
1387-
1388-
def GetNominationController(self, mode):
1389-
self.local.AddLog("start GetNominationController function", "debug")
1390-
nominationControllerList = ["nomination_controller_001", "nomination_controller_002"]
1391-
for item in nominationControllerList:
1392-
wallet = self.GetLocalWallet(item)
1393-
if mode == "stake" and self.IsNominationControllerReadyToStake(wallet.addrB64):
1394-
return wallet
1395-
if mode == "vote" and self.IsNominationControllerReadyToVote(wallet.addrB64):
1396-
return wallet
1397-
raise Exception("Validator сontroller not found")
1398-
#end define
1399-
14001366
def GetValidatorWallet(self, mode="stake"):
14011367
self.local.add_log("start GetValidatorWallet function", "debug")
1402-
useNominationController = self.local.db.get("useNominationController")
1403-
if useNominationController is True:
1404-
wallet = self.GetNominationController(mode)
1405-
else:
1406-
walletName = self.local.db.get("validatorWalletName")
1407-
wallet = self.GetLocalWallet(walletName)
1368+
walletName = self.local.db.get("validatorWalletName")
1369+
wallet = self.GetLocalWallet(walletName)
14081370
return wallet
14091371
#end define
14101372

@@ -3421,71 +3383,6 @@ def DownloadContract(self, url, branch=None):
34213383
#end if
34223384
#end define
34233385

3424-
def CreateNominationController(self, name, nominatorAddr, **kwargs):
3425-
workchain = kwargs.get("workchain", -1)
3426-
subwalletDefault = 698983191 + workchain # 0x29A9A317 + workchain
3427-
subwallet = kwargs.get("subwallet", subwalletDefault)
3428-
rewardShare = kwargs.get("rewardShare", 0)
3429-
coverAbility = kwargs.get("coverAbility", 0)
3430-
self.local.AddLog("start CreateNominationController function", "debug")
3431-
walletPath = self.walletsDir + name
3432-
contractPath = self.contractsDir + "nomination-contract/"
3433-
if not os.path.isdir(contractPath):
3434-
self.DownloadContract("https://github.com/EmelyanenkoK/nomination-contract")
3435-
#end if
3436-
3437-
fiftScript = contractPath + "scripts/new-nomination-controller.fif"
3438-
args = [fiftScript, workchain, subwallet, nominatorAddr, rewardShare, coverAbility, walletPath]
3439-
result = self.fift.Run(args)
3440-
version = "v3r3"
3441-
wallet = self.GetLocalWallet(name, version)
3442-
self.SetWalletVersion(wallet.addrB64, version)
3443-
#end define
3444-
3445-
def DepositToNominationController(self, walletName, destAddr, amount):
3446-
wallet = self.GetLocalWallet(walletName)
3447-
bocPath = self.contractsDir + "nomination-contract/scripts/add-stake.boc"
3448-
resultFilePath = self.SignBocWithWallet(wallet, bocPath, destAddr, amount)
3449-
self.SendFile(resultFilePath, wallet)
3450-
#end define
3451-
3452-
def WithdrawFromNominationController(self, walletName, destAddr, amount):
3453-
wallet = self.GetLocalWallet(walletName)
3454-
fiftScript = self.contractsDir + "nomination-contract/scripts/request-stake.fif" # withdraw-stake.fif
3455-
bocPath = self.contractsDir + "nomination-contract/scripts/withdraw-stake"
3456-
args = [fiftScript, amount, bocPath]
3457-
result = self.fift.Run(args)
3458-
bocPath = parse(result, "Saved to file ", ")")
3459-
resultFilePath = self.SignBocWithWallet(wallet, bocPath, destAddr, 1)
3460-
self.SendFile(resultFilePath, wallet)
3461-
#end define
3462-
3463-
def SendRequestToNominationController(self, walletName, destAddr):
3464-
wallet = self.GetLocalWallet(walletName)
3465-
bocPath = self.contractsDir + "nomination-contract/scripts/elector-refund.boc"
3466-
resultFilePath = self.SignBocWithWallet(wallet, bocPath, destAddr, 1.5)
3467-
self.SendFile(resultFilePath, wallet)
3468-
#end define
3469-
3470-
def CreateRestrictedWallet(self, name, ownerAddr, **kwargs):
3471-
workchain = kwargs.get("workchain", 0)
3472-
subwalletDefault = 698983191 + workchain # 0x29A9A317 + workchain
3473-
subwallet = kwargs.get("subwallet", subwalletDefault)
3474-
self.local.AddLog("start CreateRestrictedWallet function", "debug")
3475-
walletPath = self.walletsDir + name
3476-
contractPath = self.contractsDir + "nomination-contract/"
3477-
if not os.path.isdir(contractPath):
3478-
self.DownloadContract("https://github.com/EmelyanenkoK/nomination-contract")
3479-
#end if
3480-
3481-
fiftScript = contractPath + "scripts/new-restricted-wallet.fif"
3482-
args = [fiftScript, workchain, subwallet, ownerAddr, walletPath]
3483-
result = self.fift.Run(args)
3484-
version = "v3r4"
3485-
wallet = self.GetLocalWallet(name, version)
3486-
self.SetWalletVersion(wallet.addrB64, version)
3487-
#end define
3488-
34893386
def CreatePool(self, poolName, validatorRewardSharePercent, maxNominatorsCount, minValidatorStake, minNominatorStake):
34903387
self.local.add_log("start CreatePool function", "debug")
34913388
validatorRewardShare = int(validatorRewardSharePercent * 100)

0 commit comments

Comments
 (0)