File tree Expand file tree Collapse file tree 3 files changed +5
-8
lines changed
Expand file tree Collapse file tree 3 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export const gloadUint64: internal.opTypes.GloadUint64Type = (
88 const txn = lazyContext . activeGroup . getTransaction ( a )
99 const result = txn . getScratchSlot ( b )
1010 if ( result instanceof internal . primitives . Uint64Cls ) {
11- return result as uint64
11+ return result . asAlgoTs ( )
1212 }
1313 throw new internal . errors . InternalError ( 'invalid scratch slot type' )
1414}
@@ -20,7 +20,7 @@ export const gloadBytes: internal.opTypes.GloadBytesType = (
2020 const txn = lazyContext . activeGroup . getTransaction ( a )
2121 const result = txn . getScratchSlot ( b )
2222 if ( result instanceof internal . primitives . BytesCls ) {
23- return result as bytes
23+ return result . asAlgoTs ( )
2424 }
2525 throw new internal . errors . InternalError ( 'invalid scratch slot type' )
2626}
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ export type ApplicationTransactionFields = TxnFields<gtxn.ApplicationTxn> &
233233 approvalProgramPages : Array < bytes >
234234 clearStateProgramPages : Array < bytes >
235235 appLogs : Array < bytes >
236- scratchSpace : Array < bytes | uint64 >
236+ scratchSpace : Record < number , bytes | uint64 >
237237 } >
238238
239239export class ApplicationTransaction extends TransactionBase implements gtxn . ApplicationTxn {
@@ -266,7 +266,7 @@ export class ApplicationTransaction extends TransactionBase implements gtxn.Appl
266266 this . #apps = fields . apps ?? [ ]
267267 this . #approvalProgramPages = fields . approvalProgramPages ?? ( fields . approvalProgram ? [ fields . approvalProgram ] : [ ] )
268268 this . #clearStateProgramPages = fields . clearStateProgramPages ?? ( fields . clearStateProgram ? [ fields . clearStateProgram ] : [ ] )
269- fields . scratchSpace ? .forEach ( ( v , i ) => this . setScratchSlot ( i , v ) )
269+ Object . entries ( fields . scratchSpace ?? { } ) . forEach ( ( [ k , v ] ) => this . setScratchSlot ( Number ( k ) , v ) )
270270 }
271271
272272 readonly appId : Application
Original file line number Diff line number Diff line change @@ -367,10 +367,7 @@ describe('State op codes', async () => {
367367 [ 3 , Uint64 ( 42 ) ] ,
368368 [ 255 , Bytes ( 'max_index' ) ] ,
369369 ] ) ( 'should return the correct field value of the scratch slot' , async ( index : number , value : bytes | uint64 ) => {
370- const newScratchSpace = Array ( 256 ) . fill ( Uint64 ( 0 ) )
371- newScratchSpace [ index ] = value
372-
373- ctx . txn . createScope ( [ ctx . any . txn . applicationCall ( { scratchSpace : newScratchSpace } ) ] ) . execute ( ( ) => { } )
370+ ctx . txn . createScope ( [ ctx . any . txn . applicationCall ( { scratchSpace : { [ index ] : value } } ) ] ) . execute ( ( ) => { } )
374371
375372 expect ( ctx . txn . lastGroup . getScratchSlot ( index ) ) . toEqual ( value )
376373
You can’t perform that action at this time.
0 commit comments