trezoa-sas-lib 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/src/generated/accounts/attestation.d.ts +40 -0
  2. package/dist/src/generated/accounts/attestation.js +69 -0
  3. package/dist/src/generated/accounts/credential.d.ts +27 -0
  4. package/dist/src/generated/accounts/credential.js +61 -0
  5. package/dist/src/generated/accounts/index.d.ts +10 -0
  6. package/dist/src/generated/accounts/index.js +26 -0
  7. package/dist/src/generated/accounts/schema.d.ts +31 -0
  8. package/dist/src/generated/accounts/schema.js +69 -0
  9. package/dist/src/generated/index.d.ts +11 -0
  10. package/dist/src/generated/index.js +27 -0
  11. package/dist/src/generated/instructions/changeAuthorizedSigners.d.ts +51 -0
  12. package/dist/src/generated/instructions/changeAuthorizedSigners.js +93 -0
  13. package/dist/src/generated/instructions/changeSchemaDescription.d.ts +56 -0
  14. package/dist/src/generated/instructions/changeSchemaDescription.js +96 -0
  15. package/dist/src/generated/instructions/changeSchemaStatus.d.ts +50 -0
  16. package/dist/src/generated/instructions/changeSchemaStatus.js +82 -0
  17. package/dist/src/generated/instructions/changeSchemaVersion.d.ts +60 -0
  18. package/dist/src/generated/instructions/changeSchemaVersion.js +107 -0
  19. package/dist/src/generated/instructions/closeAttestation.d.ts +56 -0
  20. package/dist/src/generated/instructions/closeAttestation.js +102 -0
  21. package/dist/src/generated/instructions/closeTokenizedAttestation.d.ts +74 -0
  22. package/dist/src/generated/instructions/closeTokenizedAttestation.js +124 -0
  23. package/dist/src/generated/instructions/createAttestation.d.ts +67 -0
  24. package/dist/src/generated/instructions/createAttestation.js +100 -0
  25. package/dist/src/generated/instructions/createCredential.d.ts +52 -0
  26. package/dist/src/generated/instructions/createCredential.js +92 -0
  27. package/dist/src/generated/instructions/createSchema.d.ts +63 -0
  28. package/dist/src/generated/instructions/createSchema.js +105 -0
  29. package/dist/src/generated/instructions/createTokenizedAttestation.d.ts +110 -0
  30. package/dist/src/generated/instructions/createTokenizedAttestation.js +146 -0
  31. package/dist/src/generated/instructions/emitEvent.d.ts +36 -0
  32. package/dist/src/generated/instructions/emitEvent.js +69 -0
  33. package/dist/src/generated/instructions/index.d.ts +19 -0
  34. package/dist/src/generated/instructions/index.js +35 -0
  35. package/dist/src/generated/instructions/tokenizeSchema.d.ts +67 -0
  36. package/dist/src/generated/instructions/tokenizeSchema.js +106 -0
  37. package/dist/src/generated/programs/index.d.ts +8 -0
  38. package/dist/src/generated/programs/index.js +24 -0
  39. package/dist/src/generated/programs/trezoaAttestationService.d.ts +57 -0
  40. package/dist/src/generated/programs/trezoaAttestationService.js +74 -0
  41. package/dist/src/generated/shared/index.d.ts +49 -0
  42. package/dist/src/generated/shared/index.js +94 -0
  43. package/dist/src/generated/types/closeAttestationEvent.d.ts +17 -0
  44. package/dist/src/generated/types/closeAttestationEvent.js +36 -0
  45. package/dist/src/generated/types/index.d.ts +8 -0
  46. package/dist/src/generated/types/index.js +24 -0
  47. package/dist/src/index.d.ts +3 -0
  48. package/dist/src/index.js +19 -0
  49. package/dist/src/pdas.d.ts +69 -0
  50. package/dist/src/pdas.js +96 -0
  51. package/dist/src/utils.d.ts +21 -0
  52. package/dist/src/utils.js +98 -0
  53. package/dist/test/pdas.d.ts +1 -0
  54. package/dist/test/pdas.js +61 -0
  55. package/dist/test/utils.d.ts +1 -0
  56. package/dist/test/utils.js +29 -0
  57. package/package.json +29 -0
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the Codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun Codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CLOSE_TOKENIZED_ATTESTATION_DISCRIMINATOR = void 0;
11
+ exports.getCloseTokenizedAttestationDiscriminatorBytes = getCloseTokenizedAttestationDiscriminatorBytes;
12
+ exports.getCloseTokenizedAttestationInstructionDataEncoder = getCloseTokenizedAttestationInstructionDataEncoder;
13
+ exports.getCloseTokenizedAttestationInstructionDataDecoder = getCloseTokenizedAttestationInstructionDataDecoder;
14
+ exports.getCloseTokenizedAttestationInstructionDataCodec = getCloseTokenizedAttestationInstructionDataCodec;
15
+ exports.getCloseTokenizedAttestationInstruction = getCloseTokenizedAttestationInstruction;
16
+ exports.parseCloseTokenizedAttestationInstruction = parseCloseTokenizedAttestationInstruction;
17
+ const kit_1 = require("@trezoa/kit");
18
+ const programs_1 = require("../programs");
19
+ const shared_1 = require("../shared");
20
+ exports.CLOSE_TOKENIZED_ATTESTATION_DISCRIMINATOR = 11;
21
+ function getCloseTokenizedAttestationDiscriminatorBytes() {
22
+ return (0, kit_1.getU8Encoder)().encode(exports.CLOSE_TOKENIZED_ATTESTATION_DISCRIMINATOR);
23
+ }
24
+ function getCloseTokenizedAttestationInstructionDataEncoder() {
25
+ return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.getU8Encoder)()]]), (value) => ({
26
+ ...value,
27
+ discriminator: exports.CLOSE_TOKENIZED_ATTESTATION_DISCRIMINATOR,
28
+ }));
29
+ }
30
+ function getCloseTokenizedAttestationInstructionDataDecoder() {
31
+ return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.getU8Decoder)()]]);
32
+ }
33
+ function getCloseTokenizedAttestationInstructionDataCodec() {
34
+ return (0, kit_1.combineCodec)(getCloseTokenizedAttestationInstructionDataEncoder(), getCloseTokenizedAttestationInstructionDataDecoder());
35
+ }
36
+ function getCloseTokenizedAttestationInstruction(input, config) {
37
+ // Program address.
38
+ const programAddress = config?.programAddress ?? programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS;
39
+ // Original accounts.
40
+ const originalAccounts = {
41
+ payer: { value: input.payer ?? null, isWritable: true },
42
+ authority: { value: input.authority ?? null, isWritable: false },
43
+ credential: { value: input.credential ?? null, isWritable: false },
44
+ attestation: { value: input.attestation ?? null, isWritable: true },
45
+ eventAuthority: { value: input.eventAuthority ?? null, isWritable: false },
46
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
47
+ attestationProgram: {
48
+ value: input.attestationProgram ?? null,
49
+ isWritable: false,
50
+ },
51
+ attestationMint: { value: input.attestationMint ?? null, isWritable: true },
52
+ sasPda: { value: input.sasPda ?? null, isWritable: false },
53
+ attestationTokenAccount: {
54
+ value: input.attestationTokenAccount ?? null,
55
+ isWritable: true,
56
+ },
57
+ tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
58
+ };
59
+ const accounts = originalAccounts;
60
+ // Resolve default values.
61
+ if (!accounts.eventAuthority.value) {
62
+ accounts.eventAuthority.value =
63
+ '9qmfijJ9MX4XVGdgWB64UuGUb19guVXrpn1HxweCybVb';
64
+ }
65
+ if (!accounts.systemProgram.value) {
66
+ accounts.systemProgram.value =
67
+ '11111111111111111111111111111111';
68
+ }
69
+ if (!accounts.attestationProgram.value) {
70
+ accounts.attestationProgram.value =
71
+ '8AVGA5ygh9XXLYLdnZRc2M5oEPyRLx7zdfjR57XHuFBL';
72
+ }
73
+ if (!accounts.tokenProgram.value) {
74
+ accounts.tokenProgram.value =
75
+ 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
76
+ }
77
+ const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
78
+ return Object.freeze({
79
+ accounts: [
80
+ getAccountMeta(accounts.payer),
81
+ getAccountMeta(accounts.authority),
82
+ getAccountMeta(accounts.credential),
83
+ getAccountMeta(accounts.attestation),
84
+ getAccountMeta(accounts.eventAuthority),
85
+ getAccountMeta(accounts.systemProgram),
86
+ getAccountMeta(accounts.attestationProgram),
87
+ getAccountMeta(accounts.attestationMint),
88
+ getAccountMeta(accounts.sasPda),
89
+ getAccountMeta(accounts.attestationTokenAccount),
90
+ getAccountMeta(accounts.tokenProgram),
91
+ ],
92
+ data: getCloseTokenizedAttestationInstructionDataEncoder().encode({}),
93
+ programAddress,
94
+ });
95
+ }
96
+ function parseCloseTokenizedAttestationInstruction(instruction) {
97
+ if (instruction.accounts.length < 11) {
98
+ // TODO: Coded error.
99
+ throw new Error('Not enough accounts');
100
+ }
101
+ let accountIndex = 0;
102
+ const getNextAccount = () => {
103
+ const accountMeta = instruction.accounts[accountIndex];
104
+ accountIndex += 1;
105
+ return accountMeta;
106
+ };
107
+ return {
108
+ programAddress: instruction.programAddress,
109
+ accounts: {
110
+ payer: getNextAccount(),
111
+ authority: getNextAccount(),
112
+ credential: getNextAccount(),
113
+ attestation: getNextAccount(),
114
+ eventAuthority: getNextAccount(),
115
+ systemProgram: getNextAccount(),
116
+ attestationProgram: getNextAccount(),
117
+ attestationMint: getNextAccount(),
118
+ sasPda: getNextAccount(),
119
+ attestationTokenAccount: getNextAccount(),
120
+ tokenProgram: getNextAccount(),
121
+ },
122
+ data: getCloseTokenizedAttestationInstructionDataDecoder().decode(instruction.data),
123
+ };
124
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@trezoa/kit';
9
+ import { TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS } from '../programs';
10
+ export declare const CREATE_ATTESTATION_DISCRIMINATOR = 6;
11
+ export declare function getCreateAttestationDiscriminatorBytes(): ReadonlyUint8Array;
12
+ export type CreateAttestationInstruction<TProgram extends string = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS, TAccountPayer extends string | AccountMeta<string> = string, TAccountAuthority extends string | AccountMeta<string> = string, TAccountCredential extends string | AccountMeta<string> = string, TAccountSchema extends string | AccountMeta<string> = string, TAccountAttestation extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = '11111111111111111111111111111111', TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
13
+ TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer,
14
+ TAccountAuthority extends string ? ReadonlySignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority,
15
+ TAccountCredential extends string ? ReadonlyAccount<TAccountCredential> : TAccountCredential,
16
+ TAccountSchema extends string ? ReadonlyAccount<TAccountSchema> : TAccountSchema,
17
+ TAccountAttestation extends string ? WritableAccount<TAccountAttestation> : TAccountAttestation,
18
+ TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
19
+ ...TRemainingAccounts
20
+ ]>;
21
+ export type CreateAttestationInstructionData = {
22
+ discriminator: number;
23
+ nonce: Address;
24
+ data: ReadonlyUint8Array;
25
+ expiry: bigint;
26
+ };
27
+ export type CreateAttestationInstructionDataArgs = {
28
+ nonce: Address;
29
+ data: ReadonlyUint8Array;
30
+ expiry: number | bigint;
31
+ };
32
+ export declare function getCreateAttestationInstructionDataEncoder(): Encoder<CreateAttestationInstructionDataArgs>;
33
+ export declare function getCreateAttestationInstructionDataDecoder(): Decoder<CreateAttestationInstructionData>;
34
+ export declare function getCreateAttestationInstructionDataCodec(): Codec<CreateAttestationInstructionDataArgs, CreateAttestationInstructionData>;
35
+ export type CreateAttestationInput<TAccountPayer extends string = string, TAccountAuthority extends string = string, TAccountCredential extends string = string, TAccountSchema extends string = string, TAccountAttestation extends string = string, TAccountSystemProgram extends string = string> = {
36
+ payer: TransactionSigner<TAccountPayer>;
37
+ /** Authorized signer of the Schema's Credential */
38
+ authority: TransactionSigner<TAccountAuthority>;
39
+ /** Credential the Schema is associated with */
40
+ credential: Address<TAccountCredential>;
41
+ /** Schema the Attestation is associated with */
42
+ schema: Address<TAccountSchema>;
43
+ attestation: Address<TAccountAttestation>;
44
+ systemProgram?: Address<TAccountSystemProgram>;
45
+ nonce: CreateAttestationInstructionDataArgs['nonce'];
46
+ data: CreateAttestationInstructionDataArgs['data'];
47
+ expiry: CreateAttestationInstructionDataArgs['expiry'];
48
+ };
49
+ export declare function getCreateAttestationInstruction<TAccountPayer extends string, TAccountAuthority extends string, TAccountCredential extends string, TAccountSchema extends string, TAccountAttestation extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS>(input: CreateAttestationInput<TAccountPayer, TAccountAuthority, TAccountCredential, TAccountSchema, TAccountAttestation, TAccountSystemProgram>, config?: {
50
+ programAddress?: TProgramAddress;
51
+ }): CreateAttestationInstruction<TProgramAddress, TAccountPayer, TAccountAuthority, TAccountCredential, TAccountSchema, TAccountAttestation, TAccountSystemProgram>;
52
+ export type ParsedCreateAttestationInstruction<TProgram extends string = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
53
+ programAddress: Address<TProgram>;
54
+ accounts: {
55
+ payer: TAccountMetas[0];
56
+ /** Authorized signer of the Schema's Credential */
57
+ authority: TAccountMetas[1];
58
+ /** Credential the Schema is associated with */
59
+ credential: TAccountMetas[2];
60
+ /** Schema the Attestation is associated with */
61
+ schema: TAccountMetas[3];
62
+ attestation: TAccountMetas[4];
63
+ systemProgram: TAccountMetas[5];
64
+ };
65
+ data: CreateAttestationInstructionData;
66
+ };
67
+ export declare function parseCreateAttestationInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCreateAttestationInstruction<TProgram, TAccountMetas>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the Codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun Codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CREATE_ATTESTATION_DISCRIMINATOR = void 0;
11
+ exports.getCreateAttestationDiscriminatorBytes = getCreateAttestationDiscriminatorBytes;
12
+ exports.getCreateAttestationInstructionDataEncoder = getCreateAttestationInstructionDataEncoder;
13
+ exports.getCreateAttestationInstructionDataDecoder = getCreateAttestationInstructionDataDecoder;
14
+ exports.getCreateAttestationInstructionDataCodec = getCreateAttestationInstructionDataCodec;
15
+ exports.getCreateAttestationInstruction = getCreateAttestationInstruction;
16
+ exports.parseCreateAttestationInstruction = parseCreateAttestationInstruction;
17
+ const kit_1 = require("@trezoa/kit");
18
+ const programs_1 = require("../programs");
19
+ const shared_1 = require("../shared");
20
+ exports.CREATE_ATTESTATION_DISCRIMINATOR = 6;
21
+ function getCreateAttestationDiscriminatorBytes() {
22
+ return (0, kit_1.getU8Encoder)().encode(exports.CREATE_ATTESTATION_DISCRIMINATOR);
23
+ }
24
+ function getCreateAttestationInstructionDataEncoder() {
25
+ return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
26
+ ['discriminator', (0, kit_1.getU8Encoder)()],
27
+ ['nonce', (0, kit_1.getAddressEncoder)()],
28
+ ['data', (0, kit_1.addEncoderSizePrefix)((0, kit_1.getBytesEncoder)(), (0, kit_1.getU32Encoder)())],
29
+ ['expiry', (0, kit_1.getI64Encoder)()],
30
+ ]), (value) => ({ ...value, discriminator: exports.CREATE_ATTESTATION_DISCRIMINATOR }));
31
+ }
32
+ function getCreateAttestationInstructionDataDecoder() {
33
+ return (0, kit_1.getStructDecoder)([
34
+ ['discriminator', (0, kit_1.getU8Decoder)()],
35
+ ['nonce', (0, kit_1.getAddressDecoder)()],
36
+ ['data', (0, kit_1.addDecoderSizePrefix)((0, kit_1.getBytesDecoder)(), (0, kit_1.getU32Decoder)())],
37
+ ['expiry', (0, kit_1.getI64Decoder)()],
38
+ ]);
39
+ }
40
+ function getCreateAttestationInstructionDataCodec() {
41
+ return (0, kit_1.combineCodec)(getCreateAttestationInstructionDataEncoder(), getCreateAttestationInstructionDataDecoder());
42
+ }
43
+ function getCreateAttestationInstruction(input, config) {
44
+ // Program address.
45
+ const programAddress = config?.programAddress ?? programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS;
46
+ // Original accounts.
47
+ const originalAccounts = {
48
+ payer: { value: input.payer ?? null, isWritable: true },
49
+ authority: { value: input.authority ?? null, isWritable: false },
50
+ credential: { value: input.credential ?? null, isWritable: false },
51
+ schema: { value: input.schema ?? null, isWritable: false },
52
+ attestation: { value: input.attestation ?? null, isWritable: true },
53
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
54
+ };
55
+ const accounts = originalAccounts;
56
+ // Original args.
57
+ const args = { ...input };
58
+ // Resolve default values.
59
+ if (!accounts.systemProgram.value) {
60
+ accounts.systemProgram.value =
61
+ '11111111111111111111111111111111';
62
+ }
63
+ const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
64
+ return Object.freeze({
65
+ accounts: [
66
+ getAccountMeta(accounts.payer),
67
+ getAccountMeta(accounts.authority),
68
+ getAccountMeta(accounts.credential),
69
+ getAccountMeta(accounts.schema),
70
+ getAccountMeta(accounts.attestation),
71
+ getAccountMeta(accounts.systemProgram),
72
+ ],
73
+ data: getCreateAttestationInstructionDataEncoder().encode(args),
74
+ programAddress,
75
+ });
76
+ }
77
+ function parseCreateAttestationInstruction(instruction) {
78
+ if (instruction.accounts.length < 6) {
79
+ // TODO: Coded error.
80
+ throw new Error('Not enough accounts');
81
+ }
82
+ let accountIndex = 0;
83
+ const getNextAccount = () => {
84
+ const accountMeta = instruction.accounts[accountIndex];
85
+ accountIndex += 1;
86
+ return accountMeta;
87
+ };
88
+ return {
89
+ programAddress: instruction.programAddress,
90
+ accounts: {
91
+ payer: getNextAccount(),
92
+ authority: getNextAccount(),
93
+ credential: getNextAccount(),
94
+ schema: getNextAccount(),
95
+ attestation: getNextAccount(),
96
+ systemProgram: getNextAccount(),
97
+ },
98
+ data: getCreateAttestationInstructionDataDecoder().decode(instruction.data),
99
+ };
100
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@trezoa/kit';
9
+ import { TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS } from '../programs';
10
+ export declare const CREATE_CREDENTIAL_DISCRIMINATOR = 0;
11
+ export declare function getCreateCredentialDiscriminatorBytes(): ReadonlyUint8Array;
12
+ export type CreateCredentialInstruction<TProgram extends string = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS, TAccountPayer extends string | AccountMeta<string> = string, TAccountCredential extends string | AccountMeta<string> = string, TAccountAuthority extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = '11111111111111111111111111111111', TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
13
+ TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer,
14
+ TAccountCredential extends string ? WritableAccount<TAccountCredential> : TAccountCredential,
15
+ TAccountAuthority extends string ? ReadonlySignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority,
16
+ TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
17
+ ...TRemainingAccounts
18
+ ]>;
19
+ export type CreateCredentialInstructionData = {
20
+ discriminator: number;
21
+ name: string;
22
+ signers: Array<Address>;
23
+ };
24
+ export type CreateCredentialInstructionDataArgs = {
25
+ name: string;
26
+ signers: Array<Address>;
27
+ };
28
+ export declare function getCreateCredentialInstructionDataEncoder(): Encoder<CreateCredentialInstructionDataArgs>;
29
+ export declare function getCreateCredentialInstructionDataDecoder(): Decoder<CreateCredentialInstructionData>;
30
+ export declare function getCreateCredentialInstructionDataCodec(): Codec<CreateCredentialInstructionDataArgs, CreateCredentialInstructionData>;
31
+ export type CreateCredentialInput<TAccountPayer extends string = string, TAccountCredential extends string = string, TAccountAuthority extends string = string, TAccountSystemProgram extends string = string> = {
32
+ payer: TransactionSigner<TAccountPayer>;
33
+ credential: Address<TAccountCredential>;
34
+ authority: TransactionSigner<TAccountAuthority>;
35
+ systemProgram?: Address<TAccountSystemProgram>;
36
+ name: CreateCredentialInstructionDataArgs['name'];
37
+ signers: CreateCredentialInstructionDataArgs['signers'];
38
+ };
39
+ export declare function getCreateCredentialInstruction<TAccountPayer extends string, TAccountCredential extends string, TAccountAuthority extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS>(input: CreateCredentialInput<TAccountPayer, TAccountCredential, TAccountAuthority, TAccountSystemProgram>, config?: {
40
+ programAddress?: TProgramAddress;
41
+ }): CreateCredentialInstruction<TProgramAddress, TAccountPayer, TAccountCredential, TAccountAuthority, TAccountSystemProgram>;
42
+ export type ParsedCreateCredentialInstruction<TProgram extends string = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
43
+ programAddress: Address<TProgram>;
44
+ accounts: {
45
+ payer: TAccountMetas[0];
46
+ credential: TAccountMetas[1];
47
+ authority: TAccountMetas[2];
48
+ systemProgram: TAccountMetas[3];
49
+ };
50
+ data: CreateCredentialInstructionData;
51
+ };
52
+ export declare function parseCreateCredentialInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCreateCredentialInstruction<TProgram, TAccountMetas>;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the Codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun Codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CREATE_CREDENTIAL_DISCRIMINATOR = void 0;
11
+ exports.getCreateCredentialDiscriminatorBytes = getCreateCredentialDiscriminatorBytes;
12
+ exports.getCreateCredentialInstructionDataEncoder = getCreateCredentialInstructionDataEncoder;
13
+ exports.getCreateCredentialInstructionDataDecoder = getCreateCredentialInstructionDataDecoder;
14
+ exports.getCreateCredentialInstructionDataCodec = getCreateCredentialInstructionDataCodec;
15
+ exports.getCreateCredentialInstruction = getCreateCredentialInstruction;
16
+ exports.parseCreateCredentialInstruction = parseCreateCredentialInstruction;
17
+ const kit_1 = require("@trezoa/kit");
18
+ const programs_1 = require("../programs");
19
+ const shared_1 = require("../shared");
20
+ exports.CREATE_CREDENTIAL_DISCRIMINATOR = 0;
21
+ function getCreateCredentialDiscriminatorBytes() {
22
+ return (0, kit_1.getU8Encoder)().encode(exports.CREATE_CREDENTIAL_DISCRIMINATOR);
23
+ }
24
+ function getCreateCredentialInstructionDataEncoder() {
25
+ return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
26
+ ['discriminator', (0, kit_1.getU8Encoder)()],
27
+ ['name', (0, kit_1.addEncoderSizePrefix)((0, kit_1.getUtf8Encoder)(), (0, kit_1.getU32Encoder)())],
28
+ ['signers', (0, kit_1.getArrayEncoder)((0, kit_1.getAddressEncoder)())],
29
+ ]), (value) => ({ ...value, discriminator: exports.CREATE_CREDENTIAL_DISCRIMINATOR }));
30
+ }
31
+ function getCreateCredentialInstructionDataDecoder() {
32
+ return (0, kit_1.getStructDecoder)([
33
+ ['discriminator', (0, kit_1.getU8Decoder)()],
34
+ ['name', (0, kit_1.addDecoderSizePrefix)((0, kit_1.getUtf8Decoder)(), (0, kit_1.getU32Decoder)())],
35
+ ['signers', (0, kit_1.getArrayDecoder)((0, kit_1.getAddressDecoder)())],
36
+ ]);
37
+ }
38
+ function getCreateCredentialInstructionDataCodec() {
39
+ return (0, kit_1.combineCodec)(getCreateCredentialInstructionDataEncoder(), getCreateCredentialInstructionDataDecoder());
40
+ }
41
+ function getCreateCredentialInstruction(input, config) {
42
+ // Program address.
43
+ const programAddress = config?.programAddress ?? programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS;
44
+ // Original accounts.
45
+ const originalAccounts = {
46
+ payer: { value: input.payer ?? null, isWritable: true },
47
+ credential: { value: input.credential ?? null, isWritable: true },
48
+ authority: { value: input.authority ?? null, isWritable: false },
49
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
50
+ };
51
+ const accounts = originalAccounts;
52
+ // Original args.
53
+ const args = { ...input };
54
+ // Resolve default values.
55
+ if (!accounts.systemProgram.value) {
56
+ accounts.systemProgram.value =
57
+ '11111111111111111111111111111111';
58
+ }
59
+ const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
60
+ return Object.freeze({
61
+ accounts: [
62
+ getAccountMeta(accounts.payer),
63
+ getAccountMeta(accounts.credential),
64
+ getAccountMeta(accounts.authority),
65
+ getAccountMeta(accounts.systemProgram),
66
+ ],
67
+ data: getCreateCredentialInstructionDataEncoder().encode(args),
68
+ programAddress,
69
+ });
70
+ }
71
+ function parseCreateCredentialInstruction(instruction) {
72
+ if (instruction.accounts.length < 4) {
73
+ // TODO: Coded error.
74
+ throw new Error('Not enough accounts');
75
+ }
76
+ let accountIndex = 0;
77
+ const getNextAccount = () => {
78
+ const accountMeta = instruction.accounts[accountIndex];
79
+ accountIndex += 1;
80
+ return accountMeta;
81
+ };
82
+ return {
83
+ programAddress: instruction.programAddress,
84
+ accounts: {
85
+ payer: getNextAccount(),
86
+ credential: getNextAccount(),
87
+ authority: getNextAccount(),
88
+ systemProgram: getNextAccount(),
89
+ },
90
+ data: getCreateCredentialInstructionDataDecoder().decode(instruction.data),
91
+ };
92
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type AccountMeta, type AccountSignerMeta, type Address, type Codec, type Decoder, type Encoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@trezoa/kit';
9
+ import { TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS } from '../programs';
10
+ export declare const CREATE_SCHEMA_DISCRIMINATOR = 1;
11
+ export declare function getCreateSchemaDiscriminatorBytes(): ReadonlyUint8Array;
12
+ export type CreateSchemaInstruction<TProgram extends string = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS, TAccountPayer extends string | AccountMeta<string> = string, TAccountAuthority extends string | AccountMeta<string> = string, TAccountCredential extends string | AccountMeta<string> = string, TAccountSchema extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = '11111111111111111111111111111111', TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
13
+ TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer,
14
+ TAccountAuthority extends string ? ReadonlySignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority,
15
+ TAccountCredential extends string ? ReadonlyAccount<TAccountCredential> : TAccountCredential,
16
+ TAccountSchema extends string ? WritableAccount<TAccountSchema> : TAccountSchema,
17
+ TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
18
+ ...TRemainingAccounts
19
+ ]>;
20
+ export type CreateSchemaInstructionData = {
21
+ discriminator: number;
22
+ name: string;
23
+ description: string;
24
+ layout: ReadonlyUint8Array;
25
+ fieldNames: Array<string>;
26
+ };
27
+ export type CreateSchemaInstructionDataArgs = {
28
+ name: string;
29
+ description: string;
30
+ layout: ReadonlyUint8Array;
31
+ fieldNames: Array<string>;
32
+ };
33
+ export declare function getCreateSchemaInstructionDataEncoder(): Encoder<CreateSchemaInstructionDataArgs>;
34
+ export declare function getCreateSchemaInstructionDataDecoder(): Decoder<CreateSchemaInstructionData>;
35
+ export declare function getCreateSchemaInstructionDataCodec(): Codec<CreateSchemaInstructionDataArgs, CreateSchemaInstructionData>;
36
+ export type CreateSchemaInput<TAccountPayer extends string = string, TAccountAuthority extends string = string, TAccountCredential extends string = string, TAccountSchema extends string = string, TAccountSystemProgram extends string = string> = {
37
+ payer: TransactionSigner<TAccountPayer>;
38
+ authority: TransactionSigner<TAccountAuthority>;
39
+ /** Credential the Schema is associated with */
40
+ credential: Address<TAccountCredential>;
41
+ schema: Address<TAccountSchema>;
42
+ systemProgram?: Address<TAccountSystemProgram>;
43
+ name: CreateSchemaInstructionDataArgs['name'];
44
+ description: CreateSchemaInstructionDataArgs['description'];
45
+ layout: CreateSchemaInstructionDataArgs['layout'];
46
+ fieldNames: CreateSchemaInstructionDataArgs['fieldNames'];
47
+ };
48
+ export declare function getCreateSchemaInstruction<TAccountPayer extends string, TAccountAuthority extends string, TAccountCredential extends string, TAccountSchema extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS>(input: CreateSchemaInput<TAccountPayer, TAccountAuthority, TAccountCredential, TAccountSchema, TAccountSystemProgram>, config?: {
49
+ programAddress?: TProgramAddress;
50
+ }): CreateSchemaInstruction<TProgramAddress, TAccountPayer, TAccountAuthority, TAccountCredential, TAccountSchema, TAccountSystemProgram>;
51
+ export type ParsedCreateSchemaInstruction<TProgram extends string = typeof TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
52
+ programAddress: Address<TProgram>;
53
+ accounts: {
54
+ payer: TAccountMetas[0];
55
+ authority: TAccountMetas[1];
56
+ /** Credential the Schema is associated with */
57
+ credential: TAccountMetas[2];
58
+ schema: TAccountMetas[3];
59
+ systemProgram: TAccountMetas[4];
60
+ };
61
+ data: CreateSchemaInstructionData;
62
+ };
63
+ export declare function parseCreateSchemaInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCreateSchemaInstruction<TProgram, TAccountMetas>;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the Codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun Codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CREATE_SCHEMA_DISCRIMINATOR = void 0;
11
+ exports.getCreateSchemaDiscriminatorBytes = getCreateSchemaDiscriminatorBytes;
12
+ exports.getCreateSchemaInstructionDataEncoder = getCreateSchemaInstructionDataEncoder;
13
+ exports.getCreateSchemaInstructionDataDecoder = getCreateSchemaInstructionDataDecoder;
14
+ exports.getCreateSchemaInstructionDataCodec = getCreateSchemaInstructionDataCodec;
15
+ exports.getCreateSchemaInstruction = getCreateSchemaInstruction;
16
+ exports.parseCreateSchemaInstruction = parseCreateSchemaInstruction;
17
+ const kit_1 = require("@trezoa/kit");
18
+ const programs_1 = require("../programs");
19
+ const shared_1 = require("../shared");
20
+ exports.CREATE_SCHEMA_DISCRIMINATOR = 1;
21
+ function getCreateSchemaDiscriminatorBytes() {
22
+ return (0, kit_1.getU8Encoder)().encode(exports.CREATE_SCHEMA_DISCRIMINATOR);
23
+ }
24
+ function getCreateSchemaInstructionDataEncoder() {
25
+ return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
26
+ ['discriminator', (0, kit_1.getU8Encoder)()],
27
+ ['name', (0, kit_1.addEncoderSizePrefix)((0, kit_1.getUtf8Encoder)(), (0, kit_1.getU32Encoder)())],
28
+ ['description', (0, kit_1.addEncoderSizePrefix)((0, kit_1.getUtf8Encoder)(), (0, kit_1.getU32Encoder)())],
29
+ ['layout', (0, kit_1.addEncoderSizePrefix)((0, kit_1.getBytesEncoder)(), (0, kit_1.getU32Encoder)())],
30
+ [
31
+ 'fieldNames',
32
+ (0, kit_1.getArrayEncoder)((0, kit_1.addEncoderSizePrefix)((0, kit_1.getUtf8Encoder)(), (0, kit_1.getU32Encoder)())),
33
+ ],
34
+ ]), (value) => ({ ...value, discriminator: exports.CREATE_SCHEMA_DISCRIMINATOR }));
35
+ }
36
+ function getCreateSchemaInstructionDataDecoder() {
37
+ return (0, kit_1.getStructDecoder)([
38
+ ['discriminator', (0, kit_1.getU8Decoder)()],
39
+ ['name', (0, kit_1.addDecoderSizePrefix)((0, kit_1.getUtf8Decoder)(), (0, kit_1.getU32Decoder)())],
40
+ ['description', (0, kit_1.addDecoderSizePrefix)((0, kit_1.getUtf8Decoder)(), (0, kit_1.getU32Decoder)())],
41
+ ['layout', (0, kit_1.addDecoderSizePrefix)((0, kit_1.getBytesDecoder)(), (0, kit_1.getU32Decoder)())],
42
+ [
43
+ 'fieldNames',
44
+ (0, kit_1.getArrayDecoder)((0, kit_1.addDecoderSizePrefix)((0, kit_1.getUtf8Decoder)(), (0, kit_1.getU32Decoder)())),
45
+ ],
46
+ ]);
47
+ }
48
+ function getCreateSchemaInstructionDataCodec() {
49
+ return (0, kit_1.combineCodec)(getCreateSchemaInstructionDataEncoder(), getCreateSchemaInstructionDataDecoder());
50
+ }
51
+ function getCreateSchemaInstruction(input, config) {
52
+ // Program address.
53
+ const programAddress = config?.programAddress ?? programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS;
54
+ // Original accounts.
55
+ const originalAccounts = {
56
+ payer: { value: input.payer ?? null, isWritable: true },
57
+ authority: { value: input.authority ?? null, isWritable: false },
58
+ credential: { value: input.credential ?? null, isWritable: false },
59
+ schema: { value: input.schema ?? null, isWritable: true },
60
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
61
+ };
62
+ const accounts = originalAccounts;
63
+ // Original args.
64
+ const args = { ...input };
65
+ // Resolve default values.
66
+ if (!accounts.systemProgram.value) {
67
+ accounts.systemProgram.value =
68
+ '11111111111111111111111111111111';
69
+ }
70
+ const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId');
71
+ return Object.freeze({
72
+ accounts: [
73
+ getAccountMeta(accounts.payer),
74
+ getAccountMeta(accounts.authority),
75
+ getAccountMeta(accounts.credential),
76
+ getAccountMeta(accounts.schema),
77
+ getAccountMeta(accounts.systemProgram),
78
+ ],
79
+ data: getCreateSchemaInstructionDataEncoder().encode(args),
80
+ programAddress,
81
+ });
82
+ }
83
+ function parseCreateSchemaInstruction(instruction) {
84
+ if (instruction.accounts.length < 5) {
85
+ // TODO: Coded error.
86
+ throw new Error('Not enough accounts');
87
+ }
88
+ let accountIndex = 0;
89
+ const getNextAccount = () => {
90
+ const accountMeta = instruction.accounts[accountIndex];
91
+ accountIndex += 1;
92
+ return accountMeta;
93
+ };
94
+ return {
95
+ programAddress: instruction.programAddress,
96
+ accounts: {
97
+ payer: getNextAccount(),
98
+ authority: getNextAccount(),
99
+ credential: getNextAccount(),
100
+ schema: getNextAccount(),
101
+ systemProgram: getNextAccount(),
102
+ },
103
+ data: getCreateSchemaInstructionDataDecoder().decode(instruction.data),
104
+ };
105
+ }