metaplex-foundation / solita

Genrates an SDK API from solana contract IDL.
Apache License 2.0
140 stars 32 forks source link

feat: render tuples #70

Closed thlorenz closed 2 years ago

thlorenz commented 2 years ago

Summary

Renders tuples (indicated via tuple in the IDL).

This supports tuples nested inside other types as in the below example as well as tuples whose elements themselves are composites.

A part of nft-packs IDL was included to serve as a smoke-test and more detailed tests were added to the typemapper.

Example

Rendering Vec<u32, u32, u32>

export type PackConfig = {
  weights: [number, number, number][]
}

export const packConfigBeet = new beet.FixableBeetArgsStruct<PackConfig>(
  [
    [
      'weights',
      beet.array(beet.fixedSizeTuple([beet.u32, beet.u32, beet.u32])),
    ],
  ],
  'PackConfig'
)