olas-operate-middleware 0.13.1__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.1.dist-info → olas_operate_middleware-0.13.3.dist-info}/METADATA +8 -27
- {olas_operate_middleware-0.13.1.dist-info → olas_operate_middleware-0.13.3.dist-info}/RECORD +42 -42
- operate/bridge/providers/provider.py +23 -31
- operate/cli.py +5 -18
- 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/deployment_runner.py +107 -82
- operate/services/health_checker.py +38 -2
- 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 +53 -50
- operate/wallet/wallet_recovery_manager.py +110 -56
- {olas_operate_middleware-0.13.1.dist-info → olas_operate_middleware-0.13.3.dist-info}/WHEEL +0 -0
- {olas_operate_middleware-0.13.1.dist-info → olas_operate_middleware-0.13.3.dist-info}/entry_points.txt +0 -0
- {olas_operate_middleware-0.13.1.dist-info → olas_operate_middleware-0.13.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import asyncio
|
|
22
22
|
import json
|
|
23
23
|
import logging
|
|
24
|
+
import time
|
|
24
25
|
import typing as t
|
|
25
26
|
from concurrent.futures import ThreadPoolExecutor
|
|
26
27
|
from http import HTTPStatus
|
|
@@ -40,6 +41,8 @@ class HealthChecker:
|
|
|
40
41
|
PORT_UP_TIMEOUT_DEFAULT = 300 # seconds
|
|
41
42
|
REQUEST_TIMEOUT_DEFAULT = 90 # seconds
|
|
42
43
|
NUMBER_OF_FAILS_DEFAULT = 60
|
|
44
|
+
FAILFAST_NUM = 15
|
|
45
|
+
FAILFAST_TIMEOUT = 15 * 60 # 15 minutes
|
|
43
46
|
|
|
44
47
|
def __init__(
|
|
45
48
|
self,
|
|
@@ -121,7 +124,7 @@ class HealthChecker:
|
|
|
121
124
|
)
|
|
122
125
|
return False
|
|
123
126
|
|
|
124
|
-
async def healthcheck_job(
|
|
127
|
+
async def healthcheck_job( # pylint: disable=too-many-statements
|
|
125
128
|
self,
|
|
126
129
|
service_config_id: str,
|
|
127
130
|
) -> None:
|
|
@@ -214,7 +217,24 @@ class HealthChecker:
|
|
|
214
217
|
if exception is not None:
|
|
215
218
|
raise exception
|
|
216
219
|
|
|
220
|
+
async def _stop(
|
|
221
|
+
service_manager: ServiceManager, service_config_id: str
|
|
222
|
+
) -> None:
|
|
223
|
+
def _do_stop() -> None:
|
|
224
|
+
service_manager.stop_service_locally(
|
|
225
|
+
service_config_id=service_config_id
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
loop = asyncio.get_event_loop()
|
|
229
|
+
with ThreadPoolExecutor() as executor:
|
|
230
|
+
future = loop.run_in_executor(executor, _do_stop)
|
|
231
|
+
await future
|
|
232
|
+
exception = future.exception()
|
|
233
|
+
if exception is not None:
|
|
234
|
+
raise exception
|
|
235
|
+
|
|
217
236
|
# upper cycle
|
|
237
|
+
failfast_records: t.List[float] = []
|
|
218
238
|
while True:
|
|
219
239
|
self.logger.info(
|
|
220
240
|
f"[HEALTH_CHECKER] {service_config_id} wait for port ready"
|
|
@@ -224,6 +244,7 @@ class HealthChecker:
|
|
|
224
244
|
self.logger.info(
|
|
225
245
|
f"[HEALTH_CHECKER] {service_config_id} port is ready, checking health every {self.sleep_period}"
|
|
226
246
|
)
|
|
247
|
+
failfast_records = []
|
|
227
248
|
await _check_health(
|
|
228
249
|
number_of_fails=self.number_of_fails,
|
|
229
250
|
sleep_period=self.sleep_period,
|
|
@@ -236,7 +257,22 @@ class HealthChecker:
|
|
|
236
257
|
|
|
237
258
|
# perform restart
|
|
238
259
|
# TODO: blocking!!!!!!!
|
|
239
|
-
|
|
260
|
+
while True:
|
|
261
|
+
# we count every restart till success (port is up and healtcheck started)
|
|
262
|
+
failfast_records.append(time.time())
|
|
263
|
+
try:
|
|
264
|
+
await _restart(self._service_manager, service_config_id)
|
|
265
|
+
break
|
|
266
|
+
except Exception: # pylint: disable=broad-except
|
|
267
|
+
if (len(failfast_records) >= self.FAILFAST_NUM) or (
|
|
268
|
+
time.time() - failfast_records[0]
|
|
269
|
+
) > self.FAILFAST_TIMEOUT:
|
|
270
|
+
await _stop(self._service_manager, service_config_id)
|
|
271
|
+
raise
|
|
272
|
+
|
|
273
|
+
self.logger.exception(f"Restart problem: {service_config_id}")
|
|
274
|
+
await asyncio.sleep(30)
|
|
275
|
+
|
|
240
276
|
except Exception:
|
|
241
277
|
self.logger.exception(
|
|
242
278
|
f"Problems running healthcheck job for {service_config_id}"
|
operate/services/manage.py
CHANGED
|
@@ -1551,7 +1551,7 @@ class ServiceManager:
|
|
|
1551
1551
|
f"Cannot enable recovery module. Safe {service_safe_address} has inconsistent owners."
|
|
1552
1552
|
)
|
|
1553
1553
|
|
|
1554
|
-
def _get_current_staking_program(
|
|
1554
|
+
def _get_current_staking_program(
|
|
1555
1555
|
self, service: Service, chain: str
|
|
1556
1556
|
) -> t.Optional[str]:
|
|
1557
1557
|
staking_manager = StakingManager(Chain(chain))
|
|
@@ -1940,7 +1940,7 @@ class ServiceManager:
|
|
|
1940
1940
|
|
|
1941
1941
|
# transfer claimed amount from agents safe to master safe
|
|
1942
1942
|
# TODO: remove after staking contract directly starts sending the rewards to master safe
|
|
1943
|
-
amount_claimed = int(receipt["logs"][0]["data"].
|
|
1943
|
+
amount_claimed = int(receipt["logs"][0]["data"].to_0x_hex(), 16)
|
|
1944
1944
|
self.logger.info(f"Claimed amount: {amount_claimed}")
|
|
1945
1945
|
ethereum_crypto = self.keys_manager.get_crypto_instance(
|
|
1946
1946
|
service.agent_addresses[0]
|
|
@@ -2352,9 +2352,9 @@ class ServiceManager:
|
|
|
2352
2352
|
allow_start_agent = False
|
|
2353
2353
|
|
|
2354
2354
|
# Protocol asset requirements
|
|
2355
|
-
protocol_asset_requirements[
|
|
2356
|
-
chain
|
|
2357
|
-
|
|
2355
|
+
protocol_asset_requirements[chain] = (
|
|
2356
|
+
self._compute_protocol_asset_requirements(service_config_id, chain)
|
|
2357
|
+
)
|
|
2358
2358
|
service_asset_requirements = chain_data.user_params.fund_requirements
|
|
2359
2359
|
|
|
2360
2360
|
# Bonded assets
|
|
@@ -2461,15 +2461,12 @@ class ServiceManager:
|
|
|
2461
2461
|
asset_address
|
|
2462
2462
|
] = recommended_refill
|
|
2463
2463
|
|
|
2464
|
-
total_requirements[chain].setdefault(master_safe, {})[
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
chain
|
|
2471
|
-
].get(
|
|
2472
|
-
asset_address, 0
|
|
2464
|
+
total_requirements[chain].setdefault(master_safe, {})[asset_address] = (
|
|
2465
|
+
sum(
|
|
2466
|
+
agent_asset_funding_values[address]["topup"]
|
|
2467
|
+
for address in agent_asset_funding_values
|
|
2468
|
+
)
|
|
2469
|
+
+ protocol_asset_requirements[chain].get(asset_address, 0)
|
|
2473
2470
|
)
|
|
2474
2471
|
|
|
2475
2472
|
if asset_address == ZERO_ADDRESS and any(
|
|
@@ -2498,9 +2495,9 @@ class ServiceManager:
|
|
|
2498
2495
|
ZERO_ADDRESS
|
|
2499
2496
|
] = eoa_recommended_refill
|
|
2500
2497
|
|
|
2501
|
-
total_requirements[chain].setdefault(master_eoa, {})[
|
|
2502
|
-
|
|
2503
|
-
|
|
2498
|
+
total_requirements[chain].setdefault(master_eoa, {})[ZERO_ADDRESS] = (
|
|
2499
|
+
eoa_funding_values["topup"]
|
|
2500
|
+
)
|
|
2504
2501
|
|
|
2505
2502
|
is_refill_required = any(
|
|
2506
2503
|
amount > 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,
|