Skip to content

Commit

Permalink
Bump dev deps (#1215)
Browse files Browse the repository at this point in the history
* Bump dev deps

* Bump deps
  • Loading branch information
jacogr authored Feb 25, 2023
1 parent c5aa85b commit c9edeea
Show file tree
Hide file tree
Showing 29 changed files with 612 additions and 2,257 deletions.
17 changes: 0 additions & 17 deletions jest.config.cjs

This file was deleted.

16 changes: 0 additions & 16 deletions jest/setupEnv.js

This file was deleted.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"build:ui": "cd packages/extension && NODE_ENV=production yarn polkadot-exec-webpack --config webpack.extension.cjs --mode production",
"build:zip": "yarn build:zip:dst && yarn build:zip:src",
"build:zip:dst": "rm -rf ./master-build.zip && cd packages/extension/build && zip -r -FS ../../../master-build.zip .",
"build:zip:src": "rm -rf ./master-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-src.zip packages .editorconfig .eslintignore .eslintrc.js babel.config.cjs CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.js jest.config.cjs LICENSE package.json README.md tsconfig.json yarn.lock",
"build:zip:src": "rm -rf ./master-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-src.zip packages .editorconfig .eslintignore .eslintrc.js babel.config.cjs CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.js LICENSE package.json README.md tsconfig.json yarn.lock",
"clean": "polkadot-dev-clean-build",
"lint": "polkadot-dev-run-lint",
"postinstall": "polkadot-dev-yarn-only",
"start": "yarn watch",
"test": "EXTENSION_PREFIX='test' polkadot-dev-run-test --env jest",
"test:one": "EXTENSION_PREFIX='test' polkadot-dev-run-test --env jest",
"test": "EXTENSION_PREFIX='test' polkadot-dev-run-test --env browser ^:.spec.tsx",
"test:one": "EXTENSION_PREFIX='test' polkadot-dev-run-test --env browser",
"watch": "cd packages/extension && yarn polkadot-exec-webpack --config webpack.watch.cjs --mode development --watch"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@polkadot/dev": "^0.68.41",
"@types/jest": "^29.4.0",
"@babel/core": "^7.21.0",
"@polkadot/dev": "^0.69.14",
"@types/node": "^18.14.1",
"i18next-scanner": "^4.1.1",
"sinon-chrome": "^3.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"version": "0.44.10-0-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"@polkadot/api": "^9.14.2",
"@polkadot/extension-chains": "^0.44.10-0-x",
"@polkadot/extension-dapp": "^0.44.10-0-x",
Expand Down
113 changes: 67 additions & 46 deletions packages/extension-base/src/background/handlers/Extension.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright 2019-2023 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0

// eslint-disable-next-line spaced-comment
/// <reference types="@polkadot/dev/node/test/node" />

import '@polkadot/extension-mocks/chrome';

import type { ResponseSigning } from '@polkadot/extension-base/background/types';
Expand Down Expand Up @@ -28,23 +31,29 @@ describe('Extension', () => {
const address = '5FbSap4BsWfjyRhCchoVdZHkDnmDm3NEgLZ25mesq4aw2WvX';

async function createExtension (): Promise<Extension> {
await cryptoWaitReady();

keyring.loadAll({ store: new AccountsStore() });
const authUrls: AuthUrls = {};

authUrls['localhost:3000'] = {
authorizedAccounts: [address],
count: 0,
id: '11',
origin: 'example.com',
url: 'http://localhost:3000'
};
localStorage.setItem('authUrls', JSON.stringify(authUrls));
state = new State();
tabs = new Tabs(state);

return new Extension(state);
try {
await cryptoWaitReady();

keyring.loadAll({ store: new AccountsStore() });
const authUrls: AuthUrls = {};

authUrls['localhost:3000'] = {
authorizedAccounts: [address],
count: 0,
id: '11',
origin: 'example.com',
url: 'http://localhost:3000'
};
localStorage.setItem('authUrls', JSON.stringify(authUrls));
state = new State();
tabs = new Tabs(state);

return new Extension(state);
} catch (e) {
console.error(e);

throw e;
}
}

const createAccount = async (type?: KeypairType): Promise<string> => {
Expand Down Expand Up @@ -76,7 +85,7 @@ describe('Extension', () => {
extension = await createExtension();
});

test('exports account from keyring', async () => {
it('exports account from keyring', async () => {
const { pair: { address } } = keyring.addUri(suri, password);
const result = await extension.handle('id', 'pri(accounts.export)', {
address,
Expand All @@ -94,36 +103,36 @@ describe('Extension', () => {
address = await createAccount();
});

test('pri(derivation.validate) passes for valid suri', async () => {
it('pri(derivation.validate) passes for valid suri', async () => {
const result = await extension.handle('id', 'pri(derivation.validate)', {
parentAddress: address,
parentPassword: password,
suri: '//path'
}, {} as chrome.runtime.Port);

expect(result).toStrictEqual({
expect(result).toEqual({
address: '5FP3TT3EruYBNh8YM8yoxsreMx7uZv1J1zNX7fFhoC5enwmN',
suri: '//path'
});
});

test('pri(derivation.validate) throws for invalid suri', async () => {
it('pri(derivation.validate) throws for invalid suri', async () => {
await expect(extension.handle('id', 'pri(derivation.validate)', {
parentAddress: address,
parentPassword: password,
suri: 'invalid-path'
}, {} as chrome.runtime.Port)).rejects.toStrictEqual(new Error('"invalid-path" is not a valid derivation path'));
}, {} as chrome.runtime.Port)).rejects.toThrow(/is not a valid derivation path/);
});

test('pri(derivation.validate) throws for invalid password', async () => {
it('pri(derivation.validate) throws for invalid password', async () => {
await expect(extension.handle('id', 'pri(derivation.validate)', {
parentAddress: address,
parentPassword: 'invalid-password',
suri: '//path'
}, {} as chrome.runtime.Port)).rejects.toStrictEqual(new Error('invalid password'));
}, {} as chrome.runtime.Port)).rejects.toThrow(/invalid password/);
});

test('pri(derivation.create) adds a derived account', async () => {
it('pri(derivation.create) adds a derived account', async () => {
await extension.handle('id', 'pri(derivation.create)', {
name: 'child',
parentAddress: address,
Expand All @@ -134,7 +143,7 @@ describe('Extension', () => {
expect(keyring.getAccounts()).toHaveLength(2);
});

test('pri(derivation.create) saves parent address in meta', async () => {
it('pri(derivation.create) saves parent address in meta', async () => {
await extension.handle('id', 'pri(derivation.create)', {
name: 'child',
parentAddress: address,
Expand All @@ -153,29 +162,31 @@ describe('Extension', () => {
address = await createAccount();
});

test('pri(accounts.changePassword) changes account password', async () => {
it('pri(accounts.changePassword) changes account password', async () => {
const newPass = 'pa55word';
const wrongPass = 'ZZzzZZzz';

await expect(extension.handle('id', 'pri(accounts.changePassword)', {
address,
newPass,
oldPass: wrongPass
}, {} as chrome.runtime.Port)).rejects.toStrictEqual(new Error('oldPass is invalid'));
}, {} as chrome.runtime.Port)).rejects.toThrow(/oldPass is invalid/);

await expect(extension.handle('id', 'pri(accounts.changePassword)', {
const res = await extension.handle('id', 'pri(accounts.changePassword)', {
address,
newPass,
oldPass: password
}, {} as chrome.runtime.Port)).resolves.toEqual(true);
}, {} as chrome.runtime.Port);

expect(res).toEqual(true);

const pair = keyring.getPair(address);

expect(pair.decodePkcs8(newPass)).toEqual(undefined);

expect(() => {
pair.decodePkcs8(password);
}).toThrowError('Unable to decode using the supplied passphrase');
}).toThrow(/Unable to decode using the supplied passphrase/);
});
});

Expand All @@ -202,7 +213,7 @@ describe('Extension', () => {
};
});

test('signs with default signed extensions', async () => {
it('signs with default signed extensions', async () => {
const registry = new TypeRegistry();

registry.setSignedExtensions(payload.signedExtensions);
Expand All @@ -215,14 +226,16 @@ describe('Extension', () => {
expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
}).catch((err) => console.log(err));

await expect(extension.handle('1615192072290.7', 'pri(signing.approve.password)', {
const res = await extension.handle('1615192072290.7', 'pri(signing.approve.password)', {
id: state.allSignRequests[0].id,
password,
savePass: false
}, {} as chrome.runtime.Port)).resolves.toEqual(true);
}, {} as chrome.runtime.Port);

expect(res).toEqual(true);
});

test('signs with default signed extensions - ethereum', async () => {
it('signs with default signed extensions - ethereum', async () => {
const ethAddress = await createAccount('ethereum');
const ethPair = keyring.getPair(ethAddress);

Expand Down Expand Up @@ -261,14 +274,16 @@ describe('Extension', () => {
expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
}).catch((err) => console.log(err));

await expect(extension.handle('1615192072290.7', 'pri(signing.approve.password)', {
const res = await extension.handle('1615192072290.7', 'pri(signing.approve.password)', {
id: state.allSignRequests[0].id,
password,
savePass: false
}, {} as chrome.runtime.Port)).resolves.toEqual(true);
}, {} as chrome.runtime.Port);

expect(res).toEqual(true);
});

test('signs with user extensions, known types', async () => {
it('signs with user extensions, known types', async () => {
const types = {} as unknown as Record<string, string>;

const userExtensions = {
Expand Down Expand Up @@ -323,14 +338,16 @@ describe('Extension', () => {
expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
}).catch((err) => console.log(err));

await expect(extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
const res = await extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
id: state.allSignRequests[0].id,
password,
savePass: false
}, {} as chrome.runtime.Port)).resolves.toEqual(true);
}, {} as chrome.runtime.Port);

expect(res).toEqual(true);
});

test('override default signed extension', async () => {
it('override default signed extension', async () => {
const types = {
FeeExchangeV1: {
assetId: 'Compact<AssetId>',
Expand Down Expand Up @@ -379,14 +396,16 @@ describe('Extension', () => {
expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
}).catch((err) => console.log(err));

await expect(extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
const res = await extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
id: state.allSignRequests[0].id,
password,
savePass: false
}, {} as chrome.runtime.Port)).resolves.toEqual(true);
}, {} as chrome.runtime.Port);

expect(res).toEqual(true);
});

test('signs with user extensions, additional types', async () => {
it('signs with user extensions, additional types', async () => {
const types = {
myCustomType: {
feeExchange: 'Compact<AssetId>',
Expand Down Expand Up @@ -446,11 +465,13 @@ describe('Extension', () => {
expect((result as ResponseSigning)?.signature).toEqual(signatureExpected.signature);
}).catch((err) => console.log(err));

await expect(extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
const res = await extension.handle('1615192062290.7', 'pri(signing.approve.password)', {
id: state.allSignRequests[0].id,
password,
savePass: false
}, {} as chrome.runtime.Port)).resolves.toEqual(true);
}, {} as chrome.runtime.Port);

expect(res).toEqual(true);
});
});
});
2 changes: 1 addition & 1 deletion packages/extension-chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"version": "0.44.10-0-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"@polkadot/extension-inject": "^0.44.10-0-x",
"@polkadot/networks": "^10.4.2",
"@polkadot/util": "^10.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-compat-metamask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"version": "0.44.10-0-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"@metamask/detect-provider": "^1.2.0",
"@polkadot/extension-inject": "^0.44.10-0-x",
"@polkadot/types": "^9.14.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"version": "0.44.10-0-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"@polkadot/extension-inject": "^0.44.10-0-x",
"@polkadot/util": "^10.4.2",
"@polkadot/util-crypto": "^10.4.2"
Expand Down
3 changes: 3 additions & 0 deletions packages/extension-dapp/src/wrapBytes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright 2019-2023 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0

// eslint-disable-next-line spaced-comment
/// <reference types="@polkadot/dev/node/test/node" />

import { u8aConcat, u8aEq, u8aToString } from '@polkadot/util';

import { ETHEREUM, POSTFIX, PREFIX, unwrapBytes, wrapBytes } from './wrapBytes';
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-inject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"version": "0.44.10-0-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"@polkadot/rpc-provider": "^9.14.2",
"@polkadot/types": "^9.14.2",
"@polkadot/util": "^10.4.2",
"@polkadot/util-crypto": "^10.4.2",
"@polkadot/x-global": "^10.4.2"
},
"devDependencies": {
"@types/chrome": "^0.0.216",
"@types/chrome": "^0.0.217",
"@types/firefox-webext-browser": "^109.0.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": "0.44.10-0-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"sinon-chrome": "^3.0.1"
}
}
Loading

0 comments on commit c9edeea

Please sign in to comment.