1
- /** An ABI-encoded type */
2
- type ABIType = string ;
3
-
4
- /** The name of a defined struct */
5
- type StructName = string ;
6
-
7
- /** Raw byteslice without the length prefixed that is specified in ARC-4 */
8
- type AVMBytes = 'bytes' ;
9
-
10
- /** Mapping of named structs to the ABI type of their fields */
11
- interface StructFields {
12
- [ fieldName : string ] : ABIType | StructFields ;
13
- }
14
-
15
- /** Describes a single key in app storage */
16
- interface StorageKey {
17
- /** Description of what this storage key holds */
18
- desc ?: string ;
19
- /** The type of the key */
20
- keyType : ABIType | AVMBytes | StructName ;
21
- /** The type of the value */
22
- valueType : ABIType | AVMBytes | StructName ;
23
- /** The bytes of the key encoded as base64 */
24
- key : string ;
25
- }
26
-
27
- interface StorageMap {
28
- /** Description of what the key-value pairs in this mapping hold */
29
- desc ?: string ;
30
- /** The type of the keys in the map */
31
- keyType : ABIType | AVMBytes | StructName ;
32
- /** The type of the values in the map */
33
- valueType : ABIType | AVMBytes | StructName ;
34
- /** The prefix of the map, encoded as a utf-8 string */
35
- prefix ?: string ;
36
- }
37
-
38
- interface SourceInfo {
39
- /** The line of pre-compiled TEAL */
40
- teal ?: number ;
41
- /** The program counter offset(s) that correspond to this line of TEAL */
42
- pc ?: Array < number > ;
43
- /** A human-readable string that describes the error when the program fails at this given line of TEAL */
44
- errorMessage ?: string ;
45
- }
46
-
47
- interface Event {
48
- /** The name of the event */
49
- name : string ;
50
- /** Optional, user-friendly description for the event */
51
- desc ?: string ;
52
- /** The arguments of the event, in order */
53
- args : Array < {
54
- /** The type of the argument */
55
- type : ABIType ;
56
- /** Optional, user-friendly name for the argument */
57
- name ?: string ;
58
- /** Optional, user-friendly description for the argument */
59
- desc ?: string ;
60
- /** If the type is a struct, the name of the struct */
61
- struct ?: StructName ;
62
- } > ;
63
- }
64
-
65
- /** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */
66
- interface Method {
67
- /** The name of the method */
68
- name : string ;
69
- /** Optional, user-friendly description for the method */
70
- desc ?: string ;
71
- /** The arguments of the method, in order */
72
- args : Array < {
73
- /** The type of the argument */
74
- type : ABIType ;
75
- /** If the type is a struct, the name of the struct */
76
- struct ?: StructName ;
77
- /** Optional, user-friendly name for the argument */
78
- name ?: string ;
79
- /** Optional, user-friendly description for the argument */
80
- desc ?: string ;
81
- /** The default value that clients should use. MUST be base64 encoded bytes */
82
- defaultValue ?: string ;
83
- } > ;
84
- /** Information about the method's return value */
85
- returns : {
86
- /** The type of the return value, or "void" to indicate no return value. */
87
- type : ABIType ;
88
- /** If the type is a struct, the name of the struct */
89
- struct ?: StructName ;
90
- /** Optional, user-friendly description for the return value */
91
- desc ?: string ;
92
- } ;
93
- /** an action is a combination of call/create and an OnComplete */
94
- actions : {
95
- /** OnCompletes this method allows when appID === 0 */
96
- create : ( 'NoOp' | 'OptIn' | 'DeleteApplication' ) [ ] ;
97
- /** OnCompletes this method allows when appID !== 0 */
98
- call : ( 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication' ) [ ] ;
99
- } ;
100
- /** If this method does not write anything to the ledger (ARC-22) */
101
- readonly : boolean ;
102
- /** ARC-28 events that MAY be emitted by this method */
103
- events ?: Array < Event > ;
104
- /** Information that clients can use when calling the method */
105
- recommendations ?: {
106
- /** The number of inner transactions the caller should cover the fees for */
107
- innerTransactionCount ?: number ;
108
- /** Recommended box references to include */
109
- boxes ?: {
110
- /** The app ID for the box */
111
- app ?: number ;
112
- /** The base64 encoded box key */
113
- key : string ;
114
- /** The number of bytes being read from the box */
115
- readBytes : number ;
116
- /** The number of bytes being written to the box */
117
- writeBytes : number ;
118
- } ;
119
- /** Recommended foreign accounts */
120
- accounts ?: string [ ] ;
121
- /** Recommended foreign apps */
122
- apps ?: number [ ] ;
123
- /** Recommended foreign assets */
124
- assets ?: number [ ] ;
125
- } ;
126
- }
127
-
1
+ /* eslint-disable no-use-before-define */
128
2
/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */
129
3
export interface ARC56Contract {
130
4
/** The ARCs used and/or supported by this contract. All contracts implicity support ARC4 and ARC56 */
@@ -134,22 +8,20 @@ export interface ARC56Contract {
134
8
/** Optional, user-friendly description for the interface */
135
9
desc ?: string ;
136
10
/**
137
- * Optional object listing the contract instances across different networks
11
+ * Optional object listing the contract instances across different networks.
12
+ * The key is the base64 genesis hash of the network, and the value contains
13
+ * information about the deployed contract in the network indicated by the
14
+ * key. A key containing the human-readable name of the network MAY be
15
+ * included, but the corresponding genesis hash key MUST also be define
138
16
*/
139
17
networks ?: {
140
- /**
141
- * The key is the base64 genesis hash of the network, and the value contains
142
- * information about the deployed contract in the network indicated by the
143
- * key. A key containing the human-readable name of the network MAY be
144
- * included, but the corresponding genesis hash key MUST also be defined
145
- */
146
18
[ network : string ] : {
147
19
/** The app ID of the deployed contract in this network */
148
20
appID : number ;
149
21
} ;
150
22
} ;
151
- /** Named structs use by the application */
152
- structs : { [ structName : StructName ] : StructFields } ;
23
+ /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */
24
+ structs : { [ structName : StructName ] : StructField [ ] } ;
153
25
/** All of the methods that the contract implements */
154
26
methods : Method [ ] ;
155
27
state : {
@@ -184,8 +56,13 @@ export interface ARC56Contract {
184
56
/** OnCompletes this method allows when appID !== 0 */
185
57
call : ( 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication' ) [ ] ;
186
58
} ;
187
- /** Information about the TEAL */
188
- sourceInfo ?: SourceInfo [ ] ;
59
+ /** Information about the TEAL programs */
60
+ sourceInfo ?: {
61
+ /** Approval program information */
62
+ approval : SourceInfo [ ] ;
63
+ /** Clear program information */
64
+ clear : SourceInfo [ ] ;
65
+ } ;
189
66
/** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */
190
67
source ?: {
191
68
/** The approval program */
@@ -209,7 +86,7 @@ export interface ARC56Contract {
209
86
major : number ;
210
87
minor : number ;
211
88
patch : number ;
212
- commit ?: string ;
89
+ commitHash ?: string ;
213
90
} ;
214
91
} ;
215
92
/** ARC-28 events that MAY be emitted by this contract */
@@ -218,7 +95,7 @@ export interface ARC56Contract {
218
95
templateVariables ?: {
219
96
[ name : string ] : {
220
97
/** The type of the template variable */
221
- type : ABIType | AVMBytes | StructName ;
98
+ type : ABIType | AVMString | AVMBytes | StructName ;
222
99
/** If given, the the base64 encoded value used for the given app/program */
223
100
value ?: string ;
224
101
} ;
@@ -227,7 +104,155 @@ export interface ARC56Contract {
227
104
scratchVariables ?: {
228
105
[ name : string ] : {
229
106
slot : number ;
230
- type : ABIType | AVMBytes | StructName ;
107
+ type : ABIType | AVMString | AVMBytes | StructName ;
108
+ } ;
109
+ } ;
110
+ }
111
+
112
+ /** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */
113
+ export interface Method {
114
+ /** The name of the method */
115
+ name : string ;
116
+ /** Optional, user-friendly description for the method */
117
+ desc ?: string ;
118
+ /** The arguments of the method, in order */
119
+ args : Array < {
120
+ /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */
121
+ type : ABIType ;
122
+ /** If the type is a struct, the name of the struct */
123
+ struct ?: StructName ;
124
+ /** Optional, user-friendly name for the argument */
125
+ name ?: string ;
126
+ /** Optional, user-friendly description for the argument */
127
+ desc ?: string ;
128
+ /** The default value that clients should use. */
129
+ defaultValue ?: {
130
+ /** Base64 encoded bytes or uint64 */
131
+ data : string | bigint ;
132
+ /** How the data is encoded. This is the encoding for the data provided here, not the arg type */
133
+ type : ABIType | AVMBytes | AVMString ;
134
+ /** Where the default value is coming from
135
+ * - box: The data key signifies the box key to read the value from
136
+ * - global: The data key signifies the global state key to read the value from
137
+ * - local: The data key signifies the local state key to read the value from (for the sender)
138
+ * - literal: the value is a literal and should be passed directly as the argument
139
+ */
140
+ source : 'box' | 'global' | 'local' | 'literal' ;
231
141
} ;
142
+ } > ;
143
+ /** Information about the method's return value */
144
+ returns : {
145
+ /** The type of the return value, or "void" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */
146
+ type : ABIType ;
147
+ /** If the type is a struct, the name of the struct */
148
+ struct ?: StructName ;
149
+ /** Optional, user-friendly description for the return value */
150
+ desc ?: string ;
232
151
} ;
152
+ /** an action is a combination of call/create and an OnComplete */
153
+ actions : {
154
+ /** OnCompletes this method allows when appID === 0 */
155
+ create : ( 'NoOp' | 'OptIn' | 'DeleteApplication' ) [ ] ;
156
+ /** OnCompletes this method allows when appID !== 0 */
157
+ call : ( 'NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication' ) [ ] ;
158
+ } ;
159
+ /** If this method does not write anything to the ledger (ARC-22) */
160
+ readonly ?: boolean ;
161
+ /** ARC-28 events that MAY be emitted by this method */
162
+ events ?: Array < Event > ;
163
+ /** Information that clients can use when calling the method */
164
+ recommendations ?: {
165
+ /** The number of inner transactions the caller should cover the fees for */
166
+ innerTransactionCount ?: number ;
167
+ /** Recommended box references to include */
168
+ boxes ?: {
169
+ /** The app ID for the box */
170
+ app ?: number ;
171
+ /** The base64 encoded box key */
172
+ key : string ;
173
+ /** The number of bytes being read from the box */
174
+ readBytes : number ;
175
+ /** The number of bytes being written to the box */
176
+ writeBytes : number ;
177
+ } ;
178
+ /** Recommended foreign accounts */
179
+ accounts ?: string [ ] ;
180
+ /** Recommended foreign apps */
181
+ apps ?: number [ ] ;
182
+ /** Recommended foreign assets */
183
+ assets ?: number [ ] ;
184
+ } ;
185
+ }
186
+
187
+ export interface Event {
188
+ /** The name of the event */
189
+ name : string ;
190
+ /** Optional, user-friendly description for the event */
191
+ desc ?: string ;
192
+ /** The arguments of the event, in order */
193
+ args : Array < {
194
+ /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */
195
+ type : ABIType ;
196
+ /** Optional, user-friendly name for the argument */
197
+ name ?: string ;
198
+ /** Optional, user-friendly description for the argument */
199
+ desc ?: string ;
200
+ /** If the type is a struct, the name of the struct */
201
+ struct ?: StructName ;
202
+ } > ;
203
+ }
204
+
205
+ /** An ABI-encoded type */
206
+ type ABIType = string ;
207
+
208
+ /** The name of a defined struct */
209
+ type StructName = string ;
210
+
211
+ /** Raw byteslice without the length prefixed that is specified in ARC-4 */
212
+ type AVMBytes = 'AVMBytes' ;
213
+
214
+ /** A string without the length prefix that is specified in ARC-4 */
215
+ type AVMString = 'AVMString' ;
216
+
217
+ /** Information about a single field in a struct */
218
+ export interface StructField {
219
+ /** The name of the struct field */
220
+ name : string ;
221
+ /** The type of the struct field's value */
222
+ type : ABIType | StructName | StructField [ ] ;
223
+ }
224
+
225
+ /** Describes a single key in app storage */
226
+ export interface StorageKey {
227
+ /** Description of what this storage key holds */
228
+ desc ?: string ;
229
+ /** The type of the key */
230
+ keyType : ABIType | AVMString | AVMBytes | StructName ;
231
+ /** The type of the value */
232
+ valueType : ABIType | AVMString | AVMBytes | StructName ;
233
+ /** The bytes of the key encoded as base64 */
234
+ key : string ;
235
+ }
236
+
237
+ /** Describes a mapping of key-value pairs in storage */
238
+ export interface StorageMap {
239
+ /** Description of what the key-value pairs in this mapping hold */
240
+ desc ?: string ;
241
+ /** The type of the keys in the map */
242
+ keyType : ABIType | AVMString | AVMBytes | StructName ;
243
+ /** The type of the values in the map */
244
+ valueType : ABIType | AVMString | AVMBytes | StructName ;
245
+ /** The base64-encoded prefix of the map keys */
246
+ prefix ?: string ;
247
+ }
248
+
249
+ export interface SourceInfo {
250
+ /** The line of pre-compiled TEAL */
251
+ teal ?: number ;
252
+ /** The program counter offset(s) that correspond to this line of TEAL */
253
+ pc ?: Array < number > ;
254
+ /** A human-readable string that describes the error when the program fails at this given line of TEAL */
255
+ errorMessage ?: string ;
256
+ /** The line of the dissasembled TEAL this line of pre-compiled TEAL corresponds to */
257
+ disassembledTeal ?: number ;
233
258
}
0 commit comments