Skip to content

Commit

Permalink
Merge branch 'release/v2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq committed Jan 27, 2023
2 parents 5eb7b4f + 3dd7813 commit 1fa884d
Show file tree
Hide file tree
Showing 56 changed files with 321 additions and 70 deletions.
22 changes: 18 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
mocha: true,
'shared-node-browser': true,
},
extends: ['airbnb-base', 'prettier', 'plugin:import/typescript'],
extends: [
'airbnb-base',
'prettier',
'plugin:import/typescript',
'eslint:recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
},
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
rules: {
'no-restricted-globals': [
'error',
{
// This is to ensure that we use the 'buffer' package in the browser. In Node it doesn't
// make a difference.
name: 'Buffer',
message:
"Explictly import Buffer with `import { Buffer } from 'buffer'`",
},
],
'no-constant-condition': ['error', { checkLoops: false }],
'no-restricted-syntax': ['error', 'LabeledStatement', 'WithStatement'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'max-classes-per-file': 'off',
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.DS_Store

.idea/
# Webstorm
*.iml
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# 2.0.0
# v2.1.0

## What's Changed

### Enhancements

- Enhancement: Add foreign array objects to ATC `addMethodCall` by @algochoi in https://github.com/algorand/js-algorand-sdk/pull/725
- API: verifyTealSign utility function by @M-Picco in https://github.com/algorand/js-algorand-sdk/pull/735
- Packaging: Don't use global `Buffer` object by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/733
- algod REST API: Add support for algod /v2/teal/disassemble by @michaeldiamant in https://github.com/algorand/js-algorand-sdk/pull/702

## New Contributors

- @M-Picco made their first contribution in https://github.com/algorand/js-algorand-sdk/pull/735

**Full Changelog**: https://github.com/algorand/js-algorand-sdk/compare/v2.0.0...v2.1.0

# v2.0.0

## What's Changed

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@v2.0.0/dist/browser/algosdk.min.js"
integrity="sha384-NBHc5NXk7w78aVp9uPMo1JmBan6l4MHxzhiKXgYT8wtBoeIMHEuu5OECfGHYTLh7"
src="https://unpkg.com/algosdk@v2.1.0/dist/browser/algosdk.min.js"
integrity="sha384-SwM9TdxjIFpIT2FUfchrQvtwi748UI0q12Zi32yd6BM8D/lCTumPhw0+BrPC0yd0"
crossorigin="anonymous"
></script>
```
Expand All @@ -32,8 +32,8 @@ or

```html
<script
src="https://cdn.jsdelivr.net/npm/algosdk@v2.0.0/dist/browser/algosdk.min.js"
integrity="sha384-NBHc5NXk7w78aVp9uPMo1JmBan6l4MHxzhiKXgYT8wtBoeIMHEuu5OECfGHYTLh7"
src="https://cdn.jsdelivr.net/npm/algosdk@v2.1.0/dist/browser/algosdk.min.js"
integrity="sha384-SwM9TdxjIFpIT2FUfchrQvtwi748UI0q12Zi32yd6BM8D/lCTumPhw0+BrPC0yd0"
crossorigin="anonymous"
></script>
```
Expand Down
1 change: 1 addition & 0 deletions examples/app_transaction_examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// makeApplicationCreateTxnFromObject, makeApplicationOptInTxnFromObject, etc.
// counterparts in your code for readability.

const { Buffer } = require('buffer');
const algosdk = require('../src');
const utils = require('./utils');

Expand Down
1 change: 1 addition & 0 deletions examples/asset_create_example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Example: creating an asset

const { Buffer } = require('buffer');
const algosdk = require('../src');
const utils = require('./utils');

Expand Down
1 change: 1 addition & 0 deletions examples/logic_sig_example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Example: creating a LogicSig transaction signed by a program that never approves the transfer.

const { Buffer } = require('buffer');
const algosdk = require('../src');
const utils = require('./utils');

Expand Down
1 change: 1 addition & 0 deletions examples/notefield_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* want in the "note" field.
*/

const { Buffer } = require('buffer');
const algosdk = require('../src');
const utils = require('./utils');

Expand Down
1 change: 1 addition & 0 deletions examples/typescript_example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Example: with TypeScript

import { Buffer } from 'buffer';
import algosdk from '../src';
import utils from './utils';

Expand Down
19 changes: 3 additions & 16 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "algosdk",
"version": "2.0.0",
"version": "2.1.0",
"description": "The official JavaScript SDK for Algorand",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand All @@ -22,7 +22,7 @@
},
"dependencies": {
"algo-msgpack-with-bigint": "^2.1.1",
"buffer": "^6.0.2",
"buffer": "^6.0.3",
"cross-fetch": "^3.1.5",
"hi-base32": "^0.5.1",
"js-sha256": "^0.9.0",
Expand All @@ -35,7 +35,6 @@
"devDependencies": {
"@types/json-bigint": "^1.0.0",
"@types/mocha": "^8.2.2",
"@types/url-parse": "^1.4.3",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"assert": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/abi/abi_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// | string
// | (T1, ..., Tn)
*/
import { Buffer } from 'buffer';
import { encodeAddress, decodeAddress } from '../encoding/address';
import { bigIntToBytes, bytesToBigInt } from '../encoding/bigint';
import { concatArrays } from '../utils/utils';
Expand Down
1 change: 1 addition & 0 deletions src/bid.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import * as address from './encoding/address';
import * as encoding from './encoding/encoding';
import * as nacl from './nacl/naclWrappers';
Expand Down
1 change: 1 addition & 0 deletions src/client/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import * as utils from '../utils/utils';
import {
BaseHTTPClient,
Expand Down
1 change: 1 addition & 0 deletions src/client/kmd.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import ServiceClient from './v2/serviceClient';
import * as txn from '../transaction';
import { CustomTokenHeader, KMDTokenHeader } from './urlTokenBaseHTTPClient';
Expand Down
1 change: 1 addition & 0 deletions src/client/urlTokenBaseHTTPClient.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import { fetch, Response, Headers } from 'cross-fetch';
import {
BaseHTTPClient,
Expand Down
17 changes: 17 additions & 0 deletions src/client/v2/algod/algod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from '../../urlTokenBaseHTTPClient';
import LightBlockHeaderProof from './lightBlockHeaderProof';
import StateProof from './stateproof';
import Disassemble from './disassemble';

/**
* Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with.
Expand Down Expand Up @@ -397,6 +398,22 @@ export default class AlgodClient extends ServiceClient {
return new Compile(this.c, source);
}

/**
* Given the program bytes, return the TEAL source code in plain text.
*
* #### Example
* ```typescript
* const bytecode = "TEAL bytecode";
* const disassembledSource = await algodClient.disassemble(bytecode).do();
* ```
*
* @remarks This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true.
* @param source
*/
disassemble(source: string | Uint8Array) {
return new Disassemble(this.c, source);
}

/**
* Provides debugging information for a transaction (or group).
*
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/algod/compile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';

Expand Down
46 changes: 46 additions & 0 deletions src/client/v2/algod/disassemble.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';

/**
* Sets the default header (if not previously set)
* @param headers - A headers object
*/
export function setHeaders(headers = {}) {
let hdrs = headers;
if (Object.keys(hdrs).every((key) => key.toLowerCase() !== 'content-type')) {
hdrs = { ...headers };
hdrs['Content-Type'] = 'text/plain';
}
return hdrs;
}

/**
* Executes disassemble
*/
export default class Disassemble extends JSONRequest {
constructor(c: HTTPClient, private source: string | Uint8Array) {
super(c);
this.source = source;
}

// eslint-disable-next-line class-methods-use-this
path() {
return `/v2/teal/disassemble`;
}

/**
* Executes disassemble
* @param headers - A headers object
*/
async do(headers = {}) {
const txHeaders = setHeaders(headers);
const res = await this.c.post(
this.path(),
Buffer.from(this.source),
txHeaders,
this.query
);
return res.body;
}
}
1 change: 1 addition & 0 deletions src/client/v2/algod/dryrun.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import * as modelsv2 from './models/types';
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/algod/getApplicationBoxByName.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import IntDecoding from '../../../types/intDecoding';
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/algod/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

/* eslint-disable no-use-before-define */
import { Buffer } from 'buffer';
import BaseModel from '../../basemodel';
import { EncodedSignedTransaction } from '../../../../types/transactions/encoded';
import BlockHeader from '../../../../types/blockHeader';
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/algod/sendRawTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import { concatArrays } from '../../../utils/utils';
Expand Down
2 changes: 2 additions & 0 deletions src/client/v2/basemodel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Buffer } from 'buffer';

/**
* Base class for models
*/
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/indexer/lookupAccountTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import IntDecoding from '../../../types/intDecoding';
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/indexer/lookupApplicationBoxByIDandName.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Buffer } from 'buffer';
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import IntDecoding from '../../../types/intDecoding';
Expand Down
1 change: 1 addition & 0 deletions src/client/v2/indexer/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

/* eslint-disable no-use-before-define */
import { Buffer } from 'buffer';
import BaseModel from '../../basemodel';

/**
Expand Down
Loading

0 comments on commit 1fa884d

Please sign in to comment.