diff --git a/.test-env b/.test-env
index a321a7f1e..049289d7b 100644
--- a/.test-env
+++ b/.test-env
@@ -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
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb37564c0..8bde12443 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,17 @@
+# 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
diff --git a/README.md b/README.md
index 54bfd4827..81e2d8f48 100644
--- a/README.md
+++ b/README.md
@@ -20,8 +20,8 @@ Include a minified browser bundle directly in your HTML like so:
```html
```
@@ -30,8 +30,8 @@ or
```html
```
diff --git a/package-lock.json b/package-lock.json
index f16d29e71..970294906 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "algosdk",
- "version": "2.8.0",
+ "version": "2.9.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "algosdk",
- "version": "2.8.0",
+ "version": "2.9.0",
"license": "MIT",
"dependencies": {
"algo-msgpack-with-bigint": "^2.1.1",
diff --git a/package.json b/package.json
index a316127dc..8daac89fe 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/abi/contract.ts b/src/abi/contract.ts
index d4d6236a8..2362914bc 100644
--- a/src/abi/contract.ts
+++ b/src/abi/contract.ts
@@ -1,4 +1,5 @@
import { ABIMethod, ABIMethodParams, getMethodByName } from './method';
+import { ARC28Event } from './event';
export interface ABIContractNetworkInfo {
appID: number;
@@ -13,6 +14,7 @@ export interface ABIContractParams {
desc?: string;
networks?: ABIContractNetworks;
methods: ABIMethodParams[];
+ events?: ARC28Event[];
}
export class ABIContract {
@@ -20,6 +22,8 @@ export class ABIContract {
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 (
@@ -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 {
@@ -42,6 +47,7 @@ export class ABIContract {
desc: this.description,
networks: this.networks,
methods: this.methods.map((method) => method.toJSON()),
+ events: this.events,
};
}
diff --git a/src/abi/event.ts b/src/abi/event.ts
new file mode 100644
index 000000000..0f8652607
--- /dev/null
+++ b/src/abi/event.ts
@@ -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;
+ }>;
+}
diff --git a/src/abi/method.ts b/src/abi/method.ts
index 00704efbf..709895a58 100644
--- a/src/abi/method.ts
+++ b/src/abi/method.ts
@@ -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
@@ -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;
@@ -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 (
@@ -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 {
@@ -147,6 +157,8 @@ export class ABIMethod {
type: this.returns.type.toString(),
desc: this.returns.description,
},
+ events: this.events,
+ readonly: this.readonly,
};
}
diff --git a/src/client/v2/algod/models/types.ts b/src/client/v2/algod/models/types.ts
index bff5405a5..f77a3fa48 100644
--- a/src/client/v2/algod/models/types.ts
+++ b/src/client/v2/algod/models/types.ts
@@ -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
@@ -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).
@@ -4313,6 +4321,7 @@ export class SimulateRequest extends BaseModel {
allowUnnamedResources,
execTraceConfig,
extraOpcodeBudget,
+ fixSigners,
round,
}: {
txnGroups: SimulateRequestTransactionGroup[];
@@ -4321,6 +4330,7 @@ export class SimulateRequest extends BaseModel {
allowUnnamedResources?: boolean;
execTraceConfig?: SimulateTraceConfig;
extraOpcodeBudget?: number | bigint;
+ fixSigners?: boolean;
round?: number | bigint;
}) {
super();
@@ -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 = {
@@ -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',
};
}
@@ -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 */
@@ -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.
*/
@@ -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
@@ -4792,12 +4813,14 @@ 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;
}) {
@@ -4805,6 +4828,7 @@ export class SimulateTransactionResult extends BaseModel {
this.txnResult = txnResult;
this.appBudgetConsumed = appBudgetConsumed;
this.execTrace = execTrace;
+ this.fixedSigner = fixedSigner;
this.logicSigBudgetConsumed = logicSigBudgetConsumed;
this.unnamedResourcesAccessed = unnamedResourcesAccessed;
@@ -4812,6 +4836,7 @@ export class SimulateTransactionResult extends BaseModel {
txnResult: 'txn-result',
appBudgetConsumed: 'app-budget-consumed',
execTrace: 'exec-trace',
+ fixedSigner: 'fixed-signer',
logicSigBudgetConsumed: 'logic-sig-budget-consumed',
unnamedResourcesAccessed: 'unnamed-resources-accessed',
};
@@ -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'
@@ -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
*/
@@ -5022,6 +5054,8 @@ 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
*/
@@ -5029,12 +5063,14 @@ export class SimulationEvalOverrides extends BaseModel {
allowEmptySignatures,
allowUnnamedResources,
extraOpcodeBudget,
+ fixSigners,
maxLogCalls,
maxLogSize,
}: {
allowEmptySignatures?: boolean;
allowUnnamedResources?: boolean;
extraOpcodeBudget?: number | bigint;
+ fixSigners?: boolean;
maxLogCalls?: number | bigint;
maxLogSize?: number | bigint;
}) {
@@ -5042,6 +5078,7 @@ export class SimulationEvalOverrides extends BaseModel {
this.allowEmptySignatures = allowEmptySignatures;
this.allowUnnamedResources = allowUnnamedResources;
this.extraOpcodeBudget = extraOpcodeBudget;
+ this.fixSigners = fixSigners;
this.maxLogCalls = maxLogCalls;
this.maxLogSize = maxLogSize;
@@ -5049,6 +5086,7 @@ export class SimulationEvalOverrides extends BaseModel {
allowEmptySignatures: 'allow-empty-signatures',
allowUnnamedResources: 'allow-unnamed-resources',
extraOpcodeBudget: 'extra-opcode-budget',
+ fixSigners: 'fix-signers',
maxLogCalls: 'max-log-calls',
maxLogSize: 'max-log-size',
};
@@ -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'],
});
diff --git a/src/makeTxn.ts b/src/makeTxn.ts
index 4dd08ecf1..19bbe0883 100644
--- a/src/makeTxn.ts
+++ b/src/makeTxn.ts
@@ -39,6 +39,8 @@ import { RenameProperties, RenameProperty, Expand } from './types/utils';
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makePaymentTxnWithSuggestedParamsFromObject}
*/
export function makePaymentTxnWithSuggestedParams(
from: PaymentTxn['from'],
@@ -111,6 +113,8 @@ export function makePaymentTxnWithSuggestedParamsFromObject(
* @param nonParticipation - configure whether the address wants to stop participating. If true,
* voteKey, selectionKey, voteFirst, voteLast, and voteKeyDilution must be undefined.
* @param stateProofKey - state proof key. for key deregistration, leave undefined
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeKeyRegistrationTxnWithSuggestedParamsFromObject}
*/
export function makeKeyRegistrationTxnWithSuggestedParams(
from: KeyRegistrationTxn['from'],
@@ -245,6 +249,8 @@ export function makeKeyRegistrationTxnWithSuggestedParamsFromObject(o: any) {
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeAssetCreateTxnWithSuggestedParamsFromObject}
*/
export function makeAssetCreateTxnWithSuggestedParams(
from: AssetCreateTxn['from'],
@@ -360,6 +366,8 @@ export function makeAssetCreateTxnWithSuggestedParamsFromObject(
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeAssetConfigTxnWithSuggestedParamsFromObject}
*/
export function makeAssetConfigTxnWithSuggestedParams(
from: AssetConfigTxn['from'],
@@ -456,6 +464,8 @@ export function makeAssetConfigTxnWithSuggestedParamsFromObject(
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeAssetDestroyTxnWithSuggestedParamsFromObject}
*/
export function makeAssetDestroyTxnWithSuggestedParams(
from: AssetDestroyTxn['from'],
@@ -514,6 +524,8 @@ export function makeAssetDestroyTxnWithSuggestedParamsFromObject(
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeAssetFreezeTxnWithSuggestedParamsFromObject}
*/
export function makeAssetFreezeTxnWithSuggestedParams(
from: AssetFreezeTxn['from'],
@@ -592,6 +604,8 @@ export function makeAssetFreezeTxnWithSuggestedParamsFromObject(
* genesisHash - string specifies hash genesis block of network in use
* genesisID - string specifies genesis ID of network in use
* @param rekeyTo - rekeyTo address, optional
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeAssetTransferTxnWithSuggestedParamsFromObject}
*/
export function makeAssetTransferTxnWithSuggestedParams(
from: AssetTransferTxn['from'],
@@ -682,6 +696,8 @@ export function makeAssetTransferTxnWithSuggestedParamsFromObject(
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param extraPages - integer extra pages of memory to rent on creation of application
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationCreateTxnFromObject}
*/
export function makeApplicationCreateTxn(
from: AppCreateTxn['from'],
@@ -813,6 +829,8 @@ export function makeApplicationCreateTxnFromObject(
* @param lease - Lease a transaction
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationUpdateTxnFromObject}
*/
export function makeApplicationUpdateTxn(
from: AppUpdateTxn['from'],
@@ -917,6 +935,8 @@ export function makeApplicationUpdateTxnFromObject(
* @param lease - Lease a transaction
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationDeleteTxnFromObject}
*/
export function makeApplicationDeleteTxn(
from: AppDeleteTxn['from'],
@@ -1011,6 +1031,8 @@ export function makeApplicationDeleteTxnFromObject(
* @param lease - Lease a transaction
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationOptInTxnFromObject}
*/
export function makeApplicationOptInTxn(
from: AppOptInTxn['from'],
@@ -1105,6 +1127,8 @@ export function makeApplicationOptInTxnFromObject(
* @param lease - Lease a transaction
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationCloseOutTxnFromObject}
*/
export function makeApplicationCloseOutTxn(
from: AppCloseOutTxn['from'],
@@ -1199,6 +1223,8 @@ export function makeApplicationCloseOutTxnFromObject(
* @param lease - Lease a transaction
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationClearStateTxnFromObject}
*/
export function makeApplicationClearStateTxn(
from: AppClearStateTxn['from'],
@@ -1293,6 +1319,8 @@ export function makeApplicationClearStateTxnFromObject(
* @param lease - Lease a transaction
* @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
* @param boxes - Array of BoxReference, app ID and name of box to be accessed
+ *
+ * @deprecated This function will be removed in v3 in favor of {@link makeApplicationNoOpTxnFromObject}
*/
export function makeApplicationNoOpTxn(
from: AppNoOpTxn['from'],