@metamask/keyring-api 21.3.0 → 21.5.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 +49 -2
- package/README.md +4 -0
- package/dist/api/account-options.cjs +44 -7
- package/dist/api/account-options.cjs.map +1 -1
- package/dist/api/account-options.d.cts +41 -3
- package/dist/api/account-options.d.cts.map +1 -1
- package/dist/api/account-options.d.mts +41 -3
- package/dist/api/account-options.d.mts.map +1 -1
- package/dist/api/account-options.mjs +43 -6
- package/dist/api/account-options.mjs.map +1 -1
- package/dist/api/account.d.cts +4 -0
- package/dist/api/account.d.cts.map +1 -1
- package/dist/api/account.d.mts +4 -0
- package/dist/api/account.d.mts.map +1 -1
- package/dist/api/keyring.cjs +0 -2
- package/dist/api/keyring.cjs.map +1 -1
- package/dist/api/keyring.d.cts +13 -0
- package/dist/api/keyring.d.cts.map +1 -1
- package/dist/api/keyring.d.mts +13 -0
- package/dist/api/keyring.d.mts.map +1 -1
- package/dist/api/keyring.mjs +0 -2
- package/dist/api/keyring.mjs.map +1 -1
- package/dist/api/v2/create-account/bip44.cjs +27 -1
- package/dist/api/v2/create-account/bip44.cjs.map +1 -1
- package/dist/api/v2/create-account/bip44.d.cts +46 -0
- package/dist/api/v2/create-account/bip44.d.cts.map +1 -1
- package/dist/api/v2/create-account/bip44.d.mts +46 -0
- package/dist/api/v2/create-account/bip44.d.mts.map +1 -1
- package/dist/api/v2/create-account/bip44.mjs +26 -0
- package/dist/api/v2/create-account/bip44.mjs.map +1 -1
- package/dist/api/v2/create-account/custom.cjs +14 -0
- package/dist/api/v2/create-account/custom.cjs.map +1 -0
- package/dist/api/v2/create-account/custom.d.cts +25 -0
- package/dist/api/v2/create-account/custom.d.cts.map +1 -0
- package/dist/api/v2/create-account/custom.d.mts +25 -0
- package/dist/api/v2/create-account/custom.d.mts.map +1 -0
- package/dist/api/v2/create-account/custom.mjs +11 -0
- package/dist/api/v2/create-account/custom.mjs.map +1 -0
- package/dist/api/v2/create-account/index.cjs +55 -0
- package/dist/api/v2/create-account/index.cjs.map +1 -1
- package/dist/api/v2/create-account/index.d.cts +55 -1
- package/dist/api/v2/create-account/index.d.cts.map +1 -1
- package/dist/api/v2/create-account/index.d.mts +55 -1
- package/dist/api/v2/create-account/index.d.mts.map +1 -1
- package/dist/api/v2/create-account/index.mjs +55 -1
- package/dist/api/v2/create-account/index.mjs.map +1 -1
- package/dist/api/v2/index.cjs +1 -0
- package/dist/api/v2/index.cjs.map +1 -1
- package/dist/api/v2/index.d.cts +1 -0
- package/dist/api/v2/index.d.cts.map +1 -1
- package/dist/api/v2/index.d.mts +1 -0
- package/dist/api/v2/index.d.mts.map +1 -1
- package/dist/api/v2/index.mjs +1 -0
- package/dist/api/v2/index.mjs.map +1 -1
- package/dist/api/v2/keyring-capabilities.cjs +17 -3
- package/dist/api/v2/keyring-capabilities.cjs.map +1 -1
- package/dist/api/v2/keyring-capabilities.d.cts +31 -9
- package/dist/api/v2/keyring-capabilities.d.cts.map +1 -1
- package/dist/api/v2/keyring-capabilities.d.mts +31 -9
- package/dist/api/v2/keyring-capabilities.d.mts.map +1 -1
- package/dist/api/v2/keyring-capabilities.mjs +18 -4
- package/dist/api/v2/keyring-capabilities.mjs.map +1 -1
- package/dist/api/v2/wrapper/index.cjs +19 -0
- package/dist/api/v2/wrapper/index.cjs.map +1 -0
- package/dist/api/v2/wrapper/index.d.cts +3 -0
- package/dist/api/v2/wrapper/index.d.cts.map +1 -0
- package/dist/api/v2/wrapper/index.d.mts +3 -0
- package/dist/api/v2/wrapper/index.d.mts.map +1 -0
- package/dist/api/v2/wrapper/index.mjs +3 -0
- package/dist/api/v2/wrapper/index.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs +135 -0
- package/dist/api/v2/wrapper/keyring-account-registry.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts +88 -0
- package/dist/api/v2/wrapper/keyring-account-registry.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs +131 -0
- package/dist/api/v2/wrapper/keyring-account-registry.mjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs +134 -0
- package/dist/api/v2/wrapper/keyring-wrapper.cjs.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts +154 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.cts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts +154 -0
- package/dist/api/v2/wrapper/keyring-wrapper.d.mts.map +1 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs +130 -0
- package/dist/api/v2/wrapper/keyring-wrapper.mjs.map +1 -0
- package/dist/btc/types.d.cts +16 -0
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +16 -0
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/eth/index.cjs +2 -0
- package/dist/eth/index.cjs.map +1 -1
- package/dist/eth/index.d.cts +2 -0
- package/dist/eth/index.d.cts.map +1 -1
- package/dist/eth/index.d.mts +2 -0
- package/dist/eth/index.d.mts.map +1 -1
- package/dist/eth/index.mjs +2 -0
- package/dist/eth/index.mjs.map +1 -1
- package/dist/eth/rpc/index.cjs +18 -0
- package/dist/eth/rpc/index.cjs.map +1 -0
- package/dist/eth/rpc/index.d.cts +2 -0
- package/dist/eth/rpc/index.d.cts.map +1 -0
- package/dist/eth/rpc/index.d.mts +2 -0
- package/dist/eth/rpc/index.d.mts.map +1 -0
- package/dist/eth/rpc/index.mjs +2 -0
- package/dist/eth/rpc/index.mjs.map +1 -0
- package/dist/eth/rpc/params.cjs +151 -0
- package/dist/eth/rpc/params.cjs.map +1 -0
- package/dist/eth/rpc/params.d.cts +215 -0
- package/dist/eth/rpc/params.d.cts.map +1 -0
- package/dist/eth/rpc/params.d.mts +215 -0
- package/dist/eth/rpc/params.d.mts.map +1 -0
- package/dist/eth/rpc/params.mjs +148 -0
- package/dist/eth/rpc/params.mjs.map +1 -0
- package/dist/eth/types.cjs +5 -2
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +9 -0
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +9 -0
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs +4 -1
- package/dist/eth/types.mjs.map +1 -1
- package/dist/eth/v2/eth-keyring-wrapper.cjs +165 -0
- package/dist/eth/v2/eth-keyring-wrapper.cjs.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.cts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts +54 -0
- package/dist/eth/v2/eth-keyring-wrapper.d.mts.map +1 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs +161 -0
- package/dist/eth/v2/eth-keyring-wrapper.mjs.map +1 -0
- package/dist/eth/v2/index.cjs +18 -0
- package/dist/eth/v2/index.cjs.map +1 -0
- package/dist/eth/v2/index.d.cts +2 -0
- package/dist/eth/v2/index.d.cts.map +1 -0
- package/dist/eth/v2/index.d.mts +2 -0
- package/dist/eth/v2/index.d.mts.map +1 -0
- package/dist/eth/v2/index.mjs +2 -0
- package/dist/eth/v2/index.mjs.map +1 -0
- package/dist/events.cjs +0 -2
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +16 -0
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +16 -0
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +0 -2
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.cjs +27 -12
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +200 -12
- package/dist/rpc.d.cts.map +1 -1
- package/dist/rpc.d.mts +200 -12
- package/dist/rpc.d.mts.map +1 -1
- package/dist/rpc.mjs +27 -12
- package/dist/rpc.mjs.map +1 -1
- package/dist/sol/types.d.cts +4 -0
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts +4 -0
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/trx/types.d.cts +4 -0
- package/dist/trx/types.d.cts.map +1 -1
- package/dist/trx/types.d.mts +4 -0
- package/dist/trx/types.d.mts.map +1 -1
- package/package.json +9 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Infer } from "@metamask/superstruct";
|
|
2
2
|
export * from "./bip44.cjs";
|
|
3
|
+
export * from "./custom.cjs";
|
|
3
4
|
export * from "./private-key.cjs";
|
|
4
5
|
/**
|
|
5
6
|
* Enum representing the different ways an account can be created.
|
|
@@ -17,6 +18,14 @@ export declare enum AccountCreationType {
|
|
|
17
18
|
* index.
|
|
18
19
|
*/
|
|
19
20
|
Bip44DeriveIndex = "bip44:derive-index",
|
|
21
|
+
/**
|
|
22
|
+
* Represents accounts created by deriving a range of BIP-44 account indices.
|
|
23
|
+
*
|
|
24
|
+
* More than one account can be created per index, for example, the keyring
|
|
25
|
+
* can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
|
|
26
|
+
* account index in the range.
|
|
27
|
+
*/
|
|
28
|
+
Bip44DeriveIndexRange = "bip44:derive-index-range",
|
|
20
29
|
/**
|
|
21
30
|
* Represents accounts created through BIP-44 account discovery.
|
|
22
31
|
*
|
|
@@ -28,7 +37,14 @@ export declare enum AccountCreationType {
|
|
|
28
37
|
/**
|
|
29
38
|
* Represents an account imported from a private key.
|
|
30
39
|
*/
|
|
31
|
-
PrivateKeyImport = "private-key:import"
|
|
40
|
+
PrivateKeyImport = "private-key:import",
|
|
41
|
+
/**
|
|
42
|
+
* Represents an account created using a custom, keyring-specific method.
|
|
43
|
+
*
|
|
44
|
+
* This is used by keyrings that have non-standard account creation flows
|
|
45
|
+
* and declare `custom.createAccounts: true` in their capabilities.
|
|
46
|
+
*/
|
|
47
|
+
Custom = "custom"
|
|
32
48
|
}
|
|
33
49
|
/**
|
|
34
50
|
* Struct for {@link CreateAccountOptions}.
|
|
@@ -45,6 +61,15 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
|
|
|
45
61
|
type: "bip44:discover";
|
|
46
62
|
groupIndex: number;
|
|
47
63
|
entropySource: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "bip44:derive-index-range";
|
|
66
|
+
range: {
|
|
67
|
+
from: number;
|
|
68
|
+
to: number;
|
|
69
|
+
};
|
|
70
|
+
entropySource: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "custom";
|
|
48
73
|
} | {
|
|
49
74
|
type: "private-key:import";
|
|
50
75
|
encoding: "hexadecimal" | "base58";
|
|
@@ -55,4 +80,33 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
|
|
|
55
80
|
* Represents the available options for creating a new account.
|
|
56
81
|
*/
|
|
57
82
|
export type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;
|
|
83
|
+
/**
|
|
84
|
+
* Asserts that a given create account option type is supported by the keyring.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* createAccounts(options: CreateAccountOptions) {
|
|
89
|
+
* assertCreateAccountOptionIsSupported(options, [
|
|
90
|
+
* ${AccountCreationType.Bip44DeriveIndex},
|
|
91
|
+
* ${AccountCreationType.Bip44DeriveIndexRange},
|
|
92
|
+
* ] as const);
|
|
93
|
+
*
|
|
94
|
+
* // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
|
|
95
|
+
* if (options.type === AccountCreationType.Bip44DeriveIndex) {
|
|
96
|
+
* ... // Handle Bip44DeriveIndex case.
|
|
97
|
+
* } else {
|
|
98
|
+
* ... // Handle Bip44DeriveIndexRange case.
|
|
99
|
+
* }
|
|
100
|
+
* ...
|
|
101
|
+
* return accounts;
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param options - The create account option object to check.
|
|
106
|
+
* @param supportedTypes - The list of supported create account option types for this keyring.
|
|
107
|
+
* @throws Will throw an error if the provided options are not supported.
|
|
108
|
+
*/
|
|
109
|
+
export declare function assertCreateAccountOptionIsSupported<Options extends CreateAccountOptions, Type extends `${CreateAccountOptions['type']}`>(options: Options, supportedTypes: readonly `${Type}`[]): asserts options is Options & {
|
|
110
|
+
type: `${Type}` & `${Options['type']}`;
|
|
111
|
+
};
|
|
58
112
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,oBAAoB,EAEpC,IAAI,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,GAEnC,OAAO,CAAC,OAAO,IAAI,OAAO,GAAG;IAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;CAAE,CAOzE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Infer } from "@metamask/superstruct";
|
|
2
2
|
export * from "./bip44.mjs";
|
|
3
|
+
export * from "./custom.mjs";
|
|
3
4
|
export * from "./private-key.mjs";
|
|
4
5
|
/**
|
|
5
6
|
* Enum representing the different ways an account can be created.
|
|
@@ -17,6 +18,14 @@ export declare enum AccountCreationType {
|
|
|
17
18
|
* index.
|
|
18
19
|
*/
|
|
19
20
|
Bip44DeriveIndex = "bip44:derive-index",
|
|
21
|
+
/**
|
|
22
|
+
* Represents accounts created by deriving a range of BIP-44 account indices.
|
|
23
|
+
*
|
|
24
|
+
* More than one account can be created per index, for example, the keyring
|
|
25
|
+
* can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
|
|
26
|
+
* account index in the range.
|
|
27
|
+
*/
|
|
28
|
+
Bip44DeriveIndexRange = "bip44:derive-index-range",
|
|
20
29
|
/**
|
|
21
30
|
* Represents accounts created through BIP-44 account discovery.
|
|
22
31
|
*
|
|
@@ -28,7 +37,14 @@ export declare enum AccountCreationType {
|
|
|
28
37
|
/**
|
|
29
38
|
* Represents an account imported from a private key.
|
|
30
39
|
*/
|
|
31
|
-
PrivateKeyImport = "private-key:import"
|
|
40
|
+
PrivateKeyImport = "private-key:import",
|
|
41
|
+
/**
|
|
42
|
+
* Represents an account created using a custom, keyring-specific method.
|
|
43
|
+
*
|
|
44
|
+
* This is used by keyrings that have non-standard account creation flows
|
|
45
|
+
* and declare `custom.createAccounts: true` in their capabilities.
|
|
46
|
+
*/
|
|
47
|
+
Custom = "custom"
|
|
32
48
|
}
|
|
33
49
|
/**
|
|
34
50
|
* Struct for {@link CreateAccountOptions}.
|
|
@@ -45,6 +61,15 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
|
|
|
45
61
|
type: "bip44:discover";
|
|
46
62
|
groupIndex: number;
|
|
47
63
|
entropySource: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "bip44:derive-index-range";
|
|
66
|
+
range: {
|
|
67
|
+
from: number;
|
|
68
|
+
to: number;
|
|
69
|
+
};
|
|
70
|
+
entropySource: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "custom";
|
|
48
73
|
} | {
|
|
49
74
|
type: "private-key:import";
|
|
50
75
|
encoding: "hexadecimal" | "base58";
|
|
@@ -55,4 +80,33 @@ export declare const CreateAccountOptionsStruct: import("@metamask/superstruct")
|
|
|
55
80
|
* Represents the available options for creating a new account.
|
|
56
81
|
*/
|
|
57
82
|
export type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;
|
|
83
|
+
/**
|
|
84
|
+
* Asserts that a given create account option type is supported by the keyring.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* createAccounts(options: CreateAccountOptions) {
|
|
89
|
+
* assertCreateAccountOptionIsSupported(options, [
|
|
90
|
+
* ${AccountCreationType.Bip44DeriveIndex},
|
|
91
|
+
* ${AccountCreationType.Bip44DeriveIndexRange},
|
|
92
|
+
* ] as const);
|
|
93
|
+
*
|
|
94
|
+
* // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
|
|
95
|
+
* if (options.type === AccountCreationType.Bip44DeriveIndex) {
|
|
96
|
+
* ... // Handle Bip44DeriveIndex case.
|
|
97
|
+
* } else {
|
|
98
|
+
* ... // Handle Bip44DeriveIndexRange case.
|
|
99
|
+
* }
|
|
100
|
+
* ...
|
|
101
|
+
* return accounts;
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param options - The create account option object to check.
|
|
106
|
+
* @param supportedTypes - The list of supported create account option types for this keyring.
|
|
107
|
+
* @throws Will throw an error if the provided options are not supported.
|
|
108
|
+
*/
|
|
109
|
+
export declare function assertCreateAccountOptionIsSupported<Options extends CreateAccountOptions, Type extends `${CreateAccountOptions['type']}`>(options: Options, supportedTypes: readonly `${Type}`[]): asserts options is Options & {
|
|
110
|
+
type: `${Type}` & `${Options['type']}`;
|
|
111
|
+
};
|
|
58
112
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,oBAAoB,EAEpC,IAAI,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,GAEnC,OAAO,CAAC,OAAO,IAAI,OAAO,GAAG;IAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;CAAE,CAOzE"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { selectiveUnion } from "@metamask/keyring-utils";
|
|
2
|
-
import { CreateAccountBip44DiscoverOptionsStruct, CreateAccountBip44DeriveIndexOptionsStruct, CreateAccountBip44DerivePathOptionsStruct } from "./bip44.mjs";
|
|
2
|
+
import { CreateAccountBip44DiscoverOptionsStruct, CreateAccountBip44DeriveIndexOptionsStruct, CreateAccountBip44DeriveIndexRangeOptionsStruct, CreateAccountBip44DerivePathOptionsStruct } from "./bip44.mjs";
|
|
3
|
+
import { CreateAccountCustomOptionsStruct } from "./custom.mjs";
|
|
3
4
|
import { CreateAccountPrivateKeyOptionsStruct } from "./private-key.mjs";
|
|
4
5
|
export * from "./bip44.mjs";
|
|
6
|
+
export * from "./custom.mjs";
|
|
5
7
|
export * from "./private-key.mjs";
|
|
6
8
|
/**
|
|
7
9
|
* Enum representing the different ways an account can be created.
|
|
@@ -20,6 +22,14 @@ export var AccountCreationType;
|
|
|
20
22
|
* index.
|
|
21
23
|
*/
|
|
22
24
|
AccountCreationType["Bip44DeriveIndex"] = "bip44:derive-index";
|
|
25
|
+
/**
|
|
26
|
+
* Represents accounts created by deriving a range of BIP-44 account indices.
|
|
27
|
+
*
|
|
28
|
+
* More than one account can be created per index, for example, the keyring
|
|
29
|
+
* can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each
|
|
30
|
+
* account index in the range.
|
|
31
|
+
*/
|
|
32
|
+
AccountCreationType["Bip44DeriveIndexRange"] = "bip44:derive-index-range";
|
|
23
33
|
/**
|
|
24
34
|
* Represents accounts created through BIP-44 account discovery.
|
|
25
35
|
*
|
|
@@ -32,6 +42,13 @@ export var AccountCreationType;
|
|
|
32
42
|
* Represents an account imported from a private key.
|
|
33
43
|
*/
|
|
34
44
|
AccountCreationType["PrivateKeyImport"] = "private-key:import";
|
|
45
|
+
/**
|
|
46
|
+
* Represents an account created using a custom, keyring-specific method.
|
|
47
|
+
*
|
|
48
|
+
* This is used by keyrings that have non-standard account creation flows
|
|
49
|
+
* and declare `custom.createAccounts: true` in their capabilities.
|
|
50
|
+
*/
|
|
51
|
+
AccountCreationType["Custom"] = "custom";
|
|
35
52
|
})(AccountCreationType || (AccountCreationType = {}));
|
|
36
53
|
/**
|
|
37
54
|
* Struct for {@link CreateAccountOptions}.
|
|
@@ -43,13 +60,50 @@ export const CreateAccountOptionsStruct = selectiveUnion((value) => {
|
|
|
43
60
|
return CreateAccountBip44DerivePathOptionsStruct;
|
|
44
61
|
case AccountCreationType.Bip44DeriveIndex:
|
|
45
62
|
return CreateAccountBip44DeriveIndexOptionsStruct;
|
|
63
|
+
case AccountCreationType.Bip44DeriveIndexRange:
|
|
64
|
+
return CreateAccountBip44DeriveIndexRangeOptionsStruct;
|
|
46
65
|
case AccountCreationType.Bip44Discover:
|
|
47
66
|
return CreateAccountBip44DiscoverOptionsStruct;
|
|
48
67
|
case AccountCreationType.PrivateKeyImport:
|
|
49
68
|
return CreateAccountPrivateKeyOptionsStruct;
|
|
69
|
+
case AccountCreationType.Custom:
|
|
70
|
+
return CreateAccountCustomOptionsStruct;
|
|
50
71
|
default:
|
|
51
72
|
// Return first struct as fallback - validation will fail with proper error indicating the type mismatch
|
|
52
73
|
return CreateAccountBip44DerivePathOptionsStruct;
|
|
53
74
|
}
|
|
54
75
|
});
|
|
76
|
+
/**
|
|
77
|
+
* Asserts that a given create account option type is supported by the keyring.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* createAccounts(options: CreateAccountOptions) {
|
|
82
|
+
* assertCreateAccountOptionIsSupported(options, [
|
|
83
|
+
* ${AccountCreationType.Bip44DeriveIndex},
|
|
84
|
+
* ${AccountCreationType.Bip44DeriveIndexRange},
|
|
85
|
+
* ] as const);
|
|
86
|
+
*
|
|
87
|
+
* // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.
|
|
88
|
+
* if (options.type === AccountCreationType.Bip44DeriveIndex) {
|
|
89
|
+
* ... // Handle Bip44DeriveIndex case.
|
|
90
|
+
* } else {
|
|
91
|
+
* ... // Handle Bip44DeriveIndexRange case.
|
|
92
|
+
* }
|
|
93
|
+
* ...
|
|
94
|
+
* return accounts;
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param options - The create account option object to check.
|
|
99
|
+
* @param supportedTypes - The list of supported create account option types for this keyring.
|
|
100
|
+
* @throws Will throw an error if the provided options are not supported.
|
|
101
|
+
*/
|
|
102
|
+
export function assertCreateAccountOptionIsSupported(options, supportedTypes) {
|
|
103
|
+
const { type } = options;
|
|
104
|
+
const types = supportedTypes;
|
|
105
|
+
if (!types.includes(type)) {
|
|
106
|
+
throw new Error(`Unsupported create account option type: ${type}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
55
109
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gCAAgC;AAGzD,OAAO,EACL,uCAAuC,EACvC,0CAA0C,EAC1C,yCAAyC,EAC1C,oBAAgB;AACjB,OAAO,EAAE,oCAAoC,EAAE,0BAAsB;AAErE,4BAAwB;AACxB,kCAA8B;AAE9B;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gCAAgC;AAGzD,OAAO,EACL,uCAAuC,EACvC,0CAA0C,EAC1C,+CAA+C,EAC/C,yCAAyC,EAC1C,oBAAgB;AACjB,OAAO,EAAE,gCAAgC,EAAE,qBAAiB;AAC5D,OAAO,EAAE,oCAAoC,EAAE,0BAAsB;AAErE,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,MAAM,CAAN,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,KAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,yCAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,0CAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,+CAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,uCAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,oCAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,gCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,yCAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,oCAAoC,CAKlD,OAAgB,EAChB,cAAoC;IAGpC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,KAAK,GAA4C,cAAc,CAAC;IAEtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n\n/**\n * Asserts that a given create account option type is supported by the keyring.\n *\n * @example\n * ```ts\n * createAccounts(options: CreateAccountOptions) {\n * assertCreateAccountOptionIsSupported(options, [\n * ${AccountCreationType.Bip44DeriveIndex},\n * ${AccountCreationType.Bip44DeriveIndexRange},\n * ] as const);\n *\n * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.\n * if (options.type === AccountCreationType.Bip44DeriveIndex) {\n * ... // Handle Bip44DeriveIndex case.\n * } else {\n * ... // Handle Bip44DeriveIndexRange case.\n * }\n * ...\n * return accounts;\n * }\n * ```\n *\n * @param options - The create account option object to check.\n * @param supportedTypes - The list of supported create account option types for this keyring.\n * @throws Will throw an error if the provided options are not supported.\n */\nexport function assertCreateAccountOptionIsSupported<\n Options extends CreateAccountOptions,\n // We use template literal types to enforce string-literal over strict enum values.\n Type extends `${CreateAccountOptions['type']}`,\n>(\n options: Options,\n supportedTypes: readonly `${Type}`[],\n // Use intersection to avoid widening `type` beyond `Options['type']`.\n): asserts options is Options & { type: `${Type}` & `${Options['type']}` } {\n const { type } = options;\n const types: readonly CreateAccountOptions['type'][] = supportedTypes;\n\n if (!types.includes(type)) {\n throw new Error(`Unsupported create account option type: ${type}`);\n }\n}\n"]}
|
package/dist/api/v2/index.cjs
CHANGED
|
@@ -19,4 +19,5 @@ __exportStar(require("./keyring-type.cjs"), exports);
|
|
|
19
19
|
__exportStar(require("./create-account/index.cjs"), exports);
|
|
20
20
|
__exportStar(require("./export-account/index.cjs"), exports);
|
|
21
21
|
__exportStar(require("./private-key.cjs"), exports);
|
|
22
|
+
__exportStar(require("./wrapper/index.cjs"), exports);
|
|
22
23
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6DAAuC;AACvC,qDAA+B;AAC/B,6DAAiC;AACjC,6DAAiC;AACjC,oDAA8B","sourcesContent":["export type * from './keyring';\nexport * from './keyring-capabilities';\nexport * from './keyring-type';\nexport * from './create-account';\nexport * from './export-account';\nexport * from './private-key';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,6DAAuC;AACvC,qDAA+B;AAC/B,6DAAiC;AACjC,6DAAiC;AACjC,oDAA8B;AAC9B,sDAA0B","sourcesContent":["export type * from './keyring';\nexport * from './keyring-capabilities';\nexport * from './keyring-type';\nexport * from './create-account';\nexport * from './export-account';\nexport * from './private-key';\nexport * from './wrapper';\n"]}
|
package/dist/api/v2/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":"AAAA,mCAA+B;AAC/B,2CAAuC;AACvC,mCAA+B;AAC/B,2CAAiC;AACjC,2CAAiC;AACjC,kCAA8B"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":"AAAA,mCAA+B;AAC/B,2CAAuC;AACvC,mCAA+B;AAC/B,2CAAiC;AACjC,2CAAiC;AACjC,kCAA8B;AAC9B,oCAA0B"}
|
package/dist/api/v2/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":"AAAA,mCAA+B;AAC/B,2CAAuC;AACvC,mCAA+B;AAC/B,2CAAiC;AACjC,2CAAiC;AACjC,kCAA8B"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":"AAAA,mCAA+B;AAC/B,2CAAuC;AACvC,mCAA+B;AAC/B,2CAAiC;AACjC,2CAAiC;AACjC,kCAA8B;AAC9B,oCAA0B"}
|
package/dist/api/v2/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":"AACA,2CAAuC;AACvC,mCAA+B;AAC/B,2CAAiC;AACjC,2CAAiC;AACjC,kCAA8B","sourcesContent":["export type * from './keyring';\nexport * from './keyring-capabilities';\nexport * from './keyring-type';\nexport * from './create-account';\nexport * from './export-account';\nexport * from './private-key';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/api/v2/index.ts"],"names":[],"mappings":"AACA,2CAAuC;AACvC,mCAA+B;AAC/B,2CAAiC;AACjC,2CAAiC;AACjC,kCAA8B;AAC9B,oCAA0B","sourcesContent":["export type * from './keyring';\nexport * from './keyring-capabilities';\nexport * from './keyring-type';\nexport * from './create-account';\nexport * from './export-account';\nexport * from './private-key';\nexport * from './wrapper';\n"]}
|
|
@@ -19,15 +19,19 @@ exports.KeyringCapabilitiesStruct = (0, superstruct_1.object)({
|
|
|
19
19
|
/**
|
|
20
20
|
* Whether the keyring supports deriving accounts from a specific BIP-44 path.
|
|
21
21
|
*/
|
|
22
|
-
derivePath: (0, superstruct_1.boolean)(),
|
|
22
|
+
derivePath: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
|
|
23
23
|
/**
|
|
24
24
|
* Whether the keyring supports deriving accounts from a BIP-44 account index.
|
|
25
25
|
*/
|
|
26
|
-
deriveIndex: (0, superstruct_1.boolean)(),
|
|
26
|
+
deriveIndex: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
|
|
27
|
+
/**
|
|
28
|
+
* Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
|
|
29
|
+
*/
|
|
30
|
+
deriveIndexRange: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
|
|
27
31
|
/**
|
|
28
32
|
* Whether the keyring supports BIP-44 account discovery.
|
|
29
33
|
*/
|
|
30
|
-
discover: (0, superstruct_1.boolean)(),
|
|
34
|
+
discover: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
|
|
31
35
|
})),
|
|
32
36
|
/**
|
|
33
37
|
* Private key capabilities supported by this keyring.
|
|
@@ -42,5 +46,15 @@ exports.KeyringCapabilitiesStruct = (0, superstruct_1.object)({
|
|
|
42
46
|
*/
|
|
43
47
|
exportFormats: (0, superstruct_1.exactOptional)((0, superstruct_1.array)(private_key_1.ExportPrivateKeyFormatStruct)),
|
|
44
48
|
})),
|
|
49
|
+
/**
|
|
50
|
+
* Indicates which KeyringV2 methods accept non-standard options.
|
|
51
|
+
*
|
|
52
|
+
* When a method is set to `true`, it signals that the keyring implementation
|
|
53
|
+
* accepts custom options for that method, different from the standard API.
|
|
54
|
+
* This is a workaround for keyrings with very specific requirements.
|
|
55
|
+
*/
|
|
56
|
+
custom: (0, superstruct_1.exactOptional)((0, superstruct_1.partial)((0, superstruct_1.object)({
|
|
57
|
+
createAccounts: (0, superstruct_1.boolean)(),
|
|
58
|
+
}))),
|
|
45
59
|
});
|
|
46
60
|
//# sourceMappingURL=keyring-capabilities.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,uDAQ+B;AAE/B,mDAGuB;AACvB,sCAA4C;AAE5C;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,IAAA,2BAAa,EAClB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,UAAU,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACpC;;WAEG;QACH,WAAW,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACrC;;WAEG;QACH,gBAAgB,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QAC1C;;WAEG;QACH,QAAQ,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KACnC,CAAC,CACH;IACD;;OAEG;IACH,UAAU,EAAE,IAAA,2BAAa,EACvB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;QACjE;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;KAClE,CAAC,CACH;IACD;;;;;;OAMG;IACH,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,qBAAO,EACL,IAAA,oBAAM,EAAC;QACL,cAAc,EAAE,IAAA,qBAAO,GAAE;KAC1B,CAAC,CACH,CACF;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n exactOptional,\n nonempty,\n object,\n partial,\n type Infer,\n} from '@metamask/superstruct';\n\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\nimport { CaipChainIdStruct } from '../caip';\n\n/**\n * Struct for {@link KeyringCapabilities}.\n */\nexport const KeyringCapabilitiesStruct = object({\n /**\n * List of CAIP-2 chain IDs that this keyring supports.\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n /**\n * BIP-44 capabilities supported by this keyring.\n */\n bip44: exactOptional(\n object({\n /**\n * Whether the keyring supports deriving accounts from a specific BIP-44 path.\n */\n derivePath: exactOptional(boolean()),\n /**\n * Whether the keyring supports deriving accounts from a BIP-44 account index.\n */\n deriveIndex: exactOptional(boolean()),\n /**\n * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.\n */\n deriveIndexRange: exactOptional(boolean()),\n /**\n * Whether the keyring supports BIP-44 account discovery.\n */\n discover: exactOptional(boolean()),\n }),\n ),\n /**\n * Private key capabilities supported by this keyring.\n */\n privateKey: exactOptional(\n object({\n /**\n * List of supported formats for importing private keys.\n */\n importFormats: exactOptional(array(ImportPrivateKeyFormatStruct)),\n /**\n * List of supported formats for exporting private keys.\n */\n exportFormats: exactOptional(array(ExportPrivateKeyFormatStruct)),\n }),\n ),\n /**\n * Indicates which KeyringV2 methods accept non-standard options.\n *\n * When a method is set to `true`, it signals that the keyring implementation\n * accepts custom options for that method, different from the standard API.\n * This is a workaround for keyrings with very specific requirements.\n */\n custom: exactOptional(\n partial(\n object({\n createAccounts: boolean(),\n }),\n ),\n ),\n});\n\n/**\n * Type representing the capabilities supported by a keyring.\n *\n * @example\n * ```ts\n * const capabilities: KeyringCapabilities = {\n * scopes: ['bip122:_'],\n * bip44: {\n * derivePath: true,\n * deriveIndex: true,\n * deriveIndexRange: true,\n * discover: true,\n * },\n * privateKey: {\n * importFormats: [\n * { encoding: 'base58', type: 'bip122:p2sh' },\n * { encoding: 'base58', type: 'bip122:p2tr' },\n * { encoding: 'base58', type: 'bip122:p2pkh' },\n * { encoding: 'base58', type: 'bip122:p2wpkh' },\n * ],\n * exportFormats: [\n * { encoding: 'base58' },\n * { encoding: 'base58' },\n * ],\n * },\n * };\n * ```\n */\nexport type KeyringCapabilities = Infer<typeof KeyringCapabilitiesStruct>;\n"]}
|
|
@@ -4,10 +4,14 @@ import { type Infer } from "@metamask/superstruct";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").Struct<{
|
|
6
6
|
scopes: `${string}:${string}`[];
|
|
7
|
+
custom?: {
|
|
8
|
+
createAccounts?: boolean | undefined;
|
|
9
|
+
};
|
|
7
10
|
bip44?: {
|
|
8
|
-
derivePath
|
|
9
|
-
deriveIndex
|
|
10
|
-
|
|
11
|
+
derivePath?: boolean;
|
|
12
|
+
deriveIndex?: boolean;
|
|
13
|
+
deriveIndexRange?: boolean;
|
|
14
|
+
discover?: boolean;
|
|
11
15
|
};
|
|
12
16
|
privateKey?: {
|
|
13
17
|
importFormats?: {
|
|
@@ -27,22 +31,27 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
|
|
|
27
31
|
* BIP-44 capabilities supported by this keyring.
|
|
28
32
|
*/
|
|
29
33
|
bip44: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
30
|
-
derivePath
|
|
31
|
-
deriveIndex
|
|
32
|
-
|
|
34
|
+
derivePath?: boolean;
|
|
35
|
+
deriveIndex?: boolean;
|
|
36
|
+
deriveIndexRange?: boolean;
|
|
37
|
+
discover?: boolean;
|
|
33
38
|
}, {
|
|
34
39
|
/**
|
|
35
40
|
* Whether the keyring supports deriving accounts from a specific BIP-44 path.
|
|
36
41
|
*/
|
|
37
|
-
derivePath: import("@metamask/superstruct").
|
|
42
|
+
derivePath: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
38
43
|
/**
|
|
39
44
|
* Whether the keyring supports deriving accounts from a BIP-44 account index.
|
|
40
45
|
*/
|
|
41
|
-
deriveIndex: import("@metamask/superstruct").
|
|
46
|
+
deriveIndex: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
|
|
49
|
+
*/
|
|
50
|
+
deriveIndexRange: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
42
51
|
/**
|
|
43
52
|
* Whether the keyring supports BIP-44 account discovery.
|
|
44
53
|
*/
|
|
45
|
-
discover: import("@metamask/superstruct").
|
|
54
|
+
discover: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
46
55
|
}>;
|
|
47
56
|
/**
|
|
48
57
|
* Private key capabilities supported by this keyring.
|
|
@@ -96,6 +105,18 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
|
|
|
96
105
|
}>;
|
|
97
106
|
}>>;
|
|
98
107
|
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Indicates which KeyringV2 methods accept non-standard options.
|
|
110
|
+
*
|
|
111
|
+
* When a method is set to `true`, it signals that the keyring implementation
|
|
112
|
+
* accepts custom options for that method, different from the standard API.
|
|
113
|
+
* This is a workaround for keyrings with very specific requirements.
|
|
114
|
+
*/
|
|
115
|
+
custom: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
116
|
+
createAccounts?: boolean | undefined;
|
|
117
|
+
}, import("@metamask/superstruct").PartialObjectSchema<{
|
|
118
|
+
createAccounts: import("@metamask/superstruct").Struct<boolean, null>;
|
|
119
|
+
}>>;
|
|
99
120
|
}>;
|
|
100
121
|
/**
|
|
101
122
|
* Type representing the capabilities supported by a keyring.
|
|
@@ -107,6 +128,7 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
|
|
|
107
128
|
* bip44: {
|
|
108
129
|
* derivePath: true,
|
|
109
130
|
* deriveIndex: true,
|
|
131
|
+
* deriveIndexRange: true,
|
|
110
132
|
* discover: true,
|
|
111
133
|
* },
|
|
112
134
|
* privateKey: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-capabilities.d.cts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"keyring-capabilities.d.cts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EACX,8BAA8B;AAQ/B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;IACpC;;OAEG;;IAEH;;OAEG;;;;;;;QAGC;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;;IAIP;;OAEG;;;;;;;;;;QAGC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;QAEH;;WAEG;;;;;;;;;;;;IAIP;;;;;;OAMG;;;;;;EAQH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -4,10 +4,14 @@ import { type Infer } from "@metamask/superstruct";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").Struct<{
|
|
6
6
|
scopes: `${string}:${string}`[];
|
|
7
|
+
custom?: {
|
|
8
|
+
createAccounts?: boolean | undefined;
|
|
9
|
+
};
|
|
7
10
|
bip44?: {
|
|
8
|
-
derivePath
|
|
9
|
-
deriveIndex
|
|
10
|
-
|
|
11
|
+
derivePath?: boolean;
|
|
12
|
+
deriveIndex?: boolean;
|
|
13
|
+
deriveIndexRange?: boolean;
|
|
14
|
+
discover?: boolean;
|
|
11
15
|
};
|
|
12
16
|
privateKey?: {
|
|
13
17
|
importFormats?: {
|
|
@@ -27,22 +31,27 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
|
|
|
27
31
|
* BIP-44 capabilities supported by this keyring.
|
|
28
32
|
*/
|
|
29
33
|
bip44: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
30
|
-
derivePath
|
|
31
|
-
deriveIndex
|
|
32
|
-
|
|
34
|
+
derivePath?: boolean;
|
|
35
|
+
deriveIndex?: boolean;
|
|
36
|
+
deriveIndexRange?: boolean;
|
|
37
|
+
discover?: boolean;
|
|
33
38
|
}, {
|
|
34
39
|
/**
|
|
35
40
|
* Whether the keyring supports deriving accounts from a specific BIP-44 path.
|
|
36
41
|
*/
|
|
37
|
-
derivePath: import("@metamask/superstruct").
|
|
42
|
+
derivePath: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
38
43
|
/**
|
|
39
44
|
* Whether the keyring supports deriving accounts from a BIP-44 account index.
|
|
40
45
|
*/
|
|
41
|
-
deriveIndex: import("@metamask/superstruct").
|
|
46
|
+
deriveIndex: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
|
|
49
|
+
*/
|
|
50
|
+
deriveIndexRange: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
42
51
|
/**
|
|
43
52
|
* Whether the keyring supports BIP-44 account discovery.
|
|
44
53
|
*/
|
|
45
|
-
discover: import("@metamask/superstruct").
|
|
54
|
+
discover: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
|
|
46
55
|
}>;
|
|
47
56
|
/**
|
|
48
57
|
* Private key capabilities supported by this keyring.
|
|
@@ -96,6 +105,18 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
|
|
|
96
105
|
}>;
|
|
97
106
|
}>>;
|
|
98
107
|
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Indicates which KeyringV2 methods accept non-standard options.
|
|
110
|
+
*
|
|
111
|
+
* When a method is set to `true`, it signals that the keyring implementation
|
|
112
|
+
* accepts custom options for that method, different from the standard API.
|
|
113
|
+
* This is a workaround for keyrings with very specific requirements.
|
|
114
|
+
*/
|
|
115
|
+
custom: import("@metamask/superstruct").ExactOptionalStruct<{
|
|
116
|
+
createAccounts?: boolean | undefined;
|
|
117
|
+
}, import("@metamask/superstruct").PartialObjectSchema<{
|
|
118
|
+
createAccounts: import("@metamask/superstruct").Struct<boolean, null>;
|
|
119
|
+
}>>;
|
|
99
120
|
}>;
|
|
100
121
|
/**
|
|
101
122
|
* Type representing the capabilities supported by a keyring.
|
|
@@ -107,6 +128,7 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
|
|
|
107
128
|
* bip44: {
|
|
108
129
|
* derivePath: true,
|
|
109
130
|
* deriveIndex: true,
|
|
131
|
+
* deriveIndexRange: true,
|
|
110
132
|
* discover: true,
|
|
111
133
|
* },
|
|
112
134
|
* privateKey: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyring-capabilities.d.mts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"keyring-capabilities.d.mts","sourceRoot":"","sources":["../../../src/api/v2/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EACX,8BAA8B;AAQ/B;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;IACpC;;OAEG;;IAEH;;OAEG;;;;;;;QAGC;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;;IAIP;;OAEG;;;;;;;;;;QAGC;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;QAEH;;WAEG;;;;;;;;;;;;IAIP;;;;;;OAMG;;;;;;EAQH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { array, boolean, exactOptional, nonempty, object } from "@metamask/superstruct";
|
|
1
|
+
import { array, boolean, exactOptional, nonempty, object, partial } from "@metamask/superstruct";
|
|
2
2
|
import { ExportPrivateKeyFormatStruct, ImportPrivateKeyFormatStruct } from "./private-key.mjs";
|
|
3
3
|
import { CaipChainIdStruct } from "../caip.mjs";
|
|
4
4
|
/**
|
|
@@ -16,15 +16,19 @@ export const KeyringCapabilitiesStruct = object({
|
|
|
16
16
|
/**
|
|
17
17
|
* Whether the keyring supports deriving accounts from a specific BIP-44 path.
|
|
18
18
|
*/
|
|
19
|
-
derivePath: boolean(),
|
|
19
|
+
derivePath: exactOptional(boolean()),
|
|
20
20
|
/**
|
|
21
21
|
* Whether the keyring supports deriving accounts from a BIP-44 account index.
|
|
22
22
|
*/
|
|
23
|
-
deriveIndex: boolean(),
|
|
23
|
+
deriveIndex: exactOptional(boolean()),
|
|
24
|
+
/**
|
|
25
|
+
* Whether the keyring supports deriving accounts from a range of BIP-44 account indices.
|
|
26
|
+
*/
|
|
27
|
+
deriveIndexRange: exactOptional(boolean()),
|
|
24
28
|
/**
|
|
25
29
|
* Whether the keyring supports BIP-44 account discovery.
|
|
26
30
|
*/
|
|
27
|
-
discover: boolean(),
|
|
31
|
+
discover: exactOptional(boolean()),
|
|
28
32
|
})),
|
|
29
33
|
/**
|
|
30
34
|
* Private key capabilities supported by this keyring.
|
|
@@ -39,5 +43,15 @@ export const KeyringCapabilitiesStruct = object({
|
|
|
39
43
|
*/
|
|
40
44
|
exportFormats: exactOptional(array(ExportPrivateKeyFormatStruct)),
|
|
41
45
|
})),
|
|
46
|
+
/**
|
|
47
|
+
* Indicates which KeyringV2 methods accept non-standard options.
|
|
48
|
+
*
|
|
49
|
+
* When a method is set to `true`, it signals that the keyring implementation
|
|
50
|
+
* accepts custom options for that method, different from the standard API.
|
|
51
|
+
* This is a workaround for keyrings with very specific requirements.
|
|
52
|
+
*/
|
|
53
|
+
custom: exactOptional(partial(object({
|
|
54
|
+
createAccounts: boolean(),
|
|
55
|
+
}))),
|
|
42
56
|
});
|
|
43
57
|
//# sourceMappingURL=keyring-capabilities.mjs.map
|