UNPKG

@cometh/connect-sdk-4337

Version:
2,273 lines (2,234 loc) 351 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); // src/index.ts var _erc7579 = require('permissionless/actions/erc7579'); // src/customChains.ts var _viem = require('viem'); var muster = _viem.defineChain.call(void 0, { id: 4078, name: "Muster", network: "muster", nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" }, rpcUrls: { default: { http: ["https://muster.alt.technology/"] }, public: { http: ["https://muster.alt.technology/"] } }, contracts: { multicall3: { address: "0xcA11bde05977b3631167028862bE2a173976CA11" } } }); var swisstronikTestnet = _viem.defineChain.call(void 0, { id: 1291, name: "Swisstronik testnet", network: "swisstronik testnet", nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" }, rpcUrls: { default: { http: ["https://json-rpc.testnet.swisstronik.com/unencrypted/"] }, public: { http: ["https://json-rpc.testnet.swisstronik.com/unencrypted/"] } }, contracts: { multicall3: { address: "0xcA11bde05977b3631167028862bE2a173976CA11" } } }); // src/constants.ts var API_URL = "https://api.4337.cometh.io"; var ENTRYPOINT_ADDRESS_V07 = "0x0000000071727De22E5E9d8BAf0edAc6f37da032"; var SENTINEL_MODULES = "0x0000000000000000000000000000000000000001"; var SAFE_7579_ADDRESS = "0x7579EE8307284F293B1927136486880611F20002"; var LAUNCHPAD_ADDRESS = "0x7579011aB74c46090561ea277Ba79D510c6C00ff"; var hardcodeVerificationGasLimit7579 = 1000000n; var FALLBACK_TARGET_FLAG = "0x0000000000000000000000000000000000000001"; var FALLBACK_TARGET_SELECTOR_FLAG_PERMITTED_TO_CALL_SMARTSESSION = "0x00000001"; var customChains = [muster, swisstronikTestnet]; var defaultClientConfig = { cacheTime: 6e4, batch: { multicall: { wait: 50 } } }; // src/core/services/API.ts var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios); var API = class { constructor(apiKey, baseUrl) { __publicField(this, "api"); __publicField(this, "_apiKey"); this._apiKey = apiKey; this.api = _axios2.default.create({ baseURL: baseUrl || API_URL }); this.api.defaults.headers.common.apiKey = apiKey; } get apiUrl() { return this.api.defaults.baseURL || ""; } get apiKey() { return this._apiKey; } async getProjectParams(chainId) { const response = await this.api.get( `/project/params?chainId=${chainId}` ); return response.data.projectParams; } async getWalletByNetworks(walletAddress) { const response = await this.api.get(`/wallet/${walletAddress}`); return response.data.wallets; } async createWallet({ chainId, smartAccountAddress, initiatorAddress }) { const body = { chainId: chainId.toString(), walletAddress: smartAccountAddress, initiatorAddress }; await this.api.post("/wallet", body); } async initWallet({ chainId, smartAccountAddress, initiatorAddress, publicKeyId, publicKeyX, publicKeyY, deviceData }) { const body = { chainId: chainId.toString(), walletAddress: smartAccountAddress, initiatorAddress, publicKeyId, publicKeyX, publicKeyY, deviceData }; const res = await this.api.post("/wallet/init", body); return res.data.isNewWallet; } async importExternalSafe({ smartAccountAddress, publicKeyId, publicKeyX, publicKeyY, deviceData, signerAddress, chainId, transactionCalldata }) { const body = { walletAddress: smartAccountAddress, signerAddress, publicKeyId, publicKeyX, publicKeyY, deviceData, chainId, transactionCalldata }; const res = await this.api.post("/wallet/import", body); return res.data.relayId; } /** * WebAuthn Section */ async createWebAuthnSigner({ chainId, walletAddress, publicKeyId, publicKeyX, publicKeyY, deviceData, signerAddress, isSharedWebAuthnSigner }) { const body = { chainId: chainId.toString(), walletAddress, publicKeyId, publicKeyX, publicKeyY, deviceData, signerAddress, isSharedWebAuthnSigner }; await this.api.post("/webauthn-signer/create", body); } async getPasskeySignerByPublicKeyId(publicKeyId) { const response = await this.api.get( `/webauthn-signer/public-key-id/${publicKeyId}` ); return response.data.webAuthnSigners; } async getPasskeySignersByWalletAddress(walletAddress) { const response = await this.api.get( `/webauthn-signer/${walletAddress}` ); return response.data.webAuthnSigners; } async predictWebAuthnSignerAddress({ publicKeyX, publicKeyY }) { const body = { publicKeyX, publicKeyY }; const response = await this.api.post( "/webauthn-signer/predict-address", body ); return response.data.signerAddress; } async getWebAuthnSignersByWalletAddressAndChain(walletAddress, chainId) { const response = await this.api.get( `/webauthn-signer/${walletAddress}/${chainId}` ); return _optionalChain([response, 'optionalAccess', _2 => _2.data, 'optionalAccess', _3 => _3.webAuthnSigners]); } async isValidSignature(walletAddress, message, signature, chainId) { const body = { chainId: chainId.toString(), message, signature }; const response = await this.api.post( `/wallet/is-valid-signature/${walletAddress}`, body ); return _optionalChain([response, 'optionalAccess', _4 => _4.data, 'optionalAccess', _5 => _5.result]); } async getRelayedTransaction(relayId, chainId) { const body = { chainId: chainId.toString(), relayId }; const response = await this.api.post("/relayed-transactions", body); return response.data.relayedTransaction; } }; // src/core/signers/ecdsa/fallbackEoa/fallbackEoaSigner.ts var _accounts = require('viem/accounts'); // src/errors.ts var WalletDoesNotExistsError = class extends Error { constructor() { super("Provided wallet does not exists. Please verify wallet address"); } }; var WalletNotConnectedError = class extends Error { constructor() { super("Account is not connected"); } }; var WalletNotDeployedError = class extends Error { constructor() { super("Wallet is not deployed yet"); } }; var WalletAlreadyImportedError = class extends Error { constructor() { super("Wallet is already imported"); } }; var NoSignerFoundError = class extends Error { constructor() { super("No signer instance found"); } }; var EoaFallbackDisableError = class extends Error { constructor() { super("ECC Passkeys are not compatible with your current device"); } }; var NoFallbackSignerError = class extends Error { constructor() { super("No fallback signer found"); } }; var FallbackAlreadySetError = class extends Error { constructor() { super("Fallback already set"); } }; var SignerNotOwnerError = class extends Error { constructor() { super("Signer found is not owner of the wallet"); } }; var UnauthorizedMethodError = class extends Error { constructor(methodName) { super(`Not authorized method: ${methodName}`); } }; var RelayedTransactionError = class extends Error { constructor() { super("Error during the relay of the transaction"); } }; var SafeNotDeployedError = class extends Error { constructor() { super("Safe not deployed"); } }; var ImportOnUndeployedSafeError = class extends Error { constructor() { super("Import can only be done on deployed safe"); } }; var RemoveOwnerOnUndeployedSafeError = class extends Error { constructor() { super("Can't remove owner on an undeployed safe"); } }; var SmartAccountAddressNotFoundError = class extends Error { constructor() { super("No smart account address found"); } }; var MethodNotSupportedError = class extends _viem.BaseError { constructor() { super("Method not supported", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/" }); } }; var BatchCallModeNotSupportedError = class extends Error { constructor(mode) { super( `Mode ${JSON.stringify( mode )} is not supported for batchcall calldata` ); } }; var NoCallsToEncodeError = class extends Error { constructor() { super("No calls to encode"); } }; var InvalidCallDataError = class extends Error { constructor() { super("Invalid callData for Safe Account"); } }; var SafeVersionNotSupportedError = class extends _viem.BaseError { constructor(supportedVersion, currentVersion) { super( `Safe is not version ${supportedVersion}. Current version: ${currentVersion}`, { metaMessages: [ `Current Version: ${currentVersion}`, `Supported Version: ${supportedVersion}` ] } ); } }; var OwnerToRemoveIsNotSafeOwnerError = class extends Error { constructor(ownerToRemove) { super(`${ownerToRemove} is not a safe owner`); } }; var MigrationContractAddressNotAvailableError = class extends Error { constructor() { super("Migration contract address not available for this network"); } }; var InvalidSmartAccountClientError = class extends Error { constructor() { super("Invalid Smart Account Client"); } }; var InvalidAccountAddressError = class extends Error { constructor() { super("Invalid account address"); } }; var NoRecoveryRequestFoundError = class extends _viem.BaseError { constructor() { super("No recovery request found", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var AddressIsNotAGuardianError = class extends _viem.BaseError { constructor() { super("Address is not a guardian", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var DelayModuleNotEnabledError = class extends _viem.BaseError { constructor() { super("Delay module not enabled", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var DelayModuleAlreadySetUpError = class extends _viem.BaseError { constructor() { super("Delay module already set up", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var GuardianAlreadyEnabledError = class extends _viem.BaseError { constructor() { super("Guardian already enabled", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var PreviousModuleNotFoundError = class extends _viem.BaseError { constructor() { super("Previous module not found", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var RecoveryNotActiveError = class extends _viem.BaseError { constructor() { super("Recovery not active", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var RecoveryNotSetUpError = class extends _viem.BaseError { constructor() { super("Recovery has not been setup", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var RecoveryAlreadySetUpError = class extends _viem.BaseError { constructor() { super("Recovery already setup", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/social-recovery" }); } }; var InvalidSignatureError = class extends Error { constructor() { super("Invalid signature"); } }; var InvalidSignerDataError = class extends Error { constructor() { super("Invalid signer data"); } }; var InvalidSignatureEncodingError = class extends Error { constructor() { super("Invalid signature encoding"); } }; var EoaSignerRequiredError = class extends Error { constructor() { super("eoaSigner is required"); } }; var CannotSignForAddressError = class extends Error { constructor() { super("Cannot sign for address that is not the current account"); } }; var InvalidSignerTypeError = class extends Error { constructor() { super("Invalid signer type: must be one of the allowed types"); } }; var FailedToSerializeUrlError = class extends Error { constructor(error) { super(`Failed to serialize url: ${error}`); } }; var FailedToGenerateQRCodeError = class extends Error { constructor(error) { super(`Failed to generate QR Code: ${error}`); } }; var DeviceNotCompatibleWithPasskeysError = class extends Error { constructor() { super("Device not compatible with passkeys"); } }; var DeviceNotCompatibleWithSECKP256r1PasskeysError = class extends Error { constructor() { super("Device not compatible with SECKP256r1 passkeys"); } }; var PasskeyCreationError = class extends Error { constructor() { super("Error in the passkey creation"); } }; var FailedToGeneratePasskeyError = class extends Error { constructor() { super("Failed to generate passkey. Received null as a credential"); } }; var NoPasskeySignerFoundInDBError = class extends Error { constructor() { super("No passkey signer found in db for this walletAddress"); } }; var NoPasskeySignerFoundForGivenChain = class extends Error { constructor() { super("No passkey signer found in db for this walletAddress and chain"); } }; var NoPasskeySignerFoundInDeviceError = class extends Error { constructor() { super( "No signer was found on your device. You might need to add that domain as signer" ); } }; var RetrieveWalletFromPasskeyError = class extends Error { constructor() { super("Unable to retrieve wallet address from passkeys"); } }; var PasskeySignatureFailedError = class extends Error { constructor() { super("Passkey signature failed"); } }; var PasskeySignerNotValidError = class extends Error { constructor() { super("Passkey signer not valid"); } }; var PermissionNotInstalledError = class extends _viem.BaseError { constructor() { super("Permission not installed for this wallet", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/resources/advanced-features/session-keys" }); } }; var ExpiryRequiredError = class extends Error { constructor() { super("Invalid expiry: expiry is required"); } }; var ExpiryInPastError = class extends Error { constructor() { super("Invalid expiry: expiry must be in the future"); } }; var UnsupportedPolicyError = class extends Error { constructor(policy) { super(`Unsupported policy: ${policy}`); } }; var UnsupportedPermissionTypeError = class extends Error { constructor(permissionType) { super(`Unsupported permission type: ${permissionType}`); } }; var InvalidParamsError = class extends Error { constructor(message) { super(`Invalid params: ${message}`); } }; var MissingToAddressError = class extends _viem.BaseError { constructor() { super("Missing to address", { docsBaseUrl: "https://docs.cometh.io/connect-4337", docsPath: "/sdk-features/send-transactions" }); } }; var APINotFoundError = class extends Error { constructor() { super("No API found"); } }; var FetchingProjectParamsError = class extends Error { constructor() { super("Error fetching project params"); } }; var ChainIdNotFoundError = class extends Error { constructor() { super("ChainId not found"); } }; var NoPrivateKeyFoundError = class extends Error { constructor() { super("No private key found"); } }; var ChallengeNotFoundError = class extends Error { constructor() { super("Challenge not found in client data JSON"); } }; // src/core/services/utils.ts var decodeUTF8 = (b) => { return new TextDecoder().decode(b); }; var encodeUTF8 = (s) => { return new TextEncoder().encode(s); }; var arrayBufferToBase64 = (buffer) => { let binary = ""; const bytes = new Uint8Array(buffer); const len = bytes.byteLength; for (let i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } return window.btoa(binary); }; var uint8ArrayToBase64 = (bytes) => { let binary = ""; const len = bytes.byteLength; for (let i = 0; i < len; i++) { binary += String.fromCharCode(bytes[i]); } return window.btoa(binary); }; var base64toUint8Array = (base64) => { const binary_string = window.atob(base64); const len = binary_string.length; const bytes = new Uint8Array(len); for (let i = 0; i < len; i++) { bytes[i] = binary_string.charCodeAt(i); } return bytes; }; var base64ToArrayBuffer = (base64) => { const binary_string = window.atob(base64); const len = binary_string.length; const bytes = new Uint8Array(len); for (let i = 0; i < len; i++) { bytes[i] = binary_string.charCodeAt(i); } return bytes.buffer; }; // src/core/signers/ecdsa/services/ecdsaService.ts // src/core/signers/ecdsa/services/cryptoService.ts var pbkdf2 = async (password, salt, iterations) => { const key = await window.crypto.subtle.importKey( "raw", password, { name: "PBKDF2" }, false, ["deriveBits"] ); return await window.crypto.subtle.deriveBits( { name: "PBKDF2", salt, iterations, hash: { name: "sha-256" } }, key, 256 ); }; var encryptAESCBC = async (privateKey, iv, data) => { const key = await window.crypto.subtle.importKey( "raw", new Uint8Array(privateKey), { name: "AES-CBC" }, false, ["encrypt"] ); return await window.crypto.subtle.encrypt( { name: "AES-CBC", iv }, key, data ); }; var decryptAESCBC = async (privateKey, iv, data) => { const key = await window.crypto.subtle.importKey( "raw", privateKey, { name: "AES-CBC" }, false, ["decrypt"] ); return await window.crypto.subtle.decrypt( { name: "AES-CBC", iv }, key, data ); }; var getRandomValues = (arr) => { return window.crypto.getRandomValues(arr); }; // src/core/signers/ecdsa/services/randomIvService.ts var getRandomIV = () => { const array = new Uint8Array(16); getRandomValues(array); return array; }; // src/core/signers/ecdsa/services/ecdsaService.ts var defaultEncryptionSalt = "COMETH-CONNECT"; var Pbkdf2Iterations = 1e6; var encryptSigner = async (smartAccountAddress, privateKey, salt) => { const { encryptedPrivateKey, iv } = await encryptEoaFallback( smartAccountAddress, privateKey, salt || defaultEncryptionSalt ); const signer = _accounts.privateKeyToAccount.call(void 0, privateKey); const storageValue = formatStorageValue( encryptedPrivateKey, iv, signer.address ); return storageValue; }; var encryptSignerInStorage = async (smartAccountAddress, privateKey, salt) => { const storageValue = await encryptSigner( smartAccountAddress, privateKey, salt ); window.localStorage.setItem( `cometh-connect-fallback-${smartAccountAddress}`, storageValue ); }; var getSignerLocalStorage = async (smartAccountAddress, salt) => { const localStorage2 = window.localStorage.getItem( `cometh-connect-fallback-${smartAccountAddress}` ); if (localStorage2) { const { encryptedPrivateKey, iv } = unFormatStorageValue(localStorage2); const privateKey = await decryptEoaFallback( smartAccountAddress, base64ToArrayBuffer(encryptedPrivateKey), base64toUint8Array(iv), salt || defaultEncryptionSalt ); return privateKey; } return null; }; var encryptEoaFallback = async (smartAccountAddress, privateKey, salt) => { const encodedSmartAccountAddress = encodeUTF8(smartAccountAddress); const encodedSalt = encodeUTF8(salt); const encryptionKey = await pbkdf2( encodedSmartAccountAddress, encodedSalt, Pbkdf2Iterations ); const encodedPrivateKey = encodeUTF8(privateKey); const iv = getRandomIV(); const encryptedPrivateKey = await encryptAESCBC( encryptionKey, iv, encodedPrivateKey ); return { encryptedPrivateKey: arrayBufferToBase64(encryptedPrivateKey), iv: uint8ArrayToBase64(iv) }; }; var decryptEoaFallback = async (smartAccountAddress, encryptedPrivateKey, iv, salt) => { const encodedsmartAccountAddress = encodeUTF8(smartAccountAddress); const encodedSalt = encodeUTF8(salt); const encryptionKey = await pbkdf2( encodedsmartAccountAddress, encodedSalt, Pbkdf2Iterations ); const privateKey = await decryptAESCBC( encryptionKey, iv, encryptedPrivateKey ); return decodeUTF8(privateKey); }; var formatStorageValue = (encryptedPrivateKey, iv, signerAddress) => { return JSON.stringify({ encryptedPrivateKey, iv, signerAddress }); }; var unFormatStorageValue = (storageValue) => { return JSON.parse(storageValue); }; // src/core/signers/ecdsa/fallbackEoa/fallbackEoaSigner.ts var getFallbackEoaSigner = async ({ smartAccountAddress, encryptionSalt }) => { const privateKey = await getSignerLocalStorage( smartAccountAddress, encryptionSalt ); if (!privateKey) throw new NoPrivateKeyFoundError(); return { privateKey, signer: _accounts.privateKeyToAccount.call(void 0, privateKey) }; }; var createFallbackEoaSigner = async () => { const privateKey = _accounts.generatePrivateKey.call(void 0, ); const signer = _accounts.privateKeyToAccount.call(void 0, privateKey); return { signer, privateKey }; }; // src/core/accounts/safe/abi/safe.ts var SafeAbi = [ { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "owner", type: "address" } ], name: "AddedOwner", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "approvedHash", type: "bytes32" }, { indexed: true, internalType: "address", name: "owner", type: "address" } ], name: "ApproveHash", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "handler", type: "address" } ], name: "ChangedFallbackHandler", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "guard", type: "address" } ], name: "ChangedGuard", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "threshold", type: "uint256" } ], name: "ChangedThreshold", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "module", type: "address" } ], name: "DisabledModule", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "module", type: "address" } ], name: "EnabledModule", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "txHash", type: "bytes32" }, { indexed: false, internalType: "uint256", name: "payment", type: "uint256" } ], name: "ExecutionFailure", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "module", type: "address" } ], name: "ExecutionFromModuleFailure", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "module", type: "address" } ], name: "ExecutionFromModuleSuccess", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "txHash", type: "bytes32" }, { indexed: false, internalType: "uint256", name: "payment", type: "uint256" } ], name: "ExecutionSuccess", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "owner", type: "address" } ], name: "RemovedOwner", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "module", type: "address" }, { indexed: false, internalType: "address", name: "to", type: "address" }, { indexed: false, internalType: "uint256", name: "value", type: "uint256" }, { indexed: false, internalType: "bytes", name: "data", type: "bytes" }, { indexed: false, internalType: "enum Enum.Operation", name: "operation", type: "uint8" } ], name: "SafeModuleTransaction", type: "event" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "to", type: "address" }, { indexed: false, internalType: "uint256", name: "value", type: "uint256" }, { indexed: false, internalType: "bytes", name: "data", type: "bytes" }, { indexed: false, internalType: "enum Enum.Operation", name: "operation", type: "uint8" }, { indexed: false, internalType: "uint256", name: "safeTxGas", type: "uint256" }, { indexed: false, internalType: "uint256", name: "baseGas", type: "uint256" }, { indexed: false, internalType: "uint256", name: "gasPrice", type: "uint256" }, { indexed: false, internalType: "address", name: "gasToken", type: "address" }, { indexed: false, internalType: "address payable", name: "refundReceiver", type: "address" }, { indexed: false, internalType: "bytes", name: "signatures", type: "bytes" }, { indexed: false, internalType: "bytes", name: "additionalInfo", type: "bytes" } ], name: "SafeMultiSigTransaction", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "sender", type: "address" }, { indexed: false, internalType: "uint256", name: "value", type: "uint256" } ], name: "SafeReceived", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "initiator", type: "address" }, { indexed: false, internalType: "address[]", name: "owners", type: "address[]" }, { indexed: false, internalType: "uint256", name: "threshold", type: "uint256" }, { indexed: false, internalType: "address", name: "initializer", type: "address" }, { indexed: false, internalType: "address", name: "fallbackHandler", type: "address" } ], name: "SafeSetup", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "bytes32", name: "msgHash", type: "bytes32" } ], name: "SignMsg", type: "event" }, { stateMutability: "nonpayable", type: "fallback" }, { inputs: [], name: "VERSION", outputs: [ { internalType: "string", name: "", type: "string" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "owner", type: "address" }, { internalType: "uint256", name: "_threshold", type: "uint256" } ], name: "addOwnerWithThreshold", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "hashToApprove", type: "bytes32" } ], name: "approveHash", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "", type: "address" }, { internalType: "bytes32", name: "", type: "bytes32" } ], name: "approvedHashes", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "_threshold", type: "uint256" } ], name: "changeThreshold", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "dataHash", type: "bytes32" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "bytes", name: "signatures", type: "bytes" }, { internalType: "uint256", name: "requiredSignatures", type: "uint256" } ], name: "checkNSignatures", outputs: [], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "bytes32", name: "dataHash", type: "bytes32" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "bytes", name: "signatures", type: "bytes" } ], name: "checkSignatures", outputs: [], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "prevModule", type: "address" }, { internalType: "address", name: "module", type: "address" } ], name: "disableModule", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "domainSeparator", outputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "module", type: "address" } ], name: "enableModule", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "enum Enum.Operation", name: "operation", type: "uint8" }, { internalType: "uint256", name: "safeTxGas", type: "uint256" }, { internalType: "uint256", name: "baseGas", type: "uint256" }, { internalType: "uint256", name: "gasPrice", type: "uint256" }, { internalType: "address", name: "gasToken", type: "address" }, { internalType: "address", name: "refundReceiver", type: "address" }, { internalType: "uint256", name: "_nonce", type: "uint256" } ], name: "encodeTransactionData", outputs: [ { internalType: "bytes", name: "", type: "bytes" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "enum Enum.Operation", name: "operation", type: "uint8" }, { internalType: "uint256", name: "safeTxGas", type: "uint256" }, { internalType: "uint256", name: "baseGas", type: "uint256" }, { internalType: "uint256", name: "gasPrice", type: "uint256" }, { internalType: "address", name: "gasToken", type: "address" }, { internalType: "address payable", name: "refundReceiver", type: "address" }, { internalType: "bytes", name: "signatures", type: "bytes" } ], name: "execTransaction", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "enum Enum.Operation", name: "operation", type: "uint8" } ], name: "execTransactionFromModule", outputs: [ { internalType: "bool", name: "success", type: "bool" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "enum Enum.Operation", name: "operation", type: "uint8" } ], name: "execTransactionFromModuleReturnData", outputs: [ { internalType: "bool", name: "success", type: "bool" }, { internalType: "bytes", name: "returnData", type: "bytes" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "getChainId", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "start", type: "address" }, { internalType: "uint256", name: "pageSize", type: "uint256" } ], name: "getModulesPaginated", outputs: [ { internalType: "address[]", name: "array", type: "address[]" }, { internalType: "address", name: "next", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getOwners", outputs: [ { internalType: "address[]", name: "", type: "address[]" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "uint256", name: "offset", type: "uint256" }, { internalType: "uint256", name: "length", type: "uint256" } ], name: "getStorageAt", outputs: [ { internalType: "bytes", name: "", type: "bytes" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getThreshold", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "to", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "enum Enum.Operation", name: "operation", type: "uint8" }, { internalType: "uint256", name: "safeTxGas", type: "uint256" }, { internalType: "uint256", name: "baseGas", type: "uint256" }, { internalType: "uint256", name: "gasPrice", type: "uint256" }, { internalType: "address", name: "gasToken", type: "address" }, { internalType: "address", name: "refundReceiver", type: "address" }, { internalType: "uint256", name: "_nonce", type: "uint256" } ], name: "getTransactionHash", outputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "module", type: "address" } ], name: "isModuleEnabled", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "owner", type: "address" } ], name: "isOwner", outputs: [ { internalType: "bool", name: "", type: "bool" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "nonce", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "prevOwner", type: "address" }, { internalType: "address", name: "owner", type: "address" }, { internalType: "uint256", name: "_threshold", type: "uint256" } ], name: "removeOwner", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "handler", type: "address" } ], name: "setFallbackHandler", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "guard", type: "address" } ], name: "setGuard", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address[]", name: "_owners", type: "address[]" }, { internalType: "uint256", name: "_threshold", type: "uint256" }, { internalType: "address", name: "to", type: "address" }, { internalType: "bytes", name: "data", type: "bytes" }, { internalType: "address", name: "fallbackHandler", type: "address" }, { internalType: "address", name: "paymentToken", type: "address" }, { internalType: "uint256", name: "payment", type: "uint256" }, { internalType: "address payable", name: "paymentReceiver", type: "address" } ], name: "setup", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "bytes32", name: "", type: "bytes32" } ], name: "signedMessages", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "targetContract", type: "address" }, { internalType: "bytes", name: "calldataPayload", type: "bytes" } ], name: "simulateAndRevert", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "prevOwner", type: "address" }, { internalType: "address", name: "oldOwner", type: "address" }, { internalType: "address", name: "newOwner", type: "address" } ], name: "swapOwner", outputs: [], stateMutability: "nonpayable", type: "function" }, { stateMutability: "payable", type: "receive" } ]; // src/migrationKit/abi/migration.ts var MigrationAbi = [ { inputs: [ { internalType: "address", name: "safeSingleton", type: "address" }, { internalType: "address", name: "safeL2Singleton", type: "address" }, { internalType: "address", name: "fallbackHandler", type: "address" } ], stateMutability: "nonpayable", type: "constructor" }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "singleton", type: "address" } ], name: "ChangedMasterCopy", type: "event" }, { inputs: [], name: "MIGRATION_SINGLETON", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "SAFE_FALLBACK_HANDLER", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "SAFE_L2_SINGLETON", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "SAFE_SINGLETON", outputs: [ { internalType: "address", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "migrateL2Singleton", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "migrateL2WithFallbackHandler", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "migrateSingleton", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "migrateWithFallbackHandler", outputs: [], stateMutability: "nonpayable", type: "function" } ]; // src/core/accounts/safe/services/safe.ts var _permissionless = require('permissionless'); // src/core/accounts/safe/abi/Multisend.ts var MultiSendContractABI = [ { inputs: [], stateMutability: "nonpayable", type: "constructor" }, { inputs: [ { internalType: "bytes", name: "transactions", type: "bytes" } ], name: "multiSend", outputs: [], stateMutability: "payable", type: "function" } ]; // src/core/accounts/safe/abi/enableModule.ts var EnableModuleAbi = [ { inputs: [ { internalType: "address[]", name: "modules", type: "address[]" } ], name: "enableModules", outputs: [], stateMutability: "nonpayable", type: "function" } ]; // src/core/accounts/safe/abi/safeProxyFactory.ts var SafeProxyContractFactoryABI = [ { anonymous: false, inputs: [ { indexed: true, internalType: "contract SafeProxy", name: "proxy", type: "address" }, { indexed: false, internalType: "address", name: "singleton", type: "address" } ], name: "ProxyCreation", type: "event" }, { inputs: [ { internalType: "address", name: "_singleton", type: "address" }, { internalType: "bytes", name: "initializer", type: "bytes" }, { internalType: "uint256", name: "saltNonce", type: "uint256" } ], name: "createChainSpecificProxyWithNonce", outputs: [ { internalType: "contract SafeProxy", name: "proxy", type: "address" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_singleton", type: "address" }, { internalType: "bytes", name: "initializer", type: "bytes" }, { internalType: "uint256", name: "saltNonce", type: "uint256" }, { internalType: "contract IProxyCreationCallback", name: "callback", type: "address" } ], name: "createProxyWithCallback", outputs: [ { internalType: "contract SafeProxy", name: "proxy", type: "address" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "_singleton", type: "address" }, { internalType: "bytes", name: "initializer", type: "bytes" }, { internalType: "uint256", name: "saltNonce", type: "uint256" } ], name: "createProxyWithNonce", outputs: [ { internalType: "contract SafeProxy", name: "proxy", type: "address" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "getChainId", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "proxyCreationCode", outputs: [ { internalType: "bytes", name: "", type: "bytes" } ], stateMutability: "pure", type: "function" } ]; // src/core/accounts/safe/abi/sharedWebAuthnSigner.ts var SafeWebAuthnSharedSignerAbi = [ { type: "constructor", inputs: [], stateMutability: "nonpayable" }, { type: "error", name: "NotDelegateCalled", inputs: [] }, { type: "function", name: "SIGNER_SLOT", inputs: [], outputs: [ { name: "", type: "uint256", internalType: "uint256" } ], stateMutability: "view" }, { type: "function", name: "configure", inputs: [ { name: "signer", type: "tuple", inter