From 38e0b17d0832afc9a0cbc1834c5b380ef4dfb9f5 Mon Sep 17 00:00:00 2001 From: Troy Kessler <43882936+troykessler@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:35:50 +0200 Subject: [PATCH] fix: runtime tendermint (#58) * fix: removed index from event attributes * fix: properly map over begin and end block events --- .../src/reactors/storageProviders/Bundlr.ts | 5 +- integrations/.DS_Store | Bin 0 -> 6148 bytes integrations/tendermint/src/runtime.ts | 65 +++++++++++------- yarn.lock | 39 ++--------- 4 files changed, 47 insertions(+), 62 deletions(-) create mode 100644 integrations/.DS_Store diff --git a/common/protocol/src/reactors/storageProviders/Bundlr.ts b/common/protocol/src/reactors/storageProviders/Bundlr.ts index dbbcbf50..e32b5de0 100644 --- a/common/protocol/src/reactors/storageProviders/Bundlr.ts +++ b/common/protocol/src/reactors/storageProviders/Bundlr.ts @@ -47,10 +47,7 @@ export class Bundlr implements IStorageProvider { } async saveBundle(bundle: Buffer, tags: BundleTag[]) { - const transaction = this.bundlrClient.createTransaction( - bundle, - { tags } - ); + const transaction = this.bundlrClient.createTransaction(bundle, { tags }); await transaction.sign(); await transaction.upload(); diff --git a/integrations/.DS_Store b/integrations/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f9df5be882e5eadfde627f6579d0cf30ff122c16 GIT binary patch literal 6148 zcmeHKPfNov6i>G4I)|`>!j1v21Lrm;;-%F21+3^nWv;Ynv1>-#*~1w0tY64a;^*n`cc=UWGskWeIsBA8?%tb zEL)2v!*65&_ihJvD}X)opZxygM8T7JC|`b3gaMA385cA$lXmC`!aXrH1<=K>uQHpvueXe zb2jVtPg)PV5)(X%EP!x + const compareEventAttribute = (a: IAttribute, b: IAttribute) => a.key.toLowerCase() > b.key.toLowerCase() ? 1 : b.key.toLowerCase() > a.key.toLowerCase() ? -1 : 0; - // sort attributes in begin_block_events - if (item.value?.begin_block_events) { - item.value.begin_block_events = item.value.begin_block_events.map( - (event: any) => { - event.attributes.sort(compareEventAttribute); + // sort attributes and remove index in begin_block_events + if (item.value.block_results.begin_block_events) { + item.value.block_results.begin_block_events = + item.value.block_results.begin_block_events.map((event: IEvent) => { + event.attributes = event.attributes + .sort(compareEventAttribute) + .map(({ index, ...attribute }: IAttribute) => attribute); return event; - } - ); + }); } - // sort attributes in end_block_events - if (item.value?.end_block_events) { - item.value.end_block_events = item.value.end_block_events.map( - (event: any) => { - event.attributes.sort(compareEventAttribute); + // sort attributes and remove index in end_block_events + if (item.value.block_results.end_block_events) { + item.value.block_results.end_block_events = + item.value.block_results.end_block_events.map((event: IEvent) => { + event.attributes = event.attributes + .sort(compareEventAttribute) + .map(({ index, ...attribute }: IAttribute) => attribute); return event; - } - ); + }); } - if (item.value?.block_results?.txs_results) { + if (item.value.block_results.txs_results) { item.value.block_results.txs_results = item.value.block_results.txs_results.map((tx_result: any) => { // delete log property of transaction results since it stores duplicate data delete tx_result.log; if (tx_result.events) { - tx_result.events = tx_result.events.map((event: any) => { + tx_result.events = tx_result.events.map((event: IEvent) => { // sort attributes in txs_results - event.attributes.sort(compareEventAttribute); + event.attributes = event.attributes + .sort(compareEventAttribute) + .map(({ index, ...attribute }: IAttribute) => attribute); // set attribute "acknowledgement" in ibc event "fungible_token_packet" to empty string if (event.type === 'fungible_token_packet') { - event.attributes = event.attributes.map((attribute: any) => { - if (attribute.key === 'YWNrbm93bGVkZ2VtZW50') { - attribute.value = ''; - } + event.attributes = event.attributes.map( + (attribute: IAttribute) => { + if (attribute.key === 'YWNrbm93bGVkZ2VtZW50') { + attribute.value = ''; + } - return attribute; - }); + return attribute; + } + ); } return event; diff --git a/yarn.lock b/yarn.lock index 2b1ca211..a4cb238f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -899,11 +899,6 @@ near-api-js "^0.44.2" near-seed-phrase "^0.2.0" -"@celo-tools/celo-ethers-wrapper@^0.3.0": - version "0.3.0" - resolved "https://registry.yarnpkg.com/@celo-tools/celo-ethers-wrapper/-/celo-ethers-wrapper-0.3.0.tgz#14e19edde1c71da912927344590029e9ffcb3a97" - integrity sha512-qJgVQ3EeVYzM0uvGcVxPB4cH8BaEnoLMyG8k/gAWzSCjJFIgNTlRs05IFGzAb7U0GlbDKCDSualHSGMXq+OHEw== - "@confio/ics23@^0.6.3", "@confio/ics23@^0.6.8": version "0.6.8" resolved "https://registry.yarnpkg.com/@confio/ics23/-/ics23-0.6.8.tgz#2a6b4f1f2b7b20a35d9a0745bb5a446e72930b3d" @@ -3645,13 +3640,6 @@ axios@^0.24.0: dependencies: follow-redirects "^1.14.4" -axios@^0.26.1: - version "0.26.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9" - integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA== - dependencies: - follow-redirects "^1.14.8" - axios@^0.27.2: version "0.27.2" resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" @@ -3660,7 +3648,7 @@ axios@^0.27.2: follow-redirects "^1.14.9" form-data "^4.0.0" -axios@^1.0.0, axios@^1.3.4: +axios@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== @@ -5121,7 +5109,7 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -ethers@^5.5.1, ethers@^5.6.5, ethers@^5.6.9: +ethers@^5.5.1: version "5.7.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e" integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg== @@ -5446,7 +5434,7 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== -follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.7, follow-redirects@^1.14.8, follow-redirects@^1.14.9, follow-redirects@^1.15.0: +follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.7, follow-redirects@^1.14.9, follow-redirects@^1.15.0: version "1.15.2" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== @@ -7631,11 +7619,6 @@ nan@^2.13.2: resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb" integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ== -nanoid@^3.3.3: - version "3.3.6" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" - integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== - napi-build-utils@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" @@ -8487,7 +8470,7 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.3.0, prettier@^2.4.1, prettier@^2.5.1, prettier@^2.6.2, prettier@^2.7.1: +prettier@^2.3.0, prettier@^2.4.1, prettier@^2.5.1, prettier@^2.7.1: version "2.8.8" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== @@ -9129,11 +9112,6 @@ smart-buffer@^4.2.0: resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== -snekfetch@^3.6.4: - version "3.6.4" - resolved "https://registry.yarnpkg.com/snekfetch/-/snekfetch-3.6.4.tgz#d13e80a616d892f3d38daae4289f4d258a645120" - integrity sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw== - socks-proxy-agent@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-7.0.0.tgz#dc069ecf34436621acb41e3efa66ca1b5fed15b6" @@ -9844,7 +9822,7 @@ typescript-json-schema@^0.53.1: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274" integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA== -typescript@^4.4.3, typescript@^4.5.5, typescript@^4.6.3, typescript@^4.6.4, typescript@^4.7.3, typescript@^4.7.4: +typescript@^4.4.3, typescript@^4.5.5, typescript@^4.6.4, typescript@^4.7.3, typescript@^4.7.4: version "4.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== @@ -10046,13 +10024,6 @@ wcwidth@^1.0.0, wcwidth@^1.0.1: dependencies: defaults "^1.0.3" -webhook-discord@^3.7.8: - version "3.7.8" - resolved "https://registry.yarnpkg.com/webhook-discord/-/webhook-discord-3.7.8.tgz#856ce6928713ee7d1a05dbc8a64dfc233d0d816d" - integrity sha512-IDEvKmu83SIAPZD0efpEXj3ZEm+X8Q68iRuKEKtyXlGN9S9lVtdL7cp4I0AXqTapVj+eh+Wby7y9DaxP01Yk2g== - dependencies: - snekfetch "^3.6.4" - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"