From 6cbffe1f3e25d7451151801221aa8f8e4a2ff022 Mon Sep 17 00:00:00 2001 From: Jun Ma Date: Wed, 24 May 2023 12:09:47 +0800 Subject: [PATCH 1/4] fix:layout of tooltip is improper (#943) --- styles/tooltip.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/tooltip.scss b/styles/tooltip.scss index 3d2f519be..d3eea3acb 100644 --- a/styles/tooltip.scss +++ b/styles/tooltip.scss @@ -23,7 +23,7 @@ background-color: var(--tooltip-background-color); color: var(--tooltip-font-color); user-select: text; - white-space: normal; + white-space: nowrap; text-align: center; display: none; From 1217e4eb870ec7738b75aa434fc7b904da04925b Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Thu, 25 May 2023 00:29:19 +0800 Subject: [PATCH 2/4] test: fix test case of online data (#948) --- cypress/integration/tokens/index.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/integration/tokens/index.spec.ts b/cypress/integration/tokens/index.spec.ts index 5c5f8435b..d607a1eb4 100644 --- a/cypress/integration/tokens/index.spec.ts +++ b/cypress/integration/tokens/index.spec.ts @@ -202,7 +202,9 @@ context('Tokens List Pages Tests', () => { .first() .find('td') .first() - .should('contain.text', '57us test Collection(57u)') + .should(field => { + expect(field.text()).to.match(/\w+(\w+)/) + }) .next() .should(field => { expect(field.text()).to.match(FULL_ADDRESS_REGEX) From cdeb0483c15f17933fa488e6c92355d342dc71d5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 May 2023 01:11:04 +0800 Subject: [PATCH 3/4] chore(deps): update dependency @cypress/code-coverage to v3.10.6 (#941) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 62 +++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 27479f725..d8a45fe10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "wagmi": "0.10.6" }, "devDependencies": { - "@cypress/code-coverage": "3.10.0", + "@cypress/code-coverage": "3.10.6", "@svgr/webpack": "6.5.1", "@types/node": "18.11.19", "@types/phoenix": "1.5.4", @@ -2605,11 +2605,10 @@ } }, "node_modules/@cypress/code-coverage": { - "version": "3.10.0", - "resolved": "https://registry.npmmirror.com/@cypress/code-coverage/-/code-coverage-3.10.0.tgz", - "integrity": "sha512-K5pW2KPpK4vKMXqxd6vuzo6m9BNgpAv1LcrrtmqAtOJ1RGoEILXYZVost0L6Q+V01NyY7n7jXIIfS7LR3nP6YA==", + "version": "3.10.6", + "resolved": "https://registry.npmjs.org/@cypress/code-coverage/-/code-coverage-3.10.6.tgz", + "integrity": "sha512-ewsNEqEFmirSGeWraOrrn/S64/jCsoA1tVwQ6ySFO+gUhOsaWveoPy8oeX5jzKS2HpqAihuuO3kXSEvVQoPTkw==", "dev": true, - "license": "MIT", "dependencies": { "@cypress/webpack-preprocessor": "^5.11.0", "chalk": "4.1.2", @@ -2618,19 +2617,24 @@ "execa": "4.1.0", "globby": "11.0.4", "istanbul-lib-coverage": "3.0.0", - "js-yaml": "3.14.1", + "js-yaml": "4.1.0", "nyc": "15.1.0" }, "peerDependencies": { "cypress": "*" } }, + "node_modules/@cypress/code-coverage/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/@cypress/code-coverage/node_modules/chalk": { "version": "4.1.2", - "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -2644,10 +2648,21 @@ }, "node_modules/@cypress/code-coverage/node_modules/dayjs": { "version": "1.10.7", - "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.10.7.tgz", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.7.tgz", "integrity": "sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==", + "dev": true + }, + "node_modules/@cypress/code-coverage/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, - "license": "MIT" + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } }, "node_modules/@cypress/request": { "version": "2.88.10", @@ -28135,9 +28150,9 @@ "requires": {} }, "@cypress/code-coverage": { - "version": "3.10.0", - "resolved": "https://registry.npmmirror.com/@cypress/code-coverage/-/code-coverage-3.10.0.tgz", - "integrity": "sha512-K5pW2KPpK4vKMXqxd6vuzo6m9BNgpAv1LcrrtmqAtOJ1RGoEILXYZVost0L6Q+V01NyY7n7jXIIfS7LR3nP6YA==", + "version": "3.10.6", + "resolved": "https://registry.npmjs.org/@cypress/code-coverage/-/code-coverage-3.10.6.tgz", + "integrity": "sha512-ewsNEqEFmirSGeWraOrrn/S64/jCsoA1tVwQ6ySFO+gUhOsaWveoPy8oeX5jzKS2HpqAihuuO3kXSEvVQoPTkw==", "dev": true, "requires": { "@cypress/webpack-preprocessor": "^5.11.0", @@ -28147,13 +28162,19 @@ "execa": "4.1.0", "globby": "11.0.4", "istanbul-lib-coverage": "3.0.0", - "js-yaml": "3.14.1", + "js-yaml": "4.1.0", "nyc": "15.1.0" }, "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "chalk": { "version": "4.1.2", - "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { @@ -28163,9 +28184,18 @@ }, "dayjs": { "version": "1.10.7", - "resolved": "https://registry.npmmirror.com/dayjs/-/dayjs-1.10.7.tgz", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.7.tgz", "integrity": "sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==", "dev": true + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } } } }, diff --git a/package.json b/package.json index adc6ae5f2..0abc5a401 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "wagmi": "0.10.6" }, "devDependencies": { - "@cypress/code-coverage": "3.10.0", + "@cypress/code-coverage": "3.10.6", "@svgr/webpack": "6.5.1", "@types/node": "18.11.19", "@types/phoenix": "1.5.4", From bc0727ae8c751e80ea3ec2bd1d8f62a182d32d52 Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Fri, 26 May 2023 11:54:41 +0800 Subject: [PATCH 4/4] fix: support complex arguments/response in contract call (#942) --- components/ContractInfo/index.tsx | 41 ++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/components/ContractInfo/index.tsx b/components/ContractInfo/index.tsx index cd40c27be..67e30e3a3 100644 --- a/components/ContractInfo/index.tsx +++ b/components/ContractInfo/index.tsx @@ -2,7 +2,7 @@ import type { PolyjuiceContract as PolyjuiceContractProps } from 'components/Acc import { useState, useEffect } from 'react' import { useTranslation } from 'next-i18next' import NextLink from 'next/link' -import { utils } from 'ethers' +import { ethers, utils } from 'ethers' import OpenInNewIcon from 'assets/icons/open-in-new.svg' import ExpandIcon from 'assets/icons/expand.svg' import { currentChain as targetChain } from 'utils' @@ -128,7 +128,22 @@ const ContractInfo: React.FC<{ address: string; contract: PolyjuiceContractProps const method = isCallStatic ? contract.callStatic[contract.interface.functions[signature].name] : contract[contract.interface.functions[signature].name] - const params = Array.from(paramInputList).map(i => i.value) + + const fragment = contract.interface.functions[signature] + + const params = Array.from(paramInputList).map((p, idx) => { + if (fragment.inputs[idx].type.endsWith('[]')) { + try { + return JSON.parse(p.value) + } catch { + return p.value + .replace(/(\[|\])/g, '') + .split(',') + .map(v => v.trim()) + } + } + return p.value + }) if (!method) return btn.disabled = true @@ -160,6 +175,11 @@ const ContractInfo: React.FC<{ address: string; contract: PolyjuiceContractProps try { const pCKB = form.querySelector('input[name=pCKB]')?.value ?? '0' const result = await method(...params, { value: utils.parseEther(pCKB) }) + + if (!resInputList.length) { + return + } + if (tabIdx === 2) { const elm = resInputList[0] if (elm) { @@ -170,9 +190,22 @@ const ContractInfo: React.FC<{ address: string; contract: PolyjuiceContractProps window.open(`/tx/${result.hash}`) } } + return + } + + if (!Array.isArray(result)) { + resInputList[0].value = result.toString() + return + } + + if (result.length <= fragment.outputs?.length) { + result.forEach((res, i) => { + if (resInputList[i]) { + resInputList[i].value = res.toString() + } + }) } else { - const resList = Array.isArray(result) ? result : [result] - resList.map((res, i) => (resInputList[i] ? (resInputList[i].value = res.toString()) : null)) + resInputList[0].value = `[${result.join(', ')}]` } } catch (err: any) { if (err.code === 4001 || err.code === 'ACTION_REJECTED') {