RootSoft / algorand-dart

Unofficial community SDK to interact with the Algorand network, for Dart & Flutter
MIT License
36 stars 16 forks source link

TEALProgram.fromSource ~ program version 35 greater than max supported version 7 #38

Closed 1m1-github closed 2 years ago

1m1-github commented 2 years ago

state_approval_program.teal

#pragma version 5
pushint 1

dart

final approvalProgramSource = await rootBundle.loadString('assets/state_approval_program.teal');
final approvalProgram = TEALProgram.fromSource(source: approvalProgramSource);
final createTxn = await (ApplicationCreateTransactionBuilder()
          ..sender = Address.fromAlgorandAddress(address: session.accounts.first)
          ..suggestedParams = params
          ..approvalProgram = approvalProgram
          ..clearStateProgram = clearStateProgram
          ..globalStateSchema = StateSchema(numUint: 5, numByteSlice: 1)
          ..localStateSchema = StateSchema(numUint: 0, numByteSlice: 0)
          ..onCompletion = OnCompletion.OPT_IN_OC)
        .build();

    final txnsBytes = Encoder.encodeMessagePack(createTxn.toMessagePack());
    final signedTxnsBytes = await provider.signTransaction(txnsBytes);
    final txId = await lib.sendRawTransactions(signedTxnsBytes);

gives error TransactionPool.Remember: transaction PKRTIV3CRNEOQB6BR75NJ2XXS3K3DCNIVMI7NAERH75NHIBJXFDA: check failed on ApprovalProgram: program version 35 greater than max supported version 7

maybe the fromSource method has a bug?

RootSoft commented 2 years ago

@1m1-github You still have to compile the TEAL source code before passing it to the transaction builder.

final approvalProgram =
    await algorand.applicationManager.compileTEAL(approvalProgramSource);
1m1-github commented 2 years ago

ok - thx