@metamask/keyring-api 23.2.0 → 23.4.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/api/transaction.cjs +19 -3
  3. package/dist/api/transaction.cjs.map +1 -1
  4. package/dist/api/transaction.d.cts +44 -12
  5. package/dist/api/transaction.d.cts.map +1 -1
  6. package/dist/api/transaction.d.mts +44 -12
  7. package/dist/api/transaction.d.mts.map +1 -1
  8. package/dist/api/transaction.mjs +19 -3
  9. package/dist/api/transaction.mjs.map +1 -1
  10. package/dist/events.d.cts +6 -3
  11. package/dist/events.d.cts.map +1 -1
  12. package/dist/events.d.mts +6 -3
  13. package/dist/events.d.mts.map +1 -1
  14. package/dist/rpc.cjs.map +1 -1
  15. package/dist/rpc.d.cts +83 -41
  16. package/dist/rpc.d.cts.map +1 -1
  17. package/dist/rpc.d.mts +83 -41
  18. package/dist/rpc.d.mts.map +1 -1
  19. package/dist/rpc.mjs.map +1 -1
  20. package/dist/v2/api/index.cjs +1 -0
  21. package/dist/v2/api/index.cjs.map +1 -1
  22. package/dist/v2/api/index.d.cts +1 -0
  23. package/dist/v2/api/index.d.cts.map +1 -1
  24. package/dist/v2/api/index.d.mts +1 -0
  25. package/dist/v2/api/index.d.mts.map +1 -1
  26. package/dist/v2/api/index.mjs +1 -0
  27. package/dist/v2/api/index.mjs.map +1 -1
  28. package/dist/v2/api/keyring-capabilities.cjs +32 -0
  29. package/dist/v2/api/keyring-capabilities.cjs.map +1 -1
  30. package/dist/v2/api/keyring-capabilities.d.cts +50 -0
  31. package/dist/v2/api/keyring-capabilities.d.cts.map +1 -1
  32. package/dist/v2/api/keyring-capabilities.d.mts +50 -0
  33. package/dist/v2/api/keyring-capabilities.d.mts.map +1 -1
  34. package/dist/v2/api/keyring-capabilities.mjs +32 -0
  35. package/dist/v2/api/keyring-capabilities.mjs.map +1 -1
  36. package/dist/v2/api/keyring-snap-rpc.cjs +79 -0
  37. package/dist/v2/api/keyring-snap-rpc.cjs.map +1 -0
  38. package/dist/v2/api/keyring-snap-rpc.d.cts +491 -0
  39. package/dist/v2/api/keyring-snap-rpc.d.cts.map +1 -0
  40. package/dist/v2/api/keyring-snap-rpc.d.mts +491 -0
  41. package/dist/v2/api/keyring-snap-rpc.d.mts.map +1 -0
  42. package/dist/v2/api/keyring-snap-rpc.mjs +75 -0
  43. package/dist/v2/api/keyring-snap-rpc.mjs.map +1 -0
  44. package/package.json +1 -1
@@ -56,5 +56,37 @@ exports.KeyringCapabilitiesStruct = (0, superstruct_1.object)({
56
56
  custom: (0, superstruct_1.exactOptional)((0, superstruct_1.partial)((0, superstruct_1.object)({
57
57
  createAccounts: (0, superstruct_1.boolean)(),
58
58
  }))),
59
+ /**
60
+ * Snap-specific capabilities supported by this keyring.
61
+ *
62
+ * Each flag maps to a Snap keyring RPC method that the Snap implements.
63
+ */
64
+ snap: (0, superstruct_1.exactOptional)((0, superstruct_1.object)({
65
+ /**
66
+ * Asset-related capabilities.
67
+ */
68
+ assets: (0, superstruct_1.exactOptional)((0, superstruct_1.object)({
69
+ /**
70
+ * Whether the keyring supports getting account assets
71
+ * (`keyring_getAccountAssets`).
72
+ */
73
+ metadata: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
74
+ /**
75
+ * Whether the keyring supports getting account balances
76
+ * (`keyring_getAccountBalances`).
77
+ */
78
+ balances: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
79
+ })),
80
+ /**
81
+ * Whether the keyring supports getting account transactions
82
+ * (`keyring_getAccountTransactions`).
83
+ */
84
+ transactions: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
85
+ /**
86
+ * Whether the keyring supports receiving selected accounts notifications
87
+ * (`keyring_setSelectedAccounts`).
88
+ */
89
+ selectedAccounts: (0, superstruct_1.exactOptional)((0, superstruct_1.boolean)()),
90
+ })),
59
91
  });
60
92
  //# sourceMappingURL=keyring-capabilities.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAG/B,6CAAmD;AACnD,mDAGuB;AAEvB;;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} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { CaipChainIdStruct } from '../../api/caip';\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\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 Keyring 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"]}
1
+ {"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAG/B,6CAAmD;AACnD,mDAGuB;AAEvB;;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;IACD;;;;OAIG;IACH,IAAI,EAAE,IAAA,2BAAa,EACjB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,oBAAM,EAAC;YACL;;;eAGG;YACH,QAAQ,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;YAClC;;;eAGG;YACH,QAAQ,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;SACnC,CAAC,CACH;QACD;;;WAGG;QACH,YAAY,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACtC;;;WAGG;QACH,gBAAgB,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KAC3C,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n exactOptional,\n nonempty,\n object,\n partial,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { CaipChainIdStruct } from '../../api/caip';\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\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 Keyring 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 * Snap-specific capabilities supported by this keyring.\n *\n * Each flag maps to a Snap keyring RPC method that the Snap implements.\n */\n snap: exactOptional(\n object({\n /**\n * Asset-related capabilities.\n */\n assets: exactOptional(\n object({\n /**\n * Whether the keyring supports getting account assets\n * (`keyring_getAccountAssets`).\n */\n metadata: exactOptional(boolean()),\n /**\n * Whether the keyring supports getting account balances\n * (`keyring_getAccountBalances`).\n */\n balances: exactOptional(boolean()),\n }),\n ),\n /**\n * Whether the keyring supports getting account transactions\n * (`keyring_getAccountTransactions`).\n */\n transactions: exactOptional(boolean()),\n /**\n * Whether the keyring supports receiving selected accounts notifications\n * (`keyring_setSelectedAccounts`).\n */\n selectedAccounts: exactOptional(boolean()),\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"]}
@@ -22,6 +22,14 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
22
22
  encoding: "hexadecimal" | "base58";
23
23
  }[];
24
24
  };
25
+ snap?: {
26
+ assets?: {
27
+ metadata?: boolean;
28
+ balances?: boolean;
29
+ };
30
+ transactions?: boolean;
31
+ selectedAccounts?: boolean;
32
+ };
25
33
  }, {
26
34
  /**
27
35
  * List of CAIP-2 chain IDs that this keyring supports.
@@ -118,6 +126,48 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
118
126
  }, import("@metamask/superstruct").PartialObjectSchema<{
119
127
  createAccounts: import("@metamask/superstruct").Struct<boolean, null>;
120
128
  }>>;
129
+ /**
130
+ * Snap-specific capabilities supported by this keyring.
131
+ *
132
+ * Each flag maps to a Snap keyring RPC method that the Snap implements.
133
+ */
134
+ snap: import("@metamask/superstruct").ExactOptionalStruct<{
135
+ assets?: {
136
+ metadata?: boolean;
137
+ balances?: boolean;
138
+ };
139
+ transactions?: boolean;
140
+ selectedAccounts?: boolean;
141
+ }, {
142
+ /**
143
+ * Asset-related capabilities.
144
+ */
145
+ assets: import("@metamask/superstruct").ExactOptionalStruct<{
146
+ metadata?: boolean;
147
+ balances?: boolean;
148
+ }, {
149
+ /**
150
+ * Whether the keyring supports getting account assets
151
+ * (`keyring_getAccountAssets`).
152
+ */
153
+ metadata: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
154
+ /**
155
+ * Whether the keyring supports getting account balances
156
+ * (`keyring_getAccountBalances`).
157
+ */
158
+ balances: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
159
+ }>;
160
+ /**
161
+ * Whether the keyring supports getting account transactions
162
+ * (`keyring_getAccountTransactions`).
163
+ */
164
+ transactions: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
165
+ /**
166
+ * Whether the keyring supports receiving selected accounts notifications
167
+ * (`keyring_setSelectedAccounts`).
168
+ */
169
+ selectedAccounts: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
170
+ }>;
121
171
  }>;
122
172
  /**
123
173
  * Type representing the capabilities supported by a keyring.
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.d.cts","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAQnD;;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
+ {"version":3,"file":"keyring-capabilities.d.cts","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAQnD;;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;;;;;;IAQH;;;;OAIG;;;;;;;;;QAGC;;WAEG;;;;;YAGC;;;eAGG;;YAEH;;;eAGG;;;QAIP;;;WAGG;;QAEH;;;WAGG;;;EAIP,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -22,6 +22,14 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
22
22
  encoding: "hexadecimal" | "base58";
23
23
  }[];
24
24
  };
25
+ snap?: {
26
+ assets?: {
27
+ metadata?: boolean;
28
+ balances?: boolean;
29
+ };
30
+ transactions?: boolean;
31
+ selectedAccounts?: boolean;
32
+ };
25
33
  }, {
26
34
  /**
27
35
  * List of CAIP-2 chain IDs that this keyring supports.
@@ -118,6 +126,48 @@ export declare const KeyringCapabilitiesStruct: import("@metamask/superstruct").
118
126
  }, import("@metamask/superstruct").PartialObjectSchema<{
119
127
  createAccounts: import("@metamask/superstruct").Struct<boolean, null>;
120
128
  }>>;
129
+ /**
130
+ * Snap-specific capabilities supported by this keyring.
131
+ *
132
+ * Each flag maps to a Snap keyring RPC method that the Snap implements.
133
+ */
134
+ snap: import("@metamask/superstruct").ExactOptionalStruct<{
135
+ assets?: {
136
+ metadata?: boolean;
137
+ balances?: boolean;
138
+ };
139
+ transactions?: boolean;
140
+ selectedAccounts?: boolean;
141
+ }, {
142
+ /**
143
+ * Asset-related capabilities.
144
+ */
145
+ assets: import("@metamask/superstruct").ExactOptionalStruct<{
146
+ metadata?: boolean;
147
+ balances?: boolean;
148
+ }, {
149
+ /**
150
+ * Whether the keyring supports getting account assets
151
+ * (`keyring_getAccountAssets`).
152
+ */
153
+ metadata: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
154
+ /**
155
+ * Whether the keyring supports getting account balances
156
+ * (`keyring_getAccountBalances`).
157
+ */
158
+ balances: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
159
+ }>;
160
+ /**
161
+ * Whether the keyring supports getting account transactions
162
+ * (`keyring_getAccountTransactions`).
163
+ */
164
+ transactions: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
165
+ /**
166
+ * Whether the keyring supports receiving selected accounts notifications
167
+ * (`keyring_setSelectedAccounts`).
168
+ */
169
+ selectedAccounts: import("@metamask/superstruct").ExactOptionalStruct<boolean, null>;
170
+ }>;
121
171
  }>;
122
172
  /**
123
173
  * Type representing the capabilities supported by a keyring.
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.d.mts","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAQnD;;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
+ {"version":3,"file":"keyring-capabilities.d.mts","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAQnD;;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;;;;;;IAQH;;;;OAIG;;;;;;;;;QAGC;;WAEG;;;;;YAGC;;;eAGG;;YAEH;;;eAGG;;;QAIP;;;WAGG;;QAEH;;;WAGG;;;EAIP,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -53,5 +53,37 @@ export const KeyringCapabilitiesStruct = object({
53
53
  custom: exactOptional(partial(object({
54
54
  createAccounts: boolean(),
55
55
  }))),
56
+ /**
57
+ * Snap-specific capabilities supported by this keyring.
58
+ *
59
+ * Each flag maps to a Snap keyring RPC method that the Snap implements.
60
+ */
61
+ snap: exactOptional(object({
62
+ /**
63
+ * Asset-related capabilities.
64
+ */
65
+ assets: exactOptional(object({
66
+ /**
67
+ * Whether the keyring supports getting account assets
68
+ * (`keyring_getAccountAssets`).
69
+ */
70
+ metadata: exactOptional(boolean()),
71
+ /**
72
+ * Whether the keyring supports getting account balances
73
+ * (`keyring_getAccountBalances`).
74
+ */
75
+ balances: exactOptional(boolean()),
76
+ })),
77
+ /**
78
+ * Whether the keyring supports getting account transactions
79
+ * (`keyring_getAccountTransactions`).
80
+ */
81
+ transactions: exactOptional(boolean()),
82
+ /**
83
+ * Whether the keyring supports receiving selected accounts notifications
84
+ * (`keyring_setSelectedAccounts`).
85
+ */
86
+ selectedAccounts: exactOptional(boolean()),
87
+ })),
56
88
  });
57
89
  //# sourceMappingURL=keyring-capabilities.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyring-capabilities.mjs","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,MAAM,EACN,OAAO,EACR,8BAA8B;AAG/B,OAAO,EAAE,iBAAiB,EAAE,2BAAuB;AACnD,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC7B,0BAAsB;AAEvB;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAC9C;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,aAAa,CAClB,MAAM,CAAC;QACL;;WAEG;QACH,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QACpC;;WAEG;QACH,WAAW,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QACrC;;WAEG;QACH,gBAAgB,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1C;;WAEG;QACH,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KACnC,CAAC,CACH;IACD;;OAEG;IACH,UAAU,EAAE,aAAa,CACvB,MAAM,CAAC;QACL;;WAEG;QACH,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACjE;;WAEG;QACH,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAClE,CAAC,CACH;IACD;;;;;;OAMG;IACH,MAAM,EAAE,aAAa,CACnB,OAAO,CACL,MAAM,CAAC;QACL,cAAc,EAAE,OAAO,EAAE;KAC1B,CAAC,CACH,CACF;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n exactOptional,\n nonempty,\n object,\n partial,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { CaipChainIdStruct } from '../../api/caip';\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\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 Keyring 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"]}
1
+ {"version":3,"file":"keyring-capabilities.mjs","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,MAAM,EACN,OAAO,EACR,8BAA8B;AAG/B,OAAO,EAAE,iBAAiB,EAAE,2BAAuB;AACnD,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC7B,0BAAsB;AAEvB;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAC9C;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,aAAa,CAClB,MAAM,CAAC;QACL;;WAEG;QACH,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QACpC;;WAEG;QACH,WAAW,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QACrC;;WAEG;QACH,gBAAgB,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1C;;WAEG;QACH,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KACnC,CAAC,CACH;IACD;;OAEG;IACH,UAAU,EAAE,aAAa,CACvB,MAAM,CAAC;QACL;;WAEG;QACH,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACjE;;WAEG;QACH,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;KAClE,CAAC,CACH;IACD;;;;;;OAMG;IACH,MAAM,EAAE,aAAa,CACnB,OAAO,CACL,MAAM,CAAC;QACL,cAAc,EAAE,OAAO,EAAE;KAC1B,CAAC,CACH,CACF;IACD;;;;OAIG;IACH,IAAI,EAAE,aAAa,CACjB,MAAM,CAAC;QACL;;WAEG;QACH,MAAM,EAAE,aAAa,CACnB,MAAM,CAAC;YACL;;;eAGG;YACH,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;YAClC;;;eAGG;YACH,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;SACnC,CAAC,CACH;QACD;;;WAGG;QACH,YAAY,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;QACtC;;;WAGG;QACH,gBAAgB,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KAC3C,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n boolean,\n exactOptional,\n nonempty,\n object,\n partial,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { CaipChainIdStruct } from '../../api/caip';\nimport {\n ExportPrivateKeyFormatStruct,\n ImportPrivateKeyFormatStruct,\n} from './private-key';\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 Keyring 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 * Snap-specific capabilities supported by this keyring.\n *\n * Each flag maps to a Snap keyring RPC method that the Snap implements.\n */\n snap: exactOptional(\n object({\n /**\n * Asset-related capabilities.\n */\n assets: exactOptional(\n object({\n /**\n * Whether the keyring supports getting account assets\n * (`keyring_getAccountAssets`).\n */\n metadata: exactOptional(boolean()),\n /**\n * Whether the keyring supports getting account balances\n * (`keyring_getAccountBalances`).\n */\n balances: exactOptional(boolean()),\n }),\n ),\n /**\n * Whether the keyring supports getting account transactions\n * (`keyring_getAccountTransactions`).\n */\n transactions: exactOptional(boolean()),\n /**\n * Whether the keyring supports receiving selected accounts notifications\n * (`keyring_setSelectedAccounts`).\n */\n selectedAccounts: exactOptional(boolean()),\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"]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAccountBalancesResponseStruct = exports.GetAccountBalancesRequestStruct = exports.GetAccountAssetsResponseStruct = exports.GetAccountAssetsRequestStruct = exports.GetAccountTransactionsResponseStruct = exports.GetAccountTransactionsRequestStruct = exports.SetSelectedAccountsResponseStruct = exports.SetSelectedAccountsRequestStruct = exports.isKeyringSnapRpcMethod = exports.KeyringSnapRpcMethod = void 0;
4
+ const keyring_utils_1 = require("@metamask/keyring-utils");
5
+ const superstruct_1 = require("@metamask/superstruct");
6
+ const balance_1 = require("../../api/balance.cjs");
7
+ const caip_1 = require("../../api/caip.cjs");
8
+ const pagination_1 = require("../../api/pagination.cjs");
9
+ const transaction_1 = require("../../api/transaction.cjs");
10
+ const keyring_rpc_1 = require("./keyring-rpc.cjs");
11
+ /**
12
+ * All keyring RPC methods available to a Snap - includes the base
13
+ * {@link KeyringRpcMethod} set plus snap-specific extensions.
14
+ */
15
+ exports.KeyringSnapRpcMethod = {
16
+ ...keyring_rpc_1.KeyringRpcMethod,
17
+ SetSelectedAccounts: 'keyring_setSelectedAccounts',
18
+ GetAccountTransactions: 'keyring_getAccountTransactions',
19
+ GetAccountAssets: 'keyring_getAccountAssets',
20
+ GetAccountBalances: 'keyring_getAccountBalances',
21
+ };
22
+ /**
23
+ * Check if a method is a Snap keyring RPC method (v2).
24
+ *
25
+ * @param method - Method to check.
26
+ * @returns Whether the method is a Snap keyring RPC method (v2).
27
+ */
28
+ function isKeyringSnapRpcMethod(method) {
29
+ return Object.values(exports.KeyringSnapRpcMethod).includes(method);
30
+ }
31
+ exports.isKeyringSnapRpcMethod = isKeyringSnapRpcMethod;
32
+ // ----------------------------------------------------------------------------
33
+ const CommonHeader = {
34
+ jsonrpc: (0, superstruct_1.literal)('2.0'),
35
+ id: (0, superstruct_1.union)([(0, superstruct_1.string)(), (0, superstruct_1.number)(), (0, superstruct_1.literal)(null)]),
36
+ };
37
+ // ----------------------------------------------------------------------------
38
+ // Set selected accounts
39
+ exports.SetSelectedAccountsRequestStruct = (0, superstruct_1.object)({
40
+ ...CommonHeader,
41
+ method: (0, superstruct_1.literal)(`${exports.KeyringSnapRpcMethod.SetSelectedAccounts}`),
42
+ params: (0, superstruct_1.object)({
43
+ accounts: (0, superstruct_1.array)((0, superstruct_1.string)()),
44
+ }),
45
+ });
46
+ exports.SetSelectedAccountsResponseStruct = (0, superstruct_1.literal)(null);
47
+ // ----------------------------------------------------------------------------
48
+ // Get account transactions
49
+ exports.GetAccountTransactionsRequestStruct = (0, superstruct_1.object)({
50
+ ...CommonHeader,
51
+ method: (0, superstruct_1.literal)(`${exports.KeyringSnapRpcMethod.GetAccountTransactions}`),
52
+ params: (0, superstruct_1.object)({
53
+ id: keyring_utils_1.UuidStruct,
54
+ pagination: pagination_1.PaginationStruct,
55
+ }),
56
+ });
57
+ exports.GetAccountTransactionsResponseStruct = transaction_1.TransactionsPageStruct;
58
+ // ----------------------------------------------------------------------------
59
+ // Get account assets
60
+ exports.GetAccountAssetsRequestStruct = (0, superstruct_1.object)({
61
+ ...CommonHeader,
62
+ method: (0, superstruct_1.literal)(`${exports.KeyringSnapRpcMethod.GetAccountAssets}`),
63
+ params: (0, superstruct_1.object)({
64
+ id: keyring_utils_1.UuidStruct,
65
+ }),
66
+ });
67
+ exports.GetAccountAssetsResponseStruct = (0, superstruct_1.array)(caip_1.CaipAssetTypeOrIdStruct);
68
+ // ----------------------------------------------------------------------------
69
+ // Get account balances
70
+ exports.GetAccountBalancesRequestStruct = (0, superstruct_1.object)({
71
+ ...CommonHeader,
72
+ method: (0, superstruct_1.literal)(`${exports.KeyringSnapRpcMethod.GetAccountBalances}`),
73
+ params: (0, superstruct_1.object)({
74
+ id: keyring_utils_1.UuidStruct,
75
+ assets: (0, superstruct_1.array)(caip_1.CaipAssetTypeStruct),
76
+ }),
77
+ });
78
+ exports.GetAccountBalancesResponseStruct = (0, superstruct_1.record)(caip_1.CaipAssetTypeStruct, balance_1.BalanceStruct);
79
+ //# sourceMappingURL=keyring-snap-rpc.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-snap-rpc.cjs","sourceRoot":"","sources":["../../../src/v2/api/keyring-snap-rpc.ts"],"names":[],"mappings":";;;AACA,2DAAqD;AAErD,uDAQ+B;AAE/B,mDAAkD;AAElD,6CAA8E;AAE9E,yDAAwD;AAExD,2DAA+D;AAE/D,mDAAiD;AAGjD;;;GAGG;AACU,QAAA,oBAAoB,GAAG;IAClC,GAAG,8BAAgB;IACnB,mBAAmB,EAAE,6BAA6B;IAClD,sBAAsB,EAAE,gCAAgC;IACxD,gBAAgB,EAAE,0BAA0B;IAC5C,kBAAkB,EAAE,4BAA4B;CACxC,CAAC;AAQX;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,MAAc;IAEd,OAAO,MAAM,CAAC,MAAM,CAAC,4BAAoB,CAAC,CAAC,QAAQ,CACjD,MAA8B,CAC/B,CAAC;AACJ,CAAC;AAND,wDAMC;AAED,+EAA+E;AAE/E,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACvB,EAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,+EAA+E;AAC/E,wBAAwB;AAEX,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAoB,CAAC,mBAAmB,EAAE,CAAC;IAC9D,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,QAAQ,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;KAC1B,CAAC;CACH,CAAC,CAAC;AAMU,QAAA,iCAAiC,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC;AAM/D,+EAA+E;AAC/E,2BAA2B;AAEd,QAAA,mCAAmC,GAAG,IAAA,oBAAM,EAAC;IACxD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAoB,CAAC,sBAAsB,EAAE,CAAC;IACjE,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;QACd,UAAU,EAAE,6BAAgB;KAC7B,CAAC;CACH,CAAC,CAAC;AAMU,QAAA,oCAAoC,GAAG,oCAAsB,CAAC;AAM3E,+EAA+E;AAC/E,qBAAqB;AAER,QAAA,6BAA6B,GAAG,IAAA,oBAAM,EAAC;IAClD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAoB,CAAC,gBAAgB,EAAE,CAAC;IAC3D,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;KACf,CAAC;CACH,CAAC,CAAC;AAMU,QAAA,8BAA8B,GAAG,IAAA,mBAAK,EAAC,8BAAuB,CAAC,CAAC;AAM7E,+EAA+E;AAC/E,uBAAuB;AAEV,QAAA,+BAA+B,GAAG,IAAA,oBAAM,EAAC;IACpD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAoB,CAAC,kBAAkB,EAAE,CAAC;IAC7D,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;QACd,MAAM,EAAE,IAAA,mBAAK,EAAC,0BAAmB,CAAC;KACnC,CAAC;CACH,CAAC,CAAC;AAMU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EACpD,0BAAmB,EACnB,uBAAa,CACd,CAAC","sourcesContent":["import type { AccountId } from '@metamask/keyring-utils';\nimport { UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n literal,\n number,\n object,\n record,\n string,\n union,\n} from '@metamask/superstruct';\n\nimport { BalanceStruct } from '../../api/balance';\nimport type { Balance } from '../../api/balance';\nimport { CaipAssetTypeOrIdStruct, CaipAssetTypeStruct } from '../../api/caip';\nimport type { CaipAssetType, CaipAssetTypeOrId } from '../../api/caip';\nimport { PaginationStruct } from '../../api/pagination';\nimport type { Pagination } from '../../api/pagination';\nimport { TransactionsPageStruct } from '../../api/transaction';\nimport type { TransactionsPage } from '../../api/transaction';\nimport { KeyringRpcMethod } from './keyring-rpc';\nimport type { KeyringRpc, KeyringRpcRequests } from './keyring-rpc';\n\n/**\n * All keyring RPC methods available to a Snap - includes the base\n * {@link KeyringRpcMethod} set plus snap-specific extensions.\n */\nexport const KeyringSnapRpcMethod = {\n ...KeyringRpcMethod,\n SetSelectedAccounts: 'keyring_setSelectedAccounts',\n GetAccountTransactions: 'keyring_getAccountTransactions',\n GetAccountAssets: 'keyring_getAccountAssets',\n GetAccountBalances: 'keyring_getAccountBalances',\n} as const;\n\n/**\n * All keyring RPC methods available to a Snap.\n */\nexport type KeyringSnapRpcMethod =\n (typeof KeyringSnapRpcMethod)[keyof typeof KeyringSnapRpcMethod];\n\n/**\n * Check if a method is a Snap keyring RPC method (v2).\n *\n * @param method - Method to check.\n * @returns Whether the method is a Snap keyring RPC method (v2).\n */\nexport function isKeyringSnapRpcMethod(\n method: string,\n): method is KeyringSnapRpcMethod {\n return Object.values(KeyringSnapRpcMethod).includes(\n method as KeyringSnapRpcMethod,\n );\n}\n\n// ----------------------------------------------------------------------------\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n};\n\n// ----------------------------------------------------------------------------\n// Set selected accounts\n\nexport const SetSelectedAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringSnapRpcMethod.SetSelectedAccounts}`),\n params: object({\n accounts: array(string()),\n }),\n});\n\nexport type SetSelectedAccountsRequest = Infer<\n typeof SetSelectedAccountsRequestStruct\n>;\n\nexport const SetSelectedAccountsResponseStruct = literal(null);\n\nexport type SetSelectedAccountsResponse = Infer<\n typeof SetSelectedAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account transactions\n\nexport const GetAccountTransactionsRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringSnapRpcMethod.GetAccountTransactions}`),\n params: object({\n id: UuidStruct,\n pagination: PaginationStruct,\n }),\n});\n\nexport type GetAccountTransactionsRequest = Infer<\n typeof GetAccountTransactionsRequestStruct\n>;\n\nexport const GetAccountTransactionsResponseStruct = TransactionsPageStruct;\n\nexport type GetAccountTransactionsResponse = Infer<\n typeof GetAccountTransactionsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account assets\n\nexport const GetAccountAssetsRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringSnapRpcMethod.GetAccountAssets}`),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetAccountAssetsRequest = Infer<\n typeof GetAccountAssetsRequestStruct\n>;\n\nexport const GetAccountAssetsResponseStruct = array(CaipAssetTypeOrIdStruct);\n\nexport type GetAccountAssetsResponse = Infer<\n typeof GetAccountAssetsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account balances\n\nexport const GetAccountBalancesRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringSnapRpcMethod.GetAccountBalances}`),\n params: object({\n id: UuidStruct,\n assets: array(CaipAssetTypeStruct),\n }),\n});\n\nexport type GetAccountBalancesRequest = Infer<\n typeof GetAccountBalancesRequestStruct\n>;\n\nexport const GetAccountBalancesResponseStruct = record(\n CaipAssetTypeStruct,\n BalanceStruct,\n);\n\nexport type GetAccountBalancesResponse = Infer<\n typeof GetAccountBalancesResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n\n/**\n * All keyring RPC requests available to a Snap - includes base\n * {@link KeyringRpcRequests} plus snap-specific request types.\n */\nexport type KeyringSnapRpcRequests =\n | KeyringRpcRequests\n | SetSelectedAccountsRequest\n | GetAccountTransactionsRequest\n | GetAccountAssetsRequest\n | GetAccountBalancesRequest;\n\n/**\n * Extract the proper request type for a given {@link KeyringSnapRpcMethod}.\n */\nexport type KeyringSnapRpcRequest<RpcMethod extends KeyringSnapRpcMethod> =\n Extract<KeyringSnapRpcRequests, { method: `${RpcMethod}` }>;\n\n// ----------------------------------------------------------------------------\n\n/**\n * Snap keyring RPC interface - extends the base {@link KeyringRpc} with\n * optional snap-specific methods that a Snap may expose.\n */\nexport type KeyringSnapRpc = KeyringRpc & {\n /**\n * Notify the Snap of the currently selected accounts.\n * Maps to `keyring_setSelectedAccounts`.\n */\n setSelectedAccounts?: (accounts: AccountId[]) => Promise<void>;\n\n /**\n * Get transactions for an account with pagination.\n * Maps to `keyring_getAccountTransactions`.\n */\n getAccountTransactions?: (\n id: AccountId,\n pagination: Pagination,\n ) => Promise<TransactionsPage>;\n\n /**\n * Get the asset types supported by an account.\n * Maps to `keyring_getAccountAssets`.\n */\n getAccountAssets?: (id: AccountId) => Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Get balances for an account for the requested asset types.\n * Maps to `keyring_getAccountBalances`.\n */\n getAccountBalances?: (\n id: AccountId,\n assets: CaipAssetType[],\n ) => Promise<Record<CaipAssetType, Balance>>;\n};\n"]}