diff --git a/bumpVersion.js b/bumpVersion.js index 61b46aa3..c5452e00 100644 --- a/bumpVersion.js +++ b/bumpVersion.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const NEW_VERSION = '1.0.22'; +const NEW_VERSION = '1.0.23'; function getPackageJson (filePath) { return { json: JSON.parse(fs.readFileSync(filePath, 'utf8')), filePath: filePath }; diff --git a/package.json b/package.json index aa98bab1..8f3892bc 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "https://github.com/reef-defi/browser-extension.git" }, "sideEffects": false, - "version": "1.0.22", + "version": "1.0.23", "workspaces": [ "packages/*" ], diff --git a/packages/extension-base/package.json b/packages/extension-base/package.json index 0a40c44f..1e974438 100644 --- a/packages/extension-base/package.json +++ b/packages/extension-base/package.json @@ -14,7 +14,7 @@ }, "sideEffects": false, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.0", @@ -22,8 +22,8 @@ "@polkadot/phishing": "^0.6.407", "@polkadot/ui-keyring": "^0.86.5", "@reef-chain/util-lib": "^0.4.0", - "@reef-defi/extension-dapp": "^1.0.22", - "@reef-defi/extension-inject": "^1.0.22", + "@reef-defi/extension-dapp": "^1.0.23", + "@reef-defi/extension-inject": "^1.0.23", "@reef-defi/keyring": "^7.8.2" } } diff --git a/packages/extension-chains/package.json b/packages/extension-chains/package.json index dacf1164..f2e88d3c 100644 --- a/packages/extension-chains/package.json +++ b/packages/extension-chains/package.json @@ -14,7 +14,7 @@ }, "sideEffects": false, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.0", diff --git a/packages/extension-compat-metamask/package.json b/packages/extension-compat-metamask/package.json index e883cba6..2df5ec27 100644 --- a/packages/extension-compat-metamask/package.json +++ b/packages/extension-compat-metamask/package.json @@ -14,12 +14,12 @@ }, "sideEffects": false, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.0", "@metamask/detect-provider": "^1.2.0", - "@reef-defi/extension-inject": "^1.0.22", + "@reef-defi/extension-inject": "^1.0.23", "@reef-defi/util": "^7.8.2", "web3": "^1.6.0" }, diff --git a/packages/extension-dapp/package.json b/packages/extension-dapp/package.json index 9cb98c8a..85df8f32 100644 --- a/packages/extension-dapp/package.json +++ b/packages/extension-dapp/package.json @@ -14,11 +14,11 @@ }, "sideEffects": false, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.0", - "@reef-defi/extension-inject": "^1.0.22", + "@reef-defi/extension-inject": "^1.0.23", "@reef-defi/util": "^7.8.2", "@reef-defi/util-crypto": "^7.8.2" }, diff --git a/packages/extension-inject/package.json b/packages/extension-inject/package.json index a6ecc015..e2596adc 100644 --- a/packages/extension-inject/package.json +++ b/packages/extension-inject/package.json @@ -14,7 +14,7 @@ }, "sideEffects": false, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "main": "index.js", "dependencies": { "@babel/runtime": "^7.16.0" diff --git a/packages/extension-inject/src/types.ts b/packages/extension-inject/src/types.ts index 9756d0a1..ccee6bcd 100644 --- a/packages/extension-inject/src/types.ts +++ b/packages/extension-inject/src/types.ts @@ -110,14 +110,15 @@ export interface ReefInjected extends Injected { export interface ReefInjectedSigner { subscribeSelectedAccount: (cb: (account: InjectedAccount | undefined) => unknown) => Unsubcall; - subscribeSelectedSigner: (cb: (signerResponse: ReefSignerResponse) => unknown, connectedVM?: ReefVM) => Unsubcall; + subscribeSelectedSigner: (cb: (signerResponse: ReefSignerResponse) => unknown, options?: ReefSignerReqOptions) => Unsubcall; getSelectedAccount: () => Promise; - getSelectedSigner: (connectedVM?: ReefVM) => Promise; + getSelectedSigner: (options?: ReefSignerReqOptions) => Promise; } export interface ReefInjectedProvider { subscribeSelectedNetwork: (cb: (rpcUrl: string) => void) => void; subscribeSelectedNetworkProvider: (cb: (provider: Provider) => void) => Unsubcall; + getNetworkProvider(): Promise; } @@ -140,6 +141,7 @@ export interface Web3AccountsOptions { } export enum ReefVM { + _NO_VALUE, NATIVE, EVM } @@ -156,3 +158,8 @@ export interface ReefSignerResponse { status: ReefSignerStatus; requestedVM: ReefVM; } + +export interface ReefSignerReqOptions { + connectedVM?: ReefVM; + // network?: 'mainnet' | 'testnet' +} diff --git a/packages/extension-ui/package.json b/packages/extension-ui/package.json index 1126d5f8..bb1dda7c 100644 --- a/packages/extension-ui/package.json +++ b/packages/extension-ui/package.json @@ -14,7 +14,7 @@ }, "sideEffects": true, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "dependencies": { "@apollo/client": "^3.5.8", "@babel/runtime": "^7.16.0", @@ -32,9 +32,9 @@ "@polkadot/util": "^7.8.2", "@polkadot/util-crypto": "^7.8.2", "@popperjs/core": "^2.11.5", - "@reef-defi/extension-base": "^1.0.22", - "@reef-defi/extension-dapp": "^1.0.22", - "@reef-defi/extension-inject": "^1.0.22", + "@reef-defi/extension-base": "^1.0.23", + "@reef-defi/extension-dapp": "^1.0.23", + "@reef-defi/extension-inject": "^1.0.23", "@reef-defi/hw-ledger": "^7.8.2", "@reef-defi/keyring": "^7.8.2", "@reef-defi/networks": "^7.8.2", diff --git a/packages/extension/package.json b/packages/extension/package.json index 0485be55..888c28c5 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -14,12 +14,12 @@ }, "sideEffects": false, "type": "module", - "version": "1.0.22", + "version": "1.0.23", "dependencies": { "@babel/runtime": "^7.16.0", - "@reef-defi/extension-base": "^1.0.22", - "@reef-defi/extension-inject": "^1.0.22", - "@reef-defi/extension-ui": "^1.0.22" + "@reef-defi/extension-base": "^1.0.23", + "@reef-defi/extension-inject": "^1.0.23", + "@reef-defi/extension-ui": "^1.0.23" }, "devDependencies": { "@reef-defi/dev": "^0.63.20", diff --git a/packages/reef/extension-base/src/page/ReefSigner.ts b/packages/reef/extension-base/src/page/ReefSigner.ts index 998c6386..bb30cb79 100644 --- a/packages/reef/extension-base/src/page/ReefSigner.ts +++ b/packages/reef/extension-base/src/page/ReefSigner.ts @@ -1,7 +1,7 @@ import { Provider, Signer as ReefVMSigner } from '@reef-defi/evm-provider'; import Accounts from '@reef-defi/extension-base/page/Accounts'; import SigningKey from '@reef-defi/extension-base/page/Signer'; -import { InjectedAccount, ReefInjectedSigner, ReefSignerResponse, ReefSignerStatus, ReefVM, Unsubcall } from '@reef-defi/extension-inject/types'; +import { InjectedAccount, ReefInjectedSigner, ReefSignerReqOptions, ReefSignerResponse, ReefSignerStatus, ReefVM, Unsubcall } from '@reef-defi/extension-inject/types'; import { ReefProvider } from './ReefProvider'; @@ -34,7 +34,9 @@ export class ReefSigner implements ReefInjectedSigner { return accounts.find((a) => a.isSelected); } - public subscribeSelectedSigner (cb: (reefSigner: ReefSignerResponse) => unknown, connectedVM: ReefVM = ReefVM.EVM): Unsubcall { + public subscribeSelectedSigner (cb: (reefSigner: ReefSignerResponse) => unknown, options: ReefSignerReqOptions = {}): Unsubcall { + const connectedVM = options.connectedVM || ReefVM.EVM; + const unsubProvFn = this.injectedProvider.subscribeSelectedNetworkProvider((provider) => { this.selectedProvider = provider; this.onSelectedSignerParamUpdate(cb, connectedVM).then( @@ -66,7 +68,7 @@ export class ReefSigner implements ReefInjectedSigner { }; } - public async getSelectedSigner (connectedVM: ReefVM = ReefVM.EVM): Promise { + public async getSelectedSigner (options: ReefSignerReqOptions = {}): Promise { if (this.selectedSignerStatus) { return Promise.resolve({ ...this.selectedSignerStatus }); } @@ -88,7 +90,7 @@ export class ReefSigner implements ReefInjectedSigner { this.resolvesList.forEach((resolve) => resolve({ ...sig })); this.resolvesList = []; } - }, connectedVM); + }, options); } return retPromise; @@ -129,6 +131,6 @@ export class ReefSigner implements ReefInjectedSigner { return false; } - return !connectedVM || (connectedVM === ReefVM.EVM && await signer?.isClaimed()); + return !connectedVM || (connectedVM === ReefVM.EVM && signer && await signer.isClaimed()); } } diff --git a/yarn.lock b/yarn.lock index 200897c8..b25374fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4618,7 +4618,7 @@ __metadata: languageName: node linkType: hard -"@reef-defi/extension-base@^1.0.10, @reef-defi/extension-base@^1.0.22, @reef-defi/extension-base@^1.0.9, @reef-defi/extension-base@workspace:packages/extension-base": +"@reef-defi/extension-base@^1.0.10, @reef-defi/extension-base@^1.0.23, @reef-defi/extension-base@^1.0.9, @reef-defi/extension-base@workspace:packages/extension-base": version: 0.0.0-use.local resolution: "@reef-defi/extension-base@workspace:packages/extension-base" dependencies: @@ -4627,8 +4627,8 @@ __metadata: "@polkadot/phishing": ^0.6.407 "@polkadot/ui-keyring": ^0.86.5 "@reef-chain/util-lib": ^0.4.0 - "@reef-defi/extension-dapp": ^1.0.22 - "@reef-defi/extension-inject": ^1.0.22 + "@reef-defi/extension-dapp": ^1.0.23 + "@reef-defi/extension-inject": ^1.0.23 "@reef-defi/keyring": ^7.8.2 languageName: unknown linkType: soft @@ -4650,7 +4650,7 @@ __metadata: dependencies: "@babel/runtime": ^7.16.0 "@metamask/detect-provider": ^1.2.0 - "@reef-defi/extension-inject": ^1.0.22 + "@reef-defi/extension-inject": ^1.0.23 "@reef-defi/util": ^7.8.2 web3: ^1.6.0 peerDependencies: @@ -4658,12 +4658,12 @@ __metadata: languageName: unknown linkType: soft -"@reef-defi/extension-dapp@^1.0.10, @reef-defi/extension-dapp@^1.0.22, @reef-defi/extension-dapp@^1.0.9, @reef-defi/extension-dapp@workspace:packages/extension-dapp": +"@reef-defi/extension-dapp@^1.0.10, @reef-defi/extension-dapp@^1.0.23, @reef-defi/extension-dapp@^1.0.9, @reef-defi/extension-dapp@workspace:packages/extension-dapp": version: 0.0.0-use.local resolution: "@reef-defi/extension-dapp@workspace:packages/extension-dapp" dependencies: "@babel/runtime": ^7.16.0 - "@reef-defi/extension-inject": ^1.0.22 + "@reef-defi/extension-inject": ^1.0.23 "@reef-defi/util": ^7.8.2 "@reef-defi/util-crypto": ^7.8.2 peerDependencies: @@ -4673,7 +4673,7 @@ __metadata: languageName: unknown linkType: soft -"@reef-defi/extension-inject@^1.0.10, @reef-defi/extension-inject@^1.0.22, @reef-defi/extension-inject@^1.0.9, @reef-defi/extension-inject@workspace:packages/extension-inject": +"@reef-defi/extension-inject@^1.0.10, @reef-defi/extension-inject@^1.0.23, @reef-defi/extension-inject@^1.0.9, @reef-defi/extension-inject@workspace:packages/extension-inject": version: 0.0.0-use.local resolution: "@reef-defi/extension-inject@workspace:packages/extension-inject" dependencies: @@ -4685,7 +4685,7 @@ __metadata: languageName: unknown linkType: soft -"@reef-defi/extension-ui@^1.0.22, @reef-defi/extension-ui@workspace:packages/extension-ui": +"@reef-defi/extension-ui@^1.0.23, @reef-defi/extension-ui@workspace:packages/extension-ui": version: 0.0.0-use.local resolution: "@reef-defi/extension-ui@workspace:packages/extension-ui" dependencies: @@ -4705,9 +4705,9 @@ __metadata: "@polkadot/util": ^7.8.2 "@polkadot/util-crypto": ^7.8.2 "@popperjs/core": ^2.11.5 - "@reef-defi/extension-base": ^1.0.22 - "@reef-defi/extension-dapp": ^1.0.22 - "@reef-defi/extension-inject": ^1.0.22 + "@reef-defi/extension-base": ^1.0.23 + "@reef-defi/extension-dapp": ^1.0.23 + "@reef-defi/extension-inject": ^1.0.23 "@reef-defi/hw-ledger": ^7.8.2 "@reef-defi/keyring": ^7.8.2 "@reef-defi/networks": ^7.8.2 @@ -4752,9 +4752,9 @@ __metadata: dependencies: "@babel/runtime": ^7.16.0 "@reef-defi/dev": ^0.63.20 - "@reef-defi/extension-base": ^1.0.22 - "@reef-defi/extension-inject": ^1.0.22 - "@reef-defi/extension-ui": ^1.0.22 + "@reef-defi/extension-base": ^1.0.23 + "@reef-defi/extension-inject": ^1.0.23 + "@reef-defi/extension-ui": ^1.0.23 babel-loader: ^8.2.3 browser-resolve: ^2.0.0 buffer: ^6.0.3