@@ -3,7 +3,7 @@ import type {ABISerializableObject} from '../serializer/serializable'
33import { abiDecode , ABIDecoder } from '../serializer/decoder'
44import { abiEncode , ABIEncoder } from '../serializer/encoder'
55
6- import { Blob , Name , NameType } from '../'
6+ import { Blob , Name , NameType , UInt64 , UInt64Type } from '../'
77
88export type ABIDef = string | Partial < ABI . Def > | ABI | Blob
99
@@ -26,6 +26,8 @@ export class ABI implements ABISerializableObject {
2626 ricardian_clauses : ABI . Clause [ ]
2727 /// Action Results
2828 action_results : ABI . ActionResult [ ]
29+ /// Sync Calls
30+ calls : ABI . Call [ ]
2931
3032 constructor ( args : Partial < ABI . Def > ) {
3133 this . version = args . version || ABI . version
@@ -36,6 +38,7 @@ export class ABI implements ABISerializableObject {
3638 this . tables = args . tables || [ ]
3739 this . ricardian_clauses = args . ricardian_clauses || [ ]
3840 this . action_results = args . action_results || [ ]
41+ this . calls = args . calls || [ ]
3942 }
4043
4144 static from ( value : ABIDef ) {
@@ -141,6 +144,17 @@ export class ABI implements ABISerializableObject {
141144 action_results . push ( { name, result_type} )
142145 }
143146 }
147+ const calls : ABI . Call [ ] = [ ]
148+ if ( decoder . canRead ( ) ) {
149+ const numCalls = decoder . readVaruint32 ( )
150+ for ( let i = 0 ; i < numCalls ; i ++ ) {
151+ const name = decoder . readString ( )
152+ const type = decoder . readString ( )
153+ const id = UInt64 . fromABI ( decoder )
154+ const result_type = decoder . readString ( )
155+ calls . push ( { name, type, id, result_type} )
156+ }
157+ }
144158 return new ABI ( {
145159 version,
146160 types,
@@ -150,6 +164,7 @@ export class ABI implements ABISerializableObject {
150164 ricardian_clauses,
151165 variants,
152166 action_results,
167+ calls,
153168 } )
154169 }
155170
@@ -210,6 +225,13 @@ export class ABI implements ABISerializableObject {
210225 Name . from ( result . name ) . toABI ( encoder )
211226 encoder . writeString ( result . result_type )
212227 }
228+ encoder . writeVaruint32 ( this . calls . length )
229+ for ( const call of this . calls ) {
230+ encoder . writeString ( call . name )
231+ encoder . writeString ( call . type )
232+ UInt64 . from ( String ( call . id ) ) . toABI ( encoder )
233+ encoder . writeString ( call . result_type )
234+ }
213235 }
214236
215237 resolveType ( name : string ) : ABI . ResolvedType {
@@ -291,7 +313,8 @@ export class ABI implements ABISerializableObject {
291313 this . tables . length != o . tables . length ||
292314 this . ricardian_clauses . length != o . ricardian_clauses . length ||
293315 this . variants . length != o . variants . length ||
294- this . action_results . length != o . action_results . length
316+ this . action_results . length != o . action_results . length ||
317+ this . calls . length != o . calls . length
295318 ) {
296319 return false
297320 }
@@ -310,6 +333,7 @@ export class ABI implements ABISerializableObject {
310333 abi_extensions : [ ] ,
311334 variants : this . variants ,
312335 action_results : this . action_results ,
336+ calls : this . calls ,
313337 }
314338 }
315339}
@@ -357,11 +381,18 @@ export namespace ABI {
357381 tables : Table [ ]
358382 ricardian_clauses : Clause [ ]
359383 action_results : ActionResult [ ]
384+ calls : Call [ ]
360385 }
361386 export interface ActionResult {
362387 name : NameType
363388 result_type : string
364389 }
390+ export interface Call {
391+ name : string
392+ type : string
393+ id : UInt64Type
394+ result_type : string
395+ }
365396 export class ResolvedType {
366397 name : string
367398 id : number
0 commit comments