import { UnsignedTransaction } from "ethers/lib/utils"; import { LitUnsignedTransaction, LitERC20SwapParams, GasConfig, UTXO, LitYachtSdkParams } from "./@types/yacht-lit-sdk"; import * as bitcoin from "bitcoinjs-lib"; export declare class YachtLitSdk { private pkpContract; private signer; private litClient; private btcTestNet; private btcApiEndpoint; /** * @constructor * Instantiates an instance of the Yacht atomic swap SDK powered by Lit Protocol. If you want to mint a PKP, then you will need to attach an ethers Wallet with a Polygon Mumbai provider. For generating Lit Action code and executing Lit Actions, you do not need a signer * @param signer - The wallet that will be used to mint a PKP and generate auth sigs * @param pkpContractAddress - The address of the PKP NFT contract - defaults to the Mumbai testnet address * @param btcTestNet - Whether or not to use the Bitcoin testnet - defaults to false * @param btcApiEndpoint - The endpoint to use for the Bitcoin API - defaults to blockstream.info * @example * import { YachtLitSdk } from "yacht-lit-sdk"; * import { Wallet, providers } from "ethers"; * * const wallet = new Wallet( * YOUR_PRIVATE_KEY, * new providers.JsonRpcProvider(YOUR_MUMBAI_PROVIDER_URL), * ); * const sdk = new YachtLitSdk({ signer: wallet }); * */ constructor({ signer, pkpContractAddress, btcTestNet, btcApiEndpoint, }: LitYachtSdkParams); /** * Converts an Ethereum public key to a Bitcoin address * @param {string} ethKey - Ethereum public key (compressed or uncompressed) * @returns {string} Bitcoin address * @example * const btcAddress = generateBtcAddress("0x043fd854ac22b8c80eadd4d8354ab8e74325265a065e566d82a21d578da4ef4d7af05d27e935d38ed28d5fda657e46a0dc4bab62960b4ad586b9c22d77f786789a"); */ generateBtcAddress(ethKey: string): string; /** * Gets first unspent bitcoin UTXO for an address * @param {string} address - Bitcoin address * @returns {UTXO} UTXO * @example * const utxo = await getUtxoByAddress("1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T"); */ getUtxoByAddress(address: string): Promise; private prepareTransactionForSignature; private signBitcoinWithLitAction; /** * Signs first UTXO for a PKP address * @param {string} pkpPublicKey - PKP public key * @param {number} fee - Fee per vbyte * @param {string} recipientAddress - Bitcoin address to send to * @returns {bitcoin.Transaction} Signed transaction * @example * const signedTransaction = sdk.signFirstBtcUtxo({ * pkpPublicKey: "0x043fd854ac22b8c80eadd4d8354ab8e74325265a065e566d82a21d578da4ef4d7af05d27e935d38ed28d5fda657e46a0dc4bab62960b4ad586b9c22d77f786789a", * fee: 24, * recipientAddress: "1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T", * }) */ signFirstBtcUtxo({ pkpPublicKey, fee, recipientAddress, }: { pkpPublicKey: string; fee: number; recipientAddress: string; }): Promise; /** * Broadcasts a signed transaction to the Bitcoin network * @param {bitcoin.Transaction} transaction - Signed transaction * @returns {Promise} Transaction ID * @example * const signedTransaction = sdk.signFirstBtcUtxo({ * pkpPublicKey: "0x043fd854ac22b8c80eadd4d8354ab8e74325265a065e566d82a21d578da4ef4d7af05d27e935d38ed28d5fda657e46a0dc4bab62960b4ad586b9c22d77f786789a", * fee: 24, * recipientAddress: "1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T", * }) * const txId = await sdk.broadcastBtcTransaction(signedTransaction) */ broadcastBtcTransaction(transaction: bitcoin.Transaction): Promise; private safeParseJSON; private connect; /** * Generates the Lit Action code that will be uploaded to IPFS and manages the logic for the cross chain atomic swap * @param {LitERC20SwapParams} chainAParams - Parameters for the swap on Chain A * @param {LitERC20SwapParams} chainBParams - Parameters for the swap on Chain B * @param originTime - Only used for testing. Leave blank * @returns {string} Lit Action code */ createERC20SwapLitAction(chainAParams: LitERC20SwapParams, chainBParams: LitERC20SwapParams, originTime?: number): string; private generateERC20SwapCondition; /** * Utility function for generating an unsigned ERC20 transaction. * @param transactionParams * @returns */ generateUnsignedERC20Transaction(transactionParams: { counterPartyAddress: string; tokenAddress: string; chain: string; amount: string; decimals: number; from?: string; nonce?: number; }): LitUnsignedTransaction; /** * * @param {string} code - The Lit Action code to be uploaded to IPFS * @returns {string} The IPFS CID to locate your record */ uploadToIPFS(code: string): Promise; /** * * @param code - The Lit Action code to be hashed * @returns The IPFS CID */ getIPFSHash(code: string): Promise; /** * Mints a PKP NFT on the Polygon Mumbai network using the provided signer * @returns {Promise<{tokenId: string; publicKey: string; address: string}>} tokenId, publicKey, and address of the minted NFT * @throws Error if signer not set * @throws Error if signer provider not set * @example * const { tokenId, publicKey, address } = await litClient.mintPkp(); */ mintPkp(): Promise<{ tokenId: string; publicKey: string; address: string; }>; /** * Mints a PKP NFT on the Polygon Mumbai network, attaches the Lit Action code to the PKP, then burns the PKP so that the code attached to the PKP cannot be changed. * @param ipfsCID - The IPFS cid where your Lit Action code is stored * @returns PKP info with tokenID, publicKey, and address */ mintGrantBurnWithLitAction(ipfsCID: string): Promise<{ tokenId: string; publicKey: string; address: string; }>; private mintGrantBurn; private getPubKeyByPKPTokenId; /** * Generates an auth sig to be used for executing a Lit Action. All parameters are optional and do not need to be changed. * @param [chainId] * @param [uri] * @param [version] * @returns A valid auth sig for use with the Lit Protocol */ generateAuthSig(chainId?: number, uri?: string, version?: string): Promise; /** * Executes the Lit Action code associated with the given PKP. If the swap conditions have been met, then it will respond with the transactions that need to be signed. If not, it will respond with the string "Conditions for swap not met!" * @param {Object} LitActionParameters - Information needed to execute a Lit Action for a cross chain atomic swap * @param {string} LitActionParameters.pkpPublicKey - The public key of the PKP associated with the Lit Action code * @param {string} LitActionParameters.ipfsCID - The IPFS cid where the Lit Action code is located * @param {string} code - Arbitrary javascript to be run. Used for testing purposes and will not work if the PKP has been associated with a Lit Action and subsequently burned * @param authSig - Used for testing purposes. The function will automatically generate an auth sig if not provided * @param {code} * @returns */ runLitAction({ pkpPublicKey, ipfsCID, code, authSig, chainAGasConfig, chainBGasConfig, }: { pkpPublicKey: string; ipfsCID?: string; code?: string; authSig?: any; chainAGasConfig: GasConfig; chainBGasConfig: GasConfig; }): Promise; private generateTransferCallData; /** * Utility function that can sign a transaction with a given private key * @param tx - Transaction to be signed * @param privateKey - Private key which will sign the transaction * @returns A serialized transaction */ signTransaction(tx: UnsignedTransaction, privateKey: string): string; private generateERC20SwapLitActionCode; }