olas-operate-middleware 0.13.2__py3-none-any.whl → 0.13.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.4.dist-info}/METADATA +8 -27
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.4.dist-info}/RECORD +40 -40
- operate/bridge/providers/provider.py +23 -31
- operate/cli.py +4 -17
- operate/constants.py +1 -0
- operate/data/contracts/dual_staking_token/contract.py +3 -3
- operate/data/contracts/dual_staking_token/contract.yaml +2 -2
- operate/data/contracts/foreign_omnibridge/contract.yaml +1 -1
- operate/data/contracts/home_omnibridge/contract.py +2 -2
- operate/data/contracts/home_omnibridge/contract.yaml +2 -2
- operate/data/contracts/l1_standard_bridge/contract.yaml +1 -1
- operate/data/contracts/l2_standard_bridge/contract.py +4 -4
- operate/data/contracts/l2_standard_bridge/contract.yaml +2 -2
- operate/data/contracts/mech_activity/contract.yaml +1 -1
- operate/data/contracts/optimism_mintable_erc20/contract.yaml +1 -1
- operate/data/contracts/recovery_module/contract.yaml +1 -1
- operate/data/contracts/requester_activity_checker/contract.yaml +1 -1
- operate/data/contracts/staking_token/contract.py +3 -3
- operate/data/contracts/staking_token/contract.yaml +2 -2
- operate/data/contracts/uniswap_v2_erc20/contract.yaml +3 -3
- operate/data/contracts/uniswap_v2_erc20/tests/test_contract.py +5 -5
- operate/keys.py +5 -3
- operate/ledger/__init__.py +1 -7
- operate/ledger/profiles.py +0 -1
- operate/operate_http/__init__.py +0 -2
- operate/operate_types.py +3 -93
- operate/quickstart/run_service.py +63 -6
- operate/quickstart/utils.py +8 -4
- operate/resource.py +2 -2
- operate/services/agent_runner.py +3 -3
- operate/services/manage.py +14 -17
- operate/services/protocol.py +124 -169
- operate/services/utils/mech.py +3 -3
- operate/services/utils/tendermint.py +5 -3
- operate/utils/gnosis.py +76 -101
- operate/wallet/master.py +42 -47
- operate/wallet/wallet_recovery_manager.py +8 -6
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.4.dist-info}/WHEEL +0 -0
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.4.dist-info}/entry_points.txt +0 -0
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.4.dist-info}/licenses/LICENSE +0 -0
operate/services/protocol.py
CHANGED
|
@@ -58,6 +58,7 @@ from autonomy.cli.helpers.chain import ServiceHelper as ServiceManager
|
|
|
58
58
|
from eth_utils import to_bytes
|
|
59
59
|
from hexbytes import HexBytes
|
|
60
60
|
from web3.contract import Contract
|
|
61
|
+
from web3.types import TxReceipt
|
|
61
62
|
|
|
62
63
|
from operate.constants import (
|
|
63
64
|
NO_STAKING_PROGRAM_ID,
|
|
@@ -121,9 +122,7 @@ class GnosisSafeTransaction:
|
|
|
121
122
|
self._txs.append(tx)
|
|
122
123
|
return self
|
|
123
124
|
|
|
124
|
-
def build(
|
|
125
|
-
self, *args: t.Any, **kwargs: t.Any
|
|
126
|
-
) -> t.Dict:
|
|
125
|
+
def build(self) -> t.Dict:
|
|
127
126
|
"""Build the transaction."""
|
|
128
127
|
multisend_data = bytes.fromhex(
|
|
129
128
|
registry_contracts.multisend.get_tx_data(
|
|
@@ -175,22 +174,21 @@ class GnosisSafeTransaction:
|
|
|
175
174
|
update_tx_with_gas_estimate(tx, self.ledger_api)
|
|
176
175
|
return t.cast(t.Dict, tx)
|
|
177
176
|
|
|
178
|
-
def settle(self) ->
|
|
177
|
+
def settle(self) -> TxReceipt:
|
|
179
178
|
"""Settle the transaction."""
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
dry_run=False,
|
|
179
|
+
return (
|
|
180
|
+
TxSettler(
|
|
181
|
+
ledger_api=self.ledger_api,
|
|
182
|
+
crypto=self.crypto,
|
|
183
|
+
chain_type=self.chain_type,
|
|
184
|
+
tx_builder=self.build,
|
|
185
|
+
timeout=ON_CHAIN_INTERACT_TIMEOUT,
|
|
186
|
+
retries=ON_CHAIN_INTERACT_RETRIES,
|
|
187
|
+
sleep=ON_CHAIN_INTERACT_SLEEP,
|
|
188
|
+
)
|
|
189
|
+
.transact()
|
|
190
|
+
.settle()
|
|
191
|
+
.tx_receipt
|
|
194
192
|
)
|
|
195
193
|
|
|
196
194
|
|
|
@@ -401,7 +399,7 @@ class StakingManager:
|
|
|
401
399
|
staking_contract: str,
|
|
402
400
|
key: Path,
|
|
403
401
|
password: str,
|
|
404
|
-
) ->
|
|
402
|
+
) -> str:
|
|
405
403
|
"""Stake the service"""
|
|
406
404
|
och = OnChainHelper(
|
|
407
405
|
key=key, chain_type=ChainType(self.chain.value), password=password
|
|
@@ -411,62 +409,52 @@ class StakingManager:
|
|
|
411
409
|
service_id=service_id, staking_contract=staking_contract
|
|
412
410
|
)
|
|
413
411
|
|
|
414
|
-
tx_settler = TxSettler(
|
|
415
|
-
ledger_api=och.ledger_api,
|
|
416
|
-
crypto=och.crypto,
|
|
417
|
-
chain_type=och.chain_type,
|
|
418
|
-
timeout=ON_CHAIN_INTERACT_TIMEOUT,
|
|
419
|
-
retries=ON_CHAIN_INTERACT_RETRIES,
|
|
420
|
-
sleep=ON_CHAIN_INTERACT_SLEEP,
|
|
421
|
-
)
|
|
422
|
-
|
|
423
412
|
# we make use of the ERC20 contract to build the approval transaction
|
|
424
413
|
# since it has the same interface as ERC721 we might want to create
|
|
425
414
|
# a ERC721 contract package
|
|
426
415
|
# this is very bad way to do it but it works because the ERC721 contract expects two arguments
|
|
427
416
|
# for approve call (spender, token_id), and the ERC20 contract wrapper used here from open-autonomy
|
|
428
417
|
# passes the amount as the second argument.
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
418
|
+
TxSettler(
|
|
419
|
+
ledger_api=och.ledger_api,
|
|
420
|
+
crypto=och.crypto,
|
|
421
|
+
chain_type=och.chain_type,
|
|
422
|
+
timeout=ON_CHAIN_INTERACT_TIMEOUT,
|
|
423
|
+
retries=ON_CHAIN_INTERACT_RETRIES,
|
|
424
|
+
sleep=ON_CHAIN_INTERACT_SLEEP,
|
|
425
|
+
tx_builder=lambda: registry_contracts.erc20.get_approve_tx(
|
|
433
426
|
ledger_api=och.ledger_api,
|
|
434
427
|
contract_address=service_registry,
|
|
435
428
|
spender=staking_contract,
|
|
436
429
|
sender=och.crypto.address,
|
|
437
430
|
amount=service_id, # TODO: This is a workaround and it should be fixed
|
|
438
|
-
)
|
|
431
|
+
),
|
|
432
|
+
).transact().settle()
|
|
439
433
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
434
|
+
return (
|
|
435
|
+
TxSettler(
|
|
436
|
+
ledger_api=och.ledger_api,
|
|
437
|
+
crypto=och.crypto,
|
|
438
|
+
chain_type=och.chain_type,
|
|
439
|
+
timeout=ON_CHAIN_INTERACT_TIMEOUT,
|
|
440
|
+
retries=ON_CHAIN_INTERACT_RETRIES,
|
|
441
|
+
sleep=ON_CHAIN_INTERACT_SLEEP,
|
|
442
|
+
tx_builder=lambda: och.ledger_api.build_transaction(
|
|
443
|
+
contract_instance=self.staking_ctr.get_instance(
|
|
444
|
+
ledger_api=och.ledger_api,
|
|
445
|
+
contract_address=staking_contract,
|
|
446
|
+
),
|
|
447
|
+
method_name="stake",
|
|
448
|
+
method_args={"serviceId": service_id},
|
|
449
|
+
tx_args={
|
|
450
|
+
"sender_address": och.crypto.address,
|
|
451
|
+
},
|
|
452
|
+
raise_on_try=True,
|
|
455
453
|
),
|
|
456
|
-
method_name="stake",
|
|
457
|
-
method_args={"serviceId": service_id},
|
|
458
|
-
tx_args={
|
|
459
|
-
"sender_address": och.crypto.address,
|
|
460
|
-
},
|
|
461
|
-
raise_on_try=True,
|
|
462
454
|
)
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
method=lambda: {},
|
|
467
|
-
contract="",
|
|
468
|
-
kwargs={},
|
|
469
|
-
dry_run=False,
|
|
455
|
+
.transact()
|
|
456
|
+
.settle()
|
|
457
|
+
.tx_hash
|
|
470
458
|
)
|
|
471
459
|
|
|
472
460
|
def check_if_unstaking_possible(
|
|
@@ -506,43 +494,36 @@ class StakingManager:
|
|
|
506
494
|
staking_contract: str,
|
|
507
495
|
key: Path,
|
|
508
496
|
password: str,
|
|
509
|
-
) ->
|
|
497
|
+
) -> str:
|
|
510
498
|
"""Unstake the service"""
|
|
511
499
|
och = OnChainHelper(
|
|
512
500
|
key=key, chain_type=ChainType(self.chain.value), password=password
|
|
513
501
|
)
|
|
514
502
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
503
|
+
return (
|
|
504
|
+
TxSettler(
|
|
505
|
+
ledger_api=och.ledger_api,
|
|
506
|
+
crypto=och.crypto,
|
|
507
|
+
chain_type=och.chain_type,
|
|
508
|
+
timeout=ON_CHAIN_INTERACT_TIMEOUT,
|
|
509
|
+
retries=ON_CHAIN_INTERACT_RETRIES,
|
|
510
|
+
sleep=ON_CHAIN_INTERACT_SLEEP,
|
|
511
|
+
tx_builder=lambda: och.ledger_api.build_transaction(
|
|
512
|
+
contract_instance=self.staking_ctr.get_instance(
|
|
513
|
+
ledger_api=och.ledger_api,
|
|
514
|
+
contract_address=staking_contract,
|
|
515
|
+
),
|
|
516
|
+
method_name="unstake",
|
|
517
|
+
method_args={"serviceId": service_id},
|
|
518
|
+
tx_args={
|
|
519
|
+
"sender_address": och.crypto.address,
|
|
520
|
+
},
|
|
521
|
+
raise_on_try=True,
|
|
531
522
|
),
|
|
532
|
-
method_name="unstake",
|
|
533
|
-
method_args={"serviceId": service_id},
|
|
534
|
-
tx_args={
|
|
535
|
-
"sender_address": och.crypto.address,
|
|
536
|
-
},
|
|
537
|
-
raise_on_try=True,
|
|
538
523
|
)
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
method=lambda: {},
|
|
543
|
-
contract="",
|
|
544
|
-
kwargs={},
|
|
545
|
-
dry_run=False,
|
|
524
|
+
.transact()
|
|
525
|
+
.settle()
|
|
526
|
+
.tx_hash
|
|
546
527
|
)
|
|
547
528
|
|
|
548
529
|
def get_stake_approval_tx_data(
|
|
@@ -559,8 +540,8 @@ class StakingManager:
|
|
|
559
540
|
return registry_contracts.erc20.get_instance(
|
|
560
541
|
ledger_api=self.ledger_api,
|
|
561
542
|
contract_address=service_registry,
|
|
562
|
-
).
|
|
563
|
-
|
|
543
|
+
).encode_abi(
|
|
544
|
+
abi_element_identifier="approve",
|
|
564
545
|
args=[
|
|
565
546
|
staking_contract,
|
|
566
547
|
service_id,
|
|
@@ -576,8 +557,8 @@ class StakingManager:
|
|
|
576
557
|
return self.staking_ctr.get_instance(
|
|
577
558
|
ledger_api=self.ledger_api,
|
|
578
559
|
contract_address=staking_contract,
|
|
579
|
-
).
|
|
580
|
-
|
|
560
|
+
).encode_abi(
|
|
561
|
+
abi_element_identifier="stake",
|
|
581
562
|
args=[service_id],
|
|
582
563
|
)
|
|
583
564
|
|
|
@@ -590,8 +571,8 @@ class StakingManager:
|
|
|
590
571
|
return self.staking_ctr.get_instance(
|
|
591
572
|
ledger_api=self.ledger_api,
|
|
592
573
|
contract_address=staking_contract,
|
|
593
|
-
).
|
|
594
|
-
|
|
574
|
+
).encode_abi(
|
|
575
|
+
abi_element_identifier="unstake",
|
|
595
576
|
args=[service_id],
|
|
596
577
|
)
|
|
597
578
|
|
|
@@ -600,8 +581,8 @@ class StakingManager:
|
|
|
600
581
|
return self.staking_ctr.get_instance(
|
|
601
582
|
ledger_api=self.ledger_api,
|
|
602
583
|
contract_address=staking_contract,
|
|
603
|
-
).
|
|
604
|
-
|
|
584
|
+
).encode_abi(
|
|
585
|
+
abi_element_identifier="claim",
|
|
605
586
|
args=[service_id],
|
|
606
587
|
)
|
|
607
588
|
|
|
@@ -612,8 +593,8 @@ class StakingManager:
|
|
|
612
593
|
return self.staking_ctr.get_instance(
|
|
613
594
|
ledger_api=self.ledger_api,
|
|
614
595
|
contract_address=staking_contract,
|
|
615
|
-
).
|
|
616
|
-
|
|
596
|
+
).encode_abi(
|
|
597
|
+
abi_element_identifier="forcedUnstake",
|
|
617
598
|
args=[service_id],
|
|
618
599
|
)
|
|
619
600
|
|
|
@@ -781,15 +762,9 @@ class _ChainUtil:
|
|
|
781
762
|
)
|
|
782
763
|
|
|
783
764
|
@cached_property
|
|
784
|
-
def service_manager_address(self) -> str:
|
|
765
|
+
def service_manager_address(self) -> str:
|
|
785
766
|
"""Get service manager contract address."""
|
|
786
|
-
|
|
787
|
-
ledger_api=self.ledger_api,
|
|
788
|
-
contract_address=CONTRACTS[OperateChain(self.chain_type.value)][
|
|
789
|
-
"service_registry"
|
|
790
|
-
],
|
|
791
|
-
)
|
|
792
|
-
return service_registry.functions.manager().call()
|
|
767
|
+
return ContractConfigs.service_manager.contracts[self.chain_type]
|
|
793
768
|
|
|
794
769
|
@property
|
|
795
770
|
def service_manager_instance(self) -> Contract:
|
|
@@ -1320,8 +1295,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1320
1295
|
instance = self.service_manager_instance
|
|
1321
1296
|
if update_token is None:
|
|
1322
1297
|
safe = self.safe
|
|
1323
|
-
txd = instance.
|
|
1324
|
-
|
|
1298
|
+
txd = instance.encode_abi(
|
|
1299
|
+
abi_element_identifier="create",
|
|
1325
1300
|
args=[
|
|
1326
1301
|
safe,
|
|
1327
1302
|
token or ETHEREUM_ERC20,
|
|
@@ -1332,8 +1307,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1332
1307
|
],
|
|
1333
1308
|
)
|
|
1334
1309
|
else:
|
|
1335
|
-
txd = instance.
|
|
1336
|
-
|
|
1310
|
+
txd = instance.encode_abi(
|
|
1311
|
+
abi_element_identifier="update",
|
|
1337
1312
|
args=[
|
|
1338
1313
|
token or ETHEREUM_ERC20,
|
|
1339
1314
|
manager.metadata_hash,
|
|
@@ -1362,8 +1337,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1362
1337
|
ledger_api=self.ledger_api,
|
|
1363
1338
|
contract_address=erc20_contract,
|
|
1364
1339
|
)
|
|
1365
|
-
txd = instance.
|
|
1366
|
-
|
|
1340
|
+
txd = instance.encode_abi(
|
|
1341
|
+
abi_element_identifier="approve",
|
|
1367
1342
|
args=[spender, amount],
|
|
1368
1343
|
)
|
|
1369
1344
|
return {
|
|
@@ -1375,12 +1350,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1375
1350
|
|
|
1376
1351
|
def get_activate_data(self, service_id: int, cost_of_bond: int) -> t.Dict:
|
|
1377
1352
|
"""Get activate tx data."""
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
contract_address=self.service_manager_address,
|
|
1381
|
-
)
|
|
1382
|
-
txd = instance.encodeABI(
|
|
1383
|
-
fn_name="activateRegistration",
|
|
1353
|
+
txd = self.service_manager_instance.encode_abi(
|
|
1354
|
+
abi_element_identifier="activateRegistration",
|
|
1384
1355
|
args=[service_id],
|
|
1385
1356
|
)
|
|
1386
1357
|
return {
|
|
@@ -1399,12 +1370,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1399
1370
|
cost_of_bond: int,
|
|
1400
1371
|
) -> t.Dict:
|
|
1401
1372
|
"""Get register instances tx data."""
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
contract_address=self.service_manager_address,
|
|
1405
|
-
)
|
|
1406
|
-
txd = instance.encodeABI(
|
|
1407
|
-
fn_name="registerAgents",
|
|
1373
|
+
txd = self.service_manager_instance.encode_abi(
|
|
1374
|
+
abi_element_identifier="registerAgents",
|
|
1408
1375
|
args=[
|
|
1409
1376
|
service_id,
|
|
1410
1377
|
instances,
|
|
@@ -1427,10 +1394,6 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1427
1394
|
use_recovery_module: bool = True,
|
|
1428
1395
|
) -> t.List[t.Dict[str, t.Any]]:
|
|
1429
1396
|
"""Get the deploy data instructions for a safe"""
|
|
1430
|
-
registry_instance = registry_contracts.service_manager.get_instance(
|
|
1431
|
-
ledger_api=self.ledger_api,
|
|
1432
|
-
contract_address=self.service_manager_address,
|
|
1433
|
-
)
|
|
1434
1397
|
approve_hash_message = None
|
|
1435
1398
|
if reuse_multisig:
|
|
1436
1399
|
if not use_recovery_module:
|
|
@@ -1478,8 +1441,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1478
1441
|
SAFE_MULTISIG_WITH_RECOVERY_MODULE_CONTRACT.name
|
|
1479
1442
|
).contracts[self.chain_type]
|
|
1480
1443
|
|
|
1481
|
-
deploy_data =
|
|
1482
|
-
|
|
1444
|
+
deploy_data = self.service_manager_instance.encode_abi(
|
|
1445
|
+
abi_element_identifier="deploy",
|
|
1483
1446
|
args=[
|
|
1484
1447
|
service_id,
|
|
1485
1448
|
gnosis_safe_multisig,
|
|
@@ -1544,8 +1507,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1544
1507
|
).get("tx_hash")
|
|
1545
1508
|
|
|
1546
1509
|
# Build approveHash message
|
|
1547
|
-
approve_hash_data = safe_b_instance.
|
|
1548
|
-
|
|
1510
|
+
approve_hash_data = safe_b_instance.encode_abi(
|
|
1511
|
+
abi_element_identifier="approveHash",
|
|
1549
1512
|
args=[safe_tx_hash],
|
|
1550
1513
|
)
|
|
1551
1514
|
approve_hash_message = {
|
|
@@ -1556,8 +1519,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1556
1519
|
}
|
|
1557
1520
|
|
|
1558
1521
|
# Build execTransaction message
|
|
1559
|
-
exec_data = safe_b_instance.
|
|
1560
|
-
|
|
1522
|
+
exec_data = safe_b_instance.encode_abi(
|
|
1523
|
+
abi_element_identifier="execTransaction",
|
|
1561
1524
|
args=[
|
|
1562
1525
|
multisend_address,
|
|
1563
1526
|
multisend_tx["value"],
|
|
@@ -1607,8 +1570,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1607
1570
|
txs.append(
|
|
1608
1571
|
{
|
|
1609
1572
|
"to": token,
|
|
1610
|
-
"data": erc20_instance.
|
|
1611
|
-
|
|
1573
|
+
"data": erc20_instance.encode_abi(
|
|
1574
|
+
abi_element_identifier="transfer",
|
|
1612
1575
|
args=[to, amount],
|
|
1613
1576
|
),
|
|
1614
1577
|
"operation": MultiSendOperation.CALL,
|
|
@@ -1636,8 +1599,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1636
1599
|
).get("tx_hash")
|
|
1637
1600
|
|
|
1638
1601
|
# Build approveHash message
|
|
1639
|
-
approve_hash_data = safe_b_instance.
|
|
1640
|
-
|
|
1602
|
+
approve_hash_data = safe_b_instance.encode_abi(
|
|
1603
|
+
abi_element_identifier="approveHash",
|
|
1641
1604
|
args=[safe_tx_hash],
|
|
1642
1605
|
)
|
|
1643
1606
|
approve_hash_message = {
|
|
@@ -1648,8 +1611,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1648
1611
|
}
|
|
1649
1612
|
|
|
1650
1613
|
# Build execTransaction message
|
|
1651
|
-
exec_data = safe_b_instance.
|
|
1652
|
-
|
|
1614
|
+
exec_data = safe_b_instance.encode_abi(
|
|
1615
|
+
abi_element_identifier="execTransaction",
|
|
1653
1616
|
args=[
|
|
1654
1617
|
multisend_address,
|
|
1655
1618
|
multisend_tx["value"],
|
|
@@ -1674,12 +1637,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1674
1637
|
|
|
1675
1638
|
def get_terminate_data(self, service_id: int) -> t.Dict:
|
|
1676
1639
|
"""Get terminate tx data."""
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
contract_address=self.service_manager_address,
|
|
1680
|
-
)
|
|
1681
|
-
txd = instance.encodeABI(
|
|
1682
|
-
fn_name="terminate",
|
|
1640
|
+
txd = self.service_manager_instance.encode_abi(
|
|
1641
|
+
abi_element_identifier="terminate",
|
|
1683
1642
|
args=[service_id],
|
|
1684
1643
|
)
|
|
1685
1644
|
return {
|
|
@@ -1691,12 +1650,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1691
1650
|
|
|
1692
1651
|
def get_unbond_data(self, service_id: int) -> t.Dict:
|
|
1693
1652
|
"""Get unbond tx data."""
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
contract_address=self.service_manager_address,
|
|
1697
|
-
)
|
|
1698
|
-
txd = instance.encodeABI(
|
|
1699
|
-
fn_name="unbond",
|
|
1653
|
+
txd = self.service_manager_instance.encode_abi(
|
|
1654
|
+
abi_element_identifier="unbond",
|
|
1700
1655
|
args=[service_id],
|
|
1701
1656
|
)
|
|
1702
1657
|
return {
|
|
@@ -1844,8 +1799,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1844
1799
|
# ledger_api=self.ledger_api, # noqa: E800
|
|
1845
1800
|
# contract_address=self.contracts["recovery_module"], # noqa: E800
|
|
1846
1801
|
# ) # noqa: E800
|
|
1847
|
-
txd = instance.
|
|
1848
|
-
|
|
1802
|
+
txd = instance.encode_abi(
|
|
1803
|
+
abi_element_identifier="recoverAccess",
|
|
1849
1804
|
args=[service_id],
|
|
1850
1805
|
)
|
|
1851
1806
|
return {
|
|
@@ -1866,8 +1821,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1866
1821
|
ledger_api=self.ledger_api,
|
|
1867
1822
|
contract_address=safe_address,
|
|
1868
1823
|
)
|
|
1869
|
-
txd = instance.
|
|
1870
|
-
|
|
1824
|
+
txd = instance.encode_abi(
|
|
1825
|
+
abi_element_identifier="enableModule",
|
|
1871
1826
|
args=[module_address],
|
|
1872
1827
|
)
|
|
1873
1828
|
return {
|
|
@@ -1948,8 +1903,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
1948
1903
|
"to": multisig_address,
|
|
1949
1904
|
"data": HexBytes(
|
|
1950
1905
|
bytes.fromhex(
|
|
1951
|
-
multisig_instance.
|
|
1952
|
-
|
|
1906
|
+
multisig_instance.encode_abi(
|
|
1907
|
+
abi_element_identifier="addOwnerWithThreshold",
|
|
1953
1908
|
args=[_owner, 1],
|
|
1954
1909
|
)[2:]
|
|
1955
1910
|
)
|
|
@@ -1964,8 +1919,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
1964
1919
|
"to": multisig_address,
|
|
1965
1920
|
"data": HexBytes(
|
|
1966
1921
|
bytes.fromhex(
|
|
1967
|
-
multisig_instance.
|
|
1968
|
-
|
|
1922
|
+
multisig_instance.encode_abi(
|
|
1923
|
+
abi_element_identifier="removeOwner",
|
|
1969
1924
|
args=[new_owners[0], master_safe, 1],
|
|
1970
1925
|
)[2:]
|
|
1971
1926
|
)
|
|
@@ -1980,8 +1935,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
1980
1935
|
"to": multisig_address,
|
|
1981
1936
|
"data": HexBytes(
|
|
1982
1937
|
bytes.fromhex(
|
|
1983
|
-
multisig_instance.
|
|
1984
|
-
|
|
1938
|
+
multisig_instance.encode_abi(
|
|
1939
|
+
abi_element_identifier="changeThreshold",
|
|
1985
1940
|
args=[threshold],
|
|
1986
1941
|
)[2:]
|
|
1987
1942
|
)
|
|
@@ -2006,8 +1961,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
2006
1961
|
data=multisend_tx["data"],
|
|
2007
1962
|
operation=1,
|
|
2008
1963
|
).get("tx_hash")
|
|
2009
|
-
approve_hash_data = multisig_instance.
|
|
2010
|
-
|
|
1964
|
+
approve_hash_data = multisig_instance.encode_abi(
|
|
1965
|
+
abi_element_identifier="approveHash",
|
|
2011
1966
|
args=[
|
|
2012
1967
|
safe_tx_hash,
|
|
2013
1968
|
],
|
|
@@ -2019,8 +1974,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
2019
1974
|
"value": 0,
|
|
2020
1975
|
}
|
|
2021
1976
|
|
|
2022
|
-
safe_exec_data = multisig_instance.
|
|
2023
|
-
|
|
1977
|
+
safe_exec_data = multisig_instance.encode_abi(
|
|
1978
|
+
abi_element_identifier="execTransaction",
|
|
2024
1979
|
args=[
|
|
2025
1980
|
multisend_address, # to address
|
|
2026
1981
|
multisend_tx["value"], # value
|
operate/services/utils/mech.py
CHANGED
|
@@ -24,7 +24,7 @@ from typing import Tuple
|
|
|
24
24
|
import requests
|
|
25
25
|
from aea_ledger_ethereum import Web3
|
|
26
26
|
|
|
27
|
-
from operate.constants import MECH_MARKETPLACE_JSON_URL
|
|
27
|
+
from operate.constants import DEFAULT_TIMEOUT, MECH_MARKETPLACE_JSON_URL
|
|
28
28
|
from operate.operate_types import Chain
|
|
29
29
|
from operate.quickstart.utils import print_section
|
|
30
30
|
from operate.services.protocol import EthSafeTxBuilder
|
|
@@ -57,7 +57,7 @@ def deploy_mech(sftxb: EthSafeTxBuilder, service: Service) -> Tuple[str, str]:
|
|
|
57
57
|
# Get the mech type from service config
|
|
58
58
|
mech_type = service.env_variables.get("MECH_TYPE", {}).get("value", "Native")
|
|
59
59
|
|
|
60
|
-
abi = requests.get(MECH_MARKETPLACE_JSON_URL).json()["abi"]
|
|
60
|
+
abi = requests.get(MECH_MARKETPLACE_JSON_URL, timeout=DEFAULT_TIMEOUT).json()["abi"]
|
|
61
61
|
chain = Chain.from_string(service.home_chain)
|
|
62
62
|
mech_marketplace_address = service.env_variables["MECH_MARKETPLACE_ADDRESS"][
|
|
63
63
|
"value"
|
|
@@ -82,7 +82,7 @@ def deploy_mech(sftxb: EthSafeTxBuilder, service: Service) -> Tuple[str, str]:
|
|
|
82
82
|
contract = sftxb.ledger_api.api.eth.contract(
|
|
83
83
|
address=Web3.to_checksum_address(mech_marketplace_address), abi=abi
|
|
84
84
|
)
|
|
85
|
-
data = contract.
|
|
85
|
+
data = contract.encode_abi(
|
|
86
86
|
"create",
|
|
87
87
|
args=[
|
|
88
88
|
service.chain_configs[service.home_chain].chain_data.token,
|
|
@@ -42,6 +42,8 @@ import requests
|
|
|
42
42
|
from flask import Flask, Response, jsonify, request
|
|
43
43
|
from werkzeug.exceptions import InternalServerError, NotFound
|
|
44
44
|
|
|
45
|
+
from operate.constants import DEFAULT_TIMEOUT
|
|
46
|
+
|
|
45
47
|
|
|
46
48
|
ENCODING = "utf-8"
|
|
47
49
|
DEFAULT_LOG_FILE = "com.log"
|
|
@@ -474,7 +476,7 @@ class PeriodDumper:
|
|
|
474
476
|
os.chmod(path, stat.S_IWRITE)
|
|
475
477
|
func(path)
|
|
476
478
|
except (FileNotFoundError, OSError):
|
|
477
|
-
|
|
479
|
+
pass
|
|
478
480
|
|
|
479
481
|
def dump_period(self) -> None:
|
|
480
482
|
"""Dump tendermint run data for replay"""
|
|
@@ -532,7 +534,7 @@ def create_app( # pylint: disable=too-many-statements
|
|
|
532
534
|
)
|
|
533
535
|
priv_key_data = json.loads(priv_key_file.read_text(encoding=ENCODING))
|
|
534
536
|
del priv_key_data["priv_key"]
|
|
535
|
-
status = requests.get(TM_STATUS_ENDPOINT).json()
|
|
537
|
+
status = requests.get(TM_STATUS_ENDPOINT, timeout=DEFAULT_TIMEOUT).json()
|
|
536
538
|
priv_key_data["peer_id"] = status["result"]["node_info"]["id"]
|
|
537
539
|
return {
|
|
538
540
|
"params": priv_key_data,
|
|
@@ -600,7 +602,7 @@ def create_app( # pylint: disable=too-many-statements
|
|
|
600
602
|
endpoint = f"{tendermint_params.rpc_laddr.replace('tcp', 'http').replace(non_routable, loopback)}/block"
|
|
601
603
|
height = request.args.get("height")
|
|
602
604
|
params = {"height": height} if height is not None else None
|
|
603
|
-
res = requests.get(endpoint, params)
|
|
605
|
+
res = requests.get(endpoint, params, timeout=DEFAULT_TIMEOUT)
|
|
604
606
|
app_hash_ = res.json()["result"]["block"]["header"]["app_hash"]
|
|
605
607
|
return jsonify({"app_hash": app_hash_}), res.status_code
|
|
606
608
|
except Exception as e: # pylint: disable=W0703
|