Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: value argument is not being properly passed to the contract call #292

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/app-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ jobs:
name: allure-results
path: packages/app/allure-results

- name: Upload test results to Allure reporter
if: always()
env:
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
run: |
./allurectl upload allure-results
echo "*Public report link: https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html"
echo "*Public report link will be available when the 'Allure Report' job will be succesfully executed."
# - name: Upload test results to Allure reporter
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable this GH action step for the time being as it fails for some reason. It will be investigated and fixed in the following PRs.

# if: always()
# env:
# ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
# run: |
# ./allurectl upload allure-results
# echo "*Public report link: https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html"
# echo "*Public report link will be available when the 'Allure Report' job will be succesfully executed."

- if: failure()
name: Save artifacts
Expand All @@ -149,7 +149,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: allure-results
path: packages/app/allure-results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { ethers } from "ethers";
import Input from "@/components/common/Input.vue";
import FunctionArrayParameter from "@/components/contract/interaction/FunctionArrayParameter.vue";

import { PAYABLE_AMOUNT_PARAM_NAME } from "@/composables/useContractInteraction";

import type { AbiFragment } from "@/composables/useAddress";

import { getRawFunctionType, getRequiredArrayLength, isArrayFunctionType } from "@/utils/helpers";
Expand Down Expand Up @@ -80,7 +82,7 @@ const inputs = computed(() => {
);
if (props.abiFragment.stateMutability === "payable") {
inputsArray.unshift({
key: "value",
key: PAYABLE_AMOUNT_PARAM_NAME,
type: "ether",
label: "payableAmount (ether)",
placeholder: "payableAmount (ether)",
Expand Down
7 changes: 4 additions & 3 deletions packages/app/src/composables/useContractInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import useContext from "@/composables/useContext";
import type { AbiFragment } from "./useAddress";
import type { WalletError } from "@matterlabs/composables";

export const PAYABLE_AMOUNT_PARAM_NAME = "payable_function_payable_amount";

export default (context = useContext()) => {
const walletContext = {
isReady: context.isReady,
Expand Down Expand Up @@ -44,7 +46,7 @@ export default (context = useContext()) => {
const contract = new ethers.Contract(address, [abiFragment], signer!);
const method = contract[abiFragment.name];
const methodArguments = Object.entries(params)
.filter(([key]) => key !== "value")
.filter(([key]) => key !== PAYABLE_AMOUNT_PARAM_NAME)
.map(([, inputValue]) => {
if (inputValue === "true") {
inputValue = true;
Expand All @@ -54,8 +56,7 @@ export default (context = useContext()) => {
return inputValue;
});
const methodOptions = {
value: ethers.utils.parseEther((params.value as string) ?? "0"),
gasLimit: "10000000",
value: ethers.utils.parseEther((params[PAYABLE_AMOUNT_PARAM_NAME] as string) ?? "0"),
};
const res = await method(
...[
Expand Down
14 changes: 7 additions & 7 deletions packages/app/tests/composables/useContractInteraction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ethers } from "ethers";

import { useWalletMock } from "../mocks";

import useContractInteraction from "@/composables/useContractInteraction";
import useContractInteraction, { PAYABLE_AMOUNT_PARAM_NAME } from "@/composables/useContractInteraction";

import type { AbiFragment } from "@/composables/useAddress";

Expand Down Expand Up @@ -116,13 +116,13 @@ describe("useContractInteraction:", () => {
stateMutability: "payable",
},
{
value: "0.1",
[PAYABLE_AMOUNT_PARAM_NAME]: "0.1",
address: ["0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b"],
}
);
expect(mock.mock.lastCall).toEqual([
["0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b"],
{ gasLimit: "10000000", value: ethers.utils.parseEther("0.1") },
{ value: ethers.utils.parseEther("0.1") },
]);
mock.mockRestore();
});
Expand All @@ -139,10 +139,10 @@ describe("useContractInteraction:", () => {
stateMutability: "payable",
},
{
value: "0.1",
[PAYABLE_AMOUNT_PARAM_NAME]: "0.1",
}
);
expect(mock.mock.lastCall).toEqual([{ gasLimit: "10000000", value: ethers.utils.parseEther("0.1") }]);
expect(mock.mock.lastCall).toEqual([{ value: ethers.utils.parseEther("0.1") }]);
mock.mockRestore();
});
it("change input to boolean type", async () => {
Expand All @@ -158,11 +158,11 @@ describe("useContractInteraction:", () => {
stateMutability: "payable",
},
{
value: "0.1",
[PAYABLE_AMOUNT_PARAM_NAME]: "0.1",
bool: "false",
}
);
expect(mock.mock.lastCall).toEqual([false, { gasLimit: "10000000", value: ethers.utils.parseEther("0.1") }]);
expect(mock.mock.lastCall).toEqual([false, { value: ethers.utils.parseEther("0.1") }]);
mock.mockRestore();
});
it("sets isRequestPending to true when request is pending", async () => {
Expand Down
Loading