@metamask-previews/chain-agnostic-permission 0.1.0-preview-b69c669
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.cjs +103 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.cjs.map +1 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.d.cts +20 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.d.cts.map +1 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.d.mts +20 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.d.mts.map +1 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.mjs +98 -0
- package/dist/adapters/caip-permission-adapter-eth-accounts.mjs.map +1 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.cjs +115 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.cjs.map +1 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.d.cts +27 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.d.cts.map +1 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.d.mts +27 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.d.mts.map +1 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.mjs +109 -0
- package/dist/adapters/caip-permission-adapter-permittedChains.mjs.map +1 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.cjs +85 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.cjs.map +1 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.d.cts +23 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.d.cts.map +1 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.d.mts +23 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.d.mts.map +1 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.mjs +80 -0
- package/dist/adapters/caip-permission-adapter-session-scopes.mjs.map +1 -0
- package/dist/caip25Permission.cjs +285 -0
- package/dist/caip25Permission.cjs.map +1 -0
- package/dist/caip25Permission.d.cts +131 -0
- package/dist/caip25Permission.d.cts.map +1 -0
- package/dist/caip25Permission.d.mts +131 -0
- package/dist/caip25Permission.d.mts.map +1 -0
- package/dist/caip25Permission.mjs +280 -0
- package/dist/caip25Permission.mjs.map +1 -0
- package/dist/index.cjs +43 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -0
- package/dist/scope/assert.cjs +170 -0
- package/dist/scope/assert.cjs.map +1 -0
- package/dist/scope/assert.d.cts +50 -0
- package/dist/scope/assert.d.cts.map +1 -0
- package/dist/scope/assert.d.mts +50 -0
- package/dist/scope/assert.d.mts.map +1 -0
- package/dist/scope/assert.mjs +162 -0
- package/dist/scope/assert.mjs.map +1 -0
- package/dist/scope/authorization.cjs +51 -0
- package/dist/scope/authorization.cjs.map +1 -0
- package/dist/scope/authorization.d.cts +50 -0
- package/dist/scope/authorization.d.cts.map +1 -0
- package/dist/scope/authorization.d.mts +50 -0
- package/dist/scope/authorization.d.mts.map +1 -0
- package/dist/scope/authorization.mjs +46 -0
- package/dist/scope/authorization.mjs.map +1 -0
- package/dist/scope/constants.cjs +83 -0
- package/dist/scope/constants.cjs.map +1 -0
- package/dist/scope/constants.d.cts +32 -0
- package/dist/scope/constants.d.cts.map +1 -0
- package/dist/scope/constants.d.mts +32 -0
- package/dist/scope/constants.d.mts.map +1 -0
- package/dist/scope/constants.mjs +84 -0
- package/dist/scope/constants.mjs.map +1 -0
- package/dist/scope/errors.cjs +47 -0
- package/dist/scope/errors.cjs.map +1 -0
- package/dist/scope/errors.d.cts +44 -0
- package/dist/scope/errors.d.cts.map +1 -0
- package/dist/scope/errors.d.mts +44 -0
- package/dist/scope/errors.d.mts.map +1 -0
- package/dist/scope/errors.mjs +44 -0
- package/dist/scope/errors.mjs.map +1 -0
- package/dist/scope/filter.cjs +76 -0
- package/dist/scope/filter.cjs.map +1 -0
- package/dist/scope/filter.d.cts +35 -0
- package/dist/scope/filter.d.cts.map +1 -0
- package/dist/scope/filter.d.mts +35 -0
- package/dist/scope/filter.d.mts.map +1 -0
- package/dist/scope/filter.mjs +71 -0
- package/dist/scope/filter.mjs.map +1 -0
- package/dist/scope/supported.cjs +116 -0
- package/dist/scope/supported.cjs.map +1 -0
- package/dist/scope/supported.d.cts +52 -0
- package/dist/scope/supported.d.cts.map +1 -0
- package/dist/scope/supported.d.mts +52 -0
- package/dist/scope/supported.d.mts.map +1 -0
- package/dist/scope/supported.mjs +109 -0
- package/dist/scope/supported.mjs.map +1 -0
- package/dist/scope/transform.cjs +152 -0
- package/dist/scope/transform.cjs.map +1 -0
- package/dist/scope/transform.d.cts +50 -0
- package/dist/scope/transform.d.cts.map +1 -0
- package/dist/scope/transform.d.mts +50 -0
- package/dist/scope/transform.d.mts.map +1 -0
- package/dist/scope/transform.mjs +144 -0
- package/dist/scope/transform.mjs.map +1 -0
- package/dist/scope/types.cjs +23 -0
- package/dist/scope/types.cjs.map +1 -0
- package/dist/scope/types.d.cts +81 -0
- package/dist/scope/types.d.cts.map +1 -0
- package/dist/scope/types.d.mts +81 -0
- package/dist/scope/types.d.mts.map +1 -0
- package/dist/scope/types.mjs +19 -0
- package/dist/scope/types.mjs.map +1 -0
- package/dist/scope/validation.cjs +87 -0
- package/dist/scope/validation.cjs.map +1 -0
- package/dist/scope/validation.d.cts +21 -0
- package/dist/scope/validation.d.cts.map +1 -0
- package/dist/scope/validation.d.mts +21 -0
- package/dist/scope/validation.d.mts.map +1 -0
- package/dist/scope/validation.mjs +82 -0
- package/dist/scope/validation.mjs.map +1 -0
- package/package.json +75 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.KnownNotifications = exports.KnownWalletNamespaceRpcMethods = exports.KnownRpcMethods = exports.Eip1193OnlyMethods = exports.KnownWalletRpcMethods = exports.CaipReferenceRegexes = exports.KnownWalletScopeString = void 0;
|
7
|
+
const api_specs_1 = __importDefault(require("@metamask/api-specs"));
|
8
|
+
/**
|
9
|
+
* ScopeStrings for offchain methods that are not specific to a chainId but are specific to a CAIP namespace.
|
10
|
+
*/
|
11
|
+
var KnownWalletScopeString;
|
12
|
+
(function (KnownWalletScopeString) {
|
13
|
+
KnownWalletScopeString["Eip155"] = "wallet:eip155";
|
14
|
+
})(KnownWalletScopeString || (exports.KnownWalletScopeString = KnownWalletScopeString = {}));
|
15
|
+
/**
|
16
|
+
* Regexes defining how references must be formed for non-wallet known CAIP namespaces
|
17
|
+
*/
|
18
|
+
exports.CaipReferenceRegexes = {
|
19
|
+
eip155: /^(0|[1-9][0-9]*)$/u,
|
20
|
+
bip122: /.*/u,
|
21
|
+
solana: /.*/u,
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* Methods that do not belong exclusively to any CAIP namespace.
|
25
|
+
*/
|
26
|
+
exports.KnownWalletRpcMethods = [
|
27
|
+
'wallet_registerOnboarding',
|
28
|
+
'wallet_scanQRCode',
|
29
|
+
];
|
30
|
+
/**
|
31
|
+
* Methods that belong to the `wallet:eip155` scope.
|
32
|
+
*/
|
33
|
+
const WalletEip155Methods = ['wallet_addEthereumChain'];
|
34
|
+
/**
|
35
|
+
* Methods that are only supported via the EIP-1193 API.
|
36
|
+
*/
|
37
|
+
exports.Eip1193OnlyMethods = [
|
38
|
+
'wallet_switchEthereumChain',
|
39
|
+
'wallet_getPermissions',
|
40
|
+
'wallet_requestPermissions',
|
41
|
+
'wallet_revokePermissions',
|
42
|
+
'eth_requestAccounts',
|
43
|
+
'eth_accounts',
|
44
|
+
'eth_coinbase',
|
45
|
+
'net_version',
|
46
|
+
'metamask_logWeb3ShimUsage',
|
47
|
+
'metamask_getProviderState',
|
48
|
+
'metamask_sendDomainMetadata',
|
49
|
+
'wallet_registerOnboarding',
|
50
|
+
];
|
51
|
+
/**
|
52
|
+
* All MetaMask methods, except for ones we have specified in the constants above.
|
53
|
+
*/
|
54
|
+
const Eip155Methods = api_specs_1.default.methods
|
55
|
+
.map(({ name }) => name)
|
56
|
+
.filter((method) => !WalletEip155Methods.includes(method))
|
57
|
+
.filter((method) => !exports.KnownWalletRpcMethods.includes(method))
|
58
|
+
.filter((method) => !exports.Eip1193OnlyMethods.includes(method));
|
59
|
+
/**
|
60
|
+
* Methods by ecosystem that are chain specific.
|
61
|
+
*/
|
62
|
+
exports.KnownRpcMethods = {
|
63
|
+
eip155: Eip155Methods,
|
64
|
+
bip122: [],
|
65
|
+
solana: [],
|
66
|
+
};
|
67
|
+
/**
|
68
|
+
* Methods for CAIP namespaces that aren't chain specific.
|
69
|
+
*/
|
70
|
+
exports.KnownWalletNamespaceRpcMethods = {
|
71
|
+
eip155: WalletEip155Methods,
|
72
|
+
bip122: [],
|
73
|
+
solana: [],
|
74
|
+
};
|
75
|
+
/**
|
76
|
+
* Notifications for known CAIP namespaces.
|
77
|
+
*/
|
78
|
+
exports.KnownNotifications = {
|
79
|
+
eip155: ['eth_subscription'],
|
80
|
+
bip122: [],
|
81
|
+
solana: [],
|
82
|
+
};
|
83
|
+
//# sourceMappingURL=constants.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../src/scope/constants.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA0D;AAI1D;;GAEG;AACH,IAAY,sBAEX;AAFD,WAAY,sBAAsB;IAChC,kDAAwB,CAAA;AAC1B,CAAC,EAFW,sBAAsB,sCAAtB,sBAAsB,QAEjC;AAED;;GAEG;AACU,QAAA,oBAAoB,GAC/B;IACE,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;CACd,CAAC;AAEJ;;GAEG;AACU,QAAA,qBAAqB,GAAa;IAC7C,2BAA2B;IAC3B,mBAAmB;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAExD;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,4BAA4B;IAC5B,uBAAuB;IACvB,2BAA2B;IAC3B,0BAA0B;IAC1B,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,aAAa;IACb,2BAA2B;IAC3B,2BAA2B;IAC3B,6BAA6B;IAC7B,2BAA2B;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,aAAa,GAAG,mBAAuB,CAAC,OAAO;KAClD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAoB,EAAE,EAAE,CAAC,IAAI,CAAC;KACzC,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACjE,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,6BAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACnE,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,0BAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACU,QAAA,eAAe,GAAkD;IAC5E,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;GAEG;AACU,QAAA,8BAA8B,GAGvC;IACF,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;GAEG;AACU,QAAA,kBAAkB,GAC7B;IACE,MAAM,EAAE,CAAC,kBAAkB,CAAC;IAC5B,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC","sourcesContent":["import MetaMaskOpenRPCDocument from '@metamask/api-specs';\n\nimport type { NonWalletKnownCaipNamespace } from './types';\n\n/**\n * ScopeStrings for offchain methods that are not specific to a chainId but are specific to a CAIP namespace.\n */\nexport enum KnownWalletScopeString {\n Eip155 = 'wallet:eip155',\n}\n\n/**\n * Regexes defining how references must be formed for non-wallet known CAIP namespaces\n */\nexport const CaipReferenceRegexes: Record<NonWalletKnownCaipNamespace, RegExp> =\n {\n eip155: /^(0|[1-9][0-9]*)$/u,\n bip122: /.*/u,\n solana: /.*/u,\n };\n\n/**\n * Methods that do not belong exclusively to any CAIP namespace.\n */\nexport const KnownWalletRpcMethods: string[] = [\n 'wallet_registerOnboarding',\n 'wallet_scanQRCode',\n];\n\n/**\n * Methods that belong to the `wallet:eip155` scope.\n */\nconst WalletEip155Methods = ['wallet_addEthereumChain'];\n\n/**\n * Methods that are only supported via the EIP-1193 API.\n */\nexport const Eip1193OnlyMethods = [\n 'wallet_switchEthereumChain',\n 'wallet_getPermissions',\n 'wallet_requestPermissions',\n 'wallet_revokePermissions',\n 'eth_requestAccounts',\n 'eth_accounts',\n 'eth_coinbase',\n 'net_version',\n 'metamask_logWeb3ShimUsage',\n 'metamask_getProviderState',\n 'metamask_sendDomainMetadata',\n 'wallet_registerOnboarding',\n];\n\n/**\n * All MetaMask methods, except for ones we have specified in the constants above.\n */\nconst Eip155Methods = MetaMaskOpenRPCDocument.methods\n .map(({ name }: { name: string }) => name)\n .filter((method: string) => !WalletEip155Methods.includes(method))\n .filter((method: string) => !KnownWalletRpcMethods.includes(method))\n .filter((method: string) => !Eip1193OnlyMethods.includes(method));\n\n/**\n * Methods by ecosystem that are chain specific.\n */\nexport const KnownRpcMethods: Record<NonWalletKnownCaipNamespace, string[]> = {\n eip155: Eip155Methods,\n bip122: [],\n solana: [],\n};\n\n/**\n * Methods for CAIP namespaces that aren't chain specific.\n */\nexport const KnownWalletNamespaceRpcMethods: Record<\n NonWalletKnownCaipNamespace,\n string[]\n> = {\n eip155: WalletEip155Methods,\n bip122: [],\n solana: [],\n};\n\n/**\n * Notifications for known CAIP namespaces.\n */\nexport const KnownNotifications: Record<NonWalletKnownCaipNamespace, string[]> =\n {\n eip155: ['eth_subscription'],\n bip122: [],\n solana: [],\n };\n"]}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import type { NonWalletKnownCaipNamespace } from "./types.cjs";
|
2
|
+
/**
|
3
|
+
* ScopeStrings for offchain methods that are not specific to a chainId but are specific to a CAIP namespace.
|
4
|
+
*/
|
5
|
+
export declare enum KnownWalletScopeString {
|
6
|
+
Eip155 = "wallet:eip155"
|
7
|
+
}
|
8
|
+
/**
|
9
|
+
* Regexes defining how references must be formed for non-wallet known CAIP namespaces
|
10
|
+
*/
|
11
|
+
export declare const CaipReferenceRegexes: Record<NonWalletKnownCaipNamespace, RegExp>;
|
12
|
+
/**
|
13
|
+
* Methods that do not belong exclusively to any CAIP namespace.
|
14
|
+
*/
|
15
|
+
export declare const KnownWalletRpcMethods: string[];
|
16
|
+
/**
|
17
|
+
* Methods that are only supported via the EIP-1193 API.
|
18
|
+
*/
|
19
|
+
export declare const Eip1193OnlyMethods: string[];
|
20
|
+
/**
|
21
|
+
* Methods by ecosystem that are chain specific.
|
22
|
+
*/
|
23
|
+
export declare const KnownRpcMethods: Record<NonWalletKnownCaipNamespace, string[]>;
|
24
|
+
/**
|
25
|
+
* Methods for CAIP namespaces that aren't chain specific.
|
26
|
+
*/
|
27
|
+
export declare const KnownWalletNamespaceRpcMethods: Record<NonWalletKnownCaipNamespace, string[]>;
|
28
|
+
/**
|
29
|
+
* Notifications for known CAIP namespaces.
|
30
|
+
*/
|
31
|
+
export declare const KnownNotifications: Record<NonWalletKnownCaipNamespace, string[]>;
|
32
|
+
//# sourceMappingURL=constants.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/scope/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAgB;AAE3D;;GAEG;AACH,oBAAY,sBAAsB;IAChC,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAK1E,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAC;AAOF;;GAEG;AACH,eAAO,MAAM,kBAAkB,UAa9B,CAAC;AAWF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,EAAE,CAIzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CACjD,2BAA2B,EAC3B,MAAM,EAAE,CAKT,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,EAAE,CAK1E,CAAC"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import type { NonWalletKnownCaipNamespace } from "./types.mjs";
|
2
|
+
/**
|
3
|
+
* ScopeStrings for offchain methods that are not specific to a chainId but are specific to a CAIP namespace.
|
4
|
+
*/
|
5
|
+
export declare enum KnownWalletScopeString {
|
6
|
+
Eip155 = "wallet:eip155"
|
7
|
+
}
|
8
|
+
/**
|
9
|
+
* Regexes defining how references must be formed for non-wallet known CAIP namespaces
|
10
|
+
*/
|
11
|
+
export declare const CaipReferenceRegexes: Record<NonWalletKnownCaipNamespace, RegExp>;
|
12
|
+
/**
|
13
|
+
* Methods that do not belong exclusively to any CAIP namespace.
|
14
|
+
*/
|
15
|
+
export declare const KnownWalletRpcMethods: string[];
|
16
|
+
/**
|
17
|
+
* Methods that are only supported via the EIP-1193 API.
|
18
|
+
*/
|
19
|
+
export declare const Eip1193OnlyMethods: string[];
|
20
|
+
/**
|
21
|
+
* Methods by ecosystem that are chain specific.
|
22
|
+
*/
|
23
|
+
export declare const KnownRpcMethods: Record<NonWalletKnownCaipNamespace, string[]>;
|
24
|
+
/**
|
25
|
+
* Methods for CAIP namespaces that aren't chain specific.
|
26
|
+
*/
|
27
|
+
export declare const KnownWalletNamespaceRpcMethods: Record<NonWalletKnownCaipNamespace, string[]>;
|
28
|
+
/**
|
29
|
+
* Notifications for known CAIP namespaces.
|
30
|
+
*/
|
31
|
+
export declare const KnownNotifications: Record<NonWalletKnownCaipNamespace, string[]>;
|
32
|
+
//# sourceMappingURL=constants.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/scope/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAgB;AAE3D;;GAEG;AACH,oBAAY,sBAAsB;IAChC,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAK1E,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAGzC,CAAC;AAOF;;GAEG;AACH,eAAO,MAAM,kBAAkB,UAa9B,CAAC;AAWF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,EAAE,CAIzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CACjD,2BAA2B,EAC3B,MAAM,EAAE,CAKT,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,EAAE,CAK1E,CAAC"}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
function $importDefault(module) {
|
2
|
+
if (module?.__esModule) {
|
3
|
+
return module.default;
|
4
|
+
}
|
5
|
+
return module;
|
6
|
+
}
|
7
|
+
import $MetaMaskOpenRPCDocument from "@metamask/api-specs";
|
8
|
+
const MetaMaskOpenRPCDocument = $importDefault($MetaMaskOpenRPCDocument);
|
9
|
+
/**
|
10
|
+
* ScopeStrings for offchain methods that are not specific to a chainId but are specific to a CAIP namespace.
|
11
|
+
*/
|
12
|
+
export var KnownWalletScopeString;
|
13
|
+
(function (KnownWalletScopeString) {
|
14
|
+
KnownWalletScopeString["Eip155"] = "wallet:eip155";
|
15
|
+
})(KnownWalletScopeString || (KnownWalletScopeString = {}));
|
16
|
+
/**
|
17
|
+
* Regexes defining how references must be formed for non-wallet known CAIP namespaces
|
18
|
+
*/
|
19
|
+
export const CaipReferenceRegexes = {
|
20
|
+
eip155: /^(0|[1-9][0-9]*)$/u,
|
21
|
+
bip122: /.*/u,
|
22
|
+
solana: /.*/u,
|
23
|
+
};
|
24
|
+
/**
|
25
|
+
* Methods that do not belong exclusively to any CAIP namespace.
|
26
|
+
*/
|
27
|
+
export const KnownWalletRpcMethods = [
|
28
|
+
'wallet_registerOnboarding',
|
29
|
+
'wallet_scanQRCode',
|
30
|
+
];
|
31
|
+
/**
|
32
|
+
* Methods that belong to the `wallet:eip155` scope.
|
33
|
+
*/
|
34
|
+
const WalletEip155Methods = ['wallet_addEthereumChain'];
|
35
|
+
/**
|
36
|
+
* Methods that are only supported via the EIP-1193 API.
|
37
|
+
*/
|
38
|
+
export const Eip1193OnlyMethods = [
|
39
|
+
'wallet_switchEthereumChain',
|
40
|
+
'wallet_getPermissions',
|
41
|
+
'wallet_requestPermissions',
|
42
|
+
'wallet_revokePermissions',
|
43
|
+
'eth_requestAccounts',
|
44
|
+
'eth_accounts',
|
45
|
+
'eth_coinbase',
|
46
|
+
'net_version',
|
47
|
+
'metamask_logWeb3ShimUsage',
|
48
|
+
'metamask_getProviderState',
|
49
|
+
'metamask_sendDomainMetadata',
|
50
|
+
'wallet_registerOnboarding',
|
51
|
+
];
|
52
|
+
/**
|
53
|
+
* All MetaMask methods, except for ones we have specified in the constants above.
|
54
|
+
*/
|
55
|
+
const Eip155Methods = MetaMaskOpenRPCDocument.methods
|
56
|
+
.map(({ name }) => name)
|
57
|
+
.filter((method) => !WalletEip155Methods.includes(method))
|
58
|
+
.filter((method) => !KnownWalletRpcMethods.includes(method))
|
59
|
+
.filter((method) => !Eip1193OnlyMethods.includes(method));
|
60
|
+
/**
|
61
|
+
* Methods by ecosystem that are chain specific.
|
62
|
+
*/
|
63
|
+
export const KnownRpcMethods = {
|
64
|
+
eip155: Eip155Methods,
|
65
|
+
bip122: [],
|
66
|
+
solana: [],
|
67
|
+
};
|
68
|
+
/**
|
69
|
+
* Methods for CAIP namespaces that aren't chain specific.
|
70
|
+
*/
|
71
|
+
export const KnownWalletNamespaceRpcMethods = {
|
72
|
+
eip155: WalletEip155Methods,
|
73
|
+
bip122: [],
|
74
|
+
solana: [],
|
75
|
+
};
|
76
|
+
/**
|
77
|
+
* Notifications for known CAIP namespaces.
|
78
|
+
*/
|
79
|
+
export const KnownNotifications = {
|
80
|
+
eip155: ['eth_subscription'],
|
81
|
+
bip122: [],
|
82
|
+
solana: [],
|
83
|
+
};
|
84
|
+
//# sourceMappingURL=constants.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/scope/constants.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,wBAAuB,4BAA4B;;AAI1D;;GAEG;AACH,MAAM,CAAN,IAAY,sBAEX;AAFD,WAAY,sBAAsB;IAChC,kDAAwB,CAAA;AAC1B,CAAC,EAFW,sBAAsB,KAAtB,sBAAsB,QAEjC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B;IACE,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;CACd,CAAC;AAEJ;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAa;IAC7C,2BAA2B;IAC3B,mBAAmB;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,4BAA4B;IAC5B,uBAAuB;IACvB,2BAA2B;IAC3B,0BAA0B;IAC1B,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,aAAa;IACb,2BAA2B;IAC3B,2BAA2B;IAC3B,6BAA6B;IAC7B,2BAA2B;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,aAAa,GAAG,uBAAuB,CAAC,OAAO;KAClD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAoB,EAAE,EAAE,CAAC,IAAI,CAAC;KACzC,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACjE,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACnE,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkD;IAC5E,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAGvC;IACF,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAC7B;IACE,MAAM,EAAE,CAAC,kBAAkB,CAAC;IAC5B,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC","sourcesContent":["import MetaMaskOpenRPCDocument from '@metamask/api-specs';\n\nimport type { NonWalletKnownCaipNamespace } from './types';\n\n/**\n * ScopeStrings for offchain methods that are not specific to a chainId but are specific to a CAIP namespace.\n */\nexport enum KnownWalletScopeString {\n Eip155 = 'wallet:eip155',\n}\n\n/**\n * Regexes defining how references must be formed for non-wallet known CAIP namespaces\n */\nexport const CaipReferenceRegexes: Record<NonWalletKnownCaipNamespace, RegExp> =\n {\n eip155: /^(0|[1-9][0-9]*)$/u,\n bip122: /.*/u,\n solana: /.*/u,\n };\n\n/**\n * Methods that do not belong exclusively to any CAIP namespace.\n */\nexport const KnownWalletRpcMethods: string[] = [\n 'wallet_registerOnboarding',\n 'wallet_scanQRCode',\n];\n\n/**\n * Methods that belong to the `wallet:eip155` scope.\n */\nconst WalletEip155Methods = ['wallet_addEthereumChain'];\n\n/**\n * Methods that are only supported via the EIP-1193 API.\n */\nexport const Eip1193OnlyMethods = [\n 'wallet_switchEthereumChain',\n 'wallet_getPermissions',\n 'wallet_requestPermissions',\n 'wallet_revokePermissions',\n 'eth_requestAccounts',\n 'eth_accounts',\n 'eth_coinbase',\n 'net_version',\n 'metamask_logWeb3ShimUsage',\n 'metamask_getProviderState',\n 'metamask_sendDomainMetadata',\n 'wallet_registerOnboarding',\n];\n\n/**\n * All MetaMask methods, except for ones we have specified in the constants above.\n */\nconst Eip155Methods = MetaMaskOpenRPCDocument.methods\n .map(({ name }: { name: string }) => name)\n .filter((method: string) => !WalletEip155Methods.includes(method))\n .filter((method: string) => !KnownWalletRpcMethods.includes(method))\n .filter((method: string) => !Eip1193OnlyMethods.includes(method));\n\n/**\n * Methods by ecosystem that are chain specific.\n */\nexport const KnownRpcMethods: Record<NonWalletKnownCaipNamespace, string[]> = {\n eip155: Eip155Methods,\n bip122: [],\n solana: [],\n};\n\n/**\n * Methods for CAIP namespaces that aren't chain specific.\n */\nexport const KnownWalletNamespaceRpcMethods: Record<\n NonWalletKnownCaipNamespace,\n string[]\n> = {\n eip155: WalletEip155Methods,\n bip122: [],\n solana: [],\n};\n\n/**\n * Notifications for known CAIP namespaces.\n */\nexport const KnownNotifications: Record<NonWalletKnownCaipNamespace, string[]> =\n {\n eip155: ['eth_subscription'],\n bip122: [],\n solana: [],\n };\n"]}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Caip25Errors = void 0;
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
5
|
+
/**
|
6
|
+
* CAIP25 Errors.
|
7
|
+
*/
|
8
|
+
exports.Caip25Errors = {
|
9
|
+
/**
|
10
|
+
* Thrown when chains requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
11
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
12
|
+
*
|
13
|
+
* @returns A new JsonRpcError instance.
|
14
|
+
*/
|
15
|
+
requestedChainsNotSupportedError: () => new rpc_errors_1.JsonRpcError(5100, 'Requested chains are not supported'),
|
16
|
+
/**
|
17
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
18
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
19
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_METHODS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
20
|
+
*
|
21
|
+
* @returns A new JsonRpcError instance.
|
22
|
+
*/
|
23
|
+
requestedMethodsNotSupportedError: () => new rpc_errors_1.JsonRpcError(5101, 'Requested methods are not supported'),
|
24
|
+
/**
|
25
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
26
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
27
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_NOTIFICATIONS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
28
|
+
*
|
29
|
+
* @returns A new JsonRpcError instance.
|
30
|
+
*/
|
31
|
+
requestedNotificationsNotSupportedError: () => new rpc_errors_1.JsonRpcError(5102, 'Requested notifications are not supported'),
|
32
|
+
/**
|
33
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
34
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
35
|
+
*
|
36
|
+
* @returns A new JsonRpcError instance.
|
37
|
+
*/
|
38
|
+
unknownMethodsRequestedError: () => new rpc_errors_1.JsonRpcError(5201, 'Unknown method(s) requested'),
|
39
|
+
/**
|
40
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
41
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
42
|
+
*
|
43
|
+
* @returns A new JsonRpcError instance.
|
44
|
+
*/
|
45
|
+
unknownNotificationsRequestedError: () => new rpc_errors_1.JsonRpcError(5202, 'Unknown notification(s) requested'),
|
46
|
+
};
|
47
|
+
//# sourceMappingURL=errors.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../../src/scope/errors.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAEpD;;GAEG;AACU,QAAA,YAAY,GAAG;IAC1B;;;;;OAKG;IACH,gCAAgC,EAAE,GAAG,EAAE,CACrC,IAAI,yBAAY,CAAC,IAAI,EAAE,oCAAoC,CAAC;IAE9D;;;;;;OAMG;IACH,iCAAiC,EAAE,GAAG,EAAE,CACtC,IAAI,yBAAY,CAAC,IAAI,EAAE,qCAAqC,CAAC;IAE/D;;;;;;OAMG;IACH,uCAAuC,EAAE,GAAG,EAAE,CAC5C,IAAI,yBAAY,CAAC,IAAI,EAAE,2CAA2C,CAAC;IAErE;;;;;OAKG;IACH,4BAA4B,EAAE,GAAG,EAAE,CACjC,IAAI,yBAAY,CAAC,IAAI,EAAE,6BAA6B,CAAC;IAEvD;;;;;OAKG;IACH,kCAAkC,EAAE,GAAG,EAAE,CACvC,IAAI,yBAAY,CAAC,IAAI,EAAE,mCAAmC,CAAC;CAC9D,CAAC","sourcesContent":["import { JsonRpcError } from '@metamask/rpc-errors';\n\n/**\n * CAIP25 Errors.\n */\nexport const Caip25Errors = {\n /**\n * Thrown when chains requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n *\n * @returns A new JsonRpcError instance.\n */\n requestedChainsNotSupportedError: () =>\n new JsonRpcError(5100, 'Requested chains are not supported'),\n\n /**\n * Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n * TODO: consider throwing the more generic version of this error (UNKNOWN_METHODS_REQUESTED_ERROR) unless in a DevMode build of the wallet\n *\n * @returns A new JsonRpcError instance.\n */\n requestedMethodsNotSupportedError: () =>\n new JsonRpcError(5101, 'Requested methods are not supported'),\n\n /**\n * Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n * TODO: consider throwing the more generic version of this error (UNKNOWN_NOTIFICATIONS_REQUESTED_ERROR) unless in a DevMode build of the wallet\n *\n * @returns A new JsonRpcError instance.\n */\n requestedNotificationsNotSupportedError: () =>\n new JsonRpcError(5102, 'Requested notifications are not supported'),\n\n /**\n * Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n *\n * @returns A new JsonRpcError instance.\n */\n unknownMethodsRequestedError: () =>\n new JsonRpcError(5201, 'Unknown method(s) requested'),\n\n /**\n * Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n *\n * @returns A new JsonRpcError instance.\n */\n unknownNotificationsRequestedError: () =>\n new JsonRpcError(5202, 'Unknown notification(s) requested'),\n};\n"]}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { JsonRpcError } from "@metamask/rpc-errors";
|
2
|
+
/**
|
3
|
+
* CAIP25 Errors.
|
4
|
+
*/
|
5
|
+
export declare const Caip25Errors: {
|
6
|
+
/**
|
7
|
+
* Thrown when chains requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
8
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
9
|
+
*
|
10
|
+
* @returns A new JsonRpcError instance.
|
11
|
+
*/
|
12
|
+
requestedChainsNotSupportedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
13
|
+
/**
|
14
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
15
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
16
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_METHODS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
17
|
+
*
|
18
|
+
* @returns A new JsonRpcError instance.
|
19
|
+
*/
|
20
|
+
requestedMethodsNotSupportedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
21
|
+
/**
|
22
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
23
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
24
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_NOTIFICATIONS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
25
|
+
*
|
26
|
+
* @returns A new JsonRpcError instance.
|
27
|
+
*/
|
28
|
+
requestedNotificationsNotSupportedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
29
|
+
/**
|
30
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
31
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
32
|
+
*
|
33
|
+
* @returns A new JsonRpcError instance.
|
34
|
+
*/
|
35
|
+
unknownMethodsRequestedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
36
|
+
/**
|
37
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
38
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
39
|
+
*
|
40
|
+
* @returns A new JsonRpcError instance.
|
41
|
+
*/
|
42
|
+
unknownNotificationsRequestedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
43
|
+
};
|
44
|
+
//# sourceMappingURL=errors.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../../src/scope/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,6BAA6B;AAEpD;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;OAKG;;IAIH;;;;;;OAMG;;IAIH;;;;;;OAMG;;IAIH;;;;;OAKG;;IAIH;;;;;OAKG;;CAGJ,CAAC"}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { JsonRpcError } from "@metamask/rpc-errors";
|
2
|
+
/**
|
3
|
+
* CAIP25 Errors.
|
4
|
+
*/
|
5
|
+
export declare const Caip25Errors: {
|
6
|
+
/**
|
7
|
+
* Thrown when chains requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
8
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
9
|
+
*
|
10
|
+
* @returns A new JsonRpcError instance.
|
11
|
+
*/
|
12
|
+
requestedChainsNotSupportedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
13
|
+
/**
|
14
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
15
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
16
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_METHODS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
17
|
+
*
|
18
|
+
* @returns A new JsonRpcError instance.
|
19
|
+
*/
|
20
|
+
requestedMethodsNotSupportedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
21
|
+
/**
|
22
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
23
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
24
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_NOTIFICATIONS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
25
|
+
*
|
26
|
+
* @returns A new JsonRpcError instance.
|
27
|
+
*/
|
28
|
+
requestedNotificationsNotSupportedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
29
|
+
/**
|
30
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
31
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
32
|
+
*
|
33
|
+
* @returns A new JsonRpcError instance.
|
34
|
+
*/
|
35
|
+
unknownMethodsRequestedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
36
|
+
/**
|
37
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
38
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
39
|
+
*
|
40
|
+
* @returns A new JsonRpcError instance.
|
41
|
+
*/
|
42
|
+
unknownNotificationsRequestedError: () => JsonRpcError<import("@metamask/rpc-errors").OptionalDataWithOptionalCause>;
|
43
|
+
};
|
44
|
+
//# sourceMappingURL=errors.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../../src/scope/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,6BAA6B;AAEpD;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;OAKG;;IAIH;;;;;;OAMG;;IAIH;;;;;;OAMG;;IAIH;;;;;OAKG;;IAIH;;;;;OAKG;;CAGJ,CAAC"}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { JsonRpcError } from "@metamask/rpc-errors";
|
2
|
+
/**
|
3
|
+
* CAIP25 Errors.
|
4
|
+
*/
|
5
|
+
export const Caip25Errors = {
|
6
|
+
/**
|
7
|
+
* Thrown when chains requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
8
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
9
|
+
*
|
10
|
+
* @returns A new JsonRpcError instance.
|
11
|
+
*/
|
12
|
+
requestedChainsNotSupportedError: () => new JsonRpcError(5100, 'Requested chains are not supported'),
|
13
|
+
/**
|
14
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
15
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
16
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_METHODS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
17
|
+
*
|
18
|
+
* @returns A new JsonRpcError instance.
|
19
|
+
*/
|
20
|
+
requestedMethodsNotSupportedError: () => new JsonRpcError(5101, 'Requested methods are not supported'),
|
21
|
+
/**
|
22
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
23
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
24
|
+
* TODO: consider throwing the more generic version of this error (UNKNOWN_NOTIFICATIONS_REQUESTED_ERROR) unless in a DevMode build of the wallet
|
25
|
+
*
|
26
|
+
* @returns A new JsonRpcError instance.
|
27
|
+
*/
|
28
|
+
requestedNotificationsNotSupportedError: () => new JsonRpcError(5102, 'Requested notifications are not supported'),
|
29
|
+
/**
|
30
|
+
* Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
31
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
32
|
+
*
|
33
|
+
* @returns A new JsonRpcError instance.
|
34
|
+
*/
|
35
|
+
unknownMethodsRequestedError: () => new JsonRpcError(5201, 'Unknown method(s) requested'),
|
36
|
+
/**
|
37
|
+
* Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.
|
38
|
+
* Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).
|
39
|
+
*
|
40
|
+
* @returns A new JsonRpcError instance.
|
41
|
+
*/
|
42
|
+
unknownNotificationsRequestedError: () => new JsonRpcError(5202, 'Unknown notification(s) requested'),
|
43
|
+
};
|
44
|
+
//# sourceMappingURL=errors.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../../src/scope/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,6BAA6B;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;;;;;OAKG;IACH,gCAAgC,EAAE,GAAG,EAAE,CACrC,IAAI,YAAY,CAAC,IAAI,EAAE,oCAAoC,CAAC;IAE9D;;;;;;OAMG;IACH,iCAAiC,EAAE,GAAG,EAAE,CACtC,IAAI,YAAY,CAAC,IAAI,EAAE,qCAAqC,CAAC;IAE/D;;;;;;OAMG;IACH,uCAAuC,EAAE,GAAG,EAAE,CAC5C,IAAI,YAAY,CAAC,IAAI,EAAE,2CAA2C,CAAC;IAErE;;;;;OAKG;IACH,4BAA4B,EAAE,GAAG,EAAE,CACjC,IAAI,YAAY,CAAC,IAAI,EAAE,6BAA6B,CAAC;IAEvD;;;;;OAKG;IACH,kCAAkC,EAAE,GAAG,EAAE,CACvC,IAAI,YAAY,CAAC,IAAI,EAAE,mCAAmC,CAAC;CAC9D,CAAC","sourcesContent":["import { JsonRpcError } from '@metamask/rpc-errors';\n\n/**\n * CAIP25 Errors.\n */\nexport const Caip25Errors = {\n /**\n * Thrown when chains requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n *\n * @returns A new JsonRpcError instance.\n */\n requestedChainsNotSupportedError: () =>\n new JsonRpcError(5100, 'Requested chains are not supported'),\n\n /**\n * Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n * TODO: consider throwing the more generic version of this error (UNKNOWN_METHODS_REQUESTED_ERROR) unless in a DevMode build of the wallet\n *\n * @returns A new JsonRpcError instance.\n */\n requestedMethodsNotSupportedError: () =>\n new JsonRpcError(5101, 'Requested methods are not supported'),\n\n /**\n * Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n * TODO: consider throwing the more generic version of this error (UNKNOWN_NOTIFICATIONS_REQUESTED_ERROR) unless in a DevMode build of the wallet\n *\n * @returns A new JsonRpcError instance.\n */\n requestedNotificationsNotSupportedError: () =>\n new JsonRpcError(5102, 'Requested notifications are not supported'),\n\n /**\n * Thrown when methods requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n *\n * @returns A new JsonRpcError instance.\n */\n unknownMethodsRequestedError: () =>\n new JsonRpcError(5201, 'Unknown method(s) requested'),\n\n /**\n * Thrown when notifications requested in a CAIP-25 `wallet_createSession` call are not supported by the wallet.\n * Defined in [CAIP-25 error codes section](https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-25.md#trusted-failure-codes).\n *\n * @returns A new JsonRpcError instance.\n */\n unknownNotificationsRequestedError: () =>\n new JsonRpcError(5202, 'Unknown notification(s) requested'),\n};\n"]}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getSupportedScopeObjects = exports.bucketScopesBySupport = void 0;
|
4
|
+
const assert_1 = require("./assert.cjs");
|
5
|
+
const supported_1 = require("./supported.cjs");
|
6
|
+
/**
|
7
|
+
* Groups a NormalizedScopesObject into two separate
|
8
|
+
* NormalizedScopesObject with supported scopes in one
|
9
|
+
* and unsupported scopes in the other.
|
10
|
+
*
|
11
|
+
* @param scopes - The NormalizedScopesObject to group.
|
12
|
+
* @param hooks - An object containing the following properties:
|
13
|
+
* @param hooks.isEvmChainIdSupported - A predicate that determines if an EVM chainID is supported.
|
14
|
+
* @param hooks.isNonEvmScopeSupported - A predicate that determines if an non EVM scopeString is supported.
|
15
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
16
|
+
* @returns The supported and unsupported scopes.
|
17
|
+
*/
|
18
|
+
const bucketScopesBySupport = (scopes, { isEvmChainIdSupported, isNonEvmScopeSupported, getNonEvmSupportedMethods, }) => {
|
19
|
+
const supportedScopes = {};
|
20
|
+
const unsupportedScopes = {};
|
21
|
+
for (const [scopeString, scopeObject] of Object.entries(scopes)) {
|
22
|
+
(0, assert_1.assertIsInternalScopeString)(scopeString);
|
23
|
+
try {
|
24
|
+
(0, assert_1.assertScopeSupported)(scopeString, scopeObject, {
|
25
|
+
isEvmChainIdSupported,
|
26
|
+
isNonEvmScopeSupported,
|
27
|
+
getNonEvmSupportedMethods,
|
28
|
+
});
|
29
|
+
supportedScopes[scopeString] = scopeObject;
|
30
|
+
}
|
31
|
+
catch {
|
32
|
+
unsupportedScopes[scopeString] = scopeObject;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return { supportedScopes, unsupportedScopes };
|
36
|
+
};
|
37
|
+
exports.bucketScopesBySupport = bucketScopesBySupport;
|
38
|
+
/**
|
39
|
+
* Returns a NormalizedScopeObject with
|
40
|
+
* unsupported methods and notifications removed.
|
41
|
+
*
|
42
|
+
* @param scopeString - The InternalScopeString for the scopeObject.
|
43
|
+
* @param scopeObject - The NormalizedScopeObject to filter.
|
44
|
+
* @param hooks - An object containing the following properties:
|
45
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
46
|
+
* @returns a NormalizedScopeObject with only methods and notifications that are currently supported.
|
47
|
+
*/
|
48
|
+
const getSupportedScopeObject = (scopeString, scopeObject, { getNonEvmSupportedMethods, }) => {
|
49
|
+
const { methods, notifications } = scopeObject;
|
50
|
+
const supportedMethods = methods.filter((method) => (0, supported_1.isSupportedMethod)(scopeString, method, { getNonEvmSupportedMethods }));
|
51
|
+
const supportedNotifications = notifications.filter((notification) => (0, supported_1.isSupportedNotification)(scopeString, notification));
|
52
|
+
return {
|
53
|
+
...scopeObject,
|
54
|
+
methods: supportedMethods,
|
55
|
+
notifications: supportedNotifications,
|
56
|
+
};
|
57
|
+
};
|
58
|
+
/**
|
59
|
+
* Returns a NormalizedScopesObject with
|
60
|
+
* unsupported methods and notifications removed from scopeObjects.
|
61
|
+
*
|
62
|
+
* @param scopes - The NormalizedScopesObject to filter.
|
63
|
+
* @param hooks - An object containing the following properties:
|
64
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
65
|
+
* @returns a NormalizedScopesObject with only methods, and notifications that are currently supported.
|
66
|
+
*/
|
67
|
+
const getSupportedScopeObjects = (scopes, { getNonEvmSupportedMethods, }) => {
|
68
|
+
const filteredScopesObject = {};
|
69
|
+
for (const [scopeString, scopeObject] of Object.entries(scopes)) {
|
70
|
+
(0, assert_1.assertIsInternalScopeString)(scopeString);
|
71
|
+
filteredScopesObject[scopeString] = getSupportedScopeObject(scopeString, scopeObject, { getNonEvmSupportedMethods });
|
72
|
+
}
|
73
|
+
return filteredScopesObject;
|
74
|
+
};
|
75
|
+
exports.getSupportedScopeObjects = getSupportedScopeObjects;
|
76
|
+
//# sourceMappingURL=filter.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filter.cjs","sourceRoot":"","sources":["../../src/scope/filter.ts"],"names":[],"mappings":";;;AAEA,yCAA6E;AAC7E,+CAAyE;AAOzE;;;;;;;;;;;GAWG;AACI,MAAM,qBAAqB,GAAG,CACnC,MAA8B,EAC9B,EACE,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GAK1B,EACD,EAAE;IACF,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,MAAM,iBAAiB,GAA2B,EAAE,CAAC;IAErD,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC/D,IAAA,oCAA2B,EAAC,WAAW,CAAC,CAAC;QACzC,IAAI;YACF,IAAA,6BAAoB,EAAC,WAAW,EAAE,WAAW,EAAE;gBAC7C,qBAAqB;gBACrB,sBAAsB;gBACtB,yBAAyB;aAC1B,CAAC,CAAC;YACH,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;SAC5C;QAAC,MAAM;YACN,iBAAiB,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;SAC9C;KACF;IAED,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAChD,CAAC,CAAC;AA9BW,QAAA,qBAAqB,yBA8BhC;AAEF;;;;;;;;;GASG;AACH,MAAM,uBAAuB,GAAG,CAC9B,WAAgC,EAChC,WAAkC,EAClC,EACE,yBAAyB,GAG1B,EACD,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC;IAE/C,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACjD,IAAA,6BAAiB,EAAC,WAAW,EAAE,MAAM,EAAE,EAAE,yBAAyB,EAAE,CAAC,CACtE,CAAC;IAEF,MAAM,sBAAsB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CACnE,IAAA,mCAAuB,EAAC,WAAW,EAAE,YAAY,CAAC,CACnD,CAAC;IAEF,OAAO;QACL,GAAG,WAAW;QACd,OAAO,EAAE,gBAAgB;QACzB,aAAa,EAAE,sBAAsB;KACtC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,wBAAwB,GAAG,CACtC,MAA8B,EAC9B,EACE,yBAAyB,GAG1B,EACD,EAAE;IACF,MAAM,oBAAoB,GAA2B,EAAE,CAAC;IAExD,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC/D,IAAA,oCAA2B,EAAC,WAAW,CAAC,CAAC;QACzC,oBAAoB,CAAC,WAAW,CAAC,GAAG,uBAAuB,CACzD,WAAW,EACX,WAAW,EACX,EAAE,yBAAyB,EAAE,CAC9B,CAAC;KACH;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC;AApBW,QAAA,wBAAwB,4BAoBnC","sourcesContent":["import type { CaipChainId, Hex } from '@metamask/utils';\n\nimport { assertIsInternalScopeString, assertScopeSupported } from './assert';\nimport { isSupportedMethod, isSupportedNotification } from './supported';\nimport type {\n InternalScopeString,\n NormalizedScopeObject,\n NormalizedScopesObject,\n} from './types';\n\n/**\n * Groups a NormalizedScopesObject into two separate\n * NormalizedScopesObject with supported scopes in one\n * and unsupported scopes in the other.\n *\n * @param scopes - The NormalizedScopesObject to group.\n * @param hooks - An object containing the following properties:\n * @param hooks.isEvmChainIdSupported - A predicate that determines if an EVM chainID is supported.\n * @param hooks.isNonEvmScopeSupported - A predicate that determines if an non EVM scopeString is supported.\n * @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.\n * @returns The supported and unsupported scopes.\n */\nexport const bucketScopesBySupport = (\n scopes: NormalizedScopesObject,\n {\n isEvmChainIdSupported,\n isNonEvmScopeSupported,\n getNonEvmSupportedMethods,\n }: {\n isEvmChainIdSupported: (chainId: Hex) => boolean;\n isNonEvmScopeSupported: (scope: CaipChainId) => boolean;\n getNonEvmSupportedMethods: (scope: CaipChainId) => string[];\n },\n) => {\n const supportedScopes: NormalizedScopesObject = {};\n const unsupportedScopes: NormalizedScopesObject = {};\n\n for (const [scopeString, scopeObject] of Object.entries(scopes)) {\n assertIsInternalScopeString(scopeString);\n try {\n assertScopeSupported(scopeString, scopeObject, {\n isEvmChainIdSupported,\n isNonEvmScopeSupported,\n getNonEvmSupportedMethods,\n });\n supportedScopes[scopeString] = scopeObject;\n } catch {\n unsupportedScopes[scopeString] = scopeObject;\n }\n }\n\n return { supportedScopes, unsupportedScopes };\n};\n\n/**\n * Returns a NormalizedScopeObject with\n * unsupported methods and notifications removed.\n *\n * @param scopeString - The InternalScopeString for the scopeObject.\n * @param scopeObject - The NormalizedScopeObject to filter.\n * @param hooks - An object containing the following properties:\n * @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.\n * @returns a NormalizedScopeObject with only methods and notifications that are currently supported.\n */\nconst getSupportedScopeObject = (\n scopeString: InternalScopeString,\n scopeObject: NormalizedScopeObject,\n {\n getNonEvmSupportedMethods,\n }: {\n getNonEvmSupportedMethods: (scope: CaipChainId) => string[];\n },\n) => {\n const { methods, notifications } = scopeObject;\n\n const supportedMethods = methods.filter((method) =>\n isSupportedMethod(scopeString, method, { getNonEvmSupportedMethods }),\n );\n\n const supportedNotifications = notifications.filter((notification) =>\n isSupportedNotification(scopeString, notification),\n );\n\n return {\n ...scopeObject,\n methods: supportedMethods,\n notifications: supportedNotifications,\n };\n};\n\n/**\n * Returns a NormalizedScopesObject with\n * unsupported methods and notifications removed from scopeObjects.\n *\n * @param scopes - The NormalizedScopesObject to filter.\n * @param hooks - An object containing the following properties:\n * @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.\n * @returns a NormalizedScopesObject with only methods, and notifications that are currently supported.\n */\nexport const getSupportedScopeObjects = (\n scopes: NormalizedScopesObject,\n {\n getNonEvmSupportedMethods,\n }: {\n getNonEvmSupportedMethods: (scope: CaipChainId) => string[];\n },\n) => {\n const filteredScopesObject: NormalizedScopesObject = {};\n\n for (const [scopeString, scopeObject] of Object.entries(scopes)) {\n assertIsInternalScopeString(scopeString);\n filteredScopesObject[scopeString] = getSupportedScopeObject(\n scopeString,\n scopeObject,\n { getNonEvmSupportedMethods },\n );\n }\n\n return filteredScopesObject;\n};\n"]}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { CaipChainId, Hex } from "@metamask/utils";
|
2
|
+
import type { NormalizedScopesObject } from "./types.cjs";
|
3
|
+
/**
|
4
|
+
* Groups a NormalizedScopesObject into two separate
|
5
|
+
* NormalizedScopesObject with supported scopes in one
|
6
|
+
* and unsupported scopes in the other.
|
7
|
+
*
|
8
|
+
* @param scopes - The NormalizedScopesObject to group.
|
9
|
+
* @param hooks - An object containing the following properties:
|
10
|
+
* @param hooks.isEvmChainIdSupported - A predicate that determines if an EVM chainID is supported.
|
11
|
+
* @param hooks.isNonEvmScopeSupported - A predicate that determines if an non EVM scopeString is supported.
|
12
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
13
|
+
* @returns The supported and unsupported scopes.
|
14
|
+
*/
|
15
|
+
export declare const bucketScopesBySupport: (scopes: NormalizedScopesObject, { isEvmChainIdSupported, isNonEvmScopeSupported, getNonEvmSupportedMethods, }: {
|
16
|
+
isEvmChainIdSupported: (chainId: Hex) => boolean;
|
17
|
+
isNonEvmScopeSupported: (scope: CaipChainId) => boolean;
|
18
|
+
getNonEvmSupportedMethods: (scope: CaipChainId) => string[];
|
19
|
+
}) => {
|
20
|
+
supportedScopes: NormalizedScopesObject;
|
21
|
+
unsupportedScopes: NormalizedScopesObject;
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* Returns a NormalizedScopesObject with
|
25
|
+
* unsupported methods and notifications removed from scopeObjects.
|
26
|
+
*
|
27
|
+
* @param scopes - The NormalizedScopesObject to filter.
|
28
|
+
* @param hooks - An object containing the following properties:
|
29
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
30
|
+
* @returns a NormalizedScopesObject with only methods, and notifications that are currently supported.
|
31
|
+
*/
|
32
|
+
export declare const getSupportedScopeObjects: (scopes: NormalizedScopesObject, { getNonEvmSupportedMethods, }: {
|
33
|
+
getNonEvmSupportedMethods: (scope: CaipChainId) => string[];
|
34
|
+
}) => NormalizedScopesObject;
|
35
|
+
//# sourceMappingURL=filter.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filter.d.cts","sourceRoot":"","sources":["../../src/scope/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAIxD,OAAO,KAAK,EAGV,sBAAsB,EACvB,oBAAgB;AAEjB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,WACxB,sBAAsB;qCAMK,GAAG,KAAK,OAAO;oCAChB,WAAW,KAAK,OAAO;uCACpB,WAAW,KAAK,MAAM,EAAE;;;;CAqB9D,CAAC;AAsCF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,WAC3B,sBAAsB;uCAIO,WAAW,KAAK,MAAM,EAAE;4BAe9D,CAAC"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type { CaipChainId, Hex } from "@metamask/utils";
|
2
|
+
import type { NormalizedScopesObject } from "./types.mjs";
|
3
|
+
/**
|
4
|
+
* Groups a NormalizedScopesObject into two separate
|
5
|
+
* NormalizedScopesObject with supported scopes in one
|
6
|
+
* and unsupported scopes in the other.
|
7
|
+
*
|
8
|
+
* @param scopes - The NormalizedScopesObject to group.
|
9
|
+
* @param hooks - An object containing the following properties:
|
10
|
+
* @param hooks.isEvmChainIdSupported - A predicate that determines if an EVM chainID is supported.
|
11
|
+
* @param hooks.isNonEvmScopeSupported - A predicate that determines if an non EVM scopeString is supported.
|
12
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
13
|
+
* @returns The supported and unsupported scopes.
|
14
|
+
*/
|
15
|
+
export declare const bucketScopesBySupport: (scopes: NormalizedScopesObject, { isEvmChainIdSupported, isNonEvmScopeSupported, getNonEvmSupportedMethods, }: {
|
16
|
+
isEvmChainIdSupported: (chainId: Hex) => boolean;
|
17
|
+
isNonEvmScopeSupported: (scope: CaipChainId) => boolean;
|
18
|
+
getNonEvmSupportedMethods: (scope: CaipChainId) => string[];
|
19
|
+
}) => {
|
20
|
+
supportedScopes: NormalizedScopesObject;
|
21
|
+
unsupportedScopes: NormalizedScopesObject;
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* Returns a NormalizedScopesObject with
|
25
|
+
* unsupported methods and notifications removed from scopeObjects.
|
26
|
+
*
|
27
|
+
* @param scopes - The NormalizedScopesObject to filter.
|
28
|
+
* @param hooks - An object containing the following properties:
|
29
|
+
* @param hooks.getNonEvmSupportedMethods - A function that returns the supported methods for a non EVM scope.
|
30
|
+
* @returns a NormalizedScopesObject with only methods, and notifications that are currently supported.
|
31
|
+
*/
|
32
|
+
export declare const getSupportedScopeObjects: (scopes: NormalizedScopesObject, { getNonEvmSupportedMethods, }: {
|
33
|
+
getNonEvmSupportedMethods: (scope: CaipChainId) => string[];
|
34
|
+
}) => NormalizedScopesObject;
|
35
|
+
//# sourceMappingURL=filter.d.mts.map
|