Skip to content

Commit

Permalink
Merge pull request #554 from algorandfoundation/feat/dynamic_tmpl_warn
Browse files Browse the repository at this point in the history
feat: only warn once on dynamic tmpl vars and improve error message
  • Loading branch information
joe-p authored Oct 23, 2024
2 parents 8c6cb4e + 60fa88e commit a796179
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7491,6 +7491,7 @@ declare type AssetFreezeTxn = Required<AssetFreezeParams>;
}

async algodCompileProgram(program: 'approval' | 'clear' | 'lsig'): Promise<{ result: string; hash: string }> {
let dynamicTemplateWarning = false;
const body = this.teal[program]
.map((t) => t.teal)
.map((t) => {
Expand All @@ -7502,14 +7503,15 @@ declare type AssetFreezeTxn = Required<AssetFreezeParams>;
if (tVar === undefined) return arg;

if (this.isDynamicType(tVar.type) || isNumeric(tVar.type)) {
if (program === 'lsig' || program === 'approval') {
if (program === 'lsig' || (program === 'approval' && !dynamicTemplateWarning)) {
console.warn(
`WARNING: Due to dynamic template variable type for ${tVar.name} (${typeInfoToABIString(
tVar.type
)}) PC values will be offset from first opcode after constant blocks`
)}) PC values will be offset from first opcode after constant blocks. This will be handled by algokit clients, but ARC56 has a minimal reference implementation available for scenarios where algokit is not being used: https://github.com/joe-p/ARCs/blob/extended_app_description/ARCs/arc-0056.md#calculating-cblock-offsets`
);

this.hasDynamicTemplateVar = true;
dynamicTemplateWarning = true;
}

return isNumeric(tVar.type) ? '0' : '0x';
Expand Down

0 comments on commit a796179

Please sign in to comment.