import { handler } from ".";
import { BaseCoreSDK } from "./../mixins/base-core-sdk";
export class NativeMetaTxMixin extends BaseCoreSDK {
    // Implementation
    async signNativeMetaTxApproveExchangeToken(exchangeToken, value, overrides = {}) {
        const user = await this._web3Lib.getSignerAddress();
        const baseArgs = {
            web3Lib: this._web3Lib,
            chainId: this._chainId,
            user,
            exchangeToken,
            spender: overrides.spender || this._protocolDiamond,
            value
        };
        if (overrides.returnTypedDataToSign) {
            return handler.signNativeMetaTxApproveExchangeToken({
                ...baseArgs,
                returnTypedDataToSign: true
            });
        }
        return handler.signNativeMetaTxApproveExchangeToken({
            ...baseArgs,
            returnTypedDataToSign: false
        });
    }
    /**
     * Relay a native meta transaction,
     * @param metaTxParams - Required params for meta transaction.
     * @param overrides - Optional overrides.
     * @returns Transaction response.
     */
    async relayNativeMetaTransaction(contractAddress, metaTxParams, overrides = {}) {
        const { metaTxApiId, metaTxApiKey, metaTxRelayerUrl } = this.assertAndGetMetaTxConfig({ ...overrides, contractAddress });
        return handler.relayNativeMetaTransaction({
            web3LibAdapter: this._web3Lib,
            contractAddress,
            chainId: this._chainId,
            metaTx: {
                config: {
                    relayerUrl: metaTxRelayerUrl,
                    apiId: metaTxApiId,
                    apiKey: metaTxApiKey
                },
                params: {
                    userAddress: overrides.userAddress || (await this._web3Lib.getSignerAddress()),
                    functionSignature: metaTxParams.functionSignature,
                    sigR: metaTxParams.sigR,
                    sigS: metaTxParams.sigS,
                    sigV: metaTxParams.sigV
                }
            }
        });
    }
    /**
     * Execute a signed native meta transaction directly on-chain (no Biconomy relayer).
     * The wallet backing the SDK pays the gas; pass `overrides.userAddress` when the
     * meta-tx signer differs from that wallet.
     * @param contractAddress - The token contract address.
     * @param metaTxParams - Required params for the native meta transaction.
     * @param overrides - Optional overrides.
     * @returns Transaction response.
     */
    async executeNativeMetaTransaction(contractAddress, metaTxParams, overrides = {}) {
        const userAddress = overrides.userAddress || (await this._web3Lib.getSignerAddress());
        return handler.executeNativeMetaTransaction({
            web3Lib: this._web3Lib,
            contractAddress,
            userAddress,
            functionSignature: metaTxParams.functionSignature,
            sigR: metaTxParams.sigR,
            sigS: metaTxParams.sigS,
            sigV: metaTxParams.sigV
        });
    }
}
//# sourceMappingURL=mixin.js.map