|
1 | 1 | // cardano-api.d.ts |
2 | 2 |
|
3 | | -export default initialise; |
4 | | - |
5 | | -/** |
6 | | - * Initialises the Cardano API. |
7 | | - * @returns A promise that resolves to the main `CardanoApi` object. |
8 | | - */ |
9 | | -declare function initialise(): Promise<CardanoApi>; |
| 3 | +import UnsignedTx from './unsigned-tx'; |
10 | 4 |
|
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; |
| 5 | +import GrpcConnection from './grpc-connection'; |
19 | 6 |
|
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 lovelaces 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 lovelaces. |
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 numKeyWitnesses The number of key witnesses. |
47 | | - * @param numByronKeyWitnesses The number of 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 lovelaces. |
50 | | - */ |
51 | | - estimateMinFee(protocolParams: any, numKeyWitnesses: number, numByronKeyWitnesses: 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 | | - * Represents a gRPC-web client connection to a Cardano node. |
86 | | - */ |
87 | | -declare interface GrpcConnection { |
88 | | - /** |
89 | | - * The type of the object, used for identification (the "GrpcConnection" string). |
90 | | - */ |
91 | | - objectType: string; |
92 | | - |
93 | | - /** |
94 | | - * Get the era from the Cardano Node using a GRPC-web client. |
95 | | - * @returns A promise that resolves to the current era number. |
96 | | - */ |
97 | | - getEra(): Promise<number>; |
98 | | - |
99 | | - /** |
100 | | - * Submit a signed and CBOR-encoded transaction to the Cardano node. |
101 | | - * @param txCbor The CBOR-encoded transaction as a hex string. |
102 | | - * @returns A promise that resolves to the transaction ID. |
103 | | - */ |
104 | | - submitTx(txCbor: string): Promise<string>; |
105 | | - |
106 | | - /** |
107 | | - * Get the protocol parameters in the cardano-ledger format from the Cardano Node using a GRPC-web client. |
108 | | - * @returns A promise that resolves to the current protocol parameters. |
109 | | - */ |
110 | | - getProtocolParams(): Promise<any>; |
111 | | - |
112 | | - /** |
113 | | - * Get all UTXOs from the node using a GRPC-web client. |
114 | | - * @returns A promise that resolves to the current UTXO set. |
115 | | - */ |
116 | | - getAllUtxos(): Promise<{ address: string, txId: string, txIndex: number, lovelace: bigint, assets: any[], datum?: any, script?: any }[]>; |
117 | | - |
118 | | - /** |
119 | | - * Get UTXOs for a given address using a GRPC-web client. |
120 | | - * @param address The address to get UTXOs for. |
121 | | - * @returns A promise that resolves to the UTXOs for the given address. |
122 | | - */ |
123 | | - getUtxosForAddress(address: string): Promise<{ txId: string, txIndex: number, lovelace: bigint, assets: any[], datum?: any, script?: any }[]>; |
124 | | -} |
125 | | - |
126 | | -/** |
127 | | - * Represents a wallet. |
128 | | - */ |
129 | | -declare interface Wallet { |
130 | | - /** |
131 | | - * The type of the object, used for identification (the "Wallet" string). |
132 | | - */ |
133 | | - objectType: string; |
134 | | - |
135 | | - /** |
136 | | - * Get the Bech32 representation of the address. (Can be shared for receiving funds.) |
137 | | - * @returns The Bech32 representation of the address. |
138 | | - */ |
139 | | - getAddressBech32(): Promise<string>; |
140 | | - |
141 | | - /** |
142 | | - * Get the Bech32 representation of the verification key of the wallet. (Can be shared for verification.) |
143 | | - * @returns The Bech32 representation of the verification key. |
144 | | - */ |
145 | | - getBech32ForVerificationKey(): Promise<string>; |
146 | | - |
147 | | - /** |
148 | | - * Get the Bech32 representation of the signing key of the wallet. (Must be kept secret.) |
149 | | - * @returns The Bech32 representation of the signing key. |
150 | | - */ |
151 | | - getBech32ForSigningKey(): Promise<string>; |
152 | | - |
153 | | - /** |
154 | | - * Get the base16 representation of the hash of the verification key of the wallet. |
155 | | - * @returns The base16 representation of the verification key hash. |
156 | | - */ |
157 | | - getBase16ForVerificationKeyHash(): Promise<string>; |
158 | | -} |
| 7 | +import Wallet from './wallet'; |
159 | 8 |
|
160 | 9 | /** |
161 | 10 | * The main Cardano API object with static methods. |
@@ -207,3 +56,11 @@ declare interface CardanoApi { |
207 | 56 | */ |
208 | 57 | restoreTestnetPaymentWalletFromSigningKeyBech32(networkMagic: number, signingKeyBech32: string): Promise<Wallet>; |
209 | 58 | } |
| 59 | + |
| 60 | +/** |
| 61 | + * Initialises the Cardano API. |
| 62 | + * @returns A promise that resolves to the main `CardanoApi` object. |
| 63 | + */ |
| 64 | +declare function initialise(): Promise<CardanoApi>; |
| 65 | + |
| 66 | +export default initialise; |
0 commit comments