import { BigNumber } from 'bignumber.js'; import { HexString, NetworkId, Paginate, SignTxSummary } from './common'; type TODO = any; export type Int32 = BigNumber & { __type: 'Int32'; }; export type UInt = BigNumber & { __type: 'Uint'; }; export type Coin = BigNumber & { __type: 'Coin'; }; export type Hash28 = HexString & { __hash: 'Hash28'; }; export type Hash32 = HexString & { __hash: 'Hash32'; }; export type TxHash = Hash32 & { __type: 'TxHash'; }; export type Address = HexString & { __type: 'Address'; }; export type AddressKeyHash = Hash28 & { __type: 'AddrKeyHash'; }; export type PolicyId = HexString & { __type: 'PolicyId'; }; export type AssetName = HexString & { __type: 'AssetName'; }; export type Asset = { policyId: PolicyId; assetName: AssetName; }; export type Token = Asset & { quantity: BigNumber; }; export declare const AdaPolicyId: PolicyId; export declare const AdaAssetName: AssetName; export type Value = Map>; export type MintValue = Map>; export type TxInput = { txHash: TxHash; index: UInt; }; export declare enum TxOutputType { LEGACY = 0, POST_ALONZO = 1 } export declare enum TxOutputDatumType { HASH = 0, INLINED_DATUM = 1 } export declare enum TxScriptType { NATIVE = 0, PLUTUS_V1 = 1, PLUTUS_V2 = 2 } export type TxOutputLegacy = { type: TxOutputType.LEGACY; address: Address; value: Value; datumHash?: Hash32; }; export type TxScriptRef = { type: TxScriptType.NATIVE; script: NativeScript; } | { type: TxScriptType.PLUTUS_V1 | TxScriptType.PLUTUS_V2; script: PlutusScript; }; export type TxOutputPostAlonzo = { type: TxOutputType.POST_ALONZO; address: Address; value: Value; datumOption?: { type: TxOutputDatumType.HASH; datumHash: Hash32; } | { type: TxOutputDatumType.INLINED_DATUM; datum: PlutusDatum; }; scriptRef?: TxScriptRef; }; export type TxOutput = TxOutputLegacy | TxOutputPostAlonzo; export type TxUnspentOutput = { txInput: TxInput; txOutput: TxOutput; }; export type Certificate = TODO; export type Withdrawals = Map; export type ProtocolParamUpdate = TODO; export type Epoch = UInt & { __type: 'Epoch'; }; export type Update = [ProtocolParamUpdate, Epoch]; export type TxBody = { inputs: Set; referenceInputs?: Set; outputs: TxOutput[]; fee: Coin; ttl?: UInt; certificates?: Certificate[]; withdrawals?: Withdrawals; update?: Update; auxiliaryDataHash?: Hash32; validityStart?: UInt; mint?: MintValue; scriptDataHash?: Hash32; collateralInputs?: Set; collateralOutput?: TxOutput; totalCollateral?: Coin; requiredSigners?: Set; networkId?: NetworkId; }; export type VKeyWitness = { publicKey: HexString; signature: HexString; }; export type NativeScript = TODO; export type PlutusScript = HexString & { __type: 'PlutusScript'; }; /** * Helper to represent raw bytes (e.g. when using addresses in plutus data) * to support js -> cbor, the bytes need to be differentiated * a simple HexString wouldn't be enough to differentiate the type for the encoder */ export type Bytes = { bytes: HexString; __typeBytes: true; }; /** * Corresponds to tagged data from plutus scripts * @param i represents the indexed structure * * The index is directly mapped to cbor tags in the binary format * i <0,7) -> cbor tag <121, 128) * i <7,128) -> cbor tag <1280, 1400) */ export interface PlutusDatumConstr { i: number; data: PlutusDatum[]; __typeConstr: true; } export interface PlutusSimpleDatum { data: PlutusDatum; __simpleDatum: true; } export type PlutusDatum = string | number | BigNumber | Bytes | Map | PlutusDatum[] | PlutusDatumConstr | PlutusSimpleDatum; export declare enum RedeemerTag { Spend = 0, Mint = 1, Cert = 2, Reward = 3 } export type ExUnits = { mem: UInt; cpu: UInt; }; export type Redeemer = { tag: RedeemerTag; index: UInt; data: PlutusDatum; exUnits: ExUnits; }; export type TxWitnessSet = { vKeyWitnesses?: VKeyWitness[]; nativeScripts?: NativeScript[]; plutusV1Scripts?: PlutusScript[]; plutusDatums?: PlutusDatum[]; redeemers?: Redeemer[]; plutusV2Scripts?: PlutusScript[]; }; type Metadata = Map | Metadata[] | number | string | Bytes; export type AuxiliaryData = Map; export type Transaction = { body: TxBody; witnessSet: TxWitnessSet; isValid: boolean; auxiliaryData?: AuxiliaryData; }; export type SignTxOptions = { /** * Used for multisig; defaults to false */ partialSign?: boolean; /** * Additional metadata to potentially show the user before signing the Tx. */ summary?: SignTxSummary; }; export type UtxoFilterOptions = { amount?: Value; paginate?: Paginate; /** * Skip collateral utxos in the listings. Some wallets already filter these out. * But they could still be spent in transactions and contribute to the balance. */ withoutCollateral?: boolean; /** * Some wallets experimentally support hiding away some of the utxos if they are pending. * They still contribute to the balance, but preferable should be not used in transactions, * as it would lead to potentially failed transactions. By default all locked txs * are included. */ withoutLocked?: boolean; }; export type DataSignature = { signature: HexString; key: HexString; }; /** * Follows the standard API from CIP-0030 */ export interface JsAPI { /** * Returns the network id of the currently connected account. * This result will stay the same unless the connected account has changed. * * @returns 0 - testnet; 1 - mainnet * @throws APIError */ getNetworkId(): Promise; /** * If `amount` is `undefined`, this shall return a list of all UTXOs * (unspent transaction outputs) controlled by the wallet. * If `amount` is not `undefined`, this request shall be limited to just the UTXOs * that are required to reach the combined ADA/multiasset value target specified * in `amount`, and if this cannot be attained, `undefined` shall be returned. * The results can be further paginated by `paginate` if it is not `undefined` or empty array. * * @param {UtxoFilterOptions} options * @returns undefined or array of utxos * * @throws APIError, PaginateError */ getUtxos(options?: UtxoFilterOptions): Promise; /** * 🚧 Experimental endpoint * * Returns a list of UTxOs that can be used as collaterals. Under normal circumstances only a single utxo * should be returned. Most wallets handle this utxo as a specific case that does not contribute * to the balance and the UTxO should be returned with the {@link getUtxos}, * unless {@link UtxoFilterOptions.withoutCollateral} is defined. * * âš ī¸ This is a slight incompatibility with the experimental APIs. Revisit when collateral handling * is standardized. * * @returns undefined or array of collateral utxos * * @throws APIError */ getCollateral(): Promise; /** * Returns the total balance available of the wallet. * This is the same as summing the results of `api.getUtxos()`, * but it is both useful to dApps and likely already maintained by the implementing * wallet in a more efficient manner so it has been included in the API as well. * * 🚧 Additional optional parameter was added to help the dapp * filter only the assets they are interested in. Inside wallets * with large amount of NFTs the actual balance result might be huge. * E.g. if the user was only interested in the balance of `policyA.tokenA` * they could query it as: * `getBalance(new Map(["policyA", new Map(["tokenA", 1])]))` or * `getBalance(objToMap( {"policyA": {"tokenA", 1}} ))` * which would return a map: Map { policyA => Map { tokenA => 131455 } } * * A second example, the user would like to get all tokens for a given policyId: * `getBalance(objToMap( {"policyA": {}}))` * would return: Map { policyA => Map { tokenA => 131455, tokenB => 4, tokenC => 25 } } * * @param partialValue a partial to define which balances should the return value contain * @returns the full balance * * @throws APIError */ getBalance(partialValue?: Value): Promise; /** * Returns a list of all used (included in some on-chain transaction) addresses * controlled by the wallet. The results can be further paginated by `paginate` * if the return value is not empty or it is not `undefined`. * * @param {Paginate} paginate * @return undefined or array of hex-encoded addresses * âš ī¸ these shouldn't be Bech32 encoded addresses * * @throws APIError */ getUsedAddresses(paginate?: Paginate): Promise; /** * Returns a list of unused addresses controlled by the wallet. * * @return array of hex-encoded addresses * âš ī¸ these shouldn't be Bech32 encoded addresses * * @throws APIError */ getUnusedAddresses(): Promise; /** * Returns an address owned by the wallet that should be used as a change address * to return leftover assets during transaction creation back to the connected wallet. * â„šī¸ This can be used as a generic receive address as well. * * @returns a hex-encoded address * âš ī¸ this shouldn't be Bech32 encoded address * * @throws APIError */ getChangeAddress(): Promise
; /** * Returns the reward addresses owned by the wallet. * This can return multiple addresses e.g. CIP-0018. * * @returns array of hex-encoded reward addresses * âš ī¸ these shouldn't be Bech32 encoded addresses * * @throws APIError */ getRewardAddresses(): Promise; /** * Requests that a user sign the unsigned portions of the supplied transaction. * The wallet should ask the user for permission, and if given, try to sign the supplied body * and return a signed transaction. If `partialSign` is true, the wallet only * tries to sign what it can. If `partialSign` is false and the wallet could not sign * the entire transaction, `TxSignError` shall be returned with the `ProofGeneration` code. * Likewise if the user declined in either case it shall return the `UserDeclined` code. * Only the portions of the witness set that were signed as a result of this call are * returned to encourage dApps to verify the contents returned by this endpoint * while building the final transaction. * * @param {Transaction} tx the data for reference that matches the txHash * @param {TxHash} txHash the transaction hash to be signed * @param {SignTxOptions} options * @returns partial transaction witness set, only the required signatures parts * @throws APIError, TxSignError */ signTx(tx: Transaction, txHash: TxHash, options?: SignTxOptions): Promise; /** * This endpoint utilizes the [CIP-0008 signing spec](https://github.com/cardano-foundation/CIPs/blob/master/CIP-0008/README.md) * for standardization/safety reasons. It allows the dApp to request * the user to sign data conforming to said spec. The user's consent should be requested * and the details of `sig_structure` shown to them in an informative way. * Please refer to the CIP-0008 spec for details on how to construct the sig structure. * * @param addr hex-encoded address âš ī¸ not a Bech32 encoded address * @param data hex-encoded data to sign * @return object with hex-encoded signature and public key * * @throws APIError, DataSignError */ signData(address: Address, data: HexString): Promise; /** * As wallets should already have this ability, we allow dApps to request that a transaction * be sent through it. If the wallet accepts the transaction and tries to send it, it shall * return the transaction id for the dApp to track. The wallet is free to return the `TxSendError` * with code `Refused` if they do not wish to send it, or `Failure` if there was an error * in sending it (e.g. preliminary checks failed on signatures). * * @param tx signed transaction * @returns hex-encoded 32-bit length hash of the transactions * * @throws APIError, TxSendError */ submitTx(tx: Transaction): Promise; /** * Same as {@link submitTx} with the already cborized transaction * * @param tx hex-encoded cbor transaction * @param txHash transaction hash * @returns the transaction hash if successfully submitted * * @throws APIError, TxSendError */ submitRawTx(tx: HexString, txHash: TxHash): Promise; } export {}; //# sourceMappingURL=jsApi.d.ts.map