From ce8dfcbca1d39faf6df69ebd466d299d15c35cc9 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Wed, 13 Dec 2023 14:25:42 +0000 Subject: [PATCH] fix(): unignore dist --- .eslintignore | 2 +- .gitignore | 4 +- cypress.config.js | 6 +- packages/plugin/.gitignore | 1 - packages/plugin/dist/extension.js | 108 ------------------------------ tsconfig.json | 5 -- 6 files changed, 5 insertions(+), 121 deletions(-) delete mode 100644 packages/plugin/dist/extension.js diff --git a/.eslintignore b/.eslintignore index c66e0ed..c7dc29d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,3 @@ -dist +packages/**/dist/**/* node_modules public \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7baef55..22e6ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,4 @@ #!.yarn/cache .pnp.* -node_modules -dist -packages/**/dist \ No newline at end of file +node_modules \ No newline at end of file diff --git a/cypress.config.js b/cypress.config.js index 0969aae..2a701f8 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,6 +2,6 @@ module.exports = { e2e: { setupNodeEvents(on, config) { // implement node event listeners here - }, - }, -}; + } + } +} diff --git a/packages/plugin/.gitignore b/packages/plugin/.gitignore index a547bf3..251ce6d 100644 --- a/packages/plugin/.gitignore +++ b/packages/plugin/.gitignore @@ -8,7 +8,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist dist-ssr *.local diff --git a/packages/plugin/dist/extension.js b/packages/plugin/dist/extension.js deleted file mode 100644 index eb09492..0000000 --- a/packages/plugin/dist/extension.js +++ /dev/null @@ -1,108 +0,0 @@ -import { Keyring } from '@polkadot/keyring'; -import { TypeRegistry } from '@polkadot/types'; -import { cryptoWaitReady } from '@polkadot/util-crypto'; -export class Extension { - authRequests = {}; - accounts = []; - txRequests = {}; - keyring; - allowedOrigins = {}; - reset = () => { - this.authRequests = {}; - this.accounts = []; - this.txRequests = {}; - this.keyring = undefined; - this.allowedOrigins = {}; - }; - init = async (accounts, allowedOrigin) => { - this.reset(); - this.accounts = accounts; - await cryptoWaitReady(); - this.keyring = new Keyring({ type: 'sr25519' }); - accounts.forEach(({ mnemonic }) => { - // we only add to the keyring the accounts with a known mnemonic - !!mnemonic && this.keyring?.addFromUri(mnemonic); - }); - const accountAddresses = accounts.map(({ address }) => address); - // if passed along all the accounts will be allowed for this origin - // there will be no need to authorize the connection - if (allowedOrigin) { - this.allowedOrigins[allowedOrigin] = accountAddresses; - } - }; - getInjectedEnable = () => { - return { - 'polkadot-js': { - enable: (origin) => { - const resolvedObject = (selectedAccounts) => ({ - accounts: { - get: () => selectedAccounts, - subscribe: (cb) => cb(selectedAccounts) - }, - signer: { - signPayload: (payload) => { - return new Promise((resolve, reject) => { - const id = Date.now(); - const res = () => { - const registry = new TypeRegistry(); - registry.setSignedExtensions(payload.signedExtensions); - const pair = this.keyring?.getPair(payload.address); - if (!pair) { - console.error(`Pair not found for encoded address ${payload.address}, with keyring:`, this.keyring?.toJson); - return; - } - const signature = registry - .createType('ExtrinsicPayload', payload, { - version: payload.version - }) - .sign(pair); - resolve({ id, signature: signature.signature }); - }; - const rej = (reason) => reject(new Error(reason)); - this.txRequests[id] = { id, payload, resolve: res, reject: rej }; - }); - } - } - }); - // this origin has already allowed some accounts - if (this.allowedOrigins[origin]) { - // return the list of accounts - const res = resolvedObject(this.accounts.filter(({ address }) => this.allowedOrigins[origin].includes(address))); - return Promise.resolve(res); - } - return new Promise((resolve, reject) => { - const timestamp = Date.now(); - const res = (accountAddresses) => { - const selectedAccounts = this.accounts.filter(({ address }) => accountAddresses.includes(address)); - // store the allowed accounts for this orgin - this.allowedOrigins[origin] = accountAddresses; - const res = resolvedObject(selectedAccounts); - resolve(res); - }; - const rej = (reason) => reject(new Error(reason)); - this.authRequests[timestamp] = { id: timestamp, origin, resolve: res, reject: rej }; - }); - }, - version: '1' - } - }; - }; - getAuthRequests = () => { - return this.authRequests; - }; - enableAuth = (id, accountAddresses) => { - this.authRequests[id].resolve(accountAddresses); - }; - rejectAuth = (id, reason) => { - this.authRequests[id].reject(reason); - }; - getTxRequests = () => { - return this.txRequests; - }; - approveTx = (id) => { - this.txRequests[id].resolve(); - }; - rejectTx = (id, reason) => { - this.txRequests[id].reject(reason); - }; -} diff --git a/tsconfig.json b/tsconfig.json index 9065695..0ec083e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,5 @@ { - "exclude": [ - "packages/**/tests/**", - "packages/**/dist/**" - ], "compilerOptions": { - "baseUrl": ".", "paths": { "@chainsafe/cypress-polkadot-wallet/*": ["packages/plugin"],