Skip to content

Commit

Permalink
release v5.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
joticajulian committed Nov 27, 2022
1 parent 0097ebd commit 46bee80
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
33 changes: 22 additions & 11 deletions dist/koinos.js
Original file line number Diff line number Diff line change
Expand Up @@ -10395,8 +10395,8 @@ class Provider {
}
/**
* Function to call "chain.get_account_nonce" to return the number of
* transactions for a particular account. This call is used
* when creating new transactions.
* transactions for a particular account. If you are creating a new
* transaction consider using [[Provider.getNextNonce]].
* @param account - account address
* @param deserialize - If set true it will deserialize the nonce
* and return it as number (default). If set false it will return
Expand All @@ -10417,6 +10417,25 @@ class Provider {
// todo: consider the case where nonce is greater than max safe integer
return Number(object.uint64_value);
}
/**
* Function to call "chain.get_account_nonce" (number of
* transactions for a particular account) and return the next nonce.
* This call is used when creating new transactions. The result is
* encoded in base64url
* @param account - account address
* @returns Nonce
*/
async getNextNonce(account) {
const oldNonce = (await this.getNonce(account));
const message = protocol_proto_js_1.koinos.chain.value_type.create({
// todo: consider using bigint for big nonces
uint64_value: String(oldNonce + 1),
});
const nonceEncoded = protocol_proto_js_1.koinos.chain.value_type
.encode(message)
.finish();
return (0, utils_1.encodeBase64url)(nonceEncoded);
}
async getAccountRc(account) {
const { rc } = await this.call("chain.get_account_rc", {
account,
Expand Down Expand Up @@ -11397,15 +11416,7 @@ class Signer {
if (tx.header.nonce === undefined) {
if (!this.provider)
throw new Error("Cannot get the nonce because provider is undefined. To skip this call set a nonce in the transaction header");
const oldNonce = (await this.provider.getNonce(payee || payer));
const message = protocol_proto_js_1.koinos.chain.value_type.create({
// todo: consider using bigint for big nonces
uint64_value: String(oldNonce + 1),
});
const nonceEncoded = protocol_proto_js_1.koinos.chain.value_type
.encode(message)
.finish();
nonce = (0, utils_1.encodeBase64url)(nonceEncoded);
nonce = await this.provider.getNextNonce(payee || payer);
}
else {
nonce = tx.header.nonce;
Expand Down
2 changes: 1 addition & 1 deletion dist/koinos.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "koilib",
"version": "5.2.2",
"version": "5.2.3",
"description": "JS Koinos Library",
"author": "Julian Gonzalez",
"repository": {
Expand Down

0 comments on commit 46bee80

Please sign in to comment.