Swap to yarn 2 (#255)

* Swap to yarn 2

* Subscription callback
This commit is contained in:
Jaco Greeff 2020-02-28 15:01:33 +01:00 committed by GitHub
parent 1f7c1be4bd
commit e2033ba38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 91412 additions and 15185 deletions

View File

@ -26,7 +26,7 @@ jobs:
${{ runner.os }}-yarn-
- name: lint
run: |
yarn install --frozen-lockfile
yarn install | grep -v 'YN0013'
yarn lint
test:
@ -53,7 +53,7 @@ jobs:
${{ runner.os }}-yarn-
- name: test
run: |
yarn install --frozen-lockfile
yarn install | grep -v 'YN0013'
yarn test
build_code:
@ -80,5 +80,5 @@ jobs:
${{ runner.os }}-yarn-
- name: build
run: |
yarn install --frozen-lockfile
yarn install | grep -v 'YN0013'
yarn build

View File

@ -38,7 +38,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --frozen-lockfile
yarn install | grep -v 'YN0013'
yarn polkadot-ci-ghact-build
dummy:

4
.gitignore vendored
View File

@ -8,6 +8,10 @@ tmp/
.env.test.local
.env.production.local
.npmrc
.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*
cc-test-reporter
lerna-debug.log*
master-build.zip

File diff suppressed because one or more lines are too long

34806
.yarn/plugins/@yarnpkg/plugin-version.js vendored Normal file

File diff suppressed because one or more lines are too long

58
.yarn/releases/yarn-berry.js vendored Executable file

File diff suppressed because one or more lines are too long

12
.yarnrc.yml Normal file
View File

@ -0,0 +1,12 @@
enableImmutableInstalls: false
enableProgressBars: false
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.js
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-berry.js

View File

@ -12,9 +12,9 @@
"yarn": "^1.10.1"
},
"resolutions": {
"@polkadot/api": "^1.4.0-beta.46",
"@polkadot/api": "^1.5.0-beta.12",
"@polkadot/keyring": "^2.5.1",
"@polkadot/types": "^1.4.0-beta.46",
"@polkadot/types": "^1.5.0-beta.12",
"@polkadot/util": "^2.5.1",
"@polkadot/util-crypto": "^2.5.1",
"babel-core": "^7.0.0-bridge.0",
@ -32,8 +32,8 @@
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@polkadot/dev": "^0.41.3",
"@polkadot/ts": "^0.2.3",
"@polkadot/dev": "^0.50.9",
"@polkadot/ts": "^0.3.1",
"sinon-chrome": "^3.0.1"
}
}

View File

@ -5,7 +5,7 @@
"author": "Jaco Greeff <jacogr@gmail.com>",
"license": "Apache-2",
"dependencies": {
"@polkadot/api": "^1.4.0-beta.46",
"@polkadot/api": "^1.5.0-beta.12",
"@polkadot/extension-ui": "0.22.0-beta.8",
"@polkadot/keyring": "^2.5.1",
"@polkadot/ui-keyring": "^0.52.0-beta.3",

View File

@ -266,28 +266,23 @@ export default class State {
// Close provider connection when page is closed
port.onDisconnect.addListener((): void => {
const provider = this.#injectedProviders.get(port);
if (provider) {
provider.disconnect();
}
this.#injectedProviders.delete(port);
});
return Promise.resolve(this.#providers[key].meta);
}
public rpcSubscribe (request: RequestRpcSubscribe, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): Promise<number> {
public rpcSubscribe ({ method, params, type }: RequestRpcSubscribe, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): Promise<number> {
const provider = this.#injectedProviders.get(port);
assert(provider, 'Cannot call pub(rpc.subscribe) before provider has been set');
return provider.subscribe(
request.type,
request.method,
request.params,
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore WsProvider gives me (error, result)=>void, whereas (result)=>void is expected
(_error, res) => { cb(res); }
);
return provider.subscribe(type, method, params, cb);
}
public rpcUnsubscribe (request: RequestRpcUnsubscribe, port: chrome.runtime.Port): Promise<boolean> {

View File

@ -7,7 +7,7 @@ import { KeyringPair } from '@polkadot/keyring/types';
import { JsonRpcResponse } from '@polkadot/rpc-provider/types';
import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
import { RequestAuthorizeTab, ResponseSigning, RequestTypes, ResponseTypes, MessageTypes, ResponseRpcListProviders, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe } from '../types';
import { RequestAuthorizeTab, ResponseSigning, RequestTypes, ResponseTypes, MessageTypes, ResponseRpcListProviders, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, SubscriptionMessageTypes } from '../types';
import keyring from '@polkadot/ui-keyring';
import accountsObservable from '@polkadot/ui-keyring/observable/accounts';
@ -86,7 +86,8 @@ export default class Tabs {
}
private async rpcSubscribe (request: RequestRpcSubscribe, id: string, port: chrome.runtime.Port): Promise<boolean> {
const cb = createSubscription<'pub(rpc.subscribe)'>(id, port);
const innerCb = createSubscription<'pub(rpc.subscribe)'>(id, port);
const cb = (_error: Error | null, data: SubscriptionMessageTypes['pub(rpc.subscribe)']): void => innerCb(data);
const subscriptionId = await this.#state.rpcSubscribe(request, cb, port);
port.onDisconnect.addListener((): void => {

35041
yarn.lock

File diff suppressed because it is too large Load Diff