koilib 5.2.2 → 5.3.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/dist/koinos.js +24 -13
- 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 +3 -11
- 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 +3 -11
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/interface.d.ts +2 -2
- package/lib/interface.d.ts +2 -2
- 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,
|
|
@@ -11203,7 +11222,7 @@ class Signer {
|
|
|
11203
11222
|
async sendTransaction(transaction, options) {
|
|
11204
11223
|
var _a;
|
|
11205
11224
|
if (!transaction.signatures || !((_a = transaction.signatures) === null || _a === void 0 ? void 0 : _a.length))
|
|
11206
|
-
transaction = await this.signTransaction(transaction);
|
|
11225
|
+
transaction = await this.signTransaction(transaction, options === null || options === void 0 ? void 0 : options.abis);
|
|
11207
11226
|
if (!this.provider)
|
|
11208
11227
|
throw new Error("provider is undefined");
|
|
11209
11228
|
const opts = {
|
|
@@ -11211,7 +11230,7 @@ class Signer {
|
|
|
11211
11230
|
...options,
|
|
11212
11231
|
};
|
|
11213
11232
|
if (opts.beforeSend) {
|
|
11214
|
-
await opts.beforeSend(transaction);
|
|
11233
|
+
await opts.beforeSend(transaction, options);
|
|
11215
11234
|
}
|
|
11216
11235
|
return this.provider.sendTransaction(transaction, opts.broadcast);
|
|
11217
11236
|
}
|
|
@@ -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;
|