Skip to content

Commit

Permalink
Merge branch 'release/v1.22.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
egieseke committed Oct 12, 2022
2 parents 98243e5 + e7fc2e2 commit 26affb5
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .test-env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="master"
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0

VERBOSE_HARNESS=0

# WARNING: If set to 1, new features will be LOST when downloading the test harness.
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# v1.22.0

## What's Changed

### Bugfixes

- Bug-Fix: Fix typo in documentation for `searchAccounts` `currencyGreaterThan` by @fionnachan in https://github.com/algorand/js-algorand-sdk/pull/572

### Enhancements

- REST API: Add algod block hash endpoint, add indexer block header-only param. by @winder in https://github.com/algorand/js-algorand-sdk/pull/665

**Full Changelog**: https://github.com/algorand/js-algorand-sdk/compare/v1.21.0...v1.22.0

# v1.21.0

## What's Changed
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ display-all-js-steps:
tail -n +135 tests/cucumber/steps/steps.js | grep -v '^ *//' | awk "/(Given|Then|When)/,/',/" | grep -E "\'.+\'" | sed "s/^[^']*'\([^']*\)'.*/\1/g"

harness:
./test-harness.sh
./test-harness.sh up

harness-down:
./test-harness.sh down

docker-build:
docker build -t js-sdk-testing -f tests/cucumber/docker/Dockerfile $(CURDIR) --build-arg TEST_BROWSER --build-arg CI=true
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Include a minified browser bundle directly in your HTML like so:

```html
<script
src="https://unpkg.com/algosdk@v1.21.0/dist/browser/algosdk.min.js"
integrity="sha384-MBUb3pc2VI86j87sLfTwm1kEs2PUDCOFXnXdgspn0lWSJOxr1gu4mZL6L7VE1ITH"
src="https://unpkg.com/algosdk@v1.22.0/dist/browser/algosdk.min.js"
integrity="sha384-aaglDMEDVV2T87uL5d+owspnKKBeMdfGkVCXBbSCN9YeCG4FTAQ7X5YhYzJcAX8Q"
crossorigin="anonymous"
></script>
```
Expand All @@ -32,8 +32,8 @@ or

```html
<script
src="https://cdn.jsdelivr.net/npm/algosdk@v1.21.0/dist/browser/algosdk.min.js"
integrity="sha384-MBUb3pc2VI86j87sLfTwm1kEs2PUDCOFXnXdgspn0lWSJOxr1gu4mZL6L7VE1ITH"
src="https://cdn.jsdelivr.net/npm/algosdk@v1.22.0/dist/browser/algosdk.min.js"
integrity="sha384-aaglDMEDVV2T87uL5d+owspnKKBeMdfGkVCXBbSCN9YeCG4FTAQ7X5YhYzJcAX8Q"
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.21.0",
"version": "1.22.0",
"description": "The official JavaScript SDK for Algorand",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
18 changes: 18 additions & 0 deletions src/client/v2/algod/algod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Dryrun from './dryrun';
import Genesis from './genesis';
import GetAssetByID from './getAssetByID';
import GetApplicationByID from './getApplicationByID';
import GetBlockHash from './getBlockHash';
import HealthCheck from './healthCheck';
import PendingTransactionInformation from './pendingTransactionInformation';
import PendingTransactions from './pendingTransactions';
Expand Down Expand Up @@ -205,6 +206,23 @@ export default class AlgodClient extends ServiceClient {
return new Block(this.c, roundNumber);
}

/**
* Get the block hash for the block on the given round.
*
* #### Example
* ```typescript
* const roundNumber = 18038133;
* const block = await algodClient.getBlockHash(roundNumber).do();
* ```
*
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/v2/#get-v2blocksroundhash)
* @param roundNumber - The round number of the block to get.
* @category GET
*/
getBlockHash(roundNumber: number) {
return new GetBlockHash(this.c, this.intDecoding, roundNumber);
}

/**
* Returns the transaction information for a specific pending transaction.
*
Expand Down
18 changes: 18 additions & 0 deletions src/client/v2/algod/getBlockHash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import IntDecoding from '../../../types/intDecoding';

export default class GetBlockHash extends JSONRequest {
round: number;

constructor(c: HTTPClient, intDecoding: IntDecoding, roundNumber: number) {
super(c, intDecoding);
if (!Number.isInteger(roundNumber))
throw Error('roundNumber should be an integer');
this.round = roundNumber;
}

path() {
return `/v2/blocks/${this.round}/hash`;
}
}
9 changes: 9 additions & 0 deletions src/client/v2/indexer/lookupBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ export default class LookupBlock extends JSONRequest {
path() {
return `/v2/blocks/${this.round}`;
}

/**
* Header only flag. When this is set to true, returned block does not contain the
* transactions.
*/
headerOnly(headerOnly: boolean) {
this.query['header-only'] = headerOnly;
return this;
}
}
2 changes: 1 addition & 1 deletion src/client/v2/indexer/searchAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class SearchAccounts extends JSONRequest {
* .do();
* ```
* @remarks
* If you are looking for accounts with the currency amount greater than 0, simply construct the query without `currencyGreaterThan` because it doesn't accept `-1`, and passing the `0` `currency-greater-than` value would exclude transactions with a 0 amount.
* If you are looking for accounts with the currency amount greater than 0, simply construct the query without `currencyGreaterThan` because it doesn't accept `-1`, and passing the `0` `currency-greater-than` value would exclude accounts with a 0 amount.
*
* @param greater
* @category query
Expand Down
56 changes: 55 additions & 1 deletion test-harness.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
#!/usr/bin/env bash

set -euo pipefail

# test-harness.sh setup/start cucumber test environment.
#
# Configuration is managed with environment variables, the ones you
# are most likely to reconfigured are stored in '.test-env'.
#
# Variables:
# SDK_TESTING_URL - URL to algorand-sdk-testing, useful for forks.
# SDK_TESTING_BRANCH - branch to checkout, useful for new tests.
# SDK_TESTING_HARNESS - local directory that the algorand-sdk-testing repo is cloned into.
# VERBOSE_HARNESS - more output while the script runs.
# INSTALL_ONLY - installs feature files only, useful for unit tests.
#
# WARNING: If set to 1, new features will be LOST when downloading the test harness.
# REGARDLESS: modified features are ALWAYS overwritten.
# REMOVE_LOCAL_FEATURES - delete all local cucumber feature files before downloading these from github.
#
# WARNING: Be careful when turning on the next variable.
# In that case you'll need to provide all variables expected by `algorand-sdk-testing`'s `.env`
# OVERWRITE_TESTING_ENVIRONMENT=0

SHUTDOWN=0
if [ $# -ne 0 ]; then
if [ $# -ne 1 ]; then
echo "this script accepts a single argument, which must be 'up' or 'down'."
exit 1
fi

case $1 in
'up')
;; # default.
'down')
SHUTDOWN=1
;;
*)
echo "unknown parameter '$1'."
echo "this script accepts a single argument, which must be 'up' or 'down'."
exit 1
;;
esac
fi

START=$(date "+%s")

THIS=$(basename "$0")
Expand All @@ -23,10 +63,19 @@ if [ -d "$SDK_TESTING_HARNESS" ]; then
./scripts/down.sh
popd
rm -rf "$SDK_TESTING_HARNESS"
if [[ $SHUTDOWN == 1 ]]; then
echo "$THIS: network shutdown complete."
exit 0
fi
else
echo "$THIS: directory $SDK_TESTING_HARNESS does not exist - NOOP"
fi

if [[ $SHUTDOWN == 1 ]]; then
echo "$THIS: unable to shutdown network."
exit 1
fi

git clone --depth 1 --single-branch --branch "$SDK_TESTING_BRANCH" "$SDK_TESTING_URL" "$SDK_TESTING_HARNESS"


Expand All @@ -52,6 +101,11 @@ if [[ $VERBOSE_HARNESS == 1 ]]; then
fi
echo "$THIS: seconds it took to get to end of cloning and copying: $(($(date "+%s") - START))s"

if [[ $INSTALL_ONLY == 1 ]]; then
echo "$THIS: configured to install feature files only. Not starting test harness environment."
exit 0
fi

## Start test harness environment
pushd "$SDK_TESTING_HARNESS"

Expand Down
14 changes: 14 additions & 0 deletions tests/cucumber/steps/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,13 @@ module.exports = function getSteps(options) {
}
);

When(
'we make a Lookup Block call against round {int} and header {string}',
async function (int, string) {
await this.indexerClient.lookupBlock(int).headerOnly(string).do();
}
);

When(
'we make a Lookup Account by ID call against account {string} with round {int}',
async function (account, round) {
Expand Down Expand Up @@ -4417,6 +4424,13 @@ module.exports = function getSteps(options) {
await this.v2Client.getStateProof(int).do();
});

When(
'we make a Lookup Block Hash call against round {int}',
async function (int) {
await this.v2Client.getBlockHash(int).do();
}
);

Given(
'a base64 encoded program bytes for heuristic sanity check {string}',
async function (programByteStr) {
Expand Down
2 changes: 2 additions & 0 deletions tests/cucumber/unit.tags
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@unit.algod.ledger_refactoring
@unit.applications
@unit.atomic_transaction_composer
@unit.blocksummary
@unit.dryrun
@unit.dryrun.trace.application
@unit.feetest
Expand All @@ -17,6 +18,7 @@
@unit.responses.231
@unit.responses.participationupdates
@unit.responses.unlimited_assets
@unit.responses.blocksummary
@unit.sourcemap
@unit.stateproof.paths
@unit.stateproof.responses
Expand Down

0 comments on commit 26affb5

Please sign in to comment.