Repository: algorand/js-algorand-sdk
Pull request #505 (2022-01-25 19:26:15)

js-algorand-sdk v1.13.1
# 1.13.1

## Added:

- Add app creator to dryrun request (#499)

## Changed:

- Adding note to use bigint to help debug when amount/assetAmount is large (#501)

## Fixed:

- Fix JSON decoding (#502)


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01e937e..65bbef1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,17 @@
+# 1.13.1
+
+## Added:
+
+- Add app creator to dryrun request (#499)
+
+## Changed:
+
+- Adding note to use bigint (#501)
+
+## Fixed:
+
+- Fix JSON decoding (#502)
+
 # 1.13.0
 
 ## Added:
diff --git a/README.md b/README.md
index 45f94a7..4d0585f 100644
--- a/README.md
+++ b/README.md
@@ -20,8 +20,8 @@ Include a minified browser bundle directly in your HTML like so:
 
 ```html
 <script
-  src="https://unpkg.com/algosdk@1.13.0/dist/browser/algosdk.min.js"
-  integrity="sha384-3IaxTgktbWGiqPkr5oZQMM4H99ziYzoEUb6sznk03coGR2Cdf1r0I1GWPUL37iu8"
+  src="https://unpkg.com/algosdk@1.13.1/dist/browser/algosdk.min.js"
+  integrity="sha384-0BSEzBpLxqFWYBI+sOGhv3W91/wPf+jFwCiuXNrC52XZav2qb3Rz+pfq3AFI0CrL"
   crossorigin="anonymous"
 ></script>
 ```
@@ -30,8 +30,8 @@ or
 
 ```html
 <script
-  src="https://cdn.jsdelivr.net/npm/algosdk@1.13.0/dist/browser/algosdk.min.js"
-  integrity="sha384-3IaxTgktbWGiqPkr5oZQMM4H99ziYzoEUb6sznk03coGR2Cdf1r0I1GWPUL37iu8"
+  src="https://cdn.jsdelivr.net/npm/algosdk@1.13.1/dist/browser/algosdk.min.js"
+  integrity="sha384-0BSEzBpLxqFWYBI+sOGhv3W91/wPf+jFwCiuXNrC52XZav2qb3Rz+pfq3AFI0CrL"
   crossorigin="anonymous"
 ></script>
 ```
diff --git a/package-lock.json b/package-lock.json
index 876e07b..99f61d8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "algosdk",
-  "version": "1.13.0",
+  "version": "1.13.1",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "algosdk",
-      "version": "1.13.0",
+      "version": "1.13.1",
       "license": "MIT",
       "dependencies": {
         "algo-msgpack-with-bigint": "^2.1.1",
diff --git a/package.json b/package.json
index 7399bac..7d303ad 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "algosdk",
-  "version": "1.13.0",
+  "version": "1.13.1",
   "description": "The official JavaScript SDK for Algorand",
   "main": "dist/cjs/index.js",
   "module": "dist/esm/index.js",
diff --git a/src/client/client.ts b/src/client/client.ts
index 170b487..8be88c1 100644
--- a/src/client/client.ts
+++ b/src/client/client.ts
@@ -140,15 +140,14 @@ export default class HTTPClient {
    * @param status Status of the response (used in case parseJSON fails)
    * @param jsonOptions Options object to use to decode JSON responses. See
    *   utils.parseJSON for the options available.
-   * @private
    */
-  private static parseJSON(
+  public static parseJSON(
     text: string,
     status: number,
     jsonOptions: utils.JSONOptions = {}
   ) {
     try {
-      if (Object.keys(jsonOptions).length !== 0) {
+      if (Object.keys(jsonOptions).length === 0) {
         return text && JSON.parse(text);
       }
       return text && utils.parseJSON(text, jsonOptions);
diff --git a/src/dryrun.ts b/src/dryrun.ts
index a3feab3..5b25975 100644
--- a/src/dryrun.ts
+++ b/src/dryrun.ts
@@ -16,6 +16,7 @@ const defaultAppId = 1380011588;
 interface AppParamsWithPrograms {
   ['approval-program']: string | Uint8Array;
   ['clear-state-program']: string | Uint8Array;
+  ['creator']: string;
 }
 
 interface AppWithAppParams {
@@ -131,9 +132,11 @@ export async function createDryrun({
         .then((appInfo) => {
           const ai = decodePrograms(appInfo as AppWithAppParams);
           appInfos.push(ai);
+          accts.push(ai.params.creator);
         })
     );
   }
+  await Promise.all(appPromises);
 
   const acctPromises = [];
   for (const acct of [...new Set(accts)]) {
@@ -152,7 +155,7 @@ export async function createDryrun({
         })
     );
   }
-  await Promise.all([...appPromises, ...acctPromises]);
+  await Promise.all(acctPromises);
 
   return new DryrunRequest({
     txns: txns.map((st) => ({ ...st, txn: st.txn.get_obj_for_encoding() })),
diff --git a/src/transaction.ts b/src/transaction.ts
index 55e4f16..37035a3 100644
--- a/src/transaction.ts
+++ b/src/transaction.ts
@@ -251,7 +251,9 @@ export class Transaction implements TransactionStorageStructure {
       ) ||
         txn.amount < 0)
     )
-      throw Error('Amount must be a positive number and smaller than 2^64-1');
+      throw Error(
+        'Amount must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'
+      );
     if (!Number.isSafeInteger(txn.fee) || txn.fee < 0)
       throw Error('fee must be a positive number and smaller than 2^53-1');
     if (!Number.isSafeInteger(txn.firstRound) || txn.firstRound < 0)
@@ -275,7 +277,7 @@ export class Transaction implements TransactionStorageStructure {
         txn.assetTotal < 0)
     )
       throw Error(
-        'Total asset issuance must be a positive number and smaller than 2^64-1'
+        'Total asset issuance must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'
       );
     if (
       txn.assetDecimals !== undefined &&


Test patch:
diff --git a/tests/5.Transaction.js b/tests/5.Transaction.js
index 48ceecb..710d16e 100644
--- a/tests/5.Transaction.js
+++ b/tests/5.Transaction.js
@@ -785,7 +785,9 @@ describe('Sign', () => {
       };
       assert.throws(
         () => new algosdk.Transaction(o),
-        new Error('Amount must be a positive number and smaller than 2^64-1')
+        new Error(
+          'Amount must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'
+        )
       );
     });
 
@@ -1152,7 +1154,7 @@ describe('Sign', () => {
       assert.throws(
         () => new algosdk.Transaction(o),
         new Error(
-          'Total asset issuance must be a positive number and smaller than 2^64-1'
+          'Total asset issuance must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'
         )
       );
     });
diff --git a/tests/9.Client.ts b/tests/9.Client.ts
index 67b1141..9c87600 100644
--- a/tests/9.Client.ts
+++ b/tests/9.Client.ts
@@ -1,6 +1,8 @@
 import assert from 'assert';
 import HTTPClient from '../src/client/client';
 import { URLTokenBaseHTTPClient } from '../src/client/urlTokenBaseHTTPClient';
+import IntDecoding from '../src/types/intDecoding';
+import * as utils from '../src/utils/utils';
 
 describe('client', () => {
   describe('url construction', () => {
@@ -33,6 +35,40 @@ describe('client', () => {
       assert.strictEqual(actual, expected);
     });
 
+    it('should encode and decode values correctly', () => {
+      const j = '{"total":18446744073709551615, "base":42}';
+
+      let options = {
+        // intDecoding: IntDecoding.DEFAULT,
+      };
+      let actual = HTTPClient.parseJSON(j, 200, options);
+      let expected = JSON.parse(j);
+      assert.strictEqual(actual.total, expected.total);
+      assert.strictEqual(typeof actual.total, 'number');
+
+      options = {
+        intDecoding: IntDecoding.BIGINT,
+      };
+      actual = HTTPClient.parseJSON(j, 200, options);
+      expected = utils.parseJSON(j, options);
+      assert.strictEqual(actual.total, expected.total);
+      assert.strictEqual(typeof actual.total, 'bigint');
+
+      options = {
+        intDecoding: IntDecoding.MIXED,
+      };
+      actual = HTTPClient.parseJSON(j, 200, options);
+      expected = utils.parseJSON(j, options);
+      assert.strictEqual(actual.total, expected.total);
+      assert.strictEqual(typeof actual.total, 'bigint');
+      assert.strictEqual(typeof actual.base, 'number');
+
+      options = {
+        intDecoding: IntDecoding.SAFE,
+      };
+      assert.throws(() => HTTPClient.parseJSON(j, 200, options), Error);
+    });
+
     it('should handle slash variations on complex paths', () => {
       const regularBase = 'https://localhost/absolute';
       const regularBaseWithFinalSlash = `${regularBase}/`;