Add detectPackage for extension-* (#946)
* Bump deps * Add detectPackage for extension-* * Add missing util deps
This commit is contained in:
parent
c3003c11a3
commit
52c9666dff
@ -12,7 +12,10 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/polkadot-js/extension.git"
|
"url": "https://github.com/polkadot-js/extension.git"
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": [
|
||||||
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.cjs"
|
||||||
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.42.4",
|
"version": "0.42.4",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
11
packages/extension-base/src/detectPackage.ts
Normal file
11
packages/extension-base/src/detectPackage.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/extension-base authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as chainsInfo } from '@polkadot/extension-chains/packageInfo';
|
||||||
|
import { packageInfo as dappInfo } from '@polkadot/extension-dapp/packageInfo';
|
||||||
|
import { packageInfo as injectInfo } from '@polkadot/extension-inject/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [chainsInfo, dappInfo, injectInfo]);
|
||||||
@ -1,4 +1,6 @@
|
|||||||
// Copyright 2019-2021 @polkadot/extension-base authors & contributors
|
// Copyright 2019-2021 @polkadot/extension-base authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// no direct exports
|
import './detectPackage';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|||||||
@ -12,7 +12,10 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/polkadot-js/extension.git"
|
"url": "https://github.com/polkadot-js/extension.git"
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": [
|
||||||
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.cjs"
|
||||||
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.42.4",
|
"version": "0.42.4",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@ -20,6 +23,7 @@
|
|||||||
"@babel/runtime": "^7.16.5",
|
"@babel/runtime": "^7.16.5",
|
||||||
"@polkadot/extension-inject": "^0.42.4",
|
"@polkadot/extension-inject": "^0.42.4",
|
||||||
"@polkadot/networks": "^8.2.2",
|
"@polkadot/networks": "^8.2.2",
|
||||||
|
"@polkadot/util": "^8.2.2",
|
||||||
"@polkadot/util-crypto": "^8.2.2"
|
"@polkadot/util-crypto": "^8.2.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
9
packages/extension-chains/src/detectPackage.ts
Normal file
9
packages/extension-chains/src/detectPackage.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/extension-chains authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as injectInfo } from '@polkadot/extension-inject/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [injectInfo]);
|
||||||
@ -1,6 +1,8 @@
|
|||||||
// Copyright 2019-2021 @polkadot/extension-chains authors & contributors
|
// Copyright 2019-2021 @polkadot/extension-chains authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type { MetadataDef } from '@polkadot/extension-inject/types';
|
import type { MetadataDef } from '@polkadot/extension-inject/types';
|
||||||
import type { ChainProperties } from '@polkadot/types/interfaces';
|
import type { ChainProperties } from '@polkadot/types/interfaces';
|
||||||
import type { Chain } from './types';
|
import type { Chain } from './types';
|
||||||
@ -8,6 +10,8 @@ import type { Chain } from './types';
|
|||||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||||
import { base64Decode } from '@polkadot/util-crypto';
|
import { base64Decode } from '@polkadot/util-crypto';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
// imports chain details, generally metadata. For the generation of these,
|
// imports chain details, generally metadata. For the generation of these,
|
||||||
// inside the api, run `yarn chain:info --ws <url>`
|
// inside the api, run `yarn chain:info --ws <url>`
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,10 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/polkadot-js/extension.git"
|
"url": "https://github.com/polkadot-js/extension.git"
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": [
|
||||||
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.cjs"
|
||||||
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.42.4",
|
"version": "0.42.4",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
9
packages/extension-compat-metamask/src/detectPackage.ts
Normal file
9
packages/extension-compat-metamask/src/detectPackage.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/extension-chains authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as injectInfo } from '@polkadot/extension-inject/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [injectInfo]);
|
||||||
@ -1,6 +1,8 @@
|
|||||||
// Copyright 2019-2020 @polkadot/extension-compat-metamask authors & contributors
|
// Copyright 2019-2020 @polkadot/extension-compat-metamask authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type { Injected, InjectedAccount, InjectedWindow } from '@polkadot/extension-inject/types';
|
import type { Injected, InjectedAccount, InjectedWindow } from '@polkadot/extension-inject/types';
|
||||||
import type { SignerPayloadRaw, SignerResult } from '@polkadot/types/types';
|
import type { SignerPayloadRaw, SignerResult } from '@polkadot/types/types';
|
||||||
import type { HexString } from '@polkadot/util/types';
|
import type { HexString } from '@polkadot/util/types';
|
||||||
@ -10,6 +12,8 @@ import Web3 from 'web3';
|
|||||||
|
|
||||||
import { assert } from '@polkadot/util';
|
import { assert } from '@polkadot/util';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
interface RequestArguments {
|
interface RequestArguments {
|
||||||
method: string;
|
method: string;
|
||||||
params?: unknown[];
|
params?: unknown[];
|
||||||
|
|||||||
@ -12,7 +12,10 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/polkadot-js/extension.git"
|
"url": "https://github.com/polkadot-js/extension.git"
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": [
|
||||||
|
"./detectPackage.js",
|
||||||
|
"./detectPackage.cjs"
|
||||||
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.42.4",
|
"version": "0.42.4",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
|||||||
9
packages/extension-dapp/src/detectPackage.ts
Normal file
9
packages/extension-dapp/src/detectPackage.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/extension-dapp authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { packageInfo as injectInfo } from '@polkadot/extension-inject/packageInfo';
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [injectInfo]);
|
||||||
@ -1,6 +1,8 @@
|
|||||||
// Copyright 2019-2021 @polkadot/extension-dapp authors & contributors
|
// Copyright 2019-2021 @polkadot/extension-dapp authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type { Injected, InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedExtensionInfo, InjectedProviderWithMeta, InjectedWindow, ProviderList, Unsubcall, Web3AccountsOptions } from '@polkadot/extension-inject/types';
|
import type { Injected, InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedExtensionInfo, InjectedProviderWithMeta, InjectedWindow, ProviderList, Unsubcall, Web3AccountsOptions } from '@polkadot/extension-inject/types';
|
||||||
|
|
||||||
import { u8aEq } from '@polkadot/util';
|
import { u8aEq } from '@polkadot/util';
|
||||||
@ -9,6 +11,7 @@ import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';
|
|||||||
import { documentReadyPromise } from './util';
|
import { documentReadyPromise } from './util';
|
||||||
|
|
||||||
// expose utility functions
|
// expose utility functions
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
export { unwrapBytes, wrapBytes } from './wrapBytes';
|
export { unwrapBytes, wrapBytes } from './wrapBytes';
|
||||||
|
|
||||||
// just a helper (otherwise we cast all-over, so shorter and more readable)
|
// just a helper (otherwise we cast all-over, so shorter and more readable)
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
"@babel/runtime": "^7.16.5",
|
"@babel/runtime": "^7.16.5",
|
||||||
"@polkadot/rpc-provider": "^7.1.1",
|
"@polkadot/rpc-provider": "^7.1.1",
|
||||||
"@polkadot/types": "^7.1.1",
|
"@polkadot/types": "^7.1.1",
|
||||||
|
"@polkadot/util": "^8.2.2",
|
||||||
"@polkadot/util-crypto": "^8.2.2"
|
"@polkadot/util-crypto": "^8.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
8
packages/extension-inject/src/detectPackage.ts
Normal file
8
packages/extension-inject/src/detectPackage.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/extension-inject authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, []);
|
||||||
@ -1,8 +1,12 @@
|
|||||||
// Copyright 2019-2021 @polkadot/extension-inject authors & contributors
|
// Copyright 2019-2021 @polkadot/extension-inject authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import './detectPackage';
|
||||||
|
|
||||||
import type { Injected, InjectedWindow, InjectOptions } from './types';
|
import type { Injected, InjectedWindow, InjectOptions } from './types';
|
||||||
|
|
||||||
|
export { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
// It is recommended to always use the function below to shield the extension and dapp from
|
// It is recommended to always use the function below to shield the extension and dapp from
|
||||||
// any future changes. The exposed interface will manage access between the 2 environments,
|
// any future changes. The exposed interface will manage access between the 2 environments,
|
||||||
// be it via window (current), postMessage (under consideration) or any other mechanism
|
// be it via window (current), postMessage (under consideration) or any other mechanism
|
||||||
|
|||||||
8
packages/extension/src/detectPackage.ts
Normal file
8
packages/extension/src/detectPackage.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/extension authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { detectPackage } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { packageInfo } from './packageInfo';
|
||||||
|
|
||||||
|
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, []);
|
||||||
@ -2505,6 +2505,7 @@ __metadata:
|
|||||||
"@babel/runtime": ^7.16.5
|
"@babel/runtime": ^7.16.5
|
||||||
"@polkadot/extension-inject": ^0.42.4
|
"@polkadot/extension-inject": ^0.42.4
|
||||||
"@polkadot/networks": ^8.2.2
|
"@polkadot/networks": ^8.2.2
|
||||||
|
"@polkadot/util": ^8.2.2
|
||||||
"@polkadot/util-crypto": ^8.2.2
|
"@polkadot/util-crypto": ^8.2.2
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
"@polkadot/api": "*"
|
"@polkadot/api": "*"
|
||||||
@ -2549,6 +2550,7 @@ __metadata:
|
|||||||
"@babel/runtime": ^7.16.5
|
"@babel/runtime": ^7.16.5
|
||||||
"@polkadot/rpc-provider": ^7.1.1
|
"@polkadot/rpc-provider": ^7.1.1
|
||||||
"@polkadot/types": ^7.1.1
|
"@polkadot/types": ^7.1.1
|
||||||
|
"@polkadot/util": ^8.2.2
|
||||||
"@polkadot/util-crypto": ^8.2.2
|
"@polkadot/util-crypto": ^8.2.2
|
||||||
"@types/chrome": ^0.0.173
|
"@types/chrome": ^0.0.173
|
||||||
"@types/firefox-webext-browser": ^94.0.0
|
"@types/firefox-webext-browser": ^94.0.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user