Skip to content

Commit

Permalink
feat: reenable destinationAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
reednaa committed Mar 12, 2024
1 parent 5973c2e commit 8d51d17
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/collector/mock/mock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions src/collector/wormhole/wormhole.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 6 additions & 15 deletions src/store/store.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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));
}

/**
Expand Down

0 comments on commit 8d51d17

Please sign in to comment.