@metamask-previews/keyring-api 8.1.0-preview-4ddfc4a → 8.1.0-preview-e65b905
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/dist/JsonRpcRequest.d.ts +1 -1
- package/dist/JsonRpcRequest.js +3 -3
- package/dist/JsonRpcRequest.js.map +1 -1
- package/dist/KeyringClient.js +10 -10
- package/dist/KeyringClient.js.map +1 -1
- package/dist/api/account.d.ts +1 -1
- package/dist/api/account.js +3 -4
- package/dist/api/account.js.map +1 -1
- package/dist/api/balance.js +3 -4
- package/dist/api/balance.js.map +1 -1
- package/dist/api/caip.js +3 -3
- package/dist/api/caip.js.map +1 -1
- package/dist/api/request.d.ts +1 -1
- package/dist/api/request.js +6 -7
- package/dist/api/request.js.map +1 -1
- package/dist/api/response.js +6 -6
- package/dist/api/response.js.map +1 -1
- package/dist/btc/types.d.ts +1 -1
- package/dist/btc/types.js +2 -2
- package/dist/btc/types.js.map +1 -1
- package/dist/eth/erc4337/types.d.ts +5 -5
- package/dist/eth/erc4337/types.js +10 -11
- package/dist/eth/erc4337/types.js.map +1 -1
- package/dist/eth/types.d.ts +2 -2
- package/dist/eth/types.js +6 -6
- package/dist/eth/types.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/api.d.ts +10 -10
- package/dist/internal/api.js +32 -33
- package/dist/internal/api.js.map +1 -1
- package/dist/internal/events.d.ts +8 -8
- package/dist/internal/events.js +16 -17
- package/dist/internal/events.js.map +1 -1
- package/dist/internal/types.d.ts +19 -19
- package/dist/internal/types.js +9 -9
- package/dist/internal/types.js.map +1 -1
- package/package.json +2 -2
- package/dist/superstruct.d.ts +0 -83
- package/dist/superstruct.js +0 -81
- package/dist/superstruct.js.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -19
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/types.d.ts +0 -17
- package/dist/utils/types.js +0 -29
- package/dist/utils/types.js.map +0 -1
- package/dist/utils/typing.d.ts +0 -32
- package/dist/utils/typing.js +0 -21
- package/dist/utils/typing.js.map +0 -1
package/dist/JsonRpcRequest.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const JsonRpcRequestStruct: import("@metamask/superstruct").Struc
|
|
|
8
8
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
|
|
9
9
|
id: import("@metamask/superstruct").Struct<string | number | null, null>;
|
|
10
10
|
method: import("@metamask/superstruct").Struct<string, null>;
|
|
11
|
-
params: import("@metamask/superstruct").Struct<import("
|
|
11
|
+
params: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>, null>;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
14
|
* JSON-RPC request type.
|
package/dist/JsonRpcRequest.js
CHANGED
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JsonRpcRequestStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
7
|
-
exports.JsonRpcRequestStruct = (0,
|
|
6
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
7
|
+
exports.JsonRpcRequestStruct = (0, keyring_utils_1.object)({
|
|
8
8
|
jsonrpc: (0, superstruct_1.literal)('2.0'),
|
|
9
9
|
id: (0, superstruct_1.union)([(0, superstruct_1.string)(), (0, superstruct_1.number)(), (0, superstruct_1.literal)(null)]),
|
|
10
10
|
method: (0, superstruct_1.string)(),
|
|
11
|
-
params: (0,
|
|
11
|
+
params: (0, keyring_utils_1.exactOptional)((0, superstruct_1.union)([(0, superstruct_1.array)(utils_1.JsonStruct), (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct)])),
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=JsonRpcRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonRpcRequest.js","sourceRoot":"","sources":["../src/JsonRpcRequest.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAE/B,2CAA6C;AAE7C
|
|
1
|
+
{"version":3,"file":"JsonRpcRequest.js","sourceRoot":"","sources":["../src/JsonRpcRequest.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAE/B,2CAA6C;AAE7C,2DAAgE;AAEnD,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACvB,EAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,MAAM,EAAE,IAAA,6BAAa,EACnB,IAAA,mBAAK,EAAC,CAAC,IAAA,mBAAK,EAAC,kBAAU,CAAC,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC,CAAC,CACzD;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n literal,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from '@metamask/keyring-utils';\n\nexport const JsonRpcRequestStruct = object({\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n method: string(),\n params: exactOptional(\n union([array(JsonStruct), record(string(), JsonStruct)]),\n ),\n});\n\n/**\n * JSON-RPC request type.\n */\nexport type JsonRpcRequest = Infer<typeof JsonRpcRequestStruct>;\n"]}
|
package/dist/KeyringClient.js
CHANGED
|
@@ -17,7 +17,7 @@ const superstruct_1 = require("@metamask/superstruct");
|
|
|
17
17
|
const uuid_1 = require("uuid");
|
|
18
18
|
const api_1 = require("./internal/api");
|
|
19
19
|
const rpc_1 = require("./internal/rpc");
|
|
20
|
-
const
|
|
20
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
21
21
|
class KeyringClient {
|
|
22
22
|
/**
|
|
23
23
|
* Create a new instance of `KeyringClient`.
|
|
@@ -30,30 +30,30 @@ class KeyringClient {
|
|
|
30
30
|
__classPrivateFieldSet(this, _KeyringClient_sender, sender, "f");
|
|
31
31
|
}
|
|
32
32
|
async listAccounts() {
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
34
34
|
method: rpc_1.KeyringRpcMethod.ListAccounts,
|
|
35
35
|
}), api_1.ListAccountsResponseStruct);
|
|
36
36
|
}
|
|
37
37
|
async getAccount(id) {
|
|
38
|
-
return (0,
|
|
38
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
39
39
|
method: rpc_1.KeyringRpcMethod.GetAccount,
|
|
40
40
|
params: { id },
|
|
41
41
|
}), api_1.GetAccountResponseStruct);
|
|
42
42
|
}
|
|
43
43
|
async getAccountBalances(id, assets) {
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
45
45
|
method: rpc_1.KeyringRpcMethod.GetAccountBalances,
|
|
46
46
|
params: { id, assets },
|
|
47
47
|
}), api_1.GetAccountBalancesResponseStruct);
|
|
48
48
|
}
|
|
49
49
|
async createAccount(options = {}) {
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
51
51
|
method: rpc_1.KeyringRpcMethod.CreateAccount,
|
|
52
52
|
params: { options },
|
|
53
53
|
}), api_1.CreateAccountResponseStruct);
|
|
54
54
|
}
|
|
55
55
|
async filterAccountChains(id, chains) {
|
|
56
|
-
return (0,
|
|
56
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
57
57
|
method: rpc_1.KeyringRpcMethod.FilterAccountChains,
|
|
58
58
|
params: { id, chains },
|
|
59
59
|
}), api_1.FilterAccountChainsResponseStruct);
|
|
@@ -71,24 +71,24 @@ class KeyringClient {
|
|
|
71
71
|
}), api_1.DeleteAccountResponseStruct);
|
|
72
72
|
}
|
|
73
73
|
async exportAccount(id) {
|
|
74
|
-
return (0,
|
|
74
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
75
75
|
method: rpc_1.KeyringRpcMethod.ExportAccount,
|
|
76
76
|
params: { id },
|
|
77
77
|
}), api_1.ExportAccountResponseStruct);
|
|
78
78
|
}
|
|
79
79
|
async listRequests() {
|
|
80
|
-
return (0,
|
|
80
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
81
81
|
method: rpc_1.KeyringRpcMethod.ListRequests,
|
|
82
82
|
}), api_1.ListRequestsResponseStruct);
|
|
83
83
|
}
|
|
84
84
|
async getRequest(id) {
|
|
85
|
-
return (0,
|
|
85
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
86
86
|
method: rpc_1.KeyringRpcMethod.GetRequest,
|
|
87
87
|
params: { id },
|
|
88
88
|
}), api_1.GetRequestResponseStruct);
|
|
89
89
|
}
|
|
90
90
|
async submitRequest(request) {
|
|
91
|
-
return (0,
|
|
91
|
+
return (0, keyring_utils_1.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
92
92
|
method: rpc_1.KeyringRpcMethod.SubmitRequest,
|
|
93
93
|
params: request,
|
|
94
94
|
}), api_1.SubmitRequestResponseStruct);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyringClient.js","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,+BAAkC;AAWlC,wCAcwB;AACxB,wCAAkD;AAElD
|
|
1
|
+
{"version":3,"file":"KeyringClient.js","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":"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","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from '@metamask/keyring-utils';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
|
package/dist/api/account.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export declare type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccount
|
|
|
24
24
|
* See {@link KeyringAccount}.
|
|
25
25
|
*/
|
|
26
26
|
export declare const KeyringAccountStruct: import("@metamask/superstruct").Struct<{
|
|
27
|
-
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh";
|
|
28
27
|
id: string;
|
|
28
|
+
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh";
|
|
29
29
|
address: string;
|
|
30
30
|
options: Record<string, import("@metamask/utils").Json>;
|
|
31
31
|
methods: string[];
|
package/dist/api/account.js
CHANGED
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KeyringAccountStruct = exports.BtcAccountType = exports.EthAccountType = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
7
|
-
const utils_2 = require("../utils");
|
|
6
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
8
7
|
/**
|
|
9
8
|
* Supported Ethereum account types.
|
|
10
9
|
*/
|
|
@@ -27,11 +26,11 @@ var BtcAccountType;
|
|
|
27
26
|
*
|
|
28
27
|
* See {@link KeyringAccount}.
|
|
29
28
|
*/
|
|
30
|
-
exports.KeyringAccountStruct = (0,
|
|
29
|
+
exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
|
|
31
30
|
/**
|
|
32
31
|
* Account ID (UUIDv4).
|
|
33
32
|
*/
|
|
34
|
-
id:
|
|
33
|
+
id: keyring_utils_1.UuidStruct,
|
|
35
34
|
/**
|
|
36
35
|
* Account type.
|
|
37
36
|
*/
|
package/dist/api/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,2DAA6D;AAE7D;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAEzB;AAUD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,0BAAU;IAEd;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;KAC3B,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { object, UuidStruct } from '@metamask/keyring-utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
|
package/dist/api/balance.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BalanceStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
amount: utils_1.StringNumberStruct,
|
|
5
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
6
|
+
exports.BalanceStruct = (0, keyring_utils_1.object)({
|
|
7
|
+
amount: keyring_utils_1.StringNumberStruct,
|
|
9
8
|
unit: (0, superstruct_1.string)(),
|
|
10
9
|
});
|
|
11
10
|
//# sourceMappingURL=balance.js.map
|
package/dist/api/balance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,2DAAqE;AAExD,QAAA,aAAa,GAAG,IAAA,sBAAM,EAAC;IAClC,MAAM,EAAE,kCAAkB;IAC1B,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nimport { object, StringNumberStruct } from '@metamask/keyring-utils';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
|
package/dist/api/caip.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCaipAssetId = exports.isCaipAssetType = exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
-
const
|
|
5
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
6
6
|
const CAIP_ASSET_TYPE_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;
|
|
7
7
|
const CAIP_ASSET_ID_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;
|
|
8
8
|
/**
|
|
9
9
|
* A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
|
|
10
10
|
*/
|
|
11
|
-
exports.CaipAssetTypeStruct = (0,
|
|
11
|
+
exports.CaipAssetTypeStruct = (0, keyring_utils_1.definePattern)('CaipAssetType', CAIP_ASSET_TYPE_REGEX);
|
|
12
12
|
/**
|
|
13
13
|
* A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
|
|
14
14
|
*/
|
|
15
|
-
exports.CaipAssetIdStruct = (0,
|
|
15
|
+
exports.CaipAssetIdStruct = (0, keyring_utils_1.definePattern)('CaipAssetId', CAIP_ASSET_ID_REGEX);
|
|
16
16
|
/**
|
|
17
17
|
* Check if the given value is a {@link CaipAssetType}.
|
|
18
18
|
*
|
package/dist/api/caip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD,
|
|
1
|
+
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD,2DAAwD;AAExD,MAAM,qBAAqB,GACzB,2JAA2J,CAAC;AAE9J,MAAM,mBAAmB,GACvB,6LAA6L,CAAC;AAEhM;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,6BAAa,EAC9C,eAAe,EACf,qBAAqB,CACtB,CAAC;AAGF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,6BAAa,EAC5C,aAAa,EACb,mBAAmB,CACpB,CAAC;AAGF;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,2BAAmB,CAAC,CAAC;AACxC,CAAC;AAFD,0CAEC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,yBAAiB,CAAC,CAAC;AACtC,CAAC;AAFD,sCAEC","sourcesContent":["import { is, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '@metamask/keyring-utils';\n\nconst CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nconst CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct = definePattern(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n);\nexport type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = definePattern(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n);\nexport type CaipAssetId = Infer<typeof CaipAssetIdStruct>;\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // true\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false\n * ```\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // false\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true\n * ```\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n"]}
|
package/dist/api/request.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const KeyringRequestStruct: import("@metamask/superstruct").Struc
|
|
|
28
28
|
params?: import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>;
|
|
29
29
|
}, {
|
|
30
30
|
method: import("@metamask/superstruct").Struct<string, null>;
|
|
31
|
-
params: import("@metamask/superstruct").Struct<import("
|
|
31
|
+
params: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>, null>;
|
|
32
32
|
}>;
|
|
33
33
|
}>;
|
|
34
34
|
/**
|
package/dist/api/request.js
CHANGED
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KeyringRequestStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
exports.KeyringRequestStruct = (0, superstruct_2.object)({
|
|
6
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
7
|
+
exports.KeyringRequestStruct = (0, keyring_utils_1.object)({
|
|
9
8
|
/**
|
|
10
9
|
* Keyring request ID (UUIDv4).
|
|
11
10
|
*/
|
|
12
|
-
id:
|
|
11
|
+
id: keyring_utils_1.UuidStruct,
|
|
13
12
|
/**
|
|
14
13
|
* Request's scope (CAIP-2 chain ID).
|
|
15
14
|
*/
|
|
@@ -17,13 +16,13 @@ exports.KeyringRequestStruct = (0, superstruct_2.object)({
|
|
|
17
16
|
/**
|
|
18
17
|
* Account ID (UUIDv4).
|
|
19
18
|
*/
|
|
20
|
-
account:
|
|
19
|
+
account: keyring_utils_1.UuidStruct,
|
|
21
20
|
/**
|
|
22
21
|
* Inner request sent by the client application.
|
|
23
22
|
*/
|
|
24
|
-
request: (0,
|
|
23
|
+
request: (0, keyring_utils_1.object)({
|
|
25
24
|
method: (0, superstruct_1.string)(),
|
|
26
|
-
params: (0,
|
|
25
|
+
params: (0, keyring_utils_1.exactOptional)((0, superstruct_1.union)([(0, superstruct_1.array)(utils_1.JsonStruct), (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct)])),
|
|
27
26
|
}),
|
|
28
27
|
});
|
|
29
28
|
//# sourceMappingURL=request.js.map
|
package/dist/api/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,2DAA4E;AAE/D,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,0BAAU;IAEd;;OAEG;IACH,KAAK,EAAE,IAAA,oBAAM,GAAE;IAEf;;OAEG;IACH,OAAO,EAAE,0BAAU;IAEnB;;OAEG;IACH,OAAO,EAAE,IAAA,sBAAM,EAAC;QACd,MAAM,EAAE,IAAA,oBAAM,GAAE;QAChB,MAAM,EAAE,IAAA,6BAAa,EACnB,IAAA,mBAAK,EAAC,CAAC,IAAA,mBAAK,EAAC,kBAAU,CAAC,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC,CAAC,CACzD;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, record, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object, UuidStruct } from '@metamask/keyring-utils';\n\nexport const KeyringRequestStruct = object({\n /**\n * Keyring request ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Request's scope (CAIP-2 chain ID).\n */\n scope: string(),\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Inner request sent by the client application.\n */\n request: object({\n method: string(),\n params: exactOptional(\n union([array(JsonStruct), record(string(), JsonStruct)]),\n ),\n }),\n});\n\n/**\n * Keyring request.\n *\n * Represents a request made to the keyring for account-related operations.\n */\nexport type KeyringRequest = Infer<typeof KeyringRequestStruct>;\n"]}
|
package/dist/api/response.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KeyringResponseStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
6
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
7
7
|
exports.KeyringResponseStruct = (0, superstruct_1.union)([
|
|
8
|
-
(0,
|
|
8
|
+
(0, keyring_utils_1.object)({
|
|
9
9
|
/**
|
|
10
10
|
* Pending flag.
|
|
11
11
|
*
|
|
@@ -21,12 +21,12 @@ exports.KeyringResponseStruct = (0, superstruct_1.union)([
|
|
|
21
21
|
* with a link to the redirect URL. The user can choose to follow the link
|
|
22
22
|
* or cancel the request.
|
|
23
23
|
*/
|
|
24
|
-
redirect: (0,
|
|
25
|
-
message: (0,
|
|
26
|
-
url: (0,
|
|
24
|
+
redirect: (0, keyring_utils_1.exactOptional)((0, keyring_utils_1.object)({
|
|
25
|
+
message: (0, keyring_utils_1.exactOptional)((0, superstruct_1.string)()),
|
|
26
|
+
url: (0, keyring_utils_1.exactOptional)((0, superstruct_1.string)()),
|
|
27
27
|
})),
|
|
28
28
|
}),
|
|
29
|
-
(0,
|
|
29
|
+
(0, keyring_utils_1.object)({
|
|
30
30
|
/**
|
|
31
31
|
* Pending flag.
|
|
32
32
|
*
|
package/dist/api/response.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAC/D,2CAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAC/D,2CAA6C;AAE7C,2DAAgE;AAEnD,QAAA,qBAAqB,GAAG,IAAA,mBAAK,EAAC;IACzC,IAAA,sBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;QAEtB;;;;;;WAMG;QACH,QAAQ,EAAE,IAAA,6BAAa,EACrB,IAAA,sBAAM,EAAC;YACL,OAAO,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;YAChC,GAAG,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;SAC7B,CAAC,CACH;KACF,CAAC;IACF,IAAA,sBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;QAEvB;;WAEG;QACH,MAAM,EAAE,kBAAU;KACnB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from '@metamask/keyring-utils';\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
|
@@ -7,8 +7,8 @@ export declare enum BtcMethod {
|
|
|
7
7
|
SendMany = "btc_sendmany"
|
|
8
8
|
}
|
|
9
9
|
export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
|
|
10
|
-
type: "bip122:p2wpkh";
|
|
11
10
|
id: string;
|
|
11
|
+
type: "bip122:p2wpkh";
|
|
12
12
|
address: string;
|
|
13
13
|
options: Record<string, import("@metamask/utils").Json>;
|
|
14
14
|
methods: "btc_sendmany"[];
|
package/dist/btc/types.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.BtcP2wpkhAccountStruct = exports.BtcMethod = exports.BtcP2wpkhAddressStr
|
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const bech32_1 = require("bech32");
|
|
6
6
|
const api_1 = require("../api");
|
|
7
|
-
const
|
|
7
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
8
8
|
exports.BtcP2wpkhAddressStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'BtcP2wpkhAddressStruct', (address) => {
|
|
9
9
|
try {
|
|
10
10
|
bech32_1.bech32.decode(address);
|
|
@@ -22,7 +22,7 @@ var BtcMethod;
|
|
|
22
22
|
// General transaction methods
|
|
23
23
|
BtcMethod["SendMany"] = "btc_sendmany";
|
|
24
24
|
})(BtcMethod = exports.BtcMethod || (exports.BtcMethod = {}));
|
|
25
|
-
exports.BtcP2wpkhAccountStruct = (0,
|
|
25
|
+
exports.BtcP2wpkhAccountStruct = (0, keyring_utils_1.object)({
|
|
26
26
|
...api_1.KeyringAccountStruct.schema,
|
|
27
27
|
/**
|
|
28
28
|
* Account address.
|
package/dist/btc/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AACA,uDAA8E;AAC9E,mCAAgC;AAEhC,gCAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AACA,uDAA8E;AAC9E,mCAAgC;AAEhC,gCAA8D;AAC9D,2DAAiD;AAEpC,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,sBAAM,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 type { Infer } from '@metamask/superstruct';\nimport { string, array, enums, refine, literal } from '@metamask/superstruct';\nimport { bech32 } from 'bech32';\n\nimport { KeyringAccountStruct, BtcAccountType } from '../api';\nimport { object } from '@metamask/keyring-utils';\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"]}
|
|
@@ -34,8 +34,8 @@ export declare type EthUserOperation = Infer<typeof EthUserOperationStruct>;
|
|
|
34
34
|
* construct a UserOperation.
|
|
35
35
|
*/
|
|
36
36
|
export declare const EthBaseTransactionStruct: import("@metamask/superstruct").Struct<{
|
|
37
|
-
value: string;
|
|
38
37
|
data: string;
|
|
38
|
+
value: string;
|
|
39
39
|
to: string;
|
|
40
40
|
}, {
|
|
41
41
|
/**
|
|
@@ -68,7 +68,7 @@ export declare const EthBaseUserOperationStruct: import("@metamask/superstruct")
|
|
|
68
68
|
nonce: import("@metamask/superstruct").Struct<string, null>;
|
|
69
69
|
initCode: import("@metamask/superstruct").Struct<string, null>;
|
|
70
70
|
callData: import("@metamask/superstruct").Struct<string, null>;
|
|
71
|
-
gasLimits: import("@metamask/superstruct").Struct<import("
|
|
71
|
+
gasLimits: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
|
|
72
72
|
callGasLimit: string;
|
|
73
73
|
verificationGasLimit: string;
|
|
74
74
|
preVerificationGas: string;
|
|
@@ -89,8 +89,8 @@ export declare const EthUserOperationPatchStruct: import("@metamask/superstruct"
|
|
|
89
89
|
preVerificationGas?: string;
|
|
90
90
|
}, {
|
|
91
91
|
paymasterAndData: import("@metamask/superstruct").Struct<string, null>;
|
|
92
|
-
callGasLimit: import("@metamask/superstruct").Struct<string | import("
|
|
93
|
-
verificationGasLimit: import("@metamask/superstruct").Struct<string | import("
|
|
94
|
-
preVerificationGas: import("@metamask/superstruct").Struct<string | import("
|
|
92
|
+
callGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
|
93
|
+
verificationGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
|
94
|
+
preVerificationGas: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
|
|
95
95
|
}>;
|
|
96
96
|
export declare type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EthUserOperationPatchStruct = exports.EthBaseUserOperationStruct = exports.EthBaseTransactionStruct = exports.EthUserOperationStruct = void 0;
|
|
4
|
-
const
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
4
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
6
5
|
const types_1 = require("../types");
|
|
7
6
|
/**
|
|
8
7
|
* Struct of a UserOperation as defined by ERC-4337.
|
|
9
8
|
* @see https://eips.ethereum.org/EIPS/eip-4337#definitions
|
|
10
9
|
*/
|
|
11
|
-
exports.EthUserOperationStruct = (0,
|
|
10
|
+
exports.EthUserOperationStruct = (0, keyring_utils_1.object)({
|
|
12
11
|
sender: types_1.EthAddressStruct,
|
|
13
12
|
nonce: types_1.EthUint256Struct,
|
|
14
13
|
initCode: types_1.EthBytesStruct,
|
|
@@ -25,7 +24,7 @@ exports.EthUserOperationStruct = (0, superstruct_1.object)({
|
|
|
25
24
|
* Struct containing the most basic transaction information required to
|
|
26
25
|
* construct a UserOperation.
|
|
27
26
|
*/
|
|
28
|
-
exports.EthBaseTransactionStruct = (0,
|
|
27
|
+
exports.EthBaseTransactionStruct = (0, keyring_utils_1.object)({
|
|
29
28
|
/**
|
|
30
29
|
* Address of the transaction recipient.
|
|
31
30
|
*/
|
|
@@ -39,23 +38,23 @@ exports.EthBaseTransactionStruct = (0, superstruct_1.object)({
|
|
|
39
38
|
*/
|
|
40
39
|
data: types_1.EthBytesStruct,
|
|
41
40
|
});
|
|
42
|
-
exports.EthBaseUserOperationStruct = (0,
|
|
41
|
+
exports.EthBaseUserOperationStruct = (0, keyring_utils_1.object)({
|
|
43
42
|
nonce: types_1.EthUint256Struct,
|
|
44
43
|
initCode: types_1.EthBytesStruct,
|
|
45
44
|
callData: types_1.EthBytesStruct,
|
|
46
|
-
gasLimits: (0,
|
|
45
|
+
gasLimits: (0, keyring_utils_1.exactOptional)((0, keyring_utils_1.object)({
|
|
47
46
|
callGasLimit: types_1.EthUint256Struct,
|
|
48
47
|
verificationGasLimit: types_1.EthUint256Struct,
|
|
49
48
|
preVerificationGas: types_1.EthUint256Struct,
|
|
50
49
|
})),
|
|
51
50
|
dummyPaymasterAndData: types_1.EthBytesStruct,
|
|
52
51
|
dummySignature: types_1.EthBytesStruct,
|
|
53
|
-
bundlerUrl:
|
|
52
|
+
bundlerUrl: keyring_utils_1.UrlStruct,
|
|
54
53
|
});
|
|
55
|
-
exports.EthUserOperationPatchStruct = (0,
|
|
54
|
+
exports.EthUserOperationPatchStruct = (0, keyring_utils_1.object)({
|
|
56
55
|
paymasterAndData: types_1.EthBytesStruct,
|
|
57
|
-
callGasLimit: (0,
|
|
58
|
-
verificationGasLimit: (0,
|
|
59
|
-
preVerificationGas: (0,
|
|
56
|
+
callGasLimit: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
|
|
57
|
+
verificationGasLimit: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
|
|
58
|
+
preVerificationGas: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
|
|
60
59
|
});
|
|
61
60
|
//# sourceMappingURL=types.js.map
|
|
@@ -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,2DAA2E;AAC3E,oCAA8E;AAE9E;;;GAGG;AACU,QAAA,sBAAsB,GAAG,IAAA,sBAAM,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,sBAAM,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,sBAAM,EAAC;IAC/C,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,SAAS,EAAE,IAAA,6BAAa,EACtB,IAAA,sBAAM,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,yBAAS;CACtB,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,sBAAM,EAAC;IAChD,gBAAgB,EAAE,sBAAc;IAChC,YAAY,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;IAC7C,oBAAoB,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;IACrD,kBAAkB,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { type Infer } from '@metamask/superstruct';\n\nimport { exactOptional, object, UrlStruct } from '@metamask/keyring-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
|
@@ -17,8 +17,8 @@ export declare enum EthMethod {
|
|
|
17
17
|
SignUserOperation = "eth_signUserOperation"
|
|
18
18
|
}
|
|
19
19
|
export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct<{
|
|
20
|
-
type: "eip155:eoa";
|
|
21
20
|
id: string;
|
|
21
|
+
type: "eip155:eoa";
|
|
22
22
|
address: string;
|
|
23
23
|
options: Record<string, import("@metamask/utils").Json>;
|
|
24
24
|
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
|
|
@@ -47,8 +47,8 @@ export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct
|
|
|
47
47
|
}>;
|
|
48
48
|
export declare type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;
|
|
49
49
|
export declare const EthErc4337AccountStruct: import("@metamask/superstruct").Struct<{
|
|
50
|
-
type: "eip155:erc4337";
|
|
51
50
|
id: string;
|
|
51
|
+
type: "eip155:erc4337";
|
|
52
52
|
address: string;
|
|
53
53
|
options: Record<string, import("@metamask/utils").Json>;
|
|
54
54
|
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
|
package/dist/eth/types.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
|
-
const
|
|
7
|
-
exports.EthBytesStruct = (0,
|
|
8
|
-
exports.EthAddressStruct = (0,
|
|
9
|
-
exports.EthUint256Struct = (0,
|
|
6
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
7
|
+
exports.EthBytesStruct = (0, keyring_utils_1.definePattern)('EthBytes', /^0x[0-9a-f]*$/iu);
|
|
8
|
+
exports.EthAddressStruct = (0, keyring_utils_1.definePattern)('EthAddress', /^0x[0-9a-f]{40}$/iu);
|
|
9
|
+
exports.EthUint256Struct = (0, keyring_utils_1.definePattern)('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu);
|
|
10
10
|
/**
|
|
11
11
|
* Supported Ethereum methods.
|
|
12
12
|
*/
|
|
@@ -24,7 +24,7 @@ var EthMethod;
|
|
|
24
24
|
EthMethod["PatchUserOperation"] = "eth_patchUserOperation";
|
|
25
25
|
EthMethod["SignUserOperation"] = "eth_signUserOperation";
|
|
26
26
|
})(EthMethod = exports.EthMethod || (exports.EthMethod = {}));
|
|
27
|
-
exports.EthEoaAccountStruct = (0,
|
|
27
|
+
exports.EthEoaAccountStruct = (0, keyring_utils_1.object)({
|
|
28
28
|
...api_1.KeyringAccountStruct.schema,
|
|
29
29
|
/**
|
|
30
30
|
* Account address.
|
|
@@ -46,7 +46,7 @@ exports.EthEoaAccountStruct = (0, superstruct_2.object)({
|
|
|
46
46
|
`${EthMethod.SignTypedDataV4}`,
|
|
47
47
|
])),
|
|
48
48
|
});
|
|
49
|
-
exports.EthErc4337AccountStruct = (0,
|
|
49
|
+
exports.EthErc4337AccountStruct = (0, keyring_utils_1.object)({
|
|
50
50
|
...api_1.KeyringAccountStruct.schema,
|
|
51
51
|
/**
|
|
52
52
|
* Account address.
|
package/dist/eth/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AACA,uDAA8D;AAE9D,gCAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AACA,uDAA8D;AAE9D,gCAA8D;AAC9D,2DAAgE;AAEnD,QAAA,cAAc,GAAG,IAAA,6BAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE9D,QAAA,gBAAgB,GAAG,IAAA,6BAAa,EAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,6BAAa,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,sBAAM,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,sBAAM,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 '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\nimport { EthAccountType, KeyringAccountStruct } from '../api';\nimport { object, definePattern } from '@metamask/keyring-utils';\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/index.d.ts
CHANGED