diff --git a/deps/concordium-dapp-libraries b/deps/concordium-dapp-libraries index 5f0da435..1aa4c381 160000 --- a/deps/concordium-dapp-libraries +++ b/deps/concordium-dapp-libraries @@ -1 +1 @@ -Subproject commit 5f0da435efb7ff2a12de19b46c02ebb680c732e0 +Subproject commit 1aa4c381b4484c5f3840f96f21e1edcab0474496 diff --git a/wallet-connect-test-bench/front-end/.eslintrc.cjs b/wallet-connect-test-bench/front-end/.eslintrc.cjs new file mode 100644 index 00000000..0ee5dc19 --- /dev/null +++ b/wallet-connect-test-bench/front-end/.eslintrc.cjs @@ -0,0 +1,32 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + // React plugins + "plugin:react/recommended", + "plugin:react/jsx-runtime", + "plugin:react-hooks/recommended", + "plugin:jsx-a11y/recommended", + // Other plugins: + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "prettier", + ], + parser: "@typescript-eslint/parser", + plugins: ["react", "@typescript-eslint"], + parserOptions: { + ecmaVersion: "latest", + ecmaFeatures: { jsx: true }, + sourceType: "module", + project: ["./tsconfig.json", "./tsconfig.node.json"], + tsconfigRootDir: __dirname, + }, + settings: { + react: { + version: "detect", + }, + }, + rules: { + "@typescript-eslint/no-unused-vars": "warn", + }, +}; diff --git a/wallet-connect-test-bench/front-end/.eslintrc.js b/wallet-connect-test-bench/front-end/.eslintrc.js deleted file mode 100644 index d6221577..00000000 --- a/wallet-connect-test-bench/front-end/.eslintrc.js +++ /dev/null @@ -1,67 +0,0 @@ -module.exports = { - parser: "@typescript-eslint/parser", - extends: [ - "airbnb", - "airbnb-typescript", - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended", - ], - parserOptions: { - ecmaVersion: 2020, - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - project: "tsconfig.json", - createDefaultProgram: true, - }, - env: { - browser: true, - jest: true, - node: true, - }, - rules: { - "import/prefer-default-export": 0, - "no-restricted-exports": 0, - "no-restricted-syntax": [ - "error", - "ForInStatement", - "LabeledStatement", - "WithStatement", - ], - "react/jsx-props-no-spreading": 0, - "react/require-default-props": 0, - "class-methods-use-this": 0, - "jsx-a11y/no-autofocus": 0, - "no-await-in-loop": 0, - "import/no-extraneous-dependencies": [ - "error", - { - devDependencies: [ - "**/*.stories.tsx", - "**/build/**/*", - "**/*.config.js", - "**/*.config.ts", - "**/test/**/*", - ], - }, - ], - "jsx-a11y/label-has-associated-control": [ - "error", - { - required: { - some: ["nesting", "id"], - }, - }, - ], - "prettier/prettier": [ - "error", - { - trailingComma: "es5", - singleQuote: true, - printWidth: 120, - tabWidth: 4, - }, - ], - }, -}; diff --git a/wallet-connect-test-bench/front-end/CHANGELOG.md b/wallet-connect-test-bench/front-end/CHANGELOG.md index f0e72507..4f85a991 100644 --- a/wallet-connect-test-bench/front-end/CHANGELOG.md +++ b/wallet-connect-test-bench/front-end/CHANGELOG.md @@ -1,8 +1,14 @@ ## Unreleased changes +## 1.5.4 + +- Update `@concordium/web-sdk` dependency to version 7.0.0. +- Update `dapp-library` dependency. +- Enable tests for signing of byte messages in the mobile wallets. + ## 1.5.3 -Update smart contract to be more efficient. +- Update smart contract to be more efficient. ## 1.5.2 @@ -18,12 +24,12 @@ Update smart contract to be more efficient. ## 1.4.1 -- Add maxEnergy input field +- Add maxEnergy input field. ## 1.4.0 -- Add link to source code -- Change that selected switch option is in bold font +- Add link to source code. +- Change that selected switch option is in bold font. ## 1.2.0 diff --git a/wallet-connect-test-bench/front-end/README.md b/wallet-connect-test-bench/front-end/README.md index b4109df0..0829b6b7 100644 --- a/wallet-connect-test-bench/front-end/README.md +++ b/wallet-connect-test-bench/front-end/README.md @@ -26,15 +26,8 @@ cd ../wallet-connect-test-bench/front-end To start the front end locally, do the following: -- Run `yarn build` in this folder. -- Run `yarn start` in this folder. -- Open URL logged in console (typically http://127.0.0.1:8080). - -To have hot-reload (useful for development), do the following instead: - -- Run `yarn watch` in this folder in a terminal. -- Run `yarn start` in this folder in another terminal. -- Open URL logged in console (typically http://127.0.0.1:8080). +- Run `yarn dev` in this folder. +- Open URL logged in console (typically http://localhost:5174/). ## Using yarn (on Unix/macOS systems) diff --git a/wallet-connect-test-bench/front-end/package.json b/wallet-connect-test-bench/front-end/package.json index 6b8a5c47..ba5e048f 100644 --- a/wallet-connect-test-bench/front-end/package.json +++ b/wallet-connect-test-bench/front-end/package.json @@ -1,19 +1,19 @@ { "name": "test-bench-for-wallets", "packageManager": "yarn@3.2.0", - "version": "1.5.3", + "version": "1.5.4", "license": "Apache-2.0", "type": "module", "engines": { "node": ">=16.x" }, "dependencies": { - "@concordium/browser-wallet-api-helpers": "^2.4.0", + "@concordium/browser-wallet-api-helpers": "^3.0.0", "@concordium/react-components": "../../deps/concordium-dapp-libraries/packages/react-components", "@concordium/wallet-connectors": "../../deps/concordium-dapp-libraries/packages/wallet-connectors", - "@concordium/web-sdk": "^6.0.0", + "@concordium/web-sdk": "^7.0.0", "@walletconnect/types": "^2.1.4", - "eslint": "^8.37.0", + "json-bigint": "^1.0.0", "moment": "^2.29.4", "react": "^18.1.0", "react-dom": "^18.1.0", @@ -22,9 +22,10 @@ "resolutions": { "@concordium/wallet-connectors": "../../deps/concordium-dapp-libraries/packages/wallet-connectors", "@concordium/react-components": "../../deps/concordium-dapp-libraries/packages/react-components", - "@concordium/web-sdk": "^6.0.0" + "@concordium/web-sdk": "^7.0.0" }, "devDependencies": { + "@types/json-bigint": "^1.0.4", "@types/react": "^18.0.9", "@types/react-dom": "^18.0.5", "@typescript-eslint/eslint-plugin": "^6.0.0", diff --git a/wallet-connect-test-bench/front-end/src/Main.tsx b/wallet-connect-test-bench/front-end/src/Main.tsx index e1b16a0d..d83905ba 100644 --- a/wallet-connect-test-bench/front-end/src/Main.tsx +++ b/wallet-connect-test-bench/front-end/src/Main.tsx @@ -1,6 +1,7 @@ -/* eslint-disable no-console */ import { useEffect, useState, ChangeEvent, PropsWithChildren } from "react"; import Switch from "react-switch"; +import JSONbig from "json-bigint"; +import { Buffer } from "buffer/"; import { toBuffer, serializeTypeValue } from "@concordium/web-sdk"; import { useGrpcClient, @@ -179,7 +180,7 @@ export default function Main(props: WalletConnectionProps) { }; // Refresh accountInfo periodically. - // eslint-disable-next-line consistent-return + useEffect(() => { if (grpcClient && account) { const interval = setInterval(() => { @@ -187,7 +188,7 @@ export default function Main(props: WalletConnectionProps) { accountInfo(grpcClient, account) .then((value) => { if (value !== undefined) { - setAccountBalance(value.accountAmount.toString()); + setAccountBalance(value.accountAmount.microCcdAmount.toString()); } setViewError(""); }) @@ -201,7 +202,7 @@ export default function Main(props: WalletConnectionProps) { }, [grpcClient, account]); // Refresh smartContractInfo periodically. - // eslint-disable-next-line consistent-return + useEffect(() => { if (grpcClient) { const interval = setInterval(() => { @@ -223,7 +224,7 @@ export default function Main(props: WalletConnectionProps) { }, [grpcClient, account]); // Refresh view periodically. - // eslint-disable-next-line consistent-return + useEffect(() => { if (grpcClient && account) { const interval = setInterval(() => { @@ -249,7 +250,7 @@ export default function Main(props: WalletConnectionProps) { accountInfo(grpcClient, account) .then((value) => { if (value !== undefined) { - setAccountBalance(value.accountAmount.toString()); + setAccountBalance(value.accountAmount.microCcdAmount.toString()); } setViewError(""); }) @@ -258,10 +259,10 @@ export default function Main(props: WalletConnectionProps) { setAccountBalance(""); }); } - }, [grpcClient]); + }, [grpcClient, account]); useEffect(() => { - if (grpcClient && account) { + if (grpcClient) { smartContractInfo(grpcClient) .then((value) => { if (value !== undefined) { @@ -277,7 +278,7 @@ export default function Main(props: WalletConnectionProps) { }, [grpcClient]); useEffect(() => { - if (grpcClient && account) { + if (grpcClient) { view(grpcClient) .then((value) => { if (value !== undefined) { @@ -577,7 +578,7 @@ export default function Main(props: WalletConnectionProps) { getValue(grpcClient, useModuleSchema, readDropDown) .then((value) => { if (value !== undefined) { - setReturnValue(JSON.stringify(value)); + setReturnValue(JSONbig.stringify(value)); } }) .catch((e) => { @@ -1113,7 +1114,7 @@ export default function Main(props: WalletConnectionProps) { setByteSignature(""); const promise = connection.signMessage(account, { type: "BinaryMessage", - value: serializedMessage, + value: Buffer.from(serializedMessage.buffer), schema: { type: "TypeSchema", value: toBuffer( @@ -1238,7 +1239,7 @@ export default function Main(props: WalletConnectionProps) {
Smart contract state:
-                {JSON.stringify(record, null, "\t")}
+                {JSONbig.stringify(record, null, "\t")}
               
diff --git a/wallet-connect-test-bench/front-end/src/Root.tsx b/wallet-connect-test-bench/front-end/src/Root.tsx index d6125c3e..d9a0217c 100644 --- a/wallet-connect-test-bench/front-end/src/Root.tsx +++ b/wallet-connect-test-bench/front-end/src/Root.tsx @@ -1,11 +1,12 @@ import { WithWalletConnector, TESTNET } from "@concordium/react-components"; -import Main from "./Main"; /** * Connect to wallet, setup application state context, and render children when the wallet API is ready for use. */ import React from "react"; import ReactDOM from "react-dom/client"; + +import Main from "./Main"; import "./index.css"; ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/wallet-connect-test-bench/front-end/src/WalletConnectorTypeButton.tsx b/wallet-connect-test-bench/front-end/src/WalletConnectorTypeButton.tsx index 5d4ca241..a37373bc 100644 --- a/wallet-connect-test-bench/front-end/src/WalletConnectorTypeButton.tsx +++ b/wallet-connect-test-bench/front-end/src/WalletConnectorTypeButton.tsx @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ - import { useCallback } from "react"; import { ConnectorType, @@ -32,7 +30,7 @@ export function WalletConnectionTypeButton(props: Props) { const onClick = useCallback(() => { setWaitingForUser(false); select(); - }, [select]); + }, [select, setWaitingForUser]); return (