UNPKG

w3s-web-core-sdk-test

Version:

Serverless Typescript SDK

1,392 lines (1,369 loc) 93.4 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN: () => CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN, CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN: () => CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN, DEFAULT_RPC_URL: () => DEFAULT_RPC_URL, EIP712_PREFIX: () => EIP712_PREFIX, ENTRY_POINT_07: () => ENTRY_POINT_07, ERC1769_PROXY: () => ERC1769_PROXY, FACTORY: () => FACTORY, MAINNET_MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT: () => MAINNET_MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT, MAINNET_MINIMUM_VERIFICATION_GAS_LIMIT: () => MAINNET_MINIMUM_VERIFICATION_GAS_LIMIT, MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT: () => MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT, MINIMUM_VERIFICATION_GAS_LIMIT: () => MINIMUM_VERIFICATION_GAS_LIMIT, MODULAR_WALLETS_TRANSPORT_KEY: () => MODULAR_WALLETS_TRANSPORT_KEY, MODULAR_WALLETS_TRANSPORT_NAME: () => MODULAR_WALLETS_TRANSPORT_NAME, ModularWalletsProvider: () => ModularWalletsProvider, PUBLIC_KEY_OWN_WEIGHTS: () => PUBLIC_KEY_OWN_WEIGHTS, PaymasterProvider: () => PaymasterProvider, REPLAY_SAFE_HASH_V1: () => REPLAY_SAFE_HASH_V1, RpProvider: () => RpProvider, SEPOLIA_MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT: () => SEPOLIA_MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT, SEPOLIA_MINIMUM_VERIFICATION_GAS_LIMIT: () => SEPOLIA_MINIMUM_VERIFICATION_GAS_LIMIT, STUB_SIGNATURE: () => STUB_SIGNATURE, THRESHOLD_WEIGHT: () => THRESHOLD_WEIGHT, UPGRADABLE_MSCA: () => UPGRADABLE_MSCA, WebAuthnMode: () => WebAuthnMode, computeAddress: () => computeAddress, createRpClient: () => createRpClient, fetchFromApi: () => fetchFromApi, getAddress: () => getAddress, getCredentialCreationOptions: () => getCredentialCreationOptions, getCredentialRequestOptions: () => getCredentialRequestOptions, getInitializeUpgradableMSCAData: () => getInitializeUpgradableMSCAData, getInitializeUpgradableMSCAParams: () => getInitializeUpgradableMSCAParams, getJsonRpcResponse: () => getJsonRpcResponse, getJsonRpcStringifyResponse: () => getJsonRpcStringifyResponse, getLoginOptions: () => getLoginOptions, getLoginVerification: () => getLoginVerification, getMinimumVerificationGasLimit: () => getMinimumVerificationGasLimit, getModularWalletAddress: () => getModularWalletAddress, getPublicKeyParamsFromOwner: () => getPublicKeyParamsFromOwner, getRegistrationOptions: () => getRegistrationOptions, getRegistrationVerification: () => getRegistrationVerification, getSalt: () => getSalt, isCircleUrl: () => isCircleUrl, modularWalletActions: () => modularWalletActions, parseBase64EncodedPublicKey: () => parseBase64EncodedPublicKey, rpActions: () => rpActions, startAuthentication: () => startAuthentication, startRegistration: () => startRegistration, toCircleModularWalletClient: () => toCircleModularWalletClient, toCircleSmartAccount: () => toCircleSmartAccount, toModularTransport: () => toModularTransport, toPasskeyTransport: () => toPasskeyTransport, toReplaySafeHash: () => toReplaySafeHash, toWebAuthnCredential: () => toWebAuthnCredential, toWebAuthnSignature: () => toWebAuthnSignature, validateClientUrl: () => validateClientUrl, webAuthnSign: () => webAuthnSign, wrapSignature: () => wrapSignature }); module.exports = __toCommonJS(src_exports); // src/utils/address/computeAddress.ts var import_viem4 = require("viem"); // src/constants/provider.ts var DEFAULT_RPC_URL = "https://modular-sdk.circle.com/v1/rpc/w3s/buidl"; var MODULAR_WALLETS_TRANSPORT_KEY = "Modular wallets transport"; var MODULAR_WALLETS_TRANSPORT_NAME = "Modular wallets transport"; // src/constants/smartAccount.ts var import_account_abstraction = require("viem/account-abstraction"); // src/abis/authenticatorData.ts var AUTHENTICATOR_DATA = [ { components: [ { components: [ { internalType: "bytes", name: "authenticatorData", type: "bytes" }, { internalType: "string", name: "clientDataJSON", type: "bytes" }, { internalType: "uint256", name: "challengeIndex", type: "uint256" }, { internalType: "uint256", name: "typeIndex", type: "uint256" }, { internalType: "bool", name: "requireUserVerification", type: "bool" } ], internalType: "struct WebAuthnData", name: "webAuthnData", type: "tuple" }, { internalType: "uint256", name: "r", type: "uint256" }, { internalType: "uint256", name: "s", type: "uint256" } ], name: "WebAuthnSigDynamicPart", type: "tuple" } ]; // src/abis/factory.ts var CIRCLE_MSCA_6900_V1_EP07_FACTORY_ABI = [ { type: "constructor", inputs: [ { name: "_owner", type: "address", internalType: "address" }, { name: "_entryPointAddr", type: "address", internalType: "address" }, { name: "_pluginManagerAddr", type: "address", internalType: "address" } ], stateMutability: "nonpayable" }, { type: "receive", stateMutability: "payable" }, { type: "function", name: "acceptOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "accountImplementation", inputs: [], outputs: [ { name: "", type: "address", internalType: "contract UpgradableMSCA" } ], stateMutability: "view" }, { type: "function", name: "addStake", inputs: [ { name: "_unstakeDelaySec", type: "uint32", internalType: "uint32" } ], outputs: [], stateMutability: "payable" }, { type: "function", name: "createAccount", inputs: [ { name: "_sender", type: "bytes32", internalType: "bytes32" }, { name: "_salt", type: "bytes32", internalType: "bytes32" }, { name: "_initializingData", type: "bytes", internalType: "bytes" } ], outputs: [ { name: "account", type: "address", internalType: "contract UpgradableMSCA" } ], stateMutability: "nonpayable" }, { type: "function", name: "entryPoint", inputs: [], outputs: [ { name: "", type: "address", internalType: "contract IEntryPoint" } ], stateMutability: "view" }, { type: "function", name: "getAddress", inputs: [ { name: "_sender", type: "bytes32", internalType: "bytes32" }, { name: "_salt", type: "bytes32", internalType: "bytes32" }, { name: "_initializingData", type: "bytes", internalType: "bytes" } ], outputs: [ { name: "addr", type: "address", internalType: "address" }, { name: "mixedSalt", type: "bytes32", internalType: "bytes32" } ], stateMutability: "view" }, { type: "function", name: "isPluginAllowed", inputs: [ { name: "", type: "address", internalType: "address" } ], outputs: [ { name: "", type: "bool", internalType: "bool" } ], stateMutability: "view" }, { type: "function", name: "owner", inputs: [], outputs: [ { name: "", type: "address", internalType: "address" } ], stateMutability: "view" }, { type: "function", name: "pendingOwner", inputs: [], outputs: [ { name: "", type: "address", internalType: "address" } ], stateMutability: "view" }, { type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "setPlugins", inputs: [ { name: "_plugins", type: "address[]", internalType: "address[]" }, { name: "_permissions", type: "bool[]", internalType: "bool[]" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "transferOwnership", inputs: [ { name: "newOwner", type: "address", internalType: "address" } ], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "unlockStake", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "withdrawStake", inputs: [ { name: "_withdrawAddress", type: "address", internalType: "address payable" } ], outputs: [], stateMutability: "nonpayable" }, { type: "event", name: "AccountCreated", inputs: [ { name: "proxy", type: "address", indexed: true, internalType: "address" }, { name: "sender", type: "bytes32", indexed: false, internalType: "bytes32" }, { name: "salt", type: "bytes32", indexed: false, internalType: "bytes32" } ], anonymous: false }, { type: "event", name: "FactoryDeployed", inputs: [ { name: "factory", type: "address", indexed: true, internalType: "address" }, { name: "accountImplementation", type: "address", indexed: false, internalType: "address" }, { name: "entryPoint", type: "address", indexed: false, internalType: "address" } ], anonymous: false }, { type: "event", name: "OwnershipTransferStarted", inputs: [ { name: "previousOwner", type: "address", indexed: true, internalType: "address" }, { name: "newOwner", type: "address", indexed: true, internalType: "address" } ], anonymous: false }, { type: "event", name: "OwnershipTransferred", inputs: [ { name: "previousOwner", type: "address", indexed: true, internalType: "address" }, { name: "newOwner", type: "address", indexed: true, internalType: "address" } ], anonymous: false }, { type: "error", name: "Create2FailedDeployment", inputs: [] }, { type: "error", name: "InvalidInitializationInput", inputs: [] }, { type: "error", name: "InvalidLength", inputs: [] }, { type: "error", name: "OwnableInvalidOwner", inputs: [ { name: "owner", type: "address", internalType: "address" } ] }, { type: "error", name: "OwnableUnauthorizedAccount", inputs: [ { name: "account", type: "address", internalType: "address" } ] }, { type: "error", name: "PluginIsNotAllowed", inputs: [ { name: "plugin", type: "address", internalType: "address" } ] } ]; // src/abis/initializingData.ts var INITIALIZING_DATA_ABI_PARAMS = [ { name: "plugins", type: "address[]" }, { name: "manifestHashes", type: "bytes32[]" }, { name: "pluginInstallData", type: "bytes[]" } ]; // src/abis/plugin.ts var CIRCLE_PLUGIN_INSTALL_DATA_ABI = [ { name: "initialOwners", type: "address[]" }, { name: "ownerWeights", type: "uint256[]" }, { name: "initialPublicKeyOwners", type: "tuple[]", components: [ { name: "x", type: "uint256" }, { name: "y", type: "uint256" } ] }, { name: "publicKeyOwnerWeights", type: "uint256[]" }, { name: "thresholdWeight", type: "uint256" } ]; // src/abis/publicKeyCoordinates.ts var PUBLIC_KEY_COORDINATES_ABI = [ { name: "x", type: "uint256" }, { name: "y", type: "uint256" } ]; // src/abis/upgradableMsca.ts var CIRCLE_MSCA_6900_V1_EP07_ABI = [ { inputs: [ { internalType: "contract IEntryPoint", name: "_newEntryPoint", type: "address" }, { internalType: "contract PluginManager", name: "_newPluginManager", type: "address" } ], stateMutability: "nonpayable", type: "constructor" }, { inputs: [{ internalType: "address", name: "target", type: "address" }], name: "AddressEmptyCode", type: "error" }, { inputs: [ { internalType: "address", name: "implementation", type: "address" } ], name: "ERC1967InvalidImplementation", type: "error" }, { inputs: [], name: "ERC1967NonPayable", type: "error" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "bytes4", name: "selector", type: "bytes4" } ], name: "ExecFromPluginToSelectorNotPermitted", type: "error" }, { inputs: [], name: "ExecuteFromPluginToExternalNotPermitted", type: "error" }, { inputs: [], name: "FailedInnerCall", type: "error" }, { inputs: [], name: "InvalidAuthorizer", type: "error" }, { inputs: [{ internalType: "bytes4", name: "selector", type: "bytes4" }], name: "InvalidExecutionFunction", type: "error" }, { inputs: [{ internalType: "uint8", name: "functionId", type: "uint8" }], name: "InvalidHookFunctionId", type: "error" }, { inputs: [], name: "InvalidInitialization", type: "error" }, { inputs: [], name: "InvalidInitializationInput", type: "error" }, { inputs: [], name: "InvalidLimit", type: "error" }, { inputs: [{ internalType: "uint8", name: "functionId", type: "uint8" }], name: "InvalidValidationFunctionId", type: "error" }, { inputs: [{ internalType: "address", name: "plugin", type: "address" }], name: "NativeTokenSpendingNotPermitted", type: "error" }, { inputs: [], name: "NotFoundSelector", type: "error" }, { inputs: [], name: "NotInitializing", type: "error" }, { inputs: [{ internalType: "bytes4", name: "selector", type: "bytes4" }], name: "NotNativeFunctionSelector", type: "error" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" }, { internalType: "bytes", name: "revertReason", type: "bytes" } ], name: "PostExecHookFailed", type: "error" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" }, { internalType: "bytes", name: "revertReason", type: "bytes" } ], name: "PreExecHookFailed", type: "error" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" }, { internalType: "bytes", name: "revertReason", type: "bytes" } ], name: "PreRuntimeValidationHookFailed", type: "error" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" }, { internalType: "bytes", name: "revertReason", type: "bytes" } ], name: "RuntimeValidationFailed", type: "error" }, { inputs: [{ internalType: "address", name: "plugin", type: "address" }], name: "TargetIsPlugin", type: "error" }, { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" }, { inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }], name: "UUPSUnsupportedProxiableUUID", type: "error" }, { inputs: [], name: "UnauthorizedCaller", type: "error" }, { inputs: [], name: "WalletStorageIsInitialized", type: "error" }, { inputs: [], name: "WalletStorageIsInitializing", type: "error" }, { inputs: [], name: "WalletStorageIsNotInitializing", type: "error" }, { inputs: [], name: "WrongTimeBounds", type: "error" }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint64", name: "version", type: "uint64" } ], name: "Initialized", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "plugin", type: "address" }, { indexed: false, internalType: "bytes32", name: "manifestHash", type: "bytes32" }, { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], indexed: false, internalType: "struct FunctionReference[]", name: "dependencies", type: "tuple[]" } ], name: "PluginInstalled", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "plugin", type: "address" }, { indexed: true, internalType: "bool", name: "onUninstallSucceeded", type: "bool" } ], name: "PluginUninstalled", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "account", type: "address" }, { indexed: true, internalType: "address", name: "entryPointAddress", type: "address" } ], name: "UpgradableMSCAInitialized", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "implementation", type: "address" } ], name: "Upgraded", type: "event" }, { anonymous: false, inputs: [], name: "WalletStorageInitialized", type: "event" }, { stateMutability: "payable", type: "fallback" }, { inputs: [], name: "UPGRADE_INTERFACE_VERSION", outputs: [{ internalType: "string", name: "", type: "string" }], stateMutability: "view", type: "function" }, { inputs: [], name: "addDeposit", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [], name: "author", outputs: [{ internalType: "string", name: "", type: "string" }], stateMutability: "view", type: "function" }, { inputs: [], name: "entryPoint", outputs: [ { internalType: "contract IEntryPoint", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "target", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" } ], name: "execute", outputs: [{ internalType: "bytes", name: "returnData", type: "bytes" }], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "address", name: "target", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" } ], internalType: "struct Call[]", name: "calls", type: "tuple[]" } ], name: "executeBatch", outputs: [{ internalType: "bytes[]", name: "returnData", type: "bytes[]" }], stateMutability: "payable", type: "function" }, { inputs: [{ internalType: "bytes", name: "data", type: "bytes" }], name: "executeFromPlugin", outputs: [{ internalType: "bytes", name: "", type: "bytes" }], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "target", type: "address" }, { internalType: "uint256", name: "value", type: "uint256" }, { internalType: "bytes", name: "data", type: "bytes" } ], name: "executeFromPluginExternal", outputs: [{ internalType: "bytes", name: "", type: "bytes" }], stateMutability: "payable", type: "function" }, { inputs: [], name: "getDeposit", outputs: [{ internalType: "uint256", name: "", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [], name: "getEntryPoint", outputs: [ { internalType: "contract IEntryPoint", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "bytes4", name: "selector", type: "bytes4" }], name: "getExecutionFunctionConfig", outputs: [ { components: [ { internalType: "address", name: "plugin", type: "address" }, { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference", name: "userOpValidationFunction", type: "tuple" }, { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference", name: "runtimeValidationFunction", type: "tuple" } ], internalType: "struct ExecutionFunctionConfig", name: "executionFunctionConfig", type: "tuple" } ], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "bytes4", name: "selector", type: "bytes4" }], name: "getExecutionHooks", outputs: [ { components: [ { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference", name: "preExecHook", type: "tuple" }, { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference", name: "postExecHook", type: "tuple" } ], internalType: "struct ExecutionHooks[]", name: "executionHooks", type: "tuple[]" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getInstalledPlugins", outputs: [ { internalType: "address[]", name: "pluginAddresses", type: "address[]" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "getNonce", outputs: [{ internalType: "uint256", name: "", type: "uint256" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "bytes4", name: "selector", type: "bytes4" }], name: "getPreValidationHooks", outputs: [ { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference[]", name: "preUserOpValidationHooks", type: "tuple[]" }, { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference[]", name: "preRuntimeValidationHooks", type: "tuple[]" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address[]", name: "plugins", type: "address[]" }, { internalType: "bytes32[]", name: "manifestHashes", type: "bytes32[]" }, { internalType: "bytes[]", name: "pluginInstallData", type: "bytes[]" } ], name: "initializeUpgradableMSCA", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "bytes32", name: "manifestHash", type: "bytes32" }, { internalType: "bytes", name: "pluginInstallData", type: "bytes" }, { components: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "uint8", name: "functionId", type: "uint8" } ], internalType: "struct FunctionReference[]", name: "dependencies", type: "tuple[]" } ], name: "installPlugin", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "pluginManager", outputs: [ { internalType: "contract PluginManager", name: "", type: "address" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "proxiableUUID", outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], stateMutability: "view", type: "function" }, { inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], name: "supportsInterface", outputs: [{ internalType: "bool", name: "", type: "bool" }], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "plugin", type: "address" }, { internalType: "bytes", name: "config", type: "bytes" }, { internalType: "bytes", name: "pluginUninstallData", type: "bytes" } ], name: "uninstallPlugin", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address", name: "newImplementation", type: "address" }, { internalType: "bytes", name: "data", type: "bytes" } ], name: "upgradeToAndCall", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { components: [ { internalType: "address", name: "sender", type: "address" }, { internalType: "uint256", name: "nonce", type: "uint256" }, { internalType: "bytes", name: "initCode", type: "bytes" }, { internalType: "bytes", name: "callData", type: "bytes" }, { internalType: "bytes32", name: "accountGasLimits", type: "bytes32" }, { internalType: "uint256", name: "preVerificationGas", type: "uint256" }, { internalType: "bytes32", name: "gasFees", type: "bytes32" }, { internalType: "bytes", name: "paymasterAndData", type: "bytes" }, { internalType: "bytes", name: "signature", type: "bytes" } ], internalType: "struct PackedUserOperation", name: "userOp", type: "tuple" }, { internalType: "bytes32", name: "userOpHash", type: "bytes32" }, { internalType: "uint256", name: "missingAccountFunds", type: "uint256" } ], name: "validateUserOp", outputs: [ { internalType: "uint256", name: "validationData", type: "uint256" } ], stateMutability: "nonpayable", type: "function" }, { inputs: [], name: "version", outputs: [{ internalType: "string", name: "", type: "string" }], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address payable", name: "withdrawAddress", type: "address" }, { internalType: "uint256", name: "amount", type: "uint256" } ], name: "withdrawDepositTo", outputs: [], stateMutability: "nonpayable", type: "function" }, { stateMutability: "payable", type: "receive" } ]; // src/bytecode/factory.ts var CIRCLE_MSCA_6900_V07_FACTORY_BYTECODE = "0x6040608081526004803610156200001557600080fd5b600091823560e01c9081630396cb60146200060257816311464fbe14620005bc578163715018a6146200055257816379ba509714620004c157816381d0dff1146200048f5781638da5cb5b1462000465578163a50833cd1462000422578163acf85fc114620003d5578163b0d691fe146200038f57838263bb9fe6bf1462000310578263c23a5cea146200025f57508163e034b090146200016e578163e30c39781462000143575063f2fde38b14620000cd57600080fd5b346200013f5760203660031901126200013f57356001600160a01b03818116918290036200013b57620000ff62000c62565b600180546001600160a01b031916831790558254167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b8280fd5b5080fd5b8390346200013f57816003193601126200013f5760015490516001600160a01b039091168152602090f35b9050346200013b57806003193601126200013b5767ffffffffffffffff9082358281116200025b57620001a5903690850162000783565b90926024359081116200025757620001c1903690860162000783565b9094620001cd62000c62565b818303620002495750855b828110620001e4578680f35b620001f181838862000c3b565b359081151580920362000245576200020b81858862000c3b565b356001600160a01b03811692908390036200024157600192895260026020528589209060ff8019835416911617905501620001d8565b8880fd5b8780fd5b835163251f56a160e21b8152fd5b8580fd5b8480fd5b929150346200030c5760203660031901126200030c5781356001600160a01b0381811693918490036200025b576200029662000c62565b7f0000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0321692833b156200025b5760248592838551968794859363611d2e7560e11b85528401525af1908115620003035750620002ed5750f35b620002f8906200069a565b620003005780f35b80fd5b513d84823e3d90fd5b5050fd5b929150346200030c57826003193601126200030c576200032f62000c62565b7f0000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0326001600160a01b031691823b156200038a57815163bb9fe6bf60e01b81529284918491829084905af1908115620003035750620002ed5750f35b505050fd5b8390346200013f57816003193601126200013f57517f0000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0326001600160a01b03168152602090f35b83346200030057506200040c62000403620003f03662000705565b60208082959395518301019101620007f5565b93909262000ca4565b82516001600160a01b0390921682526020820152f35b919050346200013b5760203660031901126200013b57356001600160a01b038116908190036200013b57818360ff92602095526002855220541690519015158152f35b8390346200013f57816003193601126200013f57905490516001600160a01b039091168152602090f35b8390346200013f57602090620004b0620004a93662000705565b9162000afd565b90516001600160a01b039091168152f35b9050346200013b57826003193601126200013b57600154916001600160a01b039133838516036200053b5750506bffffffffffffffffffffffff60a01b8092166001556000549133908316176000553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a380f35b60249250519063118cdaa760e01b82523390820152fd5b833462000300578060031936011262000300576200056f62000c62565b600180546001600160a01b0319908116909155600080549182168155906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b8390346200013f57816003193601126200013f57517f000000000000000000000000d3987990b728a8f62819ef2fb58180188fb266a76001600160a01b03168152602090f35b905060203660031901126200013b5782823563ffffffff81168091036200013f576200062d62000c62565b7f0000000000000000000000000000000071727de22e5e9d8baf0edac6f37da0326001600160a01b031693843b156200013b5760249084519586938492621cb65b60e51b845283015234905af19081156200030357506200068c575080f35b62000697906200069a565b80f35b67ffffffffffffffff8111620006af57604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117620006af57604052565b67ffffffffffffffff8111620006af57601f01601f191660200190565b60606003198201126200077e57600435916024359160443567ffffffffffffffff81116200077e57816023820112156200077e578060040135906200074a82620006e8565b926200075a6040519485620006c5565b828452602483830101116200077e5781600092602460209301838601378301015290565b600080fd5b9181601f840112156200077e5782359167ffffffffffffffff83116200077e576020808501948460051b0101116200077e57565b67ffffffffffffffff8111620006af5760051b60200190565b60005b838110620007e45750506000910152565b8181015183820152602001620007d3565b90916060828403126200077e57815167ffffffffffffffff908181116200077e57830184601f820112156200077e578051946020916200083587620007b7565b906040976200084789519384620006c5565b808352848084019160051b830101918483116200077e578501905b828210620009ae5750505095828601518481116200077e57860182601f820112156200077e578051906200089682620007b7565b91620008a584519384620006c5565b808352858084019160051b830101918583116200077e5786809101915b8383106200099d57505050509581810151908582116200077e57019180601f840112156200077e57825190620008f882620007b7565b956200090784519788620006c5565b828752858088019360051b860101948286116200077e57868101935b8685106200093657505050505050505090565b84518381116200077e5782019084603f830112156200077e5788820151906200095f82620006e8565b6200096d89519182620006c5565b828152868984860101116200077e57620009918b949385948b8685019101620007d0565b81520194019362000923565b8251815291810191879101620008c2565b81516001600160a01b03811681036200077e57815290850190850162000862565b90602091620009ea81518092818552858086019101620007d0565b601f01601f1916010190565b60608101606082528251809152608082019060208094019060005b8582821062000ab857505050508181038383015282808551928381520194019060005b81811062000aa35750505060408184039101528251908183528083019281808460051b8301019501936000915b84831062000a725750505050505090565b909192939495848062000a92600193601f198682030187528a51620009cf565b980193019301919493929062000a61565b82518652948401949184019160010162000a34565b83516001600160a01b03168552938401939092019160010162000a11565b6001600160a01b03909116815260406020820181905262000afa92910190620009cf565b90565b929162000b149060208082518301019101620007f5565b9162000b26838383878a969a62000ca4565b9096873b62000c275762000b6d60018060a01b039362000b5e60409788519485936370c321eb60e01b602086015260248501620009f6565b03601f198101835282620006c5565b8451906102d38083019183831067ffffffffffffffff841117620006af57839262000bc29262000e9a8539867f000000000000000000000000d3987990b728a8f62819ef2fb58180188fb266a7169062000ad6565b03906000f5801562000c1c57811695169283860362000c0b57825191825260208201527f934abbffb6906db60a85b076f1e41da9667dfa53c7724f4fe2333298d7b1db8c9190a2565b8251633a0ba96160e11b8152600490fd5b83513d6000823e3d90fd5b50506001600160a01b039095169450505050565b919081101562000c4c5760051b0190565b634e487b7160e01b600052603260045260246000fd5b6000546001600160a01b0316330362000c7757565b60405163118cdaa760e01b8152336004820152602490fd5b805182101562000c4c5760209160051b010190565b91939492908451801590811562000e8c575b811562000e7f575b5062000e6d5760005b855181101562000d2f576001600160a01b038062000ce6838962000c8f565b5116600052600260205260409060ff8260002054161562000d0c57505060010162000cc7565b62000d1a6024938962000c8f565b519151625e27f360e81b815291166004820152fd5b509091929394604091825160209182820196875284820152838152606081019481861067ffffffffffffffff871117620006af5762000e54838762000e479362000dbc9c60559b600b9b8b52875190209d8e9960806102d39962000d96888c0188620006c5565b8a8752019862000e9a8a398b516370c321eb60e01b8782015293849360248501620009f6565b0362000dd1601f1991828101845283620006c5565b62000e1e8a51918262000e118782019560018060a01b037f000000000000000000000000d3987990b728a8f62819ef2fb58180188fb266a7168762000ad6565b03908101835282620006c5565b895195869362000e37868601998a9251928391620007d0565b84019151809386840190620007d0565b01038084520182620006c5565b5190208351938401528201523081520160ff8153209190565b604051635297bbdb60e11b8152600490fd5b9050865114153862000cbe565b8351811415915062000cb656fe60806040526102d38038038061001481610194565b92833981019060408183031261018f5780516001600160a01b03811680820361018f5760208381015190936001600160401b03821161018f570184601f8201121561018f5780519061006d610068836101cf565b610194565b9582875285838301011161018f57849060005b83811061017b57505060009186010152813b15610163577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b03191682179055604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28351156101455750600080848461012c96519101845af4903d1561013c573d61011c610068826101cf565b908152600081943d92013e6101ea565b505b6040516085908161024e8239f35b606092506101ea565b9250505034610154575061012e565b63b398979f60e01b8152600490fd5b60249060405190634c9c8ce360e01b82526004820152fd5b818101830151888201840152869201610080565b600080fd5b6040519190601f01601f191682016001600160401b038111838210176101b957604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116101b957601f01601f191660200190565b9061021157508051156101ff57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580610244575b610222575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561021a56fe60806040527f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54600090819081906001600160a01b0316368280378136915af43d82803e15604b573d90f35b3d90fdfea26469706673582212202b867e05fada64e8389ea34fca4e9048d8dde9af33f4fdd783dd16f9ba5fcf9c64736f6c63430008180033a264697066735822122092daff5db426464b06d1b690c6f5ffb5bb1e6a2d5c94602ef7595a14039390b564736f6c63430008180033"; // src/constants/smartAccount.ts var ENTRY_POINT_07 = { abi: import_account_abstraction.entryPoint07Abi, address: import_account_abstraction.entryPoint07Address, version: "0.7" }; var FACTORY = { abi: CIRCLE_MSCA_6900_V1_EP07_FACTORY_ABI, address: "0xc83d88C018D143d08AFE910221D445189Fc6817a", bytecode: CIRCLE_MSCA_6900_V07_FACTORY_BYTECODE }; var UPGRADABLE_MSCA = { abi: CIRCLE_MSCA_6900_V1_EP07_ABI, /** * The address of the upgradable MSCA account implementation. * @remarks This address is from https://sepolia.etherscan.io/address/0xc83d88c018d143d08afe910221d445189fc6817a#readContract `accountImplementation` value. */ address: "0xd3987990b728a8F62819ef2Fb58180188fb266a7" }; var CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN = { address: "0x5a2262d58eB72B84701D6efBf6bB6586C793A65b", manifestHash: "0xa043327d77a74c1c55cfa799284b831fe09535a88b9f5fa4173d334e5ba0fd91" }; var CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN = { address: "0x03431Fb00fB2e26b5bC502DFeF8dA30E1C8643b8", manifestHash: "0xd892482cc7e665eca1d358d318d38aa3a63c10247d473d04fc3538f4069ce4ae", installData: "0x" }; var ERC1769_PROXY = { creationCode: "0x60806040526102d38038038061001481610194565b92833981019060408183031261018f5780516001600160a01b03811680820361018f5760208381015190936001600160401b03821161018f570184601f8201121561018f5780519061006d610068836101cf565b610194565b9582875285838301011161018f57849060005b83811061017b57505060009186010152813b15610163577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b03191682179055604051907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28351156101455750600080848461012c96519101845af4903d1561013c573d61011c610068826101cf565b908152600081943d92013e6101ea565b505b6040516085908161024e8239f35b606092506101ea565b9250505034610154575061012e565b63b398979f60e01b8152600490fd5b60249060405190634c9c8ce360e01b82526004820152fd5b818101830151888201840152869201610080565b600080fd5b6040519190601f01601f191682016001600160401b038111838210176101b957604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116101b957601f01601f191660200190565b9061021157508051156101ff57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580610244575b610222575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561021a56fe60806040527f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54600090819081906001600160a01b0316368280378136915af43d82803e15604b573d90f35b3d90fdfea26469706673582212202b867e05fada64e8389ea34fca4e9048d8dde9af33f4fdd783dd16f9ba5fcf9c64736f6c63430008180033" }; var PUBLIC_KEY_OWN_WEIGHTS = [1n]; var THRESHOLD_WEIGHT = 1n; var STUB_SIGNATURE = "0x0000be58786f7ae825e097256fc83a4749b95189e03e9963348373e9c595b15200000000000000000000000000000000000000000000000000000000000000412200000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006091077742edaf8be2fa866827236532ec2a5547fe2721e606ba591d1ffae7a15c022e5f8fe5614bbf65ea23ad3781910eb04a1a60fae88190001ecf46e5f5680a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a224b6d62474d316a4d554b57794d6352414c6774553953537144384841744867486178564b6547516b503541222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000"; var REPLAY_SAFE_HASH_V1 = { name: "Weighted Multisig Webauthn Plugin", primaryType: "CircleWeightedWebauthnMultisigMessage", domainSeparatorType: "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)", moduleType: "CircleWeightedWebauthnMultisigMessage(bytes32 hash)", version: "1.0.0" }; var EIP712_PREFIX = "0x1901"; var MINIMUM_VERIFICATION_GAS_LIMIT = 6e5; var MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT = 15e5; var SEPOLIA_MINIMUM_VERIFICATION_GAS_LIMIT = 6e5; var SEPOLIA_MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT = 2e6; var MAINNET_MINIMUM_VERIFICATION_GAS_LIMIT = 1e6; var MAINNET_MINIMUM_UNDEPLOY_VERIFICATION_GAS_LIMIT = 25e5; // src/utils/address/getPublicKeyParamsFromOwner.ts var import_viem = require("viem"); var import_webauthn_p256 = require("webauthn-p256"); function getPublicKeyParamsFromOwner(owner) { const publicKey = (0, import_webauthn_p256.parsePublicKey)(owner.publicKey); const initialPublicKeyOwners = [publicKey]; const sender = (0, import_viem.keccak256)( (0, import_viem.encodeAbiParameters)(PUBLIC_KEY_COORDINATES_ABI, [ initialPublicKeyOwners[0].x, initialPublicKeyOwners[0].y ]) ); return { sender, initialPublicKeyOwners }; } // src/utils/address/getSalt.ts var import_viem2 = require("viem"); function getSalt() { return (0, import_viem2.pad)("0x", { size: 32 }); } // src/utils/address/initializeUpgradableMSCA.ts var import_viem3 = require("viem"); function getInitializeUpgradableMSCAData(owner) { const { initialPublicKeyOwners } = getPublicKeyParamsFromOwner(owner); const pluginInstallParams = (0, import_viem3.encodeAbiParameters)( CIRCLE_PLUGIN_INSTALL_DATA_ABI, [[], [], initialPublicKeyOwners, PUBLIC_KEY_OWN_WEIGHTS, THRESHOLD_WEIGHT] ); const initializeUpgradableMSCAData = (0, import_viem3.encodeFunctionData)({ abi: UPGRADABLE_MSCA.abi, functionName: "initializeUpgradableMSCA", args: [ [ CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN.address, CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN.address ], [ CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN.manifestHash, CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN.manifestHash ], [pluginInstallParams, CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN.installData] ] }); return initializeUpgradableMSCAData; } function getInitializeUpgradableMSCAParams(owner) { const { initialPublicKeyOwners } = getPublicKeyParamsFromOwner(owner); const pluginInstallParams = (0, import_viem3.encodeAbiParameters)( CIRCLE_PLUGIN_INSTALL_DATA_ABI, [[], [], initialPublicKeyOwners, PUBLIC_KEY_OWN_WEIGHTS, THRESHOLD_WEIGHT] ); const initializeUpgradableMSCAParams = (0, import_viem3.encodeAbiParameters)( INITIALIZING_DATA_ABI_PARAMS, [ [ CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN.address, CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN.address ], [ CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN.manifestHash, CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN.manifestHash ], [pluginInstallParams, CIRCLE_DEFAULT_TOKEN_CALLBACK_PLUGIN.installData] ] ); return initializeUpgradableMSCAParams; } // src/utils/address/computeAddress.ts function computeAddress(owner) { const { sender } = getPublicKeyParamsFromOwner(owner); const salt = getSalt(); const initializeUpgradableMSCAData = getInitializeUpgradableMSCAData(owner); const mixedSalt = (0, import_viem4.keccak256)( (0, import_viem4.encodeAbiParameters)( [{ type: "bytes32" }, { type: "bytes32" }], [sender, salt] ) ); const bytecode = (0, import_viem4.encodePacked)( ["bytes", "bytes"], [ ERC1769_PROXY.creationCode, (0, import_viem4.encodeAbiParameters)((0, import_viem4.parseAbiParameters)("address, bytes"), [ UPGRADABLE_MSCA.address, initializeUpgradableMSCAData ]) ] ); const address = (0, import_viem4.getContractAddress)({ bytecode, from: FACTORY.address, opcode: "CREATE2", salt: mixedSalt }); return address; } // src/utils/mock/getJsonRpcResponse.ts function getJsonRpcResponse(payload, result) { return Promise.resolve({ id: payload.id, jsonrpc: "2.0", result }); } // src/utils/mock/getJsonRpcStringifyResponse.ts function getJsonRpcStringifyResponse(result, id = 1) { const mockResponse = { id, jsonrpc: "2.0", result }; return JSON.stringify(mockResponse); } // src/utils/publicKey/parseBase64EncodedPublicKey.ts var import_webauthn_p2562 = require("webauthn-p256"); async function parseBase64EncodedPublicKey(base64Url) { const bytes = (0, import_webauthn_p2562.base64UrlToBytes)(base64Url); const cryptoKey = await (0, import_webauthn_p2562.bytesToCryptoKey)(bytes); const publicKey = await (0, import_webauthn_p2562.cryptoKeyToBytes)(cryptoKey); return (0, import_webauthn_p2562.parsePublicKey)(publicKey); } // src/utils/rpc/fetchFromApi.ts var import_uuid = require("uuid"); var import_viem5 = require("viem"); var import_web3 = require("web3"); async function fetchFromApi(clientUrl, clientKey, payload, requestOptions) { const fetchResponse = await fetch(clientUrl, { ...requestOptions, method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${clientKey}`, "X-AppInfo": `platform=web;version=${"1.0.0"};uri=${window?.location?.hostname}` }, body: JSON.stringify({ ...payload, jsonrpc: "2.0", id: payload?.id ?? (0, import_uuid.v4)() }) }); if (!fetchResponse.ok) { const errorResponse = await fetchResponse.json(); throw new import_web3.ResponseError( errorResponse, void 0, void 0, fetchResponse.status ); } const jsonResponse = await fetchResponse.json(); if ("error" in jsonResponse) { const errorResponse = jsonResponse; throw new import_viem5.EIP1193ProviderRpcError( errorResponse.error.code, errorResponse.error.message ); } return jsonResponse; } // src/utils/rpc/isCircleUrl.ts function isCircleUrl(url) { try { const parsedUrl = new URL(url); const allowedHosts = [ "modular-sdk.circle.com", "modular-sdk-staging.circle.com" ]; return allowedHosts.includes(parsedUrl.host); } catch { return false; } } // src/utils/rpc/validateClientUrl.ts function validateClientUrl(clientUrl) { try { const url = new URL(clientUrl); const urlPattern = /^(https?:\/\/)([\da-zA-Z.-]+)(:[\d]{1,5})?([/\w .-]*)*(\?[^\s]*)?$/; if (!urlPattern.test(clientUrl)) { return false; } return url.protocol === "http:" || url.protocol === "https:"; } catch { return false; } } // src/utils/signature/toReplaySafeHash.ts var import_viem6 = require("viem"); function toReplaySafeHash({ address, chainId, hash }) { const textEncoder = new TextEncoder(); const { name, version, domainSeparatorType, moduleType } = REPLAY_SAFE_HASH_V1; const domainSeparatorTypeHash = (0, import_viem6.keccak256)( textEncoder.encode(domainSeparatorType) ); const moduleIdHash = (0, import_viem6.keccak256)( (0, import_viem6.encodePacked)(["string", "string"], [name, version]) ); const moduleTypeHash = (0, import_viem6.keccak256)(textEncoder.encode(moduleType)); const domainSeparator = (0, import_viem6.encodePacked)( ["bytes", "bytes", "uint256", "bytes32", "bytes32"], [ domainSeparatorTypeHash, moduleIdHash, BigInt(chainId), (0, import_viem6.pad)(CIRCLE_WEIGHTED_WEB_AUTHN_MULTISIG_PLUGIN.address), (0, import_viem6.pad)(address, { dir: "right" }) ] ); const structHash = (0, import_viem6.encodePacked)(["bytes", "bytes"], [moduleTypeHash, hash]);