koilib 5.2.2 → 5.2.3
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/dist/koinos.js +22 -11
- package/dist/koinos.min.js +1 -1
- package/lib/Provider.d.ts +11 -2
- package/lib/Provider.js +21 -2
- package/lib/Provider.js.map +1 -1
- package/lib/Signer.js +1 -9
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Provider.d.ts +11 -2
- package/lib/browser/Provider.js +21 -2
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Signer.js +1 -9
- package/lib/browser/Signer.js.map +1 -1
- package/package.json +1 -1
package/dist/koinos.js
CHANGED
|
@@ -10395,8 +10395,8 @@ class Provider {
|
|
|
10395
10395
|
}
|
|
10396
10396
|
/**
|
|
10397
10397
|
* Function to call "chain.get_account_nonce" to return the number of
|
|
10398
|
-
* transactions for a particular account.
|
|
10399
|
-
*
|
|
10398
|
+
* transactions for a particular account. If you are creating a new
|
|
10399
|
+
* transaction consider using [[Provider.getNextNonce]].
|
|
10400
10400
|
* @param account - account address
|
|
10401
10401
|
* @param deserialize - If set true it will deserialize the nonce
|
|
10402
10402
|
* and return it as number (default). If set false it will return
|
|
@@ -10417,6 +10417,25 @@ class Provider {
|
|
|
10417
10417
|
// todo: consider the case where nonce is greater than max safe integer
|
|
10418
10418
|
return Number(object.uint64_value);
|
|
10419
10419
|
}
|
|
10420
|
+
/**
|
|
10421
|
+
* Function to call "chain.get_account_nonce" (number of
|
|
10422
|
+
* transactions for a particular account) and return the next nonce.
|
|
10423
|
+
* This call is used when creating new transactions. The result is
|
|
10424
|
+
* encoded in base64url
|
|
10425
|
+
* @param account - account address
|
|
10426
|
+
* @returns Nonce
|
|
10427
|
+
*/
|
|
10428
|
+
async getNextNonce(account) {
|
|
10429
|
+
const oldNonce = (await this.getNonce(account));
|
|
10430
|
+
const message = protocol_proto_js_1.koinos.chain.value_type.create({
|
|
10431
|
+
// todo: consider using bigint for big nonces
|
|
10432
|
+
uint64_value: String(oldNonce + 1),
|
|
10433
|
+
});
|
|
10434
|
+
const nonceEncoded = protocol_proto_js_1.koinos.chain.value_type
|
|
10435
|
+
.encode(message)
|
|
10436
|
+
.finish();
|
|
10437
|
+
return (0, utils_1.encodeBase64url)(nonceEncoded);
|
|
10438
|
+
}
|
|
10420
10439
|
async getAccountRc(account) {
|
|
10421
10440
|
const { rc } = await this.call("chain.get_account_rc", {
|
|
10422
10441
|
account,
|
|
@@ -11397,15 +11416,7 @@ class Signer {
|
|
|
11397
11416
|
if (tx.header.nonce === undefined) {
|
|
11398
11417
|
if (!this.provider)
|
|
11399
11418
|
throw new Error("Cannot get the nonce because provider is undefined. To skip this call set a nonce in the transaction header");
|
|
11400
|
-
|
|
11401
|
-
const message = protocol_proto_js_1.koinos.chain.value_type.create({
|
|
11402
|
-
// todo: consider using bigint for big nonces
|
|
11403
|
-
uint64_value: String(oldNonce + 1),
|
|
11404
|
-
});
|
|
11405
|
-
const nonceEncoded = protocol_proto_js_1.koinos.chain.value_type
|
|
11406
|
-
.encode(message)
|
|
11407
|
-
.finish();
|
|
11408
|
-
nonce = (0, utils_1.encodeBase64url)(nonceEncoded);
|
|
11419
|
+
nonce = await this.provider.getNextNonce(payee || payer);
|
|
11409
11420
|
}
|
|
11410
11421
|
else {
|
|
11411
11422
|
nonce = tx.header.nonce;
|