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,57 @@
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 Address, type ReadonlyUint8Array } from '@trezoa/kit';
9
+ import { type ParsedChangeAuthorizedSignersInstruction, type ParsedChangeSchemaDescriptionInstruction, type ParsedChangeSchemaStatusInstruction, type ParsedChangeSchemaVersionInstruction, type ParsedCloseAttestationInstruction, type ParsedCloseTokenizedAttestationInstruction, type ParsedCreateAttestationInstruction, type ParsedCreateCredentialInstruction, type ParsedCreateSchemaInstruction, type ParsedCreateTokenizedAttestationInstruction, type ParsedEmitEventInstruction, type ParsedTokenizeSchemaInstruction } from '../instructions';
10
+ export declare const TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS: Address<"8AVGA5ygh9XXLYLdnZRc2M5oEPyRLx7zdfjR57XHuFBL">;
11
+ export declare enum TrezoaAttestationServiceAccount {
12
+ Attestation = 0,
13
+ Credential = 1,
14
+ Schema = 2
15
+ }
16
+ export declare enum TrezoaAttestationServiceInstruction {
17
+ CreateCredential = 0,
18
+ CreateSchema = 1,
19
+ ChangeSchemaStatus = 2,
20
+ ChangeAuthorizedSigners = 3,
21
+ ChangeSchemaDescription = 4,
22
+ ChangeSchemaVersion = 5,
23
+ CreateAttestation = 6,
24
+ CloseAttestation = 7,
25
+ TokenizeSchema = 8,
26
+ CreateTokenizedAttestation = 9,
27
+ CloseTokenizedAttestation = 10,
28
+ EmitEvent = 11
29
+ }
30
+ export declare function identifyTrezoaAttestationServiceInstruction(instruction: {
31
+ data: ReadonlyUint8Array;
32
+ } | ReadonlyUint8Array): TrezoaAttestationServiceInstruction;
33
+ export type ParsedTrezoaAttestationServiceInstruction<TProgram extends string = '8AVGA5ygh9XXLYLdnZRc2M5oEPyRLx7zdfjR57XHuFBL'> = ({
34
+ instructionType: TrezoaAttestationServiceInstruction.CreateCredential;
35
+ } & ParsedCreateCredentialInstruction<TProgram>) | ({
36
+ instructionType: TrezoaAttestationServiceInstruction.CreateSchema;
37
+ } & ParsedCreateSchemaInstruction<TProgram>) | ({
38
+ instructionType: TrezoaAttestationServiceInstruction.ChangeSchemaStatus;
39
+ } & ParsedChangeSchemaStatusInstruction<TProgram>) | ({
40
+ instructionType: TrezoaAttestationServiceInstruction.ChangeAuthorizedSigners;
41
+ } & ParsedChangeAuthorizedSignersInstruction<TProgram>) | ({
42
+ instructionType: TrezoaAttestationServiceInstruction.ChangeSchemaDescription;
43
+ } & ParsedChangeSchemaDescriptionInstruction<TProgram>) | ({
44
+ instructionType: TrezoaAttestationServiceInstruction.ChangeSchemaVersion;
45
+ } & ParsedChangeSchemaVersionInstruction<TProgram>) | ({
46
+ instructionType: TrezoaAttestationServiceInstruction.CreateAttestation;
47
+ } & ParsedCreateAttestationInstruction<TProgram>) | ({
48
+ instructionType: TrezoaAttestationServiceInstruction.CloseAttestation;
49
+ } & ParsedCloseAttestationInstruction<TProgram>) | ({
50
+ instructionType: TrezoaAttestationServiceInstruction.TokenizeSchema;
51
+ } & ParsedTokenizeSchemaInstruction<TProgram>) | ({
52
+ instructionType: TrezoaAttestationServiceInstruction.CreateTokenizedAttestation;
53
+ } & ParsedCreateTokenizedAttestationInstruction<TProgram>) | ({
54
+ instructionType: TrezoaAttestationServiceInstruction.CloseTokenizedAttestation;
55
+ } & ParsedCloseTokenizedAttestationInstruction<TProgram>) | ({
56
+ instructionType: TrezoaAttestationServiceInstruction.EmitEvent;
57
+ } & ParsedEmitEventInstruction<TProgram>);
@@ -0,0 +1,74 @@
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.TrezoaAttestationServiceInstruction = exports.TrezoaAttestationServiceAccount = exports.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS = void 0;
11
+ exports.identifyTrezoaAttestationServiceInstruction = identifyTrezoaAttestationServiceInstruction;
12
+ const kit_1 = require("@trezoa/kit");
13
+ exports.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS = '8AVGA5ygh9XXLYLdnZRc2M5oEPyRLx7zdfjR57XHuFBL';
14
+ var TrezoaAttestationServiceAccount;
15
+ (function (TrezoaAttestationServiceAccount) {
16
+ TrezoaAttestationServiceAccount[TrezoaAttestationServiceAccount["Attestation"] = 0] = "Attestation";
17
+ TrezoaAttestationServiceAccount[TrezoaAttestationServiceAccount["Credential"] = 1] = "Credential";
18
+ TrezoaAttestationServiceAccount[TrezoaAttestationServiceAccount["Schema"] = 2] = "Schema";
19
+ })(TrezoaAttestationServiceAccount || (exports.TrezoaAttestationServiceAccount = TrezoaAttestationServiceAccount = {}));
20
+ var TrezoaAttestationServiceInstruction;
21
+ (function (TrezoaAttestationServiceInstruction) {
22
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["CreateCredential"] = 0] = "CreateCredential";
23
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["CreateSchema"] = 1] = "CreateSchema";
24
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["ChangeSchemaStatus"] = 2] = "ChangeSchemaStatus";
25
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["ChangeAuthorizedSigners"] = 3] = "ChangeAuthorizedSigners";
26
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["ChangeSchemaDescription"] = 4] = "ChangeSchemaDescription";
27
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["ChangeSchemaVersion"] = 5] = "ChangeSchemaVersion";
28
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["CreateAttestation"] = 6] = "CreateAttestation";
29
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["CloseAttestation"] = 7] = "CloseAttestation";
30
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["TokenizeSchema"] = 8] = "TokenizeSchema";
31
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["CreateTokenizedAttestation"] = 9] = "CreateTokenizedAttestation";
32
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["CloseTokenizedAttestation"] = 10] = "CloseTokenizedAttestation";
33
+ TrezoaAttestationServiceInstruction[TrezoaAttestationServiceInstruction["EmitEvent"] = 11] = "EmitEvent";
34
+ })(TrezoaAttestationServiceInstruction || (exports.TrezoaAttestationServiceInstruction = TrezoaAttestationServiceInstruction = {}));
35
+ function identifyTrezoaAttestationServiceInstruction(instruction) {
36
+ const data = 'data' in instruction ? instruction.data : instruction;
37
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(0), 0)) {
38
+ return TrezoaAttestationServiceInstruction.CreateCredential;
39
+ }
40
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(1), 0)) {
41
+ return TrezoaAttestationServiceInstruction.CreateSchema;
42
+ }
43
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(2), 0)) {
44
+ return TrezoaAttestationServiceInstruction.ChangeSchemaStatus;
45
+ }
46
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(3), 0)) {
47
+ return TrezoaAttestationServiceInstruction.ChangeAuthorizedSigners;
48
+ }
49
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(4), 0)) {
50
+ return TrezoaAttestationServiceInstruction.ChangeSchemaDescription;
51
+ }
52
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(5), 0)) {
53
+ return TrezoaAttestationServiceInstruction.ChangeSchemaVersion;
54
+ }
55
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(6), 0)) {
56
+ return TrezoaAttestationServiceInstruction.CreateAttestation;
57
+ }
58
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(7), 0)) {
59
+ return TrezoaAttestationServiceInstruction.CloseAttestation;
60
+ }
61
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(9), 0)) {
62
+ return TrezoaAttestationServiceInstruction.TokenizeSchema;
63
+ }
64
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(10), 0)) {
65
+ return TrezoaAttestationServiceInstruction.CreateTokenizedAttestation;
66
+ }
67
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(11), 0)) {
68
+ return TrezoaAttestationServiceInstruction.CloseTokenizedAttestation;
69
+ }
70
+ if ((0, kit_1.containsBytes)(data, (0, kit_1.getU8Encoder)().encode(228), 0)) {
71
+ return TrezoaAttestationServiceInstruction.EmitEvent;
72
+ }
73
+ throw new Error('The provided instruction could not be identified as a trezoaAttestationService instruction.');
74
+ }
@@ -0,0 +1,49 @@
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 ProgramDerivedAddress, type TransactionSigner } from '@trezoa/kit';
9
+ /**
10
+ * Asserts that the given value is not null or undefined.
11
+ * @internal
12
+ */
13
+ export declare function expectSome<T>(value: T | null | undefined): T;
14
+ /**
15
+ * Asserts that the given value is a PublicKey.
16
+ * @internal
17
+ */
18
+ export declare function expectAddress<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): Address<T>;
19
+ /**
20
+ * Asserts that the given value is a PDA.
21
+ * @internal
22
+ */
23
+ export declare function expectProgramDerivedAddress<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): ProgramDerivedAddress<T>;
24
+ /**
25
+ * Asserts that the given value is a TransactionSigner.
26
+ * @internal
27
+ */
28
+ export declare function expectTransactionSigner<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): TransactionSigner<T>;
29
+ /**
30
+ * Defines an instruction account to resolve.
31
+ * @internal
32
+ */
33
+ export type ResolvedAccount<T extends string = string, U extends Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null = Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null> = {
34
+ isWritable: boolean;
35
+ value: U;
36
+ };
37
+ /**
38
+ * Defines an instruction that stores additional bytes on-chain.
39
+ * @internal
40
+ */
41
+ export type InstructionWithByteDelta = {
42
+ byteDelta: number;
43
+ };
44
+ /**
45
+ * Get account metas and signers from resolved accounts.
46
+ * @internal
47
+ */
48
+ export declare function getAccountMetaFactory(programAddress: Address, optionalAccountStrategy: 'omitted' | 'programId'): (account: ResolvedAccount) => AccountMeta | AccountSignerMeta | undefined;
49
+ export declare function isTransactionSigner<TAddress extends string = string>(value: Address<TAddress> | ProgramDerivedAddress<TAddress> | TransactionSigner<TAddress>): value is TransactionSigner<TAddress>;
@@ -0,0 +1,94 @@
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.expectSome = expectSome;
11
+ exports.expectAddress = expectAddress;
12
+ exports.expectProgramDerivedAddress = expectProgramDerivedAddress;
13
+ exports.expectTransactionSigner = expectTransactionSigner;
14
+ exports.getAccountMetaFactory = getAccountMetaFactory;
15
+ exports.isTransactionSigner = isTransactionSigner;
16
+ const kit_1 = require("@trezoa/kit");
17
+ /**
18
+ * Asserts that the given value is not null or undefined.
19
+ * @internal
20
+ */
21
+ function expectSome(value) {
22
+ if (value === null || value === undefined) {
23
+ throw new Error('Expected a value but received null or undefined.');
24
+ }
25
+ return value;
26
+ }
27
+ /**
28
+ * Asserts that the given value is a PublicKey.
29
+ * @internal
30
+ */
31
+ function expectAddress(value) {
32
+ if (!value) {
33
+ throw new Error('Expected a Address.');
34
+ }
35
+ if (typeof value === 'object' && 'address' in value) {
36
+ return value.address;
37
+ }
38
+ if (Array.isArray(value)) {
39
+ return value[0];
40
+ }
41
+ return value;
42
+ }
43
+ /**
44
+ * Asserts that the given value is a PDA.
45
+ * @internal
46
+ */
47
+ function expectProgramDerivedAddress(value) {
48
+ if (!value || !Array.isArray(value) || !(0, kit_1.isProgramDerivedAddress)(value)) {
49
+ throw new Error('Expected a ProgramDerivedAddress.');
50
+ }
51
+ return value;
52
+ }
53
+ /**
54
+ * Asserts that the given value is a TransactionSigner.
55
+ * @internal
56
+ */
57
+ function expectTransactionSigner(value) {
58
+ if (!value || !isTransactionSigner(value)) {
59
+ throw new Error('Expected a TransactionSigner.');
60
+ }
61
+ return value;
62
+ }
63
+ /**
64
+ * Get account metas and signers from resolved accounts.
65
+ * @internal
66
+ */
67
+ function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
68
+ return (account) => {
69
+ if (!account.value) {
70
+ if (optionalAccountStrategy === 'omitted')
71
+ return;
72
+ return Object.freeze({
73
+ address: programAddress,
74
+ role: kit_1.AccountRole.READONLY,
75
+ });
76
+ }
77
+ const writableRole = account.isWritable
78
+ ? kit_1.AccountRole.WRITABLE
79
+ : kit_1.AccountRole.READONLY;
80
+ return Object.freeze({
81
+ address: expectAddress(account.value),
82
+ role: isTransactionSigner(account.value)
83
+ ? (0, kit_1.upgradeRoleToSigner)(writableRole)
84
+ : writableRole,
85
+ ...(isTransactionSigner(account.value) ? { signer: account.value } : {}),
86
+ });
87
+ };
88
+ }
89
+ function isTransactionSigner(value) {
90
+ return (!!value &&
91
+ typeof value === 'object' &&
92
+ 'address' in value &&
93
+ (0, kit_1.isTransactionSigner)(value));
94
+ }
@@ -0,0 +1,17 @@
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 Address, type Codec, type Decoder, type Encoder, type ReadonlyUint8Array } from '@trezoa/kit';
9
+ export type CloseAttestationEvent = {
10
+ discriminator: number;
11
+ schema: Address;
12
+ attestationData: ReadonlyUint8Array;
13
+ };
14
+ export type CloseAttestationEventArgs = CloseAttestationEvent;
15
+ export declare function getCloseAttestationEventEncoder(): Encoder<CloseAttestationEventArgs>;
16
+ export declare function getCloseAttestationEventDecoder(): Decoder<CloseAttestationEvent>;
17
+ export declare function getCloseAttestationEventCodec(): Codec<CloseAttestationEventArgs, CloseAttestationEvent>;
@@ -0,0 +1,36 @@
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.getCloseAttestationEventEncoder = getCloseAttestationEventEncoder;
11
+ exports.getCloseAttestationEventDecoder = getCloseAttestationEventDecoder;
12
+ exports.getCloseAttestationEventCodec = getCloseAttestationEventCodec;
13
+ const kit_1 = require("@trezoa/kit");
14
+ function getCloseAttestationEventEncoder() {
15
+ return (0, kit_1.getStructEncoder)([
16
+ ['discriminator', (0, kit_1.getU8Encoder)()],
17
+ ['schema', (0, kit_1.getAddressEncoder)()],
18
+ [
19
+ 'attestationData',
20
+ (0, kit_1.addEncoderSizePrefix)((0, kit_1.getBytesEncoder)(), (0, kit_1.getU32Encoder)()),
21
+ ],
22
+ ]);
23
+ }
24
+ function getCloseAttestationEventDecoder() {
25
+ return (0, kit_1.getStructDecoder)([
26
+ ['discriminator', (0, kit_1.getU8Decoder)()],
27
+ ['schema', (0, kit_1.getAddressDecoder)()],
28
+ [
29
+ 'attestationData',
30
+ (0, kit_1.addDecoderSizePrefix)((0, kit_1.getBytesDecoder)(), (0, kit_1.getU32Decoder)()),
31
+ ],
32
+ ]);
33
+ }
34
+ function getCloseAttestationEventCodec() {
35
+ return (0, kit_1.combineCodec)(getCloseAttestationEventEncoder(), getCloseAttestationEventDecoder());
36
+ }
@@ -0,0 +1,8 @@
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
+ export * from './closeAttestationEvent';
@@ -0,0 +1,24 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ __exportStar(require("./closeAttestationEvent"), exports);
@@ -0,0 +1,3 @@
1
+ export * from "./generated";
2
+ export * from "./pdas";
3
+ export * from "./utils";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generated"), exports);
18
+ __exportStar(require("./pdas"), exports);
19
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,69 @@
1
+ import { Address } from "@trezoa/kit";
2
+ export declare const ATTESTATION_SEED = "attestation";
3
+ export declare const CREDENTIAL_SEED = "credential";
4
+ export declare const SCHEMA_SEED = "schema";
5
+ export declare const EVENT_AUTHORITY_SEED = "__event_authority";
6
+ export declare const SAS_SEED = "sas";
7
+ export declare const SCHEMA_MINT_SEED = "schemaMint";
8
+ export declare const ATTESTATION_MINT_SEED = "attestationMint";
9
+ /**
10
+ * Derive the EVENT_AUTHORITY_ADDRESS.
11
+ */
12
+ export declare const deriveEventAuthorityAddress: () => Promise<Address<string>>;
13
+ /**
14
+ * Derive the SAS_ADDRESS.
15
+ */
16
+ export declare const deriveSasAuthorityAddress: () => Promise<Address<string>>;
17
+ /**
18
+ * Derive a Credential (aka Issuer) PDA.
19
+ * @param authority The Address that controls the Credential account.
20
+ * @param name A name for the credential. NOTE that only the first 32 bytes
21
+ * will be used for the PDA due to seed size limits.
22
+ * @returns
23
+ */
24
+ export declare const deriveCredentialPda: ({ authority, name, }: {
25
+ authority: Address;
26
+ name: string;
27
+ }) => Promise<readonly [Address<string>, import("@trezoa/kit").ProgramDerivedAddressBump]>;
28
+ /**
29
+ * Derive a Schema PDA.
30
+ * @param credential The Credential that the Schema is associated with.
31
+ * @param name A name for the schema. NOTE that only the first 32 bytes
32
+ * will be used for the PDA due to seed size limits.
33
+ * @param version The version number (up to 255) of the Schema.
34
+ * @returns
35
+ */
36
+ export declare const deriveSchemaPda: ({ credential, name, version, }: {
37
+ credential: Address;
38
+ name: string;
39
+ version: number;
40
+ }) => Promise<readonly [Address<string>, import("@trezoa/kit").ProgramDerivedAddressBump]>;
41
+ /**
42
+ * Derive an Attestation PDA.
43
+ * @param credential The Credential (aka Issuer) that controls the Attestation state.
44
+ * @param schema The Schema that the Attestation adheres to.
45
+ * @param nonce An Address that may either represent the Wallet the Attestation
46
+ * is associated with OR a randomly generated Address to prevent PDA collision.
47
+ * @returns
48
+ */
49
+ export declare const deriveAttestationPda: ({ credential, schema, nonce, }: {
50
+ credential: Address;
51
+ schema: Address;
52
+ nonce: Address;
53
+ }) => Promise<readonly [Address<string>, import("@trezoa/kit").ProgramDerivedAddressBump]>;
54
+ /**
55
+ * Derive the Token2022 Mint address of the tokenized Schema.
56
+ * @param schema The Schema that the token belongs to.
57
+ * @returns
58
+ */
59
+ export declare const deriveSchemaMintPda: ({ schema }: {
60
+ schema: Address;
61
+ }) => Promise<readonly [Address<string>, import("@trezoa/kit").ProgramDerivedAddressBump]>;
62
+ /**
63
+ * Derive the Token2022 Mint address of the tokenized Attestation.
64
+ * @param attestations The Attestation that the token belongs to.
65
+ * @returns
66
+ */
67
+ export declare const deriveAttestationMintPda: ({ attestation, }: {
68
+ attestation: Address;
69
+ }) => Promise<readonly [Address<string>, import("@trezoa/kit").ProgramDerivedAddressBump]>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deriveAttestationMintPda = exports.deriveSchemaMintPda = exports.deriveAttestationPda = exports.deriveSchemaPda = exports.deriveCredentialPda = exports.deriveSasAuthorityAddress = exports.deriveEventAuthorityAddress = exports.ATTESTATION_MINT_SEED = exports.SCHEMA_MINT_SEED = exports.SAS_SEED = exports.EVENT_AUTHORITY_SEED = exports.SCHEMA_SEED = exports.CREDENTIAL_SEED = exports.ATTESTATION_SEED = void 0;
4
+ const kit_1 = require("@trezoa/kit");
5
+ const programs_1 = require("./generated/programs");
6
+ exports.ATTESTATION_SEED = "attestation";
7
+ exports.CREDENTIAL_SEED = "credential";
8
+ exports.SCHEMA_SEED = "schema";
9
+ exports.EVENT_AUTHORITY_SEED = "__event_authority";
10
+ exports.SAS_SEED = "sas";
11
+ exports.SCHEMA_MINT_SEED = "schemaMint";
12
+ exports.ATTESTATION_MINT_SEED = "attestationMint";
13
+ // Note: event authority and sas address could be constant, but
14
+ // to keep the SDK dynamic in the event the program ID changes we
15
+ // always derive the addresses.
16
+ /**
17
+ * Derive the EVENT_AUTHORITY_ADDRESS.
18
+ */
19
+ const deriveEventAuthorityAddress = async () => (await (0, kit_1.getProgramDerivedAddress)({
20
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
21
+ seeds: [exports.EVENT_AUTHORITY_SEED],
22
+ }))[0];
23
+ exports.deriveEventAuthorityAddress = deriveEventAuthorityAddress;
24
+ /**
25
+ * Derive the SAS_ADDRESS.
26
+ */
27
+ const deriveSasAuthorityAddress = async () => (await (0, kit_1.getProgramDerivedAddress)({
28
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
29
+ seeds: [exports.SAS_SEED],
30
+ }))[0];
31
+ exports.deriveSasAuthorityAddress = deriveSasAuthorityAddress;
32
+ /**
33
+ * Derive a Credential (aka Issuer) PDA.
34
+ * @param authority The Address that controls the Credential account.
35
+ * @param name A name for the credential. NOTE that only the first 32 bytes
36
+ * will be used for the PDA due to seed size limits.
37
+ * @returns
38
+ */
39
+ const deriveCredentialPda = ({ authority, name, }) => (0, kit_1.getProgramDerivedAddress)({
40
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
41
+ seeds: [exports.CREDENTIAL_SEED, (0, kit_1.getAddressEncoder)().encode(authority), name],
42
+ });
43
+ exports.deriveCredentialPda = deriveCredentialPda;
44
+ /**
45
+ * Derive a Schema PDA.
46
+ * @param credential The Credential that the Schema is associated with.
47
+ * @param name A name for the schema. NOTE that only the first 32 bytes
48
+ * will be used for the PDA due to seed size limits.
49
+ * @param version The version number (up to 255) of the Schema.
50
+ * @returns
51
+ */
52
+ const deriveSchemaPda = ({ credential, name, version, }) => {
53
+ const versionSeed = Uint8Array.from([version]);
54
+ return (0, kit_1.getProgramDerivedAddress)({
55
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
56
+ seeds: [exports.SCHEMA_SEED, (0, kit_1.getAddressEncoder)().encode(credential), name, versionSeed],
57
+ });
58
+ };
59
+ exports.deriveSchemaPda = deriveSchemaPda;
60
+ /**
61
+ * Derive an Attestation PDA.
62
+ * @param credential The Credential (aka Issuer) that controls the Attestation state.
63
+ * @param schema The Schema that the Attestation adheres to.
64
+ * @param nonce An Address that may either represent the Wallet the Attestation
65
+ * is associated with OR a randomly generated Address to prevent PDA collision.
66
+ * @returns
67
+ */
68
+ const deriveAttestationPda = ({ credential, schema, nonce, }) => {
69
+ const addressEncoder = (0, kit_1.getAddressEncoder)();
70
+ return (0, kit_1.getProgramDerivedAddress)({
71
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
72
+ seeds: [exports.ATTESTATION_SEED, addressEncoder.encode(credential), addressEncoder.encode(schema), addressEncoder.encode(nonce)],
73
+ });
74
+ };
75
+ exports.deriveAttestationPda = deriveAttestationPda;
76
+ /* PDAs for tokenization */
77
+ /**
78
+ * Derive the Token2022 Mint address of the tokenized Schema.
79
+ * @param schema The Schema that the token belongs to.
80
+ * @returns
81
+ */
82
+ const deriveSchemaMintPda = ({ schema }) => (0, kit_1.getProgramDerivedAddress)({
83
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
84
+ seeds: [exports.SCHEMA_MINT_SEED, (0, kit_1.getAddressEncoder)().encode(schema)],
85
+ });
86
+ exports.deriveSchemaMintPda = deriveSchemaMintPda;
87
+ /**
88
+ * Derive the Token2022 Mint address of the tokenized Attestation.
89
+ * @param attestations The Attestation that the token belongs to.
90
+ * @returns
91
+ */
92
+ const deriveAttestationMintPda = ({ attestation, }) => (0, kit_1.getProgramDerivedAddress)({
93
+ programAddress: programs_1.TREZOA_ATTESTATION_SERVICE_PROGRAM_ADDRESS,
94
+ seeds: [exports.ATTESTATION_MINT_SEED, (0, kit_1.getAddressEncoder)().encode(attestation)],
95
+ });
96
+ exports.deriveAttestationMintPda = deriveAttestationMintPda;
@@ -0,0 +1,21 @@
1
+ import { BorshSchema } from "borsher";
2
+ import { Schema } from "./generated";
3
+ /**
4
+ * Given the onchain representation of a Schema, we generate a Borsh schema
5
+ * for (de)serialization.
6
+ * @param schema
7
+ * @returns
8
+ */
9
+ export declare const convertSasSchemaToBorshSchema: (schema: Schema) => BorshSchema<Record<string, unknown>>;
10
+ /**
11
+ * Given a SAS Schema and an object that represents the Attestation data,
12
+ * serialize the Attestation data to valid byte array.
13
+ * @param schema
14
+ */
15
+ export declare const serializeAttestationData: (schema: Schema, data: Record<string, unknown>) => Uint8Array;
16
+ /**
17
+ * Given a SAS Schema and a byte array of Attestation data,
18
+ * deserialize the Attestation data to an object.
19
+ * @param schema
20
+ */
21
+ export declare const deserializeAttestationData: <T>(schema: Schema, data: Uint8Array) => T;