|
| 1 | +// cardano-api.d.ts |
| 2 | + |
| 3 | +export default initialize; |
| 4 | + |
| 5 | +/** |
| 6 | + * Initializes the Cardano API. |
| 7 | + * @returns A promise that resolves to the main `CardanoAPI` object. |
| 8 | + */ |
| 9 | +declare function initialize(): Promise<CardanoAPI>; |
| 10 | + |
| 11 | +/** |
| 12 | + * Represents an unsigned transaction. |
| 13 | + */ |
| 14 | +declare interface UnsignedTx { |
| 15 | + /** |
| 16 | + * The type of the object, used for identification (the "UnsignedTx" string). |
| 17 | + */ |
| 18 | + objectType: string; |
| 19 | + |
| 20 | + /** |
| 21 | + * Adds a simple transaction input to the transaction. |
| 22 | + * @param txId The transaction ID of the input UTxO. |
| 23 | + * @param txIx The index of the input within the UTxO. |
| 24 | + * @returns The `UnsignedTx` object with the added input. |
| 25 | + */ |
| 26 | + addTxInput(txId: string, txIx: number): UnsignedTx; |
| 27 | + |
| 28 | + /** |
| 29 | + * Adds a simple transaction output to the transaction. |
| 30 | + * @param destAddr The destination address. |
| 31 | + * @param lovelaceAmount The amount in lovelace to output. |
| 32 | + * @returns The `UnsignedTx` object with the added output. |
| 33 | + */ |
| 34 | + addSimpleTxOut(destAddr: string, lovelaceAmount: bigint): UnsignedTx; |
| 35 | + |
| 36 | + /** |
| 37 | + * Sets the fee for the transaction. |
| 38 | + * @param lovelaceAmount The fee amount in lovelace. |
| 39 | + * @returns The `UnsignedTx` object with the set fee. |
| 40 | + */ |
| 41 | + setFee(lovelaceAmount: bigint): UnsignedTx; |
| 42 | + |
| 43 | + /** |
| 44 | + * Estimates the minimum fee for the transaction. |
| 45 | + * @param protocolParams The protocol parameters. |
| 46 | + * @param numExtraKeyWitnesses The number of extra key witnesses (in addition to the ones already added). |
| 47 | + * @param numExtraByronKeyWitnesses The number of extra Byron key witnesses. |
| 48 | + * @param totalRefScriptSize The total size of reference scripts in bytes. |
| 49 | + * @returns A promise that resolves to the estimated minimum fee in lovelace. |
| 50 | + */ |
| 51 | + estimateMinFee(protocolParams: any, numExtraKeyWitnesses: number, numExtraByronKeyWitnesses: number, totalRefScriptSize: number): Promise<bigint>; |
| 52 | + |
| 53 | + /** |
| 54 | + * Signs the transaction with a payment key. |
| 55 | + * @param signingKey The signing key to witness the transaction. |
| 56 | + * @returns A promise that resolves to a `SignedTx` object. |
| 57 | + */ |
| 58 | + signWithPaymentKey(signingKey: string): Promise<SignedTx>; |
| 59 | +} |
| 60 | + |
| 61 | +/** |
| 62 | + * Represents a signed transaction. |
| 63 | + */ |
| 64 | +declare interface SignedTx { |
| 65 | + /** |
| 66 | + * The type of the object, used for identification (the "SignedTx" string). |
| 67 | + */ |
| 68 | + objectType: string; |
| 69 | + |
| 70 | + /** |
| 71 | + * Adds an extra signature to the transaction with a payment key. |
| 72 | + * @param signingKey The signing key to witness the transaction. |
| 73 | + * @returns The `SignedTx` object with the additional signature. |
| 74 | + */ |
| 75 | + alsoSignWithPaymentKey(signingKey: string): SignedTx; |
| 76 | + |
| 77 | + /** |
| 78 | + * Converts the signed transaction to its CBOR representation. |
| 79 | + * @returns A promise that resolves to the CBOR representation of the transaction as a hex string. |
| 80 | + */ |
| 81 | + txToCbor(): Promise<string>; |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * The main Cardano API object with static methods. |
| 86 | + */ |
| 87 | +declare interface CardanoAPI { |
| 88 | + /** |
| 89 | + * The type of the object, used for identification (the "CardanoAPI" string). |
| 90 | + */ |
| 91 | + objectType: string; |
| 92 | + |
| 93 | + /** |
| 94 | + * Creates a new Conway-era transaction. |
| 95 | + * @returns A promise that resolves to a new `UnsignedTx` object. |
| 96 | + */ |
| 97 | + newConwayTx(): Promise<UnsignedTx>; |
| 98 | +} |
0 commit comments