@metamask/keyring-api 6.2.1 → 6.3.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 +21 -1
- package/dist/KeyringClient.js +9 -9
- package/dist/KeyringClient.js.map +1 -1
- package/dist/api/account.d.ts +62 -0
- package/dist/api/account.js +56 -0
- package/dist/api/account.js.map +1 -0
- package/dist/api/balance.d.ts +9 -0
- package/dist/api/balance.js +11 -0
- package/dist/api/balance.js.map +1 -0
- package/dist/api/export.d.ts +8 -0
- package/dist/api/export.js +7 -0
- package/dist/api/export.js.map +1 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +1 -0
- package/dist/{api.d.ts → api/keyring.d.ts} +34 -125
- package/dist/api/keyring.js +3 -0
- package/dist/api/keyring.js.map +1 -0
- package/dist/api/request.d.ts +39 -0
- package/dist/api/request.js +29 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/response.d.ts +24 -0
- package/dist/api/response.js +44 -0
- package/dist/api/response.js.map +1 -0
- package/dist/btc/types.d.ts +4 -7
- package/dist/btc/types.js +10 -12
- package/dist/btc/types.js.map +1 -1
- package/dist/eth/erc4337/types.d.ts +1 -1
- package/dist/eth/erc4337/types.js +2 -1
- package/dist/eth/erc4337/types.js.map +1 -1
- package/dist/eth/types.d.ts +9 -15
- package/dist/eth/types.js +23 -29
- package/dist/eth/types.js.map +1 -1
- package/dist/eth/utils.d.ts +3 -2
- package/dist/eth/utils.js +3 -2
- package/dist/eth/utils.js.map +1 -1
- package/dist/internal/api.d.ts +94 -112
- package/dist/internal/api.js +35 -22
- package/dist/internal/api.js.map +1 -1
- package/dist/internal/events.d.ts +40 -92
- package/dist/internal/rpc.d.ts +1 -0
- package/dist/internal/rpc.js +1 -0
- package/dist/internal/rpc.js.map +1 -1
- package/dist/internal/types.d.ts +65 -6
- package/dist/internal/types.js +7 -9
- package/dist/internal/types.js.map +1 -1
- package/dist/rpc-handler.d.ts +12 -0
- package/dist/rpc-handler.js +40 -2
- package/dist/rpc-handler.js.map +1 -1
- package/dist/superstruct.d.ts +9 -4
- package/dist/superstruct.js +14 -14
- package/dist/superstruct.js.map +1 -1
- package/dist/utils/caip.d.ts +37 -0
- package/dist/utils/caip.js +48 -0
- package/dist/utils/caip.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/types.d.ts +17 -0
- package/dist/utils/types.js +29 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/typing.d.ts +32 -0
- package/dist/utils/typing.js +21 -0
- package/dist/utils/typing.js.map +1 -0
- package/package.json +1 -1
- package/dist/api.js +0 -108
- package/dist/api.js.map +0 -1
- package/dist/base-types.d.ts +0 -62
- package/dist/base-types.js +0 -32
- package/dist/base-types.js.map +0 -1
- package/dist/utils.d.ts +0 -26
- package/dist/utils.js +0 -26
- package/dist/utils.js.map +0 -1
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.KeyringResponseStruct = void 0;
|
4
|
+
const utils_1 = require("@metamask/utils");
|
5
|
+
const superstruct_1 = require("superstruct");
|
6
|
+
const superstruct_2 = require("../superstruct");
|
7
|
+
exports.KeyringResponseStruct = (0, superstruct_1.union)([
|
8
|
+
(0, superstruct_2.object)({
|
9
|
+
/**
|
10
|
+
* Pending flag.
|
11
|
+
*
|
12
|
+
* Setting the pending flag to true indicates that the request will be
|
13
|
+
* handled asynchronously. The keyring must be called with `approveRequest`
|
14
|
+
* or `rejectRequest` to resolve the request.
|
15
|
+
*/
|
16
|
+
pending: (0, superstruct_1.literal)(true),
|
17
|
+
/**
|
18
|
+
* Redirect URL.
|
19
|
+
*
|
20
|
+
* If present in the response, MetaMask will display a confirmation dialog
|
21
|
+
* with a link to the redirect URL. The user can choose to follow the link
|
22
|
+
* or cancel the request.
|
23
|
+
*/
|
24
|
+
redirect: (0, superstruct_2.exactOptional)((0, superstruct_2.object)({
|
25
|
+
message: (0, superstruct_2.exactOptional)((0, superstruct_1.string)()),
|
26
|
+
url: (0, superstruct_2.exactOptional)((0, superstruct_1.string)()),
|
27
|
+
})),
|
28
|
+
}),
|
29
|
+
(0, superstruct_2.object)({
|
30
|
+
/**
|
31
|
+
* Pending flag.
|
32
|
+
*
|
33
|
+
* Setting the pending flag to false indicates that the request will be
|
34
|
+
* handled synchronously. The keyring must return the result of the
|
35
|
+
* request execution.
|
36
|
+
*/
|
37
|
+
pending: (0, superstruct_1.literal)(false),
|
38
|
+
/**
|
39
|
+
* Request result.
|
40
|
+
*/
|
41
|
+
result: utils_1.JsonStruct,
|
42
|
+
}),
|
43
|
+
]);
|
44
|
+
//# sourceMappingURL=response.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,6CAAqD;AAErD,gDAAuD;AAE1C,QAAA,qBAAqB,GAAG,IAAA,mBAAK,EAAC;IACzC,IAAA,oBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;QAEtB;;;;;;WAMG;QACH,QAAQ,EAAE,IAAA,2BAAa,EACrB,IAAA,oBAAM,EAAC;YACL,OAAO,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;YAChC,GAAG,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;SAC7B,CAAC,CACH;KACF,CAAC;IACF,IAAA,oBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;QAEvB;;WAEG;QACH,MAAM,EAAE,kBAAU;KACnB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { JsonStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport { literal, string, union } from 'superstruct';\n\nimport { exactOptional, object } from '../superstruct';\n\nexport const KeyringResponseStruct = union([\n object({\n /**\n * Pending flag.\n *\n * Setting the pending flag to true indicates that the request will be\n * handled asynchronously. The keyring must be called with `approveRequest`\n * or `rejectRequest` to resolve the request.\n */\n pending: literal(true),\n\n /**\n * Redirect URL.\n *\n * If present in the response, MetaMask will display a confirmation dialog\n * with a link to the redirect URL. The user can choose to follow the link\n * or cancel the request.\n */\n redirect: exactOptional(\n object({\n message: exactOptional(string()),\n url: exactOptional(string()),\n }),\n ),\n }),\n object({\n /**\n * Pending flag.\n *\n * Setting the pending flag to false indicates that the request will be\n * handled synchronously. The keyring must return the result of the\n * request execution.\n */\n pending: literal(false),\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n]);\n\n/**\n * Response to a call to `submitRequest`.\n *\n * Keyring implementations must return a response with `pending: true` if the\n * request will be handled asynchronously. Otherwise, the response must contain\n * the result of the request and `pending: false`.\n *\n * In the asynchronous case, the keyring can return a redirect URL and message\n * to be shown to the user. The user can choose to follow the link or cancel\n * the request. The main use case for this is to redirect the user to the snap\n * dapp to review the request.\n */\nexport type KeyringResponse = Infer<typeof KeyringResponseStruct>;\n"]}
|
package/dist/btc/types.d.ts
CHANGED
@@ -6,12 +6,6 @@ export declare const BtcP2wpkhAddressStruct: import("superstruct").Struct<string
|
|
6
6
|
export declare enum BtcMethod {
|
7
7
|
SendMany = "btc_sendmany"
|
8
8
|
}
|
9
|
-
/**
|
10
|
-
* Supported Bitcoin account types.
|
11
|
-
*/
|
12
|
-
export declare enum BtcAccountType {
|
13
|
-
P2wpkh = "bip122:p2wpkh"
|
14
|
-
}
|
15
9
|
export declare const BtcP2wpkhAccountStruct: import("superstruct").Struct<{
|
16
10
|
type: "bip122:p2wpkh";
|
17
11
|
id: string;
|
@@ -19,6 +13,10 @@ export declare const BtcP2wpkhAccountStruct: import("superstruct").Struct<{
|
|
19
13
|
options: Record<string, import("@metamask/utils").Json>;
|
20
14
|
methods: "btc_sendmany"[];
|
21
15
|
}, {
|
16
|
+
/**
|
17
|
+
* Account address.
|
18
|
+
*/
|
19
|
+
address: import("superstruct").Struct<string, null>;
|
22
20
|
/**
|
23
21
|
* Account type.
|
24
22
|
*/
|
@@ -30,7 +28,6 @@ export declare const BtcP2wpkhAccountStruct: import("superstruct").Struct<{
|
|
30
28
|
btc_sendmany: "btc_sendmany";
|
31
29
|
}>>;
|
32
30
|
id: import("superstruct").Struct<string, null>;
|
33
|
-
address: import("superstruct").Struct<string, null>;
|
34
31
|
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
35
32
|
}>;
|
36
33
|
export declare type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;
|
package/dist/btc/types.js
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BtcP2wpkhAccountStruct = exports.
|
3
|
+
exports.BtcP2wpkhAccountStruct = exports.BtcMethod = exports.BtcP2wpkhAddressStruct = void 0;
|
4
4
|
const bech32_1 = require("bech32");
|
5
5
|
const superstruct_1 = require("superstruct");
|
6
|
-
const
|
6
|
+
const api_1 = require("../api");
|
7
|
+
const superstruct_2 = require("../superstruct");
|
7
8
|
exports.BtcP2wpkhAddressStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'BtcP2wpkhAddressStruct', (address) => {
|
8
9
|
try {
|
9
10
|
bech32_1.bech32.decode(address);
|
@@ -21,19 +22,16 @@ var BtcMethod;
|
|
21
22
|
// General transaction methods
|
22
23
|
BtcMethod["SendMany"] = "btc_sendmany";
|
23
24
|
})(BtcMethod = exports.BtcMethod || (exports.BtcMethod = {}));
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
})(BtcAccountType = exports.BtcAccountType || (exports.BtcAccountType = {}));
|
31
|
-
exports.BtcP2wpkhAccountStruct = (0, superstruct_1.object)({
|
32
|
-
...base_types_1.BaseAccount,
|
25
|
+
exports.BtcP2wpkhAccountStruct = (0, superstruct_2.object)({
|
26
|
+
...api_1.KeyringAccountStruct.schema,
|
27
|
+
/**
|
28
|
+
* Account address.
|
29
|
+
*/
|
30
|
+
address: exports.BtcP2wpkhAddressStruct,
|
33
31
|
/**
|
34
32
|
* Account type.
|
35
33
|
*/
|
36
|
-
type: (0, superstruct_1.literal)(`${BtcAccountType.P2wpkh}`),
|
34
|
+
type: (0, superstruct_1.literal)(`${api_1.BtcAccountType.P2wpkh}`),
|
37
35
|
/**
|
38
36
|
* Account supported methods.
|
39
37
|
*/
|
package/dist/btc/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,6CAAoE;AAEpE,gCAA8D;AAC9D,gDAAwC;AAE3B,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAC1C,IAAA,oBAAM,GAAE,EACR,wBAAwB,EACxB,CAAC,OAAe,EAAE,EAAE;IAClB,IAAI;QACF,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KACxB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,sCAAyB,CAAA;AAC3B,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAEY,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,8BAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC;IAEzC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;CACjD,CAAC,CAAC","sourcesContent":["import { bech32 } from 'bech32';\nimport type { Infer } from 'superstruct';\nimport { string, array, enums, refine, literal } from 'superstruct';\n\nimport { KeyringAccountStruct, BtcAccountType } from '../api';\nimport { object } from '../superstruct';\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n try {\n bech32.decode(address);\n } catch (error) {\n return new Error(\n `Could not decode P2WPKH address: ${(error as Error).message}`,\n );\n }\n return true;\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n // General transaction methods\n SendMany = 'btc_sendmany',\n}\n\nexport const BtcP2wpkhAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${BtcMethod.SendMany}`])),\n});\n\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\n"]}
|
@@ -35,8 +35,8 @@ export declare type EthUserOperation = Infer<typeof EthUserOperationStruct>;
|
|
35
35
|
*/
|
36
36
|
export declare const EthBaseTransactionStruct: import("superstruct").Struct<{
|
37
37
|
value: string;
|
38
|
-
to: string;
|
39
38
|
data: string;
|
39
|
+
to: string;
|
40
40
|
}, {
|
41
41
|
/**
|
42
42
|
* Address of the transaction recipient.
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.EthUserOperationPatchStruct = exports.EthBaseUserOperationStruct = exports.EthBaseTransactionStruct = exports.EthUserOperationStruct = void 0;
|
4
4
|
const superstruct_1 = require("../../superstruct");
|
5
|
+
const utils_1 = require("../../utils");
|
5
6
|
const types_1 = require("../types");
|
6
7
|
/**
|
7
8
|
* Struct of a UserOperation as defined by ERC-4337.
|
@@ -49,7 +50,7 @@ exports.EthBaseUserOperationStruct = (0, superstruct_1.object)({
|
|
49
50
|
})),
|
50
51
|
dummyPaymasterAndData: types_1.EthBytesStruct,
|
51
52
|
dummySignature: types_1.EthBytesStruct,
|
52
|
-
bundlerUrl:
|
53
|
+
bundlerUrl: utils_1.UrlStruct,
|
53
54
|
});
|
54
55
|
exports.EthUserOperationPatchStruct = (0, superstruct_1.object)({
|
55
56
|
paymasterAndData: types_1.EthBytesStruct,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":";;;AAEA,
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":";;;AAEA,mDAA0D;AAC1D,uCAAwC;AACxC,oCAA8E;AAE9E;;;GAGG;AACU,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C,MAAM,EAAE,wBAAgB;IACxB,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,kBAAkB,EAAE,wBAAgB;IACpC,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,gBAAgB,EAAE,sBAAc;IAChC,SAAS,EAAE,sBAAc;CAC1B,CAAC,CAAC;AAIH;;;GAGG;AACU,QAAA,wBAAwB,GAAG,IAAA,oBAAM,EAAC;IAC7C;;OAEG;IACH,EAAE,EAAE,wBAAgB;IAEpB;;OAEG;IACH,KAAK,EAAE,wBAAgB;IAEvB;;OAEG;IACH,IAAI,EAAE,sBAAc;CACrB,CAAC,CAAC;AAIU,QAAA,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IAC/C,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,SAAS,EAAE,IAAA,2BAAa,EACtB,IAAA,oBAAM,EAAC;QACL,YAAY,EAAE,wBAAgB;QAC9B,oBAAoB,EAAE,wBAAgB;QACtC,kBAAkB,EAAE,wBAAgB;KACrC,CAAC,CACH;IACD,qBAAqB,EAAE,sBAAc;IACrC,cAAc,EAAE,sBAAc;IAC9B,UAAU,EAAE,iBAAS;CACtB,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,oBAAM,EAAC;IAChD,gBAAgB,EAAE,sBAAc;IAChC,YAAY,EAAE,IAAA,2BAAa,EAAC,wBAAgB,CAAC;IAC7C,oBAAoB,EAAE,IAAA,2BAAa,EAAC,wBAAgB,CAAC;IACrD,kBAAkB,EAAE,IAAA,2BAAa,EAAC,wBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { type Infer } from 'superstruct';\n\nimport { exactOptional, object } from '../../superstruct';\nimport { UrlStruct } from '../../utils';\nimport { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';\n\n/**\n * Struct of a UserOperation as defined by ERC-4337.\n * @see https://eips.ethereum.org/EIPS/eip-4337#definitions\n */\nexport const EthUserOperationStruct = object({\n sender: EthAddressStruct,\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n maxFeePerGas: EthUint256Struct,\n maxPriorityFeePerGas: EthUint256Struct,\n paymasterAndData: EthBytesStruct,\n signature: EthBytesStruct,\n});\n\nexport type EthUserOperation = Infer<typeof EthUserOperationStruct>;\n\n/**\n * Struct containing the most basic transaction information required to\n * construct a UserOperation.\n */\nexport const EthBaseTransactionStruct = object({\n /**\n * Address of the transaction recipient.\n */\n to: EthAddressStruct,\n\n /**\n * Amount of wei to transfer to the recipient.\n */\n value: EthUint256Struct,\n\n /**\n * Data to pass to the recipient.\n */\n data: EthBytesStruct,\n});\n\nexport type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;\n\nexport const EthBaseUserOperationStruct = object({\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n gasLimits: exactOptional(\n object({\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n }),\n ),\n dummyPaymasterAndData: EthBytesStruct,\n dummySignature: EthBytesStruct,\n bundlerUrl: UrlStruct,\n});\n\nexport type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;\n\nexport const EthUserOperationPatchStruct = object({\n paymasterAndData: EthBytesStruct,\n callGasLimit: exactOptional(EthUint256Struct),\n verificationGasLimit: exactOptional(EthUint256Struct),\n preVerificationGas: exactOptional(EthUint256Struct),\n});\n\nexport type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;\n"]}
|
package/dist/eth/types.d.ts
CHANGED
@@ -11,23 +11,11 @@ export declare enum EthMethod {
|
|
11
11
|
SignTransaction = "eth_signTransaction",
|
12
12
|
SignTypedDataV1 = "eth_signTypedData_v1",
|
13
13
|
SignTypedDataV3 = "eth_signTypedData_v3",
|
14
|
-
SignTypedDataV4 = "eth_signTypedData_v4"
|
15
|
-
}
|
16
|
-
/**
|
17
|
-
* Supported Ethereum methods for ERC-4337 (Account Abstraction) accounts.
|
18
|
-
*/
|
19
|
-
export declare enum EthErc4337Method {
|
14
|
+
SignTypedDataV4 = "eth_signTypedData_v4",
|
20
15
|
PrepareUserOperation = "eth_prepareUserOperation",
|
21
16
|
PatchUserOperation = "eth_patchUserOperation",
|
22
17
|
SignUserOperation = "eth_signUserOperation"
|
23
18
|
}
|
24
|
-
/**
|
25
|
-
* Supported Ethereum account types.
|
26
|
-
*/
|
27
|
-
export declare enum EthAccountType {
|
28
|
-
Eoa = "eip155:eoa",
|
29
|
-
Erc4337 = "eip155:erc4337"
|
30
|
-
}
|
31
19
|
export declare const EthEoaAccountStruct: import("superstruct").Struct<{
|
32
20
|
type: "eip155:eoa";
|
33
21
|
id: string;
|
@@ -35,6 +23,10 @@ export declare const EthEoaAccountStruct: import("superstruct").Struct<{
|
|
35
23
|
options: Record<string, import("@metamask/utils").Json>;
|
36
24
|
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
|
37
25
|
}, {
|
26
|
+
/**
|
27
|
+
* Account address.
|
28
|
+
*/
|
29
|
+
address: import("superstruct").Struct<string, null>;
|
38
30
|
/**
|
39
31
|
* Account type.
|
40
32
|
*/
|
@@ -51,7 +43,6 @@ export declare const EthEoaAccountStruct: import("superstruct").Struct<{
|
|
51
43
|
eth_signTypedData_v4: "eth_signTypedData_v4";
|
52
44
|
}>>;
|
53
45
|
id: import("superstruct").Struct<string, null>;
|
54
|
-
address: import("superstruct").Struct<string, null>;
|
55
46
|
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
56
47
|
}>;
|
57
48
|
export declare type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;
|
@@ -62,6 +53,10 @@ export declare const EthErc4337AccountStruct: import("superstruct").Struct<{
|
|
62
53
|
options: Record<string, import("@metamask/utils").Json>;
|
63
54
|
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
|
64
55
|
}, {
|
56
|
+
/**
|
57
|
+
* Account address.
|
58
|
+
*/
|
59
|
+
address: import("superstruct").Struct<string, null>;
|
65
60
|
/**
|
66
61
|
* Account type.
|
67
62
|
*/
|
@@ -80,7 +75,6 @@ export declare const EthErc4337AccountStruct: import("superstruct").Struct<{
|
|
80
75
|
eth_signUserOperation: "eth_signUserOperation";
|
81
76
|
}>>;
|
82
77
|
id: import("superstruct").Struct<string, null>;
|
83
|
-
address: import("superstruct").Struct<string, null>;
|
84
78
|
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
85
79
|
}>;
|
86
80
|
export declare type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;
|
package/dist/eth/types.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.
|
3
|
+
exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0;
|
4
4
|
const superstruct_1 = require("superstruct");
|
5
|
-
const
|
5
|
+
const api_1 = require("../api");
|
6
6
|
const superstruct_2 = require("../superstruct");
|
7
7
|
exports.EthBytesStruct = (0, superstruct_2.definePattern)('EthBytes', /^0x[0-9a-f]*$/iu);
|
8
8
|
exports.EthAddressStruct = (0, superstruct_2.definePattern)('EthAddress', /^0x[0-9a-f]{40}$/iu);
|
@@ -19,31 +19,21 @@ var EthMethod;
|
|
19
19
|
EthMethod["SignTypedDataV1"] = "eth_signTypedData_v1";
|
20
20
|
EthMethod["SignTypedDataV3"] = "eth_signTypedData_v3";
|
21
21
|
EthMethod["SignTypedDataV4"] = "eth_signTypedData_v4";
|
22
|
-
})(EthMethod = exports.EthMethod || (exports.EthMethod = {}));
|
23
|
-
/**
|
24
|
-
* Supported Ethereum methods for ERC-4337 (Account Abstraction) accounts.
|
25
|
-
*/
|
26
|
-
var EthErc4337Method;
|
27
|
-
(function (EthErc4337Method) {
|
28
22
|
// ERC-4337 methods
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
})(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
EthAccountType["Erc4337"] = "eip155:erc4337";
|
40
|
-
})(EthAccountType = exports.EthAccountType || (exports.EthAccountType = {}));
|
41
|
-
exports.EthEoaAccountStruct = (0, superstruct_1.object)({
|
42
|
-
...base_types_1.BaseAccount,
|
23
|
+
EthMethod["PrepareUserOperation"] = "eth_prepareUserOperation";
|
24
|
+
EthMethod["PatchUserOperation"] = "eth_patchUserOperation";
|
25
|
+
EthMethod["SignUserOperation"] = "eth_signUserOperation";
|
26
|
+
})(EthMethod = exports.EthMethod || (exports.EthMethod = {}));
|
27
|
+
exports.EthEoaAccountStruct = (0, superstruct_2.object)({
|
28
|
+
...api_1.KeyringAccountStruct.schema,
|
29
|
+
/**
|
30
|
+
* Account address.
|
31
|
+
*/
|
32
|
+
address: exports.EthAddressStruct,
|
43
33
|
/**
|
44
34
|
* Account type.
|
45
35
|
*/
|
46
|
-
type: (0, superstruct_1.literal)(`${EthAccountType.Eoa}`),
|
36
|
+
type: (0, superstruct_1.literal)(`${api_1.EthAccountType.Eoa}`),
|
47
37
|
/**
|
48
38
|
* Account supported methods.
|
49
39
|
*/
|
@@ -56,12 +46,16 @@ exports.EthEoaAccountStruct = (0, superstruct_1.object)({
|
|
56
46
|
`${EthMethod.SignTypedDataV4}`,
|
57
47
|
])),
|
58
48
|
});
|
59
|
-
exports.EthErc4337AccountStruct = (0,
|
60
|
-
...
|
49
|
+
exports.EthErc4337AccountStruct = (0, superstruct_2.object)({
|
50
|
+
...api_1.KeyringAccountStruct.schema,
|
51
|
+
/**
|
52
|
+
* Account address.
|
53
|
+
*/
|
54
|
+
address: exports.EthAddressStruct,
|
61
55
|
/**
|
62
56
|
* Account type.
|
63
57
|
*/
|
64
|
-
type: (0, superstruct_1.literal)(`${EthAccountType.Erc4337}`),
|
58
|
+
type: (0, superstruct_1.literal)(`${api_1.EthAccountType.Erc4337}`),
|
65
59
|
/**
|
66
60
|
* Account supported methods.
|
67
61
|
*/
|
@@ -71,9 +65,9 @@ exports.EthErc4337AccountStruct = (0, superstruct_1.object)({
|
|
71
65
|
`${EthMethod.SignTypedDataV1}`,
|
72
66
|
`${EthMethod.SignTypedDataV3}`,
|
73
67
|
`${EthMethod.SignTypedDataV4}`,
|
74
|
-
`${
|
75
|
-
`${
|
76
|
-
`${
|
68
|
+
`${EthMethod.PrepareUserOperation}`,
|
69
|
+
`${EthMethod.PatchUserOperation}`,
|
70
|
+
`${EthMethod.SignUserOperation}`,
|
77
71
|
])),
|
78
72
|
});
|
79
73
|
//# sourceMappingURL=types.js.map
|
package/dist/eth/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AACA,6CAAoD;AAEpD,gCAA8D;AAC9D,gDAAuD;AAE1C,QAAA,cAAc,GAAG,IAAA,2BAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE9D,QAAA,gBAAgB,GAAG,IAAA,2BAAa,EAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,2BAAa,EAC3C,YAAY,EACZ,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,0BAA0B;IAC1B,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,oDAAuC,CAAA;IACvC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,mBAAmB;IACnB,8DAAiD,CAAA;IACjD,0DAA6C,CAAA;IAC7C,wDAA2C,CAAA;AAC7C,CAAC,EAZW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAYpB;AAEY,QAAA,mBAAmB,GAAG,IAAA,oBAAM,EAAC;IACxC,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,GAAG,EAAE,CAAC;IAEtC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;KAC/B,CAAC,CACH;CACF,CAAC,CAAC;AAIU,QAAA,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IAC5C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,OAAO,EAAE,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import type { Infer } from 'superstruct';\nimport { array, enums, literal } from 'superstruct';\n\nimport { EthAccountType, KeyringAccountStruct } from '../api';\nimport { object, definePattern } from '../superstruct';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]}
|
package/dist/eth/utils.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import type {
|
1
|
+
import type { KeyringAccountType } from '../api';
|
2
2
|
/**
|
3
3
|
* Checks if the given type is an EVM account type.
|
4
|
+
*
|
4
5
|
* @param type - The type to check.
|
5
6
|
* @returns Returns true if the type is an EVM account type, false otherwise.
|
6
7
|
*/
|
7
|
-
export declare function isEvmAccountType(type:
|
8
|
+
export declare function isEvmAccountType(type: KeyringAccountType): boolean;
|
package/dist/eth/utils.js
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isEvmAccountType = void 0;
|
4
|
-
const
|
4
|
+
const api_1 = require("../api");
|
5
5
|
/**
|
6
6
|
* Checks if the given type is an EVM account type.
|
7
|
+
*
|
7
8
|
* @param type - The type to check.
|
8
9
|
* @returns Returns true if the type is an EVM account type, false otherwise.
|
9
10
|
*/
|
10
11
|
function isEvmAccountType(type) {
|
11
|
-
return type ===
|
12
|
+
return type === api_1.EthAccountType.Eoa || type === api_1.EthAccountType.Erc4337;
|
12
13
|
}
|
13
14
|
exports.isEvmAccountType = isEvmAccountType;
|
14
15
|
//# sourceMappingURL=utils.js.map
|
package/dist/eth/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/eth/utils.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/eth/utils.ts"],"names":[],"mappings":";;;AACA,gCAAwC;AAExC;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,IAAwB;IACvD,OAAO,IAAI,KAAK,oBAAc,CAAC,GAAG,IAAI,IAAI,KAAK,oBAAc,CAAC,OAAO,CAAC;AACxE,CAAC;AAFD,4CAEC","sourcesContent":["import type { KeyringAccountType } from '../api';\nimport { EthAccountType } from '../api';\n\n/**\n * Checks if the given type is an EVM account type.\n *\n * @param type - The type to check.\n * @returns Returns true if the type is an EVM account type, false otherwise.\n */\nexport function isEvmAccountType(type: KeyringAccountType): boolean {\n return type === EthAccountType.Eoa || type === EthAccountType.Erc4337;\n}\n"]}
|