olas-operate-middleware 0.14.4__tar.gz → 0.14.6__tar.gz

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.

Potentially problematic release.


This version of olas-operate-middleware might be problematic. Click here for more details.

Files changed (97) hide show
  1. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/PKG-INFO +1 -1
  2. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/bridge/providers/provider.py +24 -7
  3. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/cli.py +1 -1
  4. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/constants.py +2 -1
  5. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/ledger/profiles.py +9 -2
  6. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/manage.py +11 -0
  7. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/protocol.py +23 -3
  8. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/service.py +7 -6
  9. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/wallet/master.py +6 -2
  10. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/pyproject.toml +1 -1
  11. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/LICENSE +0 -0
  12. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/README.md +0 -0
  13. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/__init__.py +0 -0
  14. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/account/__init__.py +0 -0
  15. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/account/user.py +0 -0
  16. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/bridge/bridge_manager.py +0 -0
  17. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/bridge/providers/lifi_provider.py +0 -0
  18. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/bridge/providers/native_bridge_provider.py +0 -0
  19. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/bridge/providers/relay_provider.py +0 -0
  20. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/README.md +0 -0
  21. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/__init__.py +0 -0
  22. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/__init__.py +0 -0
  23. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/dual_staking_token/__init__.py +0 -0
  24. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/dual_staking_token/build/DualStakingToken.json +0 -0
  25. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/dual_staking_token/contract.py +0 -0
  26. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/dual_staking_token/contract.yaml +0 -0
  27. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/foreign_omnibridge/__init__.py +0 -0
  28. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/foreign_omnibridge/build/ForeignOmnibridge.json +0 -0
  29. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/foreign_omnibridge/contract.py +0 -0
  30. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/foreign_omnibridge/contract.yaml +0 -0
  31. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/home_omnibridge/__init__.py +0 -0
  32. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/home_omnibridge/build/HomeOmnibridge.json +0 -0
  33. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/home_omnibridge/contract.py +0 -0
  34. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/home_omnibridge/contract.yaml +0 -0
  35. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l1_standard_bridge/__init__.py +0 -0
  36. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l1_standard_bridge/build/L1StandardBridge.json +0 -0
  37. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l1_standard_bridge/contract.py +0 -0
  38. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l1_standard_bridge/contract.yaml +0 -0
  39. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l2_standard_bridge/__init__.py +0 -0
  40. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l2_standard_bridge/build/L2StandardBridge.json +0 -0
  41. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l2_standard_bridge/contract.py +0 -0
  42. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/l2_standard_bridge/contract.yaml +0 -0
  43. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/mech_activity/__init__.py +0 -0
  44. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/mech_activity/build/MechActivity.json +0 -0
  45. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/mech_activity/contract.py +0 -0
  46. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/mech_activity/contract.yaml +0 -0
  47. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/optimism_mintable_erc20/__init__.py +0 -0
  48. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/optimism_mintable_erc20/build/OptimismMintableERC20.json +0 -0
  49. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/optimism_mintable_erc20/contract.py +0 -0
  50. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/optimism_mintable_erc20/contract.yaml +0 -0
  51. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/requester_activity_checker/__init__.py +0 -0
  52. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/requester_activity_checker/build/RequesterActivityChecker.json +0 -0
  53. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/requester_activity_checker/contract.py +0 -0
  54. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/requester_activity_checker/contract.yaml +0 -0
  55. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/staking_token/__init__.py +0 -0
  56. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/staking_token/build/StakingToken.json +0 -0
  57. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/staking_token/contract.py +0 -0
  58. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/staking_token/contract.yaml +0 -0
  59. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/uniswap_v2_erc20/__init__.py +0 -0
  60. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/uniswap_v2_erc20/build/IUniswapV2ERC20.json +0 -0
  61. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/uniswap_v2_erc20/contract.py +0 -0
  62. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/uniswap_v2_erc20/contract.yaml +0 -0
  63. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/uniswap_v2_erc20/tests/__init__.py +0 -0
  64. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/data/contracts/uniswap_v2_erc20/tests/test_contract.py +0 -0
  65. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/keys.py +0 -0
  66. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/ledger/__init__.py +0 -0
  67. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/migration.py +0 -0
  68. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/operate_http/__init__.py +0 -0
  69. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/operate_http/exceptions.py +0 -0
  70. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/operate_types.py +0 -0
  71. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/pearl.py +0 -0
  72. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/analyse_logs.py +0 -0
  73. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/claim_staking_rewards.py +0 -0
  74. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/reset_configs.py +0 -0
  75. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/reset_password.py +0 -0
  76. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/reset_staking.py +0 -0
  77. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/run_service.py +0 -0
  78. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/stop_service.py +0 -0
  79. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/terminate_on_chain_service.py +0 -0
  80. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/quickstart/utils.py +0 -0
  81. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/resource.py +0 -0
  82. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/serialization.py +0 -0
  83. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/__init__.py +0 -0
  84. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/agent_runner.py +0 -0
  85. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/deployment_runner.py +0 -0
  86. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/funding_manager.py +0 -0
  87. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/health_checker.py +0 -0
  88. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/utils/__init__.py +0 -0
  89. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/utils/mech.py +0 -0
  90. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/services/utils/tendermint.py +0 -0
  91. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/settings.py +0 -0
  92. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/utils/__init__.py +0 -0
  93. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/utils/gnosis.py +0 -0
  94. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/utils/single_instance.py +0 -0
  95. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/utils/ssl.py +0 -0
  96. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/wallet/__init__.py +0 -0
  97. {olas_operate_middleware-0.14.4 → olas_operate_middleware-0.14.6}/operate/wallet/wallet_recovery_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: olas-operate-middleware
3
- Version: 0.14.4
3
+ Version: 0.14.6
4
4
  Summary:
5
5
  License-File: LICENSE
6
6
  Author: David Vilela
@@ -61,7 +61,9 @@ MESSAGE_EXECUTION_FAILED_SETTLEMENT = (
61
61
  )
62
62
  MESSAGE_REQUIREMENTS_QUOTE_FAILED = "Cannot compute requirements for failed quote."
63
63
 
64
- ERC20_APPROVE_SELECTOR = "0x095ea7b3" # First 4 bytes of Web3.keccak(text='approve(address,uint256)').to_0x_hex()[:10]
64
+ # ERC-20 function selectors (first 4 bytes of the Keccak-256 hash of the function signature)
65
+ ERC20_APPROVE_SELECTOR = "0x095ea7b3"
66
+ ERC20_TRANSFER_SELECTOR = "0xa9059cbb"
65
67
 
66
68
 
67
69
  @dataclass
@@ -287,14 +289,29 @@ class Provider(ABC):
287
289
  f"[PROVIDER] {from_ledger_api.api.eth.get_block('latest').baseFeePerGas=}"
288
290
  )
289
291
 
290
- if tx.get("to", "").lower() == from_token.lower() and tx.get(
291
- "data", ""
292
- ).startswith(ERC20_APPROVE_SELECTOR):
292
+ # TODO Move the requirements logic to be implemented by each provider.
293
+ #
294
+ # The following code parses the required ERC20 token amount. The typical case is that the bridge
295
+ # transactions fall into one of these cases:
296
+ # a. ERC20.approve + Bridge.deposit (bridge-specific tx), or
297
+ # b. ERC20.transfer
298
+ #
299
+ # Thus, the logic below assumes that there is only either an ERC20.approve OR ERC20.transfer (but not both).
300
+ # However, since the set of transactions is bridge-dependent, this might not always be the case, and
301
+ # is suggested that the requirements() logic be implemented per-provider.
302
+ if tx.get("to", "").lower() == from_token.lower():
303
+ data = tx.get("data", "").lower()
293
304
  try:
294
- amount = BigInt(tx["data"][-64:], 16)
295
- total_token += amount
305
+ if data.startswith(ERC20_APPROVE_SELECTOR):
306
+ amount_hex = data[-64:]
307
+ amount = BigInt(amount_hex, 16)
308
+ total_token += amount
309
+ elif data.startswith(ERC20_TRANSFER_SELECTOR):
310
+ amount_hex = data[10 + 64 : 10 + 64 + 64]
311
+ amount = BigInt(amount_hex, 16)
312
+ total_token += amount
296
313
  except Exception as e:
297
- raise RuntimeError("Malformed ERC20 approve transaction.") from e
314
+ raise RuntimeError("Malformed ERC20 transaction.") from e
298
315
 
299
316
  self.logger.info(
300
317
  f"[PROVIDER] Total gas fees for request {provider_request.id}: {total_gas_fees} native units."
@@ -824,7 +824,7 @@ def create_app( # pylint: disable=too-many-locals, unused-argument, too-many-st
824
824
 
825
825
  if transfer_excess_assets:
826
826
  asset_addresses = {ZERO_ADDRESS} | {
827
- token[chain] for token in ERC20_TOKENS.values()
827
+ token[chain] for token in ERC20_TOKENS.values() if chain in token
828
828
  }
829
829
  balances = get_assets_balances(
830
830
  ledger_api=ledger_api,
@@ -81,9 +81,10 @@ MECH_AGENT_FACTORY_JSON_URL = "https://raw.githubusercontent.com/valory-xyz/auto
81
81
  MECH_MARKETPLACE_JSON_URL = "https://raw.githubusercontent.com/valory-xyz/mech-quickstart/refs/heads/main/contracts/MechMarketplace.json"
82
82
  NO_STAKING_PROGRAM_ID = "no_staking"
83
83
 
84
-
85
84
  DEPLOYMENT_START_TRIES_NUM = 3
86
85
  IPFS_CHECK_URL = "https://gateway.autonolas.tech/ipfs/bafybeigcllaxn4ycjjvika3zd6eicksuriez2wtg67gx7pamhcazl3tv54/echo/README.md"
87
86
  MSG_NEW_PASSWORD_MISSING = "'new_password' is required." # nosec
88
87
  MSG_INVALID_PASSWORD = "Password is not valid." # nosec
89
88
  MSG_INVALID_MNEMONIC = "Seed phrase is not valid." # nosec
89
+
90
+ POLY_SAFE_SERVICE_NAMES = frozenset(("polymarket_trader",))
@@ -189,6 +189,12 @@ USDC: t.Dict[Chain, str] = {
189
189
  Chain.POLYGON: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
190
190
  }
191
191
 
192
+ USDC_E: t.Dict[Chain, str] = {
193
+ Chain.GNOSIS: "0x2a22f9c3b484c3629090FeED35F17Ff8F88f76F0",
194
+ Chain.OPTIMISM: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607",
195
+ Chain.POLYGON: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
196
+ }
197
+
192
198
  WRAPPED_NATIVE_ASSET = {
193
199
  Chain.ARBITRUM_ONE: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
194
200
  Chain.BASE: "0x4200000000000000000000000000000000000006",
@@ -203,6 +209,7 @@ WRAPPED_NATIVE_ASSET = {
203
209
  ERC20_TOKENS = {
204
210
  "OLAS": OLAS,
205
211
  "USDC": USDC,
212
+ "USDC.e": USDC_E,
206
213
  "WRAPPED_NATIVE": WRAPPED_NATIVE_ASSET,
207
214
  }
208
215
 
@@ -252,7 +259,7 @@ DEFAULT_EOA_TOPUPS = {
252
259
  Chain.GNOSIS: {ZERO_ADDRESS: BigInt(750_000_000_000_000_000)},
253
260
  Chain.MODE: {ZERO_ADDRESS: BigInt(250_000_000_000_000)},
254
261
  Chain.OPTIMISM: {ZERO_ADDRESS: BigInt(2_500_000_000_000_000)},
255
- Chain.POLYGON: {ZERO_ADDRESS: BigInt(750_000_000_000_000_000)},
262
+ Chain.POLYGON: {ZERO_ADDRESS: BigInt(4_000_000_000_000_000_000)},
256
263
  }
257
264
 
258
265
  DEFAULT_EOA_TOPUPS_WITHOUT_SAFE = {
@@ -268,7 +275,7 @@ DEFAULT_RECOVERY_TOPUPS = {
268
275
  Chain.GNOSIS: {ZERO_ADDRESS: BigInt(187_500_000_000_000_000)},
269
276
  Chain.MODE: {ZERO_ADDRESS: BigInt(62_500_000_000_000)},
270
277
  Chain.OPTIMISM: {ZERO_ADDRESS: BigInt(625_000_000_000_000)},
271
- Chain.POLYGON: {ZERO_ADDRESS: BigInt(187_500_000_000_000_000)},
278
+ Chain.POLYGON: {ZERO_ADDRESS: BigInt(1_000_000_000_000_000_000)},
272
279
  }
273
280
 
274
281
  DEFAULT_EOA_THRESHOLD = 0.5
@@ -30,6 +30,7 @@ from http import HTTPStatus
30
30
  from pathlib import Path
31
31
 
32
32
  import requests
33
+ from aea.configurations.data_types import PublicId
33
34
  from aea.helpers.base import IPFSHash
34
35
  from aea_ledger_ethereum import LedgerApi
35
36
  from autonomy.chain.base import registry_contracts
@@ -45,6 +46,7 @@ from operate.constants import (
45
46
  IPFS_ADDRESS,
46
47
  MIN_AGENT_BOND,
47
48
  MIN_SECURITY_DEPOSIT,
49
+ POLY_SAFE_SERVICE_NAMES,
48
50
  ZERO_ADDRESS,
49
51
  )
50
52
  from operate.data import DATA_DIR
@@ -1114,6 +1116,7 @@ class ServiceManager:
1114
1116
  is_recovery_module_enabled = True
1115
1117
  else:
1116
1118
  reuse_multisig = True
1119
+ is_initial_funding = False
1117
1120
  is_recovery_module_enabled = (
1118
1121
  registry_contracts.gnosis_safe.is_module_enabled(
1119
1122
  ledger_api=sftxb.ledger_api,
@@ -1125,11 +1128,19 @@ class ServiceManager:
1125
1128
  self.logger.info(f"{reuse_multisig=}")
1126
1129
  self.logger.info(f"{is_recovery_module_enabled=}")
1127
1130
 
1131
+ service_public_id = PublicId.from_str(service.service_public_id())
1132
+ use_poly_safe = service_public_id.name in POLY_SAFE_SERVICE_NAMES
1133
+
1134
+ self.logger.info(f"{use_poly_safe=}")
1128
1135
  messages = sftxb.get_deploy_data_from_safe(
1129
1136
  service_id=chain_data.token,
1130
1137
  reuse_multisig=reuse_multisig,
1131
1138
  master_safe=safe,
1132
1139
  use_recovery_module=is_recovery_module_enabled,
1140
+ use_poly_safe=use_poly_safe,
1141
+ agent_eoa_crypto=self.keys_manager.get_crypto_instance(
1142
+ service.agent_addresses[0]
1143
+ ),
1133
1144
  )
1134
1145
  tx = sftxb.new_tx()
1135
1146
  for message in messages:
@@ -41,6 +41,7 @@ from autonomy.chain.constants import (
41
41
  GNOSIS_SAFE_PROXY_FACTORY_CONTRACT,
42
42
  GNOSIS_SAFE_SAME_ADDRESS_MULTISIG_CONTRACT,
43
43
  MULTISEND_CONTRACT,
44
+ POLY_SAFE_CREATOR_WITH_RECOVERY_MODULE_CONTRACT,
44
45
  RECOVERY_MODULE_CONTRACT,
45
46
  SAFE_MULTISIG_WITH_RECOVERY_MODULE_CONTRACT,
46
47
  )
@@ -49,6 +50,7 @@ from autonomy.chain.service import (
49
50
  get_agent_instances,
50
51
  get_deployment_payload,
51
52
  get_deployment_with_recovery_payload,
53
+ get_poly_safe_deployment_payload,
52
54
  get_service_info,
53
55
  get_token_deposit_amount,
54
56
  )
@@ -1408,12 +1410,14 @@ class EthSafeTxBuilder(_ChainUtil):
1408
1410
  "value": cost_of_bond,
1409
1411
  }
1410
1412
 
1411
- def get_deploy_data_from_safe(
1413
+ def get_deploy_data_from_safe( # pylint: disable=too-many-arguments
1412
1414
  self,
1413
1415
  service_id: int,
1414
1416
  master_safe: str,
1415
1417
  reuse_multisig: bool = False,
1416
1418
  use_recovery_module: bool = True,
1419
+ use_poly_safe: bool = False,
1420
+ agent_eoa_crypto: t.Optional[Crypto] = None,
1417
1421
  ) -> t.List[t.Dict[str, t.Any]]:
1418
1422
  """Get the deploy data instructions for a safe"""
1419
1423
  approve_hash_message = None
@@ -1452,12 +1456,28 @@ class EthSafeTxBuilder(_ChainUtil):
1452
1456
  RECOVERY_MODULE_CONTRACT.name
1453
1457
  ).contracts[self.chain_type]
1454
1458
  else: # Deploy a new multisig
1455
- if not use_recovery_module:
1459
+ if not use_recovery_module and not use_poly_safe:
1456
1460
  deployment_payload = get_deployment_payload()
1457
1461
  gnosis_safe_multisig = ContractConfigs.get(
1458
1462
  GNOSIS_SAFE_PROXY_FACTORY_CONTRACT.name
1459
1463
  ).contracts[self.chain_type]
1460
- else:
1464
+ elif use_recovery_module and use_poly_safe:
1465
+ if not agent_eoa_crypto:
1466
+ raise ValueError("Crypto object must be provided for Poly Safe.")
1467
+
1468
+ deployment_payload = get_poly_safe_deployment_payload(
1469
+ ledger_api=self.ledger_api,
1470
+ chain_type=self.chain_type,
1471
+ crypto=agent_eoa_crypto,
1472
+ )
1473
+ gnosis_safe_multisig = ContractConfigs.get(
1474
+ POLY_SAFE_CREATOR_WITH_RECOVERY_MODULE_CONTRACT.name
1475
+ ).contracts[self.chain_type]
1476
+ elif not use_recovery_module and use_poly_safe:
1477
+ raise ValueError(
1478
+ "Poly Safe deployment without recovery module is not supported."
1479
+ )
1480
+ else: # Normal case: use_recovery_module and not use_poly_safe
1461
1481
  deployment_payload = get_deployment_with_recovery_payload()
1462
1482
  gnosis_safe_multisig = ContractConfigs.get(
1463
1483
  SAFE_MULTISIG_WITH_RECOVERY_MODULE_CONTRACT.name
@@ -1047,22 +1047,23 @@ class Service(LocalResource):
1047
1047
  AchievementsNotifications, AchievementsNotifications.load(self.path)
1048
1048
  )
1049
1049
 
1050
- agent_achievements_json_path = (
1050
+ agent_performance_json_path = (
1051
1051
  Path(
1052
1052
  self.env_variables.get(
1053
1053
  AGENT_PERSISTENT_STORAGE_ENV_VAR, {"value": "."}
1054
1054
  ).get("value", ".")
1055
1055
  )
1056
- / "achievements.json"
1056
+ / "agent_performance.json"
1057
1057
  )
1058
1058
 
1059
1059
  agent_achievements: t.Dict[str, t.Any] = {}
1060
- if agent_achievements_json_path.exists():
1060
+ if agent_performance_json_path.exists():
1061
1061
  try:
1062
- with open(agent_achievements_json_path, "r", encoding="utf-8") as f:
1063
- agent_achievements = json.load(f)
1062
+ with open(agent_performance_json_path, "r", encoding="utf-8") as f:
1063
+ data = json.load(f)
1064
+ agent_achievements = data.get("achievements", {}).get("items", {})
1064
1065
  except (json.JSONDecodeError, OSError) as e:
1065
- print(f"Error reading file 'achievements.json': {e}")
1066
+ logger.warning(f"Cannot read file 'agent_performance.json': {e}")
1066
1067
 
1067
1068
  save_changes = False
1068
1069
  for achievement_id in agent_achievements:
@@ -547,7 +547,9 @@ class EthereumMasterWallet(MasterWallet):
547
547
  rpc: t.Optional[str] = None,
548
548
  ) -> None:
549
549
  """Drain all erc20/native assets to the given account."""
550
- assets = [token[chain] for token in ERC20_TOKENS.values()] + [ZERO_ADDRESS]
550
+ assets = [token[chain] for token in ERC20_TOKENS.values() if chain in token] + [
551
+ ZERO_ADDRESS
552
+ ]
551
553
  for asset in assets:
552
554
  balance = self.get_balance(chain=chain, asset=asset, from_safe=from_safe)
553
555
  if balance <= 0:
@@ -783,7 +785,9 @@ class EthereumMasterWallet(MasterWallet):
783
785
 
784
786
  balances[chain_str] = {self.address: {}, safe: {}}
785
787
 
786
- assets = [token[chain] for token in ERC20_TOKENS.values()] + [ZERO_ADDRESS]
788
+ assets = [
789
+ token[chain] for token in ERC20_TOKENS.values() if chain in token
790
+ ] + [ZERO_ADDRESS]
787
791
  for asset in assets:
788
792
  balances[chain_str][self.address][asset] = str(
789
793
  self.get_balance(chain=chain, asset=asset, from_safe=False)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "olas-operate-middleware"
3
- version = "0.14.4"
3
+ version = "0.14.6"
4
4
  description = ""
5
5
  authors = ["David Vilela <dvilelaf@gmail.com>", "Viraj Patel <vptl185@gmail.com>"]
6
6
  readme = "README.md"