@etherspot/remote-signer
Version:
Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler
65 lines (63 loc) • 1.56 kB
JavaScript
import {
isHex
} from "./chunk-WIHABNGC.mjs";
import {
parseSignature,
serializeSignature
} from "./chunk-EGVR4AKQ.mjs";
import {
InvalidAddressError,
isAddress
} from "./chunk-VPBLFL5G.mjs";
// src/sdk/remote-signer/local-account-utils.ts
function createLocalAccount(address) {
return {
address,
publicKey: "0x",
source: "",
type: "local",
signMessage: void 0,
signTransaction: void 0,
signTypedData: void 0
};
}
function toExtendedLocalAccount(source) {
if (typeof source === "string") {
if (!isAddress(source, { strict: false }))
throw new InvalidAddressError({ address: source });
return {
address: source,
type: "json-rpc"
};
}
if (!isAddress(source.address, { strict: false }))
throw new InvalidAddressError({ address: source.address });
return {
address: source.address,
nonceManager: source.nonceManager,
signMessage: source.signMessage,
signTransaction: source.signTransaction,
signTypedData: source.signTypedData,
source: "custom",
type: "local"
};
}
var fixSignedData = (sig) => {
let signature = sig;
if (!isHex(signature)) {
signature = `0x${signature}`;
if (!isHex(signature)) {
throw new Error(`Invalid signed data ${sig}`);
}
}
let { r, s, v } = parseSignature(signature);
if (v === 0n || v === 1n) v += 27n;
const joined = serializeSignature({ r, s, v });
return joined;
};
export {
createLocalAccount,
toExtendedLocalAccount,
fixSignedData
};
//# sourceMappingURL=chunk-O4FDP7LU.mjs.map