UNPKG

dp-contract-proxy-kit

Version:

Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.

168 lines (167 loc) 5.74 kB
import BigNumber from 'bignumber.js'; import { NetworksConfig, NormalizedNetworksConfig } from './config/networks'; import ContractManager from './contractManager'; import EthLibAdapter from './ethLibAdapters/EthLibAdapter'; import SafeAppsSdkConnector from './safeAppsSdkConnector'; import TransactionManager from './transactionManagers/TransactionManager'; import { Address } from './utils/basicTypes'; import { ExecOptions, OperationType, Transaction, TransactionResult } from './utils/transactions'; export interface CPKConfig { ethLibAdapter: EthLibAdapter; transactionManager?: TransactionManager; ownerAccount?: string; networks?: NetworksConfig; saltNonce?: string; isSafeApp?: boolean; } declare class CPK { #private; static Call: OperationType; static DelegateCall: OperationType; /** * Creates and initializes an instance of the CPK with the selected configuration parameters. * * @param opts - CPK configuration * @returns The CPK instance */ static create(opts?: CPKConfig): Promise<CPK>; /** * Creates a non-initialized instance of the CPK with the selected configuration parameters. * * @param opts - CPK configuration * @returns The CPK instance */ constructor(opts?: CPKConfig); /** * Initializes the CPK instance. */ init(): Promise<void>; /** * Checks if the Proxy contract is deployed or not. The deployment of the Proxy contract happens automatically when the first transaction is submitted. * * @returns TRUE when the Proxy contract is deployed */ isProxyDeployed(): Promise<boolean>; /** * Returns the address of the account connected to the CPK (Proxy contract owner). However, if the CPK is running as a Safe App or connected to a Safe, the Safe address will be returned. * * @returns The address of the account connected to the CPK */ getOwnerAccount(): Promise<Address | undefined>; /** * Returns the ETH balance of the Proxy contract. * * @returns The ETH balance of the Proxy contract */ getBalance(): Promise<BigNumber>; /** * Returns the ID of the connected network. * * @returns The ID of the connected network */ getNetworkId(): Promise<number | undefined>; /** * Returns the safeAppsSdkConnector used by the CPK. * * @returns The safeAppsSdkConnector used by the CPK */ get safeAppsSdkConnector(): SafeAppsSdkConnector | undefined; /** * Returns the contractManager used by the CPK. * * @returns The contractManager used by the CPK */ get contractManager(): ContractManager | undefined; /** * Returns the ethLibAdapter used by the CPK. * * @returns The ethLibAdapter used by the CPK */ get ethLibAdapter(): EthLibAdapter | undefined; /** * Returns a list of the contract addresses which drive the CPK per network by network ID. * * @returns The list of the contract addresses which drive the CPK per network by network ID */ get networks(): NormalizedNetworksConfig; /** * Checks if the CPK is connected to a Safe account or not. * * @returns TRUE if the CPK is connected to a Safe account */ get isConnectedToSafe(): boolean; /** * Returns the salt nonce used to deploy the Proxy Contract. * * @returns The salt nonce used to deploy the Proxy Contract */ get saltNonce(): string; /** * Returns the address of the Proxy contract. * * @returns The address of the Proxy contract */ get address(): Address | undefined; /** * Sets the ethLibAdapter used by the CPK. */ setEthLibAdapter(ethLibAdapter: EthLibAdapter): void; /** * Sets the transactionManager used by the CPK. */ setTransactionManager(transactionManager: TransactionManager): void; /** * Sets the network configuration used by the CPK. */ setNetworks(networks: NetworksConfig): void; /** * Returns the encoding of a list of transactions. * * @param transactions - The transaction list * @returns The encoding of a list of transactions */ encodeMultiSendCallData(transactions: Transaction[]): string; /** * Executes a list of transactions. * * @param transactions - The transaction list to execute * @param options - Execution configuration options * @returns The transaction response */ execTransactions(transactions: Transaction[], options?: ExecOptions): Promise<TransactionResult>; /** * Returns the Master Copy contract version. * * @returns The Master Copy contract version */ getContractVersion(): Promise<string>; /** * Returns the list of addresses of all the enabled Safe modules. * * @returns The list of addresses of all the enabled Safe modules */ getModules(): Promise<Address[]>; /** * Checks if a specific Safe module is enabled or not. * * @param moduleAddress - The desired module address * @returns TRUE if the module is enabled */ isModuleEnabled(moduleAddress: Address): Promise<boolean>; /** * Enables a Safe module * * @param moduleAddress - The desired module address * @returns The transaction response */ enableModule(moduleAddress: Address): Promise<TransactionResult>; /** * Disables a Safe module * * @param moduleAddress - The desired module address * @returns The transaction response */ disableModule(moduleAddress: Address): Promise<TransactionResult>; private getSafeExecTxParams; } export default CPK;