@solana-mobile/guardian-client 0.0.0-stage → 0.1.0

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 (69) hide show
  1. package/README.md +8 -2
  2. package/dist/src/index.js +4641 -0
  3. package/dist/src/index.js.map +1 -0
  4. package/dist/src/index.mjs +4282 -0
  5. package/dist/src/index.mjs.map +1 -0
  6. package/dist/types/generated/accounts/appAccount.d.ts +50 -0
  7. package/dist/types/generated/accounts/guardiansConfig.d.ts +54 -0
  8. package/dist/types/generated/accounts/index.d.ts +10 -0
  9. package/dist/types/generated/accounts/pendingRegistry.d.ts +35 -0
  10. package/dist/types/generated/constants/guardian.d.ts +8 -0
  11. package/dist/types/generated/constants/index.d.ts +8 -0
  12. package/dist/types/generated/errors/guardian.d.ts +95 -0
  13. package/dist/types/generated/errors/index.d.ts +8 -0
  14. package/dist/types/generated/events/appAuthorityAccepted.d.ts +42 -0
  15. package/dist/types/generated/events/appAuthorityProposed.d.ts +42 -0
  16. package/dist/types/generated/events/appDeveloperUpdated.d.ts +42 -0
  17. package/dist/types/generated/events/appRegistered.d.ts +42 -0
  18. package/dist/types/generated/events/configAuthorityAccepted.d.ts +38 -0
  19. package/dist/types/generated/events/configAuthorityProposed.d.ts +38 -0
  20. package/dist/types/generated/events/configInitialized.d.ts +46 -0
  21. package/dist/types/generated/events/configUpdated.d.ts +52 -0
  22. package/dist/types/generated/events/guardianAdded.d.ts +34 -0
  23. package/dist/types/generated/events/guardianRegistered.d.ts +46 -0
  24. package/dist/types/generated/events/guardianRemoved.d.ts +42 -0
  25. package/dist/types/generated/events/guardianVoteAuthorityRotated.d.ts +42 -0
  26. package/dist/types/generated/events/index.d.ts +25 -0
  27. package/dist/types/generated/events/releaseApproved.d.ts +27 -0
  28. package/dist/types/generated/events/releaseCancelled.d.ts +38 -0
  29. package/dist/types/generated/events/releaseExpired.d.ts +38 -0
  30. package/dist/types/generated/events/releaseProposed.d.ts +42 -0
  31. package/dist/types/generated/events/releaseRejected.d.ts +27 -0
  32. package/dist/types/generated/events/voteCast.d.ts +55 -0
  33. package/dist/types/generated/index.d.ts +15 -0
  34. package/dist/types/generated/instructions/acceptAppAuthority.d.ts +71 -0
  35. package/dist/types/generated/instructions/acceptConfigAuthority.d.ts +71 -0
  36. package/dist/types/generated/instructions/addGuardian.d.ts +90 -0
  37. package/dist/types/generated/instructions/cancelRelease.d.ts +78 -0
  38. package/dist/types/generated/instructions/expireRelease.d.ts +71 -0
  39. package/dist/types/generated/instructions/index.d.ts +24 -0
  40. package/dist/types/generated/instructions/initializeConfig.d.ts +135 -0
  41. package/dist/types/generated/instructions/proposeAppAuthority.d.ts +76 -0
  42. package/dist/types/generated/instructions/proposeConfigAuthority.d.ts +76 -0
  43. package/dist/types/generated/instructions/proposeRelease.d.ts +121 -0
  44. package/dist/types/generated/instructions/registerApp.d.ts +87 -0
  45. package/dist/types/generated/instructions/registerGuardian.d.ts +120 -0
  46. package/dist/types/generated/instructions/removeGuardian.d.ts +120 -0
  47. package/dist/types/generated/instructions/rotateVoteAuthority.d.ts +80 -0
  48. package/dist/types/generated/instructions/setAppDeveloper.d.ts +112 -0
  49. package/dist/types/generated/instructions/updateConfig.d.ts +88 -0
  50. package/dist/types/generated/instructions/vote.d.ts +116 -0
  51. package/dist/types/generated/instructions/writeReleaseManifest.d.ts +104 -0
  52. package/dist/types/generated/pdas/bondVault.d.ts +11 -0
  53. package/dist/types/generated/pdas/guardiansConfig.d.ts +11 -0
  54. package/dist/types/generated/pdas/index.d.ts +10 -0
  55. package/dist/types/generated/pdas/pendingRegistry.d.ts +11 -0
  56. package/dist/types/generated/programs/guardian.d.ts +179 -0
  57. package/dist/types/generated/programs/index.d.ts +8 -0
  58. package/dist/types/generated/types/bondInfo.d.ts +19 -0
  59. package/dist/types/generated/types/guardianInfo.d.ts +19 -0
  60. package/dist/types/generated/types/index.d.ts +14 -0
  61. package/dist/types/generated/types/pendingRelease.d.ts +29 -0
  62. package/dist/types/generated/types/publishedApp.d.ts +16 -0
  63. package/dist/types/generated/types/releaseManifest.d.ts +45 -0
  64. package/dist/types/generated/types/releaseResolution.d.ts +65 -0
  65. package/dist/types/generated/types/voteFinding.d.ts +24 -0
  66. package/dist/types/index.d.ts +3 -0
  67. package/dist/types/manifest.d.ts +72 -0
  68. package/dist/types/proposal.d.ts +66 -0
  69. package/package.json +58 -3
@@ -0,0 +1,179 @@
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 ClientWithRpc, type ClientWithTransactionPlanning, type ClientWithTransactionSending, type ExtendedClient, type GetAccountInfoApi, type GetMultipleAccountsApi, type HasAddress, type Instruction, type InstructionWithData, type ReadonlyUint8Array } from '@solana/kit';
9
+ import { type SelfFetchFunctions, type SelfPlanAndSendFunctions } from '@solana/program-client-core';
10
+ import { getAppAccountCodec, getGuardiansConfigCodec, getPendingRegistryCodec, type AppAccount, type AppAccountArgs, type GuardiansConfig, type GuardiansConfigArgs, type PendingRegistry, type PendingRegistryArgs } from '../accounts';
11
+ import { getAcceptAppAuthorityInstructionAsync, getAcceptConfigAuthorityInstructionAsync, getAddGuardianInstructionAsync, getCancelReleaseInstructionAsync, getExpireReleaseInstructionAsync, getInitializeConfigInstructionAsync, getProposeAppAuthorityInstructionAsync, getProposeConfigAuthorityInstructionAsync, getProposeReleaseInstructionAsync, getRegisterAppInstructionAsync, getRegisterGuardianInstructionAsync, getRemoveGuardianInstructionAsync, getRotateVoteAuthorityInstructionAsync, getSetAppDeveloperInstructionAsync, getUpdateConfigInstructionAsync, getVoteInstructionAsync, getWriteReleaseManifestInstructionAsync, type AcceptAppAuthorityAsyncInput, type AcceptConfigAuthorityAsyncInput, type AddGuardianAsyncInput, type CancelReleaseAsyncInput, type ExpireReleaseAsyncInput, type InitializeConfigAsyncInput, type ParsedAcceptAppAuthorityInstruction, type ParsedAcceptConfigAuthorityInstruction, type ParsedAddGuardianInstruction, type ParsedCancelReleaseInstruction, type ParsedExpireReleaseInstruction, type ParsedInitializeConfigInstruction, type ParsedProposeAppAuthorityInstruction, type ParsedProposeConfigAuthorityInstruction, type ParsedProposeReleaseInstruction, type ParsedRegisterAppInstruction, type ParsedRegisterGuardianInstruction, type ParsedRemoveGuardianInstruction, type ParsedRotateVoteAuthorityInstruction, type ParsedSetAppDeveloperInstruction, type ParsedUpdateConfigInstruction, type ParsedVoteInstruction, type ParsedWriteReleaseManifestInstruction, type ProposeAppAuthorityAsyncInput, type ProposeConfigAuthorityAsyncInput, type ProposeReleaseAsyncInput, type RegisterAppAsyncInput, type RegisterGuardianAsyncInput, type RemoveGuardianAsyncInput, type RotateVoteAuthorityAsyncInput, type SetAppDeveloperAsyncInput, type UpdateConfigAsyncInput, type VoteAsyncInput, type WriteReleaseManifestAsyncInput } from '../instructions';
12
+ import { findBondVaultPda, findGuardiansConfigPda, findPendingRegistryPda } from '../pdas';
13
+ export declare const GUARDIAN_PROGRAM_ADDRESS: Address<"GUARDsVUfAaydbPU6QGcpWRLUkExaULtaygwEtkdhZAD">;
14
+ export declare enum GuardianAccount {
15
+ AppAccount = 0,
16
+ GuardiansConfig = 1,
17
+ PendingRegistry = 2
18
+ }
19
+ export declare function identifyGuardianAccount(account: {
20
+ data: ReadonlyUint8Array;
21
+ } | ReadonlyUint8Array): GuardianAccount;
22
+ export declare enum GuardianEvent {
23
+ AppAuthorityAccepted = 0,
24
+ AppAuthorityProposed = 1,
25
+ AppDeveloperUpdated = 2,
26
+ AppRegistered = 3,
27
+ ConfigAuthorityAccepted = 4,
28
+ ConfigAuthorityProposed = 5,
29
+ ConfigInitialized = 6,
30
+ ConfigUpdated = 7,
31
+ GuardianAdded = 8,
32
+ GuardianRegistered = 9,
33
+ GuardianRemoved = 10,
34
+ GuardianVoteAuthorityRotated = 11,
35
+ ReleaseApproved = 12,
36
+ ReleaseCancelled = 13,
37
+ ReleaseExpired = 14,
38
+ ReleaseProposed = 15,
39
+ ReleaseRejected = 16,
40
+ VoteCast = 17
41
+ }
42
+ export declare function identifyGuardianEvent(event: {
43
+ data: ReadonlyUint8Array;
44
+ } | ReadonlyUint8Array): GuardianEvent;
45
+ export declare enum GuardianInstruction {
46
+ AcceptAppAuthority = 0,
47
+ AcceptConfigAuthority = 1,
48
+ AddGuardian = 2,
49
+ CancelRelease = 3,
50
+ ExpireRelease = 4,
51
+ InitializeConfig = 5,
52
+ ProposeAppAuthority = 6,
53
+ ProposeConfigAuthority = 7,
54
+ ProposeRelease = 8,
55
+ RegisterApp = 9,
56
+ RegisterGuardian = 10,
57
+ RemoveGuardian = 11,
58
+ RotateVoteAuthority = 12,
59
+ SetAppDeveloper = 13,
60
+ UpdateConfig = 14,
61
+ Vote = 15,
62
+ WriteReleaseManifest = 16
63
+ }
64
+ export declare function identifyGuardianInstruction(instruction: {
65
+ data: ReadonlyUint8Array;
66
+ } | ReadonlyUint8Array): GuardianInstruction;
67
+ export type ParsedGuardianInstruction<TProgram extends string = 'GUARDsVUfAaydbPU6QGcpWRLUkExaULtaygwEtkdhZAD'> = ({
68
+ instructionType: GuardianInstruction.AcceptAppAuthority;
69
+ } & ParsedAcceptAppAuthorityInstruction<TProgram>) | ({
70
+ instructionType: GuardianInstruction.AcceptConfigAuthority;
71
+ } & ParsedAcceptConfigAuthorityInstruction<TProgram>) | ({
72
+ instructionType: GuardianInstruction.AddGuardian;
73
+ } & ParsedAddGuardianInstruction<TProgram>) | ({
74
+ instructionType: GuardianInstruction.CancelRelease;
75
+ } & ParsedCancelReleaseInstruction<TProgram>) | ({
76
+ instructionType: GuardianInstruction.ExpireRelease;
77
+ } & ParsedExpireReleaseInstruction<TProgram>) | ({
78
+ instructionType: GuardianInstruction.InitializeConfig;
79
+ } & ParsedInitializeConfigInstruction<TProgram>) | ({
80
+ instructionType: GuardianInstruction.ProposeAppAuthority;
81
+ } & ParsedProposeAppAuthorityInstruction<TProgram>) | ({
82
+ instructionType: GuardianInstruction.ProposeConfigAuthority;
83
+ } & ParsedProposeConfigAuthorityInstruction<TProgram>) | ({
84
+ instructionType: GuardianInstruction.ProposeRelease;
85
+ } & ParsedProposeReleaseInstruction<TProgram>) | ({
86
+ instructionType: GuardianInstruction.RegisterApp;
87
+ } & ParsedRegisterAppInstruction<TProgram>) | ({
88
+ instructionType: GuardianInstruction.RegisterGuardian;
89
+ } & ParsedRegisterGuardianInstruction<TProgram>) | ({
90
+ instructionType: GuardianInstruction.RemoveGuardian;
91
+ } & ParsedRemoveGuardianInstruction<TProgram>) | ({
92
+ instructionType: GuardianInstruction.RotateVoteAuthority;
93
+ } & ParsedRotateVoteAuthorityInstruction<TProgram>) | ({
94
+ instructionType: GuardianInstruction.SetAppDeveloper;
95
+ } & ParsedSetAppDeveloperInstruction<TProgram>) | ({
96
+ instructionType: GuardianInstruction.UpdateConfig;
97
+ } & ParsedUpdateConfigInstruction<TProgram>) | ({
98
+ instructionType: GuardianInstruction.Vote;
99
+ } & ParsedVoteInstruction<TProgram>) | ({
100
+ instructionType: GuardianInstruction.WriteReleaseManifest;
101
+ } & ParsedWriteReleaseManifestInstruction<TProgram>);
102
+ export declare function parseGuardianInstruction<TProgram extends string>(instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>): ParsedGuardianInstruction<TProgram>;
103
+ export type GuardianPlugin = {
104
+ accounts: GuardianPluginAccounts;
105
+ instructions: GuardianPluginInstructions;
106
+ pdas: GuardianPluginPdas;
107
+ identifyAccount: typeof identifyGuardianAccount;
108
+ identifyInstruction: typeof identifyGuardianInstruction;
109
+ parseInstruction: typeof parseGuardianInstruction;
110
+ };
111
+ export type GuardianPluginAccounts = {
112
+ appAccount: ReturnType<typeof getAppAccountCodec> & SelfFetchFunctions<AppAccountArgs, AppAccount>;
113
+ guardiansConfig: ReturnType<typeof getGuardiansConfigCodec> & SelfFetchFunctions<GuardiansConfigArgs, GuardiansConfig>;
114
+ pendingRegistry: ReturnType<typeof getPendingRegistryCodec> & SelfFetchFunctions<PendingRegistryArgs, PendingRegistry>;
115
+ };
116
+ export type GuardianPluginInstructions = {
117
+ acceptAppAuthority: (input: AcceptAppAuthorityAsyncInput, config?: {
118
+ programAddress?: Address | HasAddress;
119
+ }) => ReturnType<typeof getAcceptAppAuthorityInstructionAsync> & SelfPlanAndSendFunctions;
120
+ acceptConfigAuthority: (input: AcceptConfigAuthorityAsyncInput, config?: {
121
+ programAddress?: Address | HasAddress;
122
+ }) => ReturnType<typeof getAcceptConfigAuthorityInstructionAsync> & SelfPlanAndSendFunctions;
123
+ addGuardian: (input: AddGuardianAsyncInput, config?: {
124
+ programAddress?: Address | HasAddress;
125
+ }) => ReturnType<typeof getAddGuardianInstructionAsync> & SelfPlanAndSendFunctions;
126
+ cancelRelease: (input: CancelReleaseAsyncInput, config?: {
127
+ programAddress?: Address | HasAddress;
128
+ }) => ReturnType<typeof getCancelReleaseInstructionAsync> & SelfPlanAndSendFunctions;
129
+ expireRelease: (input: ExpireReleaseAsyncInput, config?: {
130
+ programAddress?: Address | HasAddress;
131
+ }) => ReturnType<typeof getExpireReleaseInstructionAsync> & SelfPlanAndSendFunctions;
132
+ initializeConfig: (input: InitializeConfigAsyncInput, config?: {
133
+ programAddress?: Address | HasAddress;
134
+ }) => ReturnType<typeof getInitializeConfigInstructionAsync> & SelfPlanAndSendFunctions;
135
+ proposeAppAuthority: (input: ProposeAppAuthorityAsyncInput, config?: {
136
+ programAddress?: Address | HasAddress;
137
+ }) => ReturnType<typeof getProposeAppAuthorityInstructionAsync> & SelfPlanAndSendFunctions;
138
+ proposeConfigAuthority: (input: ProposeConfigAuthorityAsyncInput, config?: {
139
+ programAddress?: Address | HasAddress;
140
+ }) => ReturnType<typeof getProposeConfigAuthorityInstructionAsync> & SelfPlanAndSendFunctions;
141
+ proposeRelease: (input: ProposeReleaseAsyncInput, config?: {
142
+ programAddress?: Address | HasAddress;
143
+ }) => ReturnType<typeof getProposeReleaseInstructionAsync> & SelfPlanAndSendFunctions;
144
+ registerApp: (input: RegisterAppAsyncInput, config?: {
145
+ programAddress?: Address | HasAddress;
146
+ }) => ReturnType<typeof getRegisterAppInstructionAsync> & SelfPlanAndSendFunctions;
147
+ registerGuardian: (input: RegisterGuardianAsyncInput, config?: {
148
+ programAddress?: Address | HasAddress;
149
+ }) => ReturnType<typeof getRegisterGuardianInstructionAsync> & SelfPlanAndSendFunctions;
150
+ removeGuardian: (input: RemoveGuardianAsyncInput, config?: {
151
+ programAddress?: Address | HasAddress;
152
+ }) => ReturnType<typeof getRemoveGuardianInstructionAsync> & SelfPlanAndSendFunctions;
153
+ rotateVoteAuthority: (input: RotateVoteAuthorityAsyncInput, config?: {
154
+ programAddress?: Address | HasAddress;
155
+ }) => ReturnType<typeof getRotateVoteAuthorityInstructionAsync> & SelfPlanAndSendFunctions;
156
+ setAppDeveloper: (input: SetAppDeveloperAsyncInput, config?: {
157
+ programAddress?: Address | HasAddress;
158
+ }) => ReturnType<typeof getSetAppDeveloperInstructionAsync> & SelfPlanAndSendFunctions;
159
+ updateConfig: (input: UpdateConfigAsyncInput, config?: {
160
+ programAddress?: Address | HasAddress;
161
+ }) => ReturnType<typeof getUpdateConfigInstructionAsync> & SelfPlanAndSendFunctions;
162
+ vote: (input: VoteAsyncInput, config?: {
163
+ programAddress?: Address | HasAddress;
164
+ }) => ReturnType<typeof getVoteInstructionAsync> & SelfPlanAndSendFunctions;
165
+ writeReleaseManifest: (input: WriteReleaseManifestAsyncInput, config?: {
166
+ programAddress?: Address | HasAddress;
167
+ }) => ReturnType<typeof getWriteReleaseManifestInstructionAsync> & SelfPlanAndSendFunctions;
168
+ };
169
+ export type GuardianPluginPdas = {
170
+ guardiansConfig: typeof findGuardiansConfigPda;
171
+ pendingRegistry: typeof findPendingRegistryPda;
172
+ bondVault: typeof findBondVaultPda;
173
+ };
174
+ export type GuardianPluginRequirements = ClientWithRpc<GetAccountInfoApi & GetMultipleAccountsApi> & ClientWithTransactionPlanning & ClientWithTransactionSending;
175
+ export declare function guardianProgram(config?: {
176
+ programAddress?: Address | HasAddress;
177
+ }): <T extends GuardianPluginRequirements>(client: T) => ExtendedClient<T, {
178
+ guardian: GuardianPlugin;
179
+ }>;
@@ -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 './guardian';
@@ -0,0 +1,19 @@
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 FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type HasAddress } from '@solana/kit';
9
+ export type BondInfo = {
10
+ mint: Address;
11
+ amount: bigint;
12
+ };
13
+ export type BondInfoArgs = {
14
+ mint: Address | HasAddress;
15
+ amount: number | bigint;
16
+ };
17
+ export declare function getBondInfoEncoder(): FixedSizeEncoder<BondInfoArgs>;
18
+ export declare function getBondInfoDecoder(): FixedSizeDecoder<BondInfo>;
19
+ export declare function getBondInfoCodec(): FixedSizeCodec<BondInfoArgs, BondInfo>;
@@ -0,0 +1,19 @@
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 FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type HasAddress } from '@solana/kit';
9
+ export type GuardianInfo = {
10
+ voteAuthority: Address;
11
+ bond: bigint;
12
+ };
13
+ export type GuardianInfoArgs = {
14
+ voteAuthority: Address | HasAddress;
15
+ bond: number | bigint;
16
+ };
17
+ export declare function getGuardianInfoEncoder(): FixedSizeEncoder<GuardianInfoArgs>;
18
+ export declare function getGuardianInfoDecoder(): FixedSizeDecoder<GuardianInfo>;
19
+ export declare function getGuardianInfoCodec(): FixedSizeCodec<GuardianInfoArgs, GuardianInfo>;
@@ -0,0 +1,14 @@
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 './bondInfo';
9
+ export * from './guardianInfo';
10
+ export * from './pendingRelease';
11
+ export * from './publishedApp';
12
+ export * from './releaseManifest';
13
+ export * from './releaseResolution';
14
+ export * from './voteFinding';
@@ -0,0 +1,29 @@
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 Codec, type Decoder, type Encoder, type GetDiscriminatedUnionVariant, type GetDiscriminatedUnionVariantContent } from '@solana/kit';
9
+ import { type ReleaseManifest, type ReleaseManifestArgs } from '.';
10
+ export type PendingRelease = {
11
+ __kind: 'None';
12
+ } | {
13
+ __kind: 'Pending';
14
+ fields: readonly [ReleaseManifest];
15
+ };
16
+ export type PendingReleaseArgs = {
17
+ __kind: 'None';
18
+ } | {
19
+ __kind: 'Pending';
20
+ fields: readonly [ReleaseManifestArgs];
21
+ };
22
+ export declare function getPendingReleaseEncoder(): Encoder<PendingReleaseArgs>;
23
+ export declare function getPendingReleaseDecoder(): Decoder<PendingRelease>;
24
+ export declare function getPendingReleaseCodec(): Codec<PendingReleaseArgs, PendingRelease>;
25
+ export declare function pendingRelease(kind: 'None'): GetDiscriminatedUnionVariant<PendingReleaseArgs, '__kind', 'None'>;
26
+ export declare function pendingRelease(kind: 'Pending', data: GetDiscriminatedUnionVariantContent<PendingReleaseArgs, '__kind', 'Pending'>['fields']): GetDiscriminatedUnionVariant<PendingReleaseArgs, '__kind', 'Pending'>;
27
+ export declare function isPendingRelease<K extends PendingRelease['__kind']>(kind: K, value: PendingRelease): value is PendingRelease & {
28
+ __kind: K;
29
+ };
@@ -0,0 +1,16 @@
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 FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
9
+ export type PublishedApp = {
10
+ versionCode: number;
11
+ manifestHash: ReadonlyUint8Array;
12
+ };
13
+ export type PublishedAppArgs = PublishedApp;
14
+ export declare function getPublishedAppEncoder(): FixedSizeEncoder<PublishedAppArgs>;
15
+ export declare function getPublishedAppDecoder(): FixedSizeDecoder<PublishedApp>;
16
+ export declare function getPublishedAppCodec(): FixedSizeCodec<PublishedAppArgs, PublishedApp>;
@@ -0,0 +1,45 @@
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 HasAddress, type ReadonlyUint8Array } from '@solana/kit';
9
+ export type ReleaseManifest = {
10
+ versionCode: number;
11
+ finalized: boolean;
12
+ guardianNonce: number;
13
+ manifestHash: ReadonlyUint8Array;
14
+ policyBundleHash: ReadonlyUint8Array;
15
+ resolved: boolean;
16
+ approved: boolean;
17
+ quorumTs: bigint;
18
+ votingDeadline: bigint;
19
+ finalizeTs: bigint;
20
+ finalizeSeq: bigint;
21
+ previousFinalizeTs: bigint;
22
+ certificateSha256: ReadonlyUint8Array;
23
+ data: ReadonlyUint8Array;
24
+ votes: Map<Address, boolean>;
25
+ };
26
+ export type ReleaseManifestArgs = {
27
+ versionCode: number;
28
+ finalized: boolean;
29
+ guardianNonce: number;
30
+ manifestHash: ReadonlyUint8Array;
31
+ policyBundleHash: ReadonlyUint8Array;
32
+ resolved: boolean;
33
+ approved: boolean;
34
+ quorumTs: number | bigint;
35
+ votingDeadline: number | bigint;
36
+ finalizeTs: number | bigint;
37
+ finalizeSeq: number | bigint;
38
+ previousFinalizeTs: number | bigint;
39
+ certificateSha256: ReadonlyUint8Array;
40
+ data: ReadonlyUint8Array;
41
+ votes: Map<Address | HasAddress, boolean>;
42
+ };
43
+ export declare function getReleaseManifestEncoder(): Encoder<ReleaseManifestArgs>;
44
+ export declare function getReleaseManifestDecoder(): Decoder<ReleaseManifest>;
45
+ export declare function getReleaseManifestCodec(): Codec<ReleaseManifestArgs, ReleaseManifest>;
@@ -0,0 +1,65 @@
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 HasAddress, type ReadonlyUint8Array } from '@solana/kit';
9
+ /**
10
+ * A resolved release, with its manifest and voters. Late votes aren't included; each one gets its
11
+ * own `VoteCast`.
12
+ */
13
+ export type ReleaseResolution = {
14
+ /** The wrapping event's `VERSION`. */
15
+ version: number;
16
+ /** Position in the app's event sequence. */
17
+ seq: bigint;
18
+ /** The app account. */
19
+ app: Address;
20
+ /** Version code of the resolved release. */
21
+ versionCode: number;
22
+ /** sha256 of `manifest`. */
23
+ manifestHash: ReadonlyUint8Array;
24
+ /**
25
+ * The release's signing certificate hash. Copied to the app's `signing_certificate` on
26
+ * approval.
27
+ */
28
+ certificateSha256: ReadonlyUint8Array;
29
+ /** Guardian-set nonce the votes were cast under. */
30
+ guardianNonce: number;
31
+ /** Authority keys of the guardians that approved, sorted. */
32
+ approvals: Array<Address>;
33
+ /** Authority keys of the guardians that rejected, sorted. */
34
+ rejections: Array<Address>;
35
+ /** Full manifest bytes. */
36
+ manifest: ReadonlyUint8Array;
37
+ };
38
+ export type ReleaseResolutionArgs = {
39
+ /** The wrapping event's `VERSION`. */
40
+ version: number;
41
+ /** Position in the app's event sequence. */
42
+ seq: number | bigint;
43
+ /** The app account. */
44
+ app: Address | HasAddress;
45
+ /** Version code of the resolved release. */
46
+ versionCode: number;
47
+ /** sha256 of `manifest`. */
48
+ manifestHash: ReadonlyUint8Array;
49
+ /**
50
+ * The release's signing certificate hash. Copied to the app's `signing_certificate` on
51
+ * approval.
52
+ */
53
+ certificateSha256: ReadonlyUint8Array;
54
+ /** Guardian-set nonce the votes were cast under. */
55
+ guardianNonce: number;
56
+ /** Authority keys of the guardians that approved, sorted. */
57
+ approvals: Array<Address | HasAddress>;
58
+ /** Authority keys of the guardians that rejected, sorted. */
59
+ rejections: Array<Address | HasAddress>;
60
+ /** Full manifest bytes. */
61
+ manifest: ReadonlyUint8Array;
62
+ };
63
+ export declare function getReleaseResolutionEncoder(): Encoder<ReleaseResolutionArgs>;
64
+ export declare function getReleaseResolutionDecoder(): Decoder<ReleaseResolution>;
65
+ export declare function getReleaseResolutionCodec(): Codec<ReleaseResolutionArgs, ReleaseResolution>;
@@ -0,0 +1,24 @@
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 Codec, type Decoder, type Encoder } from '@solana/kit';
9
+ /**
10
+ * A finding reported with a vote. `code` indexes the taxonomy of the vote's policy bundle. The
11
+ * program doesn't interpret findings.
12
+ */
13
+ export type VoteFinding = {
14
+ /** Index of the finding code in the policy bundle's taxonomy. */
15
+ code: number;
16
+ /** Check outcome, encoded by the voter. */
17
+ status: number;
18
+ /** Free-text detail. */
19
+ detail: string;
20
+ };
21
+ export type VoteFindingArgs = VoteFinding;
22
+ export declare function getVoteFindingEncoder(): Encoder<VoteFindingArgs>;
23
+ export declare function getVoteFindingDecoder(): Decoder<VoteFinding>;
24
+ export declare function getVoteFindingCodec(): Codec<VoteFindingArgs, VoteFinding>;
@@ -0,0 +1,3 @@
1
+ export * from './generated';
2
+ export * from './manifest';
3
+ export * from './proposal';
@@ -0,0 +1,72 @@
1
+ import { type Codec, type Decoder, type Encoder, type ReadonlyUint8Array } from '@solana/kit';
2
+ /** An off-chain file and the sha256 its bytes must match. */
3
+ export type Artifact = {
4
+ /** Where to fetch the file. */
5
+ uri: string;
6
+ /** sha256 the fetched bytes must match, 32 bytes. */
7
+ sha256: ReadonlyUint8Array;
8
+ };
9
+ /**
10
+ * The release manifest a publisher uploads with `write_release_manifest` and guardians vote on.
11
+ * `__kind` is the schema version. The encoding is specified in `docs/manifest.md`. Different from
12
+ * `ReleaseManifest`, the program's account record of a proposed release, its manifest bytes, and
13
+ * its votes.
14
+ */
15
+ export type Manifest = {
16
+ __kind: 'V1';
17
+ } & ManifestV1;
18
+ /** Schema version 1 of a {@link Manifest}. */
19
+ export type ManifestV1 = {
20
+ /** Android `versionCode`. Must equal the release's on-chain `version_code`. */
21
+ versionCode: number;
22
+ /** Android package name, e.g. `com.example.app`. */
23
+ package: string;
24
+ /** Android `versionName`. */
25
+ versionName: string;
26
+ /** Android `minSdkVersion`. */
27
+ minSdk: number;
28
+ /** Android permissions the APK requests. */
29
+ permissions: string[];
30
+ /** The APK. */
31
+ apk: Artifact;
32
+ /** URL of the terms and conditions. */
33
+ terms: string;
34
+ /** URL of the privacy policy. */
35
+ privacy: string;
36
+ /** sha256 of the APK's signing certificate, 32 bytes. Must equal the release's on-chain `certificate_sha256`. */
37
+ certificateSha256: ReadonlyUint8Array;
38
+ /** The publisher's website URL, or `null`. */
39
+ publisherSite: string | null;
40
+ };
41
+ /**
42
+ * Manifest bytes per `write_release_manifest` transaction, leaving headroom in a 1232-byte legacy
43
+ * transaction with two signers.
44
+ */
45
+ export declare const DEFAULT_MANIFEST_CHUNK = 800;
46
+ /** One `write_release_manifest` upload: `bytes` go at byte `offset` of the encoded manifest. */
47
+ export type ManifestChunk = {
48
+ offset: number;
49
+ bytes: ReadonlyUint8Array;
50
+ };
51
+ /**
52
+ * Splits an encoded manifest into upload chunks of at most `chunkSize` bytes, in order, each with
53
+ * its byte offset. An empty manifest gives one empty chunk, so a write still starts its release.
54
+ * Throws if `chunkSize` is not a positive integer.
55
+ */
56
+ export declare function getManifestChunks(manifest: ReadonlyUint8Array, chunkSize?: number): ManifestChunk[];
57
+ /**
58
+ * The sha256 of an encoded manifest, which `propose_release` takes as `manifestHash`. Finalizing
59
+ * fails with `ManifestHashMismatch` unless the uploaded bytes hash to it.
60
+ */
61
+ export declare function getManifestHash(manifest: ReadonlyUint8Array): Promise<Uint8Array>;
62
+ /** Encodes a {@link Manifest}. See {@link getManifestCodec}. */
63
+ export declare function getManifestEncoder(): Encoder<Manifest>;
64
+ /** Decodes a {@link Manifest}. See {@link getManifestCodec}. */
65
+ export declare function getManifestDecoder(): Decoder<Manifest>;
66
+ /**
67
+ * The borsh encoding of a {@link Manifest}, the bytes `write_release_manifest` uploads and the
68
+ * on-chain manifest hash covers. Like the Rust decoder in `tools/manifest`, decoding throws on an
69
+ * unknown schema version, an option tag other than 0 or 1, invalid UTF-8, a truncated field, or
70
+ * trailing bytes, so each manifest has one encoding.
71
+ */
72
+ export declare function getManifestCodec(): Codec<Manifest>;
@@ -0,0 +1,66 @@
1
+ import type { ReadonlyUint8Array } from '@solana/kit';
2
+ import type { AppAccount, GuardiansConfig, ReleaseManifest } from './generated';
3
+ /** The release in `app`'s pending slot, or `null` when the slot is empty. */
4
+ export declare function getPendingRelease(app: Pick<AppAccount, 'pendingRelease'>): ReleaseManifest | null;
5
+ /** A resolved release that still takes late votes, which holds the app's next release. */
6
+ export type LateVoteWindow = {
7
+ /** Cluster unix time, in seconds, at which the window closes. */
8
+ closesAt: bigint;
9
+ /** Votes cast so far, including late ones. */
10
+ votesCast: number;
11
+ /** Guardians in the set the release resolved under. */
12
+ guardians: number;
13
+ };
14
+ /**
15
+ * The late-vote window `pending` is in at cluster time `now` (unix seconds), or `null` when it
16
+ * takes no more late votes. While it is open, the program refuses the app's next
17
+ * `write_release_manifest` and `propose_release` with `VoteWindowOpen`. A window is open while
18
+ * `now` is before `quorumTs + config.voteWindow`, the guardian set hasn't changed since the
19
+ * release's round, and some guardian hasn't voted.
20
+ */
21
+ export declare function getLateVoteWindow(pending: ReleaseManifest | null, config: Pick<GuardiansConfig, 'guardians' | 'updateNonce' | 'voteWindow'>, now: bigint): LateVoteWindow | null;
22
+ /** What proposing a version takes next, per {@link getReleaseProposalStep}. */
23
+ export type ReleaseProposalStep =
24
+ /**
25
+ * Write the manifest, then propose it. `written` is the buffer an unfinished upload of the same
26
+ * version and length left, which the writes may build on; `null` when the upload starts fresh.
27
+ */
28
+ {
29
+ kind: 'write';
30
+ written: ReadonlyUint8Array | null;
31
+ }
32
+ /**
33
+ * Cancel the release in the slot first: an older version's unresolved round or unfinished
34
+ * upload, or an unfinished upload of this version with another length. Only the app authority
35
+ * may cancel.
36
+ */
37
+ | {
38
+ kind: 'cancelFirst';
39
+ }
40
+ /** The version is at or below the app's last resolved version, so it can't be proposed. */
41
+ | {
42
+ kind: 'spent';
43
+ }
44
+ /**
45
+ * The version is already proposed, or a newer version holds the slot, as a round or an
46
+ * unfinished upload. The app authority could cancel the newer one, but a proposal never
47
+ * displaces a newer version.
48
+ */
49
+ | {
50
+ kind: 'underReview';
51
+ pendingVersionCode: number;
52
+ }
53
+ /** The last release still takes late votes; propose after the window closes. */
54
+ | {
55
+ kind: 'waitForLateVotes';
56
+ window: LateVoteWindow;
57
+ };
58
+ /**
59
+ * What proposing `versionCode`, with a manifest of `manifestLength` bytes, takes next under `app`
60
+ * (`null` before it is registered). `clock` (the guardian config and cluster time) decides
61
+ * whether a resolved release still holds the slot, and is needed only when the app has one.
62
+ */
63
+ export declare function getReleaseProposalStep(app: Pick<AppAccount, 'lastResolvedVersion' | 'pendingRelease'> | null, versionCode: number, manifestLength: number, clock: {
64
+ config: Pick<GuardiansConfig, 'guardians' | 'updateNonce' | 'voteWindow'>;
65
+ now: bigint;
66
+ } | null): ReleaseProposalStep;
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@solana-mobile/guardian-client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "JavaScript client for the guardian program",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/solana-mobile/guardian-system.git",
9
+ "directory": "clients/js"
10
+ },
11
+ "files": [
12
+ "./dist/src",
13
+ "./dist/types"
14
+ ],
15
+ "type": "commonjs",
16
+ "sideEffects": false,
17
+ "main": "./dist/src/index.js",
18
+ "module": "./dist/src/index.mjs",
19
+ "types": "./dist/types/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/types/index.d.ts",
23
+ "import": "./dist/src/index.mjs",
24
+ "require": "./dist/src/index.js"
25
+ }
26
+ },
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org"
30
+ },
31
+ "dependencies": {
32
+ "@solana/program-client-core": "^8.5.0"
33
+ },
34
+ "devDependencies": {
35
+ "@changesets/cli": "3.0.3",
36
+ "@solana-config/oxc": "^0.1.1",
37
+ "@solana/kit": "^8.5.0",
38
+ "@types/node": "^24",
39
+ "oxfmt": "^0.55.0",
40
+ "oxlint": "^1.70.0",
41
+ "oxlint-tsgolint": "^0.23.0",
42
+ "rimraf": "^5.0.5",
43
+ "tsup": "^8.1.2",
44
+ "typescript": "^5.9.3",
45
+ "vitest": "^4.0.15"
46
+ },
47
+ "peerDependencies": {
48
+ "@solana/kit": "^8.5.0"
49
+ },
50
+ "scripts": {
51
+ "build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
52
+ "dev": "vitest",
53
+ "test": "vitest run",
54
+ "lint": "oxlint",
55
+ "lint:fix": "oxlint --fix",
56
+ "format": "oxfmt --check",
57
+ "format:fix": "oxfmt",
58
+ "changeset:check": "node ./scripts/check-changesets.mjs",
59
+ "publish-packages": "pnpm build && pnpm changeset publish"
60
+ }
6
61
  }