11import { bytes , Contract , internal , TransactionType , uint64 } from '@algorandfoundation/algorand-typescript'
22import { AbiMetadata , getContractMethodAbiMetadata } from '../abi-metadata'
33import { TRANSACTION_GROUP_MAX_SIZE } from '../constants'
4+ import { checkRoutingConditions } from '../context-helpers/context-util'
45import { lazyContext } from '../context-helpers/internal-context'
56import { DecodedLogs , decodeLogs , LogDecoding } from '../decode-logs'
67import { testInvariant } from '../errors'
@@ -49,23 +50,6 @@ interface ExecutionScope {
4950 execute : < TReturn > ( body : ( ) => TReturn ) => TReturn
5051}
5152
52- export const checkRoutingConditions = ( appId : uint64 , metadata : AbiMetadata ) => {
53- const appData = lazyContext . getApplicationData ( appId )
54- const isCreating = appData . isCreating
55- if ( isCreating && metadata . onCreate === 'disallow' ) {
56- throw new internal . errors . CodeError ( 'method can not be called while creating' )
57- }
58- if ( ! isCreating && metadata . onCreate === 'require' ) {
59- throw new internal . errors . CodeError ( 'method can only be called while creating' )
60- }
61- const txn = lazyContext . activeGroup . activeTransaction
62- if ( txn instanceof ApplicationTransaction && metadata . allowActions && ! metadata . allowActions . includes ( txn . onCompletion ) ) {
63- throw new internal . errors . CodeError (
64- `method can only be called with one of the following on_completion values: ${ metadata . allowActions . join ( ', ' ) } ` ,
65- )
66- }
67- }
68-
6953export class DeferredAppCall < TParams extends unknown [ ] , TReturn > {
7054 constructor (
7155 private readonly appId : uint64 ,
@@ -106,6 +90,7 @@ export class TransactionContext {
10690 }
10791 }
10892
93+ /* internal */
10994 ensureScope ( group : Transaction [ ] , activeTransactionIndex ?: number ) : ExecutionScope {
11095 if ( ! this . #activeGroup || ! this . #activeGroup. transactions . length ) {
11196 return this . createScope ( group , activeTransactionIndex )
@@ -200,6 +185,7 @@ export class TransactionGroup {
200185 return this . activeTransaction . appId . id
201186 }
202187
188+ /* internal */
203189 get constructingItxn ( ) {
204190 if ( ! this . constructingItxnGroup . length ) {
205191 internal . errors . internalError ( 'itxn field without itxn begin' )
@@ -221,9 +207,12 @@ export class TransactionGroup {
221207 Object . assign ( activeTransaction , filteredFields )
222208 }
223209
210+ /* internal */
224211 addInnerTransactionGroup ( ...itxns : InnerTxn [ ] ) {
225212 this . itxnGroups . push ( new ItxnGroup ( itxns ) )
226213 }
214+
215+ /* internal */
227216 beginInnerTransactionGroup ( ) {
228217 if ( this . constructingItxnGroup . length ) {
229218 internal . errors . internalError ( 'itxn begin without itxn submit' )
@@ -235,13 +224,15 @@ export class TransactionGroup {
235224 this . constructingItxnGroup . push ( { } as InnerTxnFields )
236225 }
237226
227+ /* internal */
238228 appendInnerTransactionGroup ( ) {
239229 if ( ! this . constructingItxnGroup . length ) {
240230 internal . errors . internalError ( 'itxn next without itxn begin' )
241231 }
242232 this . constructingItxnGroup . push ( { type : TransactionType . Payment } as InnerTxnFields )
243233 }
244234
235+ /* internal */
245236 submitInnerTransactionGroup ( ) {
246237 if ( ! this . constructingItxnGroup . length ) {
247238 internal . errors . internalError ( 'itxn submit without itxn begin' )
0 commit comments