/** * ERC-8021 transaction attribution (Base Builder Codes). * * ERC-8021 appends an attribution suffix to transaction calldata. Contracts * decode their ABI-encoded arguments normally and ignore the trailing bytes, * while offchain indexers (e.g. base.dev analytics for Base Builder Codes) * read the suffix to attribute the transaction to the originating app. * * This is a leaf module: process-global state configured once via * {@link IAugustBase.attribution} in the SDK constructor and read by the * EVM write paths (the normalized-signer wrap in the EVM adapter and the * cross-chain vault `writeContract` calls). * * @module attribution */ /** * The 16-byte ERC-8021 suffix terminator. The last 16 bytes of an attributed * transaction's calldata are always this marker; parsers read backwards from * it to recover the schema ID and builder codes. */ export declare const ERC8021_MARKER = "80218021802180218021802180218021"; /** * ERC-8021 builder-code attribution and the SwapRouter origin code — independent; set either or both. * * @example * ```typescript * const sdk = new AugustSDK({ * appName: 'my-app', * providers: { 8453: 'https://...' }, * keys: { august: '...' }, * attribution: { builderCodes: ['bc_abc123'] }, * }); * ``` */ export interface IAttributionConfig { /** * Builder codes to embed in the suffix, e.g. from base.dev registration * (`bc_…`). ASCII strings of 1–64 characters each; the comma-joined list * must fit in 255 bytes (schema 0 length prefix is a single byte). Omit to * send no ERC-8021 suffix. */ builderCodes?: string[]; /** * EVM chain IDs to attribute. Omit to attribute writes on every EVM chain * (the suffix is inert on chains without an ERC-8021 indexer and costs * ~16 gas per non-zero byte). When set, gating is fail-closed: writes on * other chains — and writes whose chain ID cannot be determined — are sent * without the suffix. * * Over-attribution is not harmless. The suffix makes calldata longer than * the ABI encoding of the call, which breaks clear-signing on hardware * wallets: a Ledger rejects an over-long ERC-20 `approve` with * `EthAppCommandError: Invalid data 6a80`, so an unattributed chain that * receives the suffix anyway cannot be transacted on from a Ledger at all. */ chains?: number[]; /** * SwapRouter origin (referral / fee-sharing) code: the `bytes32` registered * via the router's `addOrigin`, as `0x` + 64 hex chars. Every Ethereum * mainnet SwapRouter deposit carries it unless the call passes its own * `originCode`; it is never sent on another chain. Omit to send the * all-zero sentinel (no origin fee). Unaffected by `chains`. An * unregistered code reverts with `InvalidOrigin` — check it with * `getOriginInfo` first. */ originCode?: `0x${string}`; /** * When `true`, a deposit route that would use the SwapRouter with an * `originCode` not registered there throws `AugustValidationError` before * any transaction, instead of falling back to the vault's native path. */ strictOrigin?: boolean; } /** * Build an ERC-8021 schema-0 attribution suffix from builder codes. * * Layout (appended to calldata, read back-to-front by parsers): * `ascii(codes.join(','))` ∥ codesLength (1 byte) ∥ schemaId `0x00` ∥ * 16-byte marker `0x80218021802180218021802180218021`. * * @param codes Builder codes as printable-ASCII strings (e.g. `bc_abc123`), * each 1–64 chars, no commas; the comma-joined list must be ≤ 255 bytes. * @returns `0x`-prefixed hex suffix ready to concatenate onto calldata. * @throws Error when `codes` is empty, a code contains a comma or * non-printable/non-ASCII characters, or the joined list exceeds 255 bytes. * @example * ```typescript * buildAttributionSuffix(['baseapp', 'morpho']); * // '0x626173656170702c6d6f7270686f0e0080218021802180218021802180218021' * ``` */ export declare function buildAttributionSuffix(codes: string[]): string; /** * Set (or clear) the process-global attribution config. * * Called unconditionally on every `AugustSDK` construction — an instance * that omits `attribution` passes `null` and RESETS the state, so a prior * instance's builder codes or origin code never leak into a later instance * in the same process (same semantics as `setPublicApiBaseUrl`). * * @param config Attribution config from the SDK constructor, or `null` to * disable attribution. * @throws Error when the config's builder codes fail validation — thrown * synchronously from the constructor so misconfiguration is caught at * init, not on the first write. * @throws {@link AugustValidationError} when `originCode` is not a 32-byte * hex string. */ export declare function setAttribution(config: IAttributionConfig | null): void; /** * Whether {@link IAttributionConfig.strictOrigin} is set on the SDK instance. * * @returns `true` when an unregistered origin code must fail a deposit. */ export declare function isStrictOrigin(): boolean; /** * The SwapRouter origin code configured on the SDK instance via * {@link IAttributionConfig.originCode}. * * @returns The `bytes32` code, or `null` when none is configured. */ export declare function getOriginCode(): `0x${string}` | null; /** * Whether attribution is configured at all, independent of any chain gate. * * Call sites that need to know whether to resolve a chain ID before asking * for the suffix use this; {@link getAttributionSuffix} applies the gate. * * @returns `true` when builder codes are configured. */ export declare function isAttributionEnabled(): boolean; /** * Return the active ERC-8021 suffix for a write on the given chain, or * `undefined` when attribution is off or the chain is not attributed. * * @param chainId EVM chain ID of the transaction, when the call site knows * it. When a `chains` restriction is configured, gating is fail-closed: an * omitted chain ID yields no suffix, since a suffix on an unattributed * chain buys nothing and breaks hardware-wallet clear-signing (see * {@link IAttributionConfig.chains}). * @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be * appended. */ export declare function getAttributionSuffix(chainId?: number): string | undefined; /** * Append the active attribution suffix to calldata. * * No-ops (returns `data` unchanged) when attribution is off, the chain is * not attributed (including an unknown chain under a `chains` restriction), * `data` is empty/absent (plain value transfers are never * attributed), or `data` already ends with the ERC-8021 marker (guards * against double-appending when an upstream layer — e.g. a wagmi config * `dataSuffix` — already attributed the transaction). * * @param data `0x`-prefixed calldata of the outgoing transaction. * @param chainId EVM chain ID of the transaction, when known. * @returns Calldata with the suffix appended, or the input unchanged. */ export declare function appendAttributionSuffix(data: string | undefined | null, chainId?: number): string | undefined | null;