Skip to content

Commit

Permalink
Merge branch 'release/v1.11.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
algobarb committed Aug 20, 2021
2 parents 9afe012 + 0be9a15 commit 51df7ec
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.11.1

## Fixed

- Properly decode transaction extra pages field (#419)

# 1.11.0

## Added
Expand Down
2 changes: 1 addition & 1 deletion 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.11.0",
"version": "1.11.1",
"description": "The official JavaScript SDK for Algorand",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
48 changes: 48 additions & 0 deletions src/client/v2/algod/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,8 @@ export class DryrunTxnResult extends BaseModel {

public logicSigTrace?: DryrunState[];

public logs?: LogItem[];

/**
* Creates a new `DryrunTxnResult` object.
* @param disassembly - Disassembled program line by line.
Expand All @@ -1263,6 +1265,7 @@ export class DryrunTxnResult extends BaseModel {
* @param localDeltas -
* @param logicSigMessages -
* @param logicSigTrace -
* @param logs -
*/
constructor({
disassembly,
Expand All @@ -1272,6 +1275,7 @@ export class DryrunTxnResult extends BaseModel {
localDeltas,
logicSigMessages,
logicSigTrace,
logs,
}: {
disassembly: string[];
appCallMessages?: string[];
Expand All @@ -1280,6 +1284,7 @@ export class DryrunTxnResult extends BaseModel {
localDeltas?: AccountStateDelta[];
logicSigMessages?: string[];
logicSigTrace?: DryrunState[];
logs?: LogItem[];
}) {
super();
this.disassembly = disassembly;
Expand All @@ -1289,6 +1294,7 @@ export class DryrunTxnResult extends BaseModel {
this.localDeltas = localDeltas;
this.logicSigMessages = logicSigMessages;
this.logicSigTrace = logicSigTrace;
this.logs = logs;

this.attribute_map = {
disassembly: 'disassembly',
Expand All @@ -1298,6 +1304,7 @@ export class DryrunTxnResult extends BaseModel {
localDeltas: 'local-deltas',
logicSigMessages: 'logic-sig-messages',
logicSigTrace: 'logic-sig-trace',
logs: 'logs',
};
}
}
Expand Down Expand Up @@ -1394,6 +1401,37 @@ export class EvalDeltaKeyValue extends BaseModel {
}
}

/**
* Application Log
*/
export class LogItem extends BaseModel {
/**
* unique application identifier
*/
public id: number | bigint;

/**
* base64 encoded log message
*/
public value: string;

/**
* Creates a new `LogItem` object.
* @param id - unique application identifier
* @param value - base64 encoded log message
*/
constructor(id: number | bigint, value: string) {
super();
this.id = id;
this.value = value;

this.attribute_map = {
id: 'id',
value: 'value',
};
}
}

/**
*
*/
Expand Down Expand Up @@ -1639,6 +1677,11 @@ export class PendingTransactionResponse extends BaseModel {
*/
public localStateDelta?: AccountStateDelta[];

/**
* (lg) Logs for the application being executed by this transaction.
*/
public logs?: LogItem[];

/**
* Rewards in microalgos applied to the receiver account.
*/
Expand Down Expand Up @@ -1666,6 +1709,7 @@ export class PendingTransactionResponse extends BaseModel {
* transaction.
* @param localStateDelta - (ld) Local state key/value changes for the application being executed by this
* transaction.
* @param logs - (lg) Logs for the application being executed by this transaction.
* @param receiverRewards - Rewards in microalgos applied to the receiver account.
* @param senderRewards - Rewards in microalgos applied to the sender account.
*/
Expand All @@ -1680,6 +1724,7 @@ export class PendingTransactionResponse extends BaseModel {
confirmedRound,
globalStateDelta,
localStateDelta,
logs,
receiverRewards,
senderRewards,
}: {
Expand All @@ -1693,6 +1738,7 @@ export class PendingTransactionResponse extends BaseModel {
confirmedRound?: number | bigint;
globalStateDelta?: EvalDeltaKeyValue[];
localStateDelta?: AccountStateDelta[];
logs?: LogItem[];
receiverRewards?: number | bigint;
senderRewards?: number | bigint;
}) {
Expand All @@ -1707,6 +1753,7 @@ export class PendingTransactionResponse extends BaseModel {
this.confirmedRound = confirmedRound;
this.globalStateDelta = globalStateDelta;
this.localStateDelta = localStateDelta;
this.logs = logs;
this.receiverRewards = receiverRewards;
this.senderRewards = senderRewards;

Expand All @@ -1721,6 +1768,7 @@ export class PendingTransactionResponse extends BaseModel {
confirmedRound: 'confirmed-round',
globalStateDelta: 'global-state-delta',
localStateDelta: 'local-state-delta',
logs: 'logs',
receiverRewards: 'receiver-rewards',
senderRewards: 'sender-rewards',
};
Expand Down
3 changes: 3 additions & 0 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ export class Transaction implements TransactionStorageStructure {
if (txnForEnc.apgs.nbs !== undefined)
txn.appGlobalByteSlices = txnForEnc.apgs.nbs;
}
if (txnForEnc.apep !== undefined) {
txn.extraPages = txnForEnc.apep;
}
if (txnForEnc.apap !== undefined) {
txn.appApprovalProgram = new Uint8Array(txnForEnc.apap);
}
Expand Down
36 changes: 36 additions & 0 deletions tests/5.Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,42 @@ describe('Sign', () => {
assert.deepStrictEqual(reencRep, encRep);
});

it('should correctly serialize and deserialize an application create transaction from msgpack representation', () => {
const expectedTxn = algosdk.makeApplicationCreateTxnFromObject({
from: 'BH55E5RMBD4GYWXGX5W5PJ5JAHPGM5OXKDQH5DC4O2MGI7NW4H6VOE4CP4',
approvalProgram: Uint8Array.from([1, 32, 1, 1, 34]),
clearProgram: Uint8Array.from([2, 32, 1, 1, 34]),
numGlobalInts: 1,
numGlobalByteSlices: 2,
numLocalInts: 3,
numLocalByteSlices: 4,
onComplete: algosdk.OnApplicationComplete.OptInOC,
accounts: [
'XMHLMNAVJIMAW2RHJXLXKKK4G3J3U6VONNO3BTAQYVDC3MHTGDP3J5OCRU',
],
appArgs: [Uint8Array.from([0]), Uint8Array.from([1, 2])],
extraPages: 2,
foreignApps: [3, 4],
foreignAssets: [5, 6],
lease: Uint8Array.from(new Array(32).fill(7)),
note: new Uint8Array(Buffer.from('note value')),
rekeyTo: 'UCE2U2JC4O4ZR6W763GUQCG57HQCDZEUJY4J5I6VYY4HQZUJDF7AKZO5GM',
suggestedParams: {
fee: 0,
firstRound: 322575,
lastRound: 323575,
genesisID: 'testnet-v1.0',
genesisHash: 'SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=',
},
});
const encRep = expectedTxn.get_obj_for_encoding();
const encTxn = algosdk.encodeObj(encRep);
const decEncRep = algosdk.decodeObj(encTxn);
const decTxn = algosdk.Transaction.from_obj_for_encoding(decEncRep);
const reencRep = decTxn.get_obj_for_encoding();
assert.deepStrictEqual(reencRep, encRep);
});

it('should correctly serialize and deserialize an asset freeze transaction from msgpack representation', () => {
const address =
'BH55E5RMBD4GYWXGX5W5PJ5JAHPGM5OXKDQH5DC4O2MGI7NW4H6VOE4CP4';
Expand Down

0 comments on commit 51df7ec

Please sign in to comment.