@metamask/eip-5792-middleware 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/dist/constants.cjs +10 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +7 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +7 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +9 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/{methods → hooks}/getCallsStatus.cjs +5 -6
- package/dist/hooks/getCallsStatus.cjs.map +1 -0
- package/dist/{methods → hooks}/getCallsStatus.d.cts +1 -2
- package/dist/hooks/getCallsStatus.d.cts.map +1 -0
- package/dist/{methods → hooks}/getCallsStatus.d.mts +1 -2
- package/dist/hooks/getCallsStatus.d.mts.map +1 -0
- package/dist/{methods → hooks}/getCallsStatus.mjs +1 -2
- package/dist/hooks/getCallsStatus.mjs.map +1 -0
- package/dist/hooks/getCapabilities.cjs.map +1 -0
- package/dist/{methods → hooks}/getCapabilities.d.cts +1 -2
- package/dist/hooks/getCapabilities.d.cts.map +1 -0
- package/dist/{methods → hooks}/getCapabilities.d.mts +1 -2
- package/dist/hooks/getCapabilities.d.mts.map +1 -0
- package/dist/hooks/getCapabilities.mjs.map +1 -0
- package/dist/hooks/processSendCalls.cjs.map +1 -0
- package/dist/{methods → hooks}/processSendCalls.d.cts +2 -3
- package/dist/hooks/processSendCalls.d.cts.map +1 -0
- package/dist/{methods → hooks}/processSendCalls.d.mts +2 -3
- package/dist/hooks/processSendCalls.d.mts.map +1 -0
- package/dist/hooks/processSendCalls.mjs.map +1 -0
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/methods/wallet_getCallsStatus.cjs +24 -0
- package/dist/methods/wallet_getCallsStatus.cjs.map +1 -0
- package/dist/methods/wallet_getCallsStatus.d.cts +14 -0
- package/dist/methods/wallet_getCallsStatus.d.cts.map +1 -0
- package/dist/methods/wallet_getCallsStatus.d.mts +14 -0
- package/dist/methods/wallet_getCallsStatus.d.mts.map +1 -0
- package/dist/methods/wallet_getCallsStatus.mjs +20 -0
- package/dist/methods/wallet_getCallsStatus.mjs.map +1 -0
- package/dist/methods/wallet_getCapabilities.cjs +30 -0
- package/dist/methods/wallet_getCapabilities.cjs.map +1 -0
- package/dist/methods/wallet_getCapabilities.d.cts +16 -0
- package/dist/methods/wallet_getCapabilities.d.cts.map +1 -0
- package/dist/methods/wallet_getCapabilities.d.mts +16 -0
- package/dist/methods/wallet_getCapabilities.d.mts.map +1 -0
- package/dist/methods/wallet_getCapabilities.mjs +26 -0
- package/dist/methods/wallet_getCapabilities.mjs.map +1 -0
- package/dist/methods/wallet_sendCalls.cjs +34 -0
- package/dist/methods/wallet_sendCalls.cjs.map +1 -0
- package/dist/methods/wallet_sendCalls.d.cts +16 -0
- package/dist/methods/wallet_sendCalls.d.cts.map +1 -0
- package/dist/methods/wallet_sendCalls.d.mts +16 -0
- package/dist/methods/wallet_sendCalls.d.mts.map +1 -0
- package/dist/methods/wallet_sendCalls.mjs +30 -0
- package/dist/methods/wallet_sendCalls.mjs.map +1 -0
- package/dist/types.cjs +30 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +57 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +57 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +29 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs +70 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +31 -1
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +31 -1
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +67 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +3 -1
- package/dist/methods/getCallsStatus.cjs.map +0 -1
- package/dist/methods/getCallsStatus.d.cts.map +0 -1
- package/dist/methods/getCallsStatus.d.mts.map +0 -1
- package/dist/methods/getCallsStatus.mjs.map +0 -1
- package/dist/methods/getCapabilities.cjs.map +0 -1
- package/dist/methods/getCapabilities.d.cts.map +0 -1
- package/dist/methods/getCapabilities.d.mts.map +0 -1
- package/dist/methods/getCapabilities.mjs.map +0 -1
- package/dist/methods/processSendCalls.cjs.map +0 -1
- package/dist/methods/processSendCalls.d.cts.map +0 -1
- package/dist/methods/processSendCalls.d.mts.map +0 -1
- package/dist/methods/processSendCalls.mjs.map +0 -1
- /package/dist/{methods → hooks}/getCapabilities.cjs +0 -0
- /package/dist/{methods → hooks}/getCapabilities.mjs +0 -0
- /package/dist/{methods → hooks}/processSendCalls.cjs +0 -0
- /package/dist/{methods → hooks}/processSendCalls.mjs +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
+
import { type GetCallsStatusHook } from "../types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The RPC method handler middleware for `wallet_getCallStatus`
|
|
5
|
+
*
|
|
6
|
+
* @param req - The JSON RPC request's end callback.
|
|
7
|
+
* @param res - The JSON RPC request's pending response object.
|
|
8
|
+
* @param hooks - The hooks object.
|
|
9
|
+
* @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.
|
|
10
|
+
*/
|
|
11
|
+
export declare function walletGetCallsStatus(req: JsonRpcRequest, res: PendingJsonRpcResponse, { getCallsStatus, }: {
|
|
12
|
+
getCallsStatus?: GetCallsStatusHook;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=wallet_getCallsStatus.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAE9E,OAAO,EAAE,KAAK,kBAAkB,EAAwB,qBAAiB;AAGzE;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,cAAc,GACf,EAAE;IACD,cAAc,CAAC,EAAE,kBAAkB,CAAC;CACrC,GACA,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
import { GetCallsStatusStruct } from "../types.mjs";
|
|
3
|
+
import { validateParams } from "../utils.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* The RPC method handler middleware for `wallet_getCallStatus`
|
|
6
|
+
*
|
|
7
|
+
* @param req - The JSON RPC request's end callback.
|
|
8
|
+
* @param res - The JSON RPC request's pending response object.
|
|
9
|
+
* @param hooks - The hooks object.
|
|
10
|
+
* @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.
|
|
11
|
+
*/
|
|
12
|
+
export async function walletGetCallsStatus(req, res, { getCallsStatus, }) {
|
|
13
|
+
if (!getCallsStatus) {
|
|
14
|
+
throw rpcErrors.methodNotSupported();
|
|
15
|
+
}
|
|
16
|
+
validateParams(req.params, GetCallsStatusStruct);
|
|
17
|
+
const id = req.params[0];
|
|
18
|
+
res.result = await getCallsStatus(id, req);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=wallet_getCallsStatus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCallsStatus.mjs","sourceRoot":"","sources":["../../src/methods/wallet_getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAA2B,oBAAoB,EAAE,qBAAiB;AACzE,OAAO,EAAE,cAAc,EAAE,qBAAiB;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAmB,EACnB,GAA2B,EAC3B,EACE,cAAc,GAGf;IAED,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAC;KACtC;IAED,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAEjD,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEzB,GAAG,CAAC,MAAM,GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { type GetCallsStatusHook, GetCallsStatusStruct } from '../types';\nimport { validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCallStatus`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getCallsStatus - Function that retrieves the status of a transaction batch by its ID.\n */\nexport async function walletGetCallsStatus(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getCallsStatus,\n }: {\n getCallsStatus?: GetCallsStatusHook;\n },\n): Promise<void> {\n if (!getCallsStatus) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCallsStatusStruct);\n\n const id = req.params[0];\n\n res.result = await getCallsStatus(id, req);\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walletGetCapabilities = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const types_1 = require("../types.cjs");
|
|
6
|
+
const utils_1 = require("../utils.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* The RPC method handler middleware for `wallet_getCapabilities`
|
|
9
|
+
*
|
|
10
|
+
* @param req - The JSON RPC request's end callback.
|
|
11
|
+
* @param res - The JSON RPC request's pending response object.
|
|
12
|
+
* @param hooks - The hooks object.
|
|
13
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
14
|
+
* @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.
|
|
15
|
+
*/
|
|
16
|
+
async function walletGetCapabilities(req, res, { getAccounts, getCapabilities, }) {
|
|
17
|
+
if (!getCapabilities) {
|
|
18
|
+
throw rpc_errors_1.rpcErrors.methodNotSupported();
|
|
19
|
+
}
|
|
20
|
+
(0, utils_1.validateParams)(req.params, types_1.GetCapabilitiesStruct);
|
|
21
|
+
const address = req.params[0];
|
|
22
|
+
const chainIds = req.params[1];
|
|
23
|
+
await (0, utils_1.validateAndNormalizeKeyholder)(address, req, {
|
|
24
|
+
getAccounts,
|
|
25
|
+
});
|
|
26
|
+
const capabilities = await getCapabilities(address, chainIds, req);
|
|
27
|
+
res.result = capabilities;
|
|
28
|
+
}
|
|
29
|
+
exports.walletGetCapabilities = walletGetCapabilities;
|
|
30
|
+
//# sourceMappingURL=wallet_getCapabilities.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.cjs","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,wCAA2E;AAC3E,wCAAyE;AAEzE;;;;;;;;GAQG;AACI,KAAK,UAAU,qBAAqB,CACzC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,eAAe,GAIhB;IAED,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,sBAAS,CAAC,kBAAkB,EAAE,CAAC;KACtC;IAED,IAAA,sBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,6BAAqB,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/B,MAAM,IAAA,qCAA6B,EAAC,OAAO,EAAE,GAAG,EAAE;QAChD,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAEnE,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC;AAC5B,CAAC;AA3BD,sDA2BC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { type GetCapabilitiesHook, GetCapabilitiesStruct } from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCapabilities`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.\n */\nexport async function walletGetCapabilities(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n getCapabilities,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n getCapabilities?: GetCapabilitiesHook;\n },\n): Promise<void> {\n if (!getCapabilities) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCapabilitiesStruct);\n\n const address = req.params[0];\n const chainIds = req.params[1];\n\n await validateAndNormalizeKeyholder(address, req, {\n getAccounts,\n });\n\n const capabilities = await getCapabilities(address, chainIds, req);\n\n res.result = capabilities;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
+
import { type GetCapabilitiesHook } from "../types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* The RPC method handler middleware for `wallet_getCapabilities`
|
|
5
|
+
*
|
|
6
|
+
* @param req - The JSON RPC request's end callback.
|
|
7
|
+
* @param res - The JSON RPC request's pending response object.
|
|
8
|
+
* @param hooks - The hooks object.
|
|
9
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
10
|
+
* @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.
|
|
11
|
+
*/
|
|
12
|
+
export declare function walletGetCapabilities(req: JsonRpcRequest, res: PendingJsonRpcResponse, { getAccounts, getCapabilities, }: {
|
|
13
|
+
getAccounts: (req: JsonRpcRequest) => Promise<string[]>;
|
|
14
|
+
getCapabilities?: GetCapabilitiesHook;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=wallet_getCapabilities.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAE9E,OAAO,EAAE,KAAK,mBAAmB,EAAyB,qBAAiB;AAG3E;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,eAAe,GAChB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC,GACA,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
+
import { type GetCapabilitiesHook } from "../types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The RPC method handler middleware for `wallet_getCapabilities`
|
|
5
|
+
*
|
|
6
|
+
* @param req - The JSON RPC request's end callback.
|
|
7
|
+
* @param res - The JSON RPC request's pending response object.
|
|
8
|
+
* @param hooks - The hooks object.
|
|
9
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
10
|
+
* @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.
|
|
11
|
+
*/
|
|
12
|
+
export declare function walletGetCapabilities(req: JsonRpcRequest, res: PendingJsonRpcResponse, { getAccounts, getCapabilities, }: {
|
|
13
|
+
getAccounts: (req: JsonRpcRequest) => Promise<string[]>;
|
|
14
|
+
getCapabilities?: GetCapabilitiesHook;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=wallet_getCapabilities.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAE9E,OAAO,EAAE,KAAK,mBAAmB,EAAyB,qBAAiB;AAG3E;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,eAAe,GAChB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC,GACA,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
import { GetCapabilitiesStruct } from "../types.mjs";
|
|
3
|
+
import { validateAndNormalizeKeyholder, validateParams } from "../utils.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* The RPC method handler middleware for `wallet_getCapabilities`
|
|
6
|
+
*
|
|
7
|
+
* @param req - The JSON RPC request's end callback.
|
|
8
|
+
* @param res - The JSON RPC request's pending response object.
|
|
9
|
+
* @param hooks - The hooks object.
|
|
10
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
11
|
+
* @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.
|
|
12
|
+
*/
|
|
13
|
+
export async function walletGetCapabilities(req, res, { getAccounts, getCapabilities, }) {
|
|
14
|
+
if (!getCapabilities) {
|
|
15
|
+
throw rpcErrors.methodNotSupported();
|
|
16
|
+
}
|
|
17
|
+
validateParams(req.params, GetCapabilitiesStruct);
|
|
18
|
+
const address = req.params[0];
|
|
19
|
+
const chainIds = req.params[1];
|
|
20
|
+
await validateAndNormalizeKeyholder(address, req, {
|
|
21
|
+
getAccounts,
|
|
22
|
+
});
|
|
23
|
+
const capabilities = await getCapabilities(address, chainIds, req);
|
|
24
|
+
res.result = capabilities;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=wallet_getCapabilities.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_getCapabilities.mjs","sourceRoot":"","sources":["../../src/methods/wallet_getCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAA4B,qBAAqB,EAAE,qBAAiB;AAC3E,OAAO,EAAE,6BAA6B,EAAE,cAAc,EAAE,qBAAiB;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,eAAe,GAIhB;IAED,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAC;KACtC;IAED,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/B,MAAM,6BAA6B,CAAC,OAAO,EAAE,GAAG,EAAE;QAChD,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IAEnE,GAAG,CAAC,MAAM,GAAG,YAAY,CAAC;AAC5B,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { type GetCapabilitiesHook, GetCapabilitiesStruct } from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_getCapabilities`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.getCapabilities - Function that retrieves the capabilities for atomic transactions on specified chains.\n */\nexport async function walletGetCapabilities(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n getCapabilities,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n getCapabilities?: GetCapabilitiesHook;\n },\n): Promise<void> {\n if (!getCapabilities) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, GetCapabilitiesStruct);\n\n const address = req.params[0];\n const chainIds = req.params[1];\n\n await validateAndNormalizeKeyholder(address, req, {\n getAccounts,\n });\n\n const capabilities = await getCapabilities(address, chainIds, req);\n\n res.result = capabilities;\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.walletSendCalls = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const types_1 = require("../types.cjs");
|
|
6
|
+
const utils_1 = require("../utils.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* The RPC method handler middleware for `wallet_sendCalls`
|
|
9
|
+
*
|
|
10
|
+
* @param req - The JSON RPC request's end callback.
|
|
11
|
+
* @param res - The JSON RPC request's pending response object.
|
|
12
|
+
* @param hooks - The hooks object.
|
|
13
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
14
|
+
* @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.
|
|
15
|
+
*/
|
|
16
|
+
async function walletSendCalls(req, res, { getAccounts, processSendCalls, }) {
|
|
17
|
+
if (!processSendCalls) {
|
|
18
|
+
throw rpc_errors_1.rpcErrors.methodNotSupported();
|
|
19
|
+
}
|
|
20
|
+
(0, utils_1.validateParams)(req.params, types_1.SendCallsStruct);
|
|
21
|
+
const params = req.params[0];
|
|
22
|
+
const from = params.from
|
|
23
|
+
? await (0, utils_1.validateAndNormalizeKeyholder)(params.from, req, {
|
|
24
|
+
getAccounts,
|
|
25
|
+
})
|
|
26
|
+
: undefined;
|
|
27
|
+
const sendCalls = {
|
|
28
|
+
...params,
|
|
29
|
+
from,
|
|
30
|
+
};
|
|
31
|
+
res.result = await processSendCalls(sendCalls, req);
|
|
32
|
+
}
|
|
33
|
+
exports.walletSendCalls = walletSendCalls;
|
|
34
|
+
//# sourceMappingURL=wallet_sendCalls.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.cjs","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAGjD,wCAIkB;AAClB,wCAAyE;AAEzE;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,gBAAgB,GAIjB;IAED,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,sBAAS,CAAC,kBAAkB,EAAE,CAAC;KACtC;IAED,IAAA,sBAAc,EAAC,GAAG,CAAC,MAAM,EAAE,uBAAe,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;QACtB,CAAC,CAAC,MAAM,IAAA,qCAA6B,EAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACpD,WAAW;SACZ,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,SAAS,GAAqB;QAClC,GAAG,MAAM;QACT,IAAI;KACL,CAAC;IAEF,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC;AA/BD,0CA+BC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport {\n type ProcessSendCallsHook,\n type SendCallsPayload,\n SendCallsStruct,\n} from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_sendCalls`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.\n */\nexport async function walletSendCalls(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n processSendCalls,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n processSendCalls?: ProcessSendCallsHook;\n },\n): Promise<void> {\n if (!processSendCalls) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, SendCallsStruct);\n\n const params = req.params[0];\n\n const from = params.from\n ? await validateAndNormalizeKeyholder(params.from, req, {\n getAccounts,\n })\n : undefined;\n\n const sendCalls: SendCallsPayload = {\n ...params,\n from,\n };\n\n res.result = await processSendCalls(sendCalls, req);\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
+
import { type ProcessSendCallsHook } from "../types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* The RPC method handler middleware for `wallet_sendCalls`
|
|
5
|
+
*
|
|
6
|
+
* @param req - The JSON RPC request's end callback.
|
|
7
|
+
* @param res - The JSON RPC request's pending response object.
|
|
8
|
+
* @param hooks - The hooks object.
|
|
9
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
10
|
+
* @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.
|
|
11
|
+
*/
|
|
12
|
+
export declare function walletSendCalls(req: JsonRpcRequest, res: PendingJsonRpcResponse, { getAccounts, processSendCalls, }: {
|
|
13
|
+
getAccounts: (req: JsonRpcRequest) => Promise<string[]>;
|
|
14
|
+
processSendCalls?: ProcessSendCallsHook;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=wallet_sendCalls.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.d.cts","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAE9E,OAAO,EACL,KAAK,oBAAoB,EAG1B,qBAAiB;AAGlB;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC,GACA,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonRpcRequest, PendingJsonRpcResponse } from "@metamask/utils";
|
|
2
|
+
import { type ProcessSendCallsHook } from "../types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The RPC method handler middleware for `wallet_sendCalls`
|
|
5
|
+
*
|
|
6
|
+
* @param req - The JSON RPC request's end callback.
|
|
7
|
+
* @param res - The JSON RPC request's pending response object.
|
|
8
|
+
* @param hooks - The hooks object.
|
|
9
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
10
|
+
* @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.
|
|
11
|
+
*/
|
|
12
|
+
export declare function walletSendCalls(req: JsonRpcRequest, res: PendingJsonRpcResponse, { getAccounts, processSendCalls, }: {
|
|
13
|
+
getAccounts: (req: JsonRpcRequest) => Promise<string[]>;
|
|
14
|
+
processSendCalls?: ProcessSendCallsHook;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=wallet_sendCalls.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.d.mts","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,wBAAwB;AAE9E,OAAO,EACL,KAAK,oBAAoB,EAG1B,qBAAiB;AAGlB;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,sBAAsB,EAC3B,EACE,WAAW,EACX,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC,GACA,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
import { SendCallsStruct } from "../types.mjs";
|
|
3
|
+
import { validateAndNormalizeKeyholder, validateParams } from "../utils.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* The RPC method handler middleware for `wallet_sendCalls`
|
|
6
|
+
*
|
|
7
|
+
* @param req - The JSON RPC request's end callback.
|
|
8
|
+
* @param res - The JSON RPC request's pending response object.
|
|
9
|
+
* @param hooks - The hooks object.
|
|
10
|
+
* @param hooks.getAccounts - Function that retrieves available accounts.
|
|
11
|
+
* @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.
|
|
12
|
+
*/
|
|
13
|
+
export async function walletSendCalls(req, res, { getAccounts, processSendCalls, }) {
|
|
14
|
+
if (!processSendCalls) {
|
|
15
|
+
throw rpcErrors.methodNotSupported();
|
|
16
|
+
}
|
|
17
|
+
validateParams(req.params, SendCallsStruct);
|
|
18
|
+
const params = req.params[0];
|
|
19
|
+
const from = params.from
|
|
20
|
+
? await validateAndNormalizeKeyholder(params.from, req, {
|
|
21
|
+
getAccounts,
|
|
22
|
+
})
|
|
23
|
+
: undefined;
|
|
24
|
+
const sendCalls = {
|
|
25
|
+
...params,
|
|
26
|
+
from,
|
|
27
|
+
};
|
|
28
|
+
res.result = await processSendCalls(sendCalls, req);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=wallet_sendCalls.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_sendCalls.mjs","sourceRoot":"","sources":["../../src/methods/wallet_sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAGL,eAAe,EAChB,qBAAiB;AAClB,OAAO,EAAE,6BAA6B,EAAE,cAAc,EAAE,qBAAiB;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAmB,EACnB,GAA2B,EAC3B,EACE,WAAW,EACX,gBAAgB,GAIjB;IAED,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAC;KACtC;IAED,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAE5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI;QACtB,CAAC,CAAC,MAAM,6BAA6B,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACpD,WAAW;SACZ,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,SAAS,GAAqB;QAClC,GAAG,MAAM;QACT,IAAI;KACL,CAAC;IAEF,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\nimport {\n type ProcessSendCallsHook,\n type SendCallsPayload,\n SendCallsStruct,\n} from '../types';\nimport { validateAndNormalizeKeyholder, validateParams } from '../utils';\n\n/**\n * The RPC method handler middleware for `wallet_sendCalls`\n *\n * @param req - The JSON RPC request's end callback.\n * @param res - The JSON RPC request's pending response object.\n * @param hooks - The hooks object.\n * @param hooks.getAccounts - Function that retrieves available accounts.\n * @param hooks.processSendCalls - Function that processes a sendCalls request for EIP-5792 transactions.\n */\nexport async function walletSendCalls(\n req: JsonRpcRequest,\n res: PendingJsonRpcResponse,\n {\n getAccounts,\n processSendCalls,\n }: {\n getAccounts: (req: JsonRpcRequest) => Promise<string[]>;\n processSendCalls?: ProcessSendCallsHook;\n },\n): Promise<void> {\n if (!processSendCalls) {\n throw rpcErrors.methodNotSupported();\n }\n\n validateParams(req.params, SendCallsStruct);\n\n const params = req.params[0];\n\n const from = params.from\n ? await validateAndNormalizeKeyholder(params.from, req, {\n getAccounts,\n })\n : undefined;\n\n const sendCalls: SendCallsPayload = {\n ...params,\n from,\n };\n\n res.result = await processSendCalls(sendCalls, req);\n}\n"]}
|
package/dist/types.cjs
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SendCallsStruct = exports.CapabilitiesStruct = exports.GetCapabilitiesStruct = exports.GetCallsStatusStruct = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
// /** Structs **/
|
|
7
|
+
// Even though these aren't actually typescript types, these structs essentially represent
|
|
8
|
+
// runtime types, so we keep them in this file.
|
|
9
|
+
exports.GetCallsStatusStruct = (0, superstruct_1.tuple)([utils_1.StrictHexStruct]);
|
|
10
|
+
exports.GetCapabilitiesStruct = (0, superstruct_1.tuple)([
|
|
11
|
+
utils_1.HexChecksumAddressStruct,
|
|
12
|
+
(0, superstruct_1.optional)((0, superstruct_1.array)(utils_1.StrictHexStruct)),
|
|
13
|
+
]);
|
|
14
|
+
exports.CapabilitiesStruct = (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.type)({
|
|
15
|
+
optional: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
|
|
16
|
+
}));
|
|
17
|
+
exports.SendCallsStruct = (0, superstruct_1.tuple)([
|
|
18
|
+
(0, superstruct_1.object)({
|
|
19
|
+
version: (0, superstruct_1.nonempty)((0, superstruct_1.string)()),
|
|
20
|
+
id: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
|
|
21
|
+
from: (0, superstruct_1.optional)(utils_1.HexChecksumAddressStruct),
|
|
22
|
+
chainId: utils_1.StrictHexStruct,
|
|
23
|
+
atomicRequired: (0, superstruct_1.boolean)(),
|
|
24
|
+
calls: (0, superstruct_1.array)((0, superstruct_1.object)({
|
|
25
|
+
to: (0, superstruct_1.optional)(utils_1.HexChecksumAddressStruct),
|
|
26
|
+
data: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
|
|
27
|
+
value: (0, superstruct_1.optional)(utils_1.StrictHexStruct),
|
|
28
|
+
capabilities: (0, superstruct_1.optional)(exports.CapabilitiesStruct),
|
|
29
|
+
})),
|
|
30
|
+
capabilities: (0, superstruct_1.optional)(exports.CapabilitiesStruct),
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
3
33
|
//# sourceMappingURL=types.cjs.map
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerGetStateAction,\n} from '@metamask/accounts-controller';\nimport type { Messenger } from '@metamask/base-controller';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { PreferencesControllerGetStateAction } from '@metamask/preferences-controller';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\n\ntype Actions =\n | AccountsControllerGetStateAction\n | AccountsControllerGetSelectedAccountAction\n | NetworkControllerGetNetworkClientByIdAction\n | TransactionControllerGetStateAction\n | PreferencesControllerGetStateAction\n | NetworkControllerGetStateAction;\n\nexport type EIP5792Messenger = Messenger<Actions, never>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAWA,uDAU+B;AAG/B,2CAA4E;AAiE5E,kBAAkB;AAClB,0FAA0F;AAC1F,+CAA+C;AAClC,QAAA,oBAAoB,GAAG,IAAA,mBAAK,EAAC,CAAC,uBAAe,CAAC,CAAC,CAAC;AAEhD,QAAA,qBAAqB,GAAG,IAAA,mBAAK,EAAC;IACzC,gCAAwB;IACxB,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,uBAAe,CAAC,CAAC;CACjC,CAAC,CAAC;AAEU,QAAA,kBAAkB,GAAG,IAAA,oBAAM,EACtC,IAAA,oBAAM,GAAE,EACR,IAAA,kBAAI,EAAC;IACH,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;CAC9B,CAAC,CACH,CAAC;AAEW,QAAA,eAAe,GAAG,IAAA,mBAAK,EAAC;IACnC,IAAA,oBAAM,EAAC;QACL,OAAO,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;QAC3B,EAAE,EAAE,IAAA,sBAAQ,EAAC,uBAAe,CAAC;QAC7B,IAAI,EAAE,IAAA,sBAAQ,EAAC,gCAAwB,CAAC;QACxC,OAAO,EAAE,uBAAe;QACxB,cAAc,EAAE,IAAA,qBAAO,GAAE;QACzB,KAAK,EAAE,IAAA,mBAAK,EACV,IAAA,oBAAM,EAAC;YACL,EAAE,EAAE,IAAA,sBAAQ,EAAC,gCAAwB,CAAC;YACtC,IAAI,EAAE,IAAA,sBAAQ,EAAC,uBAAe,CAAC;YAC/B,KAAK,EAAE,IAAA,sBAAQ,EAAC,uBAAe,CAAC;YAChC,YAAY,EAAE,IAAA,sBAAQ,EAAC,0BAAkB,CAAC;SAC3C,CAAC,CACH;QACD,YAAY,EAAE,IAAA,sBAAQ,EAAC,0BAAkB,CAAC;KAC3C,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerGetStateAction,\n} from '@metamask/accounts-controller';\nimport type { Messenger } from '@metamask/base-controller';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { PreferencesControllerGetStateAction } from '@metamask/preferences-controller';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n nonempty,\n object,\n optional,\n record,\n string,\n tuple,\n type,\n} from '@metamask/superstruct';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\nimport type { Hex, Json, JsonRpcRequest } from '@metamask/utils';\nimport { HexChecksumAddressStruct, StrictHexStruct } from '@metamask/utils';\n\ntype Actions =\n | AccountsControllerGetStateAction\n | AccountsControllerGetSelectedAccountAction\n | NetworkControllerGetNetworkClientByIdAction\n | TransactionControllerGetStateAction\n | PreferencesControllerGetStateAction\n | NetworkControllerGetStateAction;\n\nexport type EIP5792Messenger = Messenger<Actions, never>;\n\n// wallet_getCallStatus\nexport type GetCallsStatusParams = Infer<typeof GetCallsStatusStruct>;\n\nexport type GetCallsStatusResult = {\n version: string;\n id: Hex;\n chainId: Hex;\n status: number;\n atomic: boolean;\n receipts?: {\n logs: {\n address: Hex;\n data: Hex;\n topics: Hex[];\n }[];\n status: '0x0' | '0x1';\n blockHash: Hex;\n blockNumber: Hex;\n gasUsed: Hex;\n transactionHash: Hex;\n }[];\n capabilities?: Record<string, Json>;\n};\n\nexport type GetCallsStatusHook = (\n id: GetCallsStatusParams[0],\n req: JsonRpcRequest,\n) => Promise<GetCallsStatusResult>;\n\n// wallet_getCapabilities\nexport type GetCapabilitiesParams = Infer<typeof GetCapabilitiesStruct>;\nexport type GetCapabilitiesResult = Record<Hex, Record<string, Json>>;\n\nexport type GetCapabilitiesHook = (\n address: GetCapabilitiesParams[0],\n chainIds: GetCapabilitiesParams[1],\n req: JsonRpcRequest,\n) => Promise<GetCapabilitiesResult>;\n\n// wallet_sendCalls\nexport type SendCallsParams = Infer<typeof SendCallsStruct>;\nexport type SendCallsPayload = SendCallsParams[0];\n\nexport type SendCallsResult = {\n id: Hex;\n capabilities?: Record<string, Json>;\n};\n\nexport type ProcessSendCallsHook = (\n sendCalls: SendCallsPayload,\n req: JsonRpcRequest,\n) => Promise<SendCallsResult>;\n\n// /** Structs **/\n// Even though these aren't actually typescript types, these structs essentially represent\n// runtime types, so we keep them in this file.\nexport const GetCallsStatusStruct = tuple([StrictHexStruct]);\n\nexport const GetCapabilitiesStruct = tuple([\n HexChecksumAddressStruct,\n optional(array(StrictHexStruct)),\n]);\n\nexport const CapabilitiesStruct = record(\n string(),\n type({\n optional: optional(boolean()),\n }),\n);\n\nexport const SendCallsStruct = tuple([\n object({\n version: nonempty(string()),\n id: optional(StrictHexStruct),\n from: optional(HexChecksumAddressStruct),\n chainId: StrictHexStruct,\n atomicRequired: boolean(),\n calls: array(\n object({\n to: optional(HexChecksumAddressStruct),\n data: optional(StrictHexStruct),\n value: optional(StrictHexStruct),\n capabilities: optional(CapabilitiesStruct),\n }),\n ),\n capabilities: optional(CapabilitiesStruct),\n }),\n]);\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -2,8 +2,65 @@ import type { AccountsControllerGetSelectedAccountAction, AccountsControllerGetS
|
|
|
2
2
|
import type { Messenger } from "@metamask/base-controller";
|
|
3
3
|
import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction } from "@metamask/network-controller";
|
|
4
4
|
import type { PreferencesControllerGetStateAction } from "@metamask/preferences-controller";
|
|
5
|
+
import type { Infer } from "@metamask/superstruct";
|
|
5
6
|
import type { TransactionControllerGetStateAction } from "@metamask/transaction-controller";
|
|
7
|
+
import type { Hex, Json, JsonRpcRequest } from "@metamask/utils";
|
|
6
8
|
type Actions = AccountsControllerGetStateAction | AccountsControllerGetSelectedAccountAction | NetworkControllerGetNetworkClientByIdAction | TransactionControllerGetStateAction | PreferencesControllerGetStateAction | NetworkControllerGetStateAction;
|
|
7
9
|
export type EIP5792Messenger = Messenger<Actions, never>;
|
|
10
|
+
export type GetCallsStatusParams = Infer<typeof GetCallsStatusStruct>;
|
|
11
|
+
export type GetCallsStatusResult = {
|
|
12
|
+
version: string;
|
|
13
|
+
id: Hex;
|
|
14
|
+
chainId: Hex;
|
|
15
|
+
status: number;
|
|
16
|
+
atomic: boolean;
|
|
17
|
+
receipts?: {
|
|
18
|
+
logs: {
|
|
19
|
+
address: Hex;
|
|
20
|
+
data: Hex;
|
|
21
|
+
topics: Hex[];
|
|
22
|
+
}[];
|
|
23
|
+
status: '0x0' | '0x1';
|
|
24
|
+
blockHash: Hex;
|
|
25
|
+
blockNumber: Hex;
|
|
26
|
+
gasUsed: Hex;
|
|
27
|
+
transactionHash: Hex;
|
|
28
|
+
}[];
|
|
29
|
+
capabilities?: Record<string, Json>;
|
|
30
|
+
};
|
|
31
|
+
export type GetCallsStatusHook = (id: GetCallsStatusParams[0], req: JsonRpcRequest) => Promise<GetCallsStatusResult>;
|
|
32
|
+
export type GetCapabilitiesParams = Infer<typeof GetCapabilitiesStruct>;
|
|
33
|
+
export type GetCapabilitiesResult = Record<Hex, Record<string, Json>>;
|
|
34
|
+
export type GetCapabilitiesHook = (address: GetCapabilitiesParams[0], chainIds: GetCapabilitiesParams[1], req: JsonRpcRequest) => Promise<GetCapabilitiesResult>;
|
|
35
|
+
export type SendCallsParams = Infer<typeof SendCallsStruct>;
|
|
36
|
+
export type SendCallsPayload = SendCallsParams[0];
|
|
37
|
+
export type SendCallsResult = {
|
|
38
|
+
id: Hex;
|
|
39
|
+
capabilities?: Record<string, Json>;
|
|
40
|
+
};
|
|
41
|
+
export type ProcessSendCallsHook = (sendCalls: SendCallsPayload, req: JsonRpcRequest) => Promise<SendCallsResult>;
|
|
42
|
+
export declare const GetCallsStatusStruct: import("@metamask/superstruct").Struct<[`0x${string}`], null>;
|
|
43
|
+
export declare const GetCapabilitiesStruct: import("@metamask/superstruct").Struct<[`0x${string}`, `0x${string}`[] | undefined], null>;
|
|
44
|
+
export declare const CapabilitiesStruct: import("@metamask/superstruct").Struct<Record<string, {
|
|
45
|
+
optional?: boolean | undefined;
|
|
46
|
+
}>, null>;
|
|
47
|
+
export declare const SendCallsStruct: import("@metamask/superstruct").Struct<[{
|
|
48
|
+
version: string;
|
|
49
|
+
chainId: `0x${string}`;
|
|
50
|
+
atomicRequired: boolean;
|
|
51
|
+
calls: {
|
|
52
|
+
data?: `0x${string}` | undefined;
|
|
53
|
+
value?: `0x${string}` | undefined;
|
|
54
|
+
to?: `0x${string}` | undefined;
|
|
55
|
+
capabilities?: Record<string, {
|
|
56
|
+
optional?: boolean | undefined;
|
|
57
|
+
}> | undefined;
|
|
58
|
+
}[];
|
|
59
|
+
id?: `0x${string}` | undefined;
|
|
60
|
+
from?: `0x${string}` | undefined;
|
|
61
|
+
capabilities?: Record<string, {
|
|
62
|
+
optional?: boolean | undefined;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
}], null>;
|
|
8
65
|
export {};
|
|
9
66
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0CAA0C,EAC1C,gCAAgC,EACjC,sCAAsC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;AAC5F,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0CAA0C,EAC1C,gCAAgC,EACjC,sCAAsC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;AAC5F,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;AAC5F,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,wBAAwB;AAGjE,KAAK,OAAO,GACR,gCAAgC,GAChC,0CAA0C,GAC1C,2CAA2C,GAC3C,mCAAmC,GACnC,mCAAmC,GACnC,+BAA+B,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAGzD,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,GAAG,CAAC;IACR,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG,CAAC;YACb,IAAI,EAAE,GAAG,CAAC;YACV,MAAM,EAAE,GAAG,EAAE,CAAC;SACf,EAAE,CAAC;QACJ,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;QACtB,SAAS,EAAE,GAAG,CAAC;QACf,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,GAAG,CAAC;QACb,eAAe,EAAE,GAAG,CAAC;KACtB,EAAE,CAAC;IACJ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAC3B,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnC,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,EACjC,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAClC,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAGpC,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,GAAG,CAAC;IACR,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CACjC,SAAS,EAAE,gBAAgB,EAC3B,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,eAAe,CAAC,CAAC;AAK9B,eAAO,MAAM,oBAAoB,+DAA2B,CAAC;AAE7D,eAAO,MAAM,qBAAqB,4FAGhC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;SAK9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;SAiB1B,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -2,8 +2,65 @@ import type { AccountsControllerGetSelectedAccountAction, AccountsControllerGetS
|
|
|
2
2
|
import type { Messenger } from "@metamask/base-controller";
|
|
3
3
|
import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction } from "@metamask/network-controller";
|
|
4
4
|
import type { PreferencesControllerGetStateAction } from "@metamask/preferences-controller";
|
|
5
|
+
import type { Infer } from "@metamask/superstruct";
|
|
5
6
|
import type { TransactionControllerGetStateAction } from "@metamask/transaction-controller";
|
|
7
|
+
import type { Hex, Json, JsonRpcRequest } from "@metamask/utils";
|
|
6
8
|
type Actions = AccountsControllerGetStateAction | AccountsControllerGetSelectedAccountAction | NetworkControllerGetNetworkClientByIdAction | TransactionControllerGetStateAction | PreferencesControllerGetStateAction | NetworkControllerGetStateAction;
|
|
7
9
|
export type EIP5792Messenger = Messenger<Actions, never>;
|
|
10
|
+
export type GetCallsStatusParams = Infer<typeof GetCallsStatusStruct>;
|
|
11
|
+
export type GetCallsStatusResult = {
|
|
12
|
+
version: string;
|
|
13
|
+
id: Hex;
|
|
14
|
+
chainId: Hex;
|
|
15
|
+
status: number;
|
|
16
|
+
atomic: boolean;
|
|
17
|
+
receipts?: {
|
|
18
|
+
logs: {
|
|
19
|
+
address: Hex;
|
|
20
|
+
data: Hex;
|
|
21
|
+
topics: Hex[];
|
|
22
|
+
}[];
|
|
23
|
+
status: '0x0' | '0x1';
|
|
24
|
+
blockHash: Hex;
|
|
25
|
+
blockNumber: Hex;
|
|
26
|
+
gasUsed: Hex;
|
|
27
|
+
transactionHash: Hex;
|
|
28
|
+
}[];
|
|
29
|
+
capabilities?: Record<string, Json>;
|
|
30
|
+
};
|
|
31
|
+
export type GetCallsStatusHook = (id: GetCallsStatusParams[0], req: JsonRpcRequest) => Promise<GetCallsStatusResult>;
|
|
32
|
+
export type GetCapabilitiesParams = Infer<typeof GetCapabilitiesStruct>;
|
|
33
|
+
export type GetCapabilitiesResult = Record<Hex, Record<string, Json>>;
|
|
34
|
+
export type GetCapabilitiesHook = (address: GetCapabilitiesParams[0], chainIds: GetCapabilitiesParams[1], req: JsonRpcRequest) => Promise<GetCapabilitiesResult>;
|
|
35
|
+
export type SendCallsParams = Infer<typeof SendCallsStruct>;
|
|
36
|
+
export type SendCallsPayload = SendCallsParams[0];
|
|
37
|
+
export type SendCallsResult = {
|
|
38
|
+
id: Hex;
|
|
39
|
+
capabilities?: Record<string, Json>;
|
|
40
|
+
};
|
|
41
|
+
export type ProcessSendCallsHook = (sendCalls: SendCallsPayload, req: JsonRpcRequest) => Promise<SendCallsResult>;
|
|
42
|
+
export declare const GetCallsStatusStruct: import("@metamask/superstruct").Struct<[`0x${string}`], null>;
|
|
43
|
+
export declare const GetCapabilitiesStruct: import("@metamask/superstruct").Struct<[`0x${string}`, `0x${string}`[] | undefined], null>;
|
|
44
|
+
export declare const CapabilitiesStruct: import("@metamask/superstruct").Struct<Record<string, {
|
|
45
|
+
optional?: boolean | undefined;
|
|
46
|
+
}>, null>;
|
|
47
|
+
export declare const SendCallsStruct: import("@metamask/superstruct").Struct<[{
|
|
48
|
+
version: string;
|
|
49
|
+
chainId: `0x${string}`;
|
|
50
|
+
atomicRequired: boolean;
|
|
51
|
+
calls: {
|
|
52
|
+
data?: `0x${string}` | undefined;
|
|
53
|
+
value?: `0x${string}` | undefined;
|
|
54
|
+
to?: `0x${string}` | undefined;
|
|
55
|
+
capabilities?: Record<string, {
|
|
56
|
+
optional?: boolean | undefined;
|
|
57
|
+
}> | undefined;
|
|
58
|
+
}[];
|
|
59
|
+
id?: `0x${string}` | undefined;
|
|
60
|
+
from?: `0x${string}` | undefined;
|
|
61
|
+
capabilities?: Record<string, {
|
|
62
|
+
optional?: boolean | undefined;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
}], null>;
|
|
8
65
|
export {};
|
|
9
66
|
//# sourceMappingURL=types.d.mts.map
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0CAA0C,EAC1C,gCAAgC,EACjC,sCAAsC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;AAC5F,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0CAA0C,EAC1C,gCAAgC,EACjC,sCAAsC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;AAC5F,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD,OAAO,KAAK,EAAE,mCAAmC,EAAE,yCAAyC;AAC5F,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,wBAAwB;AAGjE,KAAK,OAAO,GACR,gCAAgC,GAChC,0CAA0C,GAC1C,2CAA2C,GAC3C,mCAAmC,GACnC,mCAAmC,GACnC,+BAA+B,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAGzD,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,GAAG,CAAC;IACR,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG,CAAC;YACb,IAAI,EAAE,GAAG,CAAC;YACV,MAAM,EAAE,GAAG,EAAE,CAAC;SACf,EAAE,CAAC;QACJ,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;QACtB,SAAS,EAAE,GAAG,CAAC;QACf,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,GAAG,CAAC;QACb,eAAe,EAAE,GAAG,CAAC;KACtB,EAAE,CAAC;IACJ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAC3B,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnC,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,EACjC,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAClC,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAGpC,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,GAAG,CAAC;IACR,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CACjC,SAAS,EAAE,gBAAgB,EAC3B,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,eAAe,CAAC,CAAC;AAK9B,eAAO,MAAM,oBAAoB,+DAA2B,CAAC;AAE7D,eAAO,MAAM,qBAAqB,4FAGhC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;SAK9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;SAiB1B,CAAC"}
|
package/dist/types.mjs
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { array, boolean, nonempty, object, optional, record, string, tuple, type } from "@metamask/superstruct";
|
|
2
|
+
import { HexChecksumAddressStruct, StrictHexStruct } from "@metamask/utils";
|
|
3
|
+
// /** Structs **/
|
|
4
|
+
// Even though these aren't actually typescript types, these structs essentially represent
|
|
5
|
+
// runtime types, so we keep them in this file.
|
|
6
|
+
export const GetCallsStatusStruct = tuple([StrictHexStruct]);
|
|
7
|
+
export const GetCapabilitiesStruct = tuple([
|
|
8
|
+
HexChecksumAddressStruct,
|
|
9
|
+
optional(array(StrictHexStruct)),
|
|
10
|
+
]);
|
|
11
|
+
export const CapabilitiesStruct = record(string(), type({
|
|
12
|
+
optional: optional(boolean()),
|
|
13
|
+
}));
|
|
14
|
+
export const SendCallsStruct = tuple([
|
|
15
|
+
object({
|
|
16
|
+
version: nonempty(string()),
|
|
17
|
+
id: optional(StrictHexStruct),
|
|
18
|
+
from: optional(HexChecksumAddressStruct),
|
|
19
|
+
chainId: StrictHexStruct,
|
|
20
|
+
atomicRequired: boolean(),
|
|
21
|
+
calls: array(object({
|
|
22
|
+
to: optional(HexChecksumAddressStruct),
|
|
23
|
+
data: optional(StrictHexStruct),
|
|
24
|
+
value: optional(StrictHexStruct),
|
|
25
|
+
capabilities: optional(CapabilitiesStruct),
|
|
26
|
+
})),
|
|
27
|
+
capabilities: optional(CapabilitiesStruct),
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
2
30
|
//# sourceMappingURL=types.mjs.map
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerGetStateAction,\n} from '@metamask/accounts-controller';\nimport type { Messenger } from '@metamask/base-controller';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { PreferencesControllerGetStateAction } from '@metamask/preferences-controller';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\n\ntype Actions =\n | AccountsControllerGetStateAction\n | AccountsControllerGetSelectedAccountAction\n | NetworkControllerGetNetworkClientByIdAction\n | TransactionControllerGetStateAction\n | PreferencesControllerGetStateAction\n | NetworkControllerGetStateAction;\n\nexport type EIP5792Messenger = Messenger<Actions, never>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACL,8BAA8B;AAG/B,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,wBAAwB;AAiE5E,kBAAkB;AAClB,0FAA0F;AAC1F,+CAA+C;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;IACzC,wBAAwB;IACxB,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CACtC,MAAM,EAAE,EACR,IAAI,CAAC;IACH,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;CAC9B,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;IACnC,MAAM,CAAC;QACL,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC3B,EAAE,EAAE,QAAQ,CAAC,eAAe,CAAC;QAC7B,IAAI,EAAE,QAAQ,CAAC,wBAAwB,CAAC;QACxC,OAAO,EAAE,eAAe;QACxB,cAAc,EAAE,OAAO,EAAE;QACzB,KAAK,EAAE,KAAK,CACV,MAAM,CAAC;YACL,EAAE,EAAE,QAAQ,CAAC,wBAAwB,CAAC;YACtC,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC;YAC/B,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC;YAChC,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC;SAC3C,CAAC,CACH;QACD,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC;KAC3C,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type {\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerGetStateAction,\n} from '@metamask/accounts-controller';\nimport type { Messenger } from '@metamask/base-controller';\nimport type {\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { PreferencesControllerGetStateAction } from '@metamask/preferences-controller';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n nonempty,\n object,\n optional,\n record,\n string,\n tuple,\n type,\n} from '@metamask/superstruct';\nimport type { TransactionControllerGetStateAction } from '@metamask/transaction-controller';\nimport type { Hex, Json, JsonRpcRequest } from '@metamask/utils';\nimport { HexChecksumAddressStruct, StrictHexStruct } from '@metamask/utils';\n\ntype Actions =\n | AccountsControllerGetStateAction\n | AccountsControllerGetSelectedAccountAction\n | NetworkControllerGetNetworkClientByIdAction\n | TransactionControllerGetStateAction\n | PreferencesControllerGetStateAction\n | NetworkControllerGetStateAction;\n\nexport type EIP5792Messenger = Messenger<Actions, never>;\n\n// wallet_getCallStatus\nexport type GetCallsStatusParams = Infer<typeof GetCallsStatusStruct>;\n\nexport type GetCallsStatusResult = {\n version: string;\n id: Hex;\n chainId: Hex;\n status: number;\n atomic: boolean;\n receipts?: {\n logs: {\n address: Hex;\n data: Hex;\n topics: Hex[];\n }[];\n status: '0x0' | '0x1';\n blockHash: Hex;\n blockNumber: Hex;\n gasUsed: Hex;\n transactionHash: Hex;\n }[];\n capabilities?: Record<string, Json>;\n};\n\nexport type GetCallsStatusHook = (\n id: GetCallsStatusParams[0],\n req: JsonRpcRequest,\n) => Promise<GetCallsStatusResult>;\n\n// wallet_getCapabilities\nexport type GetCapabilitiesParams = Infer<typeof GetCapabilitiesStruct>;\nexport type GetCapabilitiesResult = Record<Hex, Record<string, Json>>;\n\nexport type GetCapabilitiesHook = (\n address: GetCapabilitiesParams[0],\n chainIds: GetCapabilitiesParams[1],\n req: JsonRpcRequest,\n) => Promise<GetCapabilitiesResult>;\n\n// wallet_sendCalls\nexport type SendCallsParams = Infer<typeof SendCallsStruct>;\nexport type SendCallsPayload = SendCallsParams[0];\n\nexport type SendCallsResult = {\n id: Hex;\n capabilities?: Record<string, Json>;\n};\n\nexport type ProcessSendCallsHook = (\n sendCalls: SendCallsPayload,\n req: JsonRpcRequest,\n) => Promise<SendCallsResult>;\n\n// /** Structs **/\n// Even though these aren't actually typescript types, these structs essentially represent\n// runtime types, so we keep them in this file.\nexport const GetCallsStatusStruct = tuple([StrictHexStruct]);\n\nexport const GetCapabilitiesStruct = tuple([\n HexChecksumAddressStruct,\n optional(array(StrictHexStruct)),\n]);\n\nexport const CapabilitiesStruct = record(\n string(),\n type({\n optional: optional(boolean()),\n }),\n);\n\nexport const SendCallsStruct = tuple([\n object({\n version: nonempty(string()),\n id: optional(StrictHexStruct),\n from: optional(HexChecksumAddressStruct),\n chainId: StrictHexStruct,\n atomicRequired: boolean(),\n calls: array(\n object({\n to: optional(HexChecksumAddressStruct),\n data: optional(StrictHexStruct),\n value: optional(StrictHexStruct),\n capabilities: optional(CapabilitiesStruct),\n }),\n ),\n capabilities: optional(CapabilitiesStruct),\n }),\n]);\n"]}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccountKeyringType = void 0;
|
|
3
|
+
exports.resemblesAddress = exports.validateParams = exports.validateAndNormalizeKeyholder = exports.getAccountKeyringType = void 0;
|
|
4
4
|
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
6
|
const constants_1 = require("./constants.cjs");
|
|
6
7
|
/**
|
|
7
8
|
* Retrieves the keyring type for a given account address.
|
|
@@ -21,4 +22,72 @@ function getAccountKeyringType(accountAddress, messenger) {
|
|
|
21
22
|
return keyringType;
|
|
22
23
|
}
|
|
23
24
|
exports.getAccountKeyringType = getAccountKeyringType;
|
|
25
|
+
/**
|
|
26
|
+
* Validates and normalizes a keyholder address for EIP-5792 operations.
|
|
27
|
+
*
|
|
28
|
+
* @param address - The Ethereum address to validate and normalize.
|
|
29
|
+
* @param req - The JSON-RPC request object for permission checking.
|
|
30
|
+
* @param options - Configuration object containing the getAccounts function.
|
|
31
|
+
* @param options.getAccounts - Function to retrieve accounts for the requester.
|
|
32
|
+
* @returns A normalized (lowercase) hex address if valid and authorized.
|
|
33
|
+
* @throws JsonRpcError with unauthorized error if the requester doesn't have permission to access the address.
|
|
34
|
+
* @throws JsonRpcError with invalid params if the address format is invalid.
|
|
35
|
+
*/
|
|
36
|
+
async function validateAndNormalizeKeyholder(address, req, { getAccounts }) {
|
|
37
|
+
if (typeof address === 'string' &&
|
|
38
|
+
address.length > 0 &&
|
|
39
|
+
resemblesAddress(address)) {
|
|
40
|
+
// Ensure that an "unauthorized" error is thrown if the requester
|
|
41
|
+
// does not have the `eth_accounts` permission.
|
|
42
|
+
const accounts = await getAccounts(req);
|
|
43
|
+
const normalizedAccounts = accounts.map((_address) => _address.toLowerCase());
|
|
44
|
+
const normalizedAddress = address.toLowerCase();
|
|
45
|
+
if (normalizedAccounts.includes(normalizedAddress)) {
|
|
46
|
+
return normalizedAddress;
|
|
47
|
+
}
|
|
48
|
+
throw rpc_errors_1.providerErrors.unauthorized();
|
|
49
|
+
}
|
|
50
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
51
|
+
message: `Invalid parameters: must provide an Ethereum address.`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.validateAndNormalizeKeyholder = validateAndNormalizeKeyholder;
|
|
55
|
+
/**
|
|
56
|
+
* Validates parameters against a Superstruct schema and throws an error if validation fails.
|
|
57
|
+
*
|
|
58
|
+
* @param value - The value to validate against the struct schema.
|
|
59
|
+
* @param struct - The Superstruct schema to validate against.
|
|
60
|
+
* @throws JsonRpcError with invalid params if the value doesn't match the struct schema.
|
|
61
|
+
*/
|
|
62
|
+
function validateParams(value, struct) {
|
|
63
|
+
const [error] = (0, superstruct_1.validate)(value, struct);
|
|
64
|
+
if (error) {
|
|
65
|
+
throw rpc_errors_1.rpcErrors.invalidParams(formatValidationError(error, `Invalid params`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.validateParams = validateParams;
|
|
69
|
+
/**
|
|
70
|
+
* Checks if a string resembles an Ethereum address format.
|
|
71
|
+
*
|
|
72
|
+
* @param str - The string to check for address-like format.
|
|
73
|
+
* @returns True if the string has the correct length for an Ethereum address.
|
|
74
|
+
*/
|
|
75
|
+
function resemblesAddress(str) {
|
|
76
|
+
// hex prefix 2 + 20 bytes
|
|
77
|
+
return str.length === 2 + 20 * 2;
|
|
78
|
+
}
|
|
79
|
+
exports.resemblesAddress = resemblesAddress;
|
|
80
|
+
/**
|
|
81
|
+
* Formats a Superstruct validation error into a human-readable string.
|
|
82
|
+
*
|
|
83
|
+
* @param error - The Superstruct validation error to format.
|
|
84
|
+
* @param message - The base error message to prepend to the formatted details.
|
|
85
|
+
* @returns A formatted error message string with validation failure details.
|
|
86
|
+
*/
|
|
87
|
+
function formatValidationError(error, message) {
|
|
88
|
+
return `${message}\n\n${error
|
|
89
|
+
.failures()
|
|
90
|
+
.map((f) => `${f.path.join(' > ')}${f.path.length ? ' - ' : ''}${f.message}`)
|
|
91
|
+
.join('\n')}`;
|
|
92
|
+
}
|
|
24
93
|
//# sourceMappingURL=utils.cjs.map
|