import {Log, PastLogsOptions} from "web3-core"; import type Web3 from "web3"; import type {TransactionConfig, Eth} from "web3-eth"; import type {Utils} from "web3-utils"; import * as Buffer from "buffer"; declare module "web3js-quorum" { export default function Web3Quorum(web3: Web3, enclaveOptions: EnclaveOptions, isQuorum: boolean): IWeb3Quorum; export interface IWeb3Quorum extends Web3 { utils: IUtilsWeb3; ptm: IPtm priv: IPrivWeb3; eth: IEthWeb3; raft: IRaftWeb3; istanbul: IIstanbulWeb3; permission: IPermissionWeb3; } export interface EnclaveOptions { /** * absolute file path to the ipc of the transaction manager */ ipcPath: string /** * http url to the transaction manager */ privateUrl: string /** * TLS configuration for the transaction manager when using HTTPS in privateUrl * */ tlsSettings: TlsSettings } export interface TlsSettings { /** * client key buffer */ key: Buffer /** * client certificate buffer */ clcert: Buffer /** * CA certificate buffer */ cacert: Buffer allowInsecure: boolean } export interface IUtilsWeb3 extends Utils { /** * Generate a privacyGroupId */ generatePrivacyGroup(options: IPrivacyOptions): string /** * @function setPrivate */ setPrivate(rawTransaction: string): Buffer } export interface IPrivacyOptions { readonly privateFor: string[]; readonly privateFrom: string; } export interface IPtm { send(options: IPtmSend): Promise storeRaw(options: IPtmStoreRaw): Promise keys(): Promise partyInfoKeys(): Promise upCheck(): Promise } export interface IPtmSend extends IOptions { readonly privateFor: string; } export interface IPtmStoreRaw extends IOptions { } interface IOptions { readonly data: string; readonly privateFrom: string; } export interface IPrivWeb3 { call(privacyGroupId: string, call: TransactionConfig, blockNumber?: string): Promise debugGetStateRoot(privacyGroupId: string, blockNumber: string | number): Promise distributeRawTransaction(transaction: string): Promise; /** * Send the Raw transaction to the Besu node */ sendRawTransaction(transaction: string): Promise; getEeaTransactionCount(address: string, sender: string, recipients: string[]): Promise getFilterChanges(privacyGroupId: string, filterId: string): Promise getFilterLogs(privacyGroupId: string, filterId: string): Promise getLogs(privacyGroupId: string, filterOptions: PastLogsOptions): Promise getPrivacyPrecompileAddress(): Promise getPrivateTransaction(transaction: string): Promise getTransactionCount(address: string, privacyGroupId: string): Promise; /** * Get the private transaction Receipt. * @param {String} transactionHash 32-byte hash of a transaction */ getTransactionReceipt(transactionHash: string): Promise; getCode(privacyGroupId: string, address: string, blockNumber: string | number): Promise newFilter(privacyGroupId: string, filter: PastLogsOptions): Promise; uninstallFilter(privacyGroupId: string, filter: PastLogsOptions): Promise; /** * Creates an on chain privacy group */ createPrivacyGroup(options: ICreatePrivacyGroupOptions): Promise; /** * Returns with the deleted group's ID (same one that was passed in). */ deletePrivacyGroup(privacyGroupId: string): Promise; /** * Returns a list of privacy groups containing only the listed members. * For example, if the listed members are A and B, a privacy group * containing A, B, and C is not returned. */ findPrivacyGroup(members: string[]): Promise; subscribe(privacyGroupId: string, type: string, filter: Object): Promise; unsubscribe(privacyGroupId: string, subscriptionId: string): Promise; waitForTransactionReceipt(txHash: string, retries?: number, delay?: number): Promise generateAndDistributeRawTransaction(options: IDistributeRawTransaction): Promise generateAndSendRawTransaction(options: ISendRawTransaction): Promise subscribeWithPooling(privacyGroupId: string, filter: Object, callback: (error, result) => any): Promise } export interface IPrivacyGroup { readonly privacyGroupId: string; readonly type: PrivacyGroupType; readonly name: string; readonly description: string; readonly members: string[]; } export const enum PrivacyGroupType { LEGACY, ONCHAIN, PANTHEON } export interface ICreatePrivacyGroupOptions { readonly addresses: string[]; readonly name?: string; readonly description?: string; } interface IBasicPrivateTransaction { /** * Data, 20 bytes Address of the sender. */ readonly from: string; /** * Data, 20 bytes Address of the receiver, if sending ether, otherwise, null. */ readonly to: string; /** * Data, 32 bytes Tessera public key of the sender. */ readonly privateFrom: string; /** * or privacyGroupId Array or Data, 32 bytes Tessera public keys or privacy group ID of the recipients. */ readonly privateFor: string | string[]; } export interface IPrivateTransactionReceipt extends IBasicPrivateTransaction { /** * Data, 32 bytes Hash of block containing this transaction. */ readonly blockHash: string; /** * Quantity Block number of block containing this transaction. */ readonly blockNumber: number; /** * Data, 20 bytes Contract address created if a contract creation transaction, otherwise, null. */ readonly contractAddress: string; /** * Array Array of log objects generated by this private transaction. */ readonly logs: Array; /** * Data, 256 bytes Bloom filter for light clients to quickly retrieve related logs. */ readonly logsBloom: string; /** * Data, 32 bytes Hash of the private transaction. */ readonly transactionHash: string; /** * Quantity, Integer Index position of transaction in the block. */ readonly transactionIndex: number; /** * Quantity Either `0x1` (success) or `0x0` (failure). */ readonly status: string; /** * String ABI - encoded string that displays the reason for reverting the transaction.Only available if revert reason is enabled. */ readonly revertReason: string; /** * Data RLP - encoded return value of a contract call if a value returns, otherwise, null. */ readonly output: string; /** * Data, 32 bytes Hash of the privacy marker transaction. */ readonly commitmentHash: string; } export interface IPrivateTransactionObject extends IBasicPrivateTransaction { readonly gas: number; readonly gasPrice: number; readonly input: string; readonly nonce: number; readonly value: number; readonly v: number; readonly r: string; readonly s: string; readonly privacyGroupId: string; readonly restriction: string; } /** * @see https://besu.hyperledger.org/en/stable/Reference/API-Objects/#log-object */ export interface ILogObject { /** * Tag true if log removed because of a chain reorganization.false if a valid log. */ readonly removed: string; /** * Quantity, Integer Log index position in the block.null when log is pending. */ readonly logIndex: number; /** * Quantity, Integer Index position of the starting transaction for the log.null when log is pending. */ readonly transactionIndex: number; /** * Data, 32 bytes Hash of the starting transaction for the log.null when log is pending. */ readonly transactionHash: string; /** * Data, 32 bytes Hash of the block that includes the log.null when log is pending. */ readonly blockHash: string; /** * Quantity Number of block that includes the log.null when log is pending. */ readonly blockNumber: number; /** * Data, 20 bytes Address the log originated from. */ readonly address: string; /** * Data Non - indexed arguments of the log. */ readonly data: string; /** * Array of Data, 32 bytes each Event signature hash and 0 to 3 indexed log arguments. */ readonly topics: string[]; } export interface IDistributeRawTransaction { readonly privateKey: string; readonly privateFrom: string; readonly privateFor: string; readonly privacyGroupId: string; readonly nonce: string; readonly to: string; readonly data: string; } export interface ISendRawTransaction extends IDistributeRawTransaction { readonly gasLimit: string; readonly gasPrice: string; } export interface IEthWeb3 extends Eth { flexiblePrivacyGroup: IFlexiblePrivacyGroup sendRawPrivateTransaction(signed: string, privateData: IPrivateData): Promise fillTransaction(tx: ITransaction): Promise<{ raw: string, tx: IPrivateTransactionObject }> storageRoot(address: string, block?: string): Promise getQuorumPayload(id: string): Promise sendTransactionAsync(tx: ITransaction): Promise getContractPrivacyMetadata(contractAddress: string): Promise distributePrivateTransaction(privateTx: string, privateData: IDistributePrivateData): Promise getPrivacyPrecompileAddress(): Promise getPrivateTransactionByHash(hash: string): Promise getPrivateTransactionReceipt(hash: string): Promise getPSI(): Promise sendGoQuorumTransaction(tx: TransactionConfig): Promise } export interface IFlexiblePrivacyGroup { find(enclaveKeys: string[]): Promise getParticipants({privacyGroupId: string}): Promise create(options: ICreateFlexiblePrivacyGroup): Promise removeFrom(options: IRemoveFromFlexiblePrivacyGroup): Promise setLockState(options: ISetLockStateFlexiblePrivacyGroup): Promise addTo(options: ICreateFlexiblePrivacyGroup): Promise } export interface IBaseFlexiblePrivacyGroup { readonly privacyGroupId: string readonly privateKey: string readonly enclaveKey: string } export interface ICreateFlexiblePrivacyGroup extends IBaseFlexiblePrivacyGroup { readonly participants: string[] } export interface IRemoveFromFlexiblePrivacyGroup extends IBaseFlexiblePrivacyGroup { readonly participants: string } export interface ISetLockStateFlexiblePrivacyGroup extends IBaseFlexiblePrivacyGroup { readonly lock: boolean } export interface IPrivateData { readonly privacyFlag: PrivacyFlag; readonly privateFor: string[]; readonly mandatoryFor: string[]; } export interface IDistributePrivateData extends IPrivateData { readonly privateFrom: string[]; } export const enum PrivacyFlag { SP, PP, MPP, PSV } export interface ITransaction { readonly from: string; readonly to?: string; readonly value?: number; readonly data?: string; readonly privateFor?: string[]; } export interface IContractPrivacyMetadata { readonly creationTxHash: string; readonly privacyFlag: PrivacyFlag; readonly mandatoryFor: string[]; } export interface IRaftWeb3 { cluster(): Promise role(): Promise leader(): Promise addPeer(enodeId: string): Promise removePeer(raftId: number): Promise addLearner(enodeId: string): Promise promoteToPeer(raftId: number): Promise } export interface ICluster { readonly hostName: string; readonly nodeActive: boolean; readonly nodeId: string; readonly p2pPort: number; readonly raftId: string; readonly raftPort: number; readonly role: RaftRole; } export const enum RaftRole { Minter = "minter", Verifier = "verifier", Learner = "learner" } export interface IIstanbulWeb3 { discard(address: string): Promise propose(address: string, auth: boolean): Promise getValidatorsAtHash(blockHash: string): Promise getValidators(block: string | number): Promise candidates(): Promise<{[address: string]: boolean}> getSnapshot(block: string | number): Promise getSnapshotAtHash(blockHash: string): Promise nodeAddress(): Promise getSignersFromBlock(block: number): Promise getSignersFromBlockByHash(block: string): Promise status(startBlock: number, endBlock: number): Promise isValidator(block: number): Promise } export interface IPermissionWeb3 { orgList(): Promise acctList(): Promise nodeList(): Promise roleList(): Promise getOrgDetails(orgId: string): Promise addOrg(orgId: string, enodeId: string, accountId: string): Promise approveOrg(orgId: string, enodeId: string, accountId: string): Promise updateOrgStatus(orgId: string, action: number): Promise approveOrgStatus(orgId: string, action: number): Promise addSubOrg(parentOrgId: string, subOrgId: string, enodeId: string): Promise addNewRole(orgId: string, roleId: string, accountAccess: string, isVoter: boolean, isAdminRole: boolean): Promise removeRole(orgId: string, roleId: string): Promise addAccountToOrg(acctId: string, orgId: string, roleId: string): Promise changeAccountRole(acctId: string, orgId: string, roleId: string): Promise updateAccountStatus(orgId: string, acctId: string, action: string): Promise recoverBlackListedAccount(orgId: string, acctId: string): Promise approveBlackListedAccountRecovery(orgId: string, acctId: string): Promise assignAdminRole(orgId: string, acctId: string, roleId: string): Promise approveAdminRole(orgId: string, acctId: string): Promise addNode(orgId: string, enodeId: string): Promise updateNodeStatus(orgId: string, enodeId: string, action: string): Promise recoverBlackListedNode(orgId: string, enodeId: string): Promise approveBlackListedNodeRecovery(orgId: string, enodeId: string): Promise transactionAllowed(tx: TransactionConfig): Promise connectionAllowed(enodeId: string, ip: string, port: number): Promise } }