Skip to content

Commit

Permalink
fix: messaging template (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev authored Aug 21, 2023
1 parent dec5e2c commit 4e9115d
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions templates/messaging/contracts/{{contractName}}.sol.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract {{contractName}} is
if (!_isValidChainId(destinationChainId))
revert InvalidDestinationChainId();

uint256 crossChainGas = 18 * (10 ** 18);
uint256 crossChainGas = 2 * (10 ** 18);
uint256 zetaValueAndGas = _zetaConsumer.getZetaFromEth{
value: msg.value
}(address(this), crossChainGas);
Expand All @@ -58,27 +58,16 @@ contract {{contractName}} is
function onZetaMessage(
ZetaInterfaces.ZetaMessage calldata zetaMessage
) external override isValidMessageCall(zetaMessage) {
/**
* @dev Decode should follow the signature of the message provided to zeta.send.
*/
(bytes32 messageType{{#if arguments.pairs}}, {{#each arguments.pairs}}{{#if @index}}, {{/if}}{{this.[1]}} {{this.[0]}}{{/each}}{{/if}}) = abi.decode(
zetaMessage.message, (bytes32{{#if arguments.pairs}}, {{#each arguments.pairs}}{{#if @index}}, {{/if}}{{this.[1]}}{{/each}}{{/if}})
);

/**
* @dev Setting a message type is a useful pattern to distinguish between different messages.
*/
if (messageType != {{contractNameUnderscore}}_MESSAGE_TYPE)
revert InvalidMessageType();

emit {{contractName}}Event({{#each arguments.pairs}}{{#if @index}}, {{/if}}{{this.[0]}}{{/each}});
}

/**
* @dev Called by the Zeta Connector contract when the message fails to be sent.
* Useful to cleanup and leave the application on its initial state.
* Note that the require statements and the functionality are similar to onZetaMessage.
*/
function onZetaRevert(
ZetaInterfaces.ZetaRevert calldata zetaRevert
) external override isValidRevertCall(zetaRevert) {
Expand Down

0 comments on commit 4e9115d

Please sign in to comment.