import { Hex, ControlProof, OpContext, WalletKitClient, Wallet } from '@universal-everything/sdk-core'; import { LocalAccount } from 'viem'; /** * A1 control-proof helper. The relayer's external-controller deploy requires * the caller to prove they hold `controllerAddress` by signing a canonical, * nonce-bound message. This builds that exact message (byte-identical to the * relayer's `buildControlProofMessage`) and packages the signature. * * The signing itself is caller-supplied (`signMessage`) so this works with any * key source — a Privy embedded wallet, a wagmi `signMessage`, or a viem * account — without this package depending on any of them. */ type ControlProofClaims = { /** The Privy `did:privy:*` account the profile will be recorded under. */ subject: string; /** The user-held controller being proven. */ controllerAddress: Hex; /** CREATE2-predicted UP address for this deploy. */ predictedAddress: Hex; /** Target chain id. */ chainId: number; /** Exact deployment calldata (bound as a keccak256 hash). */ deploymentCalldata: Hex; }; /** * The exact string the controller signs. MUST stay byte-identical to the * relayer's `buildControlProofMessage` (apps/relayer/src/services/control-proof.ts) * or the recovered signer won't match and the deploy is rejected. */ declare function buildControlProofMessage(claims: ControlProofClaims, nonce: string, issuedAtUnix: number): string; /** * Build a {@link ControlProof} by signing the canonical message. Pair with * `client.getNonce()` for the nonce and `Math.floor(Date.now() / 1000)` for * `issuedAtUnix`. `signMessage` should EIP-191 personal_sign the string (e.g. * wagmi `signMessage({ message })`, viem `account.signMessage({ message })`, * or Privy). */ declare function buildControlProof(claims: ControlProofClaims, nonce: string, issuedAtUnix: number, signMessage: (message: string) => Promise): Promise; /** * Client-side LSP-23 CREATE2 helpers — build the `deployERC1167Proxies` * calldata for a given salt and derive the resulting Universal Profile * address WITHOUT a chain roundtrip. This lets an onboarding client "vary the * salt" to offer a choice of profile addresses (identicons) before deploying. * * The derivation is byte-identical to the relayer's server-side check * (`apps/relayer/src/services/up-create2.ts`): same salt construction, same * EIP-1167 minimal-proxy bytecode template. A `predictedAddress` computed here * will match what the relayer independently re-derives from the same calldata. */ /** * LSP-23 `deployERC1167Proxies` ABI fragment (stable per the LSP-23 spec — * hardcoded to avoid the `@lukso/lsp23-contracts` artifact dependency). */ declare const DEPLOY_ERC1167_PROXIES_ABI: readonly [{ readonly type: "function"; readonly name: "deployERC1167Proxies"; readonly stateMutability: "payable"; readonly inputs: readonly [{ readonly name: "primaryContractDeploymentInit"; readonly type: "tuple"; readonly components: readonly [{ readonly name: "salt"; readonly type: "bytes32"; }, { readonly name: "fundingAmount"; readonly type: "uint256"; }, { readonly name: "implementationContract"; readonly type: "address"; }, { readonly name: "initializationCalldata"; readonly type: "bytes"; }]; }, { readonly name: "secondaryContractDeploymentInit"; readonly type: "tuple"; readonly components: readonly [{ readonly name: "fundingAmount"; readonly type: "uint256"; }, { readonly name: "implementationContract"; readonly type: "address"; }, { readonly name: "initializationCalldata"; readonly type: "bytes"; }, { readonly name: "addPrimaryContractAddress"; readonly type: "bool"; }, { readonly name: "extraInitializationParams"; readonly type: "bytes"; }]; }, { readonly name: "postDeploymentModule"; readonly type: "address"; }, { readonly name: "postDeploymentModuleCalldata"; readonly type: "bytes"; }]; readonly outputs: readonly [{ readonly name: "primaryContractAddress"; readonly type: "address"; }, { readonly name: "secondaryContractAddress"; readonly type: "address"; }]; }]; /** Inputs to build a `deployERC1167Proxies` calldata. Only `salt` typically * varies between identicon candidates; the rest are fixed per chain/profile. */ type Lsp23DeploymentParams = { /** CREATE2 salt — vary this to get different profile addresses. */ salt: Hex; /** Primary proxy (UP) implementation. */ primaryImplementation: Hex; /** Primary proxy init calldata (default "0x"). */ primaryInitializationCalldata?: Hex; /** Primary funding amount (default 0). */ primaryFundingAmount?: bigint; /** Secondary proxy (Key Manager) implementation. */ secondaryImplementation: Hex; /** Secondary proxy init calldata (default "0x"). */ secondaryInitializationCalldata?: Hex; /** Secondary funding amount (default 0). */ secondaryFundingAmount?: bigint; /** Append the primary (UP) address to the secondary init (default true). */ addPrimaryContractAddress?: boolean; /** Secondary extra init params (default "0x"). */ secondaryExtraInitializationParams?: Hex; /** Post-deployment module (sets LSP-6 permissions / LSP-3 data). */ postDeploymentModule: Hex; /** Post-deployment module calldata (the setData payload). */ postDeploymentModuleCalldata: Hex; }; /** Encode `deployERC1167Proxies` calldata from the given params. */ declare function encodeDeploymentCalldata(params: Lsp23DeploymentParams): Hex; /** * Independently derive the LSP-23 CREATE2 profile address from * `deploymentCalldata` + the chain's LSP-23 factory. Returns the lowercased * `0x…` address. Throws if the calldata doesn't decode as * `deployERC1167Proxies`. */ declare function deriveLsp23ProxyAddress(opts: { factoryAddress: Hex; deploymentCalldata: Hex; }): Hex; /** * Build the calldata AND derive the predicted address in one call — the unit * an onboarding client repeats while varying `params.salt` to render identicon * candidates. */ declare function predictProfileAddress(factoryAddress: Hex, params: Lsp23DeploymentParams): { deploymentCalldata: Hex; predictedAddress: Hex; }; /** * viem `LocalAccount` adapter for a WalletKit-managed wallet. * * Wraps an existing `Wallet` record so the server-held private key * appears as an ordinary viem account. Drops into any viem * `WalletClient`: * * ```ts * const client = new WalletKitClient({ baseUrl, getAccessToken }); * const [wallet] = await client.listWallets(); * const account = createWalletKitAccount(client, wallet); * const walletClient = createWalletClient({ account, transport: http(...), chain }); * const hash = await walletClient.sendTransaction({ ... }); * ``` * * Method routing: * - `signMessage({ message })` → `POST /v1/sign/message` * - `signTransaction(tx)` → `POST /v1/sign/transaction` * - `signTypedData(typedData)` → throws (not supported server-side yet) * * Privy per-op authorization: if a caller needs to forward a Privy * authorization signature (required for user-owned Privy wallets), * pass a `getOpContext` callback. It's invoked fresh per sign * operation so each request gets a fresh signature. */ type CreateWalletKitAccountOptions = { /** * Resolve a per-op Privy authorization context. Invoked immediately * before each sign call. Return `null` (or omit) for unauthenticated * / non-Privy signing contexts. */ getOpContext?: () => OpContext | null | Promise; }; declare function createWalletKitAccount(client: WalletKitClient, wallet: Wallet, opts?: CreateWalletKitAccountOptions): LocalAccount; export { type ControlProofClaims, type CreateWalletKitAccountOptions, DEPLOY_ERC1167_PROXIES_ABI, type Lsp23DeploymentParams, buildControlProof, buildControlProofMessage, createWalletKitAccount, deriveLsp23ProxyAddress, encodeDeploymentCalldata, predictProfileAddress };