olas-operate-middleware 0.13.2__py3-none-any.whl → 0.13.3__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.3.dist-info}/METADATA +8 -27
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.3.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 +122 -141
- 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.3.dist-info}/WHEEL +0 -0
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.3.dist-info}/entry_points.txt +0 -0
- {olas_operate_middleware-0.13.2.dist-info → olas_operate_middleware-0.13.3.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
|
|
|
@@ -1320,8 +1301,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1320
1301
|
instance = self.service_manager_instance
|
|
1321
1302
|
if update_token is None:
|
|
1322
1303
|
safe = self.safe
|
|
1323
|
-
txd = instance.
|
|
1324
|
-
|
|
1304
|
+
txd = instance.encode_abi(
|
|
1305
|
+
abi_element_identifier="create",
|
|
1325
1306
|
args=[
|
|
1326
1307
|
safe,
|
|
1327
1308
|
token or ETHEREUM_ERC20,
|
|
@@ -1332,8 +1313,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1332
1313
|
],
|
|
1333
1314
|
)
|
|
1334
1315
|
else:
|
|
1335
|
-
txd = instance.
|
|
1336
|
-
|
|
1316
|
+
txd = instance.encode_abi(
|
|
1317
|
+
abi_element_identifier="update",
|
|
1337
1318
|
args=[
|
|
1338
1319
|
token or ETHEREUM_ERC20,
|
|
1339
1320
|
manager.metadata_hash,
|
|
@@ -1362,8 +1343,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1362
1343
|
ledger_api=self.ledger_api,
|
|
1363
1344
|
contract_address=erc20_contract,
|
|
1364
1345
|
)
|
|
1365
|
-
txd = instance.
|
|
1366
|
-
|
|
1346
|
+
txd = instance.encode_abi(
|
|
1347
|
+
abi_element_identifier="approve",
|
|
1367
1348
|
args=[spender, amount],
|
|
1368
1349
|
)
|
|
1369
1350
|
return {
|
|
@@ -1379,8 +1360,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1379
1360
|
ledger_api=self.ledger_api,
|
|
1380
1361
|
contract_address=self.service_manager_address,
|
|
1381
1362
|
)
|
|
1382
|
-
txd = instance.
|
|
1383
|
-
|
|
1363
|
+
txd = instance.encode_abi(
|
|
1364
|
+
abi_element_identifier="activateRegistration",
|
|
1384
1365
|
args=[service_id],
|
|
1385
1366
|
)
|
|
1386
1367
|
return {
|
|
@@ -1403,8 +1384,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1403
1384
|
ledger_api=self.ledger_api,
|
|
1404
1385
|
contract_address=self.service_manager_address,
|
|
1405
1386
|
)
|
|
1406
|
-
txd = instance.
|
|
1407
|
-
|
|
1387
|
+
txd = instance.encode_abi(
|
|
1388
|
+
abi_element_identifier="registerAgents",
|
|
1408
1389
|
args=[
|
|
1409
1390
|
service_id,
|
|
1410
1391
|
instances,
|
|
@@ -1478,8 +1459,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1478
1459
|
SAFE_MULTISIG_WITH_RECOVERY_MODULE_CONTRACT.name
|
|
1479
1460
|
).contracts[self.chain_type]
|
|
1480
1461
|
|
|
1481
|
-
deploy_data = registry_instance.
|
|
1482
|
-
|
|
1462
|
+
deploy_data = registry_instance.encode_abi(
|
|
1463
|
+
abi_element_identifier="deploy",
|
|
1483
1464
|
args=[
|
|
1484
1465
|
service_id,
|
|
1485
1466
|
gnosis_safe_multisig,
|
|
@@ -1544,8 +1525,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1544
1525
|
).get("tx_hash")
|
|
1545
1526
|
|
|
1546
1527
|
# Build approveHash message
|
|
1547
|
-
approve_hash_data = safe_b_instance.
|
|
1548
|
-
|
|
1528
|
+
approve_hash_data = safe_b_instance.encode_abi(
|
|
1529
|
+
abi_element_identifier="approveHash",
|
|
1549
1530
|
args=[safe_tx_hash],
|
|
1550
1531
|
)
|
|
1551
1532
|
approve_hash_message = {
|
|
@@ -1556,8 +1537,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1556
1537
|
}
|
|
1557
1538
|
|
|
1558
1539
|
# Build execTransaction message
|
|
1559
|
-
exec_data = safe_b_instance.
|
|
1560
|
-
|
|
1540
|
+
exec_data = safe_b_instance.encode_abi(
|
|
1541
|
+
abi_element_identifier="execTransaction",
|
|
1561
1542
|
args=[
|
|
1562
1543
|
multisend_address,
|
|
1563
1544
|
multisend_tx["value"],
|
|
@@ -1607,8 +1588,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1607
1588
|
txs.append(
|
|
1608
1589
|
{
|
|
1609
1590
|
"to": token,
|
|
1610
|
-
"data": erc20_instance.
|
|
1611
|
-
|
|
1591
|
+
"data": erc20_instance.encode_abi(
|
|
1592
|
+
abi_element_identifier="transfer",
|
|
1612
1593
|
args=[to, amount],
|
|
1613
1594
|
),
|
|
1614
1595
|
"operation": MultiSendOperation.CALL,
|
|
@@ -1636,8 +1617,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1636
1617
|
).get("tx_hash")
|
|
1637
1618
|
|
|
1638
1619
|
# Build approveHash message
|
|
1639
|
-
approve_hash_data = safe_b_instance.
|
|
1640
|
-
|
|
1620
|
+
approve_hash_data = safe_b_instance.encode_abi(
|
|
1621
|
+
abi_element_identifier="approveHash",
|
|
1641
1622
|
args=[safe_tx_hash],
|
|
1642
1623
|
)
|
|
1643
1624
|
approve_hash_message = {
|
|
@@ -1648,8 +1629,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1648
1629
|
}
|
|
1649
1630
|
|
|
1650
1631
|
# Build execTransaction message
|
|
1651
|
-
exec_data = safe_b_instance.
|
|
1652
|
-
|
|
1632
|
+
exec_data = safe_b_instance.encode_abi(
|
|
1633
|
+
abi_element_identifier="execTransaction",
|
|
1653
1634
|
args=[
|
|
1654
1635
|
multisend_address,
|
|
1655
1636
|
multisend_tx["value"],
|
|
@@ -1678,8 +1659,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1678
1659
|
ledger_api=self.ledger_api,
|
|
1679
1660
|
contract_address=self.service_manager_address,
|
|
1680
1661
|
)
|
|
1681
|
-
txd = instance.
|
|
1682
|
-
|
|
1662
|
+
txd = instance.encode_abi(
|
|
1663
|
+
abi_element_identifier="terminate",
|
|
1683
1664
|
args=[service_id],
|
|
1684
1665
|
)
|
|
1685
1666
|
return {
|
|
@@ -1695,8 +1676,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1695
1676
|
ledger_api=self.ledger_api,
|
|
1696
1677
|
contract_address=self.service_manager_address,
|
|
1697
1678
|
)
|
|
1698
|
-
txd = instance.
|
|
1699
|
-
|
|
1679
|
+
txd = instance.encode_abi(
|
|
1680
|
+
abi_element_identifier="unbond",
|
|
1700
1681
|
args=[service_id],
|
|
1701
1682
|
)
|
|
1702
1683
|
return {
|
|
@@ -1844,8 +1825,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1844
1825
|
# ledger_api=self.ledger_api, # noqa: E800
|
|
1845
1826
|
# contract_address=self.contracts["recovery_module"], # noqa: E800
|
|
1846
1827
|
# ) # noqa: E800
|
|
1847
|
-
txd = instance.
|
|
1848
|
-
|
|
1828
|
+
txd = instance.encode_abi(
|
|
1829
|
+
abi_element_identifier="recoverAccess",
|
|
1849
1830
|
args=[service_id],
|
|
1850
1831
|
)
|
|
1851
1832
|
return {
|
|
@@ -1866,8 +1847,8 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1866
1847
|
ledger_api=self.ledger_api,
|
|
1867
1848
|
contract_address=safe_address,
|
|
1868
1849
|
)
|
|
1869
|
-
txd = instance.
|
|
1870
|
-
|
|
1850
|
+
txd = instance.encode_abi(
|
|
1851
|
+
abi_element_identifier="enableModule",
|
|
1871
1852
|
args=[module_address],
|
|
1872
1853
|
)
|
|
1873
1854
|
return {
|
|
@@ -1948,8 +1929,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
1948
1929
|
"to": multisig_address,
|
|
1949
1930
|
"data": HexBytes(
|
|
1950
1931
|
bytes.fromhex(
|
|
1951
|
-
multisig_instance.
|
|
1952
|
-
|
|
1932
|
+
multisig_instance.encode_abi(
|
|
1933
|
+
abi_element_identifier="addOwnerWithThreshold",
|
|
1953
1934
|
args=[_owner, 1],
|
|
1954
1935
|
)[2:]
|
|
1955
1936
|
)
|
|
@@ -1964,8 +1945,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
1964
1945
|
"to": multisig_address,
|
|
1965
1946
|
"data": HexBytes(
|
|
1966
1947
|
bytes.fromhex(
|
|
1967
|
-
multisig_instance.
|
|
1968
|
-
|
|
1948
|
+
multisig_instance.encode_abi(
|
|
1949
|
+
abi_element_identifier="removeOwner",
|
|
1969
1950
|
args=[new_owners[0], master_safe, 1],
|
|
1970
1951
|
)[2:]
|
|
1971
1952
|
)
|
|
@@ -1980,8 +1961,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
1980
1961
|
"to": multisig_address,
|
|
1981
1962
|
"data": HexBytes(
|
|
1982
1963
|
bytes.fromhex(
|
|
1983
|
-
multisig_instance.
|
|
1984
|
-
|
|
1964
|
+
multisig_instance.encode_abi(
|
|
1965
|
+
abi_element_identifier="changeThreshold",
|
|
1985
1966
|
args=[threshold],
|
|
1986
1967
|
)[2:]
|
|
1987
1968
|
)
|
|
@@ -2006,8 +1987,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
2006
1987
|
data=multisend_tx["data"],
|
|
2007
1988
|
operation=1,
|
|
2008
1989
|
).get("tx_hash")
|
|
2009
|
-
approve_hash_data = multisig_instance.
|
|
2010
|
-
|
|
1990
|
+
approve_hash_data = multisig_instance.encode_abi(
|
|
1991
|
+
abi_element_identifier="approveHash",
|
|
2011
1992
|
args=[
|
|
2012
1993
|
safe_tx_hash,
|
|
2013
1994
|
],
|
|
@@ -2019,8 +2000,8 @@ def get_reuse_multisig_from_safe_payload( # pylint: disable=too-many-locals
|
|
|
2019
2000
|
"value": 0,
|
|
2020
2001
|
}
|
|
2021
2002
|
|
|
2022
|
-
safe_exec_data = multisig_instance.
|
|
2023
|
-
|
|
2003
|
+
safe_exec_data = multisig_instance.encode_abi(
|
|
2004
|
+
abi_element_identifier="execTransaction",
|
|
2024
2005
|
args=[
|
|
2025
2006
|
multisend_address, # to address
|
|
2026
2007
|
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
|