Skip to content

Commit

Permalink
Merge branch 'release/v3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Algo-devops-service committed Sep 12, 2024
2 parents 4b0eabc + 6973ff5 commit 7759197
Show file tree
Hide file tree
Showing 187 changed files with 30,331 additions and 22,738 deletions.
19 changes: 9 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ module.exports = {
},
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 }],
Expand Down Expand Up @@ -68,4 +58,13 @@ module.exports = {
'tests/cucumber/browser/build/',
'tests/browser/bundle.*',
],
settings: {
'import/resolver': {
typescript: {
extensionAlias: {
'.js': ['.ts', '.d.ts', '.js'],
},
},
},
},
};
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/client/v2/algod/models/types.ts linguist-generated=true
src/client/v2/indexer/models/types.ts linguist-generated=true
5 changes: 3 additions & 2 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ jobs:
id: build-changelog
env:
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
CHANGELOG=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \
-d '{"tag_name":"${{ env.RELEASE_VERSION }}","target_commitish":"${{ env.RELEASE_BRANCH }}","previous_tag_name":"${{ env.PREVIOUS_VERSION }}","configuration_file_path":".github/release.yml"}' \
-d '{"tag_name":"${{ env.RELEASE_TAG }}","target_commitish":"${{ env.RELEASE_BRANCH }}","previous_tag_name":"${{ env.PREVIOUS_VERSION }}","configuration_file_path":".github/release.yml"}' \
| jq -r '.body')
# The EOF steps are used to save multiline string in github:
Expand All @@ -115,7 +116,7 @@ jobs:
env:
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
rm -rf dist node_modules
rm -rf node_modules
npm ci
npm run build
NEW_HASH=$(cat dist/browser/algosdk.min.js | openssl dgst -sha384 -binary | openssl base64 -A)
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
dist/*
!dist/esm
dist/esm/*
!dist/esm/package.json

.DS_Store

.idea/
Expand All @@ -6,6 +11,7 @@
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
!.vscode/launch.json

# npm
node_modules/
Expand All @@ -23,7 +29,6 @@ tests/cucumber/browser/build
tests/browser/bundle.*

# Builds
dist/
docs/
built/

Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug unit tests",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/tests/mocha.js",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/tsx",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"NODE_ENV": "testing",
"MOCHA_TIMEOUT": "0"
},
"skipFiles": [
// Node.js internal core modules
"<node_internals>/**",
// Ignore all dependencies (optional)
"${workspaceFolder}/node_modules/**"
]
}
]
}
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# v3.0.0

<!-- Release notes generated using configuration in .github/release.yml at 3.0.0 **WITH MANUAL EDITING AFTERWARD** -->

## What's Changed

> ⚠️ **WARNING:** This release is a new major version with breaking changes from the v2.X.X series. For help migrating from v2 releases, see the file `v2_TO_v3_MIGRATION_GUIDE.md`.
### v2 End of Life

With the release of v3 of this SDK, v2 is now in maintenance mode. No new features will be added to v2, and only security fixes or critical errors will be addressed. At the end of March 2025, no further updates will be made to the v2 package.

### Breaking Changes

- Convert algod responses to typed by @Eric-Warehime in https://github.com/algorand/js-algorand-sdk/pull/776
- Align transaction fields to transaction reference spec by @algochoi in https://github.com/algorand/js-algorand-sdk/pull/804
- TEAL Source Map: Improve SourceMap and support columns by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/834
- Remove `IntDecoding` as a REST option & support native bigint types in models by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/852
- Refactor `Transaction` class by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/854
- Improve object encoding and decoding by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/862
- Correctly model blocks by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/875
- Fix stateproof txn representation by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/876
- Typed indexer responses by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/857
- Support special case raw binary strings by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/878
- REST API TEAL bytes fix by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/881
- Fix remaining REST untyped responses by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/882

### Enhancements

- Remove buffer usage in favor or Uint8Array and Dataview by @algochoi in https://github.com/algorand/js-algorand-sdk/pull/800
- Remove `Buffer` Usage by @algochoi in https://github.com/algorand/js-algorand-sdk/pull/801
- Add address bytes length check in encodeAddress by @algochoi in https://github.com/algorand/js-algorand-sdk/pull/809
- Native esm bundle by @PhearZero in https://github.com/algorand/js-algorand-sdk/pull/836
- Add ability to pass through fetch options by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/883
- REST API: Allow bigints for client args by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/893

### Bugfixes

- Fix: Don't delete `dist` folder when creating release PR by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/890
- Release PR Generation: Use prerelease tag in changelog generation by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/892

### Other

- Type and formatting changes by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/853
- 3.0.0: Sync changes to develop by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/884

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

# v2.9.0

<!-- Release notes generated using configuration in .github/release.yml at release/v2.9.0 -->
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ UNIT_TAGS := "$(subst :, or ,$(shell awk '{print $2}' tests/cucumber/unit.tags
INTEGRATIONS_TAGS := "$(subst :, or ,$(shell awk '{print $2}' tests/cucumber/integration.tags | paste -s -d: -))"

unit:
node_modules/.bin/cucumber-js --tags $(UNIT_TAGS) tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js
node_modules/.bin/cucumber-js --tags $(UNIT_TAGS) tests/cucumber/features --require-module tsx/cjs --require tests/cucumber/steps/index.js

integration:
node_modules/.bin/cucumber-js --tags $(INTEGRATIONS_TAGS) tests/cucumber/features --require-module ts-node/register --require tests/cucumber/steps/index.js
node_modules/.bin/cucumber-js --tags $(INTEGRATIONS_TAGS) tests/cucumber/features --require-module tsx/cjs --require tests/cucumber/steps/index.js

# The following assumes that all cucumber steps are defined in `./tests/cucumber/steps/steps.js` and begin past line 135 of that file.
# Please note any deviations of the above before presuming correctness.
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

AlgoSDK is the official JavaScript library for communicating with the Algorand network. It's designed for modern browsers and Node.js.

## New Major Version 3

Existing codebases using v2 of this library will be incompatible with v3. The v3 release introduces breaking changes to the API, and a migration guide is available [here](v2_TO_v3_MIGRATION_GUIDE.md).

## Installation

### [Node.js](https://nodejs.org/en/download/)
Expand All @@ -20,8 +24,8 @@ Include a minified browser bundle directly in your HTML like so:

```html
<script
src="https://unpkg.com/algosdk@v2.9.0/dist/browser/algosdk.min.js"
integrity="sha384-R84o0hH3cBFIzv9uqyKcDNfDi/6jgn1MrS1/tOMDWxeh8hWfOLuRoMy0LekUm2KL"
src="https://unpkg.com/algosdk@v3.0.0/dist/browser/algosdk.min.js"
integrity="sha384-EdTN548g1VApyPivwjhxg5HpPLY6nzw58f8nbvmc89M8fO8eBor+KHzf17y1SWl3"
crossorigin="anonymous"
></script>
```
Expand All @@ -30,8 +34,8 @@ or

```html
<script
src="https://cdn.jsdelivr.net/npm/algosdk@v2.9.0/dist/browser/algosdk.min.js"
integrity="sha384-R84o0hH3cBFIzv9uqyKcDNfDi/6jgn1MrS1/tOMDWxeh8hWfOLuRoMy0LekUm2KL"
src="https://cdn.jsdelivr.net/npm/algosdk@v3.0.0/dist/browser/algosdk.min.js"
integrity="sha384-EdTN548g1VApyPivwjhxg5HpPLY6nzw58f8nbvmc89M8fO8eBor+KHzf17y1SWl3"
crossorigin="anonymous"
></script>
```
Expand Down
1 change: 1 addition & 0 deletions dist/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "module"}
38 changes: 21 additions & 17 deletions examples/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function main() {
const mnemonic =
'creek phrase island true then hope employ veteran rapid hurdle above liberty tissue connect alcohol timber idle ten frog bulb embody crunch taxi abstract month';
const recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic);
console.log('Recovered mnemonic account: ', recoveredAccount.addr);
console.log('Recovered mnemonic account: ', recoveredAccount.addr.toString());
// example: ACCOUNT_RECOVER_MNEMONIC

const funder = accounts[0];
Expand All @@ -31,30 +31,30 @@ async function main() {
signerAccounts.push(algosdk.generateAccount());

// multiSigParams is used when creating the address and when signing transactions
const multiSigParams = {
const multiSigParams: algosdk.MultisigMetadata = {
version: 1,
threshold: 2,
addrs: signerAccounts.map((a) => a.addr),
};
const multisigAddr = algosdk.multisigAddress(multiSigParams);

console.log('Created MultiSig Address: ', multisigAddr);
console.log('Created MultiSig Address: ', multisigAddr.toString());
// example: MULTISIG_CREATE

const fundMsigTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: funder.addr,
to: multisigAddr,
sender: funder.addr,
receiver: multisigAddr,
amount: 1_000_000,
suggestedParams,
});

await client.sendRawTransaction(fundMsigTxn.signTxn(funder.privateKey)).do();
await algosdk.waitForConfirmation(client, fundMsigTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, fundMsigTxn.txID(), 3);

// example: MULTISIG_SIGN
const msigTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: multisigAddr,
to: funder.addr,
sender: multisigAddr,
receiver: funder.addr,
amount: 100,
suggestedParams,
});
Expand All @@ -74,46 +74,50 @@ async function main() {
).blob;

await client.sendRawTransaction(msigWithSecondSig).do();
await algosdk.waitForConfirmation(client, msigTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, msigTxn.txID(), 3);
// example: MULTISIG_SIGN

// example: ACCOUNT_GENERATE
const generatedAccount = algosdk.generateAccount();
const passphrase = algosdk.secretKeyToMnemonic(generatedAccount.sk);
console.log(`My address: ${generatedAccount.addr}`);
console.log(`My address: ${generatedAccount.addr.toString()}`);
console.log(`My passphrase: ${passphrase}`);
// example: ACCOUNT_GENERATE

// example: ACCOUNT_REKEY
// rekey the original account to the new signer via a payment transaction
// Note any transaction type can be used to rekey an account
const rekeyTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: acct1.addr,
to: acct1.addr,
sender: acct1.addr,
receiver: acct1.addr,
amount: 0,
suggestedParams,
rekeyTo: acct2.addr, // set the rekeyTo field to the new signer
});

await client.sendRawTransaction(rekeyTxn.signTxn(acct1.privateKey)).do();
await algosdk.waitForConfirmation(client, rekeyTxn.txID().toString(), 3);
await algosdk.waitForConfirmation(client, rekeyTxn.txID(), 3);

const acctInfo = await client.accountInformation(acct1.addr).do();

console.log(`Account Info: ${acctInfo} Auth Addr: ${acctInfo['auth-addr']}`);
console.log(
`Account Info: ${algosdk.stringifyJSON(acctInfo)} Auth Addr: ${
acctInfo['auth-addr']
}`
);
// example: ACCOUNT_REKEY

// the transaction is from originalAccount, but signed with newSigner private key

const rekeyBack = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: acct1.addr,
to: acct1.addr,
sender: acct1.addr,
receiver: acct1.addr,
amount: 0,
suggestedParams,
rekeyTo: acct1.addr,
});
await client.sendRawTransaction(rekeyBack.signTxn(acct2.privateKey)).do();
await algosdk.waitForConfirmation(client, rekeyBack.txID().toString(), 3);
await algosdk.waitForConfirmation(client, rekeyBack.txID(), 3);
}

main();
Loading

0 comments on commit 7759197

Please sign in to comment.