Skip to content

Commit

Permalink
feat: Include option for outputting arc56 json files
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmenzel committed Nov 27, 2024
1 parent 7df6574 commit 48590b4
Show file tree
Hide file tree
Showing 16 changed files with 1,857 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const cliOptionsSchema = z.object({
// Puya options
outputTeal: z.boolean(),
outputArc32: z.boolean(),
outputArc56: z.boolean(),
outputSsaIr: z.boolean(),
outputOptimizationIr: z.boolean(),
outputDestructuredIr: z.boolean(),
Expand Down
3 changes: 3 additions & 0 deletions src/puya/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type CompilationSetMapping = Record<string, string>
export const defaultPuyaOptions: PuyaPassThroughOptions = {
outputTeal: true,
outputArc32: true,
outputArc56: true,
outputSsaIr: false,
outputOptimizationIr: false,
outputDestructuredIr: false,
Expand All @@ -26,6 +27,7 @@ export type PuyaPassThroughOptions = Omit<PuyaOptions, 'compilationSet'>
export class PuyaOptions {
outputTeal: boolean
outputArc32: boolean
outputArc56: boolean
outputSsaIr: boolean
outputOptimizationIr: boolean
outputDestructuredIr: boolean
Expand All @@ -50,6 +52,7 @@ export class PuyaOptions {
this.compilationSet = compilationSet
this.outputTeal = passThroughOptions.outputTeal
this.outputArc32 = passThroughOptions.outputArc32
this.outputArc56 = passThroughOptions.outputArc56
this.outputSsaIr = passThroughOptions.outputSsaIr
this.outputOptimizationIr = passThroughOptions.outputOptimizationIr
this.outputDestructuredIr = passThroughOptions.outputDestructuredIr
Expand Down
1 change: 1 addition & 0 deletions tests/approvals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Approvals', () => {
optimizationLevel: 0,
outputTeal: true,
outputArc32: true,
outputArc56: true,
},
)
invariant(result.ast, 'Compilation must result in ast')
Expand Down
190 changes: 190 additions & 0 deletions tests/approvals/out/abi-decorators/AbiDecorators.arc56.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"name": "AbiDecorators",
"structs": {},
"methods": [
{
"name": "justNoop",
"args": [],
"returns": {
"type": "void"
},
"actions": {
"create": [],
"call": [
"NoOp"
]
},
"readonly": false,
"events": [],
"recommendations": {}
},
{
"name": "createMethod",
"args": [],
"returns": {
"type": "void"
},
"actions": {
"create": [
"NoOp"
],
"call": []
},
"readonly": false,
"events": [],
"recommendations": {}
},
{
"name": "allActions",
"args": [],
"returns": {
"type": "void"
},
"actions": {
"create": [],
"call": [
"NoOp",
"OptIn",
"CloseOut",
"DeleteApplication",
"UpdateApplication"
]
},
"readonly": false,
"events": [],
"recommendations": {}
},
{
"name": "overrideReadonlyName",
"args": [],
"returns": {
"type": "uint64"
},
"actions": {
"create": [],
"call": [
"NoOp"
]
},
"readonly": true,
"events": [],
"recommendations": {}
},
{
"name": "methodWithDefaults",
"args": [
{
"type": "uint64",
"name": "a",
"defaultValue": {
"source": "global",
"data": "Z2xvYmFsVmFsdWU=",
"type": "AVMString"
}
},
{
"type": "uint64",
"name": "b",
"defaultValue": {
"source": "method",
"data": "readonly()uint64"
}
},
{
"type": "uint64",
"name": "c"
}
],
"returns": {
"type": "uint64"
},
"actions": {
"create": [],
"call": [
"NoOp"
]
},
"readonly": false,
"events": [],
"recommendations": {}
}
],
"arcs": [
22,
28
],
"networks": {},
"state": {
"schema": {
"global": {
"ints": 1,
"bytes": 0
},
"local": {
"ints": 0,
"bytes": 0
}
},
"keys": {
"global": {
"globalValue": {
"keyType": "AVMString",
"valueType": "AVMUint64",
"key": "Z2xvYmFsVmFsdWU="
}
},
"local": {},
"box": {}
},
"maps": {
"global": {},
"local": {},
"box": {}
}
},
"bareActions": {
"create": [],
"call": []
},
"sourceInfo": {
"approval": {
"sourceInfo": [
{
"pc": [
108,
123,
148,
168
],
"errorMessage": "OnCompletion is not NoOp"
},
{
"pc": [
128
],
"errorMessage": "can only call when creating"
},
{
"pc": [
113,
138,
153,
173
],
"errorMessage": "can only call when not creating"
}
],
"pcOffsetMethod": "none"
},
"clear": {
"sourceInfo": [],
"pcOffsetMethod": "none"
}
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCgp0ZXN0cy9hcHByb3ZhbHMvYWJpLWRlY29yYXRvcnMuYWxnby50czo6QWJpRGVjb3JhdG9ycy5hcHByb3ZhbFByb2dyYW06CiAgICBpbnRjYmxvY2sgMCAxCiAgICBieXRlY2Jsb2NrIDB4MTUxZjdjNzUKICAgIHR4biBBcHBsaWNhdGlvbklECiAgICBibnogbWFpbl9hZnRlcl9pZl9lbHNlQDIKICAgIGNhbGxzdWIgY29uc3RydWN0b3IKCm1haW5fYWZ0ZXJfaWZfZWxzZUAyOgogICAgY2FsbHN1YiBfX3B1eWFfYXJjNF9yb3V0ZXJfXwogICAgcmV0dXJuCgoKLy8gdGVzdHMvYXBwcm92YWxzL2FiaS1kZWNvcmF0b3JzLmFsZ28udHM6OkFiaURlY29yYXRvcnMuY29uc3RydWN0b3IoKSAtPiB2b2lkOgpjb25zdHJ1Y3RvcjoKICAgIC8vIHRlc3RzL2FwcHJvdmFscy9hYmktZGVjb3JhdG9ycy5hbGdvLnRzOjQKICAgIC8vIGV4cG9ydCBkZWZhdWx0IGNsYXNzIEFiaURlY29yYXRvcnMgZXh0ZW5kcyBDb250cmFjdCB7CiAgICBwcm90byAwIDAKICAgIC8vIHRlc3RzL2FwcHJvdmFscy9hYmktZGVjb3JhdG9ycy5hbGdvLnRzOjE2CiAgICAvLyBnbG9iYWxWYWx1ZSA9IEdsb2JhbFN0YXRlKHsgaW5pdGlhbFZhbHVlOiBVaW50NjQoMTIzKSB9KQogICAgcHVzaGJ5dGVzICJnbG9iYWxWYWx1ZSIKICAgIHB1c2hpbnQgMTIzIC8vIDEyMwogICAgYXBwX2dsb2JhbF9wdXQKICAgIHJldHN1YgoKCi8vIHRlc3RzL2FwcHJvdmFscy9hYmktZGVjb3JhdG9ycy5hbGdvLnRzOjpBYmlE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nMubWV0aG9kV2l0aERlZmF1bHRzKGE6IHVpbnQ2NCwgYjogdWludDY0LCBjOiB1aW50NjQpIC0+IHVpbnQ2NDoKbWV0aG9kV2l0aERlZmF1bHRzOgogICAgLy8gdGVzdHMvYXBwcm92YWxzL2FiaS1kZWNvcmF0b3JzLmFsZ28udHM6MTgtMTkKICAgIC8vIEBhYmltZXRob2QoeyBkZWZhdWx0QXJndW1lbnRzOiB7IGE6IHsgZnJvbTogJ2dsb2JhbFZhbHVlJyB9LCBiOiB7IGZyb206ICdyZWFkb25seScgfSwgYzogeyBjb25zdGFudDogMTQ1IH0gfSB9KQogICAgLy8gcHVibGljIG1ldGhvZFdpdGhEZWZhdWx0cyhhOiB1aW50NjQsIGI6IHVpbnQ2NCwgYzogdWludDY0KTogdWludDY0IHsKICAgIHByb3RvIDMgMQogICAgLy8gdGVzdHMvYXBwcm92YWxzL2FiaS1kZWNvcmF0b3JzLmFsZ28udHM6MjAKICAgIC8vIHJldHVybiBhICogYiArIGMKICAgIGZyYW1lX2RpZyAtMwogICAgZnJhbWVfZGlnIC0yCiAgICAqCiAgICBmcmFtZV9kaWcgLTEKICAgICsKICAgIHJldHN1Ygo=",
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCgp0ZXN0cy9hcHByb3ZhbHMvYWJpLWRlY29yYXRvcnMuYWxnby50czo6QWJpRGVjb3JhdG9ycy5jbGVhclN0YXRlUHJvZ3JhbToKICAgIHB1c2hpbnQgMSAvLyAxCiAgICByZXR1cm4K"
},
"events": [],
"templateVariables": {}
}
Loading

0 comments on commit 48590b4

Please sign in to comment.