Skip to content

Commit

Permalink
change gasLimits and gasPrices from calldata to memory in example con…
Browse files Browse the repository at this point in the history
…tracts
  • Loading branch information
RnkSngh committed Jul 18, 2024
1 parent 0f9c48a commit b241af6
Show file tree
Hide file tree
Showing 26 changed files with 256 additions and 372 deletions.
56 changes: 28 additions & 28 deletions bindings/go/mars/Mars.go

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions bindings/go/mars/PanickingMars.go

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions bindings/go/mars/RevertingBytesMars.go

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions bindings/go/mars/RevertingEmptyMars.go

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions bindings/go/mars/RevertingStringCloseChannelMars.go

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions bindings/go/mars/RevertingStringMars.go

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions bindings/go/moon/Moon.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/base/GeneralMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ contract GeneralMiddleware is IbcMwUser, IbcMiddleware, IbcMwEventsEmitter, IbcM
bytes32 destPortAddr,
bytes calldata appData,
uint64 timeoutTimestamp,
uint256[2] calldata gasLimits,
uint256[2] calldata gasPrices
uint256[2] memory gasLimits,
uint256[2] memory gasPrices
) external payable override returns (uint64 sequence) {}

function sendMWPacket(
Expand Down
2 changes: 2 additions & 0 deletions contracts/core/FeeVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ contract FeeVault is Ownable, ReentrancyGuard, IFeeVault {
* - gasPrices[1] for `ackPacket` fees, for the src chain
* @notice The total fees sent in the msg.value should be equal to the total gasLimits[0] * gasPrices[0] +
* gasLimits[1] * gasPrices[1]. The transaction will revert if a higher or lower value is sent
* @dev Note: if you're having trouble with your packet data being mysteriously lost, try passing in the gasLimits
* and gasPrices as memory, solidity sometimes misbehaves when trying to pass in too much calldata.
*/
function depositSendPacketFee(
bytes32 channelId,
Expand Down
34 changes: 11 additions & 23 deletions contracts/examples/Mars.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,9 @@ contract Mars is IbcReceiverBase, IbcReceiver, FeeSender {

/**
* @notice Callback for acknowledging a packet; triggered on reciept of an IBC packet by the counterparty
* @param packet The IBC packet for which acknowledgement is received
* @param ack The acknowledgement packet received
* @dev Make sure to validate packet's source and destiation channels and ports.
*/
function onAcknowledgementPacket(IbcPacket calldata packet, AckPacket calldata ack)
external
virtual
onlyIbcDispatcher
{
function onAcknowledgementPacket(IbcPacket calldata, AckPacket calldata ack) external virtual onlyIbcDispatcher {
ackPackets.push(ack);
}

Expand All @@ -119,14 +113,8 @@ contract Mars is IbcReceiverBase, IbcReceiver, FeeSender {
* @notice Handles channel close callback on the dest chain
* @param channelId The unique identifier of the channel
* @dev Make sure to validate channelId and counterpartyVersion
* @param counterpartyPortId The unique identifier of the counterparty's port
* @param counterpartyChannelId The unique identifier of the counterparty's channel
*/
function onChanCloseConfirm(bytes32 channelId, string calldata counterpartyPortId, bytes32 counterpartyChannelId)
external
virtual
onlyIbcDispatcher
{
function onChanCloseConfirm(bytes32 channelId, string calldata, bytes32) external virtual onlyIbcDispatcher {
// logic to determine if the channel should be closed
bool channelFound = false;
for (uint256 i = 0; i < connectedChannels.length; i++) {
Expand Down Expand Up @@ -182,8 +170,8 @@ contract Mars is IbcReceiverBase, IbcReceiver, FeeSender {
string calldata message,
bytes32 channelId,
uint64 timeoutTimestamp,
uint256[2] calldata gasLimits,
uint256[2] calldata gasPrices
uint256[2] memory gasLimits,
uint256[2] memory gasPrices
) external payable returns (uint64 sequence) {
sequence = dispatcher.sendPacket(channelId, bytes(message), timeoutTimestamp);
_depositSendPacketFee(dispatcher, channelId, sequence, gasLimits, gasPrices);
Expand All @@ -192,15 +180,15 @@ contract Mars is IbcReceiverBase, IbcReceiver, FeeSender {
/**
* @notice Handles the channel close init event
* @dev Make sure to validate channelId and counterpartyVersion
* @param counterpartyPortIdentifier The unique identifier of the counterparty's channel
* @param version The channel version
*/
function onChanOpenInit(
ChannelOrder,
string[] calldata,
string calldata counterpartyPortIdentifier,
string calldata version
) external view virtual onlyIbcDispatcher returns (string memory selectedVersion) {
function onChanOpenInit(ChannelOrder, string[] calldata, string calldata, string calldata version)
external
view
virtual
onlyIbcDispatcher
returns (string memory selectedVersion)
{
return _openChannel(version);
}

Expand Down
6 changes: 4 additions & 2 deletions contracts/implementation_templates/FeeSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ abstract contract FeeSender {
* - gasPrices[1] for `ackPacket` fees, for the src chain
* @notice The total fees sent in the msg.value should be equal to the total gasLimits[0] * gasPrices[0] +
* @notice Use the Polymer fee estimation api to get the required fees to ensure that enough fees are sent.
* @dev Note: We have to have gasLimits and gasPrices as memory arrays. We cannot have them as calldata arrays
* because solidity has weird behavior with using too much calldata in stacked calls
* gasLimits[1] * gasPrices[1]. The transaction will revert if a higher or lower value is sent
*/
function _depositSendPacketFee(
IbcDispatcher dispatcher,
bytes32 channelId,
uint64 sequence,
uint256[2] calldata gasLimits,
uint256[2] calldata gasPrices
uint256[2] memory gasLimits,
uint256[2] memory gasPrices
) internal {
dispatcher.feeVault().depositSendPacketFee{value: msg.value}(channelId, sequence, gasLimits, gasPrices);
}
Expand Down
30 changes: 6 additions & 24 deletions src/evm/contracts/Mars.sol/Mars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,13 @@ export interface Mars extends BaseContract {
>;

onAcknowledgementPacket: TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;

onChanCloseConfirm: TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -403,12 +399,7 @@ export interface Mars extends BaseContract {
>;

onChanOpenInit: TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down Expand Up @@ -568,18 +559,14 @@ export interface Mars extends BaseContract {
getFunction(
nameOrSignature: "onAcknowledgementPacket"
): TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;
getFunction(
nameOrSignature: "onChanCloseConfirm"
): TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -603,12 +590,7 @@ export interface Mars extends BaseContract {
getFunction(
nameOrSignature: "onChanOpenInit"
): TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down
30 changes: 6 additions & 24 deletions src/evm/contracts/Mars.sol/PanickingMars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,13 @@ export interface PanickingMars extends BaseContract {
>;

onAcknowledgementPacket: TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;

onChanCloseConfirm: TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -403,12 +399,7 @@ export interface PanickingMars extends BaseContract {
>;

onChanOpenInit: TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down Expand Up @@ -568,18 +559,14 @@ export interface PanickingMars extends BaseContract {
getFunction(
nameOrSignature: "onAcknowledgementPacket"
): TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;
getFunction(
nameOrSignature: "onChanCloseConfirm"
): TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -603,12 +590,7 @@ export interface PanickingMars extends BaseContract {
getFunction(
nameOrSignature: "onChanOpenInit"
): TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down
30 changes: 6 additions & 24 deletions src/evm/contracts/Mars.sol/RevertingBytesMars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,13 @@ export interface RevertingBytesMars extends BaseContract {
>;

onAcknowledgementPacket: TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;

onChanCloseConfirm: TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -403,12 +399,7 @@ export interface RevertingBytesMars extends BaseContract {
>;

onChanOpenInit: TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down Expand Up @@ -564,18 +555,14 @@ export interface RevertingBytesMars extends BaseContract {
getFunction(
nameOrSignature: "onAcknowledgementPacket"
): TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;
getFunction(
nameOrSignature: "onChanCloseConfirm"
): TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -599,12 +586,7 @@ export interface RevertingBytesMars extends BaseContract {
getFunction(
nameOrSignature: "onChanOpenInit"
): TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down
30 changes: 6 additions & 24 deletions src/evm/contracts/Mars.sol/RevertingEmptyMars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,13 @@ export interface RevertingEmptyMars extends BaseContract {
>;

onAcknowledgementPacket: TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;

onChanCloseConfirm: TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -403,12 +399,7 @@ export interface RevertingEmptyMars extends BaseContract {
>;

onChanOpenInit: TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down Expand Up @@ -568,18 +559,14 @@ export interface RevertingEmptyMars extends BaseContract {
getFunction(
nameOrSignature: "onAcknowledgementPacket"
): TypedContractMethod<
[packet: IbcPacketStruct, ack: AckPacketStruct],
[arg0: IbcPacketStruct, ack: AckPacketStruct],
[void],
"nonpayable"
>;
getFunction(
nameOrSignature: "onChanCloseConfirm"
): TypedContractMethod<
[
channelId: BytesLike,
counterpartyPortId: string,
counterpartyChannelId: BytesLike
],
[channelId: BytesLike, arg1: string, arg2: BytesLike],
[void],
"nonpayable"
>;
Expand All @@ -603,12 +590,7 @@ export interface RevertingEmptyMars extends BaseContract {
getFunction(
nameOrSignature: "onChanOpenInit"
): TypedContractMethod<
[
arg0: BigNumberish,
arg1: string[],
counterpartyPortIdentifier: string,
version: string
],
[arg0: BigNumberish, arg1: string[], arg2: string, version: string],
[string],
"view"
>;
Expand Down
Loading

0 comments on commit b241af6

Please sign in to comment.