koilib 2.7.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -12
- package/dist/koinos.js +8556 -269
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +66 -18
- package/lib/Contract.js +103 -40
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +22 -7
- package/lib/Provider.js +60 -21
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +9 -3
- package/lib/Serializer.js +111 -85
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +58 -38
- package/lib/Signer.js +318 -97
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +66 -18
- package/lib/browser/Contract.js +103 -40
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +22 -7
- package/lib/browser/Provider.js +60 -21
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +9 -3
- package/lib/browser/Serializer.js +111 -85
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +58 -38
- package/lib/browser/Signer.js +318 -97
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/indexUtils.d.ts +2 -0
- package/lib/browser/indexUtils.js +15 -0
- package/lib/browser/indexUtils.js.map +1 -0
- package/lib/browser/interface.d.ts +242 -46
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/{krc20-proto.json → token-proto.json} +47 -4
- package/lib/browser/protoModules/protocol-proto.d.ts +2 -0
- package/lib/browser/protoModules/protocol-proto.js +6336 -0
- package/lib/browser/protoModules/protocol-proto.js.map +1 -0
- package/lib/browser/utils.d.ts +19 -255
- package/lib/browser/utils.js +170 -15
- package/lib/browser/utils.js.map +1 -1
- package/lib/browser/utilsNode.d.ts +1021 -0
- package/lib/browser/utilsNode.js +346 -0
- package/lib/browser/utilsNode.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexUtils.d.ts +2 -0
- package/lib/indexUtils.js +15 -0
- package/lib/indexUtils.js.map +1 -0
- package/lib/interface.d.ts +242 -46
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/{krc20-proto.json → token-proto.json} +47 -4
- package/lib/protoModules/protocol-proto.d.ts +2 -0
- package/lib/protoModules/protocol-proto.js +6336 -0
- package/lib/protoModules/protocol-proto.js.map +1 -0
- package/lib/utils.d.ts +19 -255
- package/lib/utils.js +170 -15
- package/lib/utils.js.map +1 -1
- package/lib/utilsNode.d.ts +1021 -0
- package/lib/utilsNode.js +346 -0
- package/lib/utilsNode.js.map +1 -0
- package/package.json +1 -1
- package/lib/browser/jsonDescriptors/protocol-proto.json +0 -246
- package/lib/jsonDescriptors/protocol-proto.json +0 -246
package/lib/browser/Signer.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Provider } from "./Provider";
|
|
2
|
-
import { TransactionJson, TransactionJsonWait,
|
|
3
|
-
import { Serializer } from "./Serializer";
|
|
2
|
+
import { TransactionJson, TransactionJsonWait, BlockJson, RecoverPublicKeyOptions, Abi, TransactionReceipt } from "./interface";
|
|
4
3
|
export interface SignerInterface {
|
|
5
4
|
provider?: Provider;
|
|
6
|
-
serializer?: Serializer;
|
|
7
5
|
getAddress: (compressed?: boolean) => string;
|
|
8
6
|
getPrivateKey: (format: "wif" | "hex", compressed?: boolean) => string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
8
|
+
signTransaction: (tx: TransactionJson | TransactionJsonWait, abis?: Record<string, Abi>) => Promise<TransactionJson>;
|
|
9
|
+
sendTransaction: (tx: TransactionJson | TransactionJsonWait, abis?: Record<string, Abi>) => Promise<{
|
|
10
|
+
receipt: TransactionReceipt;
|
|
11
|
+
transaction: TransactionJsonWait;
|
|
12
|
+
}>;
|
|
13
|
+
prepareTransaction: (tx: TransactionJson) => Promise<TransactionJson>;
|
|
14
|
+
prepareBlock: (block: BlockJson) => Promise<BlockJson>;
|
|
15
|
+
signBlock: (block: BlockJson) => Promise<BlockJson>;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* The Signer Class contains the private key needed to sign transactions.
|
|
@@ -78,13 +81,13 @@ export declare class Signer implements SignerInterface {
|
|
|
78
81
|
*/
|
|
79
82
|
address: string;
|
|
80
83
|
/**
|
|
81
|
-
*
|
|
84
|
+
* Chain id
|
|
82
85
|
*/
|
|
83
|
-
|
|
86
|
+
chainId: string;
|
|
84
87
|
/**
|
|
85
|
-
*
|
|
88
|
+
* Provider to connect with the blockchain
|
|
86
89
|
*/
|
|
87
|
-
|
|
90
|
+
provider?: Provider;
|
|
88
91
|
/**
|
|
89
92
|
* The constructor receives de private key as hexstring, bigint or Uint8Array.
|
|
90
93
|
* See also the functions [[Signer.fromWif]] and [[Signer.fromSeed]]
|
|
@@ -104,14 +107,8 @@ export declare class Signer implements SignerInterface {
|
|
|
104
107
|
constructor(c: {
|
|
105
108
|
privateKey: string | number | bigint | Uint8Array;
|
|
106
109
|
compressed?: boolean;
|
|
110
|
+
chainId?: string;
|
|
107
111
|
provider?: Provider;
|
|
108
|
-
/**
|
|
109
|
-
* Set this option if you can not use _eval_ functions
|
|
110
|
-
* in the current environment. In such cases, the
|
|
111
|
-
* serializer must come from an environment where it
|
|
112
|
-
* is able to use those functions.
|
|
113
|
-
*/
|
|
114
|
-
serializer?: Serializer;
|
|
115
112
|
});
|
|
116
113
|
/**
|
|
117
114
|
* Function to import a private key from the WIF
|
|
@@ -124,7 +121,7 @@ export declare class Signer implements SignerInterface {
|
|
|
124
121
|
* ```
|
|
125
122
|
* @returns Signer object
|
|
126
123
|
*/
|
|
127
|
-
static fromWif(wif: string): Signer;
|
|
124
|
+
static fromWif(wif: string, compressed?: boolean): Signer;
|
|
128
125
|
/**
|
|
129
126
|
* Function to import a private key from the seed
|
|
130
127
|
* @param seed - Seed words
|
|
@@ -163,13 +160,26 @@ export declare class Signer implements SignerInterface {
|
|
|
163
160
|
* ```
|
|
164
161
|
*/
|
|
165
162
|
getPrivateKey(format?: "wif" | "hex", compressed?: boolean): string;
|
|
163
|
+
/**
|
|
164
|
+
* Function to sign a hash value. It returns the bytes signature.
|
|
165
|
+
* The signature is in compact format with the recovery byte
|
|
166
|
+
* @param hash - Hash value. Also known as digest
|
|
167
|
+
*/
|
|
168
|
+
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
166
169
|
/**
|
|
167
170
|
* Function to sign a transaction. It's important to remark that
|
|
168
171
|
* the transaction parameter is modified inside this function.
|
|
169
172
|
* @param tx - Unsigned transaction
|
|
170
|
-
* @returns
|
|
171
173
|
*/
|
|
172
|
-
signTransaction(tx: TransactionJson): Promise<TransactionJson>;
|
|
174
|
+
signTransaction(tx: TransactionJson | TransactionJsonWait, _abis?: Record<string, Abi>): Promise<TransactionJson>;
|
|
175
|
+
/**
|
|
176
|
+
* Function to sign a block for federated consensus. That is,
|
|
177
|
+
* just the ecdsa signature. For other algorithms, like PoW,
|
|
178
|
+
* you have to sign the block and then process the signature
|
|
179
|
+
* to add the extra data (nonce in the case of PoW).
|
|
180
|
+
* @param block - Unsigned block
|
|
181
|
+
*/
|
|
182
|
+
signBlock(block: BlockJson): Promise<BlockJson>;
|
|
173
183
|
/**
|
|
174
184
|
* Function to sign and send a transaction. It internally uses
|
|
175
185
|
* [[Provider.sendTransaction]]
|
|
@@ -179,15 +189,25 @@ export declare class Signer implements SignerInterface {
|
|
|
179
189
|
* transaction. This parameter is optional.
|
|
180
190
|
* @returns
|
|
181
191
|
*/
|
|
182
|
-
sendTransaction(tx: TransactionJson, _abis?: Record<string, Abi>): Promise<
|
|
192
|
+
sendTransaction(tx: TransactionJson | TransactionJsonWait, _abis?: Record<string, Abi>): Promise<{
|
|
193
|
+
receipt: TransactionReceipt;
|
|
194
|
+
transaction: TransactionJsonWait;
|
|
195
|
+
}>;
|
|
196
|
+
/**
|
|
197
|
+
* Function to recover the public key from hash and signature
|
|
198
|
+
* @param hash - hash sha256
|
|
199
|
+
* @param signature - compact signature
|
|
200
|
+
* @param compressed - default true
|
|
201
|
+
*/
|
|
202
|
+
static recoverPublicKey(hash: Uint8Array, signature: Uint8Array, compressed?: boolean): string;
|
|
183
203
|
/**
|
|
184
|
-
* Function to recover the
|
|
204
|
+
* Function to recover the publics keys from a signed
|
|
185
205
|
* transaction or block.
|
|
186
206
|
* The output format can be compressed (default) or uncompressed.
|
|
187
207
|
*
|
|
188
208
|
* @example
|
|
189
209
|
* ```ts
|
|
190
|
-
* const
|
|
210
|
+
* const publicKeys = await Signer.recoverPublicKeys(tx);
|
|
191
211
|
* ```
|
|
192
212
|
*
|
|
193
213
|
* If the signature data contains more data, like in the
|
|
@@ -221,7 +241,7 @@ export declare class Signer implements SignerInterface {
|
|
|
221
241
|
* defaultTypeName: "pow_signature_data",
|
|
222
242
|
* });
|
|
223
243
|
*
|
|
224
|
-
* const
|
|
244
|
+
* const publicKeys = await signer.recoverPublicKeys(block, {
|
|
225
245
|
* transformSignature: async (signatureData) => {
|
|
226
246
|
* const powSignatureData = await serializer.deserialize(signatureData);
|
|
227
247
|
* return powSignatureData.recoverable_signature;
|
|
@@ -229,14 +249,14 @@ export declare class Signer implements SignerInterface {
|
|
|
229
249
|
* });
|
|
230
250
|
* ```
|
|
231
251
|
*/
|
|
232
|
-
|
|
252
|
+
recoverPublicKeys(txOrBlock: TransactionJson | BlockJson, opts?: RecoverPublicKeyOptions): Promise<string[]>;
|
|
233
253
|
/**
|
|
234
|
-
* Function to recover the signer
|
|
254
|
+
* Function to recover the signer addresses from a signed
|
|
235
255
|
* transaction or block.
|
|
236
256
|
* The output format can be compressed (default) or uncompressed.
|
|
237
257
|
* @example
|
|
238
258
|
* ```ts
|
|
239
|
-
* const
|
|
259
|
+
* const addresses = await signer.recoverAddress(tx);
|
|
240
260
|
* ```
|
|
241
261
|
*
|
|
242
262
|
* If the signature data contains more data, like in the
|
|
@@ -270,7 +290,7 @@ export declare class Signer implements SignerInterface {
|
|
|
270
290
|
* defaultTypeName: "pow_signature_data",
|
|
271
291
|
* });
|
|
272
292
|
*
|
|
273
|
-
* const
|
|
293
|
+
* const addresses = await signer.recoverAddress(block, {
|
|
274
294
|
* transformSignature: async (signatureData) => {
|
|
275
295
|
* const powSignatureData = await serializer.deserialize(signatureData);
|
|
276
296
|
* return powSignatureData.recoverable_signature;
|
|
@@ -278,19 +298,19 @@ export declare class Signer implements SignerInterface {
|
|
|
278
298
|
* });
|
|
279
299
|
* ```
|
|
280
300
|
*/
|
|
281
|
-
|
|
301
|
+
recoverAddresses(txOrBlock: TransactionJson | BlockJson, opts?: RecoverPublicKeyOptions): Promise<string[]>;
|
|
282
302
|
/**
|
|
283
|
-
* Function to
|
|
284
|
-
* @param
|
|
285
|
-
* operations. Do not set the nonce to get it from the blockchain
|
|
303
|
+
* Function to prepare a transaction
|
|
304
|
+
* @param tx - Do not set the nonce to get it from the blockchain
|
|
286
305
|
* using the provider. The rc_limit is 1e8 by default.
|
|
287
|
-
* @returns A transaction
|
|
288
|
-
* base64url
|
|
306
|
+
* @returns A prepared transaction. ()
|
|
289
307
|
*/
|
|
290
|
-
|
|
308
|
+
prepareTransaction(tx: TransactionJson): Promise<TransactionJson>;
|
|
291
309
|
/**
|
|
292
|
-
* Function to
|
|
310
|
+
* Function to prepare a block
|
|
311
|
+
* @param block -
|
|
312
|
+
* @returns A prepared block. ()
|
|
293
313
|
*/
|
|
294
|
-
|
|
314
|
+
prepareBlock(block: BlockJson): Promise<BlockJson>;
|
|
295
315
|
}
|
|
296
316
|
export default Signer;
|