koilib 2.8.0 → 3.1.1
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 +8535 -284
- 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 +3 -1
- package/lib/Serializer.js +103 -83
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +54 -42
- package/lib/Signer.js +305 -114
- 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 +3 -1
- package/lib/browser/Serializer.js +103 -83
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +54 -42
- package/lib/browser/Signer.js +305 -114
- 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/Signer.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
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
|
+
signMessage: (message: string | Uint8Array) => Promise<Uint8Array>;
|
|
9
|
+
prepareTransaction: (tx: TransactionJson) => Promise<TransactionJson>;
|
|
10
|
+
signTransaction: (tx: TransactionJson | TransactionJsonWait, abis?: Record<string, Abi>) => Promise<TransactionJson>;
|
|
11
|
+
sendTransaction: (tx: TransactionJson | TransactionJsonWait, abis?: Record<string, Abi>) => Promise<{
|
|
12
|
+
receipt: TransactionReceipt;
|
|
13
|
+
transaction: TransactionJsonWait;
|
|
14
|
+
}>;
|
|
15
|
+
prepareBlock: (block: BlockJson) => Promise<BlockJson>;
|
|
16
|
+
signBlock: (block: BlockJson) => Promise<BlockJson>;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* The Signer Class contains the private key needed to sign transactions.
|
|
@@ -78,13 +82,13 @@ export declare class Signer implements SignerInterface {
|
|
|
78
82
|
*/
|
|
79
83
|
address: string;
|
|
80
84
|
/**
|
|
81
|
-
*
|
|
85
|
+
* Chain id
|
|
82
86
|
*/
|
|
83
|
-
|
|
87
|
+
chainId: string;
|
|
84
88
|
/**
|
|
85
|
-
*
|
|
89
|
+
* Provider to connect with the blockchain
|
|
86
90
|
*/
|
|
87
|
-
|
|
91
|
+
provider?: Provider;
|
|
88
92
|
/**
|
|
89
93
|
* The constructor receives de private key as hexstring, bigint or Uint8Array.
|
|
90
94
|
* See also the functions [[Signer.fromWif]] and [[Signer.fromSeed]]
|
|
@@ -104,14 +108,8 @@ export declare class Signer implements SignerInterface {
|
|
|
104
108
|
constructor(c: {
|
|
105
109
|
privateKey: string | number | bigint | Uint8Array;
|
|
106
110
|
compressed?: boolean;
|
|
111
|
+
chainId?: string;
|
|
107
112
|
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
113
|
});
|
|
116
114
|
/**
|
|
117
115
|
* Function to import a private key from the WIF
|
|
@@ -124,7 +122,7 @@ export declare class Signer implements SignerInterface {
|
|
|
124
122
|
* ```
|
|
125
123
|
* @returns Signer object
|
|
126
124
|
*/
|
|
127
|
-
static fromWif(wif: string): Signer;
|
|
125
|
+
static fromWif(wif: string, compressed?: boolean): Signer;
|
|
128
126
|
/**
|
|
129
127
|
* Function to import a private key from the seed
|
|
130
128
|
* @param seed - Seed words
|
|
@@ -164,18 +162,21 @@ export declare class Signer implements SignerInterface {
|
|
|
164
162
|
*/
|
|
165
163
|
getPrivateKey(format?: "wif" | "hex", compressed?: boolean): string;
|
|
166
164
|
/**
|
|
167
|
-
* Function to sign a hash value. It returns the signature
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @param hash Hash value. Also known as digest
|
|
165
|
+
* Function to sign a hash value. It returns the bytes signature.
|
|
166
|
+
* The signature is in compact format with the recovery byte
|
|
167
|
+
* @param hash - Hash value. Also known as digest
|
|
171
168
|
*/
|
|
172
|
-
signHash(hash: Uint8Array): Promise<
|
|
169
|
+
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
170
|
+
/**
|
|
171
|
+
* Function to sign a message, which could be a string or a Uint8Array
|
|
172
|
+
*/
|
|
173
|
+
signMessage(message: string | Uint8Array): Promise<Uint8Array>;
|
|
173
174
|
/**
|
|
174
175
|
* Function to sign a transaction. It's important to remark that
|
|
175
176
|
* the transaction parameter is modified inside this function.
|
|
176
177
|
* @param tx - Unsigned transaction
|
|
177
178
|
*/
|
|
178
|
-
signTransaction(tx: TransactionJson): Promise<TransactionJson>;
|
|
179
|
+
signTransaction(tx: TransactionJson | TransactionJsonWait, _abis?: Record<string, Abi>): Promise<TransactionJson>;
|
|
179
180
|
/**
|
|
180
181
|
* Function to sign a block for federated consensus. That is,
|
|
181
182
|
* just the ecdsa signature. For other algorithms, like PoW,
|
|
@@ -193,15 +194,26 @@ export declare class Signer implements SignerInterface {
|
|
|
193
194
|
* transaction. This parameter is optional.
|
|
194
195
|
* @returns
|
|
195
196
|
*/
|
|
196
|
-
sendTransaction(tx: TransactionJson, _abis?: Record<string, Abi>): Promise<
|
|
197
|
+
sendTransaction(tx: TransactionJson | TransactionJsonWait, _abis?: Record<string, Abi>): Promise<{
|
|
198
|
+
receipt: TransactionReceipt;
|
|
199
|
+
transaction: TransactionJsonWait;
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* Function to recover the public key from hash and signature
|
|
203
|
+
* @param hash - hash sha256
|
|
204
|
+
* @param signature - compact signature
|
|
205
|
+
* @param compressed - default true
|
|
206
|
+
*/
|
|
207
|
+
static recoverPublicKey(hash: Uint8Array, signature: Uint8Array, compressed?: boolean): string;
|
|
208
|
+
static recoverAddress(hash: Uint8Array, signature: Uint8Array, compressed?: boolean): string;
|
|
197
209
|
/**
|
|
198
|
-
* Function to recover the
|
|
210
|
+
* Function to recover the publics keys from a signed
|
|
199
211
|
* transaction or block.
|
|
200
212
|
* The output format can be compressed (default) or uncompressed.
|
|
201
213
|
*
|
|
202
214
|
* @example
|
|
203
215
|
* ```ts
|
|
204
|
-
* const
|
|
216
|
+
* const publicKeys = await Signer.recoverPublicKeys(tx);
|
|
205
217
|
* ```
|
|
206
218
|
*
|
|
207
219
|
* If the signature data contains more data, like in the
|
|
@@ -235,7 +247,7 @@ export declare class Signer implements SignerInterface {
|
|
|
235
247
|
* defaultTypeName: "pow_signature_data",
|
|
236
248
|
* });
|
|
237
249
|
*
|
|
238
|
-
* const
|
|
250
|
+
* const publicKeys = await signer.recoverPublicKeys(block, {
|
|
239
251
|
* transformSignature: async (signatureData) => {
|
|
240
252
|
* const powSignatureData = await serializer.deserialize(signatureData);
|
|
241
253
|
* return powSignatureData.recoverable_signature;
|
|
@@ -243,14 +255,14 @@ export declare class Signer implements SignerInterface {
|
|
|
243
255
|
* });
|
|
244
256
|
* ```
|
|
245
257
|
*/
|
|
246
|
-
|
|
258
|
+
recoverPublicKeys(txOrBlock: TransactionJson | BlockJson, opts?: RecoverPublicKeyOptions): Promise<string[]>;
|
|
247
259
|
/**
|
|
248
|
-
* Function to recover the signer
|
|
260
|
+
* Function to recover the signer addresses from a signed
|
|
249
261
|
* transaction or block.
|
|
250
262
|
* The output format can be compressed (default) or uncompressed.
|
|
251
263
|
* @example
|
|
252
264
|
* ```ts
|
|
253
|
-
* const
|
|
265
|
+
* const addresses = await signer.recoverAddress(tx);
|
|
254
266
|
* ```
|
|
255
267
|
*
|
|
256
268
|
* If the signature data contains more data, like in the
|
|
@@ -284,7 +296,7 @@ export declare class Signer implements SignerInterface {
|
|
|
284
296
|
* defaultTypeName: "pow_signature_data",
|
|
285
297
|
* });
|
|
286
298
|
*
|
|
287
|
-
* const
|
|
299
|
+
* const addresses = await signer.recoverAddress(block, {
|
|
288
300
|
* transformSignature: async (signatureData) => {
|
|
289
301
|
* const powSignatureData = await serializer.deserialize(signatureData);
|
|
290
302
|
* return powSignatureData.recoverable_signature;
|
|
@@ -292,19 +304,19 @@ export declare class Signer implements SignerInterface {
|
|
|
292
304
|
* });
|
|
293
305
|
* ```
|
|
294
306
|
*/
|
|
295
|
-
|
|
307
|
+
recoverAddresses(txOrBlock: TransactionJson | BlockJson, opts?: RecoverPublicKeyOptions): Promise<string[]>;
|
|
296
308
|
/**
|
|
297
|
-
* Function to
|
|
298
|
-
* @param
|
|
299
|
-
* operations. Do not set the nonce to get it from the blockchain
|
|
309
|
+
* Function to prepare a transaction
|
|
310
|
+
* @param tx - Do not set the nonce to get it from the blockchain
|
|
300
311
|
* using the provider. The rc_limit is 1e8 by default.
|
|
301
|
-
* @returns A transaction
|
|
302
|
-
* base64url
|
|
312
|
+
* @returns A prepared transaction. ()
|
|
303
313
|
*/
|
|
304
|
-
|
|
314
|
+
prepareTransaction(tx: TransactionJson): Promise<TransactionJson>;
|
|
305
315
|
/**
|
|
306
|
-
* Function to
|
|
316
|
+
* Function to prepare a block
|
|
317
|
+
* @param block -
|
|
318
|
+
* @returns A prepared block. ()
|
|
307
319
|
*/
|
|
308
|
-
|
|
320
|
+
prepareBlock(block: BlockJson): Promise<BlockJson>;
|
|
309
321
|
}
|
|
310
322
|
export default Signer;
|