Skip to content

Commit

Permalink
Regenerate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Apr 19, 2024
1 parent 7088cc4 commit a055611
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@
*/

import { Address } from '@solana/addresses';
import { Program } from '@solana/programs';

export const PUBKEY_TESTS_PROGRAM_ADDRESS =
'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d' as Address<'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'>;

export type PubkeyTestsProgram =
Program<'PubkeyTests1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d'>;

export function getPubkeyTestsProgram(): PubkeyTestsProgram {
return {
name: 'pubkeyTests',
address: PUBKEY_TESTS_PROGRAM_ADDRESS,
};
}
46 changes: 30 additions & 16 deletions test/packages/js-experimental/src/generated/types/ruleSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
Codec,
Decoder,
Encoder,
GetDataEnumKind,
GetDataEnumKindContent,
GetDiscriminatedUnionVariant,
GetDiscriminatedUnionVariantContent,
combineCodec,
getArrayDecoder,
getArrayEncoder,
getDataEnumDecoder,
getDataEnumEncoder,
getDiscriminatedUnionDecoder,
getDiscriminatedUnionEncoder,
getStructDecoder,
getStructEncoder,
getTupleDecoder,
Expand All @@ -32,14 +32,14 @@ import {

export type RuleSet =
| { __kind: 'None' }
| { __kind: 'Single'; fields: [Address] }
| { __kind: 'ProgramAllowList'; fields: [Array<Address>] }
| { __kind: 'ProgramDenyList'; fields: [Array<Address>] };
| { __kind: 'Single'; fields: readonly [Address] }
| { __kind: 'ProgramAllowList'; fields: readonly [Array<Address>] }
| { __kind: 'ProgramDenyList'; fields: readonly [Array<Address>] };

export type RuleSetArgs = RuleSet;

export function getRuleSetEncoder(): Encoder<RuleSetArgs> {
return getDataEnumEncoder([
return getDiscriminatedUnionEncoder([
['None', getUnitEncoder()],
[
'Single',
Expand All @@ -61,7 +61,7 @@ export function getRuleSetEncoder(): Encoder<RuleSetArgs> {
}

export function getRuleSetDecoder(): Decoder<RuleSet> {
return getDataEnumDecoder([
return getDiscriminatedUnionDecoder([
['None', getUnitDecoder()],
[
'Single',
Expand All @@ -87,19 +87,33 @@ export function getRuleSetCodec(): Codec<RuleSetArgs, RuleSet> {
}

// Data Enum Helpers.
export function ruleSet(kind: 'None'): GetDataEnumKind<RuleSetArgs, 'None'>;
export function ruleSet(
kind: 'None'
): GetDiscriminatedUnionVariant<RuleSetArgs, '__kind', 'None'>;
export function ruleSet(
kind: 'Single',
data: GetDataEnumKindContent<RuleSetArgs, 'Single'>['fields']
): GetDataEnumKind<RuleSetArgs, 'Single'>;
data: GetDiscriminatedUnionVariantContent<
RuleSetArgs,
'__kind',
'Single'
>['fields']
): GetDiscriminatedUnionVariant<RuleSetArgs, '__kind', 'Single'>;
export function ruleSet(
kind: 'ProgramAllowList',
data: GetDataEnumKindContent<RuleSetArgs, 'ProgramAllowList'>['fields']
): GetDataEnumKind<RuleSetArgs, 'ProgramAllowList'>;
data: GetDiscriminatedUnionVariantContent<
RuleSetArgs,
'__kind',
'ProgramAllowList'
>['fields']
): GetDiscriminatedUnionVariant<RuleSetArgs, '__kind', 'ProgramAllowList'>;
export function ruleSet(
kind: 'ProgramDenyList',
data: GetDataEnumKindContent<RuleSetArgs, 'ProgramDenyList'>['fields']
): GetDataEnumKind<RuleSetArgs, 'ProgramDenyList'>;
data: GetDiscriminatedUnionVariantContent<
RuleSetArgs,
'__kind',
'ProgramDenyList'
>['fields']
): GetDiscriminatedUnionVariant<RuleSetArgs, '__kind', 'ProgramDenyList'>;
export function ruleSet<K extends RuleSetArgs['__kind'], Data>(
kind: K,
data?: Data
Expand Down
10 changes: 8 additions & 2 deletions test/renderers/rust/instructionsPage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import test from 'ava';
import { instructionArgumentNode, instructionNode, programNode, remainderSizeNode, stringTypeNode, visit } from '../../../src';
import {
instructionArgumentNode,
instructionNode,
programNode,
stringTypeNode,
visit,
} from '../../../src';
import { getRenderMapVisitor } from '../../../src/renderers/rust/getRenderMapVisitor';
import { codeContains } from './_setup';

Expand Down Expand Up @@ -32,7 +38,7 @@ test('it renders an instruction with a remainder str', (t) => {
arguments: [
instructionArgumentNode({
name: 'memo',
type: stringTypeNode({ size: remainderSizeNode() }),
type: stringTypeNode('utf8'),
}),
],
}),
Expand Down

0 comments on commit a055611

Please sign in to comment.