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

Try code cov fix ci issue #5

Merged
merged 13 commits into from
Jan 13, 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/dapp/
4 changes: 2 additions & 2 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -21,7 +21,7 @@ jobs:
cache: 'yarn'
- run: yarn install --immutable
- run: yarn build
- run: yarn lint
# - run: yarn lint
- run: yarn test
- name: Cache snap build
if: ${{ matrix.node-version == '18.x' }}
Expand Down
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"json.schemas": [
{
"fileMatch": ["snap.manifest.json"],
"fileMatch": [
"snap.manifest.json"
],
"url": "https://raw.githubusercontent.com/MetaMask/SIPs/main/assets/sip-9/snap.manifest.schema.json"
}
],
"cSpell.words": [
"lavamoat",
"nvmrc",
"packagejson"
]
}
}
1 change: 1 addition & 0 deletions packages/dapp/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# A simple dApp for PolkaMask

This is a simple app designed for testing Polkamask. For a complete experience, please visit <a href='https://apps.polkagate.xyz'>apps.polkagate.xyz</a>.
4 changes: 2 additions & 2 deletions packages/dapp/dev package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dapp",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"dependencies": {
"@emotion/react": "latest",
Expand Down Expand Up @@ -54,4 +54,4 @@
"last 1 safari version"
]
}
}
}
4 changes: 2 additions & 2 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@polkadot/api-derive": "latest",
"@polkadot/apps-config": "latest",
"@polkadot/extension-inject": "latest",
"@polkagate/extension-dapp": "^0.46.6-17",
"@polkagate/extension-dapp": "^0.46.7-20",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand Down Expand Up @@ -54,4 +54,4 @@
"last 1 safari version"
]
}
}
}
2 changes: 1 addition & 1 deletion packages/dapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function App() {

useEffect(() => {
isPolkaMaskInstalled && web3Enable('PolkaMask-dapp').then((ext: InjectedExtension[] | undefined) => {
console.log('all injected extensions:', ext);
console.log('All injected extensions:', ext);
setExtensions(ext);
});
}, [isPolkaMaskInstalled]);
Expand Down
17 changes: 11 additions & 6 deletions packages/dapp/src/TransferFund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Props {
token: string | undefined;

}
function TransferFund({ api, account, balances, currentChainName, formatted, isPolkaMaskInstalled, token }: Props) {
function TransferFund({ api, account, balances, currentChainName, formatted, isPolkaMaskInstalled, token }: Props):React.ReactElement<Props> {
const [toAddress, setToAddress] = useState<string>();
const [_signature, setSignature] = useState<string>();
const [_result, setResult] = useState<TxResult>();
Expand All @@ -47,6 +47,9 @@ function TransferFund({ api, account, balances, currentChainName, formatted, isP
}, [],);

const handleSendClick = async () => {
setSignature(undefined);
setResult(undefined);

try {
if (!api || !account || !toAddress) {
return;
Expand Down Expand Up @@ -184,11 +187,13 @@ function TransferFund({ api, account, balances, currentChainName, formatted, isP
variant="contained"
onClick={handleSendClick}
disabled={
!api ||
!isPolkaMaskInstalled ||
waitingForUserApproval ||
!transferAmount ||
!toAddress
(!api ||
!isPolkaMaskInstalled ||
waitingForUserApproval ||
!transferAmount ||
!toAddress)
||
(!!_signature && !_result)
}
sx={{ fontSize: '18px', width: '100%' }}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"include": [
"src"
]
}
}
5 changes: 1 addition & 4 deletions packages/snap/PrivacyPolicy.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,4 @@ We will let you know via email and/or a prominent notice on our Service, prior t
You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.

## Contact Us
If you have any questions about this Privacy Policy, please contact us at [Twitter](https://twitter.com/polkagate), [Email](mailto:[email protected]), [Element](https://matrix.to/#/%23polkagate:matrix.org).



If you have any questions about this Privacy Policy, please contact us at [Twitter](https://twitter.com/polkagate), [Email](mailto:[email protected]), [Element](https://matrix.to/#/%23polkagate:matrix.org).
1 change: 1 addition & 0 deletions packages/snap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ The Polkagate Signer is currently operational within the Metamask Flask and is i
To Publish on NPM:
adjust version in package.json and snap.manifest.json
yarn build
cd packages/snap/
npm publish --auth-type=web
--!>
2 changes: 1 addition & 1 deletion packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@metamask/eslint-config-typescript": "^10.0.0",
"@metamask/snaps-cli": "^4.0.0",
"@metamask/snaps-jest": "^4.0.1",
"@metamask/utils": "latest",
"@metamask/utils": "^8.2.1",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"eslint": "^8.21.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/rpc/signRaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const signRaw = async (
const isConfirmed = await showConfirmSignRaw(origin, data);

if (!isConfirmed) {
throw new Error('User declined the signing request.');
throw new Error(`User ${address} declined the signing request.`);
}
const keypair = await getKeyPair();

Expand Down
10 changes: 9 additions & 1 deletion packages/snap/src/ui/showConfirmTx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/* eslint-disable no-case-declarations */
/* eslint-disable jsdoc/require-jsdoc */
import { RowVariant, divider, heading, image, panel, row, text } from '@metamask/snaps-sdk';
import {
RowVariant,
divider,
heading,
panel,
row,
text,
} from '@metamask/snaps-sdk';
import { ApiPromise } from '@polkadot/api';
import { SignerPayloadJSON } from '@polkadot/types/types';
import { bnToBn } from '@polkadot/util';
Expand Down Expand Up @@ -39,6 +46,7 @@ const transactionContent = (
const indexOfFirstSvgTag = maybeSvgString.indexOf('<svg');
let chainLogoSvg = EMPTY_LOGO;
if (indexOfFirstSvgTag !== -1) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
chainLogoSvg = maybeSvgString.substring(indexOfFirstSvgTag);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/util/getApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export async function getApi(genesisHash: string): Promise<ApiPromise> {
const api = await ApiPromise.create({ provider: httpProvider });

return api;
}
}
5 changes: 4 additions & 1 deletion packages/snap/src/util/getApiEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import type { LinkOption } from '@polkadot/apps-config/endpoints/types';
const endpoints = createWsEndpoints((k, v) => v?.toString() || k);

/**
* Get all api endpoint info using api url.
*
* @param apiUrl - An url of an endpoint.
* @returns The linkOption related to the url.
*/
export function getApiEndpoint(apiUrl?: string): LinkOption | null {
return endpoints.find(({ value }) => value === apiUrl) || null;
}
}
2 changes: 1 addition & 1 deletion packages/snap/src/util/getChainName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const sanitizeChainName = (chainName: string | undefined) =>
?.replace(' chain', '')
?.replace(' Chain', '')
?.replace(' Finance', '')
?.replace(/\s/g, '');
?.replace(/\s/gu, '');

// eslint-disable-next-line jsdoc/require-jsdoc
export default function getChainName(
Expand Down
6 changes: 4 additions & 2 deletions packages/snap/src/util/getLogo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import getChainName from './getChainName';
const endpoints = createWsEndpoints(() => '');

/**
* @param _genesisHash
* @description get logo of a chain based on its genesisHash
* Find a chain logo related to its genesisHAsh.
*
* @param _genesisHash - A genesisHash of a chain.
* @returns The logo in base64 format.
*/
export default function getLogo(_genesisHash: string): string {
const chainName = getChainName(_genesisHash);
Expand Down
Loading
Loading