Skip to content

Commit

Permalink
Merge branch 'release/v1.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
onetechnical committed Jan 26, 2022
2 parents 5f8097f + 51ec2aa commit fb0d633
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 15 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
```
Expand All @@ -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>
```
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/dryrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const defaultAppId = 1380011588;
interface AppParamsWithPrograms {
['approval-program']: string | Uint8Array;
['clear-state-program']: string | Uint8Array;
['creator']: string;
}

interface AppWithAppParams {
Expand Down Expand Up @@ -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)]) {
Expand All @@ -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() })),
Expand Down
6 changes: 4 additions & 2 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 &&
Expand Down
6 changes: 4 additions & 2 deletions tests/5.Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
)
);
});

Expand Down Expand Up @@ -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.'
)
);
});
Expand Down
36 changes: 36 additions & 0 deletions tests/9.Client.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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}/`;
Expand Down

0 comments on commit fb0d633

Please sign in to comment.