diff --git a/src/ASTBuilder.ts b/src/ASTBuilder.ts index 00caf28..e89d631 100644 --- a/src/ASTBuilder.ts +++ b/src/ASTBuilder.ts @@ -109,6 +109,11 @@ export class ASTBuilder isImmutable = true } + let isTransient = false + if (ctx.TransientKeyword_list().length > 0) { + isTransient = true + } + const decl: AST.StateVariableDeclarationVariable = { type: 'VariableDeclaration', typeName: type, @@ -120,6 +125,7 @@ export class ASTBuilder isDeclaredConst, isIndexed: false, isImmutable, + isTransient, override, storageLocation: null, } diff --git a/src/ast-types.ts b/src/ast-types.ts index d12cd73..e2db09c 100644 --- a/src/ast-types.ts +++ b/src/ast-types.ts @@ -245,6 +245,7 @@ export interface VariableDeclaration extends BaseASTNode { export interface StateVariableDeclarationVariable extends VariableDeclaration { override: null | UserDefinedTypeName[] isImmutable: boolean + isTransient: boolean } export interface ArrayTypeName extends BaseASTNode { type: 'ArrayTypeName' diff --git a/test/ast.ts b/test/ast.ts index 2d708d1..2019434 100644 --- a/test/ast.ts +++ b/test/ast.ts @@ -738,6 +738,7 @@ describe('AST', () => { isDeclaredConst: false, isIndexed: false, isImmutable: false, + isTransient: false, storageLocation: null, }, ], @@ -769,6 +770,39 @@ describe('AST', () => { isDeclaredConst: false, isIndexed: false, isImmutable: true, + isTransient: false, + storageLocation: null, + }, + ], + initialValue: null, + }) + }) + + it('StateVariableDeclaration with transient', () => { + const ast: any = parseNode('bool transient locked;') + assert.deepEqual(ast, { + type: 'StateVariableDeclaration', + variables: [ + { + type: 'VariableDeclaration', + typeName: { + type: 'ElementaryTypeName', + name: 'bool', + stateMutability: null, + }, + name: 'locked', + identifier: { + type: 'Identifier', + name: 'locked', + }, + expression: null, + visibility: 'default', + override: null, + isStateVar: true, + isDeclaredConst: false, + isIndexed: false, + isImmutable: false, + isTransient: true, storageLocation: null, }, ], @@ -832,6 +866,7 @@ describe('AST', () => { isDeclaredConst: false, isIndexed: false, isImmutable: false, + isTransient: false, storageLocation: null, }, ], @@ -905,6 +940,7 @@ describe('AST', () => { isDeclaredConst: false, isIndexed: false, isImmutable: false, + isTransient: false, storageLocation: null, }, ], @@ -1490,6 +1526,7 @@ describe('AST', () => { isIndexed: false, override: null, isImmutable: false, + isTransient: false, storageLocation: null, }) }) @@ -2751,6 +2788,7 @@ describe('AST', () => { isDeclaredConst: false, isIndexed: false, isImmutable: false, + isTransient: false, storageLocation: null, }, ],