Skip to content

Commit

Permalink
Merge pull request #75 from algorand-devrel/dev
Browse files Browse the repository at this point in the history
0.27.1
  • Loading branch information
joe-p authored Jul 13, 2023
2 parents 7ca0797 + 5c3280e commit a72bd21
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@algorandfoundation/tealscript",
"version": "0.27.0",
"version": "0.27.1",
"description": "Enables Algorand smart contract development with native TypeScript syntax, tooling, and IDE support",
"homepage": "https://github.com/algorand-devrel/TEALScript",
"bugs": {
Expand Down
12 changes: 9 additions & 3 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,12 @@ export default class Compiler {
chain.push(node);

chain.forEach((n) => {
if (ts.isElementAccessExpression(n)) {
this.processNode(n);
if (this.lastType === 'txn') this.lastType = 'gtxns';
return;
}

if (ts.isPropertyAccessExpression(n) && ['Account', 'Asset', 'Application', 'Address'].includes(n.expression.getText())) {
if (['zeroIndex', 'zeroAddress'].includes(n.name.getText())) {
this.push(n.name, 'int 0', this.getABIType(n.expression.getText()));
Expand Down Expand Up @@ -3476,13 +3482,13 @@ export default class Compiler {

private getChain(
node: ts.PropertyAccessExpression,
chain: (ts.PropertyAccessExpression | ts.CallExpression)[] = [],
): (ts.PropertyAccessExpression | ts.CallExpression)[] {
chain: (ts.PropertyAccessExpression | ts.CallExpression | ts.ElementAccessExpression)[] = [],
): (ts.PropertyAccessExpression | ts.CallExpression | ts.ElementAccessExpression)[] {
if (ts.isPropertyAccessExpression(node.expression)) {
chain.push(node.expression);
return this.getChain(node.expression, chain);
}
if (ts.isCallExpression(node.expression)) {
if (ts.isCallExpression(node.expression) || ts.isElementAccessExpression(node.expression)) {
chain.push(node.expression);
if (!ts.isPropertyAccessExpression(node.expression.expression)) throw new Error('Invalid call chain');
return this.getChain(
Expand Down
12 changes: 4 additions & 8 deletions tests/contracts/artifacts/GeneralTest.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@ abi_route_txnTypeEnum:
!=
&&
assert
byte 0x

// no dupn needed
callsub txnTypeEnum
int 1
return

txnTypeEnum:
proto 1 0
proto 0 0

// tests/contracts/general.algo.ts:6
// t = this.txnGroup[0]
// assert(this.txnGroup[0].typeEnum === TransactionType.Payment)
int 0
frame_bury -1 // t: txn

// tests/contracts/general.algo.ts:7
// assert(t.typeEnum === TransactionType.Payment)
frame_dig -1 // t: txn
gtxns TypeEnum
int pay
==
Expand Down
2 changes: 1 addition & 1 deletion tests/contracts/artifacts/GeneralTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDgKCWIgbWFpbgoKYWJpX3JvdXRlX3R4blR5cGVFbnVtOgoJdHhuIE9uQ29tcGxldGlvbgoJaW50IE5vT3AKCT09Cgl0eG4gQXBwbGljYXRpb25JRAoJaW50IDAKCSE9CgkmJgoJYXNzZXJ0CglieXRlIDB4CgljYWxsc3ViIHR4blR5cGVFbnVtCglpbnQgMQoJcmV0dXJuCgp0eG5UeXBlRW51bToKCXByb3RvIDEgMAoKCS8vIHRlc3RzL2NvbnRyYWN0cy9nZW5lcmFsLmFsZ28udHM6NgoJLy8gdCA9IHRoaXMudHhuR3JvdXBbMF0KCWludCAwCglmcmFtZV9idXJ5IC0xIC8vIHQ6IHR4bgoKCS8vIHRlc3RzL2NvbnRyYWN0cy9nZW5lcmFsLmFsZ28udHM6NwoJLy8gYXNzZXJ0KHQudHlwZUVudW0gPT09IFRyYW5zYWN0aW9uVHlwZS5QYXltZW50KQoJZnJhbWVfZGlnIC0xIC8vIHQ6IHR4bgoJZ3R4bnMgVHlwZUVudW0KCWludCBwYXkKCT09Cglhc3NlcnQKCXJldHN1YgoKbWFpbjoKCXR4biBOdW1BcHBBcmdzCglibnogcm91dGVfYWJpCgoJLy8gZGVmYXVsdCBjcmVhdGVBcHBsa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ZXJzaW9uIDgKaW50IDEKcmV0dXJu"
},
"contract": {
Expand Down
3 changes: 1 addition & 2 deletions tests/contracts/general.algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Contract } from '../../src/lib/index';
// eslint-disable-next-line no-unused-vars
class GeneralTest extends Contract {
txnTypeEnum(): void {
const t = this.txnGroup[0];
assert(t.typeEnum === TransactionType.Payment);
assert(this.txnGroup[0].typeEnum === TransactionType.Payment);
}
}

0 comments on commit a72bd21

Please sign in to comment.