UNPKG

@desig/web3

Version:

Desig: The Blockchain-Agnostic Multisig Solution

26 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addEvmSignature = exports.toEvmAddress = exports.isEvmAddress = void 0; const ethers_1 = require("ethers"); const isEvmAddress = (address) => { if (!address) return false; return (0, ethers_1.isAddress)(address); }; exports.isEvmAddress = isEvmAddress; var supported_chains_1 = require("@desig/supported-chains"); Object.defineProperty(exports, "toEvmAddress", { enumerable: true, get: function () { return supported_chains_1.toEvmAddress; } }); const addEvmSignature = (transaction, { sig, recv }, chainId) => { const tx = ethers_1.Transaction.from((0, ethers_1.hexlify)(transaction)); const r = sig.slice(0, 32); const s = sig.slice(32, 64); const v = BigInt(recv + 35) + BigInt(chainId) * BigInt(2); const signedTx = ethers_1.Transaction.from(Object.assign(Object.assign({}, tx.toJSON()), { signature: { r: (0, ethers_1.toBigInt)(r), s: (0, ethers_1.toBigInt)(s), v, } })); return signedTx.serialized; }; exports.addEvmSignature = addEvmSignature; //# sourceMappingURL=evm.js.map