@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
@@ -0,0 +1,70 @@
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
|
+
/**
|
3
|
+
* Supported Ethereum account types.
|
4
|
+
*/
|
5
|
+
export declare enum EthAccountType {
|
6
|
+
Eoa = "eip155:eoa",
|
7
|
+
Erc4337 = "eip155:erc4337"
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Supported Bitcoin account types.
|
11
|
+
*/
|
12
|
+
export declare enum BtcAccountType {
|
13
|
+
P2wpkh = "bip122:p2wpkh"
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Supported Solana account types.
|
17
|
+
*/
|
18
|
+
export declare enum SolAccountType {
|
19
|
+
DataAccount = "solana:data-account"
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Supported account types.
|
23
|
+
*/
|
24
|
+
export type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccountType.Erc4337}` | `${BtcAccountType.P2wpkh}` | `${SolAccountType.DataAccount}`;
|
25
|
+
/**
|
26
|
+
* A struct which represents a Keyring account object. It is abstract enough to
|
27
|
+
* be used with any blockchain. Specific blockchain account types should extend
|
28
|
+
* this struct.
|
29
|
+
*
|
30
|
+
* See {@link KeyringAccount}.
|
31
|
+
*/
|
32
|
+
export declare const KeyringAccountStruct: import("@metamask/superstruct").Struct<{
|
33
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh" | "solana:data-account";
|
34
|
+
id: string;
|
35
|
+
address: string;
|
36
|
+
options: Record<string, import("@metamask/utils").Json>;
|
37
|
+
methods: string[];
|
38
|
+
}, {
|
39
|
+
/**
|
40
|
+
* Account ID (UUIDv4).
|
41
|
+
*/
|
42
|
+
id: import("@metamask/superstruct").Struct<string, null>;
|
43
|
+
/**
|
44
|
+
* Account type.
|
45
|
+
*/
|
46
|
+
type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh" | "solana:data-account", {
|
47
|
+
"eip155:eoa": "eip155:eoa";
|
48
|
+
"eip155:erc4337": "eip155:erc4337";
|
49
|
+
"bip122:p2wpkh": "bip122:p2wpkh";
|
50
|
+
"solana:data-account": "solana:data-account";
|
51
|
+
}>;
|
52
|
+
/**
|
53
|
+
* Account main address.
|
54
|
+
*/
|
55
|
+
address: import("@metamask/superstruct").Struct<string, null>;
|
56
|
+
/**
|
57
|
+
* Account options.
|
58
|
+
*/
|
59
|
+
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
60
|
+
/**
|
61
|
+
* Account supported methods.
|
62
|
+
*/
|
63
|
+
methods: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
|
64
|
+
}>;
|
65
|
+
/**
|
66
|
+
* Keyring Account type represents an account and its properties from the
|
67
|
+
* point of view of the keyring.
|
68
|
+
*/
|
69
|
+
export type KeyringAccount = Infer<typeof KeyringAccountStruct>;
|
70
|
+
//# sourceMappingURL=account.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAOnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { array, enums, record, string } from "@metamask/superstruct";
|
2
|
+
import { JsonStruct } from "@metamask/utils";
|
3
|
+
import { object } from "../superstruct.mjs";
|
4
|
+
import { UuidStruct } from "../utils/index.mjs";
|
5
|
+
/**
|
6
|
+
* Supported Ethereum account types.
|
7
|
+
*/
|
8
|
+
export var EthAccountType;
|
9
|
+
(function (EthAccountType) {
|
10
|
+
EthAccountType["Eoa"] = "eip155:eoa";
|
11
|
+
EthAccountType["Erc4337"] = "eip155:erc4337";
|
12
|
+
})(EthAccountType || (EthAccountType = {}));
|
13
|
+
/**
|
14
|
+
* Supported Bitcoin account types.
|
15
|
+
*/
|
16
|
+
export var BtcAccountType;
|
17
|
+
(function (BtcAccountType) {
|
18
|
+
BtcAccountType["P2wpkh"] = "bip122:p2wpkh";
|
19
|
+
})(BtcAccountType || (BtcAccountType = {}));
|
20
|
+
/**
|
21
|
+
* Supported Solana account types.
|
22
|
+
*/
|
23
|
+
export var SolAccountType;
|
24
|
+
(function (SolAccountType) {
|
25
|
+
SolAccountType["DataAccount"] = "solana:data-account";
|
26
|
+
})(SolAccountType || (SolAccountType = {}));
|
27
|
+
/**
|
28
|
+
* A struct which represents a Keyring account object. It is abstract enough to
|
29
|
+
* be used with any blockchain. Specific blockchain account types should extend
|
30
|
+
* this struct.
|
31
|
+
*
|
32
|
+
* See {@link KeyringAccount}.
|
33
|
+
*/
|
34
|
+
export const KeyringAccountStruct = object({
|
35
|
+
/**
|
36
|
+
* Account ID (UUIDv4).
|
37
|
+
*/
|
38
|
+
id: UuidStruct,
|
39
|
+
/**
|
40
|
+
* Account type.
|
41
|
+
*/
|
42
|
+
type: enums([
|
43
|
+
`${EthAccountType.Eoa}`,
|
44
|
+
`${EthAccountType.Erc4337}`,
|
45
|
+
`${BtcAccountType.P2wpkh}`,
|
46
|
+
`${SolAccountType.DataAccount}`,
|
47
|
+
]),
|
48
|
+
/**
|
49
|
+
* Account main address.
|
50
|
+
*/
|
51
|
+
address: string(),
|
52
|
+
/**
|
53
|
+
* Account options.
|
54
|
+
*/
|
55
|
+
options: record(string(), JsonStruct),
|
56
|
+
/**
|
57
|
+
* Account supported methods.
|
58
|
+
*/
|
59
|
+
methods: array(string()),
|
60
|
+
});
|
61
|
+
//# sourceMappingURL=account.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.mjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AACrE,OAAO,EAAE,UAAU,EAAE,wBAAwB;AAE7C,OAAO,EAAE,MAAM,EAAE,2BAAuB;AACxC,OAAO,EAAE,UAAU,EAAE,2BAAiB;AAEtC;;GAEG;AACH,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC;;OAEG;IACH,EAAE,EAAE,UAAU;IAEd;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;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,MAAM,EAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,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"]}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.AssetStruct = exports.NonFungibleAssetStruct = exports.FungibleAssetStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
5
|
+
const utils_1 = require("@metamask/utils");
|
6
|
+
const superstruct_2 = require("../superstruct.cjs");
|
7
|
+
const utils_2 = require("../utils/index.cjs");
|
8
|
+
/**
|
9
|
+
* Fungible asset struct.
|
10
|
+
*/
|
11
|
+
exports.FungibleAssetStruct = (0, superstruct_2.object)({
|
12
|
+
/**
|
13
|
+
* It is a fungible asset.
|
14
|
+
*/
|
15
|
+
fungible: (0, superstruct_1.literal)(true),
|
16
|
+
/**
|
17
|
+
* Asset type (CAIP-19).
|
18
|
+
*/
|
19
|
+
type: utils_1.CaipAssetTypeStruct,
|
20
|
+
/**
|
21
|
+
* Asset unit.
|
22
|
+
*/
|
23
|
+
unit: (0, superstruct_1.string)(),
|
24
|
+
/**
|
25
|
+
* Asset amount.
|
26
|
+
*/
|
27
|
+
amount: utils_2.StringNumberStruct,
|
28
|
+
});
|
29
|
+
/**
|
30
|
+
* Non-fungible asset struct.
|
31
|
+
*/
|
32
|
+
exports.NonFungibleAssetStruct = (0, superstruct_2.object)({
|
33
|
+
/**
|
34
|
+
* It is a non-fungible asset.
|
35
|
+
*/
|
36
|
+
fungible: (0, superstruct_1.literal)(false),
|
37
|
+
/**
|
38
|
+
* Asset ID (CAIP-19).
|
39
|
+
*/
|
40
|
+
id: utils_1.CaipAssetIdStruct,
|
41
|
+
});
|
42
|
+
/**
|
43
|
+
* Asset struct. This represents a fungible or non-fungible asset. Fungible
|
44
|
+
* assets include an amount and a unit in addition to the asset type. While
|
45
|
+
* non-fungible assets include only an asset ID.
|
46
|
+
*
|
47
|
+
* See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
|
48
|
+
*
|
49
|
+
* All assets have a `fungible` property that is used to tag the union and
|
50
|
+
* allow the following pattern:
|
51
|
+
*
|
52
|
+
* ```ts
|
53
|
+
* if (asset.fungible) {
|
54
|
+
* // Use asset.type
|
55
|
+
* } else {
|
56
|
+
* // Use asset.id
|
57
|
+
* }
|
58
|
+
* ```
|
59
|
+
*
|
60
|
+
* @example
|
61
|
+
* ```ts
|
62
|
+
* {
|
63
|
+
* fungible: true,
|
64
|
+
* type: 'eip155:1/slip44:60',
|
65
|
+
* unit: 'ETH',
|
66
|
+
* amount: '0.01',
|
67
|
+
* }
|
68
|
+
* ```
|
69
|
+
*
|
70
|
+
* @example
|
71
|
+
* ```ts
|
72
|
+
* {
|
73
|
+
* fungible: false,
|
74
|
+
* id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
|
75
|
+
* }
|
76
|
+
* ```
|
77
|
+
*/
|
78
|
+
exports.AssetStruct = (0, superstruct_2.selectiveUnion)((value) => {
|
79
|
+
return (0, utils_1.isPlainObject)(value) && !value.fungible
|
80
|
+
? exports.NonFungibleAssetStruct
|
81
|
+
: exports.FungibleAssetStruct;
|
82
|
+
});
|
83
|
+
//# sourceMappingURL=asset.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asset.cjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":";;;AACA,uDAAwD;AACxD,2CAIyB;AAEzB,oDAAwD;AACxD,8CAA8C;AAE9C;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,oBAAM,EAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,2BAAmB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,oBAAM,GAAE;IAEd;;OAEG;IACH,MAAM,EAAE,0BAAkB;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C;;OAEG;IACH,QAAQ,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,yBAAiB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,WAAW,GAAG,IAAA,4BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACvD,OAAO,IAAA,qBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAC5C,CAAC,CAAC,8BAAsB;QACxB,CAAC,CAAC,2BAAmB,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string } from '@metamask/superstruct';\nimport {\n CaipAssetIdStruct,\n CaipAssetTypeStruct,\n isPlainObject,\n} from '@metamask/utils';\n\nimport { object, selectiveUnion } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\n/**\n * Fungible asset struct.\n */\nexport const FungibleAssetStruct = object({\n /**\n * It is a fungible asset.\n */\n fungible: literal(true),\n\n /**\n * Asset type (CAIP-19).\n */\n type: CaipAssetTypeStruct,\n\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\n\n/**\n * Non-fungible asset struct.\n */\nexport const NonFungibleAssetStruct = object({\n /**\n * It is a non-fungible asset.\n */\n fungible: literal(false),\n\n /**\n * Asset ID (CAIP-19).\n */\n id: CaipAssetIdStruct,\n});\n\n/**\n * Asset struct. This represents a fungible or non-fungible asset. Fungible\n * assets include an amount and a unit in addition to the asset type. While\n * non-fungible assets include only an asset ID.\n *\n * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.\n *\n * All assets have a `fungible` property that is used to tag the union and\n * allow the following pattern:\n *\n * ```ts\n * if (asset.fungible) {\n * // Use asset.type\n * } else {\n * // Use asset.id\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * }\n * ```\n */\nexport const AssetStruct = selectiveUnion((value: any) => {\n return isPlainObject(value) && !value.fungible\n ? NonFungibleAssetStruct\n : FungibleAssetStruct;\n});\n\n/**\n * Asset type {@see AssetStruct}.\n */\nexport type Asset = Infer<typeof AssetStruct>;\n"]}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
|
+
/**
|
3
|
+
* Fungible asset struct.
|
4
|
+
*/
|
5
|
+
export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
|
6
|
+
type: `${string}:${string}/${string}:${string}`;
|
7
|
+
fungible: true;
|
8
|
+
unit: string;
|
9
|
+
amount: string;
|
10
|
+
}, {
|
11
|
+
/**
|
12
|
+
* It is a fungible asset.
|
13
|
+
*/
|
14
|
+
fungible: import("@metamask/superstruct").Struct<true, true>;
|
15
|
+
/**
|
16
|
+
* Asset type (CAIP-19).
|
17
|
+
*/
|
18
|
+
type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
|
19
|
+
/**
|
20
|
+
* Asset unit.
|
21
|
+
*/
|
22
|
+
unit: import("@metamask/superstruct").Struct<string, null>;
|
23
|
+
/**
|
24
|
+
* Asset amount.
|
25
|
+
*/
|
26
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
27
|
+
}>;
|
28
|
+
/**
|
29
|
+
* Non-fungible asset struct.
|
30
|
+
*/
|
31
|
+
export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
|
32
|
+
id: `${string}:${string}/${string}:${string}/${string}`;
|
33
|
+
fungible: false;
|
34
|
+
}, {
|
35
|
+
/**
|
36
|
+
* It is a non-fungible asset.
|
37
|
+
*/
|
38
|
+
fungible: import("@metamask/superstruct").Struct<false, false>;
|
39
|
+
/**
|
40
|
+
* Asset ID (CAIP-19).
|
41
|
+
*/
|
42
|
+
id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
|
43
|
+
}>;
|
44
|
+
/**
|
45
|
+
* Asset struct. This represents a fungible or non-fungible asset. Fungible
|
46
|
+
* assets include an amount and a unit in addition to the asset type. While
|
47
|
+
* non-fungible assets include only an asset ID.
|
48
|
+
*
|
49
|
+
* See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
|
50
|
+
*
|
51
|
+
* All assets have a `fungible` property that is used to tag the union and
|
52
|
+
* allow the following pattern:
|
53
|
+
*
|
54
|
+
* ```ts
|
55
|
+
* if (asset.fungible) {
|
56
|
+
* // Use asset.type
|
57
|
+
* } else {
|
58
|
+
* // Use asset.id
|
59
|
+
* }
|
60
|
+
* ```
|
61
|
+
*
|
62
|
+
* @example
|
63
|
+
* ```ts
|
64
|
+
* {
|
65
|
+
* fungible: true,
|
66
|
+
* type: 'eip155:1/slip44:60',
|
67
|
+
* unit: 'ETH',
|
68
|
+
* amount: '0.01',
|
69
|
+
* }
|
70
|
+
* ```
|
71
|
+
*
|
72
|
+
* @example
|
73
|
+
* ```ts
|
74
|
+
* {
|
75
|
+
* fungible: false,
|
76
|
+
* id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
|
77
|
+
* }
|
78
|
+
* ```
|
79
|
+
*/
|
80
|
+
export declare const AssetStruct: import("@metamask/superstruct").Struct<{
|
81
|
+
type: `${string}:${string}/${string}:${string}`;
|
82
|
+
fungible: true;
|
83
|
+
unit: string;
|
84
|
+
amount: string;
|
85
|
+
} | {
|
86
|
+
id: `${string}:${string}/${string}:${string}/${string}`;
|
87
|
+
fungible: false;
|
88
|
+
}, null>;
|
89
|
+
/**
|
90
|
+
* Asset type {@see AssetStruct}.
|
91
|
+
*/
|
92
|
+
export type Asset = Infer<typeof AssetStruct>;
|
93
|
+
//# sourceMappingURL=asset.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asset.d.cts","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAWnD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,WAAW;;;;;;;;QAItB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
|
+
/**
|
3
|
+
* Fungible asset struct.
|
4
|
+
*/
|
5
|
+
export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
|
6
|
+
type: `${string}:${string}/${string}:${string}`;
|
7
|
+
fungible: true;
|
8
|
+
unit: string;
|
9
|
+
amount: string;
|
10
|
+
}, {
|
11
|
+
/**
|
12
|
+
* It is a fungible asset.
|
13
|
+
*/
|
14
|
+
fungible: import("@metamask/superstruct").Struct<true, true>;
|
15
|
+
/**
|
16
|
+
* Asset type (CAIP-19).
|
17
|
+
*/
|
18
|
+
type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
|
19
|
+
/**
|
20
|
+
* Asset unit.
|
21
|
+
*/
|
22
|
+
unit: import("@metamask/superstruct").Struct<string, null>;
|
23
|
+
/**
|
24
|
+
* Asset amount.
|
25
|
+
*/
|
26
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
27
|
+
}>;
|
28
|
+
/**
|
29
|
+
* Non-fungible asset struct.
|
30
|
+
*/
|
31
|
+
export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
|
32
|
+
id: `${string}:${string}/${string}:${string}/${string}`;
|
33
|
+
fungible: false;
|
34
|
+
}, {
|
35
|
+
/**
|
36
|
+
* It is a non-fungible asset.
|
37
|
+
*/
|
38
|
+
fungible: import("@metamask/superstruct").Struct<false, false>;
|
39
|
+
/**
|
40
|
+
* Asset ID (CAIP-19).
|
41
|
+
*/
|
42
|
+
id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
|
43
|
+
}>;
|
44
|
+
/**
|
45
|
+
* Asset struct. This represents a fungible or non-fungible asset. Fungible
|
46
|
+
* assets include an amount and a unit in addition to the asset type. While
|
47
|
+
* non-fungible assets include only an asset ID.
|
48
|
+
*
|
49
|
+
* See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
|
50
|
+
*
|
51
|
+
* All assets have a `fungible` property that is used to tag the union and
|
52
|
+
* allow the following pattern:
|
53
|
+
*
|
54
|
+
* ```ts
|
55
|
+
* if (asset.fungible) {
|
56
|
+
* // Use asset.type
|
57
|
+
* } else {
|
58
|
+
* // Use asset.id
|
59
|
+
* }
|
60
|
+
* ```
|
61
|
+
*
|
62
|
+
* @example
|
63
|
+
* ```ts
|
64
|
+
* {
|
65
|
+
* fungible: true,
|
66
|
+
* type: 'eip155:1/slip44:60',
|
67
|
+
* unit: 'ETH',
|
68
|
+
* amount: '0.01',
|
69
|
+
* }
|
70
|
+
* ```
|
71
|
+
*
|
72
|
+
* @example
|
73
|
+
* ```ts
|
74
|
+
* {
|
75
|
+
* fungible: false,
|
76
|
+
* id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
|
77
|
+
* }
|
78
|
+
* ```
|
79
|
+
*/
|
80
|
+
export declare const AssetStruct: import("@metamask/superstruct").Struct<{
|
81
|
+
type: `${string}:${string}/${string}:${string}`;
|
82
|
+
fungible: true;
|
83
|
+
unit: string;
|
84
|
+
amount: string;
|
85
|
+
} | {
|
86
|
+
id: `${string}:${string}/${string}:${string}/${string}`;
|
87
|
+
fungible: false;
|
88
|
+
}, null>;
|
89
|
+
/**
|
90
|
+
* Asset type {@see AssetStruct}.
|
91
|
+
*/
|
92
|
+
export type Asset = Infer<typeof AssetStruct>;
|
93
|
+
//# sourceMappingURL=asset.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asset.d.mts","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAWnD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,WAAW;;;;;;;;QAItB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import { literal, string } from "@metamask/superstruct";
|
2
|
+
import { CaipAssetIdStruct, CaipAssetTypeStruct, isPlainObject } from "@metamask/utils";
|
3
|
+
import { object, selectiveUnion } from "../superstruct.mjs";
|
4
|
+
import { StringNumberStruct } from "../utils/index.mjs";
|
5
|
+
/**
|
6
|
+
* Fungible asset struct.
|
7
|
+
*/
|
8
|
+
export const FungibleAssetStruct = object({
|
9
|
+
/**
|
10
|
+
* It is a fungible asset.
|
11
|
+
*/
|
12
|
+
fungible: literal(true),
|
13
|
+
/**
|
14
|
+
* Asset type (CAIP-19).
|
15
|
+
*/
|
16
|
+
type: CaipAssetTypeStruct,
|
17
|
+
/**
|
18
|
+
* Asset unit.
|
19
|
+
*/
|
20
|
+
unit: string(),
|
21
|
+
/**
|
22
|
+
* Asset amount.
|
23
|
+
*/
|
24
|
+
amount: StringNumberStruct,
|
25
|
+
});
|
26
|
+
/**
|
27
|
+
* Non-fungible asset struct.
|
28
|
+
*/
|
29
|
+
export const NonFungibleAssetStruct = object({
|
30
|
+
/**
|
31
|
+
* It is a non-fungible asset.
|
32
|
+
*/
|
33
|
+
fungible: literal(false),
|
34
|
+
/**
|
35
|
+
* Asset ID (CAIP-19).
|
36
|
+
*/
|
37
|
+
id: CaipAssetIdStruct,
|
38
|
+
});
|
39
|
+
/**
|
40
|
+
* Asset struct. This represents a fungible or non-fungible asset. Fungible
|
41
|
+
* assets include an amount and a unit in addition to the asset type. While
|
42
|
+
* non-fungible assets include only an asset ID.
|
43
|
+
*
|
44
|
+
* See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
|
45
|
+
*
|
46
|
+
* All assets have a `fungible` property that is used to tag the union and
|
47
|
+
* allow the following pattern:
|
48
|
+
*
|
49
|
+
* ```ts
|
50
|
+
* if (asset.fungible) {
|
51
|
+
* // Use asset.type
|
52
|
+
* } else {
|
53
|
+
* // Use asset.id
|
54
|
+
* }
|
55
|
+
* ```
|
56
|
+
*
|
57
|
+
* @example
|
58
|
+
* ```ts
|
59
|
+
* {
|
60
|
+
* fungible: true,
|
61
|
+
* type: 'eip155:1/slip44:60',
|
62
|
+
* unit: 'ETH',
|
63
|
+
* amount: '0.01',
|
64
|
+
* }
|
65
|
+
* ```
|
66
|
+
*
|
67
|
+
* @example
|
68
|
+
* ```ts
|
69
|
+
* {
|
70
|
+
* fungible: false,
|
71
|
+
* id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
|
72
|
+
* }
|
73
|
+
* ```
|
74
|
+
*/
|
75
|
+
export const AssetStruct = selectiveUnion((value) => {
|
76
|
+
return isPlainObject(value) && !value.fungible
|
77
|
+
? NonFungibleAssetStruct
|
78
|
+
: FungibleAssetStruct;
|
79
|
+
});
|
80
|
+
//# sourceMappingURL=asset.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"asset.mjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AACxD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACd,wBAAwB;AAEzB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,2BAAuB;AACxD,OAAO,EAAE,kBAAkB,EAAE,2BAAiB;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,mBAAmB;IAEzB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE;IAEd;;OAEG;IACH,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,iBAAiB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACvD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAC5C,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string } from '@metamask/superstruct';\nimport {\n CaipAssetIdStruct,\n CaipAssetTypeStruct,\n isPlainObject,\n} from '@metamask/utils';\n\nimport { object, selectiveUnion } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\n/**\n * Fungible asset struct.\n */\nexport const FungibleAssetStruct = object({\n /**\n * It is a fungible asset.\n */\n fungible: literal(true),\n\n /**\n * Asset type (CAIP-19).\n */\n type: CaipAssetTypeStruct,\n\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\n\n/**\n * Non-fungible asset struct.\n */\nexport const NonFungibleAssetStruct = object({\n /**\n * It is a non-fungible asset.\n */\n fungible: literal(false),\n\n /**\n * Asset ID (CAIP-19).\n */\n id: CaipAssetIdStruct,\n});\n\n/**\n * Asset struct. This represents a fungible or non-fungible asset. Fungible\n * assets include an amount and a unit in addition to the asset type. While\n * non-fungible assets include only an asset ID.\n *\n * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.\n *\n * All assets have a `fungible` property that is used to tag the union and\n * allow the following pattern:\n *\n * ```ts\n * if (asset.fungible) {\n * // Use asset.type\n * } else {\n * // Use asset.id\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * }\n * ```\n */\nexport const AssetStruct = selectiveUnion((value: any) => {\n return isPlainObject(value) && !value.fungible\n ? NonFungibleAssetStruct\n : FungibleAssetStruct;\n});\n\n/**\n * Asset type {@see AssetStruct}.\n */\nexport type Asset = Infer<typeof AssetStruct>;\n"]}
|
@@ -2,10 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.BalanceStruct = void 0;
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
5
|
-
const superstruct_2 = require("../superstruct");
|
6
|
-
const utils_1 = require("../utils");
|
5
|
+
const superstruct_2 = require("../superstruct.cjs");
|
6
|
+
const utils_1 = require("../utils/index.cjs");
|
7
7
|
exports.BalanceStruct = (0, superstruct_2.object)({
|
8
8
|
amount: utils_1.StringNumberStruct,
|
9
9
|
unit: (0, superstruct_1.string)(),
|
10
10
|
});
|
11
|
-
//# sourceMappingURL=balance.
|
11
|
+
//# sourceMappingURL=balance.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"balance.cjs","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,oDAAwC;AACxC,8CAA8C;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"]}
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import type { Infer } from
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
2
|
export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
|
3
|
-
amount: string;
|
4
3
|
unit: string;
|
4
|
+
amount: string;
|
5
5
|
}, {
|
6
6
|
amount: import("@metamask/superstruct").Struct<string, null>;
|
7
7
|
unit: import("@metamask/superstruct").Struct<string, null>;
|
8
8
|
}>;
|
9
9
|
export type Balance = Infer<typeof BalanceStruct>;
|
10
|
+
//# sourceMappingURL=balance.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"balance.d.cts","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD,eAAO,MAAM,aAAa;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
|
+
export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
|
3
|
+
unit: string;
|
4
|
+
amount: string;
|
5
|
+
}, {
|
6
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
7
|
+
unit: import("@metamask/superstruct").Struct<string, null>;
|
8
|
+
}>;
|
9
|
+
export type Balance = Infer<typeof BalanceStruct>;
|
10
|
+
//# sourceMappingURL=balance.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"balance.d.mts","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD,eAAO,MAAM,aAAa;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { string } from "@metamask/superstruct";
|
2
|
+
import { object } from "../superstruct.mjs";
|
3
|
+
import { StringNumberStruct } from "../utils/index.mjs";
|
4
|
+
export const BalanceStruct = object({
|
5
|
+
amount: StringNumberStruct,
|
6
|
+
unit: string(),
|
7
|
+
});
|
8
|
+
//# sourceMappingURL=balance.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"balance.mjs","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,MAAM,EAAE,2BAAuB;AACxC,OAAO,EAAE,kBAAkB,EAAE,2BAAiB;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,kBAAkB;IAC1B,IAAI,EAAE,MAAM,EAAE;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"]}
|
@@ -1,8 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = void 0;
|
4
|
+
exports.isCaipAssetType = isCaipAssetType;
|
5
|
+
exports.isCaipAssetId = isCaipAssetId;
|
4
6
|
const superstruct_1 = require("@metamask/superstruct");
|
5
|
-
const superstruct_2 = require("../superstruct");
|
7
|
+
const superstruct_2 = require("../superstruct.cjs");
|
6
8
|
const CAIP_ASSET_TYPE_REGEX = /^(?<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;
|
7
9
|
const CAIP_ASSET_ID_REGEX = /^(?<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;
|
8
10
|
/**
|
@@ -28,7 +30,6 @@ exports.CaipAssetIdStruct = (0, superstruct_2.definePattern)('CaipAssetId', CAIP
|
|
28
30
|
function isCaipAssetType(value) {
|
29
31
|
return (0, superstruct_1.is)(value, exports.CaipAssetTypeStruct);
|
30
32
|
}
|
31
|
-
exports.isCaipAssetType = isCaipAssetType;
|
32
33
|
/**
|
33
34
|
* Check if the given value is a {@link CaipAssetId}.
|
34
35
|
*
|
@@ -44,5 +45,4 @@ exports.isCaipAssetType = isCaipAssetType;
|
|
44
45
|
function isCaipAssetId(value) {
|
45
46
|
return (0, superstruct_1.is)(value, exports.CaipAssetIdStruct);
|
46
47
|
}
|
47
|
-
|
48
|
-
//# sourceMappingURL=caip.js.map
|
48
|
+
//# sourceMappingURL=caip.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"caip.cjs","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAwCA,0CAEC;AAcD,sCAEC;AA1DD,uDAAuD;AAEvD,oDAA+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;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,yBAAiB,CAAC,CAAC;AACtC,CAAC","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"]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type Infer } from
|
1
|
+
import { type Infer } from "@metamask/superstruct";
|
2
2
|
/**
|
3
3
|
* A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
|
4
4
|
*/
|
@@ -35,3 +35,4 @@ export declare function isCaipAssetType(value: unknown): value is CaipAssetType;
|
|
35
35
|
* ```
|
36
36
|
*/
|
37
37
|
export declare function isCaipAssetId(value: unknown): value is CaipAssetId;
|
38
|
+
//# sourceMappingURL=caip.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"caip.d.cts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,KAAK,EAAE,8BAA8B;AAUvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,sDAG/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAG7B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
|