/// import { EventEmitter } from 'events'; import { ethers } from 'ethers'; import { Provider } from 'decentraland-connect'; import { ContractData } from 'decentraland-transactions'; import { ChainId } from '@dcl/schemas/dist/dapps/chain-id'; import { AddEthereumChainParameters, Wallet } from './types'; export declare const getTransactionsApiUrl: () => string; export declare const setTransactionsApiUrl: (url: string) => string; export declare function fetchManaBalance(chainId: ChainId, address: string): Promise; export declare function buildWallet(appChainId: ChainId): Promise; export declare function getTargetNetworkProvider(chainId: ChainId): Promise; export declare enum TransactionEventType { ERROR = "error", SUCCESS = "success" } export declare type TransactionEventData = { type: T; } & (T extends TransactionEventType.ERROR ? { error: Error; } : T extends TransactionEventType.SUCCESS ? { txHash: string; } : {}); export declare const transactionEvents: EventEmitter; /** * Sends a transaction either as a meta transaction or as a regular transaction. * - If the contract chain id differs from the current provider chain id, a meta transaction will be sent. * - If the contract chain id is the same as the current provider chain id, a regular transaction will be sent. * @param contract - The contract to send the transaction to. * @param contractMethodName - The name of the contract method to call. * @param contractMethodArgs - The arguments to pass to the contract method. */ export declare function sendTransaction(contract: ContractData, contractMethodName: string, ...contractArguments: any[]): Promise; /** * @deprecated * Sends a transaction either as a meta transaction or as a regular transaction. * - If the contract chain id differs from the current provider chain id, a meta transaction will be sent. * - If the contract chain id is the same as the current provider chain id, a regular transaction will be sent. * @param contract - The contract to send the transaction to. * @param getPopulatedTransaction - A function that returns a populated transaction. */ export declare function sendTransaction(contract: ContractData, getPopulatedTransaction: (populateTransaction: ethers.Contract['populateTransaction']) => Promise): Promise; export declare function getAddEthereumChainParameters(chainId: ChainId): AddEthereumChainParameters; /** * Obtains the chain id through a provider. * Different providers might return the chain id as a hex or a number. * This function abtracts the logic in order to always obtain the chain id as a number from any given provider. * @param provider - The provider used to obtain the chain id * @returns A number representing the chain id, Eg: 80001 for Mumbai, 137 for Matic Mainnet */ export declare function getProviderChainId(provider: Provider): Promise; /** * Change the provider's chain to a provided chain. * In case it returns an error that the chain does not exist, it will try to add it. * @param provider - The provider used to swith the chain * @param chainId - The chain id that is being changed * @returns A number representing the chain id */ export declare function switchProviderChainId(provider: Provider, chainId: ChainId): Promise;