From 043414463a5160a6cbfe3fd74abc1e9f50c7e1be Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Wed, 27 Mar 2024 13:29:13 +0000 Subject: [PATCH 1/3] Update enums codecs from latest Web3.js version This PR updates the JS experimental renderer to use the latest version of the new Web3.js and adjusts the Data Enum and Scalar Enum codecs, now known as Discriminated Union and Enum codecs respectively. --- .changeset/poor-lions-promise.md | 5 +++ .../js-experimental/fragments/index.ts | 2 +- .../fragments/typeDataEnumHelpers.njk | 23 ---------- .../typeDiscriminatedUnionHelpers.njk | 23 ++++++++++ ...rs.ts => typeDiscriminatedUnionHelpers.ts} | 21 +++++----- .../js-experimental/getRenderMapVisitor.ts | 13 +++--- .../js-experimental/getTypeManifestVisitor.ts | 42 ++++++++++++------- .../js-experimental/nameTransformers.ts | 20 ++++----- .../js-experimental/renderValueNodeVisitor.ts | 6 +-- .../templates/definedTypesPage.njk | 2 +- .../src/generated/types/authorityType.ts | 8 ++-- .../src/generated/types/burnArgs.ts | 8 ++-- .../src/generated/types/collectionDetails.ts | 20 +++++---- .../src/generated/types/delegateArgs.ts | 30 ++++++++----- .../src/generated/types/delegateRole.ts | 8 ++-- .../src/generated/types/escrowAuthority.ts | 22 ++++++---- .../src/generated/types/migrateArgs.ts | 8 ++-- .../src/generated/types/mintArgs.ts | 16 +++---- .../src/generated/types/operation.ts | 8 ++-- .../src/generated/types/payloadKey.ts | 8 ++-- .../src/generated/types/payloadType.ts | 40 +++++++++++------- .../src/generated/types/revokeArgs.ts | 8 ++-- .../src/generated/types/taKey.ts | 8 ++-- .../src/generated/types/tmCreateArgs.ts | 20 ++++----- .../src/generated/types/tmKey.ts | 8 ++-- .../src/generated/types/tokenStandard.ts | 8 ++-- .../src/generated/types/transferArgs.ts | 16 +++---- .../src/generated/types/updateArgs.ts | 16 +++---- .../src/generated/types/useAssetArgs.ts | 16 +++---- .../src/generated/types/useMethod.ts | 8 ++-- .../src/generated/types/verifyArgs.ts | 8 ++-- 31 files changed, 249 insertions(+), 200 deletions(-) create mode 100644 .changeset/poor-lions-promise.md delete mode 100644 src/renderers/js-experimental/fragments/typeDataEnumHelpers.njk create mode 100644 src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.njk rename src/renderers/js-experimental/fragments/{typeDataEnumHelpers.ts => typeDiscriminatedUnionHelpers.ts} (50%) diff --git a/.changeset/poor-lions-promise.md b/.changeset/poor-lions-promise.md new file mode 100644 index 000000000..f415e80cc --- /dev/null +++ b/.changeset/poor-lions-promise.md @@ -0,0 +1,5 @@ +--- +"@metaplex-foundation/kinobi": minor +--- + +Update enums codecs from latest Web3.js version on the JS experimental renderer diff --git a/src/renderers/js-experimental/fragments/index.ts b/src/renderers/js-experimental/fragments/index.ts index fdcf2c36c..a08c7aa84 100644 --- a/src/renderers/js-experimental/fragments/index.ts +++ b/src/renderers/js-experimental/fragments/index.ts @@ -23,7 +23,7 @@ export * from './programErrors'; export * from './programInstructions'; export * from './type'; export * from './typeCodec'; -export * from './typeDataEnumHelpers'; export * from './typeDecoder'; +export * from './typeDiscriminatedUnionHelpers'; export * from './typeEncoder'; export * from './typeWithCodec'; diff --git a/src/renderers/js-experimental/fragments/typeDataEnumHelpers.njk b/src/renderers/js-experimental/fragments/typeDataEnumHelpers.njk deleted file mode 100644 index 62c32f509..000000000 --- a/src/renderers/js-experimental/fragments/typeDataEnumHelpers.njk +++ /dev/null @@ -1,23 +0,0 @@ -// Data Enum Helpers. -{% for variant in typeNode.variants %} - {% if variant.kind === 'enumStructVariantTypeNode' %} - export function {{ dataEnumFunction }}(kind: '{{ getVariant(variant.name) }}', data: GetDataEnumKindContent<{{ looseName }}, '{{ getVariant(variant.name) }}'>): GetDataEnumKind<{{ looseName }}, '{{ getVariant(variant.name) }}'>; - {% elif variant.kind === 'enumTupleVariantTypeNode' %} - export function {{ dataEnumFunction }}(kind: '{{ getVariant(variant.name) }}', data: GetDataEnumKindContent<{{ looseName }}, '{{ getVariant(variant.name) }}'>['fields']): GetDataEnumKind<{{ looseName }}, '{{ getVariant(variant.name) }}'>; - {% else %} - export function {{ dataEnumFunction }}(kind: '{{ getVariant(variant.name) }}'): GetDataEnumKind<{{ looseName }}, '{{ getVariant(variant.name) }}'>; - {% endif %} -{% endfor %} -export function {{ dataEnumFunction }}( - kind: K, - data?: Data, -) { - return Array.isArray(data) ? { {{ dataEnumDiscriminator }}: kind, fields: data } : { {{ dataEnumDiscriminator }}: kind, ...(data ?? {}) }; -} - -export function {{ isDataEnumFunction }}( - kind: K, - value: {{ strictName }}, -): value is {{ strictName }} & { {{ dataEnumDiscriminator }}: K } { - return value.{{ dataEnumDiscriminator }} === kind; -}; diff --git a/src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.njk b/src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.njk new file mode 100644 index 000000000..cc1a038d1 --- /dev/null +++ b/src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.njk @@ -0,0 +1,23 @@ +// Data Enum Helpers. +{% for variant in typeNode.variants %} + {% if variant.kind === 'enumStructVariantTypeNode' %} + export function {{ discriminatedUnionFunction }}(kind: '{{ getVariant(variant.name) }}', data: GetDiscriminatedUnionVariantContent<{{ looseName }}, '__kind', '{{ getVariant(variant.name) }}'>): GetDiscriminatedUnionVariant<{{ looseName }}, '__kind', '{{ getVariant(variant.name) }}'>; + {% elif variant.kind === 'enumTupleVariantTypeNode' %} + export function {{ discriminatedUnionFunction }}(kind: '{{ getVariant(variant.name) }}', data: GetDiscriminatedUnionVariantContent<{{ looseName }}, '__kind', '{{ getVariant(variant.name) }}'>['fields']): GetDiscriminatedUnionVariant<{{ looseName }}, '__kind', '{{ getVariant(variant.name) }}'>; + {% else %} + export function {{ discriminatedUnionFunction }}(kind: '{{ getVariant(variant.name) }}'): GetDiscriminatedUnionVariant<{{ looseName }}, '__kind', '{{ getVariant(variant.name) }}'>; + {% endif %} +{% endfor %} +export function {{ discriminatedUnionFunction }}( + kind: K, + data?: Data, +) { + return Array.isArray(data) ? { {{ discriminatedUnionDiscriminator }}: kind, fields: data } : { {{ discriminatedUnionDiscriminator }}: kind, ...(data ?? {}) }; +} + +export function {{ isDiscriminatedUnionFunction }}( + kind: K, + value: {{ strictName }}, +): value is {{ strictName }} & { {{ discriminatedUnionDiscriminator }}: K } { + return value.{{ discriminatedUnionDiscriminator }} === kind; +}; diff --git a/src/renderers/js-experimental/fragments/typeDataEnumHelpers.ts b/src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.ts similarity index 50% rename from src/renderers/js-experimental/fragments/typeDataEnumHelpers.ts rename to src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.ts index d8bbb7a04..2cb2913e1 100644 --- a/src/renderers/js-experimental/fragments/typeDataEnumHelpers.ts +++ b/src/renderers/js-experimental/fragments/typeDiscriminatedUnionHelpers.ts @@ -2,30 +2,31 @@ import { TypeNode, isDataEnum, isNode } from '../../../nodes'; import type { GlobalFragmentScope } from '../getRenderMapVisitor'; import { Fragment, fragment, fragmentFromTemplate } from './common'; -export function getTypeDataEnumHelpersFragment( +export function getTypeDiscriminatedUnionHelpersFragment( scope: Pick & { name: string; typeNode: TypeNode; } ): Fragment { const { name, typeNode, nameApi } = scope; - const isDataEnumNode = + const isDiscriminatedUnion = isNode(typeNode, 'enumTypeNode') && isDataEnum(typeNode); - if (!isDataEnumNode) { + if (!isDiscriminatedUnion) { return fragment(''); } - return fragmentFromTemplate('typeDataEnumHelpers.njk', { + return fragmentFromTemplate('typeDiscriminatedUnionHelpers.njk', { strictName: nameApi.dataType(name), looseName: nameApi.dataArgsType(name), - dataEnumDiscriminator: nameApi.dataEnumDiscriminator(name), - getVariant: (variant: string) => nameApi.dataEnumVariant(variant), - dataEnumFunction: nameApi.dataEnumFunction(name), - isDataEnumFunction: nameApi.isDataEnumFunction(name), + discriminatedUnionDiscriminator: + nameApi.discriminatedUnionDiscriminator(name), + getVariant: (variant: string) => nameApi.discriminatedUnionVariant(variant), + discriminatedUnionFunction: nameApi.discriminatedUnionFunction(name), + isDiscriminatedUnionFunction: nameApi.isDiscriminatedUnionFunction(name), typeNode, }).addImports('solanaCodecsDataStructures', [ - 'GetDataEnumKindContent', - 'GetDataEnumKind', + 'GetDiscriminatedUnionVariantContent', + 'GetDiscriminatedUnionVariant', ]); } diff --git a/src/renderers/js-experimental/getRenderMapVisitor.ts b/src/renderers/js-experimental/getRenderMapVisitor.ts index 1a5d2d5bf..4c5b112c7 100644 --- a/src/renderers/js-experimental/getRenderMapVisitor.ts +++ b/src/renderers/js-experimental/getRenderMapVisitor.ts @@ -49,7 +49,7 @@ import { getProgramErrorsFragment, getProgramFragment, getProgramInstructionsFragment, - getTypeDataEnumHelpersFragment, + getTypeDiscriminatedUnionHelpersFragment, getTypeWithCodecFragment, } from './fragments'; import { @@ -447,10 +447,13 @@ export function getRenderMapVisitor(options: GetRenderMapOptions = {}) { }; const typeWithCodecFragment = getTypeWithCodecFragment(scope); - const typeDataEnumHelpersFragment = - getTypeDataEnumHelpersFragment(scope); + const typeDiscriminatedUnionHelpersFragment = + getTypeDiscriminatedUnionHelpersFragment(scope); const imports = new ImportMap() - .mergeWith(typeWithCodecFragment, typeDataEnumHelpersFragment) + .mergeWith( + typeWithCodecFragment, + typeDiscriminatedUnionHelpersFragment + ) .remove('generatedTypes', [ nameApi.dataType(node.name), nameApi.dataArgsType(node.name), @@ -467,7 +470,7 @@ export function getRenderMapVisitor(options: GetRenderMapOptions = {}) { generatedTypes: '.', }), typeWithCodecFragment, - typeDataEnumHelpersFragment, + typeDiscriminatedUnionHelpersFragment, }) ); }, diff --git a/src/renderers/js-experimental/getTypeManifestVisitor.ts b/src/renderers/js-experimental/getTypeManifestVisitor.ts index 742deb194..700620e13 100644 --- a/src/renderers/js-experimental/getTypeManifestVisitor.ts +++ b/src/renderers/js-experimental/getTypeManifestVisitor.ts @@ -171,28 +171,28 @@ export function getTypeManifestVisitor(input: { ); } const variantNames = enumType.variants.map(({ name }) => - nameApi.scalarEnumVariant(name) + nameApi.enumVariant(name) ); return { isEnum: true, strictType: fragment(`{ ${variantNames.join(', ')} }`), looseType: fragment(`{ ${variantNames.join(', ')} }`), encoder: fragment( - `getScalarEnumEncoder(${ + `getEnumEncoder(${ currentParentName.strict + encoderOptionsAsString })`, encoderImports.add( 'solanaCodecsDataStructures', - 'getScalarEnumEncoder' + 'getEnumEncoder' ) ), decoder: fragment( - `getScalarEnumDecoder(${ + `getEnumDecoder(${ currentParentName.strict + decoderOptionsAsString })`, decoderImports.add( 'solanaCodecsDataStructures', - 'getScalarEnumDecoder' + 'getEnumDecoder' ) ), }; @@ -205,24 +205,32 @@ export function getTypeManifestVisitor(input: { ); mergedManifest.encoder .mapRender( - (r) => `getDataEnumEncoder([${r}]${encoderOptionsAsString})` + (r) => + `getDiscriminatedUnionEncoder([${r}]${encoderOptionsAsString})` ) .mergeImportsWith(encoderImports) - .addImports('solanaCodecsDataStructures', ['getDataEnumEncoder']); + .addImports('solanaCodecsDataStructures', [ + 'getDiscriminatedUnionEncoder', + ]); mergedManifest.decoder .mapRender( - (r) => `getDataEnumDecoder([${r}]${decoderOptionsAsString})` + (r) => + `getDiscriminatedUnionDecoder([${r}]${decoderOptionsAsString})` ) .mergeImportsWith(decoderImports) - .addImports('solanaCodecsDataStructures', ['getDataEnumDecoder']); + .addImports('solanaCodecsDataStructures', [ + 'getDiscriminatedUnionDecoder', + ]); return mergedManifest; }, visitEnumEmptyVariantType(enumEmptyVariantType) { - const discriminator = nameApi.dataEnumDiscriminator( + const discriminator = nameApi.discriminatedUnionDiscriminator( + enumEmptyVariantType.name + ); + const name = nameApi.discriminatedUnionVariant( enumEmptyVariantType.name ); - const name = nameApi.dataEnumVariant(enumEmptyVariantType.name); const kindAttribute = `${discriminator}: "${name}"`; return { isEnum: false, @@ -240,10 +248,12 @@ export function getTypeManifestVisitor(input: { }, visitEnumStructVariantType(enumStructVariantType, { self }) { - const discriminator = nameApi.dataEnumDiscriminator( + const discriminator = nameApi.discriminatedUnionDiscriminator( + enumStructVariantType.name + ); + const name = nameApi.discriminatedUnionVariant( enumStructVariantType.name ); - const name = nameApi.dataEnumVariant(enumStructVariantType.name); const kindAttribute = `${discriminator}: "${name}"`; const structManifest = visit(enumStructVariantType.struct, self); structManifest.strictType.mapRender( @@ -258,10 +268,12 @@ export function getTypeManifestVisitor(input: { }, visitEnumTupleVariantType(enumTupleVariantType, { self }) { - const discriminator = nameApi.dataEnumDiscriminator( + const discriminator = nameApi.discriminatedUnionDiscriminator( + enumTupleVariantType.name + ); + const name = nameApi.discriminatedUnionVariant( enumTupleVariantType.name ); - const name = nameApi.dataEnumVariant(enumTupleVariantType.name); const kindAttribute = `${discriminator}: "${name}"`; const struct = structTypeNode([ structFieldTypeNode({ diff --git a/src/renderers/js-experimental/nameTransformers.ts b/src/renderers/js-experimental/nameTransformers.ts index a8679a318..2f1a193c5 100644 --- a/src/renderers/js-experimental/nameTransformers.ts +++ b/src/renderers/js-experimental/nameTransformers.ts @@ -40,11 +40,11 @@ export type NameTransformerKey = | 'accountFetchFromSeedsFunction' | 'accountFetchMaybeFromSeedsFunction' | 'accountGetSizeFunction' - | 'scalarEnumVariant' - | 'dataEnumDiscriminator' - | 'dataEnumVariant' - | 'dataEnumFunction' - | 'isDataEnumFunction' + | 'enumVariant' + | 'discriminatedUnionDiscriminator' + | 'discriminatedUnionVariant' + | 'discriminatedUnionFunction' + | 'isDiscriminatedUnionFunction' | 'instructionAsyncInputType' | 'instructionSyncInputType' | 'instructionType' @@ -111,11 +111,11 @@ export const DEFAULT_NAME_TRANSFORMERS: NameTransformers = { accountFetchMaybeFromSeedsFunction: (name) => `fetchMaybe${pascalCase(name)}FromSeeds`, accountGetSizeFunction: (name) => `get${pascalCase(name)}Size`, - scalarEnumVariant: (name) => `${pascalCase(name)}`, - dataEnumDiscriminator: () => '__kind', - dataEnumVariant: (name) => `${pascalCase(name)}`, - dataEnumFunction: (name) => `${camelCase(name)}`, - isDataEnumFunction: (name) => `is${pascalCase(name)}`, + enumVariant: (name) => `${pascalCase(name)}`, + discriminatedUnionDiscriminator: () => '__kind', + discriminatedUnionVariant: (name) => `${pascalCase(name)}`, + discriminatedUnionFunction: (name) => `${camelCase(name)}`, + isDiscriminatedUnionFunction: (name) => `is${pascalCase(name)}`, instructionAsyncInputType: (name) => `${pascalCase(name)}AsyncInput`, instructionSyncInputType: (name) => `${pascalCase(name)}Input`, instructionType: (name) => `${pascalCase(name)}Instruction`, diff --git a/src/renderers/js-experimental/renderValueNodeVisitor.ts b/src/renderers/js-experimental/renderValueNodeVisitor.ts index 4dc2ac466..3daa586f5 100644 --- a/src/renderers/js-experimental/renderValueNodeVisitor.ts +++ b/src/renderers/js-experimental/renderValueNodeVisitor.ts @@ -24,7 +24,7 @@ export function renderValueNodeVisitor(input: { }, visitEnumValue(node) { const enumName = nameApi.dataType(node.enum.name); - const enumFunction = nameApi.dataEnumFunction(node.enum.name); + const enumFunction = nameApi.discriminatedUnionFunction(node.enum.name); const importFrom = node.enum.importFrom ?? 'generatedTypes'; const enumNode = linkables.get(node.enum)?.type; @@ -34,14 +34,14 @@ export function renderValueNodeVisitor(input: { : !nonScalarEnums.includes(node.enum.name); if (!node.value && isScalar) { - const variantName = nameApi.scalarEnumVariant(node.variant); + const variantName = nameApi.enumVariant(node.variant); return fragment(`${enumName}.${variantName}`).addImports( importFrom, enumName ); } - const variantName = nameApi.dataEnumVariant(node.variant); + const variantName = nameApi.discriminatedUnionVariant(node.variant); if (!node.value) { return fragment(`${enumFunction}('${variantName}')`).addImports( importFrom, diff --git a/src/renderers/js-experimental/templates/definedTypesPage.njk b/src/renderers/js-experimental/templates/definedTypesPage.njk index 688ab32b4..5849cad81 100644 --- a/src/renderers/js-experimental/templates/definedTypesPage.njk +++ b/src/renderers/js-experimental/templates/definedTypesPage.njk @@ -5,5 +5,5 @@ {{ imports }} {{ typeWithCodecFragment }} -{{ typeDataEnumHelpersFragment }} +{{ typeDiscriminatedUnionHelpersFragment }} {% endblock %} diff --git a/test/packages/js-experimental/src/generated/types/authorityType.ts b/test/packages/js-experimental/src/generated/types/authorityType.ts index 782cd376b..09b9a7933 100644 --- a/test/packages/js-experimental/src/generated/types/authorityType.ts +++ b/test/packages/js-experimental/src/generated/types/authorityType.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum AuthorityType { @@ -25,11 +25,11 @@ export enum AuthorityType { export type AuthorityTypeArgs = AuthorityType; export function getAuthorityTypeEncoder(): Encoder { - return getScalarEnumEncoder(AuthorityType); + return getEnumEncoder(AuthorityType); } export function getAuthorityTypeDecoder(): Decoder { - return getScalarEnumDecoder(AuthorityType); + return getEnumDecoder(AuthorityType); } export function getAuthorityTypeCodec(): Codec< diff --git a/test/packages/js-experimental/src/generated/types/burnArgs.ts b/test/packages/js-experimental/src/generated/types/burnArgs.ts index 03c97fd45..0c99ac532 100644 --- a/test/packages/js-experimental/src/generated/types/burnArgs.ts +++ b/test/packages/js-experimental/src/generated/types/burnArgs.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, getU64Decoder, getU64Encoder, } from '@solana/codecs'; @@ -24,11 +24,11 @@ export enum BurnArgs { export type BurnArgsArgs = BurnArgs; export function getBurnArgsEncoder(): Encoder { - return getScalarEnumEncoder(BurnArgs, { size: getU64Encoder() }); + return getEnumEncoder(BurnArgs, { size: getU64Encoder() }); } export function getBurnArgsDecoder(): Decoder { - return getScalarEnumDecoder(BurnArgs, { size: getU64Decoder() }); + return getEnumDecoder(BurnArgs, { size: getU64Decoder() }); } export function getBurnArgsCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/collectionDetails.ts b/test/packages/js-experimental/src/generated/types/collectionDetails.ts index 914fca35d..5800fff4e 100644 --- a/test/packages/js-experimental/src/generated/types/collectionDetails.ts +++ b/test/packages/js-experimental/src/generated/types/collectionDetails.ts @@ -10,11 +10,11 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, getU64Decoder, @@ -26,13 +26,13 @@ export type CollectionDetails = { __kind: 'V1'; size: bigint }; export type CollectionDetailsArgs = { __kind: 'V1'; size: number | bigint }; export function getCollectionDetailsEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ ['V1', getStructEncoder([['size', getU64Encoder()]])], ]); } export function getCollectionDetailsDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ ['V1', getStructDecoder([['size', getU64Decoder()]])], ]); } @@ -50,8 +50,12 @@ export function getCollectionDetailsCodec(): Codec< // Data Enum Helpers. export function collectionDetails( kind: 'V1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + CollectionDetailsArgs, + '__kind', + 'V1' + > +): GetDiscriminatedUnionVariant; export function collectionDetails< K extends CollectionDetailsArgs['__kind'], Data, diff --git a/test/packages/js-experimental/src/generated/types/delegateArgs.ts b/test/packages/js-experimental/src/generated/types/delegateArgs.ts index c36d04be2..29b10544a 100644 --- a/test/packages/js-experimental/src/generated/types/delegateArgs.ts +++ b/test/packages/js-experimental/src/generated/types/delegateArgs.ts @@ -10,11 +10,11 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, getU16Decoder, @@ -36,7 +36,7 @@ export type DelegateArgsArgs = | { __kind: 'TransferV1'; amount: number | bigint }; export function getDelegateArgsEncoder(): Encoder { - return getDataEnumEncoder( + return getDiscriminatedUnionEncoder( [ ['CollectionV1', getUnitEncoder()], ['SaleV1', getStructEncoder([['amount', getU64Encoder()]])], @@ -47,7 +47,7 @@ export function getDelegateArgsEncoder(): Encoder { } export function getDelegateArgsDecoder(): Decoder { - return getDataEnumDecoder( + return getDiscriminatedUnionDecoder( [ ['CollectionV1', getUnitDecoder()], ['SaleV1', getStructDecoder([['amount', getU64Decoder()]])], @@ -64,15 +64,23 @@ export function getDelegateArgsCodec(): Codec { // Data Enum Helpers. export function delegateArgs( kind: 'CollectionV1' -): GetDataEnumKind; +): GetDiscriminatedUnionVariant; export function delegateArgs( kind: 'SaleV1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + DelegateArgsArgs, + '__kind', + 'SaleV1' + > +): GetDiscriminatedUnionVariant; export function delegateArgs( kind: 'TransferV1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + DelegateArgsArgs, + '__kind', + 'TransferV1' + > +): GetDiscriminatedUnionVariant; export function delegateArgs( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/delegateRole.ts b/test/packages/js-experimental/src/generated/types/delegateRole.ts index 93d937fef..978365de7 100644 --- a/test/packages/js-experimental/src/generated/types/delegateRole.ts +++ b/test/packages/js-experimental/src/generated/types/delegateRole.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum DelegateRole { @@ -28,11 +28,11 @@ export enum DelegateRole { export type DelegateRoleArgs = DelegateRole; export function getDelegateRoleEncoder(): Encoder { - return getScalarEnumEncoder(DelegateRole); + return getEnumEncoder(DelegateRole); } export function getDelegateRoleDecoder(): Decoder { - return getScalarEnumDecoder(DelegateRole); + return getEnumDecoder(DelegateRole); } export function getDelegateRoleCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/escrowAuthority.ts b/test/packages/js-experimental/src/generated/types/escrowAuthority.ts index 89b832bcb..2b23134e4 100644 --- a/test/packages/js-experimental/src/generated/types/escrowAuthority.ts +++ b/test/packages/js-experimental/src/generated/types/escrowAuthority.ts @@ -15,11 +15,11 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, getTupleDecoder, @@ -35,7 +35,7 @@ export type EscrowAuthority = export type EscrowAuthorityArgs = EscrowAuthority; export function getEscrowAuthorityEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ ['TokenOwner', getUnitEncoder()], [ 'Creator', @@ -45,7 +45,7 @@ export function getEscrowAuthorityEncoder(): Encoder { } export function getEscrowAuthorityDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ ['TokenOwner', getUnitDecoder()], [ 'Creator', @@ -64,11 +64,15 @@ export function getEscrowAuthorityCodec(): Codec< // Data Enum Helpers. export function escrowAuthority( kind: 'TokenOwner' -): GetDataEnumKind; +): GetDiscriminatedUnionVariant; export function escrowAuthority( kind: 'Creator', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + EscrowAuthorityArgs, + '__kind', + 'Creator' + >['fields'] +): GetDiscriminatedUnionVariant; export function escrowAuthority( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/migrateArgs.ts b/test/packages/js-experimental/src/generated/types/migrateArgs.ts index fc66e515b..4597594c8 100644 --- a/test/packages/js-experimental/src/generated/types/migrateArgs.ts +++ b/test/packages/js-experimental/src/generated/types/migrateArgs.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum MigrateArgs { @@ -22,11 +22,11 @@ export enum MigrateArgs { export type MigrateArgsArgs = MigrateArgs; export function getMigrateArgsEncoder(): Encoder { - return getScalarEnumEncoder(MigrateArgs); + return getEnumEncoder(MigrateArgs); } export function getMigrateArgsDecoder(): Decoder { - return getScalarEnumDecoder(MigrateArgs); + return getEnumDecoder(MigrateArgs); } export function getMigrateArgsCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/mintArgs.ts b/test/packages/js-experimental/src/generated/types/mintArgs.ts index 34ae076c7..a0d520fdb 100644 --- a/test/packages/js-experimental/src/generated/types/mintArgs.ts +++ b/test/packages/js-experimental/src/generated/types/mintArgs.ts @@ -10,13 +10,13 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, Option, OptionOrNullable, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getOptionDecoder, getOptionEncoder, getStructDecoder, @@ -44,7 +44,7 @@ export type MintArgsArgs = { }; export function getMintArgsEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ [ 'V1', getStructEncoder([ @@ -56,7 +56,7 @@ export function getMintArgsEncoder(): Encoder { } export function getMintArgsDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ [ 'V1', getStructDecoder([ @@ -74,8 +74,8 @@ export function getMintArgsCodec(): Codec { // Data Enum Helpers. export function mintArgs( kind: 'V1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function mintArgs( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/operation.ts b/test/packages/js-experimental/src/generated/types/operation.ts index 037b6f1b6..23d442dc8 100644 --- a/test/packages/js-experimental/src/generated/types/operation.ts +++ b/test/packages/js-experimental/src/generated/types/operation.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum Operation { @@ -25,11 +25,11 @@ export enum Operation { export type OperationArgs = Operation; export function getOperationEncoder(): Encoder { - return getScalarEnumEncoder(Operation); + return getEnumEncoder(Operation); } export function getOperationDecoder(): Decoder { - return getScalarEnumDecoder(Operation); + return getEnumDecoder(Operation); } export function getOperationCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/payloadKey.ts b/test/packages/js-experimental/src/generated/types/payloadKey.ts index c6e0a44fa..421ba02b2 100644 --- a/test/packages/js-experimental/src/generated/types/payloadKey.ts +++ b/test/packages/js-experimental/src/generated/types/payloadKey.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum PayloadKey { @@ -25,11 +25,11 @@ export enum PayloadKey { export type PayloadKeyArgs = PayloadKey; export function getPayloadKeyEncoder(): Encoder { - return getScalarEnumEncoder(PayloadKey); + return getEnumEncoder(PayloadKey); } export function getPayloadKeyDecoder(): Decoder { - return getScalarEnumDecoder(PayloadKey); + return getEnumDecoder(PayloadKey); } export function getPayloadKeyCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/payloadType.ts b/test/packages/js-experimental/src/generated/types/payloadType.ts index 48721fff5..f52b9d623 100644 --- a/test/packages/js-experimental/src/generated/types/payloadType.ts +++ b/test/packages/js-experimental/src/generated/types/payloadType.ts @@ -15,15 +15,15 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, combineCodec, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, getTupleDecoder, @@ -48,7 +48,7 @@ export type PayloadTypeArgs = | { __kind: 'Number'; fields: [number | bigint] }; export function getPayloadTypeEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ [ 'Pubkey', getStructEncoder([['fields', getTupleEncoder([getAddressEncoder()])]]), @@ -74,7 +74,7 @@ export function getPayloadTypeEncoder(): Encoder { } export function getPayloadTypeDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ [ 'Pubkey', getStructDecoder([['fields', getTupleDecoder([getAddressDecoder()])]]), @@ -106,20 +106,32 @@ export function getPayloadTypeCodec(): Codec { // Data Enum Helpers. export function payloadType( kind: 'Pubkey', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + PayloadTypeArgs, + '__kind', + 'Pubkey' + >['fields'] +): GetDiscriminatedUnionVariant; export function payloadType( kind: 'Seeds', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function payloadType( kind: 'MerkleProof', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + PayloadTypeArgs, + '__kind', + 'MerkleProof' + > +): GetDiscriminatedUnionVariant; export function payloadType( kind: 'Number', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent< + PayloadTypeArgs, + '__kind', + 'Number' + >['fields'] +): GetDiscriminatedUnionVariant; export function payloadType( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/revokeArgs.ts b/test/packages/js-experimental/src/generated/types/revokeArgs.ts index 157d9a2a8..0e191e532 100644 --- a/test/packages/js-experimental/src/generated/types/revokeArgs.ts +++ b/test/packages/js-experimental/src/generated/types/revokeArgs.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum RevokeArgs { @@ -24,11 +24,11 @@ export enum RevokeArgs { export type RevokeArgsArgs = RevokeArgs; export function getRevokeArgsEncoder(): Encoder { - return getScalarEnumEncoder(RevokeArgs); + return getEnumEncoder(RevokeArgs); } export function getRevokeArgsDecoder(): Decoder { - return getScalarEnumDecoder(RevokeArgs); + return getEnumDecoder(RevokeArgs); } export function getRevokeArgsCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/taKey.ts b/test/packages/js-experimental/src/generated/types/taKey.ts index 4f225b1fb..0eca299f1 100644 --- a/test/packages/js-experimental/src/generated/types/taKey.ts +++ b/test/packages/js-experimental/src/generated/types/taKey.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum TaKey { @@ -23,11 +23,11 @@ export enum TaKey { export type TaKeyArgs = TaKey; export function getTaKeyEncoder(): Encoder { - return getScalarEnumEncoder(TaKey); + return getEnumEncoder(TaKey); } export function getTaKeyDecoder(): Decoder { - return getScalarEnumDecoder(TaKey); + return getEnumDecoder(TaKey); } export function getTaKeyCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/tmCreateArgs.ts b/test/packages/js-experimental/src/generated/types/tmCreateArgs.ts index 6018807d2..e013644b5 100644 --- a/test/packages/js-experimental/src/generated/types/tmCreateArgs.ts +++ b/test/packages/js-experimental/src/generated/types/tmCreateArgs.ts @@ -10,13 +10,13 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, Option, OptionOrNullable, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getOptionDecoder, getOptionEncoder, getStructDecoder, @@ -56,7 +56,7 @@ export type TmCreateArgsArgs = }; export function getTmCreateArgsEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ [ 'V1', getStructEncoder([ @@ -76,7 +76,7 @@ export function getTmCreateArgsEncoder(): Encoder { } export function getTmCreateArgsDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ [ 'V1', getStructDecoder([ @@ -102,12 +102,12 @@ export function getTmCreateArgsCodec(): Codec { // Data Enum Helpers. export function tmCreateArgs( kind: 'V1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function tmCreateArgs( kind: 'V2', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function tmCreateArgs( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/tmKey.ts b/test/packages/js-experimental/src/generated/types/tmKey.ts index 6f79e47bd..14314a8da 100644 --- a/test/packages/js-experimental/src/generated/types/tmKey.ts +++ b/test/packages/js-experimental/src/generated/types/tmKey.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum TmKey { @@ -33,11 +33,11 @@ export enum TmKey { export type TmKeyArgs = TmKey; export function getTmKeyEncoder(): Encoder { - return getScalarEnumEncoder(TmKey); + return getEnumEncoder(TmKey); } export function getTmKeyDecoder(): Decoder { - return getScalarEnumDecoder(TmKey); + return getEnumDecoder(TmKey); } export function getTmKeyCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/tokenStandard.ts b/test/packages/js-experimental/src/generated/types/tokenStandard.ts index 83dd95abe..f3b634673 100644 --- a/test/packages/js-experimental/src/generated/types/tokenStandard.ts +++ b/test/packages/js-experimental/src/generated/types/tokenStandard.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum TokenStandard { @@ -26,11 +26,11 @@ export enum TokenStandard { export type TokenStandardArgs = TokenStandard; export function getTokenStandardEncoder(): Encoder { - return getScalarEnumEncoder(TokenStandard); + return getEnumEncoder(TokenStandard); } export function getTokenStandardDecoder(): Decoder { - return getScalarEnumDecoder(TokenStandard); + return getEnumDecoder(TokenStandard); } export function getTokenStandardCodec(): Codec< diff --git a/test/packages/js-experimental/src/generated/types/transferArgs.ts b/test/packages/js-experimental/src/generated/types/transferArgs.ts index d4bed8fe7..3274b6ec6 100644 --- a/test/packages/js-experimental/src/generated/types/transferArgs.ts +++ b/test/packages/js-experimental/src/generated/types/transferArgs.ts @@ -10,13 +10,13 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, Option, OptionOrNullable, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getOptionDecoder, getOptionEncoder, getStructDecoder, @@ -44,7 +44,7 @@ export type TransferArgsArgs = { }; export function getTransferArgsEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ [ 'V1', getStructEncoder([ @@ -56,7 +56,7 @@ export function getTransferArgsEncoder(): Encoder { } export function getTransferArgsDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ [ 'V1', getStructDecoder([ @@ -74,8 +74,8 @@ export function getTransferArgsCodec(): Codec { // Data Enum Helpers. export function transferArgs( kind: 'V1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function transferArgs( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/updateArgs.ts b/test/packages/js-experimental/src/generated/types/updateArgs.ts index 22c2dddcb..40a6711dd 100644 --- a/test/packages/js-experimental/src/generated/types/updateArgs.ts +++ b/test/packages/js-experimental/src/generated/types/updateArgs.ts @@ -15,8 +15,8 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, Option, OptionOrNullable, combineCodec, @@ -24,8 +24,8 @@ import { getArrayEncoder, getBooleanDecoder, getBooleanEncoder, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getOptionDecoder, getOptionEncoder, getStringDecoder, @@ -121,7 +121,7 @@ export type UpdateArgsArgs = { }; export function getUpdateArgsEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ [ 'V1', mapEncoder( @@ -172,7 +172,7 @@ export function getUpdateArgsEncoder(): Encoder { } export function getUpdateArgsDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ [ 'V1', getStructDecoder([ @@ -217,8 +217,8 @@ export function getUpdateArgsCodec(): Codec { // Data Enum Helpers. export function updateArgs( kind: 'V1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function updateArgs( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/useAssetArgs.ts b/test/packages/js-experimental/src/generated/types/useAssetArgs.ts index a2137ceef..6c66ec648 100644 --- a/test/packages/js-experimental/src/generated/types/useAssetArgs.ts +++ b/test/packages/js-experimental/src/generated/types/useAssetArgs.ts @@ -10,11 +10,11 @@ import { Codec, Decoder, Encoder, - GetDataEnumKind, - GetDataEnumKindContent, + GetDiscriminatedUnionVariant, + GetDiscriminatedUnionVariantContent, combineCodec, - getDataEnumDecoder, - getDataEnumEncoder, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, getStructDecoder, getStructEncoder, getU64Decoder, @@ -26,13 +26,13 @@ export type UseAssetArgs = { __kind: 'V1'; useCount: bigint }; export type UseAssetArgsArgs = { __kind: 'V1'; useCount: number | bigint }; export function getUseAssetArgsEncoder(): Encoder { - return getDataEnumEncoder([ + return getDiscriminatedUnionEncoder([ ['V1', getStructEncoder([['useCount', getU64Encoder()]])], ]); } export function getUseAssetArgsDecoder(): Decoder { - return getDataEnumDecoder([ + return getDiscriminatedUnionDecoder([ ['V1', getStructDecoder([['useCount', getU64Decoder()]])], ]); } @@ -44,8 +44,8 @@ export function getUseAssetArgsCodec(): Codec { // Data Enum Helpers. export function useAssetArgs( kind: 'V1', - data: GetDataEnumKindContent -): GetDataEnumKind; + data: GetDiscriminatedUnionVariantContent +): GetDiscriminatedUnionVariant; export function useAssetArgs( kind: K, data?: Data diff --git a/test/packages/js-experimental/src/generated/types/useMethod.ts b/test/packages/js-experimental/src/generated/types/useMethod.ts index a206c846e..77771f0cb 100644 --- a/test/packages/js-experimental/src/generated/types/useMethod.ts +++ b/test/packages/js-experimental/src/generated/types/useMethod.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum UseMethod { @@ -24,11 +24,11 @@ export enum UseMethod { export type UseMethodArgs = UseMethod; export function getUseMethodEncoder(): Encoder { - return getScalarEnumEncoder(UseMethod); + return getEnumEncoder(UseMethod); } export function getUseMethodDecoder(): Decoder { - return getScalarEnumDecoder(UseMethod); + return getEnumDecoder(UseMethod); } export function getUseMethodCodec(): Codec { diff --git a/test/packages/js-experimental/src/generated/types/verifyArgs.ts b/test/packages/js-experimental/src/generated/types/verifyArgs.ts index de2e670d1..3525b0df9 100644 --- a/test/packages/js-experimental/src/generated/types/verifyArgs.ts +++ b/test/packages/js-experimental/src/generated/types/verifyArgs.ts @@ -11,8 +11,8 @@ import { Decoder, Encoder, combineCodec, - getScalarEnumDecoder, - getScalarEnumEncoder, + getEnumDecoder, + getEnumEncoder, } from '@solana/codecs'; export enum VerifyArgs { @@ -22,11 +22,11 @@ export enum VerifyArgs { export type VerifyArgsArgs = VerifyArgs; export function getVerifyArgsEncoder(): Encoder { - return getScalarEnumEncoder(VerifyArgs); + return getEnumEncoder(VerifyArgs); } export function getVerifyArgsDecoder(): Decoder { - return getScalarEnumDecoder(VerifyArgs); + return getEnumDecoder(VerifyArgs); } export function getVerifyArgsCodec(): Codec { From 6dfc64b004e1cc805ae4f9f4a5fb5bc69214aafa Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Wed, 27 Mar 2024 14:28:05 +0000 Subject: [PATCH 2/3] Update web3.js --- test/packages/js-experimental/package.json | 12 +- test/packages/js-experimental/pnpm-lock.yaml | 207 ++++++++++--------- 2 files changed, 118 insertions(+), 101 deletions(-) diff --git a/test/packages/js-experimental/package.json b/test/packages/js-experimental/package.json index f05b10ec3..625787f80 100644 --- a/test/packages/js-experimental/package.json +++ b/test/packages/js-experimental/package.json @@ -12,12 +12,12 @@ "author": "", "license": "ISC", "dependencies": { - "@solana/accounts": "2.0.0-experimental.a7a613a", - "@solana/addresses": "2.0.0-experimental.a7a613a", - "@solana/codecs": "2.0.0-experimental.a7a613a", - "@solana/instructions": "2.0.0-experimental.a7a613a", - "@solana/programs": "2.0.0-experimental.a7a613a", - "@solana/signers": "2.0.0-experimental.a7a613a" + "@solana/accounts": "2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be", + "@solana/addresses": "2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be", + "@solana/codecs": "2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be", + "@solana/instructions": "2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be", + "@solana/programs": "2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be", + "@solana/signers": "2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be" }, "devDependencies": { "@solana/eslint-config-solana": "^3.0.3", diff --git a/test/packages/js-experimental/pnpm-lock.yaml b/test/packages/js-experimental/pnpm-lock.yaml index 398f343ce..8df5f39f6 100644 --- a/test/packages/js-experimental/pnpm-lock.yaml +++ b/test/packages/js-experimental/pnpm-lock.yaml @@ -6,23 +6,23 @@ settings: dependencies: '@solana/accounts': - specifier: 2.0.0-experimental.a7a613a - version: 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + specifier: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + version: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) '@solana/addresses': - specifier: 2.0.0-experimental.a7a613a - version: 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + specifier: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + version: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) '@solana/codecs': - specifier: 2.0.0-experimental.a7a613a - version: 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + specifier: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + version: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) '@solana/instructions': - specifier: 2.0.0-experimental.a7a613a - version: 2.0.0-experimental.a7a613a + specifier: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + version: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be '@solana/programs': - specifier: 2.0.0-experimental.a7a613a - version: 2.0.0-experimental.a7a613a + specifier: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + version: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be '@solana/signers': - specifier: 2.0.0-experimental.a7a613a - version: 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + specifier: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + version: 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) devDependencies: '@solana/eslint-config-solana': @@ -117,77 +117,86 @@ packages: fastq: 1.17.1 dev: true - /@solana/accounts@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-fifvhOC49UmCqooNI5inAnkkVfLc2diQ/R3WDQSocJ8u9E3chDFg+SPmwXRNNk3Prp1MnbJhsNpRPbO+7A/ypA==} + /@solana/accounts@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-evq4lBzOGoiRmeoQZYVf6+rqWEFhk2CTZ8A+zAWadJRTG/oER8CG73ios9zZnvI12cEytpUg8D0bAmUO03Qn4w==} dependencies: - '@solana/addresses': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-strings': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/rpc-spec': 2.0.0-experimental.a7a613a - '@solana/rpc-types': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/addresses': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-strings': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/rpc-spec': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/rpc-types': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false - /@solana/addresses@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-W5lc7y9CQYwooshmZ6qr2T6Ymj6aVVEM0hlaQA6GVZ20PYCJOGSXg0mloNalG0Fp50J2ouE3Xhy5OoFjoYQgvQ==} + /@solana/addresses@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-SwpF2hRN90Z1f4QdZLBCWMjTHNcL0mo1uuEdM7ZFn9Vfd3U9i1EhAhy4B52JzJ5R+ZSduawrVB99Bdz8vlikAA==} dependencies: - '@solana/assertions': 2.0.0-experimental.a7a613a - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-strings': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/assertions': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-strings': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false - /@solana/assertions@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-V3/Q4hkdRkaSiJE3FG7ELhgFnKC1WfnrkIm+6gUfhrzh5Vihg494HXV+x7xEOJFw5m3EYmTDiYEevIr9d5qvMg==} + /@solana/assertions@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-s/5lPMD4NfQdjR+jb0M0MwJ0nD3evKKg41JtXT+OWUVH6+hv4Umfxb0+eqOiN2/xyWIlC3WK5ga2qYtIiwVvNg==} + dependencies: + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/codecs-core@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-4C0GCWoIP8zvUd4kIs4QQnNupjh+GEXcoO+RAYRJ8nDlDW4DdEhb/W4weC+hoFaEjr0STEhCeH4yMWaKF3L6WQ==} + /@solana/codecs-core@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-8yQcIGntcBsQTF9HRNPO5kTeThMeUesKN6DPBfXwKlsllHG4kl8Fp0mA5pbRGvlxD8Y2dOyqHz46YOHXEcf8fQ==} + dependencies: + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/codecs-data-structures@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-K22h6+YA8hVZ5Nq+49nFUIUJgOMxYP9zEt69oQxh/OnETZF538uIOrsCFU7MzLCLCwUnoJynkBY4Oycm+4m7OQ==} + /@solana/codecs-data-structures@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-NJAI0bp0V2iYnzJs7CA8VCx7Vj6RNEtPU2jgsXfMw67DR88awRQi4KvW+vVLgfiG45+ypWYRA/VVHvHePLcytQ==} dependencies: - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-numbers': 2.0.0-experimental.a7a613a + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-numbers': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/codecs-numbers@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-B1aNhPkoSRqMskHcgB/u0/tnAWfrp6dYHf9o36q+ppAoOZdbS9xz4rwzkt2FMUHaoSWPPa6/tHFQ0Vbge3VMRA==} + /@solana/codecs-numbers@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-hMHSO1rQT6NpoAvT86zA8Uh04tVhjzOLWGU1O5JZW5mQWhz33XmoCpU3gQFgn66VypDyEu6/2R/toSQHX8wiBQ==} dependencies: - '@solana/codecs-core': 2.0.0-experimental.a7a613a + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/codecs-strings@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-Tw9fqT8UzScpuP4bsDCiKb7DGXQ9BmsqvLJY7b1sjga9Vr0M3mA8BGHemz4WusHXb9AXJEN1Pc1NVYxd4rsH0w==} + /@solana/codecs-strings@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-zu7NMXUEzwpYJNms8tjeFHWf3no9kvAcaXVGXrTU9A5XqCD9w2Hij/HD6nuDHCOXZTsc13z9AgaRecYbXaLhfg==} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 dependencies: - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-numbers': 2.0.0-experimental.a7a613a + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-numbers': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be fastestsmallesttextencoderdecoder: 1.0.22 dev: false - /@solana/codecs@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-9egdKvdYisL1pc4EXQJmikuIJISJFvmRkSFq147xSQoTg19J7wKikILqa39/jnthqE1NwyVgZgkv/h2ILoB/8A==} + /@solana/codecs@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-MEDwGa8J3tfSSTkAsCz5rnUuGkkqgCHhHAGM9+rQyzt2D94n9tM7XRdn63o6tL8eRCJYX3JEtXupaal1U3Q9GA==} dependencies: - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-data-structures': 2.0.0-experimental.a7a613a - '@solana/codecs-numbers': 2.0.0-experimental.a7a613a - '@solana/codecs-strings': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/options': 2.0.0-experimental.a7a613a + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-data-structures': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-numbers': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-strings': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/options': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false - /@solana/errors@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-B7rkUWtAqXgsQwgOAH2qRyy/SOZ1T/3ThC4YezmWwbjxNHqx7+kekoCRhyshkw5AdhV7U4kQJSACQq/j3Cy1WA==} + /@solana/errors@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-LS7P08/Wlmh4jxrtSrHz0AskiZ/SxmjqdGtgfgFa5m+tE0U0F91R9dzQ9imLIh30P+DYiNUyCkBFpGkR8u/mEg==} hasBin: true dependencies: chalk: 5.3.0 - commander: 11.1.0 + commander: 12.0.0 dev: false /@solana/eslint-config-solana@3.0.3(@typescript-eslint/eslint-plugin@6.21.0)(@typescript-eslint/parser@6.21.0)(eslint-plugin-jest@27.9.0)(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-simple-import-sort@10.0.0)(eslint-plugin-sort-keys-fix@1.1.2)(eslint-plugin-typescript-sort-keys@3.2.0)(eslint@8.57.0)(typescript@5.3.3): @@ -214,78 +223,86 @@ packages: typescript: 5.3.3 dev: true - /@solana/functional@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-OkaYVw6O5vNzOjEut0E44mxF1yS6BMXCnUcZuKy9nvuHNeUFZ6BjFJhMQXOGhhs5qNzI9m+JHnrb7z3J0ZPrBw==} + /@solana/functional@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-qJ4LtukRnT4oTnizRZKHXIzhWu1P0+eza69XnNVMzQA5/PZ4Z0fk980Dgbk17k2p6lBlDqrhuVtcnXneh94ivw==} dev: false - /@solana/instructions@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-UJSlElg/w+pTYySxmane6RNP5Ghe52SJDy0gsEC40SkusdGtJbwlusNfGVZVFFGf14n+urWKyR+2gcdaj11qJw==} + /@solana/instructions@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-bN1GdQxTklPxE46ivPVFInQk1KaPdgYdLvh7aamS+T5DrbFSCRTDhpgGJ/oWP4BibqpKQEvgiM09V+7E8lLb0A==} + dependencies: + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/keys@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-A2Hf4IL7EH85yaadZMwu8dVMDzKLVRpIug8QjgKKiJRhu9FIezzbUDMT8l4ILBOpsRdcwgcK3/YFVRdVoMcWmA==} + /@solana/keys@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-duhsB4xTjGaRZTyHGg+BQJvOW4Yf8w2yItZHdwgYuDlCdFWS77GVb3ffwo+RvB1JqEd3ab2pewIl1cQIw1Axug==} dependencies: - '@solana/assertions': 2.0.0-experimental.a7a613a - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-strings': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/errors': 2.0.0-experimental.a7a613a + '@solana/assertions': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-strings': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false - /@solana/options@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-gUV7uSOfHrOBLt3+Wv3LJDYkVQN1PTmNu511/zkkKdE3AwUMUfG7x+jMg85h3Tiw7xPs+HOgHBEyGdiYHk0W1g==} + /@solana/options@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-F8SlYYhsEmIhZN5p6xN4Rb6EpJagBVov0auST7uVQcqVCyjZU20GOxLySr6oH0CA1bwqFV8KMtPXbz/P1btShA==} dependencies: - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-numbers': 2.0.0-experimental.a7a613a + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-numbers': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/programs@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-1A6iwvlKmuJKZrL4+bTZUV1fh4aIHDqtCuQofRdenK46TJ0QqyTewEG3i6G1UuDQx2F6eKoFL3kC0QDK+7HUyw==} + /@solana/programs@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-0g/tWJiL3YKHIcv9PEtTfyrMaYs7O293N/+7LBtUGhEjNBqJMbsMaX1QsSRypnCAtvrJ1o/HSwl7g0mJ6XPENw==} dev: false - /@solana/rpc-spec-types@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-lyZmEHac9WEL0Uf02X6sM7/vqGW6NAGV1fW3JRaLI9KOjMtN5OmRMiJiPhDKFHM/mBHGs0ddDwABBR0M1rNbzw==} + /@solana/rpc-spec-types@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-f9f1QwYDlAGKxAQy6E3uNxNU9OwG8ywtoSqrsW96xWom1rD4WrFUp4EuRJjvEEkwFFJqPogztdn85qX7YLB+mQ==} dev: false - /@solana/rpc-spec@2.0.0-experimental.a7a613a: - resolution: {integrity: sha512-YfCbUxtSP/uVD+EPnM709JFF/LDBAUiLcosXLQZF62qSEDGWc15MelfXDHHqcSdUaPbxy6cCCqbVUhWaZt4ifQ==} + /@solana/rpc-spec@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be: + resolution: {integrity: sha512-OPAgRPt1xqc8Wvh2477kcpeVqSwiVkVq6ZqwfjFSH8/bfhXJmJVviXfSXn/v+ckQhs9lf4c/W24Co2YSesH0Xw==} dependencies: - '@solana/rpc-spec-types': 2.0.0-experimental.a7a613a + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/rpc-spec-types': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be dev: false - /@solana/rpc-types@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-oICRh5Q4/5N/QRxea+xnUxLGFEp7jgRmJHqsR1eDhCUoSntwBL9ME3bdvsQh65gZ9DjKMUIU6FAPUzgmz/upWg==} + /@solana/rpc-types@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-hCOZn2vmI8s4nr+bt54ae5HI3v6FFh2nqeONBrC7/StdybYhRO3qYsJzLPsRCdzaUttWiHfbmEpi/grJgcltow==} dependencies: - '@solana/addresses': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/codecs-strings': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/addresses': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-numbers': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-strings': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false - /@solana/signers@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-2gnsMbDDnzcj63YiqkuNfcRIcWJEbuW2gwYfuypbby86g4etMhnYlsYwbRptb2BBd79ho0vBQfJco22D2UiCKw==} + /@solana/signers@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-prhuHl9KWSuYXdXNl1+hRygKdttZ1QzCRj/7GTNY8f3DtGi9IGMPIAngHWz5lqzKCHHjZlT0kDZpGCFdbShHjA==} dependencies: - '@solana/addresses': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/errors': 2.0.0-experimental.a7a613a - '@solana/instructions': 2.0.0-experimental.a7a613a - '@solana/keys': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/transactions': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/addresses': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/instructions': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/keys': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/transactions': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false - /@solana/transactions@2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-DxxMzGEPGw0s3+AQGaqJqqFkcGWFJFuMB/z3U3cYMA5AmDZ3y51lGRsUonvdYw/ksQOGXawS6hrTeQ5VPu1yig==} - dependencies: - '@solana/addresses': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/codecs-core': 2.0.0-experimental.a7a613a - '@solana/codecs-data-structures': 2.0.0-experimental.a7a613a - '@solana/codecs-numbers': 2.0.0-experimental.a7a613a - '@solana/codecs-strings': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) - '@solana/errors': 2.0.0-experimental.a7a613a - '@solana/functional': 2.0.0-experimental.a7a613a - '@solana/keys': 2.0.0-experimental.a7a613a(fastestsmallesttextencoderdecoder@1.0.22) + /@solana/transactions@2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-FIhqM+H8kc2gWnvUqSXJ2OzO1XO+KyFxxY4UttqlyYN1WXCS6ZrVrO67B9mc8rwN8AfvnOrWhRd0dP1ClbooDA==} + dependencies: + '@solana/addresses': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/codecs-core': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-data-structures': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-numbers': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/codecs-strings': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/errors': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/functional': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/instructions': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be + '@solana/keys': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) + '@solana/rpc-types': 2.0.0-preview.1.20240327135415.5b21c65e6779dd873d0a2d5ba2c7dd1ca607e2be(fastestsmallesttextencoderdecoder@1.0.22) transitivePeerDependencies: - fastestsmallesttextencoderdecoder dev: false @@ -620,9 +637,9 @@ packages: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: true - /commander@11.1.0: - resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} - engines: {node: '>=16'} + /commander@12.0.0: + resolution: {integrity: sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==} + engines: {node: '>=18'} dev: false /concat-map@0.0.1: From 46c1020e29fa8318592f7a42c34d0b9986a79a1a Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Wed, 27 Mar 2024 14:39:14 +0000 Subject: [PATCH 3/3] Use readonly for tuple arrays --- src/renderers/js-experimental/getTypeManifestVisitor.ts | 2 +- .../src/generated/types/escrowAuthority.ts | 2 +- .../src/generated/types/extendedPayload.ts | 4 ++-- .../js-experimental/src/generated/types/payloadType.ts | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderers/js-experimental/getTypeManifestVisitor.ts b/src/renderers/js-experimental/getTypeManifestVisitor.ts index 700620e13..99225bf2c 100644 --- a/src/renderers/js-experimental/getTypeManifestVisitor.ts +++ b/src/renderers/js-experimental/getTypeManifestVisitor.ts @@ -475,7 +475,7 @@ export function getTypeManifestVisitor(input: { const items = tupleType.items.map((item) => visit(item, self)); const mergedManifest = mergeManifests( items, - (types) => `[${types.join(', ')}]`, + (types) => `readonly [${types.join(', ')}]`, (codecs) => `[${codecs.join(', ')}]` ); mergedManifest.encoder diff --git a/test/packages/js-experimental/src/generated/types/escrowAuthority.ts b/test/packages/js-experimental/src/generated/types/escrowAuthority.ts index 2b23134e4..4ad08afba 100644 --- a/test/packages/js-experimental/src/generated/types/escrowAuthority.ts +++ b/test/packages/js-experimental/src/generated/types/escrowAuthority.ts @@ -30,7 +30,7 @@ import { export type EscrowAuthority = | { __kind: 'TokenOwner' } - | { __kind: 'Creator'; fields: [Address] }; + | { __kind: 'Creator'; fields: readonly [Address] }; export type EscrowAuthorityArgs = EscrowAuthority; diff --git a/test/packages/js-experimental/src/generated/types/extendedPayload.ts b/test/packages/js-experimental/src/generated/types/extendedPayload.ts index 09f11fa20..e45e5912a 100644 --- a/test/packages/js-experimental/src/generated/types/extendedPayload.ts +++ b/test/packages/js-experimental/src/generated/types/extendedPayload.ts @@ -35,12 +35,12 @@ import { export type ExtendedPayload = { map: Map; - args: [number, string]; + args: readonly [number, string]; }; export type ExtendedPayloadArgs = { map: Map; - args: [number, string]; + args: readonly [number, string]; }; export function getExtendedPayloadEncoder(): Encoder { diff --git a/test/packages/js-experimental/src/generated/types/payloadType.ts b/test/packages/js-experimental/src/generated/types/payloadType.ts index f52b9d623..c495a9431 100644 --- a/test/packages/js-experimental/src/generated/types/payloadType.ts +++ b/test/packages/js-experimental/src/generated/types/payloadType.ts @@ -36,16 +36,16 @@ import { /** This is a union of all the possible payload types. */ export type PayloadType = - | { __kind: 'Pubkey'; fields: [Address] } + | { __kind: 'Pubkey'; fields: readonly [Address] } | { __kind: 'Seeds'; seeds: Array } | { __kind: 'MerkleProof'; leaf: Uint8Array; proof: Array } - | { __kind: 'Number'; fields: [bigint] }; + | { __kind: 'Number'; fields: readonly [bigint] }; export type PayloadTypeArgs = - | { __kind: 'Pubkey'; fields: [Address] } + | { __kind: 'Pubkey'; fields: readonly [Address] } | { __kind: 'Seeds'; seeds: Array } | { __kind: 'MerkleProof'; leaf: Uint8Array; proof: Array } - | { __kind: 'Number'; fields: [number | bigint] }; + | { __kind: 'Number'; fields: readonly [number | bigint] }; export function getPayloadTypeEncoder(): Encoder { return getDiscriminatedUnionEncoder([