import type { Commitment, TransactionInfo, UnspentCommitment } from "../nightfall/types"; import type { NightfallZkpKeys } from "../nightfall/types"; import type { RecipientNightfallData } from "libs/transactions/types"; import type { L2Token } from "libs/user/types"; import type { Balance, BalancePerTokenId, TransactionResponseData } from "./types"; /** * Creates a new Client * * @class Client */ declare class Client { /** * @property {string} apiUrl client address * @property {string} [apiTxUrl] client Transaction Worker address * @property {string} [apiBpUrl] client Block Proposed address */ apiUrl: string; apiTxUrl: string; apiBpUrl: string; /** * Client constructor * * @param {string} apiUrl client address */ constructor(apiUrl: string, apiTxUrl?: string, apiBpUrl?: string); /** * Make GET request to check that API is alive * * @method healthCheck * @throws {NightfallSdkError} Response other than 200 or bad response * @returns {Promise} Should resolve `true` if API is alive, else `false` */ healthCheck(): Promise; /** * Make GET request to get the address for a given contract name * * @async * @method getContractAddress * @param {string} contractName The name of the contract for which we need the address * @throws {NightfallSdkError} Bad response * @returns {Promise} Should resolve into Eth contract address */ getContractAddress(contractName: string): Promise; /** * Make POST request to derive a set of zero-knowledge proof keys * * @method generateZkpKeysFromMnemonic * @param {string} validMnemonic A valid bip39 mnemonic * @param {number} addressIndex Pass `0` to generate the first account * @throws {NightfallSdkError} Bad response * @returns {Promise} Should resolve into a set of keys if request is successful */ generateZkpKeysFromMnemonic(validMnemonic: string, addressIndex: number): Promise; /** * Make POST request to subscribe to incoming viewing keys * * @method subscribeToIncomingViewingKeys * @param {NightfallZkpKeys} zkpKeys A set of zero-knowledge proof keys * @throws {NightfallSdkError} Bad response * @returns {Promise} Should resolve `string` (success) if request is successful */ subscribeToIncomingViewingKeys(zkpKeys: NightfallZkpKeys): Promise; /** * Make POST request to create a deposit transaction (tx) * * @async * @method deposit * @param {*} token An instance of Token holding token data such as contract address * @param {NightfallZkpKeys} ownerZkpKeys Sender's set of zero-knowledge proof keys * @param {string} value The amount in Wei of the token to be deposited * @param {string} tokenId The tokenId of the token to be deposited * @param {string} fee Proposer payment in Wei for the tx in L2 * @param {string[] | []} providedCommitmentsFee Commitments to be used to pay fee * @param {string} [salt] Salt to be added to the newly created deposit commitment * @throws {NightfallSdkError} Bad response * @returns {Promise} */ deposit(token: any, ownerZkpKeys: NightfallZkpKeys, value: string, tokenId: string, fee: string, providedCommitmentsFee: string[] | [], salt?: string): Promise; /** * Make POST request to create a L2 tokenisation transaction (tx) * * @async * @method tokenise * @param {NightfallZkpKeys} ownerZkpKeys Sender's set of zero-knowledge proof keys * @param {string} tokenContractAddress Token address to be minted in L2 * @param {string} value The amount in Wei of the token to be minted * @param {string} tokenId The tokenId of the token to be minted * @param {string} fee Proposer payment in Wei for the tx in L2 * @param {string[] | []} providedCommitmentsFee Commitments to be used to pay fee * @param {string} [salt] Salt to be added to the newly created commitment * @throws {NightfallSdkError} Bad response * @returns {Promise} */ tokenise(ownerZkpKeys: NightfallZkpKeys, tokenContractAddress: string, value: string, tokenId: string, fee: string, providedCommitmentsFee: string[] | [], salt?: string): Promise; /** * Make POST request to create a transfer transaction (tx) * * @async * @method transfer * @param {*} token An instance of Token holding token data such as contract address * @param {NightfallZkpKeys} ownerZkpKeys Sender's set of zero-knowledge proof keys * @param {RecipientNightfallData} recipientNightfallData An object with [valueWei], [recipientCompressedZkpPublicKey] * @param {string} tokenId The tokenId of the token to be transferred * @param {string} fee Proposer payment in Wei for the tx in L2 * @param {boolean} isOffChain If true, tx will be sent to the proposer's API (handled off-chain) * @param {string[] | []} providedCommitments Commitments to be used for transfer * @param {string[] | []} providedCommitmentsFee Commitments to be used to pay fee * @param {string} [regulatorUrl] regulatorUrl * @param {string} [atomicHash] Hash of the atomic transaction * @param {string} [atomicTimestamp] Expiration timestamp of the atomic transaction * @param {string} [salt] salt for the commitment to generate * @throws {NightfallSdkError} No commitments found or bad response * @returns {Promise} */ transfer(token: any, ownerZkpKeys: NightfallZkpKeys, recipientNightfallData: RecipientNightfallData, tokenId: string, fee: string, isOffChain: boolean, providedCommitments: string[] | [], providedCommitmentsFee: string[] | [], regulatorUrl?: string, atomicHash?: string, atomicTimestamp?: number, salt?: string): Promise; /** * Make POST request to create a transformTransfer transaction (tx) * * @async * @method transformTransfer * @param {NightfallZkpKeys} ownerZkpKeys Sender's set of zero-knowledge proof keys * @param {recipientCompressedZkpPublicKey} recipientCompressedZkpPublicKey compressedZkpPublicKey of the recipient * @param {string} fee Proposer payment in Wei for the tx in L2 * @param {string[] | []} providedCommitments Commitments to be used for transformTransfer * @param {string[] | []} providedCommitmentsFee Commitments to be used to pay fee * @param {string} [regulatorUrl] regulatorUrl * @param {string} [atomicHash] Hash of the atomic transaction * @param {string} [atomicTimestamp] Expiration timestamp of the atomic transaction * @param {string} [salt] salt for the commitment to generate * @throws {NightfallSdkError} No commitments found or bad response * @returns {Promise} */ transformTransfer(ownerZkpKeys: NightfallZkpKeys, recipientCompressedZkpPublicKey: string, fee: string, inputTokens: L2Token[] | [], outputTokens: L2Token[] | [], providedCommitments?: string[] | [], providedCommitmentsFee?: string[] | [], regulatorUrl?: string, atomicHash?: string, atomicTimestamp?: number, salt?: string): Promise; /** * Make POST request to create a L2 burn transaction (tx) * * @async * @method burn * @param {NightfallZkpKeys} ownerZkpKeys Sender's set of zero-knowledge proof keys * @param {string} tokenContractAddress Token address of the token to be burnt in L2 * @param {string} value The amount in Wei of the token to be burnt * @param {string} tokenId The tokenId of the token to be burnt * @param {string} fee Proposer payment in Wei for the tx in L2 * @param {string[] | []} providedCommitments Commitments to be burnt * @param {string[] | []} providedCommitmentsFee Commitments to be used to pay fee * @throws {NightfallSdkError} Bad response * @returns {Promise} */ burn(ownerZkpKeys: NightfallZkpKeys, tokenContractAddress: string, value: string, tokenId: string, fee: string, providedCommitments: string[] | [], providedCommitmentsFee: string[] | []): Promise; /** * Make POST request to create a withdrawal transaction (tx) * * @async * @method withdraw * @param {*} token An instance of Token holding token data such as contract address * @param {NightfallZkpKeys} ownerZkpKeys Sender's set of zero-knowledge proof keys * @param {string} value The amount in Wei of the token to be withdrawn * @param {string} tokenId The tokenId of the token to be withdrawn * @param {string} fee Proposer payment in Wei for the tx in L2 * @param {boolean} isOffChain If true, tx will be sent to the proposer's API (handled off-chain) * @param {string[] | []} providedCommitments Commitments to be withdrawn * @param {string[] | []} providedCommitmentsFee Commitments to be used to pay fee * @throws {NightfallSdkError} Bad response * @returns {Promise} */ withdraw(token: any, ownerZkpKeys: NightfallZkpKeys, value: string, tokenId: string, fee: string, recipientEthAddress: string, isOffChain: boolean, providedCommitments: string[] | [], providedCommitmentsFee: string[] | []): Promise; /** * Make POST request to finalise a previously initiated withdrawal (tx) * * @async * @method finaliseWithdrawal * @param {string} withdrawTxHashL2 Tx hash in Layer2 of the previously initiated withdrawal * @throws {NightfallSdkError} Bad response * @returns {Promise} */ finaliseWithdrawal(withdrawTxHashL2: string): Promise; /** * Make GET request to get aggregated value for deposits that have not settled in L2 yet * * @async * @method getPendingDeposits * @param {NightfallZkpKeys} zkpKeys Sender's set of zero-knowledge proof keys * @param {string[]} tokenContractAddresses A list of token addresses * @throws {NightfallSdkError} Bad response * @returns {Promise} */ getPendingDeposits(zkpKeys: NightfallZkpKeys, tokenContractAddresses: string[]): Promise; /** * Make GET request to retrieve Nightfall Layer2 balance * * @async * @method getNightfallBalances * @param {NightfallZkpKeys} zkpKeys Sender's set of zero-knowledge proof keys * @param {string[]} tokenContractAddresses A list of token addresses * @throws {NightfallSdkError} Bad response * @returns {Promise>} */ getNightfallBalances(zkpKeys: NightfallZkpKeys, tokenContractAddresses: string[]): Promise>; /** * Make GET request to get aggregated value for transfers and withdrawals that have not settled in L2 yet * * @async * @method getPendingSpent * @param {NightfallZkpKeys} zkpKeys Sender's set of zero-knowledge proof keys * @param {string[]} tokenContractAddresses A list of token addresses * @throws {NightfallSdkError} Bad response * @returns {Promise} */ getPendingSpent(zkpKeys: NightfallZkpKeys, tokenContractAddresses: string[]): Promise; /** * Make GET request to get all unspent commitments filtered by Nightfall addresses and * commitment erc address * * @method getUnspentCommitments * @param {NightfallZkpKeys} zkpKeys Sender's set of zero-knowledge proof keys * @param {string[]} tokenContractAddresses A list of token addresses * @throws {NightfallSdkError} No compressedZkpPublicKey given or bad response * @returns {Promise>} */ getUnspentCommitments(zkpKeys: NightfallZkpKeys, tokenContractAddresses: string[]): Promise>; /** * Make POST request to get all commitments filtered by many Nightfall addresses * * @method getCommitmentsByCompressedZkpPublicKey * @param {string[]} listOfCompressedZkpPublicKey list of compressedZkpPublicKeys (Nightfall address) * @throws {NightfallSdkError} No compressedZkpPublicKey given or bad response * @returns {Promise} Should resolve into a list of all existing commitments if request is successful */ getCommitmentsByCompressedZkpPublicKey(listOfCompressedZkpPublicKey: string[]): Promise; /** * * Make POST request to import a list of commitments * * @async * @method saveCommitments * @param {Commitment[]} listOfCommitments Commitments to be saved in the database * @throws {NightfallSdkError} Bad response * @return {Promise} Should resolve `string` (successMessage) */ saveCommitments(listOfCommitments: Commitment[]): Promise; /** * Make GET request to get info about settled L2 transactions * * @async * @method getTransactionsInfo * @param {string[]} transactionHashes A list of L2 transacton hashes * @throws {NightfallSdkError} Bad response * @returns {Promise} */ getTransactionsInfo(transactionHashes: string[]): Promise; } export default Client;