diff --git a/docs/package_list.md b/docs/package_list.md index 763b437573..1be02360c2 100644 --- a/docs/package_list.md +++ b/docs/package_list.md @@ -1,41 +1,41 @@ | Package name | Package hash | | ------------------------------------------------------------- | ------------------------------------------------------------- | -| protocol/fetchai/gym/1.0.0 | `bafybeidsxnr76uiolf4mzj6ttyzzddz3cspckly2gmkiod6b5gocjjfydq` | -| connection/fetchai/gym/0.19.0 | `bafybeie2bjvejryw2vkiyxsvkv3maa6loxim6xlwp7ywobemrzx424tt3i` | -| protocol/fetchai/default/1.0.0 | `bafybeiazamq4mogosgmr77ipita5s6sq6rfowubxf5rybfxikc772befxy` | -| protocol/valory/acn/1.1.0 | `bafybeiapa5ilsobggnspoqhspftwolrx52udrwmaxdxgrk26heuvl4oooa` | -| protocol/valory/contract_api/1.0.0 | `bafybeiasywsvax45qmugus5kxogejj66c5taen27h4voriodz7rgushtqa` | -| protocol/valory/http/1.0.0 | `bafybeia5bxdua2i6chw6pg47bvoljzcpuqxzy4rdrorbdmcbnwmnfdobtu` | -| protocol/valory/ledger_api/1.0.0 | `bafybeigsvceac33asd6ecbqev34meyyjwu3rangenv6xp5rkxyz4krvcby` | -| connection/fetchai/http_server/0.22.0 | `bafybeihp5umafxzx45aad5pj7s3343se2wjkgnbirt4pybrape22swm6de` | -| connection/fetchai/stub/0.21.0 | `bafybeihijtaawc2adyewb3g7kta7hw6jyhyhoi7cotkzgqilves5zz7smm` | -| connection/valory/ledger/0.19.0 | `bafybeiejc7g7ebv3cleiqb4f4h4pspcu6vtr54332szwlqiabfs3sfdh44` | -| connection/valory/p2p_libp2p/0.1.0 | `bafybeigfvt35r5blb3pp43iads6a56jolquvib5unbndkue7cgysazuxuu` | -| connection/valory/p2p_libp2p_client/0.1.0 | `bafybeihdnfdth3qgltefgrem7xyi4b3ejzaz67xglm2hbma2rfvpl2annq` | -| connection/valory/p2p_libp2p_mailbox/0.1.0 | `bafybeifmmwyfxxb3pbj5nlvk4uj5xb2ot3mfdr6ydkhrqwzvildhbsudae` | -| contract/fetchai/erc1155/0.22.0 | `bafybeidjvb4ojaw2trxu4rlxq3blppfherkldwz4x5spnpvef5n34jvmmm` | -| protocol/fetchai/fipa/1.0.0 | `bafybeicwagyhi3jqncpoon6ellgyun2fjv6z5u6ksn52hrbn3m54xjuswu` | -| protocol/fetchai/oef_search/1.0.0 | `bafybeih7bwei5hvi4nypuk3tgrej4rq63uk324pog3dvamix3gmy2ae2zu` | -| protocol/fetchai/state_update/1.0.0 | `bafybeiamdiu6y4jztw6y46puoc5xxj3yqqyiso37c4xadcn55om73veytm` | -| protocol/open_aea/signing/1.0.0 | `bafybeifuxs7gdg2okbn7uofymenjlmnih2wxwkym44lsgwmklgwuckxm2m` | -| skill/fetchai/echo/0.19.0 | `bafybeibyqdrhpn7ixfxw5tdvu2nwvrupof7sy3eh2ixavri74w24ik4l2i` | +| protocol/fetchai/gym/1.0.0 | `bafybeidepuani7dw6r2wwmtxfeefqwhnctprmwatzqbxg2achstc6kpfke` | +| connection/fetchai/gym/0.19.0 | `bafybeiguq4eduf35lvs3ltmi3jabpokz6raadrje3c274f5dnvfipdl7jm` | +| protocol/fetchai/default/1.0.0 | `bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm` | +| protocol/valory/acn/1.1.0 | `bafybeic2pxzfc3voxl2ejhcqyf2ehm4wm5gxvgx7bliloiqi2uppmq6weu` | +| protocol/valory/contract_api/1.0.0 | `bafybeialhbjvwiwcnqq3ysxcyemobcbie7xza66gaofcvla5njezkvhcka` | +| protocol/valory/http/1.0.0 | `bafybeiejoqgv7finfxo3rcvvovrlj5ccrbgxodjq43uo26ylpowsa3llfe` | +| protocol/valory/ledger_api/1.0.0 | `bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru` | +| connection/fetchai/http_server/0.22.0 | `bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u` | +| connection/fetchai/stub/0.21.0 | `bafybeictgpdqbpyppmoxn2g7jkaxvulihew7zaszv4xyhgvsntq7tqs7wi` | +| connection/valory/ledger/0.19.0 | `bafybeigo5vst3zlltkouenwxuzn6c47yr2fbbml6dl2o32rfnsezmalgnu` | +| connection/valory/p2p_libp2p/0.1.0 | `bafybeiaykya7tvir7k5scovjzuagpfcftvptxoi2od5qqqvukwglsrrtzy` | +| connection/valory/p2p_libp2p_client/0.1.0 | `bafybeihge56dn3xep2dzomu7rtvbgo4uc2qqh7ljl3fubqdi2lq44gs5lq` | +| connection/valory/p2p_libp2p_mailbox/0.1.0 | `bafybeieufv6tbei3vza7bg7ggzsvyvwmzps5kghxlar3drhme6d7mxawvy` | +| contract/fetchai/erc1155/0.22.0 | `bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4` | +| protocol/fetchai/fipa/1.0.0 | `bafybeid6o7dxutkendclxxtxo3pyizrfho3vxyj5j5sowkysmuqamywb24` | +| protocol/fetchai/oef_search/1.0.0 | `bafybeicysyqgag7gsbpvly5mzhlwwiosl7gupgmohx233gynw7xtgsxewy` | +| protocol/fetchai/state_update/1.0.0 | `bafybeiefezh5ei6gntomi6g5iq4raabktari3wc6t4g6jf23bgo7cgwlcq` | +| protocol/open_aea/signing/1.0.0 | `bafybeie7xyems76v5b4wc2lmaidcujizpxfzjnnwdeokmhje53g7ym25ii` | +| skill/fetchai/echo/0.19.0 | `bafybeibtjwgshqkgn5og7izogitnc66ug7pfhikcxlf2y46ixknpoxeyee` | | skill/fetchai/error_test_skill/0.1.0 | `bafybeihsbtlpe7h6fsvoxban5rilkmwviwkokul5cqym6atoolirontiyu` | -| skill/fetchai/gym/0.20.0 | `bafybeifoydd7skfcpgbqupqlfijxkvhqudfuunk35ygqj76i42bb2lxnua` | -| skill/fetchai/http_echo/0.20.0 | `bafybeigdwkqdn744ebzmjihwx44ks5ctfvsm35d2aen2rmzodmo7h47inm` | -| agent/fetchai/error_test/0.1.0 | `bafybeifpraanub6fte7vym47gygyoyy7hphvowqlv3iyagimcp5muxt654` | -| agent/fetchai/gym_aea/0.25.0 | `bafybeihi7k2qrjlidvrkc5qrzlapayaguutbo53wsb3dz6whsuxsrpt4ua` | -| agent/fetchai/my_first_aea/0.27.0 | `bafybeifd2c4rh52rk2rpdvhb44sl7el664z4yfwnmxjm6qvd6sfq7bxiy4` | -| agent/open_aea/gym_aea/0.1.0 | `bafybeib72ryduegbgjmdtecirrpu4sm3iii2q7ums62gjikd2rpqpephju` | -| agent/open_aea/http_echo/0.1.0 | `bafybeihhywlpyxvfthjj6z7dzjq77qk6leocrmjtx5w2662dopdsmmw6h4` | -| agent/open_aea/my_first_aea/0.1.0 | `bafybeida2z2lk63dq555g72oio6salsgg36k66zndjius6ujlevomby3l4` | -| connection/fetchai/local/0.20.0 | `bafybeih5qqlgx6wpuahqk5hvsbxny72lmv7cfegoacsi66bouzopyy2y2q` | -| connection/valory/http_client/0.23.0 | `bafybeieoeuy4brzimtnubmokwirhrx27ezls6cdnl5qik4rkykfle3nn2y` | -| connection/valory/test_libp2p/0.1.0 | `bafybeib3zsiy7aaiiflltgkcmmmh5slwlst7fw4gi2nk633ulo22xonntu` | -| protocol/fetchai/tac/1.0.0 | `bafybeicy5whg5lzugw4j47fsbqmfgc5lwvgezikbpnkaalcr3iznex45ky` | -| skill/fetchai/erc1155_client/0.28.0 | `bafybeibcaigq4l6ywe7y4cgpebvdp2fxf7b7ykaw3rad3rx4xl6yu554dy` | -| skill/fetchai/erc1155_deploy/0.30.0 | `bafybeidh4frqplgyoiyyf7xk45gqunwvcuxe6c2egdfzt63gwt643wg624` | -| skill/fetchai/error/0.17.0 | `bafybeighscg5yyaj63tyz5icthjnvwlca5lvpkiw3dni2q45szqyw2blye` | -| skill/fetchai/fipa_dummy_buyer/0.2.0 | `bafybeie5rctzcx6zakshzr3oht57ieu35jkvsj2dt5yghloury2mayusp4` | -| skill/fetchai/generic_buyer/0.26.0 | `bafybeiej57wwwfkxbxsxe57pmnvbtacx37tdhtx2czgi3nh2s5eiljq6bq` | -| skill/fetchai/generic_seller/0.27.0 | `bafybeic34b4bbhfdabuhciqam6mghnpyei2izcz4mngpimkcs2v54ofife` | +| skill/fetchai/gym/0.20.0 | `bafybeifaccpsmby27az6geu4d6m7xcjk2hop7ihtleqeeasphnhn2dp234` | +| skill/fetchai/http_echo/0.20.0 | `bafybeieysvwshmy2rlfzqclcfhl263roy6z3skvmy3ikmfcoioxhnhp67i` | +| agent/fetchai/error_test/0.1.0 | `bafybeif6q4pyu4vvtaljm33rw2fft3f5fu33byhku3qkspy4vhgzczqhwy` | +| agent/fetchai/gym_aea/0.25.0 | `bafybeif5c657r3ixuosbyihtsdzr2tqifikxgy5e6t7ur2jmhtiolina3m` | +| agent/fetchai/my_first_aea/0.27.0 | `bafybeicrgya4gln4lqr3ba76t2cuyik37lcgr64kzna2fkoseseobytaa4` | +| agent/open_aea/gym_aea/0.1.0 | `bafybeibyyl4wtnrfxeoed3kjnlftphkcikdqrgf76u34v4wbvwgsqfqrgy` | +| agent/open_aea/http_echo/0.1.0 | `bafybeie6dxx5zbu6bz7at7kqj3thjvvzucj45f3tksbio5dg23ywsbb2ty` | +| agent/open_aea/my_first_aea/0.1.0 | `bafybeibv7nlyxldyj5ntivsu74ylul4dltpfvkfa46k2pbveetfpkvz4jm` | +| connection/fetchai/local/0.20.0 | `bafybeigukufpgy2sdkv5qqde47dhigbjitxcrxwg6sl6unlpbc7wbxqyhm` | +| connection/valory/http_client/0.23.0 | `bafybeifgeqgryx6b3s6eseyzyezygmeitcpt3tkor2eiycozoi6clgdrny` | +| connection/valory/test_libp2p/0.1.0 | `bafybeih4vz7pprbjhe5g4tnf52ttkooii66woxbhifjc7wk5xdt6b6asiu` | +| protocol/fetchai/tac/1.0.0 | `bafybeiaukfwe7wbpikztprlmrfpphsxqpdzgamkbhvqyz54tl3k73kzsvi` | +| skill/fetchai/erc1155_client/0.28.0 | `bafybeibffkywiuz5gwm6yn4v2fhkz35i77zl5ya4tzq4wksvga2mvkeojm` | +| skill/fetchai/erc1155_deploy/0.30.0 | `bafybeif6dmam4pvsdesvgb6n3ga4uf7dxikaynbqomxpswmhqlvcuz7vti` | +| skill/fetchai/error/0.17.0 | `bafybeignei6feootyjzrqdt5j5yx7r4nrzuy6tdgdgsmrncldt5bud2dri` | +| skill/fetchai/fipa_dummy_buyer/0.2.0 | `bafybeid7rzqruvc3fkesueig2mbzy2qsfplieircyjzwbdl7c6q5eauiky` | +| skill/fetchai/generic_buyer/0.26.0 | `bafybeiebwhfzs7vbdrnm7cqu5dc4r3wqdaeirmps5pfwexjd3ms5ss7xk4` | +| skill/fetchai/generic_seller/0.27.0 | `bafybeiapnkdtn3qrh36cxpbhalv2yaunnauieo7sxori46a7ohsp7xuzlq` | | skill/fetchai/task_test_skill/0.1.0 | `bafybeidv77u2xl52mnxakwvh7fuh46aiwfpteyof4eaptfd4agoi6cdble` | diff --git a/packages/fetchai/skills/erc1155_client/skill.yaml b/packages/fetchai/skills/erc1155_client/skill.yaml index cf146f3754..8089ef1384 100644 --- a/packages/fetchai/skills/erc1155_client/skill.yaml +++ b/packages/fetchai/skills/erc1155_client/skill.yaml @@ -21,7 +21,7 @@ fingerprint: tests/test_strategy.py: bafybeicbxie3v6vue3gcnru6vsvggcgy3shxwrldis5gppizbuhooslcqa fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeiauyqzizmocjldnfuzvnihrqubfqzn5u2hp6ue7v3ka5kj54kd3zm +- valory/ledger:0.19.0:bafybeigo5vst3zlltkouenwxuzn6c47yr2fbbml6dl2o32rfnsezmalgnu contracts: - fetchai/erc1155:0.22.0:bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4 protocols: diff --git a/packages/fetchai/skills/erc1155_deploy/skill.yaml b/packages/fetchai/skills/erc1155_deploy/skill.yaml index 45cc8a16a5..6805c47889 100644 --- a/packages/fetchai/skills/erc1155_deploy/skill.yaml +++ b/packages/fetchai/skills/erc1155_deploy/skill.yaml @@ -21,7 +21,7 @@ fingerprint: tests/test_strategy.py: bafybeigxtw2j2c7vl6xhdwos62jbtmx62xfgdyadptm5eewmkesmcooyea fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeiauyqzizmocjldnfuzvnihrqubfqzn5u2hp6ue7v3ka5kj54kd3zm +- valory/ledger:0.19.0:bafybeigo5vst3zlltkouenwxuzn6c47yr2fbbml6dl2o32rfnsezmalgnu contracts: - fetchai/erc1155:0.22.0:bafybeiff7a6xncyad53o2r7lekpnhexcspze6ocy55xtpzqeuacnlpunm4 protocols: diff --git a/packages/fetchai/skills/generic_buyer/skill.yaml b/packages/fetchai/skills/generic_buyer/skill.yaml index 7dee0fea6f..9a1a57005c 100644 --- a/packages/fetchai/skills/generic_buyer/skill.yaml +++ b/packages/fetchai/skills/generic_buyer/skill.yaml @@ -19,7 +19,7 @@ fingerprint: tests/test_models.py: bafybeibh72j3n72yseqvmpppucpu5wtidf6ebxbxkfnmrnlh4zv5y5apei fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeiauyqzizmocjldnfuzvnihrqubfqzn5u2hp6ue7v3ka5kj54kd3zm +- valory/ledger:0.19.0:bafybeigo5vst3zlltkouenwxuzn6c47yr2fbbml6dl2o32rfnsezmalgnu contracts: [] protocols: - fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm diff --git a/packages/fetchai/skills/generic_seller/skill.yaml b/packages/fetchai/skills/generic_seller/skill.yaml index 6723e79317..b344e84c0b 100644 --- a/packages/fetchai/skills/generic_seller/skill.yaml +++ b/packages/fetchai/skills/generic_seller/skill.yaml @@ -20,7 +20,7 @@ fingerprint: tests/test_models.py: bafybeihabrc22zqssit3fmqhxptosy6qz6mx65ukhf5iayvirfv42xrhoq fingerprint_ignore_patterns: [] connections: -- valory/ledger:0.19.0:bafybeiauyqzizmocjldnfuzvnihrqubfqzn5u2hp6ue7v3ka5kj54kd3zm +- valory/ledger:0.19.0:bafybeigo5vst3zlltkouenwxuzn6c47yr2fbbml6dl2o32rfnsezmalgnu contracts: [] protocols: - fetchai/default:1.0.0:bafybeibtqp56jkijwjsohk4z5vqp6pfkiexmnmk5uleteotbsgrypy6gxm diff --git a/packages/packages.json b/packages/packages.json index 1614b628aa..e09881330d 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -9,7 +9,7 @@ "protocol/valory/ledger_api/1.0.0": "bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru", "connection/fetchai/http_server/0.22.0": "bafybeihvscddpxjbtqsetngmxo3kiht2wqhosmwiyuh3f6zjti3x3byu5u", "connection/fetchai/stub/0.21.0": "bafybeictgpdqbpyppmoxn2g7jkaxvulihew7zaszv4xyhgvsntq7tqs7wi", - "connection/valory/ledger/0.19.0": "bafybeiauyqzizmocjldnfuzvnihrqubfqzn5u2hp6ue7v3ka5kj54kd3zm", + "connection/valory/ledger/0.19.0": "bafybeigo5vst3zlltkouenwxuzn6c47yr2fbbml6dl2o32rfnsezmalgnu", "connection/valory/p2p_libp2p/0.1.0": "bafybeiaykya7tvir7k5scovjzuagpfcftvptxoi2od5qqqvukwglsrrtzy", "connection/valory/p2p_libp2p_client/0.1.0": "bafybeihge56dn3xep2dzomu7rtvbgo4uc2qqh7ljl3fubqdi2lq44gs5lq", "connection/valory/p2p_libp2p_mailbox/0.1.0": "bafybeieufv6tbei3vza7bg7ggzsvyvwmzps5kghxlar3drhme6d7mxawvy", @@ -32,12 +32,12 @@ "connection/valory/http_client/0.23.0": "bafybeifgeqgryx6b3s6eseyzyezygmeitcpt3tkor2eiycozoi6clgdrny", "connection/valory/test_libp2p/0.1.0": "bafybeih4vz7pprbjhe5g4tnf52ttkooii66woxbhifjc7wk5xdt6b6asiu", "protocol/fetchai/tac/1.0.0": "bafybeiaukfwe7wbpikztprlmrfpphsxqpdzgamkbhvqyz54tl3k73kzsvi", - "skill/fetchai/erc1155_client/0.28.0": "bafybeifpscpj3oor5ek7too6evd4cktffwrsyx6qmintdwywdkzwsgeaum", - "skill/fetchai/erc1155_deploy/0.30.0": "bafybeiaaxhi4rpb2ezvdbc4q7z23nilpo4vxzqnu3jz5zfphqzhhpguifi", + "skill/fetchai/erc1155_client/0.28.0": "bafybeibffkywiuz5gwm6yn4v2fhkz35i77zl5ya4tzq4wksvga2mvkeojm", + "skill/fetchai/erc1155_deploy/0.30.0": "bafybeif6dmam4pvsdesvgb6n3ga4uf7dxikaynbqomxpswmhqlvcuz7vti", "skill/fetchai/error/0.17.0": "bafybeignei6feootyjzrqdt5j5yx7r4nrzuy6tdgdgsmrncldt5bud2dri", "skill/fetchai/fipa_dummy_buyer/0.2.0": "bafybeid7rzqruvc3fkesueig2mbzy2qsfplieircyjzwbdl7c6q5eauiky", - "skill/fetchai/generic_buyer/0.26.0": "bafybeiecm6pna5pq7gf7zvtemf6zjw4a7kjvuoqp3yjefqawaghzxkeevm", - "skill/fetchai/generic_seller/0.27.0": "bafybeigv6plwuow57wgp7jbz4bhe6j5q4ryyofyyjrlq7iqzba6tsff5wa", + "skill/fetchai/generic_buyer/0.26.0": "bafybeiebwhfzs7vbdrnm7cqu5dc4r3wqdaeirmps5pfwexjd3ms5ss7xk4", + "skill/fetchai/generic_seller/0.27.0": "bafybeiapnkdtn3qrh36cxpbhalv2yaunnauieo7sxori46a7ohsp7xuzlq", "skill/fetchai/task_test_skill/0.1.0": "bafybeidv77u2xl52mnxakwvh7fuh46aiwfpteyof4eaptfd4agoi6cdble" }, "third_party": {} diff --git a/packages/valory/connections/ledger/__init__.py b/packages/valory/connections/ledger/__init__.py index b8d719382e..ae0f10868e 100644 --- a/packages/valory/connections/ledger/__init__.py +++ b/packages/valory/connections/ledger/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2022 Valory AG +# Copyright 2021-2023 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/packages/valory/connections/ledger/base.py b/packages/valory/connections/ledger/base.py index 49a1c4c697..e5537187cd 100644 --- a/packages/valory/connections/ledger/base.py +++ b/packages/valory/connections/ledger/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2022 Valory AG +# Copyright 2021-2023 Valory AG # Copyright 2018-2021 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -132,6 +132,19 @@ async def wait_for( func_result = await asyncio.wait_for(running_func, timeout=timeout) return func_result + def set_extra_kwargs( # pylint: disable=no-self-use, unused-argument + self, message: Message + ) -> None: + """ + Set extra kwargs for the provided message. + + By default, this method does nothing. Override it in subclasses to set extra kwargs. + + :param message: the message that will be decorated with the extra kwargs. + :return: None + """ + return + def dispatch(self, envelope: Envelope) -> Task: """ Dispatch the request to the right sender handler. @@ -143,7 +156,9 @@ def dispatch(self, envelope: Envelope) -> Task: raise ValueError("Ledger connection expects non-serialized messages.") message = envelope.message ledger_id = self.get_ledger_id(message) - api = self.ledger_api_registry.make(ledger_id, **self.api_config(ledger_id)) + chain_id = self.get_chain_id(message) + self.set_extra_kwargs(message) + api = self.ledger_api_registry.make(ledger_id, **self.api_config(chain_id)) dialogue = self.dialogues.update(message) if dialogue is None: raise ValueError( # pragma: nocover @@ -196,3 +211,7 @@ def ledger_api_registry(self) -> Registry: @abstractmethod def get_ledger_id(self, message: Message) -> str: """Extract the ledger id from the message.""" + + @abstractmethod + def get_chain_id(self, message: Message) -> str: + """Extract the chain id from the message.""" diff --git a/packages/valory/connections/ledger/connection.yaml b/packages/valory/connections/ledger/connection.yaml index 5d46233261..7a1b6e1929 100644 --- a/packages/valory/connections/ledger/connection.yaml +++ b/packages/valory/connections/ledger/connection.yaml @@ -7,15 +7,15 @@ license: Apache-2.0 aea_version: '>=1.0.0, <2.0.0' fingerprint: README.md: bafybeihkgodu7o7v6pfazm7u6orlspsfrae3cyz36yc46x67phfmw3l57e - __init__.py: bafybeierqitcqk7oy6m3qp7jgs67lcg55mzt3arltkwimuii2ynfejccwi - base.py: bafybeicpyhus3h2t5urzldnjns2sfwae64uinethqnlunudclbdg4xftnq + __init__.py: bafybeia3purd7y4b7tkdt2fcaxkdazos32criq5hx6fhufaislrdefe674 + base.py: bafybeifuoq2oqlcjlgeg2fg5l2ijiylb23v65xghv7u422helief2cjjuy connection.py: bafybeicydkymhz2feqmihtkiwdfg7pp4pww2elqv4tijuhjcplyvawdk74 - contract_dispatcher.py: bafybeibxclfbs3m6yc7jsldid3l6zlyssg74mdpzt3xuthyrq3ul5qosfu - ledger_dispatcher.py: bafybeidk2ucd2oc6bdmevdlmia5i5d66t446otzhq5loepvz5altpl6xdu - tests/__init__.py: bafybeieyhttiwruutk6574yzj7dk2afamgdum5vktyv54gsax7dlkuqtc4 + contract_dispatcher.py: bafybeifm5n2nh3z7cr47h2ejs4zu47s6uxliuvaacndxwt6sdcvbqwmpqa + ledger_dispatcher.py: bafybeigeziwsrriamjycjwu6qri2vervgbta7xkludnae2fzqqegwp6d5e + tests/__init__.py: bafybeifku7ttsmbj4gfx6dkgjvwypx7v5ysfqlzof6vh4p7gujakjtuwhe tests/conftest.py: bafybeid7vo7e2m76ey5beeadtbxywxx5ukefd5slwbc362rwmhht6i45ou tests/test_contract_dispatcher.py: bafybeiag5lnpc7h25w23ash4hk4cowxsy5buxgpr474l3tfewnhf56eqyq - tests/test_ledger.py: bafybeib5q7ypsuumitcsai3mpnjsrzxijtuj7ut5xcsbvpwnllkfozhsk4 + tests/test_ledger.py: bafybeigcedfr3yv3jse3xwrerrgwbelgb56uhgrvdus527d3daekh6dx4m tests/test_ledger_api.py: bafybeifwdpbds7ujd2uzxcapprdgdp5fn2gpbycsgbbefbsabrucnvrfiq fingerprint_ignore_patterns: [] connections: [] @@ -54,7 +54,7 @@ config: is_gas_estimation_enabled: true poa_chain: false authentication_private_key: null - flashbot_relayer_uri: null + flashbots_builders: [] solana: address: http://127.0.0.1:8545 chain_id: 1337 @@ -62,6 +62,41 @@ config: gas_price_strategies: *id001 is_gas_estimation_enabled: true poa_chain: false + arbitrum: + address: http://127.0.0.1:8545 + chain_id: 1337 + default_gas_price_strategy: eip1559 + gas_price_strategies: *id001 + is_gas_estimation_enabled: true + poa_chain: false + zksync: + address: http://127.0.0.1:8545 + chain_id: 1337 + default_gas_price_strategy: eip1559 + gas_price_strategies: *id001 + is_gas_estimation_enabled: true + poa_chain: false + bnb: + address: http://127.0.0.1:8545 + chain_id: 1337 + default_gas_price_strategy: eip1559 + gas_price_strategies: *id001 + is_gas_estimation_enabled: true + poa_chain: false + gnosis: + address: http://127.0.0.1:8545 + chain_id: 1337 + default_gas_price_strategy: eip1559 + gas_price_strategies: *id001 + is_gas_estimation_enabled: true + poa_chain: false + consensys: + address: http://127.0.0.1:8545 + chain_id: 1337 + default_gas_price_strategy: eip1559 + gas_price_strategies: *id001 + is_gas_estimation_enabled: true + poa_chain: false retry_attempts: 240 retry_timeout: 3 excluded_protocols: [] diff --git a/packages/valory/connections/ledger/contract_dispatcher.py b/packages/valory/connections/ledger/contract_dispatcher.py index 032c8db8e7..0d44263f3c 100644 --- a/packages/valory/connections/ledger/contract_dispatcher.py +++ b/packages/valory/connections/ledger/contract_dispatcher.py @@ -417,3 +417,35 @@ def _validate_and_call_callable( raise AEAException( # pragma: nocover f"Unexpected performative: {message.performative}" ) + + def get_chain_id(self, message: Message) -> str: + """ + Get the chain id. For ledger messages this is the same as the ledger id, for now. + + :param message: the message + :return: the chain id + """ + if not isinstance(message, ContractApiMessage): # pragma: nocover + raise ValueError("argument is not a ContractApiMessage instance.") + message = cast(ContractApiMessage, message) + kwargs = cast(JSONLike, message.kwargs.body) + # if the chain id is specified in the message, use it. + # otherwise, use the ledger id. + chain_id = cast(str, kwargs.get("chain_id", self.get_ledger_id(message))) + return chain_id + + def set_extra_kwargs(self, message: Message) -> None: + """ + Set extra kwargs for the contract api message. + + :param message: the message + """ + if not isinstance(message, ContractApiMessage): + raise ValueError("argument is not a ContractApiMessage instance.") + message = cast(ContractApiMessage, message) + if message.kwargs.body is not None and message.kwargs.body.get( + "set_ledger_api_configs", False + ): + message.kwargs.body.update( + {"ledger_api_configs": cast(dict, self._api_configs).copy()} + ) diff --git a/packages/valory/connections/ledger/ledger_dispatcher.py b/packages/valory/connections/ledger/ledger_dispatcher.py index 7917e3d348..46dc2d2719 100644 --- a/packages/valory/connections/ledger/ledger_dispatcher.py +++ b/packages/valory/connections/ledger/ledger_dispatcher.py @@ -22,6 +22,7 @@ import logging from typing import Any, cast +from aea.common import JSONLike from aea.connections.base import ConnectionStates from aea.crypto.base import LedgerApi from aea.helpers.transaction.base import RawTransaction, State, TransactionDigest @@ -452,3 +453,22 @@ def get_error_message( ), ) return response + + def get_chain_id(self, message: Message) -> str: + """ + Get the chain id. For ledger messages this is the same as the ledger id, for now. + + :param message: the message + :return: the chain id + """ + if not isinstance(message, LedgerApiMessage): # pragma: nocover + raise ValueError("argument is not a LedgerApiMessage instance.") + message = cast(LedgerApiMessage, message) + kwargs = {} + if message.is_set("kwargs"): + # check if kwargs is set + kwargs = cast(JSONLike, message.kwargs.body) + # if the chain id is specified in the message, use it. + # otherwise, use the ledger id. + chain_id = cast(str, kwargs.get("chain_id", self.get_ledger_id(message))) + return chain_id diff --git a/packages/valory/connections/ledger/tests/__init__.py b/packages/valory/connections/ledger/tests/__init__.py index cce3f2703a..346bbd4063 100644 --- a/packages/valory/connections/ledger/tests/__init__.py +++ b/packages/valory/connections/ledger/tests/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2021-2022 Valory AG +# Copyright 2021-2023 Valory AG # Copyright 2018-2020 Fetch.AI Limited # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/packages/valory/connections/ledger/tests/test_ledger.py b/packages/valory/connections/ledger/tests/test_ledger.py index 19399d3d75..ddfd8e75ca 100644 --- a/packages/valory/connections/ledger/tests/test_ledger.py +++ b/packages/valory/connections/ledger/tests/test_ledger.py @@ -413,6 +413,10 @@ def get_ledger_id(self, message: Message) -> str: raise ValueError("argument is not a `DummyLedgerApiMessage` instance.") return message.ledger_id + def get_chain_id(self, message: Message) -> str: + """Extract the chain id from the message.""" + return self.get_ledger_id(message=message) + class LedgerConnectionWithDummyDispatcher(LedgerConnection): """An extended `LedgerConnection` which utilizes the `DummyDispatcher`."""