@@ -16,7 +16,8 @@ import {
1616import { DebugProtocol } from '@vscode/debugprotocol' ;
1717import { AvmRuntime , IRuntimeBreakpoint } from './runtime' ;
1818import { Subject } from 'await-notify' ;
19- import * as algosdk from 'algosdk' ;
19+ import type { AvmValue , AvmKeyValue } from '@algorandfoundation/algokit-utils/algod-client' ;
20+ import { bytesToHex , bytesToBase64 , encodeAddress , hexToBytes , decodeAddress } from '@algorandfoundation/algokit-utils/common' ;
2021import { FileAccessor } from './fileAccessor' ;
2122import {
2223 AvmDebuggingAssets ,
@@ -541,11 +542,11 @@ export class AvmDebugSession extends DebugSession {
541542 ) ;
542543 }
543544 } else if ( v . specificState === 'scratch' ) {
544- const expandedScratch : algosdk . modelsv2 . AvmValue [ ] = [ ] ;
545+ const expandedScratch : AvmValue [ ] = [ ] ;
545546 for ( let i = 0 ; i < 256 ; i ++ ) {
546547 expandedScratch . push (
547548 programState . scratch . get ( i ) ||
548- new algosdk . modelsv2 . AvmValue ( { type : 2 } ) ,
549+ ( { type : 2 } ) ,
549550 ) ;
550551 }
551552 if ( args . filter !== 'named' ) {
@@ -652,15 +653,15 @@ export class AvmDebugSession extends DebugSession {
652653 v . scope instanceof PuyaScope
653654 ) {
654655 const state = this . getProgramState ( v . scope . frameIndex ) ;
655- let toExpand : algosdk . modelsv2 . AvmValue | undefined ;
656+ let toExpand : AvmValue | undefined ;
656657
657658 if ( v . scope instanceof ProgramStateScope ) {
658659 if ( v . scope . specificState === 'stack' ) {
659660 toExpand = state . stack [ v . key as number ] ;
660661 } else if ( v . scope . specificState === 'scratch' ) {
661662 toExpand =
662663 state . scratch . get ( v . key as number ) ||
663- new algosdk . modelsv2 . AvmValue ( { type : 2 } ) ;
664+ ( { type : 2 } ) ;
664665 }
665666 } else if ( v . scope instanceof PuyaScope ) {
666667 const variable = state . variables . find ( ( [ name ] ) => name === v . key ) ;
@@ -677,14 +678,14 @@ export class AvmDebugSession extends DebugSession {
677678 typeof v . key === 'string' &&
678679 v . key . startsWith ( '0x' )
679680 ) {
680- let toExpand : algosdk . modelsv2 . AvmKeyValue ;
681+ let toExpand : AvmKeyValue ;
681682 const state = this . _runtime . getAppState ( v . scope . appID ) ;
682683 const keyHex = v . key . slice ( 2 ) ;
683684 if ( v . scope . scope === 'global' ) {
684685 const value = state . globalState . getHex ( keyHex ) ;
685686 if ( value ) {
686- toExpand = new algosdk . modelsv2 . AvmKeyValue ( {
687- key : algosdk . hexToBytes ( keyHex ) ,
687+ toExpand = ( {
688+ key : hexToBytes ( keyHex ) ,
688689 value,
689690 } ) ;
690691 } else {
@@ -706,16 +707,16 @@ export class AvmDebugSession extends DebugSession {
706707 `key "${ v . key } " not found in local state for account "${ v . scope . account } "` ,
707708 ) ;
708709 }
709- toExpand = new algosdk . modelsv2 . AvmKeyValue ( {
710- key : algosdk . hexToBytes ( keyHex ) ,
710+ toExpand = ( {
711+ key : hexToBytes ( keyHex ) ,
711712 value,
712713 } ) ;
713714 }
714715 } else if ( v . scope . scope === 'box' ) {
715716 const value = state . boxState . getHex ( keyHex ) ;
716717 if ( value ) {
717- toExpand = new algosdk . modelsv2 . AvmKeyValue ( {
718- key : algosdk . hexToBytes ( keyHex ) ,
718+ toExpand = ( {
719+ key : hexToBytes ( keyHex ) ,
719720 value,
720721 } ) ;
721722 } else {
@@ -857,7 +858,7 @@ export class AvmDebugSession extends DebugSession {
857858 rv = this . convertAvmValue (
858859 scopeWithFrame ,
859860 state . scratch . get ( index ) ||
860- new algosdk . modelsv2 . AvmValue ( { type : 2 } ) ,
861+ ( { type : 2 } ) ,
861862 index ,
862863 ) ;
863864 } else {
@@ -874,8 +875,8 @@ export class AvmDebugSession extends DebugSession {
874875 const keyHex = key . slice ( 2 ) ;
875876 const value = state . globalState . getHex ( keyHex ) ;
876877 if ( value ) {
877- const kv = new algosdk . modelsv2 . AvmKeyValue ( {
878- key : algosdk . hexToBytes ( keyHex ) ,
878+ const kv = ( {
879+ key : hexToBytes ( keyHex ) ,
879880 value,
880881 } ) ;
881882 rv = this . convertAvmKeyValue ( scope , kv ) ;
@@ -906,8 +907,8 @@ export class AvmDebugSession extends DebugSession {
906907 const keyHex = key . slice ( 2 ) ;
907908 const value = accountState . getHex ( keyHex ) ;
908909 if ( value ) {
909- const kv = new algosdk . modelsv2 . AvmKeyValue ( {
910- key : algosdk . hexToBytes ( keyHex ) ,
910+ const kv = ( {
911+ key : hexToBytes ( keyHex ) ,
911912 value,
912913 } ) ;
913914 rv = this . convertAvmKeyValue ( scope , kv ) ;
@@ -922,8 +923,8 @@ export class AvmDebugSession extends DebugSession {
922923 const keyHex = key . slice ( 2 ) ;
923924 const value = state . boxState . getHex ( keyHex ) ;
924925 if ( value ) {
925- const kv = new algosdk . modelsv2 . AvmKeyValue ( {
926- key : algosdk . hexToBytes ( keyHex ) ,
926+ const kv = ( {
927+ key : hexToBytes ( keyHex ) ,
927928 value,
928929 } ) ;
929930 rv = this . convertAvmKeyValue ( scope , kv ) ;
@@ -1064,7 +1065,7 @@ export class AvmDebugSession extends DebugSession {
10641065
10651066 private convertAvmValue (
10661067 scope : AvmValueScope | PuyaScope ,
1067- avmValue : algosdk . modelsv2 . AvmValue ,
1068+ avmValue : AvmValue ,
10681069 key : number | string ,
10691070 overrideVariableReference ?: boolean ,
10701071 ) : DebugProtocol . Variable {
@@ -1118,7 +1119,7 @@ export class AvmDebugSession extends DebugSession {
11181119 }
11191120
11201121 private expandAvmValue (
1121- avmValue : algosdk . modelsv2 . AvmValue ,
1122+ avmValue : AvmValue ,
11221123 filter ?: DebugProtocol . VariablesArguments [ 'filter' ] ,
11231124 ) : DebugProtocol . Variable [ ] {
11241125 // uint64 has no expanded variables
@@ -1133,14 +1134,14 @@ export class AvmDebugSession extends DebugSession {
11331134 values . push ( {
11341135 name : 'hex' ,
11351136 type : 'string' ,
1136- value : algosdk . bytesToHex ( bytes ) ,
1137+ value : bytesToHex ( bytes ) ,
11371138 variablesReference : 0 ,
11381139 } ) ;
11391140
11401141 values . push ( {
11411142 name : 'base64' ,
11421143 type : 'string' ,
1143- value : algosdk . bytesToBase64 ( bytes ) ,
1144+ value : bytesToBase64 ( bytes ) ,
11441145 variablesReference : 0 ,
11451146 } ) ;
11461147
@@ -1158,7 +1159,7 @@ export class AvmDebugSession extends DebugSession {
11581159 values . push ( {
11591160 name : 'address' ,
11601161 type : 'string' ,
1161- value : algosdk . encodeAddress ( bytes ) ,
1162+ value : encodeAddress ( bytes ) ,
11621163 variablesReference : 0 ,
11631164 } ) ;
11641165 }
@@ -1187,10 +1188,10 @@ export class AvmDebugSession extends DebugSession {
11871188
11881189 private convertAvmKeyValue (
11891190 scope : AvmValueScope ,
1190- avmKeyValue : algosdk . modelsv2 . AvmKeyValue ,
1191+ avmKeyValue : AvmKeyValue ,
11911192 ) : DebugProtocol . Variable {
11921193 const keyString =
1193- '0x' + algosdk . bytesToHex ( avmKeyValue . key || new Uint8Array ( ) ) ;
1194+ '0x' + bytesToHex ( avmKeyValue . key || new Uint8Array ( ) ) ;
11941195 const value = this . convertAvmValue (
11951196 scope ,
11961197 avmKeyValue . value ,
@@ -1204,15 +1205,15 @@ export class AvmDebugSession extends DebugSession {
12041205
12051206 private expandAvmKeyValue (
12061207 scope : AppSpecificStateScope ,
1207- avmKeyValue : algosdk . modelsv2 . AvmKeyValue ,
1208+ avmKeyValue : AvmKeyValue ,
12081209 filter ?: DebugProtocol . VariablesArguments [ 'filter' ] ,
12091210 ) : DebugProtocol . Variable [ ] {
12101211 if ( typeof scope . property === 'undefined' ) {
12111212 if ( filter === 'indexed' ) {
12121213 return [ ] ;
12131214 }
12141215 const keyString =
1215- '0x' + algosdk . bytesToHex ( avmKeyValue . key || new Uint8Array ( ) ) ;
1216+ '0x' + bytesToHex ( avmKeyValue . key || new Uint8Array ( ) ) ;
12161217 const keyScope = new AppSpecificStateScope ( {
12171218 scope : scope . scope ,
12181219 appID : scope . appID ,
@@ -1227,7 +1228,7 @@ export class AvmDebugSession extends DebugSession {
12271228 } ) ;
12281229 const keyVariable = this . convertAvmValue (
12291230 keyScope ,
1230- new algosdk . modelsv2 . AvmValue ( { type : 1 , bytes : avmKeyValue . key } ) ,
1231+ ( { type : 1 , bytes : avmKeyValue . key } ) ,
12311232 '' ,
12321233 false ,
12331234 ) ;
@@ -1270,7 +1271,7 @@ export class AvmDebugSession extends DebugSession {
12701271 }
12711272
12721273 if ( scope . property === 'key' ) {
1273- const avmKey = new algosdk . modelsv2 . AvmValue ( {
1274+ const avmKey = ( {
12741275 type : 1 ,
12751276 bytes : avmKeyValue . key ,
12761277 } ) ;
@@ -1280,11 +1281,11 @@ export class AvmDebugSession extends DebugSession {
12801281 return this . expandAvmValue ( avmKeyValue . value , filter ) ;
12811282 }
12821283
1283- private avmValueToString ( avmValue : algosdk . modelsv2 . AvmValue ) : string {
1284+ private avmValueToString ( avmValue : AvmValue ) : string {
12841285 if ( avmValue . type === 1 ) {
12851286 // byte array
12861287 const bytes = avmValue . bytes || new Uint8Array ( ) ;
1287- return '0x' + algosdk . bytesToHex ( bytes ) ;
1288+ return '0x' + bytesToHex ( bytes ) ;
12881289 }
12891290 // uint64
12901291 const uint = avmValue . uint || 0 ;
@@ -1436,7 +1437,7 @@ function evaluateNameToScope(name: string): [AvmValueScope, number | string] {
14361437 throw new Error ( `Unexpected app property: ${ property } ` ) ;
14371438 }
14381439 try {
1439- algosdk . decodeAddress ( appLocalMatches [ 2 ] ) ; // ensure valid address
1440+ decodeAddress ( appLocalMatches [ 2 ] ) ; // ensure valid address
14401441 } catch {
14411442 throw new Error ( `Invalid address: ${ appLocalMatches [ 2 ] } :` ) ;
14421443 }
0 commit comments