Skip to content

Commit

Permalink
Merge branch 'release/v2.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Algo-devops-service committed Aug 20, 2024
2 parents 8aaa432 + 271e0dd commit 4b0eabc
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .test-env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="V2"
SDK_TESTING_BRANCH="master"
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# v2.9.0

<!-- Release notes generated using configuration in .github/release.yml at release/v2.9.0 -->

## What's Changed

### Enhancements

- feat: add ARC22 and ARC28 interfaces for ABI contracts and methods by @joe-p in https://github.com/algorand/js-algorand-sdk/pull/856
- Algod: Regenerate models to include new simulate option by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/880
- API: Deprecate txn maker functions that will be removed in v3 by @jasonpaulos in https://github.com/algorand/js-algorand-sdk/pull/886

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

# v2.8.0

<!-- Release notes generated using configuration in .github/release.yml at release/v2.8.0 -->
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@v2.8.0/dist/browser/algosdk.min.js"
integrity="sha384-Yf0K01l2B3xzeVyU5y0g9/1cE753a/mHjarJ3l73s43RWU4t3ZCaW72qDKQXfr78"
src="https://unpkg.com/algosdk@v2.9.0/dist/browser/algosdk.min.js"
integrity="sha384-R84o0hH3cBFIzv9uqyKcDNfDi/6jgn1MrS1/tOMDWxeh8hWfOLuRoMy0LekUm2KL"
crossorigin="anonymous"
></script>
```
Expand All @@ -30,8 +30,8 @@ or

```html
<script
src="https://cdn.jsdelivr.net/npm/algosdk@v2.8.0/dist/browser/algosdk.min.js"
integrity="sha384-Yf0K01l2B3xzeVyU5y0g9/1cE753a/mHjarJ3l73s43RWU4t3ZCaW72qDKQXfr78"
src="https://cdn.jsdelivr.net/npm/algosdk@v2.9.0/dist/browser/algosdk.min.js"
integrity="sha384-R84o0hH3cBFIzv9uqyKcDNfDi/6jgn1MrS1/tOMDWxeh8hWfOLuRoMy0LekUm2KL"
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": "2.8.0",
"version": "2.9.0",
"description": "The official JavaScript SDK for Algorand",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
6 changes: 6 additions & 0 deletions src/abi/contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ABIMethod, ABIMethodParams, getMethodByName } from './method';
import { ARC28Event } from './event';

export interface ABIContractNetworkInfo {
appID: number;
Expand All @@ -13,13 +14,16 @@ export interface ABIContractParams {
desc?: string;
networks?: ABIContractNetworks;
methods: ABIMethodParams[];
events?: ARC28Event[];
}

export class ABIContract {
public readonly name: string;
public readonly description?: string;
public readonly networks: ABIContractNetworks;
public readonly methods: ABIMethod[];
/** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this contract */
public readonly events?: ARC28Event[];

constructor(params: ABIContractParams) {
if (
Expand All @@ -34,6 +38,7 @@ export class ABIContract {
this.description = params.desc;
this.networks = params.networks ? { ...params.networks } : {};
this.methods = params.methods.map((method) => new ABIMethod(method));
this.events = params.events;
}

toJSON(): ABIContractParams {
Expand All @@ -42,6 +47,7 @@ export class ABIContract {
desc: this.description,
networks: this.networks,
methods: this.methods.map((method) => method.toJSON()),
events: this.events,
};
}

Expand Down
16 changes: 16 additions & 0 deletions src/abi/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) event description */
export interface ARC28Event {
/** The name of the event */
name: string;
/** Optional, user-friendly description for the event */
desc?: string;
/** The arguments of the event, in order */
args: Array<{
/** The type of the argument */
type: string;
/** Optional, user-friendly name for the argument */
name?: string;
/** Optional, user-friendly description for the argument */
desc?: string;
}>;
}
12 changes: 12 additions & 0 deletions src/abi/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { genericHash } from '../nacl/naclWrappers';
import { ABIType, ABITupleType } from './abi_type';
import { ABITransactionType, abiTypeIsTransaction } from './transaction';
import { ABIReferenceType, abiTypeIsReference } from './reference';
import { ARC28Event } from './event';

function parseMethodSignature(
signature: string
Expand Down Expand Up @@ -61,6 +62,10 @@ export interface ABIMethodParams {
desc?: string;
args: ABIMethodArgParams[];
returns: ABIMethodReturnParams;
/** Optional, is it a read-only method (according to [ARC-22](https://arc.algorand.foundation/ARCs/arc-0022)) */
readonly?: boolean;
/** [ARC-28](https://arc.algorand.foundation/ARCs/arc-0028) events that MAY be emitted by this method */
events?: ARC28Event[];
}

export type ABIArgumentType = ABIType | ABITransactionType | ABIReferenceType;
Expand All @@ -77,6 +82,8 @@ export class ABIMethod {
}>;

public readonly returns: { type: ABIReturnType; description?: string };
public readonly events?: ARC28Event[];
public readonly readonly?: boolean;

constructor(params: ABIMethodParams) {
if (
Expand Down Expand Up @@ -111,6 +118,9 @@ export class ABIMethod {
: ABIType.from(params.returns.type),
description: params.returns.desc,
};

this.events = params.events;
this.readonly = params.readonly;
}

getSignature(): string {
Expand Down Expand Up @@ -147,6 +157,8 @@ export class ABIMethod {
type: this.returns.type.toString(),
desc: this.returns.description,
},
events: this.events,
readonly: this.readonly,
};
}

Expand Down
39 changes: 39 additions & 0 deletions src/client/v2/algod/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4284,6 +4284,12 @@ export class SimulateRequest extends BaseModel {
*/
public extraOpcodeBudget?: number | bigint;

/**
* If true, signers for transactions that are missing signatures will be fixed
* during evaluation.
*/
public fixSigners?: boolean;

/**
* If provided, specifies the round preceding the simulation. State changes through
* this round will be used to run this simulation. Usually only the 4 most recent
Expand All @@ -4301,6 +4307,8 @@ export class SimulateRequest extends BaseModel {
* @param allowUnnamedResources - Allows access to unnamed resources during simulation.
* @param execTraceConfig - An object that configures simulation execution trace.
* @param extraOpcodeBudget - Applies extra opcode budget during simulation for each transaction group.
* @param fixSigners - If true, signers for transactions that are missing signatures will be fixed
* during evaluation.
* @param round - If provided, specifies the round preceding the simulation. State changes through
* this round will be used to run this simulation. Usually only the 4 most recent
* rounds will be available (controlled by the node config value MaxAcctLookback).
Expand All @@ -4313,6 +4321,7 @@ export class SimulateRequest extends BaseModel {
allowUnnamedResources,
execTraceConfig,
extraOpcodeBudget,
fixSigners,
round,
}: {
txnGroups: SimulateRequestTransactionGroup[];
Expand All @@ -4321,6 +4330,7 @@ export class SimulateRequest extends BaseModel {
allowUnnamedResources?: boolean;
execTraceConfig?: SimulateTraceConfig;
extraOpcodeBudget?: number | bigint;
fixSigners?: boolean;
round?: number | bigint;
}) {
super();
Expand All @@ -4330,6 +4340,7 @@ export class SimulateRequest extends BaseModel {
this.allowUnnamedResources = allowUnnamedResources;
this.execTraceConfig = execTraceConfig;
this.extraOpcodeBudget = extraOpcodeBudget;
this.fixSigners = fixSigners;
this.round = round;

this.attribute_map = {
Expand All @@ -4339,6 +4350,7 @@ export class SimulateRequest extends BaseModel {
allowUnnamedResources: 'allow-unnamed-resources',
execTraceConfig: 'exec-trace-config',
extraOpcodeBudget: 'extra-opcode-budget',
fixSigners: 'fix-signers',
round: 'round',
};
}
Expand All @@ -4362,6 +4374,7 @@ export class SimulateRequest extends BaseModel {
? SimulateTraceConfig.from_obj_for_encoding(data['exec-trace-config'])
: undefined,
extraOpcodeBudget: data['extra-opcode-budget'],
fixSigners: data['fix-signers'],
round: data['round'],
});
/* eslint-enable dot-notation */
Expand Down Expand Up @@ -4751,6 +4764,12 @@ export class SimulateTransactionResult extends BaseModel {
*/
public execTrace?: SimulationTransactionExecTrace;

/**
* The account that needed to sign this transaction when no signature was provided
* and the provided signer was incorrect.
*/
public fixedSigner?: string;

/**
* Budget used during execution of a logic sig transaction.
*/
Expand All @@ -4777,6 +4796,8 @@ export class SimulateTransactionResult extends BaseModel {
* budged used by inner app calls spawned by this transaction.
* @param execTrace - The execution trace of calling an app or a logic sig, containing the inner app
* call trace in a recursive way.
* @param fixedSigner - The account that needed to sign this transaction when no signature was provided
* and the provided signer was incorrect.
* @param logicSigBudgetConsumed - Budget used during execution of a logic sig transaction.
* @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have
* caused failure, but were allowed in simulation. Depending on where this object
Expand All @@ -4792,26 +4813,30 @@ export class SimulateTransactionResult extends BaseModel {
txnResult,
appBudgetConsumed,
execTrace,
fixedSigner,
logicSigBudgetConsumed,
unnamedResourcesAccessed,
}: {
txnResult: PendingTransactionResponse;
appBudgetConsumed?: number | bigint;
execTrace?: SimulationTransactionExecTrace;
fixedSigner?: string;
logicSigBudgetConsumed?: number | bigint;
unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed;
}) {
super();
this.txnResult = txnResult;
this.appBudgetConsumed = appBudgetConsumed;
this.execTrace = execTrace;
this.fixedSigner = fixedSigner;
this.logicSigBudgetConsumed = logicSigBudgetConsumed;
this.unnamedResourcesAccessed = unnamedResourcesAccessed;

this.attribute_map = {
txnResult: 'txn-result',
appBudgetConsumed: 'app-budget-consumed',
execTrace: 'exec-trace',
fixedSigner: 'fixed-signer',
logicSigBudgetConsumed: 'logic-sig-budget-consumed',
unnamedResourcesAccessed: 'unnamed-resources-accessed',
};
Expand All @@ -4837,6 +4862,7 @@ export class SimulateTransactionResult extends BaseModel {
data['exec-trace']
)
: undefined,
fixedSigner: data['fixed-signer'],
logicSigBudgetConsumed: data['logic-sig-budget-consumed'],
unnamedResourcesAccessed:
typeof data['unnamed-resources-accessed'] !== 'undefined'
Expand Down Expand Up @@ -5006,6 +5032,12 @@ export class SimulationEvalOverrides extends BaseModel {
*/
public extraOpcodeBudget?: number | bigint;

/**
* If true, signers for transactions that are missing signatures will be fixed
* during evaluation.
*/
public fixSigners?: boolean;

/**
* The maximum log calls one can make during simulation
*/
Expand All @@ -5022,33 +5054,39 @@ export class SimulationEvalOverrides extends BaseModel {
* were properly signed.
* @param allowUnnamedResources - If true, allows access to unnamed resources during simulation.
* @param extraOpcodeBudget - The extra opcode budget added to each transaction group during simulation
* @param fixSigners - If true, signers for transactions that are missing signatures will be fixed
* during evaluation.
* @param maxLogCalls - The maximum log calls one can make during simulation
* @param maxLogSize - The maximum byte number to log during simulation
*/
constructor({
allowEmptySignatures,
allowUnnamedResources,
extraOpcodeBudget,
fixSigners,
maxLogCalls,
maxLogSize,
}: {
allowEmptySignatures?: boolean;
allowUnnamedResources?: boolean;
extraOpcodeBudget?: number | bigint;
fixSigners?: boolean;
maxLogCalls?: number | bigint;
maxLogSize?: number | bigint;
}) {
super();
this.allowEmptySignatures = allowEmptySignatures;
this.allowUnnamedResources = allowUnnamedResources;
this.extraOpcodeBudget = extraOpcodeBudget;
this.fixSigners = fixSigners;
this.maxLogCalls = maxLogCalls;
this.maxLogSize = maxLogSize;

this.attribute_map = {
allowEmptySignatures: 'allow-empty-signatures',
allowUnnamedResources: 'allow-unnamed-resources',
extraOpcodeBudget: 'extra-opcode-budget',
fixSigners: 'fix-signers',
maxLogCalls: 'max-log-calls',
maxLogSize: 'max-log-size',
};
Expand All @@ -5063,6 +5101,7 @@ export class SimulationEvalOverrides extends BaseModel {
allowEmptySignatures: data['allow-empty-signatures'],
allowUnnamedResources: data['allow-unnamed-resources'],
extraOpcodeBudget: data['extra-opcode-budget'],
fixSigners: data['fix-signers'],
maxLogCalls: data['max-log-calls'],
maxLogSize: data['max-log-size'],
});
Expand Down
Loading

0 comments on commit 4b0eabc

Please sign in to comment.