UNPKG

@kaiachain/web3js-ext

Version:
92 lines (91 loc) 3.92 kB
import Eth from "web3-eth"; import { decodeLog, decodeParameter, decodeParameters, encodeFunctionCall, encodeFunctionSignature, encodeParameter, encodeParameters } from "web3-eth-abi"; import { encrypt, hashMessage, recover, recoverTransaction, sign, signTransaction, TxData, Transaction as LegacyTransaction, AccessListEIP2930Transaction, FeeMarketEIP1559Transaction, Wallet, Web3Account } from "web3-eth-accounts"; import { Contract } from "web3-eth-contract"; import { ENS } from "web3-eth-ens"; import { Iban } from "web3-eth-iban"; import { Personal } from "web3-eth-personal"; import { Net } from "web3-net"; import { KeyStore, Bytes, Transaction } from "web3-types"; import { KlaytnTypedTransaction } from "./accounts/klaytn_tx.js"; export interface KlaytnWeb3Account extends Web3Account { readonly address: string; readonly privateKey: string; readonly sign: (data: Record<string, unknown> | string) => { readonly messageHash: string; readonly r: string; readonly s: string; readonly v: string; readonly message?: string; readonly signature: string; }; readonly encrypt: (password: string, options?: Record<string, unknown>) => Promise<KeyStore>; readonly signTransaction: (tx: KlaytnTransaction | string) => Promise<{ readonly messageHash: string; readonly r: string; readonly s: string; readonly v: string; readonly rawTransaction: string; readonly transactionHash: string; }>; readonly signTransactionAsFeePayer: (tx: KlaytnTransaction | string) => Promise<{ readonly messageHash: string; readonly r: string; readonly s: string; readonly v: string; readonly rawTransaction: string; readonly transactionHash: string; }>; } export interface KlaytnWeb3EthInterface extends Eth { Contract: typeof Contract; Iban: typeof Iban; net: Net; ens: ENS; abi: { encodeEventSignature: typeof encodeFunctionSignature; encodeFunctionCall: typeof encodeFunctionCall; encodeFunctionSignature: typeof encodeFunctionSignature; encodeParameter: typeof encodeParameter; encodeParameters: typeof encodeParameters; decodeParameter: typeof decodeParameter; decodeParameters: typeof decodeParameters; decodeLog: typeof decodeLog; }; accounts: KlaytnAccountsInterface; personal: Personal; } export interface KlaytnAccountsInterface { recoverTransaction: typeof recoverTransaction; hashMessage: typeof hashMessage; sign: typeof sign; recover: typeof recover; encrypt: typeof encrypt; wallet: Wallet<KlaytnWeb3Account>; create: () => KlaytnWeb3Account; privateKeyToAccount: (privateKey: Uint8Array | string, address?: string) => KlaytnWeb3Account; decrypt: (keystore: string, password: string, options?: Record<string, unknown>) => Promise<KlaytnWeb3Account>; signTransaction: (transaction: KlaytnTransaction | string, privateKey: Bytes) => ReturnType<typeof signTransaction>; signTransactionAsFeePayer: (transaction: KlaytnTransaction | string, privateKey: Bytes) => ReturnType<typeof signTransaction>; decryptList: (keystore: string, password: string, options?: Record<string, unknown>) => Promise<KlaytnWeb3Account[]>; } export interface KlaytnTransaction extends Transaction { key?: any; feePayer?: string; txSignatures?: any; feePayerSignatures?: any; feeRatio?: number; } export interface KlaytnTxData extends TxData { from?: string; chainId?: bigint; key?: any; feePayer?: string; feePayer_v?: bigint; feePayer_r?: bigint; feePayer_s?: bigint; txSignatures?: any; feePayerSignatures?: any; feeRatio?: number; } export type TypedTransaction = LegacyTransaction | AccessListEIP2930Transaction | FeeMarketEIP1559Transaction | KlaytnTypedTransaction;