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 all 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
118 changes: 59 additions & 59 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 @@ -139,54 +139,54 @@ jobs:
name: portal_e2e_${{ github.run_number }}_artifacts
path: packages/app/tests/e2e/artifacts/*

publish:
name: Allure Report
runs-on: ubuntu-latest
permissions:
contents: write
needs: e2e
if: always()
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v2
with:
name: allure-results
path: packages/app/allure-results

- name: Get Allure history
uses: actions/checkout@v3
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report action from marketplace
uses: simple-elf/allure-report-action@v1.7
if: always()
id: allure-report
with:
allure_results: packages/app/allure-results
gh_pages: gh-pages
allure_report: allure-report
allure_history: allure-history
keep_reports: 10

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

- name: Prepare a link
run: |
echo "BASE64_SEARCH_REQUEST=$(echo '${{ env.ALLURE_SEARCH_REQUEST }}' | base64)" >> $GITHUB_ENV

- name: Publish Allure link to GIT Summary
run: |
LINK1="${{ vars.ALLURE_ENDPOINT }}project/${{ vars.ALLURE_PROJECT_ID }}/launches?search=${{ env.BASE64_SEARCH_REQUEST }}"
LINK2="https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html"
echo "Allure [Private]($LINK1) and [Public]($LINK2) links:rocket: in git run #${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
# publish:
# name: Allure Report
# runs-on: ubuntu-latest
# permissions:
# contents: write
# needs: e2e
# if: always()
# steps:
# - uses: actions/checkout@v3

# - uses: actions/download-artifact@v4
# with:
# name: allure-results
# path: packages/app/allure-results

# - name: Get Allure history
# uses: actions/checkout@v3
# if: always()
# continue-on-error: true
# with:
# ref: gh-pages
# path: gh-pages

# - name: Allure Report action from marketplace
# uses: simple-elf/allure-report-action@v1.7
# if: always()
# id: allure-report
# with:
# allure_results: packages/app/allure-results
# gh_pages: gh-pages
# allure_report: allure-report
# allure_history: allure-history
# keep_reports: 10

# - name: Deploy report to Github Pages
# if: always()
# uses: peaceiris/actions-gh-pages@v2
# env:
# PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PUBLISH_BRANCH: gh-pages
# PUBLISH_DIR: allure-history

# - name: Prepare a link
# run: |
# echo "BASE64_SEARCH_REQUEST=$(echo '${{ env.ALLURE_SEARCH_REQUEST }}' | base64)" >> $GITHUB_ENV

# - name: Publish Allure link to GIT Summary
# run: |
# LINK1="${{ vars.ALLURE_ENDPOINT }}project/${{ vars.ALLURE_PROJECT_ID }}/launches?search=${{ env.BASE64_SEARCH_REQUEST }}"
# LINK2="https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html"
# echo "Allure [Private]($LINK1) and [Public]($LINK2) links:rocket: in git run #${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
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