koilib 2.8.0 → 3.0.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 +61 -7
- package/dist/koinos.js +8404 -200
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +46 -7
- package/lib/Contract.js +89 -21
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +16 -3
- package/lib/Provider.js +36 -6
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +2 -1
- package/lib/Serializer.js +50 -37
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +42 -42
- package/lib/Signer.js +294 -112
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +46 -7
- package/lib/browser/Contract.js +89 -21
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +16 -3
- package/lib/browser/Provider.js +36 -6
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +2 -1
- package/lib/browser/Serializer.js +50 -37
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +42 -42
- package/lib/browser/Signer.js +294 -112
- 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 +221 -45
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/krc20-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 +18 -254
- package/lib/browser/utils.js +140 -12
- 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 +221 -45
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/krc20-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 +18 -254
- package/lib/utils.js +140 -12
- 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,15 @@
|
|
|
1
1
|
import { Provider } from "./Provider";
|
|
2
|
-
import { TransactionJson, TransactionJsonWait,
|
|
3
|
-
import { Serializer } from "./Serializer";
|
|
2
|
+
import { TransactionJson, TransactionJsonWait, BlockJson, RecoverPublicKeyOptions, Abi } 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<TransactionJsonWait>;
|
|
10
|
+
prepareTransaction: (tx: TransactionJson) => Promise<TransactionJson>;
|
|
11
|
+
prepareBlock: (block: BlockJson) => Promise<BlockJson>;
|
|
12
|
+
signBlock: (block: BlockJson) => Promise<BlockJson>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* The Signer Class contains the private key needed to sign transactions.
|
|
@@ -78,13 +78,13 @@ export declare class Signer implements SignerInterface {
|
|
|
78
78
|
*/
|
|
79
79
|
address: string;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* Chain id
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
chainId: string;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Provider to connect with the blockchain
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
provider?: Provider;
|
|
88
88
|
/**
|
|
89
89
|
* The constructor receives de private key as hexstring, bigint or Uint8Array.
|
|
90
90
|
* See also the functions [[Signer.fromWif]] and [[Signer.fromSeed]]
|
|
@@ -104,14 +104,8 @@ export declare class Signer implements SignerInterface {
|
|
|
104
104
|
constructor(c: {
|
|
105
105
|
privateKey: string | number | bigint | Uint8Array;
|
|
106
106
|
compressed?: boolean;
|
|
107
|
+
chainId?: string;
|
|
107
108
|
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
109
|
});
|
|
116
110
|
/**
|
|
117
111
|
* Function to import a private key from the WIF
|
|
@@ -124,7 +118,7 @@ export declare class Signer implements SignerInterface {
|
|
|
124
118
|
* ```
|
|
125
119
|
* @returns Signer object
|
|
126
120
|
*/
|
|
127
|
-
static fromWif(wif: string): Signer;
|
|
121
|
+
static fromWif(wif: string, compressed?: boolean): Signer;
|
|
128
122
|
/**
|
|
129
123
|
* Function to import a private key from the seed
|
|
130
124
|
* @param seed - Seed words
|
|
@@ -164,18 +158,17 @@ export declare class Signer implements SignerInterface {
|
|
|
164
158
|
*/
|
|
165
159
|
getPrivateKey(format?: "wif" | "hex", compressed?: boolean): string;
|
|
166
160
|
/**
|
|
167
|
-
* Function to sign a hash value. It returns the signature
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @param hash Hash value. Also known as digest
|
|
161
|
+
* Function to sign a hash value. It returns the bytes signature.
|
|
162
|
+
* The signature is in compact format with the recovery byte
|
|
163
|
+
* @param hash - Hash value. Also known as digest
|
|
171
164
|
*/
|
|
172
|
-
signHash(hash: Uint8Array): Promise<
|
|
165
|
+
signHash(hash: Uint8Array): Promise<Uint8Array>;
|
|
173
166
|
/**
|
|
174
167
|
* Function to sign a transaction. It's important to remark that
|
|
175
168
|
* the transaction parameter is modified inside this function.
|
|
176
169
|
* @param tx - Unsigned transaction
|
|
177
170
|
*/
|
|
178
|
-
signTransaction(tx: TransactionJson): Promise<TransactionJson>;
|
|
171
|
+
signTransaction(tx: TransactionJson | TransactionJsonWait, _abis?: Record<string, Abi>): Promise<TransactionJson>;
|
|
179
172
|
/**
|
|
180
173
|
* Function to sign a block for federated consensus. That is,
|
|
181
174
|
* just the ecdsa signature. For other algorithms, like PoW,
|
|
@@ -193,15 +186,22 @@ export declare class Signer implements SignerInterface {
|
|
|
193
186
|
* transaction. This parameter is optional.
|
|
194
187
|
* @returns
|
|
195
188
|
*/
|
|
196
|
-
sendTransaction(tx: TransactionJson, _abis?: Record<string, Abi>): Promise<TransactionJsonWait>;
|
|
189
|
+
sendTransaction(tx: TransactionJson | TransactionJsonWait, _abis?: Record<string, Abi>): Promise<TransactionJsonWait>;
|
|
190
|
+
/**
|
|
191
|
+
* Function to recover the public key from hash and signature
|
|
192
|
+
* @param hash - hash sha256
|
|
193
|
+
* @param signature - compact signature
|
|
194
|
+
* @param compressed - default true
|
|
195
|
+
*/
|
|
196
|
+
static recoverPublicKey(hash: Uint8Array, signature: Uint8Array, compressed?: boolean): string;
|
|
197
197
|
/**
|
|
198
|
-
* Function to recover the
|
|
198
|
+
* Function to recover the publics keys from a signed
|
|
199
199
|
* transaction or block.
|
|
200
200
|
* The output format can be compressed (default) or uncompressed.
|
|
201
201
|
*
|
|
202
202
|
* @example
|
|
203
203
|
* ```ts
|
|
204
|
-
* const
|
|
204
|
+
* const publicKeys = await Signer.recoverPublicKeys(tx);
|
|
205
205
|
* ```
|
|
206
206
|
*
|
|
207
207
|
* If the signature data contains more data, like in the
|
|
@@ -235,7 +235,7 @@ export declare class Signer implements SignerInterface {
|
|
|
235
235
|
* defaultTypeName: "pow_signature_data",
|
|
236
236
|
* });
|
|
237
237
|
*
|
|
238
|
-
* const
|
|
238
|
+
* const publicKeys = await signer.recoverPublicKeys(block, {
|
|
239
239
|
* transformSignature: async (signatureData) => {
|
|
240
240
|
* const powSignatureData = await serializer.deserialize(signatureData);
|
|
241
241
|
* return powSignatureData.recoverable_signature;
|
|
@@ -243,14 +243,14 @@ export declare class Signer implements SignerInterface {
|
|
|
243
243
|
* });
|
|
244
244
|
* ```
|
|
245
245
|
*/
|
|
246
|
-
|
|
246
|
+
recoverPublicKeys(txOrBlock: TransactionJson | BlockJson, opts?: RecoverPublicKeyOptions): Promise<string[]>;
|
|
247
247
|
/**
|
|
248
|
-
* Function to recover the signer
|
|
248
|
+
* Function to recover the signer addresses from a signed
|
|
249
249
|
* transaction or block.
|
|
250
250
|
* The output format can be compressed (default) or uncompressed.
|
|
251
251
|
* @example
|
|
252
252
|
* ```ts
|
|
253
|
-
* const
|
|
253
|
+
* const addresses = await signer.recoverAddress(tx);
|
|
254
254
|
* ```
|
|
255
255
|
*
|
|
256
256
|
* If the signature data contains more data, like in the
|
|
@@ -284,7 +284,7 @@ export declare class Signer implements SignerInterface {
|
|
|
284
284
|
* defaultTypeName: "pow_signature_data",
|
|
285
285
|
* });
|
|
286
286
|
*
|
|
287
|
-
* const
|
|
287
|
+
* const addresses = await signer.recoverAddress(block, {
|
|
288
288
|
* transformSignature: async (signatureData) => {
|
|
289
289
|
* const powSignatureData = await serializer.deserialize(signatureData);
|
|
290
290
|
* return powSignatureData.recoverable_signature;
|
|
@@ -292,19 +292,19 @@ export declare class Signer implements SignerInterface {
|
|
|
292
292
|
* });
|
|
293
293
|
* ```
|
|
294
294
|
*/
|
|
295
|
-
|
|
295
|
+
recoverAddresses(txOrBlock: TransactionJson | BlockJson, opts?: RecoverPublicKeyOptions): Promise<string[]>;
|
|
296
296
|
/**
|
|
297
|
-
* Function to
|
|
298
|
-
* @param
|
|
299
|
-
* operations. Do not set the nonce to get it from the blockchain
|
|
297
|
+
* Function to prepare a transaction
|
|
298
|
+
* @param tx - Do not set the nonce to get it from the blockchain
|
|
300
299
|
* using the provider. The rc_limit is 1e8 by default.
|
|
301
|
-
* @returns A transaction
|
|
302
|
-
* base64url
|
|
300
|
+
* @returns A prepared transaction. ()
|
|
303
301
|
*/
|
|
304
|
-
|
|
302
|
+
prepareTransaction(tx: TransactionJson): Promise<TransactionJson>;
|
|
305
303
|
/**
|
|
306
|
-
* Function to
|
|
304
|
+
* Function to prepare a block
|
|
305
|
+
* @param block -
|
|
306
|
+
* @returns A prepared block. ()
|
|
307
307
|
*/
|
|
308
|
-
|
|
308
|
+
prepareBlock(block: BlockJson): Promise<BlockJson>;
|
|
309
309
|
}
|
|
310
310
|
export default Signer;
|