@@ -16,6 +16,7 @@ import { AppInterfaceEntity, dbConnectionAtom } from '@/features/common/data/ind
1616import { upsertAppInterface } from '@/features/app-interfaces/data'
1717import { getTestStore } from '@/tests/utils/get-test-store'
1818import { DecodedAbiType } from '@/features/abi-methods/models'
19+ import Arc32TestContractAppSpec from '@/tests/test-app-specs/test-contract.arc32.json'
1920
2021describe ( 'resolving ABI method' , ( ) => {
2122 describe ( 'for an app call with referenced asset' , ( ) => {
@@ -27,7 +28,7 @@ describe('resolving ABI method', () => {
2728 myStore . set ( transactionResultsAtom , new Map ( [ [ transaction . id , createReadOnlyAtomAndTimestamp ( transaction ) ] ] ) )
2829 myStore . set ( assetResultsAtom , new Map ( [ [ asset . index , createReadOnlyAtomAndTimestamp ( asset ) ] ] ) )
2930
30- const applicationId = transaction [ 'application-transaction' ] ! [ 'application-id' ] !
31+ const applicationId = transaction . applicationTransaction ! . applicationId !
3132 const dbConnection = await myStore . get ( dbConnectionAtom )
3233 await upsertAppInterface ( dbConnection , {
3334 applicationId : applicationId ,
@@ -48,7 +49,7 @@ describe('resolving ABI method', () => {
4849 {
4950 name : 'asset' ,
5051 type : DecodedAbiType . Asset ,
51- value : 705457144 ,
52+ value : 705457144n ,
5253 length : 9 ,
5354 multiline : false ,
5455 } ,
@@ -61,7 +62,7 @@ describe('resolving ABI method', () => {
6162 myStore . set ( transactionResultsAtom , new Map ( [ [ transaction . id , createReadOnlyAtomAndTimestamp ( transaction ) ] ] ) )
6263 myStore . set ( assetResultsAtom , new Map ( [ [ asset . index , createReadOnlyAtomAndTimestamp ( asset ) ] ] ) )
6364
64- const applicationId = transaction [ 'application-transaction' ] ! [ 'application-id' ] !
65+ const applicationId = transaction . applicationTransaction ! . applicationId !
6566 const dbConnection = await myStore . get ( dbConnectionAtom )
6667 await upsertAppInterface ( dbConnection , {
6768 applicationId : applicationId ,
@@ -82,7 +83,7 @@ describe('resolving ABI method', () => {
8283 {
8384 name : 'asset' ,
8485 type : DecodedAbiType . Asset ,
85- value : 705457144 ,
86+ value : 705457144n ,
8687 length : 9 ,
8788 multiline : false ,
8889 } ,
@@ -97,15 +98,15 @@ describe('resolving ABI method', () => {
9798 const group = groupResultMother
9899 . groupWithTransactions ( [ axferTransaction , appCallTransaction ] )
99100 . withId ( 'kk6u1A9C9x1roBZOci/4Ne3XtHOtxKRq2O7OLVCbKOc=' )
100- . withRound ( appCallTransaction [ 'confirmed-round' ] ! )
101+ . withRound ( appCallTransaction . confirmedRound ! )
101102 . build ( )
102103
103104 it ( 'should resolve the correct data with arc32 appspec' , async ( ) => {
104105 const myStore = getTestStore ( )
105106 myStore . set ( groupResultsAtom , new Map ( [ [ group . id , createReadOnlyAtomAndTimestamp ( group ) ] ] ) )
106107 myStore . set ( transactionResultsAtom , new Map ( [ [ appCallTransaction . id , createReadOnlyAtomAndTimestamp ( appCallTransaction ) ] ] ) )
107108
108- const applicationId = appCallTransaction [ 'application-transaction' ] ! [ 'application-id' ] !
109+ const applicationId = appCallTransaction . applicationTransaction ! . applicationId !
109110 const dbConnection = await myStore . get ( dbConnectionAtom )
110111 await upsertAppInterface ( dbConnection , {
111112 applicationId : applicationId ,
@@ -152,7 +153,7 @@ describe('resolving ABI method', () => {
152153 myStore . set ( groupResultsAtom , new Map ( [ [ group . id , createReadOnlyAtomAndTimestamp ( group ) ] ] ) )
153154 myStore . set ( transactionResultsAtom , new Map ( [ [ appCallTransaction . id , createReadOnlyAtomAndTimestamp ( appCallTransaction ) ] ] ) )
154155
155- const applicationId = appCallTransaction [ 'application-transaction' ] ! [ 'application-id' ] !
156+ const applicationId = appCallTransaction . applicationTransaction ! . applicationId !
156157 const dbConnection = await myStore . get ( dbConnectionAtom )
157158 await upsertAppInterface ( dbConnection , {
158159 applicationId : applicationId ,
@@ -201,15 +202,15 @@ describe('resolving ABI method', () => {
201202 const group = groupResultMother
202203 . groupWithTransactions ( [ payTransaction , appCallTransaction ] )
203204 . withId ( 'V5t9TByjm6M6pY9B76O+myDggseVS6bZP1lgizX665w=' )
204- . withRound ( appCallTransaction [ 'confirmed-round' ] ! )
205+ . withRound ( appCallTransaction . confirmedRound ! )
205206 . build ( )
206207
207208 it ( 'should resolve the correct data' , async ( ) => {
208209 const myStore = getTestStore ( )
209210 myStore . set ( groupResultsAtom , new Map ( [ [ group . id , createReadOnlyAtomAndTimestamp ( group ) ] ] ) )
210211 myStore . set ( transactionResultsAtom , new Map ( [ [ appCallTransaction . id , createReadOnlyAtomAndTimestamp ( appCallTransaction ) ] ] ) )
211212
212- const applicationId = appCallTransaction [ 'application-transaction' ] ! [ 'application-id' ] !
213+ const applicationId = appCallTransaction . applicationTransaction ! . applicationId !
213214 const dbConnection = await myStore . get ( dbConnectionAtom )
214215 await upsertAppInterface ( dbConnection , {
215216 applicationId : applicationId ,
@@ -349,7 +350,7 @@ describe('resolving ABI method', () => {
349350 {
350351 name : 'asset' ,
351352 type : DecodedAbiType . Asset ,
352- value : 705457144 ,
353+ value : 705457144n ,
353354 length : 9 ,
354355 multiline : false ,
355356 } ,
@@ -363,7 +364,7 @@ describe('resolving ABI method', () => {
363364 {
364365 name : 'application' ,
365366 type : DecodedAbiType . Application ,
366- value : 705410358 ,
367+ value : 705410358n ,
367368 length : 9 ,
368369 multiline : false ,
369370 } ,
@@ -408,7 +409,7 @@ describe('resolving ABI method', () => {
408409 const myStore = getTestStore ( )
409410 myStore . set ( transactionResultsAtom , new Map ( [ [ transaction . id , createReadOnlyAtomAndTimestamp ( transaction ) ] ] ) )
410411
411- const applicationId = transaction [ 'application-transaction' ] ! [ 'application-id' ] !
412+ const applicationId = transaction . applicationTransaction ! . applicationId !
412413 const dbConnection = await myStore . get ( dbConnectionAtom )
413414 await upsertAppInterface ( dbConnection , {
414415 applicationId : applicationId ,
@@ -512,4 +513,72 @@ describe('resolving ABI method', () => {
512513 expect ( abiMethod ) . toBeUndefined ( )
513514 } )
514515 } )
516+
517+ describe ( 'for an inner app call with a reference to another transaction' , ( ) => {
518+ const appCallTransaction = transactionResultMother [ 'localnet-64YO3SCTIJQFVTHYFPD74GYCEH5ETU7RVZCGQ5WCXPIEZEWHRE5A' ] ( ) . build ( )
519+ const group = groupResultMother
520+ . groupWithTransactions ( [ appCallTransaction . innerTxns ! [ 0 ] , appCallTransaction . innerTxns ! [ 1 ] ] )
521+ . withId ( '8Dp0ZM4bEo4LexOu2AtAhOUBKKttkR2slT8aau9t7+E=' )
522+ . withRound ( appCallTransaction . confirmedRound ! )
523+ . build ( )
524+
525+ it ( 'should resolve the correct data with arc32 appspec' , async ( ) => {
526+ const myStore = getTestStore ( )
527+ myStore . set ( groupResultsAtom , new Map ( [ [ group . id , createReadOnlyAtomAndTimestamp ( group ) ] ] ) )
528+ myStore . set ( transactionResultsAtom , new Map ( [ [ appCallTransaction . id , createReadOnlyAtomAndTimestamp ( appCallTransaction ) ] ] ) )
529+
530+ const applicationId = appCallTransaction . applicationTransaction ! . applicationId !
531+ const dbConnection = await myStore . get ( dbConnectionAtom )
532+ await upsertAppInterface ( dbConnection , {
533+ applicationId : applicationId ,
534+ name : 'test' ,
535+ appSpecVersions : [
536+ {
537+ standard : AppSpecStandard . ARC32 ,
538+ appSpec : Arc32TestContractAppSpec as unknown as Arc32AppSpec ,
539+ } ,
540+ ] ,
541+ lastModified : createTimestamp ( ) ,
542+ } satisfies AppInterfaceEntity )
543+
544+ const innerApplicationId = appCallTransaction . innerTxns ! [ 1 ] . applicationTransaction ! . applicationId !
545+ await upsertAppInterface ( dbConnection , {
546+ applicationId : innerApplicationId ,
547+ name : 'test_1' ,
548+ appSpecVersions : [
549+ {
550+ standard : AppSpecStandard . ARC32 ,
551+ appSpec : Arc32TestContractAppSpec as unknown as Arc32AppSpec ,
552+ } ,
553+ ] ,
554+ lastModified : createTimestamp ( ) ,
555+ } satisfies AppInterfaceEntity )
556+
557+ const abiMethod = await myStore . get ( abiMethodResolver ( appCallTransaction , getGroupResultAtom ) )
558+ expect ( abiMethod ) . toBeDefined ( )
559+ expect ( abiMethod ! . name ) . toBe ( 'inner_pay_appl' )
560+ expect ( abiMethod ! . arguments ) . toStrictEqual ( [
561+ {
562+ name : 'appId' ,
563+ type : DecodedAbiType . Uint ,
564+ value : 10019n ,
565+ length : 5 ,
566+ multiline : false ,
567+ } ,
568+ ] )
569+
570+ const innerAbiMethod = await myStore . get ( abiMethodResolver ( appCallTransaction . innerTxns ! [ 1 ] , getGroupResultAtom ) )
571+ expect ( innerAbiMethod ) . toBeDefined ( )
572+ expect ( innerAbiMethod ! . name ) . toBe ( 'get_pay_txn_amount' )
573+ expect ( innerAbiMethod ! . arguments ) . toStrictEqual ( [
574+ {
575+ length : 60 ,
576+ multiline : false ,
577+ name : 'pay_txn' ,
578+ type : 'Transaction' ,
579+ value : '64YO3SCTIJQFVTHYFPD74GYCEH5ETU7RVZCGQ5WCXPIEZEWHRE5A/inner/1' ,
580+ } ,
581+ ] )
582+ } )
583+ } )
515584} )
0 commit comments