Skip to content

Commit 855c094

Browse files
authored
Use ReadonlyUint8Arrays with InstructionWithData types (#714)
1 parent 364578e commit 855c094

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+158
-104
lines changed

.changeset/flat-suns-admire.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@codama/renderers-js': minor
3+
'@codama/dynamic-parsers': patch
4+
---
5+
6+
Use `ReadonlyUint8Arrays` with `InstructionWithData` types

packages/dynamic-parsers/src/parsers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function parseInstruction(
4949
root: RootNode,
5050
instruction: Instruction &
5151
InstructionWithAccounts<readonly (AccountLookupMeta | AccountMeta)[]> &
52-
InstructionWithData<Uint8Array>,
52+
InstructionWithData<ReadonlyUint8Array>,
5353
): ParsedInstruction | undefined {
5454
const parsedData = parseInstructionData(root, instruction.data);
5555
if (!parsedData) return undefined;

packages/renderers-js/e2e/anchor/src/generated/instructions/createGuard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export type CreateGuardInstruction<
9494
| AccountMeta<string> = '11111111111111111111111111111111',
9595
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
9696
> = Instruction<TProgram> &
97-
InstructionWithData<Uint8Array> &
97+
InstructionWithData<ReadonlyUint8Array> &
9898
InstructionWithAccounts<
9999
[
100100
TAccountGuard extends string
@@ -511,7 +511,7 @@ export function parseCreateGuardInstruction<
511511
>(
512512
instruction: Instruction<TProgram> &
513513
InstructionWithAccounts<TAccountMetas> &
514-
InstructionWithData<Uint8Array>
514+
InstructionWithData<ReadonlyUint8Array>
515515
): ParsedCreateGuardInstruction<TProgram, TAccountMetas> {
516516
if (instruction.accounts.length < 8) {
517517
// TODO: Coded error.

packages/renderers-js/e2e/anchor/src/generated/instructions/execute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export type ExecuteInstruction<
5858
| AccountMeta<string> = 'Sysvar1nstructions1111111111111111111111111',
5959
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
6060
> = Instruction<TProgram> &
61-
InstructionWithData<Uint8Array> &
61+
InstructionWithData<ReadonlyUint8Array> &
6262
InstructionWithAccounts<
6363
[
6464
TAccountSourceAccount extends string
@@ -389,7 +389,7 @@ export function parseExecuteInstruction<
389389
>(
390390
instruction: Instruction<TProgram> &
391391
InstructionWithAccounts<TAccountMetas> &
392-
InstructionWithData<Uint8Array>
392+
InstructionWithData<ReadonlyUint8Array>
393393
): ParsedExecuteInstruction<TProgram, TAccountMetas> {
394394
if (instruction.accounts.length < 7) {
395395
// TODO: Coded error.

packages/renderers-js/e2e/anchor/src/generated/instructions/initialize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export type InitializeInstruction<
5959
TAccountPayer extends string | AccountMeta<string> = string,
6060
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
6161
> = Instruction<TProgram> &
62-
InstructionWithData<Uint8Array> &
62+
InstructionWithData<ReadonlyUint8Array> &
6363
InstructionWithAccounts<
6464
[
6565
TAccountExtraMetasAccount extends string
@@ -347,7 +347,7 @@ export function parseInitializeInstruction<
347347
>(
348348
instruction: Instruction<TProgram> &
349349
InstructionWithAccounts<TAccountMetas> &
350-
InstructionWithData<Uint8Array>
350+
InstructionWithData<ReadonlyUint8Array>
351351
): ParsedInitializeInstruction<TProgram, TAccountMetas> {
352352
if (instruction.accounts.length < 6) {
353353
// TODO: Coded error.

packages/renderers-js/e2e/anchor/src/generated/instructions/updateGuard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export type UpdateGuardInstruction<
8383
| AccountMeta<string> = '11111111111111111111111111111111',
8484
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
8585
> = Instruction<TProgram> &
86-
InstructionWithData<Uint8Array> &
86+
InstructionWithData<ReadonlyUint8Array> &
8787
InstructionWithAccounts<
8888
[
8989
TAccountGuard extends string
@@ -421,7 +421,7 @@ export function parseUpdateGuardInstruction<
421421
>(
422422
instruction: Instruction<TProgram> &
423423
InstructionWithAccounts<TAccountMetas> &
424-
InstructionWithData<Uint8Array>
424+
InstructionWithData<ReadonlyUint8Array>
425425
): ParsedUpdateGuardInstruction<TProgram, TAccountMetas> {
426426
if (instruction.accounts.length < 6) {
427427
// TODO: Coded error.

packages/renderers-js/e2e/dummy/src/generated/instructions/instruction3.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
type Instruction,
2222
type InstructionWithAccounts,
2323
type InstructionWithData,
24+
type ReadonlyUint8Array,
2425
} from '@solana/kit';
2526
import { DUMMY_PROGRAM_ADDRESS } from '../programs';
2627

@@ -34,7 +35,7 @@ export type Instruction3Instruction<
3435
TProgram extends string = typeof DUMMY_PROGRAM_ADDRESS,
3536
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
3637
> = Instruction<TProgram> &
37-
InstructionWithData<Uint8Array> &
38+
InstructionWithData<ReadonlyUint8Array> &
3839
InstructionWithAccounts<TRemainingAccounts>;
3940

4041
export type Instruction3InstructionData = { discriminator: number };
@@ -88,7 +89,7 @@ export type ParsedInstruction3Instruction<
8889
};
8990

9091
export function parseInstruction3Instruction<TProgram extends string>(
91-
instruction: Instruction<TProgram> & InstructionWithData<Uint8Array>
92+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
9293
): ParsedInstruction3Instruction<TProgram> {
9394
return {
9495
programAddress: instruction.programAddress,

packages/renderers-js/e2e/dummy/src/generated/instructions/instruction4.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import {
2020
type Instruction,
2121
type InstructionWithAccounts,
2222
type InstructionWithData,
23+
type ReadonlyUint8Array,
2324
} from '@solana/kit';
2425
import { DUMMY_PROGRAM_ADDRESS } from '../programs';
2526

2627
export type Instruction4Instruction<
2728
TProgram extends string = typeof DUMMY_PROGRAM_ADDRESS,
2829
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
2930
> = Instruction<TProgram> &
30-
InstructionWithData<Uint8Array> &
31+
InstructionWithData<ReadonlyUint8Array> &
3132
InstructionWithAccounts<TRemainingAccounts>;
3233

3334
export type Instruction4InstructionData = { myArgument: bigint };
@@ -86,7 +87,7 @@ export type ParsedInstruction4Instruction<
8687
};
8788

8889
export function parseInstruction4Instruction<TProgram extends string>(
89-
instruction: Instruction<TProgram> & InstructionWithData<Uint8Array>
90+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
9091
): ParsedInstruction4Instruction<TProgram> {
9192
return {
9293
programAddress: instruction.programAddress,

packages/renderers-js/e2e/dummy/src/generated/instructions/instruction5.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ import {
2121
type Instruction,
2222
type InstructionWithAccounts,
2323
type InstructionWithData,
24+
type ReadonlyUint8Array,
2425
} from '@solana/kit';
2526
import { DUMMY_PROGRAM_ADDRESS } from '../programs';
2627

2728
export type Instruction5Instruction<
2829
TProgram extends string = typeof DUMMY_PROGRAM_ADDRESS,
2930
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
3031
> = Instruction<TProgram> &
31-
InstructionWithData<Uint8Array> &
32+
InstructionWithData<ReadonlyUint8Array> &
3233
InstructionWithAccounts<TRemainingAccounts>;
3334

3435
export type Instruction5InstructionData = { myArgument: bigint };
@@ -90,7 +91,7 @@ export type ParsedInstruction5Instruction<
9091
};
9192

9293
export function parseInstruction5Instruction<TProgram extends string>(
93-
instruction: Instruction<TProgram> & InstructionWithData<Uint8Array>
94+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
9495
): ParsedInstruction5Instruction<TProgram> {
9596
return {
9697
programAddress: instruction.programAddress,

packages/renderers-js/e2e/memo/src/generated/instructions/addMemo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
type Instruction,
2222
type InstructionWithAccounts,
2323
type InstructionWithData,
24+
type ReadonlyUint8Array,
2425
type TransactionSigner,
2526
} from '@solana/kit';
2627
import { MEMO_PROGRAM_ADDRESS } from '../programs';
@@ -29,7 +30,7 @@ export type AddMemoInstruction<
2930
TProgram extends string = typeof MEMO_PROGRAM_ADDRESS,
3031
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
3132
> = Instruction<TProgram> &
32-
InstructionWithData<Uint8Array> &
33+
InstructionWithData<ReadonlyUint8Array> &
3334
InstructionWithAccounts<TRemainingAccounts>;
3435

3536
export type AddMemoInstructionData = { memo: string };
@@ -99,7 +100,7 @@ export type ParsedAddMemoInstruction<
99100
};
100101

101102
export function parseAddMemoInstruction<TProgram extends string>(
102-
instruction: Instruction<TProgram> & InstructionWithData<Uint8Array>
103+
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>
103104
): ParsedAddMemoInstruction<TProgram> {
104105
return {
105106
programAddress: instruction.programAddress,

0 commit comments

Comments
 (0)