Skip to content

Commit a4d9d71

Browse files
authored
c2c: bsqrt, acct_params_get (#3404)
also an e2e inner appl test
1 parent 29269c3 commit a4d9d71

File tree

18 files changed

+818
-453
lines changed

18 files changed

+818
-453
lines changed

THANKS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A big thank you to everyone who has contributed to the `go-algorand` codebase.
55

66
### External Contributors
77
- aybehrouz
8+
- fionnachan
89
- jeapostrophe
910
- jecassis
1011
- jsign

cmd/opdoc/opdoc.go

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -286,28 +286,6 @@ type LanguageSpec struct {
286286
Ops []OpRecord
287287
}
288288

289-
func argEnum(name string) []string {
290-
if name == "txn" || name == "gtxn" || name == "gtxns" {
291-
return logic.TxnFieldNames
292-
}
293-
if name == "global" {
294-
return logic.GlobalFieldNames
295-
}
296-
if name == "txna" || name == "gtxna" || name == "gtxnsa" || name == "txnas" || name == "gtxnas" || name == "gtxnsas" {
297-
return logic.TxnaFieldNames()
298-
}
299-
if name == "asset_holding_get" {
300-
return logic.AssetHoldingFieldNames
301-
}
302-
if name == "asset_params_get" {
303-
return logic.AssetParamsFieldNames
304-
}
305-
if name == "app_params_get" {
306-
return logic.AppParamsFieldNames
307-
}
308-
return nil
309-
}
310-
311289
func typeString(types []logic.StackType) string {
312290
out := make([]byte, len(types))
313291
for i, t := range types {
@@ -330,27 +308,32 @@ func typeString(types []logic.StackType) string {
330308
return string(out)
331309
}
332310

333-
func argEnumTypes(name string) string {
334-
if name == "txn" || name == "gtxn" || name == "gtxns" || name == "itxn" || name == "gitxn" || name == "itxn_field" {
335-
return typeString(logic.TxnFieldTypes)
336-
}
337-
if name == "global" {
338-
return typeString(logic.GlobalFieldTypes)
339-
}
340-
if name == "txna" || name == "gtxna" || name == "gtxnsa" || name == "txnas" || name == "gtxnas" || name == "gtxnsas" || name == "itxna" || name == "gitxna" {
341-
return typeString(logic.TxnaFieldTypes())
342-
}
343-
if name == "asset_holding_get" {
344-
return typeString(logic.AssetHoldingFieldTypes)
345-
}
346-
if name == "asset_params_get" {
347-
return typeString(logic.AssetParamsFieldTypes)
348-
}
349-
if name == "app_params_get" {
350-
return typeString(logic.AppParamsFieldTypes)
311+
func fieldsAndTypes(names []string, specs speccer) ([]string, string) {
312+
types := make([]logic.StackType, len(names))
313+
for i, name := range names {
314+
types[i] = specs.SpecByName(name).Type()
351315
}
316+
return names, typeString(types)
317+
}
352318

353-
return ""
319+
func argEnums(name string) (names []string, types string) {
320+
switch name {
321+
case "txn", "gtxn", "gtxns", "itxn", "gitxn", "itxn_field":
322+
return fieldsAndTypes(logic.TxnFieldNames, logic.TxnFieldSpecByName)
323+
case "global":
324+
return
325+
case "txna", "gtxna", "gtxnsa", "txnas", "gtxnas", "gtxnsas", "itxna", "gitxna":
326+
// Map is the whole txn field spec map. That's fine, we only lookup the given names.
327+
return fieldsAndTypes(logic.TxnaFieldNames(), logic.TxnFieldSpecByName)
328+
case "asset_holding_get":
329+
return fieldsAndTypes(logic.AssetHoldingFieldNames, logic.AssetHoldingFieldSpecByName)
330+
case "asset_params_get":
331+
return fieldsAndTypes(logic.AssetParamsFieldNames, logic.AssetParamsFieldSpecByName)
332+
case "app_params_get":
333+
return fieldsAndTypes(logic.AppParamsFieldNames, logic.AppParamsFieldSpecByName)
334+
default:
335+
return nil, ""
336+
}
354337
}
355338

356339
func buildLanguageSpec(opGroups map[string][]string) *LanguageSpec {
@@ -363,8 +346,7 @@ func buildLanguageSpec(opGroups map[string][]string) *LanguageSpec {
363346
records[i].Returns = typeString(spec.Returns)
364347
records[i].Cost = spec.Details.Cost
365348
records[i].Size = spec.Details.Size
366-
records[i].ArgEnum = argEnum(spec.Name)
367-
records[i].ArgEnumTypes = argEnumTypes(spec.Name)
349+
records[i].ArgEnum, records[i].ArgEnumTypes = argEnums(spec.Name)
368350
records[i].Doc = logic.OpDoc(spec.Name)
369351
records[i].DocExtra = logic.OpDocExtra(spec.Name)
370352
records[i].ImmediateNote = logic.OpImmediateNote(spec.Name)
@@ -416,6 +398,10 @@ func main() {
416398
fieldSpecsMarkdown(appparams, logic.AppParamsFieldNames, logic.AppParamsFieldSpecByName)
417399
appparams.Close()
418400

401+
acctparams, _ := os.Create("acct_params_fields.md")
402+
fieldSpecsMarkdown(acctparams, logic.AcctParamsFieldNames, logic.AcctParamsFieldSpecByName)
403+
acctparams.Close()
404+
419405
langspecjs, _ := os.Create("langspec.json")
420406
enc := json.NewEncoder(langspecjs)
421407
enc.Encode(buildLanguageSpec(opGroups))

data/transactions/logic/README.md

Lines changed: 113 additions & 100 deletions
Large diffs are not rendered by default.

data/transactions/logic/README_in.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ App fields used in the `app_params_get` opcode.
234234

235235
@@ app_params_fields.md @@
236236

237+
**Account Fields**
238+
239+
Account fields used in the `acct_params_get` opcode.
240+
241+
@@ acct_params_fields.md @@
242+
237243
### Flow Control
238244

239245
@@ Flow_Control.md @@
@@ -264,11 +270,11 @@ with the next instruction with, for example, `balance` and
264270

265271
In v5, only a few of the Header fields may be set: `Type`/`TypeEnum`,
266272
`Sender`, and `Fee`. In v6, Header fields `Note` and `RekeyTo` may
267-
also be set. For the specific fields of each transaction types, any
268-
field may be set (except `RekeyTo` in v5). This allows, for example,
269-
clawback transactions, asset opt-ins, and asset creates in addition to
270-
the more common uses of `axfer` and `acfg`. All fields default to the
271-
zero value, except those described under `itxn_begin`.
273+
also be set. For the specific (non-header) fields of each transaction
274+
type, any field may be set. This allows, for example, clawback
275+
transactions, asset opt-ins, and asset creates in addition to the more
276+
common uses of `axfer` and `acfg`. All fields default to the zero
277+
value, except those described under `itxn_begin`.
272278

273279
Fields may be set multiple times, but may not be read. The most recent
274280
setting is used when `itxn_submit` executes. For this purpose `Type`

0 commit comments

Comments
 (0)