import { Buffer } from 'buffer'; import { BaseCoin, BaseNetwork, EthereumNetwork } from '@bitgo/statics'; import EthereumCommon from '@ethereumjs/common'; import BN from 'bn.js'; import { TransactionType } from '@bitgo/sdk-core'; import { ERC1155TransferData, ERC721TransferData, FlushTokensData, FlushERC7984ForwarderTokenData, NativeTransferData, SignatureParts, TokenTransferData, TransferData, TxData, WalletInitializationData, ForwarderInitializationData } from './iface'; import { KeyPair } from './keyPair'; /** * @param network */ export declare function getCommon(network: EthereumNetwork): EthereumCommon; /** * Signs the transaction using the appropriate algorithm * and the provided common for the blockchain * * @param {TxData} transactionData the transaction data to sign * @param {KeyPair} keyPair the signer's keypair * @param {EthereumCommon} customCommon the network's custom common * @returns {string} the transaction signed and encoded */ export declare function signInternal(transactionData: TxData, keyPair: KeyPair, customCommon: EthereumCommon): Promise; /** * Signs the transaction using the appropriate algorithm * * @param {TxData} transactionData the transaction data to sign * @param {KeyPair} keyPair the signer's keypair * @returns {string} the transaction signed and encoded */ export declare function sign(transactionData: TxData, keyPair: KeyPair): Promise; /** * Returns the contract method encoded data * * @param {string} to destination address * @param {number} value Amount to tranfer * @param {string} data aditional method call data * @param {number} expireTime expiration time for the transaction in seconds * @param {number} sequenceId sequence id * @param {string} signature signature of the call * @returns {string} -- the contract method encoded data */ export declare function sendMultiSigData(to: string, value: string, data: string, expireTime: number, sequenceId: number, signature: string): string; /** * Returns the contract method encoded data * * @param {string} to destination address * @param {number} value Amount to tranfer * @param {string} tokenContractAddress the address of the erc20 token contract * @param {number} expireTime expiration time for the transaction in seconds * @param {number} sequenceId sequence id * @param {string} signature signature of the call * @returns {string} -- the contract method encoded data */ export declare function sendMultiSigTokenData(to: string, value: string, tokenContractAddress: string, expireTime: number, sequenceId: number, signature: string): string; /** * Get the data required to make a flush tokens contract call * * @param forwarderAddress The forwarder address to flush * @param tokenAddress The token address to flush from */ export declare function flushTokensData(forwarderAddress: string, tokenAddress: string, forwarderVersion: number): string; /** * Get the data required to make a flush native coins contract call */ export declare function flushCoinsData(): string; /** * Get the data required to make a flush ERC721 tokens contract call * @param forwarderAddress - The forwarder address (for v0-v3) * @param tokenAddress - The ERC721 token contract address * @param tokenId - The token ID to flush * @param forwarderVersion - The forwarder version */ export declare function flushERC721TokensData(forwarderAddress: string, tokenAddress: string, tokenId: string, forwarderVersion: number): string; /** * Decode the given ABI-encoded flush ERC721 tokens data * @param data The data to decode * @param to The to address (contract address for v4+) * @returns parsed flush data with forwarderAddress, tokenAddress, tokenId and forwarderVersion */ export declare function decodeFlushERC721TokensData(data: string, to?: string): { forwarderAddress: string; tokenAddress: string; tokenId: string; forwarderVersion?: number; }; /** * Get the data required to make a flush ERC1155 tokens contract call * @param forwarderAddress - The forwarder address (for v0-v3) * @param tokenAddress - The ERC1155 token contract address * @param tokenId - The token ID to flush * @param forwarderVersion - The forwarder version */ export declare function flushERC1155TokensData(forwarderAddress: string, tokenAddress: string, tokenId: string, forwarderVersion: number): string; /** * Decode the given ABI-encoded flush ERC1155 tokens data * @param data The data to decode * @param to The to address (contract address for v4+) * @returns parsed flush data with forwarderAddress, tokenAddress, tokenId and forwarderVersion */ export declare function decodeFlushERC1155TokensData(data: string, to?: string): { forwarderAddress: string; tokenAddress: string; tokenId: string; forwarderVersion?: number; }; /** * Returns the create forwarder method calling data * * @returns {string} - the createForwarder method encoded */ export declare function getAddressInitializationData(): string; /** * Returns whether or not the string is a valid Eth address * * @param {string} address - the tx hash to validate * @returns {boolean} - the validation result */ export declare function isValidEthAddress(address: string): boolean; /** * Returns whether or not the string is a valid amount number * * @param {string} amount - the string to validate * @returns {boolean} - the validation result */ export declare function isValidAmount(amount: string): boolean; /** * Returns the smart contract encoded data * * @param {string} data The wallet creation data to decode * @returns {string[]} - The list of signer addresses */ export declare function decodeWalletCreationData(data: string): WalletInitializationData; /** * Decode the given ABI-encoded transfer data and return parsed fields * * @param data The data to decode * @param isFirstSigner whether transaction is being built for a first signer * @returns parsed transfer data */ export declare function decodeTransferData(data: string, isFirstSigner?: boolean): TransferData; /** * Decode the given ABI-encoded transfer data for the sendMultisigToken function and return parsed fields * * @param data The data to decode * @param isFirstSigner whether transaction is being built for a first signer * @returns parsed token transfer data */ export declare function decodeTokenTransferData(data: string, isFirstSigner?: boolean): TokenTransferData; export declare function decodeERC721TransferData(data: string): ERC721TransferData; export declare function decodeERC1155TransferData(data: string): ERC1155TransferData; /** * Decode the given ABI-encoded transfer data for the sendMultisig function and return parsed fields * * @param data The data to decode * @param isFirstSigner whether transaction is being built for a first signer * @returns parsed transfer data */ export declare function decodeNativeTransferData(data: string, isFirstSigner?: boolean): NativeTransferData; /** * Decode the given ABI-encoded flush tokens data and return parsed fields * * @param data The data to decode * @param to Optional to parameter of tx * @returns parsed transfer data */ export declare function decodeFlushTokensData(data: string, to?: string): FlushTokensData; export interface ConfidentialTransferData { toAddress: string; tokenContractAddress: string; encryptedHandle: string; inputProof: string; expireTime: string; sequenceId: string; signature: string; } /** * Decode ABI-encoded confidential transfer data (sendMultiSig wrapping confidentialTransfer) * * @param data The full calldata hex string * @returns parsed confidential transfer fields */ export declare function decodeConfidentialTransferData(data: string): ConfidentialTransferData; /** * Decode a FlushERC7984ForwarderToken transaction's calldata into its component parts. * * @param data The full calldata hex string (callFromParent wrapping confidentialTransfer) * @param to The `to` field of the transaction (equals the forwarder address for V4) * @returns Decoded fields including forwarderAddress, tokenContractAddress, parentAddress, encryptedHandle */ export declare function decodeFlushERC7984ForwarderTokenData(data: string, to: string): FlushERC7984ForwarderTokenData; /** * Classify the given transaction data based as a transaction type. * ETH transactions are defined by the first 8 bytes of the transaction data, also known as the method id * * @param {string} data The data to classify the transaction with * @returns {TransactionType} The classified transaction type */ export declare function classifyTransaction(data: string): TransactionType; /** * * @param {number} num number to be converted to hex * @returns {string} the hex number */ export declare function numberToHexString(num: number): string; /** * * @param {string} hex The hex string to be converted * @returns {number} the resulting number */ export declare function hexStringToNumber(hex: string): number; /** * Generates an address of the forwarder address to be deployed * * @param {string} contractAddress the address which is creating this new address * @param {number} contractCounter the nonce of the contract address * @returns {string} the calculated forwarder contract address */ export declare function calculateForwarderAddress(contractAddress: string, contractCounter: number): string; /** * Calculate the forwarder v1 address that will be generated if `creatorAddress` creates it with salt `salt` * and initcode `inicode using the create2 opcode * @param {string} creatorAddress The address that is sending the tx to create a new address, hex string * @param {string} salt The salt to create the address with using create2, hex string * @param {string} initcode The initcode that will be deployed to the address, hex string * @return {string} The calculated address */ export declare function calculateForwarderV1Address(creatorAddress: string, salt: string, initcode: string): string; /** * Take the implementation address for the proxy contract, and get the binary initcode for the associated proxy * @param {string} implementationAddress The address of the implementation contract for the proxy * @return {string} Binary hex string of the proxy */ export declare function getProxyInitcode(implementationAddress: string): string; /** * Convert the given signature parts to a string representation * * @param {SignatureParts} sig The signature to convert to string * @returns {string} String representation of the signature */ export declare function toStringSig(sig: SignatureParts): string; /** * Return whether or not the given tx data has a signature * * @param {TxData} txData The transaction data to check for signature * @returns {boolean} true if the tx has a signature, else false */ export declare function hasSignature(txData: TxData): boolean; type RecursiveBufferOrString = string | Buffer | BN | RecursiveBufferOrString[]; /** * Get the raw data decoded for some types * * @param {string[]} types ABI types definition * @param {Buffer} serializedArgs encoded args * @returns {Buffer[]} the decoded raw */ export declare function getRawDecoded(types: string[], serializedArgs: Buffer): RecursiveBufferOrString[]; /** * Get the buffered bytecode from rawData using a methodId as delimiter * * @param {string} methodId the hex encoded method Id * @param {string} rawData the hex encoded raw data * @returns {Buffer} data buffered bytecode */ export declare function getBufferedByteCode(methodId: string, rawData: string): Buffer; /** * Get the statics coin object matching a given contract address if it exists * * @param tokenContractAddress The contract address to match against * @param network - the coin network * @param family - the coin family * @returns statics BaseCoin object for the matching token */ export declare function getToken(tokenContractAddress: string, network: BaseNetwork, family: string): Readonly | undefined; /** * Returns the create wallet method calling data for v1 wallets * * @param {string[]} walletOwners - wallet owner addresses for wallet initialization transactions * @param {string} salt - The salt for wallet initialization transactions * @returns {string} - the createWallet method encoded */ export declare function getV1WalletInitializationData(walletOwners: string[], salt: string): string; /** * Returns the create address method calling data for v1, v2, v4 forwarders * * @param {string} baseAddress - The address of the wallet contract * @param {string} salt - The salt for address initialization transactions * @param {string} feeAddress - The fee address for the enterprise * @returns {string} - the createForwarder method encoded */ export declare function getV1AddressInitializationData(baseAddress: string, salt: string, feeAddress?: string): string; /** * Returns the create address method calling data for all forwarder versions * * @param {number} forwarderVersion - The version of the forwarder to create * @param {string} baseAddress - The address of the wallet contract * @param {string} salt - The salt for address initialization transactions * @param {string} feeAddress - The fee address for the enterprise * @returns {string} - the createForwarder method encoded * */ export declare function getAddressInitDataAllForwarderVersions(forwarderVersion: number, baseAddress: string, salt: string, feeAddress?: string): string; /** * Returns the createForwarderTypes and createForwarderParams for all forwarder versions * * @param {string} baseAddress - The address of the wallet contract * @param {Buffer} saltBuffer - The salt for address initialization transaction * @param {string} feeAddress - The fee address for the enterprise * @returns {createForwarderParams: (string | Buffer)[], createForwarderTypes: string[]} */ export declare function getCreateForwarderParamsAndTypes(baseAddress: string, saltBuffer: Buffer, feeAddress?: string): { createForwarderParams: (string | Buffer)[]; createForwarderTypes: string[]; }; /** * Decode the given ABI-encoded create forwarder data and return parsed fields * * @param data The data to decode * @returns parsed transfer data */ export declare function decodeForwarderCreationData(data: string): ForwarderInitializationData; /** * Make a query to explorer for information such as balance, token balance, solidity calls * @param {Object} query key-value pairs of parameters to append after /api * @param {string} token the API token to use for the request * @param {string} explorerUrl the URL of the explorer * @returns {Promise} response from explorer */ export declare function recoveryBlockchainExplorerQuery(query: Record, explorerUrl: string, token?: string): Promise>; /** * Default expire time for a contract call (1 week) * @returns {number} Time in seconds */ export declare function getDefaultExpireTime(): number; export {}; //# sourceMappingURL=utils.d.ts.map