UNPKG

@etherspot/remote-signer

Version:

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

60 lines (58 loc) 1.91 kB
import { signUserOpWithSessionKey } from "./chunk-RUG2C3EH.mjs"; import { getSessionKey } from "./chunk-YBGMLW7N.mjs"; import { PERMISSIONS_URL } from "./chunk-FIVOBZYI.mjs"; // src/sdk/remote-signer/remote-signer.ts async function signUserOp(account, chainId, apiKey, sessionKey, userOp, permissionsBackendUrl = PERMISSIONS_URL) { return signUserOpWithSessionKey(account.address, chainId, apiKey, sessionKey, userOp, permissionsBackendUrl); } async function toRemoteSigner({ account, chainId, apiKey, sessionKey }) { const sessionKeyResponse = await getSessionKey(account.address, chainId, apiKey, sessionKey); const extendedLocalAccount = { ...account, // Spread the properties of the original LocalAccount async signUserOpWithRemoteSigner(userOp) { const signedUserOp = await signUserOp(account, chainId, apiKey, sessionKeyResponse.sessionKey, userOp); return signedUserOp; }, async signMessage({ message }) { throw new Error("signMessage with sessionKey not implemented"); }, async signTransaction(_, __) { throw new Error("signTransaction with sessionKey not implemented"); }, async signTypedData(typedData) { throw new Error("signTypedData not implemented"); } }; return extendedLocalAccount; } var signUserOperation = async (etherspotWalletAccount, chainId, apiKey, sessionKey, userOp) => { const remoteSigner = await toRemoteSigner({ account: etherspotWalletAccount, chainId, apiKey, sessionKey, permissionsBackendUrl: PERMISSIONS_URL }); const signedUserOp = await remoteSigner.signUserOpWithRemoteSigner(userOp); if (!signedUserOp || !signedUserOp.signature || signedUserOp.signature === "0x") { throw new Error("Failed to sign user operation"); } return signedUserOp; }; export { toRemoteSigner, signUserOperation }; //# sourceMappingURL=chunk-W27LWPKL.mjs.map