@@ -515,22 +515,16 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
515515 } else if v .Holding .Asset != 0 {
516516 var address sdk.Address
517517 if v .Holding .Address == 0 {
518- // indicates the sender
519- address = sdk. Address {}
518+ // indicates the sender, resolved below
519+ address = stxn . Txn . Sender
520520 } else if int (v .Holding .Address - 1 ) < len (stxn .Txn .Access ) {
521521 address = stxn .Txn .Access [v .Holding .Address - 1 ].Address
522- } else {
523- // this should not happen
524- continue
525522 }
526523
527524 var asset sdk.AssetIndex
528- // Asset must be non-zero
525+ // Asset should always be non-zero, but sanity check
529526 if int (v .Holding .Asset - 1 ) < len (stxn .Txn .Access ) {
530527 asset = stxn .Txn .Access [v .Holding .Asset - 1 ].Asset
531- } else {
532- // this should not happen
533- continue
534528 }
535529
536530 resourceRef .Holding = & generated.HoldingRef {
@@ -540,41 +534,43 @@ func signedTxnWithAdToTransaction(stxn *sdk.SignedTxnWithAD, extra rowData) (gen
540534 } else if v .Locals .Address != 0 || v .Locals .App != 0 {
541535 var address sdk.Address
542536 if v .Locals .Address == 0 {
543- // indicates the sender
544- address = sdk. Address {}
537+ // indicates the sender, resolved below
538+ address = stxn . Txn . Sender
545539 } else if int (v .Locals .Address - 1 ) < len (stxn .Txn .Access ) {
546540 address = stxn .Txn .Access [v .Locals .Address - 1 ].Address
547- } else {
548- // this should not happen
549- continue
550541 }
551542
552543 var app sdk.AppIndex
553544 if v .Locals .App == 0 {
554- // indicates this application
555- app = sdk .AppIndex (0 )
545+ // indicates this application, resolve app id
546+ if stxn .Txn .ApplicationID == 0 {
547+ // Use applyData.ApplicationID if Txn.ApplicationID is 0 (creation case)
548+ app = stxn .ApplyData .ApplicationID
549+ } else {
550+ app = stxn .Txn .ApplicationID
551+ }
556552 } else if int (v .Locals .App - 1 ) < len (stxn .Txn .Access ) {
557553 app = stxn .Txn .Access [v .Locals .App - 1 ].App
558- } else {
559- // this should not happen
560- continue
561554 }
562555
563556 resourceRef .Local = & generated.LocalsRef {
564557 Address : address .String (),
565558 App : uint64 (app ),
566559 }
567560 } else {
568- // If all else empty, default to a boxref, because a boxref is the only ResourceRef that should ever be empty
561+ // If all else empty, default to a boxref, because a boxref is the only ResourceRef that should ever be empty
569562 var appID uint64
570563 if v .Box .ForeignAppIdx == 0 {
571- appID = 0
564+ // indicates this application, resolve app id
565+ if stxn .Txn .ApplicationID == 0 {
566+ // Use applyData.ApplicationID if Txn.ApplicationID is 0 (creation case)
567+ appID = uint64 (stxn .ApplyData .ApplicationID )
568+ } else {
569+ appID = uint64 (stxn .Txn .ApplicationID )
570+ }
572571 } else if int (v .Box .ForeignAppIdx - 1 ) < len (stxn .Txn .Access ) {
573572 // Indexes are 1-based, so we subtract 1
574573 appID = uint64 (stxn .Txn .Access [v .Box .ForeignAppIdx - 1 ].App )
575- } else {
576- // this should not happen
577- continue
578574 }
579575 boxRef := generated.BoxReference {
580576 App : appID ,
0 commit comments