aeternity / aepp-calldata-js

Aeternity data serialization library
ISC License
3 stars 4 forks source link

Export ACI type and its parts #215

Open davidyuk opened 1 year ago

davidyuk commented 1 year ago

I found that it is possible to define the ACI's part defining the type of Sophia value in typescript.

type ValueAci = 'void' | 'unit' | 'int' | 'bool' | 'string' | 'bits' | 'hash' | 'signature'
| 'address' | 'contract_pubkey' | 'Chain.ttl' | 'Chain.ga_meta_tx' | 'Chain.paying_for_tx'
| 'Chain.base_tx' | 'AENS.pointee' | 'AENS.name' | 'MCL_BLS12_381.fr' | 'MCL_BLS12_381.fp'
| { 'Set.set': readonly [ValueAci] }
| { bytes: number }
| { list: readonly [ValueAci] }
| { map: readonly [ValueAci, ValueAci] }
| { tuple: ReadonlyArray<ValueAci> }
| { record: ReadonlyArray<{ name: string, type: ValueAci }> }
| { variant: ReadonlyArray<{ [key: string]: ReadonlyArray<ValueAci> }> }
| { option: readonly [ValueAci] }
| { oracle: readonly [ValueAci, ValueAci] }
| { oracle_query: readonly [ValueAci, ValueAci] };

It doesn't include type aliases because it doesn't suit my use case. But in general, it should be possible to define ACI structure in typescript instead of specifying aci as any[].

https://github.com/aeternity/aepp-calldata-js/blob/82b5a98f9b308482627da8d7484d213e9cf87151/src/main.d.ts#L5

dincho commented 1 year ago

Well, I don't care/use much for main.d.ts, feel free to shape it whatever fits your needs.