From 8d51d17892829e73b3ead9d19636b4ea2a26e25f Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 12 Mar 2024 14:42:08 +0100 Subject: [PATCH] feat: reenable destinationAddress --- src/collector/mock/mock.service.ts | 8 ++++---- src/collector/wormhole/wormhole.service.ts | 14 +++++++------- src/store/store.lib.ts | 21 ++++++--------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/collector/mock/mock.service.ts b/src/collector/mock/mock.service.ts index 9ddfc05..f2e1e09 100644 --- a/src/collector/mock/mock.service.ts +++ b/src/collector/mock/mock.service.ts @@ -156,10 +156,10 @@ const bootstrap = async () => { await store.setAmb(amb, messageEvent.transactionHash); // Set destination address for the bounty. - // await store.registerDestinationAddress({ - // messageIdentifier: amb.messageIdentifier, - // destinationAddress: messageEvent.args.recipient, - // }); + await store.registerDestinationAddress({ + messageIdentifier: amb.messageIdentifier, + destinationAddress: messageEvent.args.recipient, + }); // Encode and sign the message for delivery. // This is the proof which enables us to submit the transaciton later. diff --git a/src/collector/wormhole/wormhole.service.ts b/src/collector/wormhole/wormhole.service.ts index 433cb3d..ad7f143 100644 --- a/src/collector/wormhole/wormhole.service.ts +++ b/src/collector/wormhole/wormhole.service.ts @@ -106,13 +106,13 @@ const bootstrap = async () => { } // Set destination address for the bounty. - // await store.registerDestinationAddress({ - // messageIdentifier: amb.messageIdentifier, - // destinationAddress: await messageEscrow.implementationAddress( - // decodedPayload?.sourceApplicationAddress, - // defaultAbiCoder.encode(['uint256'], [amb.destinationChain]), - // ), - // }); + await store.registerDestinationAddress({ + messageIdentifier: amb.messageIdentifier, + destinationAddress: await messageEscrow.implementationAddress( + decodedPayload?.sourceApplicationAddress, + defaultAbiCoder.encode(['uint256'], [amb.destinationChain]), + ), + }); } startBlock = endBlock + 1; diff --git a/src/store/store.lib.ts b/src/store/store.lib.ts index 6f9913d..9f46552 100644 --- a/src/store/store.lib.ts +++ b/src/store/store.lib.ts @@ -75,6 +75,7 @@ export class Store { static readonly hashAmbMapMidfix: string = 'hashAmbMap'; static readonly proofMidfix: string = 'proof'; static readonly wordConnecter: string = ':'; + static readonly destinationAddressPostfix: string = 'destinationAddress'; readonly chainId: string | null; @@ -263,8 +264,6 @@ export class Store { /** * Register the destination address of a bounty. - * @dev This function currently doesn't work. It overrides the existing bounty and that causes - * problems with the persister and potentially also with submitter. */ async registerDestinationAddress(event: { messageIdentifier: string; @@ -280,23 +279,15 @@ export class Store { Store.relayerStorePrefix, Store.bountyMidfix, messageIdentifier, + Store.destinationAddressPostfix, ); - const existingValue = await this.redis.get(key); - if (!existingValue) { - // Then we need to create some kind of baseline with the information we know. - const bounty = { - destinationAddress: event.destinationAddress, - }; - // We can set this value now. - return this.set(key, JSON.stringify(bounty)); - } - // Okay, we know a bounty exists at this value. Lets try to update it without destorying any information. - const bountyAsRead: BountyJson = JSON.parse(existingValue); + const bounty = { - ...bountyAsRead, + messageIdentifier, destinationAddress: event.destinationAddress, }; - await this.set(key, JSON.stringify(bounty)); + // We can set this value now. + return this.set(key, JSON.stringify(bounty)); } /**