olas-operate-middleware 0.14.0__py3-none-any.whl → 0.14.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: olas-operate-middleware
3
- Version: 0.14.0
3
+ Version: 0.14.1
4
4
  Summary:
5
5
  License-File: LICENSE
6
6
  Author: David Vilela
@@ -70,7 +70,7 @@ operate/quickstart/claim_staking_rewards.py,sha256=K7X1Yq0mxe3qWmFLb1Xu9-Jghhml9
70
70
  operate/quickstart/reset_configs.py,sha256=DVPM4mh6Djunwq16hf8lD9-nGkkm7wVtwr2JUXr1if8,3380
71
71
  operate/quickstart/reset_password.py,sha256=jEBk2ROR1q8PkTIHlqum7E8PRQtXHwrauiy0_bik3RQ,2394
72
72
  operate/quickstart/reset_staking.py,sha256=SB5LZq9EctG4SYn2M6oPZ7R7ARHSFLRGzAqfKkpRcy0,5111
73
- operate/quickstart/run_service.py,sha256=myncdvwHD9DDgjj6fBVC2Ju4SplfBUZnPyXu0Z2gNYg,30279
73
+ operate/quickstart/run_service.py,sha256=tt4PYeZJ2MtYeG59vohOdMbOiCYGGUmGnjeZwYl0shQ,30383
74
74
  operate/quickstart/stop_service.py,sha256=a3-1vVyZma2UtFUPKMvVrOso1Iwpz5Rzpus9VAI4qOc,2169
75
75
  operate/quickstart/terminate_on_chain_service.py,sha256=5ENU8_mkj06i80lKUX-v1QbLU0YzKeOZDUL1e_jzySE,2914
76
76
  operate/quickstart/utils.py,sha256=i1juhJCPkzB7ZKgSk5tNiRmYxGcx8MG-dTjVyC5sKys,9287
@@ -83,7 +83,7 @@ operate/services/funding_manager.py,sha256=q-mO6kQWthCLI5uW8qbrMQw_6i--zd1rJ3SG4
83
83
  operate/services/health_checker.py,sha256=dARikrgzU1jEuK4NUqlZ7N0DQq4Ah1ZiRKHmrlh8v-A,11472
84
84
  operate/services/manage.py,sha256=9dTjXhBq6tgcFWfhU61JQL67L2h3_b_7p8OICimWWB4,113292
85
85
  operate/services/protocol.py,sha256=4wAMHoELkqJJlETsMJa-XT8xVA0jfueiaKMn7X4SUKo,71898
86
- operate/services/service.py,sha256=g5P7DmOv-DtITTLJ3m2MdH8L5gMx0Nt50O06Jd3enW0,45407
86
+ operate/services/service.py,sha256=YOU0rlPe5PjDnFRlAcThYLvr5MrPOftBDKZHMRNzZ78,46647
87
87
  operate/services/utils/__init__.py,sha256=TvioaZ1mfTRUSCtrQoLNAp4WMVXyqEJqFJM4PxSQCRU,24
88
88
  operate/services/utils/mech.py,sha256=98gNw8pMNvv_O34V1blr7JUwenqxFeeyFuXLuSYv10w,3864
89
89
  operate/services/utils/tendermint.py,sha256=M4zjF97SOJomhmj97bWKIphnia30lbDie65fs_vy_q8,25686
@@ -95,8 +95,8 @@ operate/utils/ssl.py,sha256=O5DrDoZD4T4qQuHP8GLwWUVxQ-1qXeefGp6uDJiF2lM,4308
95
95
  operate/wallet/__init__.py,sha256=NGiozD3XhvkBi7_FaOWQ8x1thZPK4uGpokJaeDY_o2w,813
96
96
  operate/wallet/master.py,sha256=019VvWsMfzAV3fUienhcYVLB12BcSVvub3weAeMOlSA,33808
97
97
  operate/wallet/wallet_recovery_manager.py,sha256=kZIKBCIVb-ufntUoCE0IqAJ-Q2YUIl7955UYY6sp8Os,19856
98
- olas_operate_middleware-0.14.0.dist-info/METADATA,sha256=zv5wkUhi9SFBx0kX1eardkHgBIxoRO3EeT7EX41JtW8,1492
99
- olas_operate_middleware-0.14.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
100
- olas_operate_middleware-0.14.0.dist-info/entry_points.txt,sha256=dM1g2I7ODApKQFcgl5J4NGA7pfBTo6qsUTXM-j2OLlw,44
101
- olas_operate_middleware-0.14.0.dist-info/licenses/LICENSE,sha256=mdBDB-mWKV5Cz4ejBzBiKqan6Z8zVLAh9xwM64O2FW4,11339
102
- olas_operate_middleware-0.14.0.dist-info/RECORD,,
98
+ olas_operate_middleware-0.14.1.dist-info/METADATA,sha256=f-5TTJaF2_pDz2a0j7nRdvqdokleT2m2-gJ94jf2YI4,1492
99
+ olas_operate_middleware-0.14.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
100
+ olas_operate_middleware-0.14.1.dist-info/entry_points.txt,sha256=dM1g2I7ODApKQFcgl5J4NGA7pfBTo6qsUTXM-j2OLlw,44
101
+ olas_operate_middleware-0.14.1.dist-info/licenses/LICENSE,sha256=mdBDB-mWKV5Cz4ejBzBiKqan6Z8zVLAh9xwM64O2FW4,11339
102
+ olas_operate_middleware-0.14.1.dist-info/RECORD,,
@@ -46,6 +46,7 @@ from operate.ledger import DEFAULT_RPCS
46
46
  from operate.ledger.profiles import STAKING, get_staking_contract
47
47
  from operate.operate_types import (
48
48
  Chain,
49
+ ChainAmounts,
49
50
  LedgerType,
50
51
  ServiceEnvProvisionType,
51
52
  ServiceTemplate,
@@ -649,7 +650,9 @@ def _ask_funds_from_requirements(
649
650
  )
650
651
 
651
652
  if not requirements["is_refill_required"] and requirements["allow_start_agent"]:
652
- for chain_name, balances in requirements["balances"].items():
653
+ for chain_name, balances in ChainAmounts.from_json(
654
+ requirements["balances"]
655
+ ).items():
653
656
  ledger_api = wallet.ledger_api(
654
657
  chain=Chain(chain_name),
655
658
  rpc=service.chain_configs[chain_name].ledger_config.rpc,
@@ -662,17 +665,19 @@ def _ask_funds_from_requirements(
662
665
 
663
666
  return True
664
667
 
665
- for chain_name, chain_requirements in requirements["refill_requirements"].items():
668
+ for chain_name, chain_requirements in ChainAmounts.from_json(
669
+ requirements["refill_requirements"]
670
+ ).items():
666
671
  chain = Chain(chain_name)
667
672
  ledger_api = wallet.ledger_api(
668
673
  chain=chain,
669
674
  rpc=service.chain_configs[chain_name].ledger_config.rpc,
670
675
  )
671
- for wallet_address, requirements in chain_requirements.items():
676
+ for wallet_address, _requirements in chain_requirements.items():
672
677
  if wallet_address in ("master_safe", "service_safe"):
673
678
  continue # we can't ask funds in placeholder addresses
674
679
 
675
- for asset_address, requirement in requirements.items():
680
+ for asset_address, requirement in _requirements.items():
676
681
  ask_funds_in_address(
677
682
  ledger_api=ledger_api,
678
683
  chain=chain_name,
@@ -77,6 +77,7 @@ from operate.constants import (
77
77
  )
78
78
  from operate.keys import KeysManager
79
79
  from operate.ledger import get_default_ledger_api, get_default_rpc
80
+ from operate.ledger.profiles import WRAPPED_NATIVE_ASSET
80
81
  from operate.operate_http.exceptions import NotAllowed
81
82
  from operate.operate_types import (
82
83
  AgentRelease,
@@ -1200,10 +1201,13 @@ class Service(LocalResource):
1200
1201
 
1201
1202
  return amounts
1202
1203
 
1203
- def get_balances(self) -> ChainAmounts:
1204
- """Get balances of the agent addresses and service safe."""
1204
+ def get_balances(self, unify_wrapped_native_tokens: bool = True) -> ChainAmounts:
1205
+ """Get balances of the agent addresses and service safe.
1206
+
1207
+ :param unify_wrapped_native_tokens: Whether to consider wrapped native tokens as native tokens.
1208
+ """
1205
1209
  initial_funding_amounts = self.get_initial_funding_amounts()
1206
- return ChainAmounts(
1210
+ absolute_balances = ChainAmounts(
1207
1211
  {
1208
1212
  chain_str: {
1209
1213
  address: {
@@ -1222,6 +1226,27 @@ class Service(LocalResource):
1222
1226
  for chain_str, addresses in initial_funding_amounts.items()
1223
1227
  }
1224
1228
  )
1229
+ if unify_wrapped_native_tokens:
1230
+ for chain_str, addresses in absolute_balances.items():
1231
+ chain = Chain.from_string(chain_str)
1232
+ wrapped_asset = WRAPPED_NATIVE_ASSET[chain]
1233
+ for address, assets in addresses.items():
1234
+ if ZERO_ADDRESS in assets or wrapped_asset in assets:
1235
+ if ZERO_ADDRESS not in assets:
1236
+ assets[ZERO_ADDRESS] = 0
1237
+
1238
+ if wrapped_asset in assets:
1239
+ assets[ZERO_ADDRESS] += assets[wrapped_asset]
1240
+ del assets[wrapped_asset]
1241
+ else:
1242
+ assets[ZERO_ADDRESS] += get_asset_balance(
1243
+ ledger_api=get_default_ledger_api(chain),
1244
+ asset_address=wrapped_asset,
1245
+ address=address,
1246
+ raise_on_invalid_address=False,
1247
+ )
1248
+
1249
+ return absolute_balances
1225
1250
 
1226
1251
  def get_funding_requests(self) -> ChainAmounts:
1227
1252
  """Get funding amounts requested by the agent."""