UNPKG

@etherspot/remote-signer

Version:

Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler

55 lines (53 loc) 1.58 kB
import { validateUserOp } from "./chunk-UR6MW6F4.mjs"; import { deepHexlify } from "./chunk-XNGSGKPY.mjs"; import { resolveProperties } from "./chunk-M6FK2HC2.mjs"; import { PERMISSIONS_URL } from "./chunk-FIVOBZYI.mjs"; // src/sdk/session-keys/sign-userop.ts var signUserOpWithSessionKey = async (accountAddress, chainId, apiKey, sessionKey, userOp, permissionsBackendUrl = PERMISSIONS_URL) => { let response = null; try { if (!sessionKey) { throw new Error("Session key is required"); } if (!apiKey) { throw new Error("API key is required"); } if (!accountAddress) { throw new Error("Account address is required"); } if (chainId === void 0 || chainId === null || chainId <= 0) { throw new Error("Chain ID is required"); } validateUserOp(userOp); let url = `${permissionsBackendUrl}/account/signUserOp?account=${accountAddress}&chainId=${chainId}&sessionKey=${sessionKey}&apiKey=${apiKey}`; response = await fetch(url, { method: "POST", headers: { "Accept": "application/json", "Content-Type": "application/json" }, body: JSON.stringify(deepHexlify(await resolveProperties(userOp))) }); if (response.status === 200) { const responseJson = await response.json(); return responseJson; } else { const responseJson = await response.json(); throw new Error(responseJson.message); } } catch (err) { throw new Error(err.message); } }; export { signUserOpWithSessionKey }; //# sourceMappingURL=chunk-RUG2C3EH.mjs.map