@metamask/keyring-api 10.1.0 → 11.1.0
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 +16 -1
- package/dist/{JsonRpcRequest.js → JsonRpcRequest.cjs} +2 -2
- package/dist/JsonRpcRequest.cjs.map +1 -0
- package/dist/{JsonRpcRequest.d.ts → JsonRpcRequest.d.cts} +3 -2
- package/dist/JsonRpcRequest.d.cts.map +1 -0
- package/dist/JsonRpcRequest.d.mts +17 -0
- package/dist/JsonRpcRequest.d.mts.map +1 -0
- package/dist/JsonRpcRequest.mjs +10 -0
- package/dist/JsonRpcRequest.mjs.map +1 -0
- package/dist/{KeyringClient.js → KeyringClient.cjs} +10 -4
- package/dist/KeyringClient.cjs.map +1 -0
- package/dist/{KeyringClient.d.ts → KeyringClient.d.cts} +6 -3
- package/dist/KeyringClient.d.cts.map +1 -0
- package/dist/KeyringClient.d.mts +31 -0
- package/dist/KeyringClient.d.mts.map +1 -0
- package/dist/KeyringClient.mjs +126 -0
- package/dist/KeyringClient.mjs.map +1 -0
- package/dist/{KeyringSnapRpcClient.js → KeyringSnapRpcClient.cjs} +2 -2
- package/dist/KeyringSnapRpcClient.cjs.map +1 -0
- package/dist/{KeyringSnapRpcClient.d.ts → KeyringSnapRpcClient.d.cts} +6 -5
- package/dist/KeyringSnapRpcClient.d.cts.map +1 -0
- package/dist/KeyringSnapRpcClient.d.mts +40 -0
- package/dist/KeyringSnapRpcClient.d.mts.map +1 -0
- package/dist/KeyringSnapRpcClient.mjs +63 -0
- package/dist/KeyringSnapRpcClient.mjs.map +1 -0
- package/dist/api/{account.js → account.cjs} +3 -3
- package/dist/api/account.cjs.map +1 -0
- package/dist/api/{account.d.ts → account.d.cts} +2 -1
- package/dist/api/account.d.cts.map +1 -0
- package/dist/api/account.d.mts +70 -0
- package/dist/api/account.d.mts.map +1 -0
- package/dist/api/account.mjs +61 -0
- package/dist/api/account.mjs.map +1 -0
- package/dist/api/asset.cjs +83 -0
- package/dist/api/asset.cjs.map +1 -0
- package/dist/api/asset.d.cts +93 -0
- package/dist/api/asset.d.cts.map +1 -0
- package/dist/api/asset.d.mts +93 -0
- package/dist/api/asset.d.mts.map +1 -0
- package/dist/api/asset.mjs +80 -0
- package/dist/api/asset.mjs.map +1 -0
- package/dist/api/{balance.js → balance.cjs} +3 -3
- package/dist/api/balance.cjs.map +1 -0
- package/dist/api/{balance.d.ts → balance.d.cts} +3 -2
- package/dist/api/balance.d.cts.map +1 -0
- package/dist/api/balance.d.mts +10 -0
- package/dist/api/balance.d.mts.map +1 -0
- package/dist/api/balance.mjs +8 -0
- package/dist/api/balance.mjs.map +1 -0
- package/dist/api/{caip.js → caip.cjs} +5 -5
- package/dist/api/caip.cjs.map +1 -0
- package/dist/api/{caip.d.ts → caip.d.cts} +2 -1
- package/dist/api/caip.d.cts.map +1 -0
- package/dist/api/caip.d.mts +38 -0
- package/dist/api/caip.d.mts.map +1 -0
- package/dist/api/caip.mjs +43 -0
- package/dist/api/caip.mjs.map +1 -0
- package/dist/api/{export.js → export.cjs} +1 -1
- package/dist/api/export.cjs.map +1 -0
- package/dist/api/{export.d.ts → export.d.cts} +2 -1
- package/dist/api/export.d.cts.map +1 -0
- package/dist/api/export.d.mts +9 -0
- package/dist/api/export.d.mts.map +1 -0
- package/dist/api/export.mjs +4 -0
- package/dist/api/export.mjs.map +1 -0
- package/dist/api/{index.js → index.cjs} +9 -7
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.cts +10 -0
- package/dist/api/index.d.cts.map +1 -0
- package/dist/api/index.d.mts +10 -0
- package/dist/api/index.d.mts.map +1 -0
- package/dist/api/index.mjs +9 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/api/{keyring.js → keyring.cjs} +1 -1
- package/dist/api/keyring.cjs.map +1 -0
- package/dist/api/{keyring.d.ts → keyring.d.cts} +22 -7
- package/dist/api/keyring.d.cts.map +1 -0
- package/dist/api/keyring.d.mts +174 -0
- package/dist/api/keyring.d.mts.map +1 -0
- package/dist/api/keyring.mjs +2 -0
- package/dist/api/keyring.mjs.map +1 -0
- package/dist/api/{request.js → request.cjs} +3 -3
- package/dist/api/request.cjs.map +1 -0
- package/dist/api/{request.d.ts → request.d.cts} +3 -2
- package/dist/api/request.d.cts.map +1 -0
- package/dist/api/request.d.mts +40 -0
- package/dist/api/request.d.mts.map +1 -0
- package/dist/api/request.mjs +26 -0
- package/dist/api/request.mjs.map +1 -0
- package/dist/api/{response.js → response.cjs} +2 -2
- package/dist/api/response.cjs.map +1 -0
- package/dist/api/{response.d.ts → response.d.cts} +2 -1
- package/dist/api/response.d.cts.map +1 -0
- package/dist/api/response.d.mts +25 -0
- package/dist/api/response.d.mts.map +1 -0
- package/dist/api/response.mjs +41 -0
- package/dist/api/response.mjs.map +1 -0
- package/dist/api/transaction.cjs +295 -0
- package/dist/api/transaction.cjs.map +1 -0
- package/dist/api/transaction.d.cts +773 -0
- package/dist/api/transaction.d.cts.map +1 -0
- package/dist/api/transaction.d.mts +773 -0
- package/dist/api/transaction.d.mts.map +1 -0
- package/dist/api/transaction.mjs +292 -0
- package/dist/api/transaction.mjs.map +1 -0
- package/dist/{eth/erc4337/index.js → btc/index.cjs} +2 -2
- package/dist/btc/index.cjs.map +1 -0
- package/dist/btc/index.d.cts +2 -0
- package/dist/btc/index.d.cts.map +1 -0
- package/dist/btc/index.d.mts +2 -0
- package/dist/btc/index.d.mts.map +1 -0
- package/dist/btc/index.mjs +2 -0
- package/dist/btc/index.mjs.map +1 -0
- package/dist/btc/{types.js → types.cjs} +3 -3
- package/dist/btc/types.cjs.map +1 -0
- package/dist/btc/{types.d.ts → types.d.cts} +2 -1
- package/dist/btc/types.d.cts.map +1 -0
- package/dist/btc/types.d.mts +34 -0
- package/dist/btc/types.d.mts.map +1 -0
- package/dist/btc/types.mjs +37 -0
- package/dist/btc/types.mjs.map +1 -0
- package/dist/{contexts.js → contexts.cjs} +1 -1
- package/dist/contexts.cjs.map +1 -0
- package/dist/{contexts.d.ts → contexts.d.cts} +1 -0
- package/dist/contexts.d.cts.map +1 -0
- package/dist/contexts.d.mts +8 -0
- package/dist/contexts.d.mts.map +1 -0
- package/dist/contexts.mjs +2 -0
- package/dist/contexts.mjs.map +1 -0
- package/dist/{sol/index.js → eth/erc4337/index.cjs} +2 -2
- package/dist/eth/erc4337/index.cjs.map +1 -0
- package/dist/eth/erc4337/index.d.cts +2 -0
- package/dist/eth/erc4337/index.d.cts.map +1 -0
- package/dist/eth/erc4337/index.d.mts +2 -0
- package/dist/eth/erc4337/index.d.mts.map +1 -0
- package/dist/eth/erc4337/index.mjs +2 -0
- package/dist/eth/erc4337/index.mjs.map +1 -0
- package/dist/eth/erc4337/{types.js → types.cjs} +4 -4
- package/dist/eth/erc4337/types.cjs.map +1 -0
- package/dist/eth/erc4337/{types.d.ts → types.d.cts} +7 -6
- package/dist/eth/erc4337/types.d.cts.map +1 -0
- package/dist/eth/erc4337/types.d.mts +98 -0
- package/dist/eth/erc4337/types.d.mts.map +1 -0
- package/dist/eth/erc4337/types.mjs +59 -0
- package/dist/eth/erc4337/types.mjs.map +1 -0
- package/dist/eth/index.cjs +20 -0
- package/dist/eth/index.cjs.map +1 -0
- package/dist/eth/index.d.cts +4 -0
- package/dist/eth/index.d.cts.map +1 -0
- package/dist/eth/index.d.mts +4 -0
- package/dist/eth/index.d.mts.map +1 -0
- package/dist/eth/index.mjs +4 -0
- package/dist/eth/index.mjs.map +1 -0
- package/dist/eth/{types.js → types.cjs} +3 -3
- package/dist/eth/types.cjs.map +1 -0
- package/dist/eth/{types.d.ts → types.d.cts} +2 -1
- package/dist/eth/types.d.cts.map +1 -0
- package/dist/eth/types.d.mts +81 -0
- package/dist/eth/types.d.mts.map +1 -0
- package/dist/eth/types.mjs +70 -0
- package/dist/eth/types.mjs.map +1 -0
- package/dist/eth/{utils.js → utils.cjs} +3 -4
- package/dist/eth/{utils.js.map → utils.cjs.map} +1 -1
- package/dist/eth/{utils.d.ts → utils.d.cts} +2 -1
- package/dist/eth/utils.d.cts.map +1 -0
- package/dist/eth/utils.d.mts +9 -0
- package/dist/eth/utils.d.mts.map +1 -0
- package/dist/eth/utils.mjs +11 -0
- package/dist/eth/utils.mjs.map +1 -0
- package/dist/{events.js → events.cjs} +1 -1
- package/dist/events.cjs.map +1 -0
- package/dist/{events.d.ts → events.d.cts} +1 -0
- package/dist/events.d.cts.map +1 -0
- package/dist/events.d.mts +11 -0
- package/dist/events.d.mts.map +1 -0
- package/dist/events.mjs +14 -0
- package/dist/events.mjs.map +1 -0
- package/dist/index.cjs +29 -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 +13 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal/{api.js → api.cjs} +17 -6
- package/dist/internal/api.cjs.map +1 -0
- package/dist/internal/{api.d.ts → api.d.cts} +323 -5
- package/dist/internal/api.d.cts.map +1 -0
- package/dist/internal/api.d.mts +737 -0
- package/dist/internal/api.d.mts.map +1 -0
- package/dist/internal/api.mjs +147 -0
- package/dist/internal/api.mjs.map +1 -0
- package/dist/internal/eth/{EthKeyring.js → EthKeyring.cjs} +1 -1
- package/dist/internal/eth/EthKeyring.cjs.map +1 -0
- package/dist/internal/eth/{EthKeyring.d.ts → EthKeyring.d.cts} +4 -3
- package/dist/internal/eth/EthKeyring.d.cts.map +1 -0
- package/dist/internal/eth/EthKeyring.d.mts +34 -0
- package/dist/internal/eth/EthKeyring.d.mts.map +1 -0
- package/dist/internal/eth/EthKeyring.mjs +2 -0
- package/dist/internal/eth/EthKeyring.mjs.map +1 -0
- package/dist/internal/eth/{index.js → index.cjs} +1 -1
- package/dist/internal/eth/index.cjs.map +1 -0
- package/dist/internal/eth/index.d.cts +2 -0
- package/dist/internal/eth/index.d.cts.map +1 -0
- package/dist/internal/eth/index.d.mts +2 -0
- package/dist/internal/eth/index.d.mts.map +1 -0
- package/dist/internal/eth/index.mjs +2 -0
- package/dist/internal/eth/index.mjs.map +1 -0
- package/dist/internal/{events.js → events.cjs} +5 -5
- package/dist/internal/events.cjs.map +1 -0
- package/dist/internal/{events.d.ts → events.d.cts} +3 -2
- package/dist/internal/events.d.cts.map +1 -0
- package/dist/internal/events.d.mts +162 -0
- package/dist/internal/events.d.mts.map +1 -0
- package/dist/internal/events.mjs +69 -0
- package/dist/internal/events.mjs.map +1 -0
- package/dist/internal/{index.js → index.cjs} +5 -5
- package/dist/internal/index.cjs.map +1 -0
- package/dist/internal/index.d.cts +6 -0
- package/dist/internal/index.d.cts.map +1 -0
- package/dist/internal/index.d.mts +6 -0
- package/dist/internal/index.d.mts.map +1 -0
- package/dist/internal/index.mjs +5 -0
- package/dist/internal/index.mjs.map +1 -0
- package/dist/internal/{rpc.js → rpc.cjs} +4 -3
- package/dist/internal/rpc.cjs.map +1 -0
- package/dist/internal/{rpc.d.ts → rpc.d.cts} +2 -0
- package/dist/internal/rpc.d.cts.map +1 -0
- package/dist/internal/rpc.d.mts +27 -0
- package/dist/internal/rpc.d.mts.map +1 -0
- package/dist/internal/rpc.mjs +30 -0
- package/dist/internal/rpc.mjs.map +1 -0
- package/dist/internal/{types.js → types.cjs} +6 -6
- package/dist/internal/types.cjs.map +1 -0
- package/dist/internal/{types.d.ts → types.d.cts} +21 -20
- package/dist/internal/types.d.cts.map +1 -0
- package/dist/internal/types.d.mts +392 -0
- package/dist/internal/types.d.mts.map +1 -0
- package/dist/internal/types.mjs +49 -0
- package/dist/internal/types.mjs.map +1 -0
- package/dist/{rpc-handler.js → rpc-handler.cjs} +13 -6
- package/dist/rpc-handler.cjs.map +1 -0
- package/dist/{rpc-handler.d.ts → rpc-handler.d.cts} +4 -3
- package/dist/rpc-handler.d.cts.map +1 -0
- package/dist/rpc-handler.d.mts +30 -0
- package/dist/rpc-handler.d.mts.map +1 -0
- package/dist/rpc-handler.mjs +138 -0
- package/dist/rpc-handler.mjs.map +1 -0
- package/dist/{snap-utils.js → snap-utils.cjs} +2 -3
- package/dist/snap-utils.cjs.map +1 -0
- package/dist/{snap-utils.d.ts → snap-utils.d.cts} +4 -3
- package/dist/snap-utils.d.cts.map +1 -0
- package/dist/snap-utils.d.mts +12 -0
- package/dist/snap-utils.d.mts.map +1 -0
- package/dist/snap-utils.mjs +17 -0
- package/dist/snap-utils.mjs.map +1 -0
- package/dist/{btc/index.js → sol/index.cjs} +2 -2
- package/dist/sol/index.cjs.map +1 -0
- package/dist/sol/index.d.cts +2 -0
- package/dist/sol/index.d.cts.map +1 -0
- package/dist/sol/index.d.mts +2 -0
- package/dist/sol/index.d.mts.map +1 -0
- package/dist/sol/index.mjs +2 -0
- package/dist/sol/index.mjs.map +1 -0
- package/dist/sol/{types.js → types.cjs} +3 -3
- package/dist/sol/types.cjs.map +1 -0
- package/dist/sol/{types.d.ts → types.d.cts} +2 -1
- package/dist/sol/types.d.cts.map +1 -0
- package/dist/sol/types.d.mts +39 -0
- package/dist/sol/types.d.mts.map +1 -0
- package/dist/sol/types.mjs +33 -0
- package/dist/sol/types.mjs.map +1 -0
- package/dist/{superstruct.js → superstruct.cjs} +34 -6
- package/dist/superstruct.cjs.map +1 -0
- package/dist/{superstruct.d.ts → superstruct.d.cts} +21 -2
- package/dist/superstruct.d.cts.map +1 -0
- package/dist/superstruct.d.mts +102 -0
- package/dist/superstruct.d.mts.map +1 -0
- package/dist/superstruct.mjs +102 -0
- package/dist/superstruct.mjs.map +1 -0
- package/dist/{eth/index.js → utils/index.cjs} +4 -4
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +4 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +4 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +4 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/pagination.cjs +28 -0
- package/dist/utils/pagination.cjs.map +1 -0
- package/dist/utils/pagination.d.cts +59 -0
- package/dist/utils/pagination.d.cts.map +1 -0
- package/dist/utils/pagination.d.mts +59 -0
- package/dist/utils/pagination.d.mts.map +1 -0
- package/dist/utils/pagination.mjs +25 -0
- package/dist/utils/pagination.mjs.map +1 -0
- package/dist/utils/{types.js → types.cjs} +2 -2
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +42 -0
- package/dist/utils/types.d.cts.map +1 -0
- package/dist/utils/types.d.mts +42 -0
- package/dist/utils/types.d.mts.map +1 -0
- package/dist/utils/types.mjs +26 -0
- package/dist/utils/types.mjs.map +1 -0
- package/dist/utils/{typing.js → typing.cjs} +2 -3
- package/dist/utils/{typing.js.map → typing.cjs.map} +1 -1
- package/dist/utils/{typing.d.ts → typing.d.cts} +1 -0
- package/dist/utils/typing.d.cts.map +1 -0
- package/dist/utils/typing.d.mts +33 -0
- package/dist/utils/typing.d.mts.map +1 -0
- package/dist/utils/typing.mjs +17 -0
- package/dist/utils/typing.mjs.map +1 -0
- package/package.json +20 -9
- package/dist/JsonRpcRequest.js.map +0 -1
- package/dist/KeyringClient.js.map +0 -1
- package/dist/KeyringSnapRpcClient.js.map +0 -1
- package/dist/api/account.js.map +0 -1
- package/dist/api/balance.js.map +0 -1
- package/dist/api/caip.js.map +0 -1
- package/dist/api/export.js.map +0 -1
- package/dist/api/index.d.ts +0 -7
- package/dist/api/index.js.map +0 -1
- package/dist/api/keyring.js.map +0 -1
- package/dist/api/request.js.map +0 -1
- package/dist/api/response.js.map +0 -1
- package/dist/btc/index.d.ts +0 -1
- package/dist/btc/index.js.map +0 -1
- package/dist/btc/types.js.map +0 -1
- package/dist/contexts.js.map +0 -1
- package/dist/eth/erc4337/index.d.ts +0 -1
- package/dist/eth/erc4337/index.js.map +0 -1
- package/dist/eth/erc4337/types.js.map +0 -1
- package/dist/eth/index.d.ts +0 -3
- package/dist/eth/index.js.map +0 -1
- package/dist/eth/types.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -28
- package/dist/index.js.map +0 -1
- package/dist/internal/api.js.map +0 -1
- package/dist/internal/eth/EthKeyring.js.map +0 -1
- package/dist/internal/eth/index.d.ts +0 -1
- package/dist/internal/eth/index.js.map +0 -1
- package/dist/internal/events.js.map +0 -1
- package/dist/internal/index.d.ts +0 -5
- package/dist/internal/index.js.map +0 -1
- package/dist/internal/rpc.js.map +0 -1
- package/dist/internal/types.js.map +0 -1
- package/dist/rpc-handler.js.map +0 -1
- package/dist/snap-utils.js.map +0 -1
- package/dist/sol/index.d.ts +0 -1
- package/dist/sol/index.js.map +0 -1
- package/dist/sol/types.js.map +0 -1
- package/dist/superstruct.js.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -19
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/types.d.ts +0 -17
- package/dist/utils/types.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@metamask/keyring-api",
|
3
|
-
"version": "
|
3
|
+
"version": "11.1.0",
|
4
4
|
"description": "MetaMask Keyring API",
|
5
5
|
"keywords": [
|
6
6
|
"metamask",
|
@@ -15,16 +15,27 @@
|
|
15
15
|
"type": "git",
|
16
16
|
"url": "https://github.com/MetaMask/keyring-api.git"
|
17
17
|
},
|
18
|
-
"
|
19
|
-
|
18
|
+
"exports": {
|
19
|
+
".": {
|
20
|
+
"import": {
|
21
|
+
"types": "./dist/index.d.mts",
|
22
|
+
"default": "./dist/index.mjs"
|
23
|
+
},
|
24
|
+
"require": {
|
25
|
+
"types": "./dist/index.d.cts",
|
26
|
+
"default": "./dist/index.cjs"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"main": "./dist/index.cjs",
|
31
|
+
"types": "./dist/index.d.cts",
|
20
32
|
"files": [
|
21
33
|
"dist/"
|
22
34
|
],
|
23
35
|
"scripts": {
|
24
|
-
"build": "
|
25
|
-
"build:clean": "
|
36
|
+
"build": "ts-bridge --project tsconfig.build.json --no-references",
|
37
|
+
"build:clean": "yarn build --clean",
|
26
38
|
"build:docs": "typedoc",
|
27
|
-
"build:force": "tsc --build tsconfig.build.json --force",
|
28
39
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/keyring-api",
|
29
40
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/keyring-api",
|
30
41
|
"publish:preview": "yarn npm publish --tag preview",
|
@@ -37,7 +48,7 @@
|
|
37
48
|
"dependencies": {
|
38
49
|
"@metamask/snaps-sdk": "^6.7.0",
|
39
50
|
"@metamask/superstruct": "^3.1.0",
|
40
|
-
"@metamask/utils": "^9.
|
51
|
+
"@metamask/utils": "^9.3.0",
|
41
52
|
"@types/uuid": "^9.0.8",
|
42
53
|
"bech32": "^2.0.0",
|
43
54
|
"uuid": "^9.0.1",
|
@@ -48,6 +59,7 @@
|
|
48
59
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
49
60
|
"@metamask/auto-changelog": "^3.4.4",
|
50
61
|
"@metamask/providers": "^18.1.0",
|
62
|
+
"@ts-bridge/cli": "^0.6.0",
|
51
63
|
"@types/jest": "^29.5.12",
|
52
64
|
"@types/node": "^20.12.12",
|
53
65
|
"@types/webextension-polyfill": "^0.12.1",
|
@@ -55,12 +67,11 @@
|
|
55
67
|
"depcheck": "^1.4.7",
|
56
68
|
"jest": "^29.5.0",
|
57
69
|
"jest-it-up": "^3.1.0",
|
58
|
-
"rimraf": "^5.0.10",
|
59
70
|
"ts-jest": "^29.0.5",
|
60
71
|
"ts-node": "^10.9.2",
|
61
72
|
"tsd": "^0.31.0",
|
62
73
|
"typedoc": "^0.25.13",
|
63
|
-
"typescript": "~5.
|
74
|
+
"typescript": "~5.6.3"
|
64
75
|
},
|
65
76
|
"peerDependencies": {
|
66
77
|
"@metamask/providers": "^18.1.0"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"JsonRpcRequest.js","sourceRoot":"","sources":["../src/JsonRpcRequest.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAE/B,2CAA6C;AAE7C,+CAAsD;AAEzC,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACvB,EAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,mBAAK,EAAC,CAAC,IAAA,mBAAK,EAAC,kBAAU,CAAC,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC,CAAC,CACzD;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n literal,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from './superstruct';\n\nexport const JsonRpcRequestStruct = object({\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n method: string(),\n params: exactOptional(\n union([array(JsonStruct), record(string(), JsonStruct)]),\n ),\n});\n\n/**\n * JSON-RPC request type.\n */\nexport type JsonRpcRequest = Infer<typeof JsonRpcRequestStruct>;\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"KeyringClient.js","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,+BAAkC;AAWlC,wCAcwB;AACxB,wCAAkD;AAElD,+CAA2C;AAM3C,MAAa,aAAa;IAGxB;;;;OAIG;IACH,YAAY,MAAc;;QAPjB,wCAAgB;QAQvB,uBAAA,IAAI,yBAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAgBD,KAAK,CAAC,YAAY;QAChB,OAAO,IAAA,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J,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,EAAU,EACV,OAA6B,EAAE;QAE/B,IAAA,oBAAM,EACJ,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,cAAc;YACvC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;SACrB,CAAC,EACF,kCAA4B,CAC7B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC5B,IAAA,oBAAM,EACJ,MAAM,uBAAA,IAAI,qDAAM,MAAV,IAAI,EAAO;YACf,MAAM,EAAE,sBAAgB,CAAC,aAAa;YACtC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,iCAA2B,CAC5B,CAAC;IACJ,CAAC;CACF;AAjKD,sCAiKC;;AArJC;;;;;GAKG;AACH,KAAK,8BAAO,OAA+C;IACzD,OAAO,uBAAA,IAAI,6BAAQ,CAAC,IAAI,CAAC;QACvB,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from './superstruct';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"KeyringSnapRpcClient.js","sourceRoot":"","sources":["../src/KeyringSnapRpcClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,mDAAgD;AAEhD;;;GAGG;AACH,MAAa,aAAa;IAKxB;;;;;OAKG;IACH,YAAY,MAAc,EAAE,QAAgC;QAVnD,wCAAgB;QAEhB,0CAAkC;QASzC,uBAAA,IAAI,yBAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,2BAAa,QAAQ,MAAA,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,OAAO,uBAAA,IAAI,+BAAU,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,sBAAsB;YAC9B,MAAM,EAAE;gBACN,MAAM,EAAE,uBAAA,IAAI,6BAAQ;gBACpB,OAAO;aACR;SACF,CAAkB,CAAC;IACtB,CAAC;CACF;AA/BD,sCA+BC;;AAED;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,6BAAa;IACrD;;;;;OAKG;IACH,YAAY,MAAc,EAAE,QAAgC;QAC1D,KAAK,CAAC,IAAI,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF;AAVD,oDAUC","sourcesContent":["import type { MetaMaskInpageProvider } from '@metamask/providers';\nimport type { Json } from '@metamask/utils';\n\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport type { Sender } from './KeyringClient';\nimport { KeyringClient } from './KeyringClient';\n\n/**\n * Implementation of the `Sender` interface that can be used to send requests\n * to a snap through the snap JSON-RPC API.\n */\nexport class SnapRpcSender implements Sender {\n readonly #origin: string;\n\n readonly #provider: MetaMaskInpageProvider;\n\n /**\n * Create a new instance of `SnapRpcSender`.\n *\n * @param origin - The caller's origin.\n * @param provider - The `MetaMaskInpageProvider` instance to use.\n */\n constructor(origin: string, provider: MetaMaskInpageProvider) {\n this.#origin = origin;\n this.#provider = provider;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param request - The JSON-RPC request to send to the snap.\n * @returns A promise that resolves to the response of the request.\n */\n async send(request: JsonRpcRequest): Promise<Json> {\n return this.#provider.request({\n method: 'wallet_invokeKeyring',\n params: {\n snapId: this.#origin,\n request,\n },\n }) as Promise<Json>;\n }\n}\n\n/**\n * A `KeyringClient` that allows the communication with a snap through the snap\n * JSON-RPC API.\n */\nexport class KeyringSnapRpcClient extends KeyringClient {\n /**\n * Create a new instance of `KeyringSnapRpcClient`.\n *\n * @param origin - Caller's origin.\n * @param provider - The `MetaMaskInpageProvider` instance to use.\n */\n constructor(origin: string, provider: MetaMaskInpageProvider) {\n super(new SnapRpcSender(origin, provider));\n }\n}\n"]}
|
package/dist/api/account.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,gDAAwC;AACxC,oCAAsC;AAEtC;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAWD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,kBAAU;IAEd;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,WAAW,EAAE;KAChC,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n `${SolAccountType.DataAccount}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
|
package/dist/api/balance.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,gDAAwC;AACxC,oCAA8C;AAEjC,QAAA,aAAa,GAAG,IAAA,oBAAM,EAAC;IAClC,MAAM,EAAE,0BAAkB;IAC1B,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nimport { object } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
|
package/dist/api/caip.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD,gDAA+C;AAE/C,MAAM,qBAAqB,GACzB,2JAA2J,CAAC;AAE9J,MAAM,mBAAmB,GACvB,6LAA6L,CAAC;AAEhM;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,2BAAa,EAC9C,eAAe,EACf,qBAAqB,CACtB,CAAC;AAGF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,2BAAa,EAC5C,aAAa,EACb,mBAAmB,CACpB,CAAC;AAGF;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,2BAAmB,CAAC,CAAC;AACxC,CAAC;AAFD,0CAEC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,yBAAiB,CAAC,CAAC;AACtC,CAAC;AAFD,sCAEC","sourcesContent":["import { is, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\nconst CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nconst CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct = definePattern(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n);\nexport type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = definePattern(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n);\nexport type CaipAssetId = Infer<typeof CaipAssetIdStruct>;\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // true\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false\n * ```\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // false\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true\n * ```\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n"]}
|
package/dist/api/export.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/api/export.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AACvD,2CAA6C;AAEhC,QAAA,wBAAwB,GAAG,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nexport const KeyringAccountDataStruct = record(string(), JsonStruct);\n\n/**\n * Response to a call to `exportAccount`.\n *\n * The exact response depends on the keyring implementation.\n */\nexport type KeyringAccountData = Infer<typeof KeyringAccountDataStruct>;\n"]}
|
package/dist/api/index.d.ts
DELETED
package/dist/api/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AAEzB,4CAA0B;AAC1B,6CAA2B","sourcesContent":["export * from './account';\nexport * from './balance';\nexport * from './caip';\nexport * from './export';\nexport type * from './keyring';\nexport * from './request';\nexport * from './response';\n"]}
|
package/dist/api/keyring.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"keyring.js","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { Balance } from './balance';\nimport type { CaipAssetType } from './caip';\nimport type { KeyringAccountData } from './export';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional).\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(options?: Record<string, Json>): Promise<KeyringAccount>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
|
package/dist/api/request.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,gDAAuD;AACvD,oCAAsC;AAEzB,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,kBAAU;IAEd;;OAEG;IACH,KAAK,EAAE,IAAA,oBAAM,GAAE;IAEf;;OAEG;IACH,OAAO,EAAE,kBAAU;IAEnB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC;QACd,MAAM,EAAE,IAAA,oBAAM,GAAE;QAChB,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,mBAAK,EAAC,CAAC,IAAA,mBAAK,EAAC,kBAAU,CAAC,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC,CAAC,CACzD;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, record, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\nexport const KeyringRequestStruct = object({\n /**\n * Keyring request ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Request's scope (CAIP-2 chain ID).\n */\n scope: string(),\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Inner request sent by the client application.\n */\n request: object({\n method: string(),\n params: exactOptional(\n union([array(JsonStruct), record(string(), JsonStruct)]),\n ),\n }),\n});\n\n/**\n * Keyring request.\n *\n * Represents a request made to the keyring for account-related operations.\n */\nexport type KeyringRequest = Infer<typeof KeyringRequestStruct>;\n"]}
|
package/dist/api/response.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAC/D,2CAA6C;AAE7C,gDAAuD;AAE1C,QAAA,qBAAqB,GAAG,IAAA,mBAAK,EAAC;IACzC,IAAA,oBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;QAEtB;;;;;;WAMG;QACH,QAAQ,EAAE,IAAA,2BAAa,EACrB,IAAA,oBAAM,EAAC;YACL,OAAO,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;YAChC,GAAG,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;SAC7B,CAAC,CACH;KACF,CAAC;IACF,IAAA,oBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;QAEvB;;WAEG;QACH,MAAM,EAAE,kBAAU;KACnB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from '../superstruct';\n\nexport const KeyringResponseStruct = union([\n object({\n /**\n * Pending flag.\n *\n * Setting the pending flag to true indicates that the request will be\n * handled asynchronously. The keyring must be called with `approveRequest`\n * or `rejectRequest` to resolve the request.\n */\n pending: literal(true),\n\n /**\n * Redirect URL.\n *\n * If present in the response, MetaMask will display a confirmation dialog\n * with a link to the redirect URL. The user can choose to follow the link\n * or cancel the request.\n */\n redirect: exactOptional(\n object({\n message: exactOptional(string()),\n url: exactOptional(string()),\n }),\n ),\n }),\n object({\n /**\n * Pending flag.\n *\n * Setting the pending flag to false indicates that the request will be\n * handled synchronously. The keyring must return the result of the\n * request execution.\n */\n pending: literal(false),\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n]);\n\n/**\n * Response to a call to `submitRequest`.\n *\n * Keyring implementations must return a response with `pending: true` if the\n * request will be handled asynchronously. Otherwise, the response must contain\n * the result of the request and `pending: false`.\n *\n * In the asynchronous case, the keyring can return a redirect URL and message\n * to be shown to the user. The user can choose to follow the link or cancel\n * the request. The main use case for this is to redirect the user to the snap\n * dapp to review the request.\n */\nexport type KeyringResponse = Infer<typeof KeyringResponseStruct>;\n"]}
|
package/dist/btc/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './types';
|
package/dist/btc/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from './types';\n"]}
|
package/dist/btc/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AACA,uDAA8E;AAC9E,mCAAgC;AAEhC,gCAA8D;AAC9D,gDAAwC;AAE3B,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAC1C,IAAA,oBAAM,GAAE,EACR,wBAAwB,EACxB,CAAC,OAAe,EAAE,EAAE;IAClB,IAAI,CAAC;QACH,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAEY,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,8BAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC;IAEzC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string, array, enums, refine, literal } from '@metamask/superstruct';\nimport { bech32 } from 'bech32';\n\nimport { KeyringAccountStruct, BtcAccountType } from '../api';\nimport { object } from '../superstruct';\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n try {\n bech32.decode(address);\n } catch (error) {\n return new Error(\n `Could not decode P2WPKH address: ${(error as Error).message}`,\n );\n }\n return true;\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n // General transaction methods\n SendBitcoin = 'sendBitcoin',\n}\n\nexport const BtcP2wpkhAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${BtcMethod.SendBitcoin}`])),\n});\n\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\n"]}
|
package/dist/contexts.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"contexts.js","sourceRoot":"","sources":["../src/contexts.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Context used by a Keyring implementation.\n */\nexport type KeyringExecutionContext = {\n /** The chain ID. */\n chainId: string;\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './types';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/eth/erc4337/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from './types';\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":";;;AAEA,mDAA0D;AAC1D,uCAAwC;AACxC,oCAA8E;AAE9E;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C,MAAM,EAAE,wBAAgB;IACxB,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,kBAAkB,EAAE,wBAAgB;IACpC,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,gBAAgB,EAAE,sBAAc;IAChC,SAAS,EAAE,sBAAc;CAC1B,CAAC,CAAC;AAIH;;;GAGG;AACU,QAAA,wBAAwB,GAAG,IAAA,oBAAM,EAAC;IAC7C;;OAEG;IACH,EAAE,EAAE,wBAAgB;IAEpB;;OAEG;IACH,KAAK,EAAE,wBAAgB;IAEvB;;OAEG;IACH,IAAI,EAAE,sBAAc;CACrB,CAAC,CAAC;AAIU,QAAA,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IAC/C,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,SAAS,EAAE,IAAA,2BAAa,EACtB,IAAA,oBAAM,EAAC;QACL,YAAY,EAAE,wBAAgB;QAC9B,oBAAoB,EAAE,wBAAgB;QACtC,kBAAkB,EAAE,wBAAgB;KACrC,CAAC,CACH;IACD,qBAAqB,EAAE,sBAAc;IACrC,cAAc,EAAE,sBAAc;IAC9B,UAAU,EAAE,iBAAS;CACtB,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,oBAAM,EAAC;IAChD,gBAAgB,EAAE,sBAAc;IAChC,YAAY,EAAE,IAAA,2BAAa,EAAC,wBAAgB,CAAC;IAC7C,oBAAoB,EAAE,IAAA,2BAAa,EAAC,wBAAgB,CAAC;IACrD,kBAAkB,EAAE,IAAA,2BAAa,EAAC,wBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { type Infer } from '@metamask/superstruct';\n\nimport { exactOptional, object } from '../../superstruct';\nimport { UrlStruct } from '../../utils';\nimport { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';\n\n/**\n * Struct of a UserOperation as defined by ERC-4337.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4337#definitions\n */\nexport const EthUserOperationStruct = object({\n sender: EthAddressStruct,\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n maxFeePerGas: EthUint256Struct,\n maxPriorityFeePerGas: EthUint256Struct,\n paymasterAndData: EthBytesStruct,\n signature: EthBytesStruct,\n});\n\nexport type EthUserOperation = Infer<typeof EthUserOperationStruct>;\n\n/**\n * Struct containing the most basic transaction information required to\n * construct a UserOperation.\n */\nexport const EthBaseTransactionStruct = object({\n /**\n * Address of the transaction recipient.\n */\n to: EthAddressStruct,\n\n /**\n * Amount of wei to transfer to the recipient.\n */\n value: EthUint256Struct,\n\n /**\n * Data to pass to the recipient.\n */\n data: EthBytesStruct,\n});\n\nexport type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;\n\nexport const EthBaseUserOperationStruct = object({\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n gasLimits: exactOptional(\n object({\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n }),\n ),\n dummyPaymasterAndData: EthBytesStruct,\n dummySignature: EthBytesStruct,\n bundlerUrl: UrlStruct,\n});\n\nexport type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;\n\nexport const EthUserOperationPatchStruct = object({\n paymasterAndData: EthBytesStruct,\n callGasLimit: exactOptional(EthUint256Struct),\n verificationGasLimit: exactOptional(EthUint256Struct),\n preVerificationGas: exactOptional(EthUint256Struct),\n});\n\nexport type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;\n"]}
|
package/dist/eth/index.d.ts
DELETED
package/dist/eth/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB","sourcesContent":["export * from './erc4337';\nexport * from './types';\nexport * from './utils';\n"]}
|
package/dist/eth/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AACA,uDAA8D;AAE9D,gCAA8D;AAC9D,gDAAuD;AAE1C,QAAA,cAAc,GAAG,IAAA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,CAAC,OAAO,EAAE,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\nimport { EthAccountType, KeyringAccountStruct } from '../api';\nimport { object, definePattern } from '../superstruct';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]}
|
package/dist/events.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB,iBAAiB;IACjB,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IAExC,iBAAiB;IACjB,0DAA0C,CAAA;IAC1C,0DAA0C,CAAA;AAC5C,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB","sourcesContent":["/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n}\n"]}
|
package/dist/index.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
export * from './api';
|
2
|
-
export * from './btc';
|
3
|
-
export type * from './contexts';
|
4
|
-
export * from './eth';
|
5
|
-
export * from './sol';
|
6
|
-
export * from './events';
|
7
|
-
export * from './internal';
|
8
|
-
export * from './KeyringClient';
|
9
|
-
export * from './KeyringSnapRpcClient';
|
10
|
-
export * from './rpc-handler';
|
11
|
-
export * from './snap-utils';
|
12
|
-
export * from './superstruct';
|
package/dist/index.js
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./api"), exports);
|
18
|
-
__exportStar(require("./btc"), exports);
|
19
|
-
__exportStar(require("./eth"), exports);
|
20
|
-
__exportStar(require("./sol"), exports);
|
21
|
-
__exportStar(require("./events"), exports);
|
22
|
-
__exportStar(require("./internal"), exports);
|
23
|
-
__exportStar(require("./KeyringClient"), exports);
|
24
|
-
__exportStar(require("./KeyringSnapRpcClient"), exports);
|
25
|
-
__exportStar(require("./rpc-handler"), exports);
|
26
|
-
__exportStar(require("./snap-utils"), exports);
|
27
|
-
__exportStar(require("./superstruct"), exports);
|
28
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,wCAAsB;AAEtB,wCAAsB;AACtB,wCAAsB;AACtB,2CAAyB;AACzB,6CAA2B;AAC3B,kDAAgC;AAChC,yDAAuC;AACvC,gDAA8B;AAC9B,+CAA6B;AAC7B,gDAA8B","sourcesContent":["export * from './api';\nexport * from './btc';\nexport type * from './contexts';\nexport * from './eth';\nexport * from './sol';\nexport * from './events';\nexport * from './internal';\nexport * from './KeyringClient';\nexport * from './KeyringSnapRpcClient';\nexport * from './rpc-handler';\nexport * from './snap-utils';\nexport * from './superstruct';\n"]}
|
package/dist/internal/api.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/internal/api.ts"],"names":[],"mappings":";;;AACA,uDAO+B;AAC/B,2CAA6C;AAE7C,+BAAyC;AACzC,gCAOgB;AAChB,gDAAwC;AACxC,oCAAsC;AAEtC,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACvB,EAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,+EAA+E;AAC/E,gBAAgB;AAEH,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,sBAAsB,CAAC;CACxC,CAAC,CAAC;AAIU,QAAA,0BAA0B,GAAG,IAAA,mBAAK,EAAC,0BAAoB,CAAC,CAAC;AAItE,+EAA+E;AAC/E,cAAc;AAED,QAAA,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IAC5C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,q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AAM,EAAE,IAAA,qBAAO,EAAC,oBAAoB,CAAC;IACrC,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,kBAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,wBAAwB,GAAG,0BAAoB,CAAC;AAI7D,+EAA+E;AAC/E,iBAAiB;AAEJ,QAAA,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,0BAAoB;CAC7B,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,2BAAqB,CAAC;AAIjE,+EAA+E;AAC/E,kBAAkB;AAEL,QAAA,2BAA2B,GAAG,IAAA,oBAAM,EAAC;IAChD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,wBAAwB,CAAC;IACzC,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,kBAAU;QACd,IAAI,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;KACnC,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,4BAA4B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC;AAI1D,+EAA+E;AAC/E,iBAAiB;AAEJ,QAAA,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,kBAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n literal,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { KeyringRpcMethod } from './rpc';\nimport {\n BalanceStruct,\n CaipAssetTypeStruct,\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n} from '../api';\nimport { object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n};\n\n// ----------------------------------------------------------------------------\n// List accounts\n\nexport const ListAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccounts'),\n});\n\nexport type ListAccountsRequest = Infer<typeof ListAccountsRequestStruct>;\n\nexport const ListAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type ListAccountsResponse = Infer<typeof ListAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account\n\nexport const GetAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetAccountRequest = Infer<typeof GetAccountRequestStruct>;\n\nexport const GetAccountResponseStruct = KeyringAccountStruct;\n\nexport type GetAccountResponse = Infer<typeof GetAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create account\n\nexport const CreateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccount'),\n params: object({\n options: record(string(), JsonStruct),\n }),\n});\n\nexport type CreateAccountRequest = Infer<typeof CreateAccountRequestStruct>;\n\nexport const CreateAccountResponseStruct = KeyringAccountStruct;\n\nexport type CreateAccountResponse = Infer<typeof CreateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account balances\n\nexport const GetAccountBalancesRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcMethod.GetAccountBalances}`),\n params: object({\n id: UuidStruct,\n assets: array(CaipAssetTypeStruct),\n }),\n});\n\nexport type GetAccountBalancesRequest = Infer<\n typeof GetAccountBalancesRequestStruct\n>;\n\nexport const GetAccountBalancesResponseStruct = record(\n CaipAssetTypeStruct,\n BalanceStruct,\n);\n\nexport type GetAccountBalancesResponse = Infer<\n typeof GetAccountBalancesResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Filter account chains\n\nexport const FilterAccountChainsStruct = object({\n ...CommonHeader,\n method: literal('keyring_filterAccountChains'),\n params: object({\n id: UuidStruct,\n chains: array(string()),\n }),\n});\n\nexport type FilterAccountChainsRequest = Infer<\n typeof FilterAccountChainsStruct\n>;\n\nexport const FilterAccountChainsResponseStruct = array(string());\n\nexport type FilterAccountChainsResponse = Infer<\n typeof FilterAccountChainsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Update account\n\nexport const UpdateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_updateAccount'),\n params: object({\n account: KeyringAccountStruct,\n }),\n});\n\nexport type UpdateAccountRequest = Infer<typeof UpdateAccountRequestStruct>;\n\nexport const UpdateAccountResponseStruct = literal(null);\n\nexport type UpdateAccountResponse = Infer<typeof UpdateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Delete account\n\nexport const DeleteAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_deleteAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type DeleteAccountRequest = Infer<typeof DeleteAccountRequestStruct>;\n\nexport const DeleteAccountResponseStruct = literal(null);\n\nexport type DeleteAccountResponse = Infer<typeof DeleteAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Export account\n\nexport const ExportAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_exportAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ExportAccountRequest = Infer<typeof ExportAccountRequestStruct>;\n\nexport const ExportAccountResponseStruct = KeyringAccountDataStruct;\n\nexport type ExportAccountResponse = Infer<typeof ExportAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// List requests\n\nexport const ListRequestsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listRequests'),\n});\n\nexport type ListRequestsRequest = Infer<typeof ListRequestsRequestStruct>;\n\nexport const ListRequestsResponseStruct = array(KeyringRequestStruct);\n\nexport type ListRequestsResponse = Infer<typeof ListRequestsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get request\n\nexport const GetRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetRequestRequest = Infer<typeof GetRequestRequestStruct>;\n\nexport const GetRequestResponseStruct = KeyringRequestStruct;\n\nexport type GetRequestResponse = Infer<typeof GetRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Submit request\n\nexport const SubmitRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_submitRequest'),\n params: KeyringRequestStruct,\n});\n\nexport type SubmitRequestRequest = Infer<typeof SubmitRequestRequestStruct>;\n\nexport const SubmitRequestResponseStruct = KeyringResponseStruct;\n\nexport type SubmitRequestResponse = Infer<typeof SubmitRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Approve request\n\nexport const ApproveRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_approveRequest'),\n params: object({\n id: UuidStruct,\n data: record(string(), JsonStruct),\n }),\n});\n\nexport type ApproveRequestRequest = Infer<typeof ApproveRequestRequestStruct>;\n\nexport const ApproveRequestResponseStruct = literal(null);\n\nexport type ApproveRequestResponse = Infer<typeof ApproveRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Reject request\n\nexport const RejectRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_rejectRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type RejectRequestRequest = Infer<typeof RejectRequestRequestStruct>;\n\nexport const RejectRequestResponseStruct = literal(null);\n\nexport type RejectRequestResponse = Infer<typeof RejectRequestResponseStruct>;\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"EthKeyring.js","sourceRoot":"","sources":["../../../src/internal/eth/EthKeyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json, Keyring } from '@metamask/utils';\n\nimport type { KeyringExecutionContext } from '../../contexts';\nimport type {\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n} from '../../eth';\n\nexport type EthKeyring<State extends Json> = Keyring<State> & {\n /**\n * Convert a base transaction to a base UserOperation.\n *\n * @param address - Address of the sender.\n * @param transactions - Base transactions to include in the UserOperation.\n * @param context - Keyring execution context.\n * @returns A pseudo-UserOperation that can be used to construct a real.\n */\n prepareUserOperation?(\n address: string,\n transactions: EthBaseTransaction[],\n context: KeyringExecutionContext,\n ): Promise<EthBaseUserOperation>;\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to patch.\n * @param context - Keyring execution context.\n * @returns A patch to apply to the UserOperation.\n */\n patchUserOperation?(\n address: string,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<EthUserOperationPatch>;\n\n /**\n * Signs an UserOperation.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to sign.\n * @param context - Keyring execution context.\n * @returns The signature of the UserOperation.\n */\n signUserOperation?(\n address: string,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<string>;\n};\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
export type * from './EthKeyring';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/eth/index.ts"],"names":[],"mappings":"","sourcesContent":["export type * from './EthKeyring';\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/internal/events.ts"],"names":[],"mappings":";;;AAAA,uDAAiE;AACjE,2CAA6C;AAE7C,gCAA8C;AAC9C,sCAAyC;AACzC,gDAAuD;AACvD,oCAAsC;AAEzB,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,qBAAY,CA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{ boolean, literal, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { KeyringAccountStruct } from '../api';\nimport { KeyringEvent } from '../events';\nimport { exactOptional, object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n }),\n});\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\n"]}
|
package/dist/internal/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AAEtB,2CAAyB;AACzB,wCAAsB;AACtB,0CAAwB","sourcesContent":["export * from './api';\nexport type * from './eth';\nexport * from './events';\nexport * from './rpc';\nexport * from './types';\n"]}
|
package/dist/internal/rpc.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/internal/rpc.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBAcX;AAdD,WAAY,gBAAgB;IAC1B,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,2DAAuC,CAAA;IACvC,qEAAiD,CAAA;IACjD,uEAAmD,CAAA;IACnD,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IACvC,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,2DAAuC,CAAA;IACvC,6DAAyC,CAAA;IACzC,2DAAuC,CAAA;AACzC,CAAC,EAdW,gBAAgB,gCAAhB,gBAAgB,QAc3B;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAA0B,CAAC,CAAC;AAC9E,CAAC;AAFD,gDAEC","sourcesContent":["/**\n * Keyring RPC methods used by the API.\n */\nexport enum KeyringRpcMethod {\n ListAccounts = 'keyring_listAccounts',\n GetAccount = 'keyring_getAccount',\n CreateAccount = 'keyring_createAccount',\n GetAccountBalances = 'keyring_getAccountBalances',\n FilterAccountChains = 'keyring_filterAccountChains',\n UpdateAccount = 'keyring_updateAccount',\n DeleteAccount = 'keyring_deleteAccount',\n ExportAccount = 'keyring_exportAccount',\n ListRequests = 'keyring_listRequests',\n GetRequest = 'keyring_getRequest',\n SubmitRequest = 'keyring_submitRequest',\n ApproveRequest = 'keyring_approveRequest',\n RejectRequest = 'keyring_rejectRequest',\n}\n\n/**\n * Check if a method is a keyring RPC method.\n *\n * @param method - Method to check.\n * @returns Whether the method is a keyring RPC method.\n */\nexport function isKeyringRpcMethod(method: string): boolean {\n return Object.values(KeyringRpcMethod).includes(method as KeyringRpcMethod);\n}\n"]}
|
@@ -1 +0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AA6B,CAAC,MAAM;CACxC,CAAC,CAAC;AAcU,QAAA,sBAAsB,GAM/B;IACF,CAAC,GAAG,oBAAc,CAAC,GAAG,EAAE,CAAC,EAAE,mCAA2B;IACtD,CAAC,GAAG,oBAAc,CAAC,OAAO,EAAE,CAAC,EAAE,uCAA+B;IAC9D,CAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC,EAAE,sCAA8B;IAC5D,CAAC,GAAG,oBAAc,CAAC,WAAW,EAAE,CAAC,EAAE,oCAA4B;CAChE,CAAC;AAQW,QAAA,qBAAqB,GAAG,IAAA,oBAAM,EAAC;IAC1C,GAAG,0BAAoB,CAAC,MAAM;IAC9B,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer, Struct } from '@metamask/superstruct';\nimport { boolean, string, number } from '@metamask/superstruct';\n\nimport {\n BtcAccountType,\n EthAccountType,\n KeyringAccountStruct,\n SolAccountType,\n} from '../api';\nimport { BtcP2wpkhAccountStruct } from '../btc/types';\nimport { EthEoaAccountStruct, EthErc4337AccountStruct } from '../eth/types';\nimport { SolDataAccountStruct } from '../sol/types';\nimport { exactOptional, object } from '../superstruct';\n\nexport type InternalAccountType =\n | EthAccountType\n | BtcAccountType\n | SolAccountType;\n\nexport const InternalAccountMetadataStruct = object({\n metadata: object({\n name: string(),\n nameLastUpdatedAt: exactOptional(number()),\n snap: exactOptional(\n object({\n id: string(),\n enabled: boolean(),\n name: string(),\n }),\n ),\n lastSelected: exactOptional(number()),\n importTime: number(),\n keyring: object({\n type: string(),\n }),\n }),\n});\n\nexport const InternalEthEoaAccountStruct = object({\n ...EthEoaAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport const InternalEthErc4337AccountStruct = object({\n ...EthErc4337AccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport const InternalBtcP2wpkhAccountStruct = object({\n ...BtcP2wpkhAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport const InternalSolDataAccountStruct = object({\n ...SolDataAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;\n\nexport type InternalEthErc4337Account = Infer<\n typeof InternalEthErc4337AccountStruct\n>;\n\nexport type InternalBtcP2wpkhAccount = Infer<\n typeof InternalBtcP2wpkhAccountStruct\n>;\n\nexport type InternalSolDataAccount = Infer<typeof InternalSolDataAccountStruct>;\n\nexport const InternalAccountStructs: Record<\n string,\n | Struct<InternalEthEoaAccount>\n | Struct<InternalEthErc4337Account>\n | Struct<InternalBtcP2wpkhAccount>\n | Struct<InternalSolDataAccount>\n> = {\n [`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct,\n [`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct,\n [`${BtcAccountType.P2wpkh}`]: InternalBtcP2wpkhAccountStruct,\n [`${SolAccountType.DataAccount}`]: InternalSolDataAccountStruct,\n};\n\nexport type InternalAccountTypes =\n | InternalEthEoaAccount\n | InternalEthErc4337Account\n | InternalBtcP2wpkhAccount\n | InternalSolDataAccount;\n\nexport const InternalAccountStruct = object({\n ...KeyringAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\n/**\n * Internal account representation.\n *\n * This type is used internally by MetaMask to add additional metadata to the\n * account object. It's should not be used by external applications.\n */\nexport type InternalAccount = Infer<typeof InternalAccountStruct>;\n"]}
|
package/dist/rpc-handler.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"rpc-handler.js","sourceRoot":"","sources":["../src/rpc-handler.ts"],"names":[],"mappings":";;;AAAA,uDAA+C;AAI/C,wCAcwB;AACxB,wCAAkD;AAElD,qDAAwD;AAExD;;GAEG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,MAAc;QACxB,KAAK,CAAC,yBAAyB,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF;AAJD,0DAIC;AA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C,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,oBAAoB,CACxC,OAAgB,EAChB,OAAuB;IAEvB,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;YACzD,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,8DAA8D,CAAC;QAErE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAdD,oDAcC","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\n\nimport type { Keyring } from './api';\nimport {\n GetAccountRequestStruct,\n CreateAccountRequestStruct,\n ApproveRequestRequestStruct,\n DeleteAccountRequestStruct,\n ExportAccountRequestStruct,\n GetRequestRequestStruct,\n RejectRequestRequestStruct,\n SubmitRequestRequestStruct,\n UpdateAccountRequestStruct,\n FilterAccountChainsStruct,\n ListAccountsRequestStruct,\n ListRequestsRequestStruct,\n GetAccountBalancesRequestStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { JsonRpcRequestStruct } from './JsonRpcRequest';\n\n/**\n * Error thrown when a keyring JSON-RPC method is not supported.\n */\nexport class MethodNotSupportedError extends Error {\n constructor(method: string) {\n super(`Method not supported: ${method}`);\n }\n}\n\n/**\n * Inner function that dispatches JSON-RPC request to the associated Keyring\n * methods.\n *\n * @param keyring - Keyring instance.\n * @param request - Keyring JSON-RPC request.\n * @returns A promise that resolves to the keyring response.\n */\nasync function dispatchRequest(\n keyring: Keyring,\n request: JsonRpcRequest,\n): Promise<Json | void> {\n // We first have to make sure that the request is a valid JSON-RPC request so\n // we can check its method name.\n assert(request, JsonRpcRequestStruct);\n\n switch (request.method) {\n case `${KeyringRpcMethod.ListAccounts}`: {\n assert(request, ListAccountsRequestStruct);\n return keyring.listAccounts();\n }\n\n case `${KeyringRpcMethod.GetAccount}`: {\n assert(request, GetAccountRequestStruct);\n return keyring.getAccount(request.params.id);\n }\n\n case `${KeyringRpcMethod.CreateAccount}`: {\n assert(request, CreateAccountRequestStruct);\n return keyring.createAccount(request.params.options);\n }\n\n case `${KeyringRpcMethod.GetAccountBalances}`: {\n if (keyring.getAccountBalances === undefined) {\n throw new MethodNotSupportedError(request.method);\n }\n assert(request, GetAccountBalancesRequestStruct);\n return keyring.getAccountBalances(\n request.params.id,\n request.params.assets,\n );\n }\n\n case `${KeyringRpcMethod.FilterAccountChains}`: {\n assert(request, FilterAccountChainsStruct);\n return keyring.filterAccountChains(\n request.params.id,\n request.params.chains,\n );\n }\n\n case `${KeyringRpcMethod.UpdateAccount}`: {\n assert(request, UpdateAccountRequestStruct);\n return keyring.updateAccount(request.params.account);\n }\n\n case `${KeyringRpcMethod.DeleteAccount}`: {\n assert(request, DeleteAccountRequestStruct);\n return keyring.deleteAccount(request.params.id);\n }\n\n case `${KeyringRpcMethod.ExportAccount}`: {\n if (keyring.exportAccount === undefined) {\n throw new MethodNotSupportedError(request.method);\n }\n assert(request, ExportAccountRequestStruct);\n return keyring.exportAccount(request.params.id);\n }\n\n case `${KeyringRpcMethod.ListRequests}`: {\n if (keyring.listRequests === undefined) {\n throw new MethodNotSupportedError(request.method);\n }\n assert(request, ListRequestsRequestStruct);\n return keyring.listRequests();\n }\n\n case `${KeyringRpcMethod.GetRequest}`: {\n if (keyring.getRequest === undefined) {\n throw new MethodNotSupportedError(request.method);\n }\n assert(request, GetRequestRequestStruct);\n return keyring.getRequest(request.params.id);\n }\n\n case `${KeyringRpcMethod.SubmitRequest}`: {\n assert(request, SubmitRequestRequestStruct);\n return keyring.submitRequest(request.params);\n }\n\n case `${KeyringRpcMethod.ApproveRequest}`: {\n if (keyring.approveRequest === undefined) {\n throw new MethodNotSupportedError(request.method);\n }\n assert(request, ApproveRequestRequestStruct);\n return keyring.approveRequest(request.params.id, request.params.data);\n }\n\n case `${KeyringRpcMethod.RejectRequest}`: {\n if (keyring.rejectRequest === undefined) {\n throw new MethodNotSupportedError(request.method);\n }\n assert(request, RejectRequestRequestStruct);\n return keyring.rejectRequest(request.params.id);\n }\n\n default: {\n throw new MethodNotSupportedError(request.method);\n }\n }\n}\n\n/**\n * Handles a keyring JSON-RPC request.\n *\n * This function is meant to be used as a handler for Keyring JSON-RPC requests\n * in an Accounts Snap.\n *\n * @param keyring - Keyring instance.\n * @param request - Keyring JSON-RPC request.\n * @returns A promise that resolves to the keyring response.\n * @example\n * ```ts\n * export const onKeyringRequest: OnKeyringRequestHandler = async ({\n * origin,\n * request,\n * }) => {\n * return await handleKeyringRequest(keyring, request);\n * };\n * ```\n */\nexport async function handleKeyringRequest(\n keyring: Keyring,\n request: JsonRpcRequest,\n): Promise<Json | void> {\n try {\n return await dispatchRequest(keyring, request);\n } catch (error) {\n const message =\n error instanceof Error && typeof error.message === 'string'\n ? error.message\n : 'An unknown error occurred while handling the keyring request';\n\n throw new Error(message);\n }\n}\n"]}
|
package/dist/snap-utils.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"snap-utils.js","sourceRoot":"","sources":["../src/snap-utils.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CACxC,IAAmB,EACnB,KAAmB,EACnB,IAA0B;IAE1B,MAAM,IAAI,CAAC,OAAO,CAAC;QACjB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE;SACpB;KACF,CAAC,CAAC;AACL,CAAC;AAZD,oDAYC","sourcesContent":["import type { SnapsProvider } from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringEvent } from './events';\n\n/**\n * Emit a keyring event from a snap.\n *\n * @param snap - The global snap object.\n * @param event - The event name.\n * @param data - The event data.\n */\nexport async function emitSnapKeyringEvent(\n snap: SnapsProvider,\n event: KeyringEvent,\n data: Record<string, Json>,\n): Promise<void> {\n await snap.request({\n method: 'snap_manageAccounts',\n params: {\n method: event,\n params: { ...data },\n },\n });\n}\n"]}
|
package/dist/sol/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './types';
|
package/dist/sol/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from './types';\n"]}
|
package/dist/sol/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":";;;AACA,uDAA8D;AAE9D,gCAA8D;AAC9D,gDAAuD;AAEvD;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,IAAA,2BAAa,EAC3C,YAAY,EACZ,iCAAiC,CAClC,CAAC;AAEF;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,oEAAuD,CAAA;AACzD,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAEY,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,WAAW,EAAE,CAAC;IAE9C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;CAClE,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\nimport { KeyringAccountStruct, SolAccountType } from '../api';\nimport { object, definePattern } from '../superstruct';\n\n/**\n * Solana addresses are represented in the format of a 256-bit ed25519 public key and\n * are encoded using base58.\n * They are usually 32 to 44 characters long.\n */\nexport const SolAddressStruct = definePattern(\n 'SolAddress',\n /^[1-9A-HJ-NP-Za-km-z]{32,44}$/iu,\n);\n\n/**\n * Supported Solana methods.\n */\nexport enum SolMethod {\n // General transaction methods\n SendAndConfirmTransaction = 'sendAndConfirmTransaction',\n}\n\nexport const SolDataAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: SolAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${SolAccountType.DataAccount}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${SolMethod.SendAndConfirmTransaction}`])),\n});\n\nexport type SolDataAccount = Infer<typeof SolDataAccountStruct>;\n"]}
|
package/dist/superstruct.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"superstruct.js","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":";;;AAAA,uDAK+B;AAqD/B;;;;;;GAMG;AACH,SAAgB,MAAM,CACpB,MAAc;IAEd,OAAO,IAAA,oBAAQ,EAAC,MAAM,CAAQ,CAAC;AACjC,CAAC;AAJD,wBAIC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,QAAQ,GAAW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAA4B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,QAAQ,IAAI,MAAM,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,MAA4B;IAE5B,OAAO,IAAI,oBAAM,CAAC;QAChB,GAAG,MAAM;QAET,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACxB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAEnD,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACtB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,GAAG,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC;AAZD,sCAYC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,IAAY,EACZ,OAAe;IAEf,OAAO,IAAA,oBAAM,EACX,IAAI,EACJ,CAAC,KAAc,EAAW,EAAE,CAC1B,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CACnD,CAAC;AACJ,CAAC;AATD,sCASC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CACxB,KAAc,EACd,MAA4B,EAC5B,OAAgB;IAEhB,IAAA,oBAAM,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,gCAOC","sourcesContent":["import {\n Struct,\n assert,\n define,\n object as stObject,\n} from '@metamask/superstruct';\nimport type {\n Infer,\n Context,\n ObjectSchema,\n OmitBy,\n Optionalize,\n PickBy,\n Simplify,\n} from '@metamask/superstruct';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare const ExactOptionalSymbol: unique symbol;\n\nexport type ExactOptionalTag = {\n type: typeof ExactOptionalSymbol;\n};\n\n/**\n * Exclude type `Type` from the properties of `Obj`.\n *\n * ```ts\n * type Foo = { a: string | null; b: number };\n * type Bar = ExcludeType<Foo, null>;\n * // Bar = { a: string, b: number }\n * ```\n */\nexport type ExcludeType<Obj, Type> = {\n [K in keyof Obj]: Exclude<Obj[K], Type>;\n};\n\n/**\n * Make optional all properties that have the `ExactOptionalTag` type.\n *\n * ```ts\n * type Foo = { a: string | ExactOptionalTag; b: number};\n * type Bar = ExactOptionalize<Foo>;\n * // Bar = { a?: string; b: number}\n * ```\n */\nexport type ExactOptionalize<Schema extends object> = OmitBy<\n Schema,\n ExactOptionalTag\n> &\n Partial<ExcludeType<PickBy<Schema, ExactOptionalTag>, ExactOptionalTag>>;\n\n/**\n * Infer a type from an superstruct object schema.\n */\nexport type ObjectType<Schema extends ObjectSchema> = Simplify<\n ExactOptionalize<Optionalize<{ [K in keyof Schema]: Infer<Schema[K]> }>>\n>;\n\n/**\n * Change the return type of a superstruct object struct to support exact\n * optional properties.\n *\n * @param schema - The object schema.\n * @returns A struct representing an object with a known set of properties.\n */\nexport function object<Schema extends ObjectSchema>(\n schema: Schema,\n): Struct<ObjectType<Schema>, Schema> {\n return stObject(schema) as any;\n}\n\n/**\n * Check if the current property is present in its parent object.\n *\n * @param ctx - The context to check.\n * @returns `true` if the property is present, `false` otherwise.\n */\nfunction hasOptional(ctx: Context): boolean {\n const property: string = ctx.path[ctx.path.length - 1];\n const parent: Record<string, unknown> = ctx.branch[ctx.branch.length - 2];\n\n return property in parent;\n}\n\n/**\n * Augment a struct to allow exact-optional values. Exact-optional values can\n * be omitted but cannot be `undefined`.\n *\n * ```ts\n * const foo = object({ bar: exactOptional(string()) });\n * type Foo = Infer<typeof foo>;\n * // Foo = { bar?: string }\n * ```\n *\n * @param struct - The struct to augment.\n * @returns The augmented struct.\n */\nexport function exactOptional<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Type | ExactOptionalTag, Schema> {\n return new Struct({\n ...struct,\n\n validator: (value, ctx) =>\n !hasOptional(ctx) || struct.validator(value, ctx),\n\n refiner: (value, ctx) =>\n !hasOptional(ctx) || struct.refiner(value as Type, ctx),\n });\n}\n\n/**\n * Defines a new string-struct matching a regular expression.\n *\n * Example:\n *\n * ```ts\n * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);\n * ```\n *\n * @param name - Type name.\n * @param pattern - Regular expression to match.\n * @returns A new string-struct that matches the given pattern.\n */\nexport function definePattern(\n name: string,\n pattern: RegExp,\n): Struct<string, null> {\n return define<string>(\n name,\n (value: unknown): boolean =>\n typeof value === 'string' && pattern.test(value),\n );\n}\n\n/**\n * Assert that a value is valid according to a struct.\n *\n * It is similar to superstruct's mask function, but it does not ignore extra\n * properties.\n *\n * @param value - Value to check.\n * @param struct - Struct to validate the value against.\n * @param message - Error message to throw if the value is not valid.\n * @returns The value if it is valid.\n */\nexport function strictMask<Type, Schema>(\n value: unknown,\n struct: Struct<Type, Schema>,\n message?: string,\n): Type {\n assert(value, struct, message);\n return value;\n}\n"]}
|
package/dist/utils/index.d.ts
DELETED
package/dist/utils/index.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./types"), exports);
|
18
|
-
__exportStar(require("./typing"), exports);
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB","sourcesContent":["export * from './types';\nexport * from './typing';\n"]}
|
package/dist/utils/types.d.ts
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import { type Infer } from '@metamask/superstruct';
|
2
|
-
/**
|
3
|
-
* UUIDv4 struct.
|
4
|
-
*/
|
5
|
-
export declare const UuidStruct: import("@metamask/superstruct").Struct<string, null>;
|
6
|
-
/**
|
7
|
-
* Validates if a given value is a valid URL.
|
8
|
-
*
|
9
|
-
* @param value - The value to be validated.
|
10
|
-
* @returns A boolean indicating if the value is a valid URL.
|
11
|
-
*/
|
12
|
-
export declare const UrlStruct: import("@metamask/superstruct").Struct<string, null>;
|
13
|
-
/**
|
14
|
-
* A string which contains a positive float number.
|
15
|
-
*/
|
16
|
-
export declare const StringNumberStruct: import("@metamask/superstruct").Struct<string, null>;
|
17
|
-
export type StringNumber = Infer<typeof StringNumberStruct>;
|
package/dist/utils/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAE3D,gDAA+C;AAE/C;;GAEG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAa,EACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACU,QAAA,SAAS,GAAG,IAAA,oBAAM,EAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAA,2BAAa,EAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n"]}
|