olas-operate-middleware 0.12.0__py3-none-any.whl → 0.12.2__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.12.0.dist-info → olas_operate_middleware-0.12.2.dist-info}/METADATA +1 -1
- {olas_operate_middleware-0.12.0.dist-info → olas_operate_middleware-0.12.2.dist-info}/RECORD +12 -12
- operate/bridge/bridge_manager.py +52 -42
- operate/bridge/providers/native_bridge_provider.py +26 -13
- operate/data/contracts/l1_standard_bridge/contract.py +20 -0
- operate/data/contracts/l1_standard_bridge/contract.yaml +1 -1
- operate/migration.py +3 -1
- operate/quickstart/run_service.py +2 -0
- operate/services/protocol.py +24 -13
- {olas_operate_middleware-0.12.0.dist-info → olas_operate_middleware-0.12.2.dist-info}/WHEEL +0 -0
- {olas_operate_middleware-0.12.0.dist-info → olas_operate_middleware-0.12.2.dist-info}/entry_points.txt +0 -0
- {olas_operate_middleware-0.12.0.dist-info → olas_operate_middleware-0.12.2.dist-info}/licenses/LICENSE +0 -0
{olas_operate_middleware-0.12.0.dist-info → olas_operate_middleware-0.12.2.dist-info}/RECORD
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
operate/__init__.py,sha256=PY5BUTF5cmNI-7UwAj2jJlPl6KJ44LoY5e16p7IrE3g,1335
|
|
2
2
|
operate/account/__init__.py,sha256=suJ_vBMO7hLCvLYe3MVDtLXTNDd6P03og7bvUN7fZsE,804
|
|
3
3
|
operate/account/user.py,sha256=y7DqqDpqgHjbVmnfL_cN0Me_JWl3Dh6GSVt2-9FdRVw,3044
|
|
4
|
-
operate/bridge/bridge_manager.py,sha256=
|
|
4
|
+
operate/bridge/bridge_manager.py,sha256=K5DMYGqgX0xw3pxzZXrwnCQ8ZKpy-HVsfNRM185xb5g,17445
|
|
5
5
|
operate/bridge/providers/lifi_provider.py,sha256=UzAeEnX9FGpnCYYml5lcICeEZeHHqNRCHkGZ-npgteo,14208
|
|
6
|
-
operate/bridge/providers/native_bridge_provider.py,sha256=
|
|
6
|
+
operate/bridge/providers/native_bridge_provider.py,sha256=vAx0MtVPIAxIdQ5OKSUDhnGurYVkC8tKVJRFK9NkIdk,25088
|
|
7
7
|
operate/bridge/providers/provider.py,sha256=KXp5CITCQ-fSOv2iFMOt8Wer1QGhBvJG0HN5Tnh5Qns,17287
|
|
8
8
|
operate/bridge/providers/relay_provider.py,sha256=4D2U8jrugh2DJZeSoxLCTVSZe8xMEwdCimqFDtfwWwc,17422
|
|
9
9
|
operate/cli.py,sha256=9IuYdcSv4fnLsvGBxwCav2A7pGXUncvT9InGzMchudM,68025
|
|
@@ -25,8 +25,8 @@ operate/data/contracts/home_omnibridge/contract.py,sha256=9kXhoZPVq-RSHCXb8jgFft
|
|
|
25
25
|
operate/data/contracts/home_omnibridge/contract.yaml,sha256=woRJPDWzpS26wjB2BcIv19lzS5TUVjJjd9CGiMv_q94,679
|
|
26
26
|
operate/data/contracts/l1_standard_bridge/__init__.py,sha256=u6pmgRIDXK0E1yCcNQNJXwfXLgc2hO-I1D3_eFCDQJQ,870
|
|
27
27
|
operate/data/contracts/l1_standard_bridge/build/L1StandardBridge.json,sha256=obGPvvhL3gwhyl-wE-U8tuDO6udMrcfycUjfwT5zzgo,41243
|
|
28
|
-
operate/data/contracts/l1_standard_bridge/contract.py,sha256=
|
|
29
|
-
operate/data/contracts/l1_standard_bridge/contract.yaml,sha256=
|
|
28
|
+
operate/data/contracts/l1_standard_bridge/contract.py,sha256=irwic3jXTNwPh1eBhANswzoPJlWWQEIJez3Alhyx3Kg,5128
|
|
29
|
+
operate/data/contracts/l1_standard_bridge/contract.yaml,sha256=PEGqG1z33Z6Bfi2o0RAGtB_UPseUYXThl5qmLeqOkCE,701
|
|
30
30
|
operate/data/contracts/l2_standard_bridge/__init__.py,sha256=DLSOdkVp7qYDtNkxK8R6rz8CkFNKHoEoW_uM1r1nL5I,870
|
|
31
31
|
operate/data/contracts/l2_standard_bridge/build/L2StandardBridge.json,sha256=Hr6X_oSP6_N7Txh4QJ9hf7Upb7WYk7fxooGlI0qV_8I,35581
|
|
32
32
|
operate/data/contracts/l2_standard_bridge/contract.py,sha256=GOzNkXxBRKLa6eDgNz6NN2MUWs8FFy58Io5GIdSp4MI,4498
|
|
@@ -60,7 +60,7 @@ operate/data/contracts/uniswap_v2_erc20/tests/test_contract.py,sha256=FzZbw9OTcr
|
|
|
60
60
|
operate/keys.py,sha256=ufnH4655vj0h7WGYMjPo-nwvVhZWRHdjyw4UYL-McIk,5959
|
|
61
61
|
operate/ledger/__init__.py,sha256=G0iWcA0Rc-Um8NwpwPJWsQNUQb2tWKyDjzirxPhGc98,6517
|
|
62
62
|
operate/ledger/profiles.py,sha256=7dxUFzjlT-VNpu9z45qeqPGyz5fDz0bM3LUK9VLcgJk,14272
|
|
63
|
-
operate/migration.py,sha256=
|
|
63
|
+
operate/migration.py,sha256=hjTKumZYWEW3G03Cd_bCV1JITn4JGgexR1sPbsEoAm0,19885
|
|
64
64
|
operate/operate_http/__init__.py,sha256=dxCIVSUos23M4R-PFZZG6k5QrOlEiK0SxhCYSFNxh7U,4711
|
|
65
65
|
operate/operate_http/exceptions.py,sha256=4UFzrn-GyDD71RhkaOyFPBynL6TrrtP3eywaaU3o4fc,1339
|
|
66
66
|
operate/operate_types.py,sha256=hGzYW47MPxOQuvDQAD_TqyIHxNReTeDYQI_uKrfJ1Jc,15570
|
|
@@ -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=ZlsRUiISQo4GVnIqB0-WmkvLeCW_ck2cRdEjIw5xMNI,2424
|
|
72
72
|
operate/quickstart/reset_staking.py,sha256=SB5LZq9EctG4SYn2M6oPZ7R7ARHSFLRGzAqfKkpRcy0,5111
|
|
73
|
-
operate/quickstart/run_service.py,sha256=
|
|
73
|
+
operate/quickstart/run_service.py,sha256=34T4TUijyzLFQim4NEJcdq5OyqbRxxE_E1IW_vXSo2A,27760
|
|
74
74
|
operate/quickstart/stop_service.py,sha256=CNcCucI4sqfZG0wTxxh-k14xGcbOh50UGyXqTZVQJP0,2048
|
|
75
75
|
operate/quickstart/terminate_on_chain_service.py,sha256=5ENU8_mkj06i80lKUX-v1QbLU0YzKeOZDUL1e_jzySE,2914
|
|
76
76
|
operate/quickstart/utils.py,sha256=jvi7IgPtJEWf7-ciZFyEh_jgNthhv3Pus4VZa_Ha_ms,9221
|
|
@@ -81,7 +81,7 @@ operate/services/deployment_runner.py,sha256=DHtp-DLOKNCT-8WR76cnuVKVxeCd1ZPY8sm
|
|
|
81
81
|
operate/services/funding_manager.py,sha256=v7ypERcYhzts2ESK6Wuvy5pckwlyZQ8pd4rfB4ogcC0,38533
|
|
82
82
|
operate/services/health_checker.py,sha256=r_lMlRZu-UNfqaM-Zo5_cWjsigdqYTAty4h-ISpM7RE,9859
|
|
83
83
|
operate/services/manage.py,sha256=ybpQ0Wqd9SESdhb3S-eqFs-Df7I4shfRcPO3pMHe0FI,112800
|
|
84
|
-
operate/services/protocol.py,sha256=
|
|
84
|
+
operate/services/protocol.py,sha256=DHu3TzaDuwTtidoEp7kGlbTAWw8pPbLjbyvanuyyjJs,72285
|
|
85
85
|
operate/services/service.py,sha256=XojE2r-GaatAl-vmAKWC3qj7YyrfYjmJ6kLCv4JbNwY,44376
|
|
86
86
|
operate/services/utils/__init__.py,sha256=TvioaZ1mfTRUSCtrQoLNAp4WMVXyqEJqFJM4PxSQCRU,24
|
|
87
87
|
operate/services/utils/mech.py,sha256=W2x4dqodivNKXjWU-Brp40QhoUHsIMyNAO7-caMoR0Q,3821
|
|
@@ -94,8 +94,8 @@ operate/utils/ssl.py,sha256=O5DrDoZD4T4qQuHP8GLwWUVxQ-1qXeefGp6uDJiF2lM,4308
|
|
|
94
94
|
operate/wallet/__init__.py,sha256=NGiozD3XhvkBi7_FaOWQ8x1thZPK4uGpokJaeDY_o2w,813
|
|
95
95
|
operate/wallet/master.py,sha256=gcax6M8_KT2IkL0kGZP4lF4f2updoP5r6ix5e72ZrL4,33674
|
|
96
96
|
operate/wallet/wallet_recovery_manager.py,sha256=ZOLq0B9irux_og8pLBzaxlRA1r6RqJfZA4j4RX0kzoU,7775
|
|
97
|
-
olas_operate_middleware-0.12.
|
|
98
|
-
olas_operate_middleware-0.12.
|
|
99
|
-
olas_operate_middleware-0.12.
|
|
100
|
-
olas_operate_middleware-0.12.
|
|
101
|
-
olas_operate_middleware-0.12.
|
|
97
|
+
olas_operate_middleware-0.12.2.dist-info/METADATA,sha256=G-t5M3ar2O1zW4YKuP_DsUSVpPXrt7OJQrN-4wb-fck,2139
|
|
98
|
+
olas_operate_middleware-0.12.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
99
|
+
olas_operate_middleware-0.12.2.dist-info/entry_points.txt,sha256=dM1g2I7ODApKQFcgl5J4NGA7pfBTo6qsUTXM-j2OLlw,44
|
|
100
|
+
olas_operate_middleware-0.12.2.dist-info/licenses/LICENSE,sha256=mdBDB-mWKV5Cz4ejBzBiKqan6Z8zVLAh9xwM64O2FW4,11339
|
|
101
|
+
olas_operate_middleware-0.12.2.dist-info/RECORD,,
|
operate/bridge/bridge_manager.py
CHANGED
|
@@ -57,52 +57,60 @@ RELAY_PROVIDER_ID = "relay-provider"
|
|
|
57
57
|
|
|
58
58
|
NATIVE_BRIDGE_PROVIDER_CONFIGS: t.Dict[str, t.Any] = {
|
|
59
59
|
"native-ethereum-to-base": {
|
|
60
|
-
"from_chain":
|
|
60
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
61
61
|
"from_bridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
|
|
62
|
-
"to_chain":
|
|
62
|
+
"to_chain": Chain.BASE.value,
|
|
63
63
|
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
64
64
|
"bridge_eta": 300,
|
|
65
65
|
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
66
66
|
},
|
|
67
|
+
"native-ethereum-to-celo": {
|
|
68
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
69
|
+
"from_bridge": "0x9C4955b92F34148dbcfDCD82e9c9eCe5CF2badfe",
|
|
70
|
+
"to_chain": Chain.CELO.value,
|
|
71
|
+
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
72
|
+
"bridge_eta": 300,
|
|
73
|
+
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
74
|
+
},
|
|
75
|
+
"native-ethereum-to-gnosis": {
|
|
76
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
77
|
+
"from_bridge": "0x88ad09518695c6c3712AC10a214bE5109a655671",
|
|
78
|
+
"to_chain": Chain.GNOSIS.value,
|
|
79
|
+
"to_bridge": "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d",
|
|
80
|
+
"bridge_eta": 1800,
|
|
81
|
+
"bridge_contract_adaptor_class": OmnibridgeContractAdaptor,
|
|
82
|
+
},
|
|
67
83
|
"native-ethereum-to-mode": {
|
|
68
|
-
"from_chain":
|
|
84
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
69
85
|
"from_bridge": "0x735aDBbE72226BD52e818E7181953f42E3b0FF21",
|
|
70
|
-
"to_chain":
|
|
86
|
+
"to_chain": Chain.MODE.value,
|
|
71
87
|
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
72
88
|
"bridge_eta": 300,
|
|
73
89
|
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
74
90
|
},
|
|
75
91
|
"native-ethereum-to-optimism": {
|
|
76
|
-
"from_chain":
|
|
92
|
+
"from_chain": Chain.ETHEREUM.value,
|
|
77
93
|
"from_bridge": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1",
|
|
78
|
-
"to_chain":
|
|
94
|
+
"to_chain": Chain.OPTIMISM.value,
|
|
79
95
|
"to_bridge": "0x4200000000000000000000000000000000000010",
|
|
80
96
|
"bridge_eta": 300,
|
|
81
97
|
"bridge_contract_adaptor_class": OptimismContractAdaptor,
|
|
82
98
|
},
|
|
83
|
-
"native-ethereum-to-gnosis": {
|
|
84
|
-
"from_chain": "ethereum",
|
|
85
|
-
"from_bridge": "0x88ad09518695c6c3712AC10a214bE5109a655671",
|
|
86
|
-
"to_chain": "gnosis",
|
|
87
|
-
"to_bridge": "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d",
|
|
88
|
-
"bridge_eta": 1800,
|
|
89
|
-
"bridge_contract_adaptor_class": OmnibridgeContractAdaptor,
|
|
90
|
-
},
|
|
91
99
|
}
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
# Routes are defined as the tuples (from_chain, from_token, to_chain, to_token)
|
|
102
|
+
PREFERRED_ROUTES = {
|
|
95
103
|
(
|
|
96
|
-
Chain.ETHEREUM,
|
|
97
|
-
USDC[Chain.ETHEREUM],
|
|
98
|
-
Chain.OPTIMISM,
|
|
99
|
-
USDC[Chain.OPTIMISM],
|
|
104
|
+
Chain.ETHEREUM,
|
|
105
|
+
USDC[Chain.ETHEREUM],
|
|
106
|
+
Chain.OPTIMISM,
|
|
107
|
+
USDC[Chain.OPTIMISM],
|
|
100
108
|
): LIFI_PROVIDER_ID,
|
|
101
109
|
(
|
|
102
|
-
Chain.ETHEREUM,
|
|
103
|
-
USDC[Chain.ETHEREUM],
|
|
104
|
-
Chain.BASE,
|
|
105
|
-
USDC[Chain.BASE],
|
|
110
|
+
Chain.ETHEREUM,
|
|
111
|
+
USDC[Chain.ETHEREUM],
|
|
112
|
+
Chain.BASE,
|
|
113
|
+
USDC[Chain.BASE],
|
|
106
114
|
): LIFI_PROVIDER_ID,
|
|
107
115
|
(Chain.ETHEREUM, ZERO_ADDRESS, Chain.GNOSIS, ZERO_ADDRESS): RELAY_PROVIDER_ID,
|
|
108
116
|
}
|
|
@@ -260,24 +268,26 @@ class BridgeManager:
|
|
|
260
268
|
|
|
261
269
|
provider_requests = []
|
|
262
270
|
for params in requests_params:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
271
|
+
route = (
|
|
272
|
+
Chain(params["from"]["chain"]),
|
|
273
|
+
params["from"]["token"],
|
|
274
|
+
Chain(params["to"]["chain"]),
|
|
275
|
+
params["to"]["token"],
|
|
276
|
+
)
|
|
277
|
+
provider_id = PREFERRED_ROUTES.get(route)
|
|
278
|
+
|
|
279
|
+
if not provider_id:
|
|
280
|
+
for provider in self._native_bridge_providers.values():
|
|
281
|
+
if provider.can_handle_request(params):
|
|
282
|
+
provider_id = provider.provider_id
|
|
283
|
+
break
|
|
284
|
+
|
|
285
|
+
if not provider_id:
|
|
286
|
+
provider_id = RELAY_PROVIDER_ID
|
|
287
|
+
|
|
288
|
+
provider_requests.append(
|
|
289
|
+
self._providers[provider_id].create_request(params=params)
|
|
290
|
+
)
|
|
281
291
|
|
|
282
292
|
bundle = ProviderRequestBundle(
|
|
283
293
|
id=f"{BRIDGE_REQUEST_BUNDLE_PREFIX}{uuid.uuid4()}",
|
|
@@ -53,7 +53,11 @@ from operate.data.contracts.l2_standard_bridge.contract import L2StandardBridge
|
|
|
53
53
|
from operate.data.contracts.optimism_mintable_erc20.contract import (
|
|
54
54
|
OptimismMintableERC20,
|
|
55
55
|
)
|
|
56
|
-
from operate.ledger import
|
|
56
|
+
from operate.ledger import (
|
|
57
|
+
get_default_ledger_api,
|
|
58
|
+
update_tx_with_gas_estimate,
|
|
59
|
+
update_tx_with_gas_pricing,
|
|
60
|
+
)
|
|
57
61
|
from operate.ledger.profiles import ERC20_TOKENS, EXPLORER_URL
|
|
58
62
|
from operate.operate_types import Chain
|
|
59
63
|
from operate.wallet.master import MasterWalletManager
|
|
@@ -75,13 +79,15 @@ class BridgeContractAdaptor(ABC):
|
|
|
75
79
|
) -> None:
|
|
76
80
|
"""Initialize the bridge contract adaptor."""
|
|
77
81
|
super().__init__()
|
|
82
|
+
if from_chain == to_chain:
|
|
83
|
+
raise ValueError("from_chain and to_chain cannot be the same.")
|
|
78
84
|
self.from_chain = from_chain
|
|
79
85
|
self.from_bridge = from_bridge
|
|
80
86
|
self.to_chain = to_chain
|
|
81
87
|
self.to_bridge = to_bridge
|
|
82
88
|
self.bridge_eta = bridge_eta
|
|
83
89
|
|
|
84
|
-
def can_handle_request(self,
|
|
90
|
+
def can_handle_request(self, params: t.Dict) -> bool:
|
|
85
91
|
"""Returns 'true' if the contract adaptor can handle a request for 'params'."""
|
|
86
92
|
from_chain = params["from"]["chain"]
|
|
87
93
|
from_token = Web3.to_checksum_address(params["from"]["token"])
|
|
@@ -158,11 +164,24 @@ class OptimismContractAdaptor(BridgeContractAdaptor):
|
|
|
158
164
|
),
|
|
159
165
|
)
|
|
160
166
|
|
|
161
|
-
def can_handle_request(self,
|
|
167
|
+
def can_handle_request(self, params: t.Dict) -> bool:
|
|
162
168
|
"""Returns 'true' if the contract adaptor can handle a request for 'params'."""
|
|
163
169
|
|
|
170
|
+
if not super().can_handle_request(params):
|
|
171
|
+
return False
|
|
172
|
+
|
|
173
|
+
from_chain = params["from"]["chain"]
|
|
164
174
|
from_token = Web3.to_checksum_address(params["from"]["token"])
|
|
175
|
+
from_ledger_api = get_default_ledger_api(Chain(from_chain))
|
|
176
|
+
to_chain = params["to"]["chain"]
|
|
165
177
|
to_token = Web3.to_checksum_address(params["to"]["token"])
|
|
178
|
+
to_ledger_api = get_default_ledger_api(Chain(to_chain))
|
|
179
|
+
|
|
180
|
+
if from_token == ZERO_ADDRESS and to_token == ZERO_ADDRESS:
|
|
181
|
+
if not self._l1_standard_bridge_contract.supports_bridge_eth_to(
|
|
182
|
+
ledger_api=from_ledger_api, contract_address=self.from_bridge
|
|
183
|
+
):
|
|
184
|
+
return False
|
|
166
185
|
|
|
167
186
|
if to_token != ZERO_ADDRESS:
|
|
168
187
|
try:
|
|
@@ -176,7 +195,7 @@ class OptimismContractAdaptor(BridgeContractAdaptor):
|
|
|
176
195
|
except Exception: # pylint: disable=broad-except
|
|
177
196
|
return False
|
|
178
197
|
|
|
179
|
-
return
|
|
198
|
+
return True
|
|
180
199
|
|
|
181
200
|
def build_bridge_tx(
|
|
182
201
|
self, from_ledger_api: LedgerApi, provider_request: ProviderRequest
|
|
@@ -288,13 +307,13 @@ class OmnibridgeContractAdaptor(BridgeContractAdaptor):
|
|
|
288
307
|
),
|
|
289
308
|
)
|
|
290
309
|
|
|
291
|
-
def can_handle_request(self,
|
|
310
|
+
def can_handle_request(self, params: t.Dict) -> bool:
|
|
292
311
|
"""Returns 'true' if the contract adaptor can handle a request for 'params'."""
|
|
293
312
|
from_token = Web3.to_checksum_address(params["from"]["token"])
|
|
294
313
|
if from_token == ZERO_ADDRESS:
|
|
295
314
|
return False
|
|
296
315
|
|
|
297
|
-
return super().can_handle_request(
|
|
316
|
+
return super().can_handle_request(params)
|
|
298
317
|
|
|
299
318
|
def build_bridge_tx(
|
|
300
319
|
self, from_ledger_api: LedgerApi, provider_request: ProviderRequest
|
|
@@ -428,16 +447,10 @@ class NativeBridgeProvider(Provider):
|
|
|
428
447
|
|
|
429
448
|
def can_handle_request(self, params: t.Dict) -> bool:
|
|
430
449
|
"""Returns 'true' if the provider can handle a request for 'params'."""
|
|
431
|
-
|
|
432
450
|
if not super().can_handle_request(params):
|
|
433
451
|
return False
|
|
434
452
|
|
|
435
|
-
|
|
436
|
-
chain = Chain(to_chain)
|
|
437
|
-
wallet = self.wallet_manager.load(chain.ledger_type)
|
|
438
|
-
to_ledger_api = wallet.ledger_api(chain)
|
|
439
|
-
|
|
440
|
-
if not self.bridge_contract_adaptor.can_handle_request(to_ledger_api, params):
|
|
453
|
+
if not self.bridge_contract_adaptor.can_handle_request(params):
|
|
441
454
|
return False
|
|
442
455
|
|
|
443
456
|
return True
|
|
@@ -45,6 +45,26 @@ class L1StandardBridge(Contract):
|
|
|
45
45
|
|
|
46
46
|
contract_id = PublicId.from_str("valory/l1_standard_bridge:0.1.0")
|
|
47
47
|
|
|
48
|
+
@classmethod
|
|
49
|
+
def supports_bridge_eth_to(
|
|
50
|
+
cls,
|
|
51
|
+
ledger_api: LedgerApi,
|
|
52
|
+
contract_address: str,
|
|
53
|
+
) -> bool:
|
|
54
|
+
"""Checks if native ETH bridging via `bridgeETHTo` is supported."""
|
|
55
|
+
contract_instance = cls.get_instance(
|
|
56
|
+
ledger_api=ledger_api, contract_address=contract_address
|
|
57
|
+
)
|
|
58
|
+
try:
|
|
59
|
+
contract_instance.functions.bridgeETHTo(
|
|
60
|
+
"0x0000000000000000000000000000000000000000",
|
|
61
|
+
0,
|
|
62
|
+
b""
|
|
63
|
+
).call({"from": PLACEHOLDER_NATIVE_TOKEN_ADDRESS, "value": 0})
|
|
64
|
+
return True
|
|
65
|
+
except Exception: # pylint: disable=broad-except
|
|
66
|
+
return False
|
|
67
|
+
|
|
48
68
|
@classmethod
|
|
49
69
|
def build_bridge_eth_to_tx(
|
|
50
70
|
cls,
|
|
@@ -8,7 +8,7 @@ aea_version: '>=1.0.0, <2.0.0'
|
|
|
8
8
|
fingerprint:
|
|
9
9
|
__init__.py: bafybeifsbxn6hlccnpgqnpvaz3ph6ajl4is4mcyerr6aqp7heggagcphye
|
|
10
10
|
build/L1StandardBridge.json: bafybeidq6jt7zmedtuxbbyggiqhu7w6543bunyd2vrbibg6y2svxsi2q5m
|
|
11
|
-
contract.py:
|
|
11
|
+
contract.py: bafybeienitro6gds2ny7guziwdu3uapmj3xxuzmqyvsect4zqmrouity2e
|
|
12
12
|
fingerprint_ignore_patterns: []
|
|
13
13
|
contracts: []
|
|
14
14
|
class_name: L1StandardBridge
|
operate/migration.py
CHANGED
|
@@ -468,7 +468,9 @@ class MigrationManager:
|
|
|
468
468
|
or key_file.suffix == ".bak"
|
|
469
469
|
or not Web3.is_address(key_file.name)
|
|
470
470
|
):
|
|
471
|
-
|
|
471
|
+
if not key_file.suffix == ".bak":
|
|
472
|
+
self.logger.warning(f"Skipping non-key file: {key_file}")
|
|
473
|
+
|
|
472
474
|
continue
|
|
473
475
|
|
|
474
476
|
migrated = False
|
|
@@ -37,6 +37,7 @@ from operate.account.user import UserAccount
|
|
|
37
37
|
from operate.constants import IPFS_ADDRESS, NO_STAKING_PROGRAM_ID, USER_JSON
|
|
38
38
|
from operate.data import DATA_DIR
|
|
39
39
|
from operate.data.contracts.staking_token.contract import StakingTokenContract
|
|
40
|
+
from operate.ledger import DEFAULT_RPCS
|
|
40
41
|
from operate.ledger.profiles import STAKING, get_staking_contract
|
|
41
42
|
from operate.operate_types import (
|
|
42
43
|
Chain,
|
|
@@ -205,6 +206,7 @@ def configure_local_config(
|
|
|
205
206
|
f"{chain.upper()}_LEDGER_RPC",
|
|
206
207
|
)
|
|
207
208
|
os.environ[f"{chain.upper()}_LEDGER_RPC"] = config.rpc[chain]
|
|
209
|
+
DEFAULT_RPCS[Chain.from_string(chain)] = config.rpc[chain]
|
|
208
210
|
|
|
209
211
|
config.principal_chain = template["home_chain"]
|
|
210
212
|
|
operate/services/protocol.py
CHANGED
|
@@ -28,7 +28,7 @@ import os
|
|
|
28
28
|
import tempfile
|
|
29
29
|
import typing as t
|
|
30
30
|
from enum import Enum
|
|
31
|
-
from functools import cache
|
|
31
|
+
from functools import cache, cached_property
|
|
32
32
|
from pathlib import Path
|
|
33
33
|
from typing import Optional, Union, cast
|
|
34
34
|
|
|
@@ -780,6 +780,17 @@ class _ChainUtil:
|
|
|
780
780
|
rpc=self.rpc,
|
|
781
781
|
)
|
|
782
782
|
|
|
783
|
+
@cached_property
|
|
784
|
+
def service_manager_address(self) -> str: # TODO: backport to OA
|
|
785
|
+
"""Get service manager contract address."""
|
|
786
|
+
service_registry = registry_contracts.service_registry.get_instance(
|
|
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()
|
|
793
|
+
|
|
783
794
|
@property
|
|
784
795
|
def service_manager_instance(self) -> Contract:
|
|
785
796
|
"""Load service manager contract instance."""
|
|
@@ -788,7 +799,7 @@ class _ChainUtil:
|
|
|
788
799
|
)
|
|
789
800
|
instance = self.ledger_api.get_contract_instance(
|
|
790
801
|
contract_interface,
|
|
791
|
-
self.
|
|
802
|
+
self.service_manager_address,
|
|
792
803
|
)
|
|
793
804
|
return instance
|
|
794
805
|
|
|
@@ -1334,7 +1345,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1334
1345
|
)
|
|
1335
1346
|
|
|
1336
1347
|
return {
|
|
1337
|
-
"to": self.
|
|
1348
|
+
"to": self.service_manager_address,
|
|
1338
1349
|
"data": txd[2:],
|
|
1339
1350
|
"operation": MultiSendOperation.CALL,
|
|
1340
1351
|
"value": 0,
|
|
@@ -1366,7 +1377,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1366
1377
|
"""Get activate tx data."""
|
|
1367
1378
|
instance = registry_contracts.service_manager.get_instance(
|
|
1368
1379
|
ledger_api=self.ledger_api,
|
|
1369
|
-
contract_address=self.
|
|
1380
|
+
contract_address=self.service_manager_address,
|
|
1370
1381
|
)
|
|
1371
1382
|
txd = instance.encodeABI(
|
|
1372
1383
|
fn_name="activateRegistration",
|
|
@@ -1374,7 +1385,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1374
1385
|
)
|
|
1375
1386
|
return {
|
|
1376
1387
|
"from": self.safe,
|
|
1377
|
-
"to": self.
|
|
1388
|
+
"to": self.service_manager_address,
|
|
1378
1389
|
"data": txd[2:],
|
|
1379
1390
|
"operation": MultiSendOperation.CALL,
|
|
1380
1391
|
"value": cost_of_bond,
|
|
@@ -1390,7 +1401,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1390
1401
|
"""Get register instances tx data."""
|
|
1391
1402
|
instance = registry_contracts.service_manager.get_instance(
|
|
1392
1403
|
ledger_api=self.ledger_api,
|
|
1393
|
-
contract_address=self.
|
|
1404
|
+
contract_address=self.service_manager_address,
|
|
1394
1405
|
)
|
|
1395
1406
|
txd = instance.encodeABI(
|
|
1396
1407
|
fn_name="registerAgents",
|
|
@@ -1402,7 +1413,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1402
1413
|
)
|
|
1403
1414
|
return {
|
|
1404
1415
|
"from": self.safe,
|
|
1405
|
-
"to": self.
|
|
1416
|
+
"to": self.service_manager_address,
|
|
1406
1417
|
"data": txd[2:],
|
|
1407
1418
|
"operation": MultiSendOperation.CALL,
|
|
1408
1419
|
"value": cost_of_bond,
|
|
@@ -1418,7 +1429,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1418
1429
|
"""Get the deploy data instructions for a safe"""
|
|
1419
1430
|
registry_instance = registry_contracts.service_manager.get_instance(
|
|
1420
1431
|
ledger_api=self.ledger_api,
|
|
1421
|
-
contract_address=self.
|
|
1432
|
+
contract_address=self.service_manager_address,
|
|
1422
1433
|
)
|
|
1423
1434
|
approve_hash_message = None
|
|
1424
1435
|
if reuse_multisig:
|
|
@@ -1476,7 +1487,7 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1476
1487
|
],
|
|
1477
1488
|
)
|
|
1478
1489
|
deploy_message = {
|
|
1479
|
-
"to": self.
|
|
1490
|
+
"to": self.service_manager_address,
|
|
1480
1491
|
"data": deploy_data[2:],
|
|
1481
1492
|
"operation": MultiSendOperation.CALL,
|
|
1482
1493
|
"value": 0,
|
|
@@ -1665,14 +1676,14 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1665
1676
|
"""Get terminate tx data."""
|
|
1666
1677
|
instance = registry_contracts.service_manager.get_instance(
|
|
1667
1678
|
ledger_api=self.ledger_api,
|
|
1668
|
-
contract_address=self.
|
|
1679
|
+
contract_address=self.service_manager_address,
|
|
1669
1680
|
)
|
|
1670
1681
|
txd = instance.encodeABI(
|
|
1671
1682
|
fn_name="terminate",
|
|
1672
1683
|
args=[service_id],
|
|
1673
1684
|
)
|
|
1674
1685
|
return {
|
|
1675
|
-
"to": self.
|
|
1686
|
+
"to": self.service_manager_address,
|
|
1676
1687
|
"data": txd[2:],
|
|
1677
1688
|
"operation": MultiSendOperation.CALL,
|
|
1678
1689
|
"value": 0,
|
|
@@ -1682,14 +1693,14 @@ class EthSafeTxBuilder(_ChainUtil):
|
|
|
1682
1693
|
"""Get unbond tx data."""
|
|
1683
1694
|
instance = registry_contracts.service_manager.get_instance(
|
|
1684
1695
|
ledger_api=self.ledger_api,
|
|
1685
|
-
contract_address=self.
|
|
1696
|
+
contract_address=self.service_manager_address,
|
|
1686
1697
|
)
|
|
1687
1698
|
txd = instance.encodeABI(
|
|
1688
1699
|
fn_name="unbond",
|
|
1689
1700
|
args=[service_id],
|
|
1690
1701
|
)
|
|
1691
1702
|
return {
|
|
1692
|
-
"to": self.
|
|
1703
|
+
"to": self.service_manager_address,
|
|
1693
1704
|
"data": txd[2:],
|
|
1694
1705
|
"operation": MultiSendOperation.CALL,
|
|
1695
1706
|
"value": 0,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|