@streamflow/distributor 7.5.3 → 8.0.0-alpha.p287.39c8818

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 (98) hide show
  1. package/dist/cjs/index.cjs +3101 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.cts +10 -0
  4. package/dist/cjs/solana/descriptor/aligned_distributor.cjs +4 -0
  5. package/dist/cjs/solana/descriptor/aligned_distributor.cjs.map +1 -0
  6. package/dist/cjs/solana/descriptor/aligned_distributor.d.cts +932 -0
  7. package/dist/cjs/solana/descriptor/merkle_distributor.cjs +4 -0
  8. package/dist/cjs/solana/descriptor/merkle_distributor.cjs.map +1 -0
  9. package/dist/cjs/solana/descriptor/merkle_distributor.d.cts +1128 -0
  10. package/dist/cjs/solana/index.cjs +3095 -0
  11. package/dist/cjs/solana/index.cjs.map +1 -0
  12. package/dist/cjs/solana/index.d.cts +1486 -0
  13. package/dist/esm/index.d.ts +10 -1
  14. package/dist/esm/index.js +3075 -1
  15. package/dist/esm/index.js.map +1 -0
  16. package/dist/esm/solana/descriptor/aligned_distributor.d.ts +3 -1
  17. package/dist/esm/solana/descriptor/aligned_distributor.js +3 -1
  18. package/dist/esm/solana/descriptor/aligned_distributor.js.map +1 -0
  19. package/dist/esm/solana/descriptor/idl/aligned_distributor.json +851 -1182
  20. package/dist/esm/solana/descriptor/idl/merkle_distributor.json +1030 -0
  21. package/dist/esm/solana/descriptor/merkle_distributor.d.ts +3 -1
  22. package/dist/esm/solana/descriptor/merkle_distributor.js +3 -1
  23. package/dist/esm/solana/descriptor/merkle_distributor.js.map +1 -0
  24. package/dist/esm/solana/index.d.ts +1486 -7
  25. package/dist/esm/solana/index.js +3047 -7
  26. package/dist/esm/solana/index.js.map +1 -0
  27. package/package.json +56 -20
  28. package/dist/cjs/index.js +0 -27
  29. package/dist/cjs/solana/clients/BaseDistributorClient.js +0 -276
  30. package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +0 -116
  31. package/dist/cjs/solana/clients/SolanaDistributorClient.js +0 -17
  32. package/dist/cjs/solana/clients/index.js +0 -10
  33. package/dist/cjs/solana/constants.js +0 -28
  34. package/dist/cjs/solana/descriptor/aligned_distributor.js +0 -2
  35. package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +0 -1255
  36. package/dist/cjs/solana/descriptor/merkle_distributor.js +0 -2
  37. package/dist/cjs/solana/generated/accounts/ClaimStatus.js +0 -135
  38. package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +0 -215
  39. package/dist/cjs/solana/generated/accounts/index.js +0 -7
  40. package/dist/cjs/solana/generated/errors/anchor.js +0 -712
  41. package/dist/cjs/solana/generated/errors/custom.js +0 -321
  42. package/dist/cjs/solana/generated/errors/index.js +0 -64
  43. package/dist/cjs/solana/generated/instructions/claimLocked.js +0 -22
  44. package/dist/cjs/solana/generated/instructions/clawback.js +0 -21
  45. package/dist/cjs/solana/generated/instructions/closeClaim.js +0 -57
  46. package/dist/cjs/solana/generated/instructions/index.js +0 -17
  47. package/dist/cjs/solana/generated/instructions/newClaim.js +0 -59
  48. package/dist/cjs/solana/generated/instructions/newDistributor.js +0 -104
  49. package/dist/cjs/solana/generated/instructions/setAdmin.js +0 -17
  50. package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +0 -17
  51. package/dist/cjs/solana/generated/programId.js +0 -8
  52. package/dist/cjs/solana/index.js +0 -36
  53. package/dist/cjs/solana/types.js +0 -159
  54. package/dist/cjs/solana/utils.js +0 -75
  55. package/dist/esm/solana/clients/BaseDistributorClient.d.ts +0 -43
  56. package/dist/esm/solana/clients/BaseDistributorClient.js +0 -274
  57. package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +0 -16
  58. package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +0 -111
  59. package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +0 -8
  60. package/dist/esm/solana/clients/SolanaDistributorClient.js +0 -11
  61. package/dist/esm/solana/clients/index.d.ts +0 -2
  62. package/dist/esm/solana/clients/index.js +0 -2
  63. package/dist/esm/solana/constants.d.ts +0 -24
  64. package/dist/esm/solana/constants.js +0 -25
  65. package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +0 -83
  66. package/dist/esm/solana/generated/accounts/ClaimStatus.js +0 -127
  67. package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +0 -179
  68. package/dist/esm/solana/generated/accounts/MerkleDistributor.js +0 -239
  69. package/dist/esm/solana/generated/accounts/index.d.ts +0 -4
  70. package/dist/esm/solana/generated/accounts/index.js +0 -2
  71. package/dist/esm/solana/generated/errors/anchor.d.ts +0 -434
  72. package/dist/esm/solana/generated/errors/anchor.js +0 -707
  73. package/dist/esm/solana/generated/errors/custom.d.ts +0 -194
  74. package/dist/esm/solana/generated/errors/custom.js +0 -317
  75. package/dist/esm/solana/generated/errors/index.d.ts +0 -5
  76. package/dist/esm/solana/generated/errors/index.js +0 -37
  77. package/dist/esm/solana/generated/instructions/claimLocked.d.ts +0 -23
  78. package/dist/esm/solana/generated/instructions/claimLocked.js +0 -19
  79. package/dist/esm/solana/generated/instructions/clawback.d.ts +0 -17
  80. package/dist/esm/solana/generated/instructions/clawback.js +0 -18
  81. package/dist/esm/solana/generated/instructions/closeClaim.d.ts +0 -22
  82. package/dist/esm/solana/generated/instructions/closeClaim.js +0 -30
  83. package/dist/esm/solana/generated/instructions/index.d.ts +0 -14
  84. package/dist/esm/solana/generated/instructions/index.js +0 -7
  85. package/dist/esm/solana/generated/instructions/newClaim.d.ts +0 -29
  86. package/dist/esm/solana/generated/instructions/newClaim.js +0 -32
  87. package/dist/esm/solana/generated/instructions/newDistributor.d.ts +0 -58
  88. package/dist/esm/solana/generated/instructions/newDistributor.js +0 -77
  89. package/dist/esm/solana/generated/instructions/setAdmin.d.ts +0 -10
  90. package/dist/esm/solana/generated/instructions/setAdmin.js +0 -14
  91. package/dist/esm/solana/generated/instructions/setClawbackReceiver.d.ts +0 -10
  92. package/dist/esm/solana/generated/instructions/setClawbackReceiver.js +0 -14
  93. package/dist/esm/solana/generated/programId.d.ts +0 -3
  94. package/dist/esm/solana/generated/programId.js +0 -5
  95. package/dist/esm/solana/types.d.ts +0 -258
  96. package/dist/esm/solana/types.js +0 -156
  97. package/dist/esm/solana/utils.d.ts +0 -14
  98. package/dist/esm/solana/utils.js +0 -65
@@ -0,0 +1,3101 @@
1
+ 'use strict';
2
+
3
+ var web3_js = require('@solana/web3.js');
4
+ require('@solana/wallet-adapter-base');
5
+ var common = require('@streamflow/common');
6
+ var solana = require('@streamflow/common/solana');
7
+ var anchor = require('@coral-xyz/anchor');
8
+ var borsh8 = require('@coral-xyz/borsh');
9
+ var buffer = require('buffer');
10
+ var BN6 = require('bn.js');
11
+ var splToken = require('@solana/spl-token');
12
+ var bs58 = require('bs58');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
+
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule) return e;
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n.default = e;
31
+ return Object.freeze(n);
32
+ }
33
+
34
+ var borsh8__namespace = /*#__PURE__*/_interopNamespace(borsh8);
35
+ var BN6__default = /*#__PURE__*/_interopDefault(BN6);
36
+ var bs58__default = /*#__PURE__*/_interopDefault(bs58);
37
+
38
+ var __defProp = Object.defineProperty;
39
+ var __export = (target, all) => {
40
+ for (var name in all)
41
+ __defProp(target, name, { get: all[name], enumerable: true });
42
+ };
43
+
44
+ // solana/index.ts
45
+ var solana_exports = {};
46
+ __export(solana_exports, {
47
+ AnchorErrorCode: () => AnchorErrorCode,
48
+ ClaimStatus: () => ClaimStatus,
49
+ ContractErrorCode: () => ContractErrorCode,
50
+ MerkleDistributor: () => MerkleDistributor,
51
+ SolanaAlignedDistributorClient: () => SolanaAlignedDistributorClient,
52
+ SolanaDistributorClient: () => SolanaDistributorClient,
53
+ calculateAmountWithTransferFees: () => calculateAmountWithTransferFees,
54
+ claimLocked: () => claimLocked,
55
+ clawback: () => clawback,
56
+ closeClaim: () => closeClaim,
57
+ constants: () => constants_exports,
58
+ fromCode: () => fromCode3,
59
+ fromTxError: () => fromTxError,
60
+ getAlignedDistributorPda: () => getAlignedDistributorPda,
61
+ getClaimantStatusPda: () => getClaimantStatusPda,
62
+ getDistributorPda: () => getDistributorPda,
63
+ getEventAuthorityPda: () => getEventAuthorityPda,
64
+ getTestOraclePda: () => getTestOraclePda,
65
+ newClaim: () => newClaim,
66
+ newDistributor: () => newDistributor,
67
+ setAdmin: () => setAdmin,
68
+ setClawbackReceiver: () => setClawbackReceiver,
69
+ wrappedSignAndExecuteTransaction: () => wrappedSignAndExecuteTransaction
70
+ });
71
+ var AnchorErrorCode = /* @__PURE__ */ ((AnchorErrorCode2) => {
72
+ AnchorErrorCode2["InstructionMissing"] = "InstructionMissing";
73
+ AnchorErrorCode2["InstructionFallbackNotFound"] = "InstructionFallbackNotFound";
74
+ AnchorErrorCode2["InstructionDidNotDeserialize"] = "InstructionDidNotDeserialize";
75
+ AnchorErrorCode2["InstructionDidNotSerialize"] = "InstructionDidNotSerialize";
76
+ AnchorErrorCode2["IdlInstructionStub"] = "IdlInstructionStub";
77
+ AnchorErrorCode2["IdlInstructionInvalidProgram"] = "IdlInstructionInvalidProgram";
78
+ AnchorErrorCode2["ConstraintMut"] = "ConstraintMut";
79
+ AnchorErrorCode2["ConstraintHasOne"] = "ConstraintHasOne";
80
+ AnchorErrorCode2["ConstraintSigner"] = "ConstraintSigner";
81
+ AnchorErrorCode2["ConstraintRaw"] = "ConstraintRaw";
82
+ AnchorErrorCode2["ConstraintOwner"] = "ConstraintOwner";
83
+ AnchorErrorCode2["ConstraintRentExempt"] = "ConstraintRentExempt";
84
+ AnchorErrorCode2["ConstraintSeeds"] = "ConstraintSeeds";
85
+ AnchorErrorCode2["ConstraintExecutable"] = "ConstraintExecutable";
86
+ AnchorErrorCode2["ConstraintState"] = "ConstraintState";
87
+ AnchorErrorCode2["ConstraintAssociated"] = "ConstraintAssociated";
88
+ AnchorErrorCode2["ConstraintAssociatedInit"] = "ConstraintAssociatedInit";
89
+ AnchorErrorCode2["ConstraintClose"] = "ConstraintClose";
90
+ AnchorErrorCode2["ConstraintAddress"] = "ConstraintAddress";
91
+ AnchorErrorCode2["ConstraintZero"] = "ConstraintZero";
92
+ AnchorErrorCode2["ConstraintTokenMint"] = "ConstraintTokenMint";
93
+ AnchorErrorCode2["ConstraintTokenOwner"] = "ConstraintTokenOwner";
94
+ AnchorErrorCode2["ConstraintMintMintAuthority"] = "ConstraintMintMintAuthority";
95
+ AnchorErrorCode2["ConstraintMintFreezeAuthority"] = "ConstraintMintFreezeAuthority";
96
+ AnchorErrorCode2["ConstraintMintDecimals"] = "ConstraintMintDecimals";
97
+ AnchorErrorCode2["ConstraintSpace"] = "ConstraintSpace";
98
+ AnchorErrorCode2["ConstraintAccountIsNone"] = "ConstraintAccountIsNone";
99
+ AnchorErrorCode2["RequireViolated"] = "RequireViolated";
100
+ AnchorErrorCode2["RequireEqViolated"] = "RequireEqViolated";
101
+ AnchorErrorCode2["RequireKeysEqViolated"] = "RequireKeysEqViolated";
102
+ AnchorErrorCode2["RequireNeqViolated"] = "RequireNeqViolated";
103
+ AnchorErrorCode2["RequireKeysNeqViolated"] = "RequireKeysNeqViolated";
104
+ AnchorErrorCode2["RequireGtViolated"] = "RequireGtViolated";
105
+ AnchorErrorCode2["RequireGteViolated"] = "RequireGteViolated";
106
+ AnchorErrorCode2["AccountDiscriminatorAlreadySet"] = "AccountDiscriminatorAlreadySet";
107
+ AnchorErrorCode2["AccountDiscriminatorNotFound"] = "AccountDiscriminatorNotFound";
108
+ AnchorErrorCode2["AccountDiscriminatorMismatch"] = "AccountDiscriminatorMismatch";
109
+ AnchorErrorCode2["AccountDidNotDeserialize"] = "AccountDidNotDeserialize";
110
+ AnchorErrorCode2["AccountDidNotSerialize"] = "AccountDidNotSerialize";
111
+ AnchorErrorCode2["AccountNotEnoughKeys"] = "AccountNotEnoughKeys";
112
+ AnchorErrorCode2["AccountNotMutable"] = "AccountNotMutable";
113
+ AnchorErrorCode2["AccountOwnedByWrongProgram"] = "AccountOwnedByWrongProgram";
114
+ AnchorErrorCode2["InvalidProgramId"] = "InvalidProgramId";
115
+ AnchorErrorCode2["InvalidProgramExecutable"] = "InvalidProgramExecutable";
116
+ AnchorErrorCode2["AccountNotSigner"] = "AccountNotSigner";
117
+ AnchorErrorCode2["AccountNotSystemOwned"] = "AccountNotSystemOwned";
118
+ AnchorErrorCode2["AccountNotInitialized"] = "AccountNotInitialized";
119
+ AnchorErrorCode2["AccountNotProgramData"] = "AccountNotProgramData";
120
+ AnchorErrorCode2["AccountNotAssociatedTokenAccount"] = "AccountNotAssociatedTokenAccount";
121
+ AnchorErrorCode2["AccountSysvarMismatch"] = "AccountSysvarMismatch";
122
+ AnchorErrorCode2["AccountReallocExceedsLimit"] = "AccountReallocExceedsLimit";
123
+ AnchorErrorCode2["AccountDuplicateReallocs"] = "AccountDuplicateReallocs";
124
+ AnchorErrorCode2["DeclaredProgramIdMismatch"] = "DeclaredProgramIdMismatch";
125
+ AnchorErrorCode2["Deprecated"] = "Deprecated";
126
+ return AnchorErrorCode2;
127
+ })(AnchorErrorCode || {});
128
+ var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
129
+ ContractErrorCode2["InsufficientUnlockedTokens"] = "InsufficientUnlockedTokens";
130
+ ContractErrorCode2["StartTooFarInFuture"] = "StartTooFarInFuture";
131
+ ContractErrorCode2["InvalidProof"] = "InvalidProof";
132
+ ContractErrorCode2["ExceededMaxClaim"] = "ExceededMaxClaim";
133
+ ContractErrorCode2["MaxNodesExceeded"] = "MaxNodesExceeded";
134
+ ContractErrorCode2["Unauthorized"] = "Unauthorized";
135
+ ContractErrorCode2["OwnerMismatch"] = "OwnerMismatch";
136
+ ContractErrorCode2["ClawbackBeforeVesting"] = "ClawbackBeforeVesting";
137
+ ContractErrorCode2["ClawbackBeforeStart"] = "ClawbackBeforeStart";
138
+ ContractErrorCode2["ClawbackAlreadyClaimed"] = "ClawbackAlreadyClaimed";
139
+ ContractErrorCode2["InsufficientClawbackDelay"] = "InsufficientClawbackDelay";
140
+ ContractErrorCode2["SameClawbackReceiver"] = "SameClawbackReceiver";
141
+ ContractErrorCode2["SameAdmin"] = "SameAdmin";
142
+ ContractErrorCode2["ClaimExpired"] = "ClaimExpired";
143
+ ContractErrorCode2["ArithmeticError"] = "ArithmeticError";
144
+ ContractErrorCode2["StartTimestampAfterEnd"] = "StartTimestampAfterEnd";
145
+ ContractErrorCode2["TimestampsNotInFuture"] = "TimestampsNotInFuture";
146
+ ContractErrorCode2["InvalidVersion"] = "InvalidVersion";
147
+ ContractErrorCode2["InvalidMint"] = "InvalidMint";
148
+ ContractErrorCode2["ClaimIsClosed"] = "ClaimIsClosed";
149
+ ContractErrorCode2["ClaimsAreNotClosable"] = "ClaimsAreNotClosable";
150
+ return ContractErrorCode2;
151
+ })(ContractErrorCode || {});
152
+ var PROGRAM_ID_CLI = new web3_js.PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N");
153
+ var PROGRAM_ID = PROGRAM_ID_CLI;
154
+
155
+ // solana/generated/instructions/newDistributor.ts
156
+ var layout = borsh8__namespace.struct([
157
+ borsh8__namespace.u64("version"),
158
+ borsh8__namespace.array(borsh8__namespace.u8(), 32, "root"),
159
+ borsh8__namespace.u64("maxTotalClaim"),
160
+ borsh8__namespace.u64("maxNumNodes"),
161
+ borsh8__namespace.u64("unlockPeriod"),
162
+ borsh8__namespace.u64("startVestingTs"),
163
+ borsh8__namespace.u64("endVestingTs"),
164
+ borsh8__namespace.u64("clawbackStartTs"),
165
+ borsh8__namespace.bool("claimsClosableByAdmin"),
166
+ borsh8__namespace.option(borsh8__namespace.bool(), "canUpdateDuration"),
167
+ borsh8__namespace.option(borsh8__namespace.u64(), "totalAmountUnlocked"),
168
+ borsh8__namespace.option(borsh8__namespace.u64(), "totalAmountLocked"),
169
+ borsh8__namespace.option(borsh8__namespace.bool(), "claimsClosableByClaimant"),
170
+ borsh8__namespace.option(borsh8__namespace.u16(), "claimsLimit")
171
+ ]);
172
+ function newDistributor(args, accounts, programId = PROGRAM_ID) {
173
+ const keys = [
174
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
175
+ { pubkey: accounts.clawbackReceiver, isSigner: false, isWritable: true },
176
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
177
+ { pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
178
+ { pubkey: accounts.admin, isSigner: true, isWritable: true },
179
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
180
+ {
181
+ pubkey: accounts.associatedTokenProgram,
182
+ isSigner: false,
183
+ isWritable: false
184
+ },
185
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
186
+ ];
187
+ const identifier = buffer.Buffer.from([32, 139, 112, 171, 0, 2, 225, 155]);
188
+ const buffer$1 = buffer.Buffer.alloc(1e3);
189
+ const len = layout.encode(
190
+ {
191
+ version: args.version,
192
+ root: args.root,
193
+ maxTotalClaim: args.maxTotalClaim,
194
+ maxNumNodes: args.maxNumNodes,
195
+ unlockPeriod: args.unlockPeriod,
196
+ startVestingTs: args.startVestingTs,
197
+ endVestingTs: args.endVestingTs,
198
+ clawbackStartTs: args.clawbackStartTs,
199
+ claimsClosableByAdmin: args.claimsClosableByAdmin,
200
+ canUpdateDuration: null,
201
+ totalAmountUnlocked: null,
202
+ totalAmountLocked: null,
203
+ claimsClosableByClaimant: args.claimsClosableByClaimant ?? null,
204
+ claimsLimit: args.claimsLimit ?? null
205
+ },
206
+ buffer$1
207
+ );
208
+ const data = buffer.Buffer.concat([identifier, buffer$1]).slice(0, 8 + len);
209
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
210
+ return ix;
211
+ }
212
+ var layout2 = borsh8__namespace.struct([
213
+ borsh8__namespace.u64("amountUnlocked"),
214
+ borsh8__namespace.u64("amountLocked"),
215
+ borsh8__namespace.vec(borsh8__namespace.array(borsh8__namespace.u8(), 32), "proof")
216
+ ]);
217
+ function newClaim(args, accounts, programId = PROGRAM_ID) {
218
+ const keys = [
219
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
220
+ { pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
221
+ { pubkey: accounts.from, isSigner: false, isWritable: true },
222
+ { pubkey: accounts.to, isSigner: false, isWritable: true },
223
+ { pubkey: accounts.claimant, isSigner: true, isWritable: true },
224
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
225
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
226
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
227
+ { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
228
+ { pubkey: accounts.program, isSigner: false, isWritable: false }
229
+ ];
230
+ const identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
231
+ const buffer = Buffer.alloc(1e3);
232
+ const len = layout2.encode(
233
+ {
234
+ amountUnlocked: args.amountUnlocked,
235
+ amountLocked: args.amountLocked,
236
+ proof: args.proof
237
+ },
238
+ buffer
239
+ );
240
+ const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
241
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
242
+ return ix;
243
+ }
244
+ function claimLocked(accounts, programId = PROGRAM_ID) {
245
+ const keys = [
246
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
247
+ { pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
248
+ { pubkey: accounts.from, isSigner: false, isWritable: true },
249
+ { pubkey: accounts.to, isSigner: false, isWritable: true },
250
+ { pubkey: accounts.claimant, isSigner: true, isWritable: true },
251
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
252
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
253
+ { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
254
+ { pubkey: accounts.program, isSigner: false, isWritable: false }
255
+ ];
256
+ const identifier = Buffer.from([34, 206, 181, 23, 11, 207, 147, 90]);
257
+ const data = identifier;
258
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
259
+ return ix;
260
+ }
261
+ function clawback(accounts, programId = PROGRAM_ID) {
262
+ const keys = [
263
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
264
+ { pubkey: accounts.from, isSigner: false, isWritable: true },
265
+ { pubkey: accounts.to, isSigner: false, isWritable: true },
266
+ { pubkey: accounts.admin, isSigner: true, isWritable: true },
267
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
268
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
269
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false }
270
+ ];
271
+ const identifier = buffer.Buffer.from([111, 92, 142, 79, 33, 234, 82, 27]);
272
+ const data = identifier;
273
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
274
+ return ix;
275
+ }
276
+ var layout3 = borsh8__namespace.struct([
277
+ borsh8__namespace.option(borsh8__namespace.u64(), "amountUnlocked"),
278
+ borsh8__namespace.option(borsh8__namespace.u64(), "amountLocked"),
279
+ borsh8__namespace.option(borsh8__namespace.vec(borsh8__namespace.array(borsh8__namespace.u8(), 32)), "proof")
280
+ ]);
281
+ function closeClaim(args, accounts, programId = PROGRAM_ID) {
282
+ const keys = [
283
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
284
+ { pubkey: accounts.adminOrClaimant, isSigner: true, isWritable: true },
285
+ { pubkey: accounts.claimant, isSigner: false, isWritable: false },
286
+ { pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
287
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
288
+ { pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
289
+ { pubkey: accounts.program, isSigner: false, isWritable: false }
290
+ ];
291
+ const identifier = buffer.Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
292
+ const buffer$1 = buffer.Buffer.alloc(1e3);
293
+ const len = layout3.encode(
294
+ {
295
+ amountUnlocked: args.amountUnlocked ?? null,
296
+ amountLocked: args.amountLocked ?? null,
297
+ proof: args.proof ?? null
298
+ },
299
+ buffer$1
300
+ );
301
+ const data = buffer.Buffer.concat([identifier, buffer$1]).slice(0, 8 + len);
302
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
303
+ return ix;
304
+ }
305
+ function setClawbackReceiver(accounts, programId = PROGRAM_ID) {
306
+ const keys = [
307
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
308
+ { pubkey: accounts.newClawbackAccount, isSigner: false, isWritable: false },
309
+ { pubkey: accounts.admin, isSigner: true, isWritable: true }
310
+ ];
311
+ const identifier = buffer.Buffer.from([153, 217, 34, 20, 19, 29, 229, 75]);
312
+ const data = identifier;
313
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
314
+ return ix;
315
+ }
316
+ function setAdmin(accounts, programId = PROGRAM_ID) {
317
+ const keys = [
318
+ { pubkey: accounts.distributor, isSigner: false, isWritable: true },
319
+ { pubkey: accounts.admin, isSigner: true, isWritable: true },
320
+ { pubkey: accounts.newAdmin, isSigner: false, isWritable: true }
321
+ ];
322
+ const identifier = buffer.Buffer.from([251, 163, 0, 52, 91, 194, 187, 92]);
323
+ const data = identifier;
324
+ const ix = new web3_js.TransactionInstruction({ keys, programId, data });
325
+ return ix;
326
+ }
327
+
328
+ // solana/constants.ts
329
+ var constants_exports = {};
330
+ __export(constants_exports, {
331
+ AIRDROP_CLAIM_FEE: () => AIRDROP_CLAIM_FEE,
332
+ ALIGNED_DISTRIBUTOR_PREFIX: () => ALIGNED_DISTRIBUTOR_PREFIX,
333
+ ALIGNED_DISTRIBUTOR_PROGRAM_ID: () => ALIGNED_DISTRIBUTOR_PROGRAM_ID,
334
+ ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
335
+ ANCHOR_DISCRIMINATOR_OFFSET: () => ANCHOR_DISCRIMINATOR_OFFSET,
336
+ CLAIM_STATUS_PREFIX: () => CLAIM_STATUS_PREFIX,
337
+ DISTRIBUTOR_ADMIN_OFFSET: () => DISTRIBUTOR_ADMIN_OFFSET,
338
+ DISTRIBUTOR_MINT_OFFSET: () => DISTRIBUTOR_MINT_OFFSET,
339
+ DISTRIBUTOR_PREFIX: () => DISTRIBUTOR_PREFIX,
340
+ DISTRIBUTOR_PROGRAM_ID: () => DISTRIBUTOR_PROGRAM_ID,
341
+ ONE_IN_BASIS_POINTS: () => ONE_IN_BASIS_POINTS,
342
+ STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
343
+ TEST_ORACLE_PREFIX: () => TEST_ORACLE_PREFIX
344
+ });
345
+ var ANCHOR_DISCRIMINATOR_OFFSET = 8;
346
+ var DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
347
+ var DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
348
+ var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
349
+ var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
350
+ var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
351
+ var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
352
+ var ALIGNED_PRECISION_FACTOR_POW = 9;
353
+ var AIRDROP_CLAIM_FEE = BigInt(52e5);
354
+ var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
355
+ var ONE_IN_BASIS_POINTS = BigInt(1e4);
356
+ var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
357
+ [common.ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
358
+ [common.ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
359
+ [common.ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
360
+ [common.ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2"
361
+ };
362
+ var DISTRIBUTOR_PROGRAM_ID = {
363
+ [common.ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
364
+ [common.ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
365
+ [common.ICluster.Testnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
366
+ [common.ICluster.Local]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
367
+ };
368
+ var _ClaimStatus = class _ClaimStatus {
369
+ constructor(fields) {
370
+ this.claimant = fields.claimant;
371
+ this.lockedAmount = fields.lockedAmount;
372
+ this.lockedAmountWithdrawn = fields.lockedAmountWithdrawn;
373
+ this.unlockedAmount = fields.unlockedAmount;
374
+ this.lastClaimTs = fields.lastClaimTs;
375
+ this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
376
+ this.closed = fields.closed;
377
+ this.distributor = fields.distributor;
378
+ this.claimsCount = fields.claimsCount;
379
+ this.closedTs = fields.closedTs;
380
+ this.buffer2 = fields.buffer2;
381
+ }
382
+ static async fetch(c, address, programId = PROGRAM_ID) {
383
+ const info = await c.getAccountInfo(address);
384
+ if (info === null) {
385
+ return null;
386
+ }
387
+ if (!info.owner.equals(programId)) {
388
+ throw new Error("account doesn't belong to this program");
389
+ }
390
+ return this.decode(info.data);
391
+ }
392
+ static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
393
+ const infos = await c.getMultipleAccountsInfo(addresses);
394
+ return infos.map((info) => {
395
+ if (info === null) {
396
+ return null;
397
+ }
398
+ if (!info.owner.equals(programId)) {
399
+ throw new Error("account doesn't belong to this program");
400
+ }
401
+ return this.decode(info.data);
402
+ });
403
+ }
404
+ static decode(data) {
405
+ if (!data.slice(0, 8).equals(_ClaimStatus.discriminator)) {
406
+ throw new Error("invalid account discriminator");
407
+ }
408
+ const dec = _ClaimStatus.layout.decode(data.slice(8));
409
+ return new _ClaimStatus({
410
+ claimant: dec.claimant,
411
+ lockedAmount: dec.lockedAmount,
412
+ lockedAmountWithdrawn: dec.lockedAmountWithdrawn,
413
+ unlockedAmount: dec.unlockedAmount,
414
+ lastClaimTs: dec.lastClaimTs,
415
+ lastAmountPerUnlock: dec.lastAmountPerUnlock,
416
+ closed: dec.closed,
417
+ distributor: dec.distributor,
418
+ claimsCount: dec.claimsCount,
419
+ closedTs: dec.closedTs,
420
+ buffer2: dec.buffer2
421
+ });
422
+ }
423
+ toJSON() {
424
+ return {
425
+ claimant: this.claimant.toString(),
426
+ lockedAmount: this.lockedAmount.toString(),
427
+ lockedAmountWithdrawn: this.lockedAmountWithdrawn.toString(),
428
+ unlockedAmount: this.unlockedAmount.toString(),
429
+ lastClaimTs: this.lastClaimTs.toString(),
430
+ lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
431
+ closed: this.closed,
432
+ distributor: this.distributor.toString(),
433
+ claimsCount: this.claimsCount,
434
+ closedTs: this.closedTs.toString(),
435
+ buffer2: this.buffer2
436
+ };
437
+ }
438
+ static fromJSON(obj) {
439
+ return new _ClaimStatus({
440
+ claimant: new web3_js.PublicKey(obj.claimant),
441
+ lockedAmount: new BN6__default.default(obj.lockedAmount),
442
+ lockedAmountWithdrawn: new BN6__default.default(obj.lockedAmountWithdrawn),
443
+ unlockedAmount: new BN6__default.default(obj.unlockedAmount),
444
+ lastClaimTs: new BN6__default.default(obj.lastClaimTs),
445
+ lastAmountPerUnlock: new BN6__default.default(obj.lastAmountPerUnlock),
446
+ closed: obj.closed,
447
+ distributor: new web3_js.PublicKey(obj.distributor),
448
+ claimsCount: obj.claimsCount,
449
+ closedTs: new BN6__default.default(obj.closedTs),
450
+ buffer2: obj.buffer2
451
+ });
452
+ }
453
+ };
454
+ _ClaimStatus.discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
455
+ _ClaimStatus.layout = borsh8__namespace.struct([
456
+ borsh8__namespace.publicKey("claimant"),
457
+ borsh8__namespace.u64("lockedAmount"),
458
+ borsh8__namespace.u64("lockedAmountWithdrawn"),
459
+ borsh8__namespace.u64("unlockedAmount"),
460
+ borsh8__namespace.u64("lastClaimTs"),
461
+ borsh8__namespace.u64("lastAmountPerUnlock"),
462
+ borsh8__namespace.bool("closed"),
463
+ borsh8__namespace.publicKey("distributor"),
464
+ borsh8__namespace.u16("claimsCount"),
465
+ borsh8__namespace.u64("closedTs"),
466
+ borsh8__namespace.array(borsh8__namespace.u8(), 22, "buffer2")
467
+ ]);
468
+ var ClaimStatus = _ClaimStatus;
469
+ var _MerkleDistributor = class _MerkleDistributor {
470
+ constructor(fields) {
471
+ this.bump = fields.bump;
472
+ this.version = fields.version;
473
+ this.root = fields.root;
474
+ this.mint = fields.mint;
475
+ this.tokenVault = fields.tokenVault;
476
+ this.maxTotalClaim = fields.maxTotalClaim;
477
+ this.maxNumNodes = fields.maxNumNodes;
478
+ this.unlockPeriod = fields.unlockPeriod;
479
+ this.totalAmountClaimed = fields.totalAmountClaimed;
480
+ this.numNodesClaimed = fields.numNodesClaimed;
481
+ this.startTs = fields.startTs;
482
+ this.endTs = fields.endTs;
483
+ this.clawbackStartTs = fields.clawbackStartTs;
484
+ this.clawbackReceiver = fields.clawbackReceiver;
485
+ this.admin = fields.admin;
486
+ this.clawedBack = fields.clawedBack;
487
+ this.claimsClosableByAdmin = fields.claimsClosableByAdmin;
488
+ this.canUpdateDuration = fields.canUpdateDuration;
489
+ this.totalAmountUnlocked = fields.totalAmountUnlocked;
490
+ this.totalAmountLocked = fields.totalAmountLocked;
491
+ this.lastDurationUpdateTs = fields.lastDurationUpdateTs;
492
+ this.totalClaimablePreUpdate = fields.totalClaimablePreUpdate;
493
+ this.clawedBackTs = fields.clawedBackTs;
494
+ this.claimsClosableByClaimant = fields.claimsClosableByClaimant;
495
+ this.claimsLimit = fields.claimsLimit;
496
+ this.buffer2 = fields.buffer2;
497
+ this.buffer3 = fields.buffer3;
498
+ }
499
+ static async fetch(c, address, programId = PROGRAM_ID) {
500
+ const info = await c.getAccountInfo(address);
501
+ if (info === null) {
502
+ return null;
503
+ }
504
+ if (!info.owner.equals(programId)) {
505
+ throw new Error("account doesn't belong to this program");
506
+ }
507
+ return this.decode(info.data);
508
+ }
509
+ static async fetchMultiple(c, addresses, programId = PROGRAM_ID) {
510
+ const infos = await c.getMultipleAccountsInfo(addresses);
511
+ return infos.map((info) => {
512
+ if (info === null) {
513
+ return null;
514
+ }
515
+ if (!info.owner.equals(programId)) {
516
+ throw new Error("account doesn't belong to this program");
517
+ }
518
+ return this.decode(info.data);
519
+ });
520
+ }
521
+ static decode(data) {
522
+ if (!data.slice(0, 8).equals(_MerkleDistributor.discriminator)) {
523
+ throw new Error("invalid account discriminator");
524
+ }
525
+ const dec = _MerkleDistributor.layout.decode(data.slice(8));
526
+ return new _MerkleDistributor({
527
+ bump: dec.bump,
528
+ version: dec.version,
529
+ root: dec.root,
530
+ mint: dec.mint,
531
+ tokenVault: dec.tokenVault,
532
+ maxTotalClaim: dec.maxTotalClaim,
533
+ maxNumNodes: dec.maxNumNodes,
534
+ unlockPeriod: dec.unlockPeriod,
535
+ totalAmountClaimed: dec.totalAmountClaimed,
536
+ numNodesClaimed: dec.numNodesClaimed,
537
+ startTs: dec.startTs,
538
+ endTs: dec.endTs,
539
+ clawbackStartTs: dec.clawbackStartTs,
540
+ clawbackReceiver: dec.clawbackReceiver,
541
+ admin: dec.admin,
542
+ clawedBack: dec.clawedBack,
543
+ claimsClosableByAdmin: dec.claimsClosableByAdmin,
544
+ canUpdateDuration: dec.canUpdateDuration,
545
+ totalAmountUnlocked: dec.totalAmountUnlocked,
546
+ totalAmountLocked: dec.totalAmountLocked,
547
+ lastDurationUpdateTs: dec.lastDurationUpdateTs,
548
+ totalClaimablePreUpdate: dec.totalClaimablePreUpdate,
549
+ clawedBackTs: dec.clawedBackTs,
550
+ claimsClosableByClaimant: dec.claimsClosableByClaimant,
551
+ claimsLimit: dec.claimsLimit,
552
+ buffer2: dec.buffer2,
553
+ buffer3: dec.buffer3
554
+ });
555
+ }
556
+ toJSON() {
557
+ return {
558
+ bump: this.bump,
559
+ version: this.version.toString(),
560
+ root: this.root,
561
+ mint: this.mint.toString(),
562
+ tokenVault: this.tokenVault.toString(),
563
+ maxTotalClaim: this.maxTotalClaim.toString(),
564
+ maxNumNodes: this.maxNumNodes.toString(),
565
+ unlockPeriod: this.unlockPeriod.toString(),
566
+ totalAmountClaimed: this.totalAmountClaimed.toString(),
567
+ numNodesClaimed: this.numNodesClaimed.toString(),
568
+ startTs: this.startTs.toString(),
569
+ endTs: this.endTs.toString(),
570
+ clawbackStartTs: this.clawbackStartTs.toString(),
571
+ clawbackReceiver: this.clawbackReceiver.toString(),
572
+ admin: this.admin.toString(),
573
+ clawedBack: this.clawedBack,
574
+ claimsClosableByAdmin: this.claimsClosableByAdmin,
575
+ canUpdateDuration: this.canUpdateDuration,
576
+ totalAmountUnlocked: this.totalAmountUnlocked.toString(),
577
+ totalAmountLocked: this.totalAmountLocked.toString(),
578
+ lastDurationUpdateTs: this.lastDurationUpdateTs.toString(),
579
+ totalClaimablePreUpdate: this.totalClaimablePreUpdate.toString(),
580
+ clawedBackTs: this.clawedBackTs.toString(),
581
+ claimsClosableByClaimant: this.claimsClosableByClaimant,
582
+ claimsLimit: this.claimsLimit,
583
+ buffer2: this.buffer2,
584
+ buffer3: this.buffer3
585
+ };
586
+ }
587
+ static fromJSON(obj) {
588
+ return new _MerkleDistributor({
589
+ bump: obj.bump,
590
+ version: new BN6__default.default(obj.version),
591
+ root: obj.root,
592
+ mint: new web3_js.PublicKey(obj.mint),
593
+ tokenVault: new web3_js.PublicKey(obj.tokenVault),
594
+ maxTotalClaim: new BN6__default.default(obj.maxTotalClaim),
595
+ maxNumNodes: new BN6__default.default(obj.maxNumNodes),
596
+ unlockPeriod: new BN6__default.default(obj.unlockPeriod),
597
+ totalAmountClaimed: new BN6__default.default(obj.totalAmountClaimed),
598
+ numNodesClaimed: new BN6__default.default(obj.numNodesClaimed),
599
+ startTs: new BN6__default.default(obj.startTs),
600
+ endTs: new BN6__default.default(obj.endTs),
601
+ clawbackStartTs: new BN6__default.default(obj.clawbackStartTs),
602
+ clawbackReceiver: new web3_js.PublicKey(obj.clawbackReceiver),
603
+ admin: new web3_js.PublicKey(obj.admin),
604
+ clawedBack: obj.clawedBack,
605
+ claimsClosableByAdmin: obj.claimsClosableByAdmin,
606
+ canUpdateDuration: obj.canUpdateDuration,
607
+ totalAmountUnlocked: new BN6__default.default(obj.totalAmountUnlocked),
608
+ totalAmountLocked: new BN6__default.default(obj.totalAmountLocked),
609
+ lastDurationUpdateTs: new BN6__default.default(obj.lastDurationUpdateTs),
610
+ totalClaimablePreUpdate: new BN6__default.default(obj.totalClaimablePreUpdate),
611
+ clawedBackTs: new BN6__default.default(obj.clawedBackTs),
612
+ claimsClosableByClaimant: obj.claimsClosableByClaimant,
613
+ claimsLimit: obj.claimsLimit,
614
+ buffer2: obj.buffer2,
615
+ buffer3: obj.buffer3
616
+ });
617
+ }
618
+ };
619
+ _MerkleDistributor.discriminator = Buffer.from([77, 119, 139, 70, 84, 247, 12, 26]);
620
+ _MerkleDistributor.layout = borsh8__namespace.struct([
621
+ borsh8__namespace.u8("bump"),
622
+ borsh8__namespace.u64("version"),
623
+ borsh8__namespace.array(borsh8__namespace.u8(), 32, "root"),
624
+ borsh8__namespace.publicKey("mint"),
625
+ borsh8__namespace.publicKey("tokenVault"),
626
+ borsh8__namespace.u64("maxTotalClaim"),
627
+ borsh8__namespace.u64("maxNumNodes"),
628
+ borsh8__namespace.u64("unlockPeriod"),
629
+ borsh8__namespace.u64("totalAmountClaimed"),
630
+ borsh8__namespace.u64("numNodesClaimed"),
631
+ borsh8__namespace.u64("startTs"),
632
+ borsh8__namespace.u64("endTs"),
633
+ borsh8__namespace.u64("clawbackStartTs"),
634
+ borsh8__namespace.publicKey("clawbackReceiver"),
635
+ borsh8__namespace.publicKey("admin"),
636
+ borsh8__namespace.bool("clawedBack"),
637
+ borsh8__namespace.bool("claimsClosableByAdmin"),
638
+ borsh8__namespace.bool("canUpdateDuration"),
639
+ borsh8__namespace.u64("totalAmountUnlocked"),
640
+ borsh8__namespace.u64("totalAmountLocked"),
641
+ borsh8__namespace.u64("lastDurationUpdateTs"),
642
+ borsh8__namespace.u64("totalClaimablePreUpdate"),
643
+ borsh8__namespace.u64("clawedBackTs"),
644
+ borsh8__namespace.bool("claimsClosableByClaimant"),
645
+ borsh8__namespace.u16("claimsLimit"),
646
+ borsh8__namespace.array(borsh8__namespace.u8(), 20, "buffer2"),
647
+ borsh8__namespace.array(borsh8__namespace.u8(), 32, "buffer3")
648
+ ]);
649
+ var MerkleDistributor = _MerkleDistributor;
650
+
651
+ // solana/generated/errors/anchor.ts
652
+ var InstructionMissing = class extends Error {
653
+ constructor(logs) {
654
+ super("100: 8 byte instruction identifier not provided");
655
+ this.logs = logs;
656
+ this.code = 100;
657
+ this.name = "InstructionMissing";
658
+ this.msg = "8 byte instruction identifier not provided";
659
+ }
660
+ };
661
+ InstructionMissing.code = 100;
662
+ var InstructionFallbackNotFound = class extends Error {
663
+ constructor(logs) {
664
+ super("101: Fallback functions are not supported");
665
+ this.logs = logs;
666
+ this.code = 101;
667
+ this.name = "InstructionFallbackNotFound";
668
+ this.msg = "Fallback functions are not supported";
669
+ }
670
+ };
671
+ InstructionFallbackNotFound.code = 101;
672
+ var InstructionDidNotDeserialize = class extends Error {
673
+ constructor(logs) {
674
+ super("102: The program could not deserialize the given instruction");
675
+ this.logs = logs;
676
+ this.code = 102;
677
+ this.name = "InstructionDidNotDeserialize";
678
+ this.msg = "The program could not deserialize the given instruction";
679
+ }
680
+ };
681
+ InstructionDidNotDeserialize.code = 102;
682
+ var InstructionDidNotSerialize = class extends Error {
683
+ constructor(logs) {
684
+ super("103: The program could not serialize the given instruction");
685
+ this.logs = logs;
686
+ this.code = 103;
687
+ this.name = "InstructionDidNotSerialize";
688
+ this.msg = "The program could not serialize the given instruction";
689
+ }
690
+ };
691
+ InstructionDidNotSerialize.code = 103;
692
+ var IdlInstructionStub = class extends Error {
693
+ constructor(logs) {
694
+ super("1000: The program was compiled without idl instructions");
695
+ this.logs = logs;
696
+ this.code = 1e3;
697
+ this.name = "IdlInstructionStub";
698
+ this.msg = "The program was compiled without idl instructions";
699
+ }
700
+ };
701
+ IdlInstructionStub.code = 1e3;
702
+ var IdlInstructionInvalidProgram = class extends Error {
703
+ constructor(logs) {
704
+ super("1001: The transaction was given an invalid program for the IDL instruction");
705
+ this.logs = logs;
706
+ this.code = 1001;
707
+ this.name = "IdlInstructionInvalidProgram";
708
+ this.msg = "The transaction was given an invalid program for the IDL instruction";
709
+ }
710
+ };
711
+ IdlInstructionInvalidProgram.code = 1001;
712
+ var ConstraintMut = class extends Error {
713
+ constructor(logs) {
714
+ super("2000: A mut constraint was violated");
715
+ this.logs = logs;
716
+ this.code = 2e3;
717
+ this.name = "ConstraintMut";
718
+ this.msg = "A mut constraint was violated";
719
+ }
720
+ };
721
+ ConstraintMut.code = 2e3;
722
+ var ConstraintHasOne = class extends Error {
723
+ constructor(logs) {
724
+ super("2001: A has one constraint was violated");
725
+ this.logs = logs;
726
+ this.code = 2001;
727
+ this.name = "ConstraintHasOne";
728
+ this.msg = "A has one constraint was violated";
729
+ }
730
+ };
731
+ ConstraintHasOne.code = 2001;
732
+ var ConstraintSigner = class extends Error {
733
+ constructor(logs) {
734
+ super("2002: A signer constraint was violated");
735
+ this.logs = logs;
736
+ this.code = 2002;
737
+ this.name = "ConstraintSigner";
738
+ this.msg = "A signer constraint was violated";
739
+ }
740
+ };
741
+ ConstraintSigner.code = 2002;
742
+ var ConstraintRaw = class extends Error {
743
+ constructor(logs) {
744
+ super("2003: A raw constraint was violated");
745
+ this.logs = logs;
746
+ this.code = 2003;
747
+ this.name = "ConstraintRaw";
748
+ this.msg = "A raw constraint was violated";
749
+ }
750
+ };
751
+ ConstraintRaw.code = 2003;
752
+ var ConstraintOwner = class extends Error {
753
+ constructor(logs) {
754
+ super("2004: An owner constraint was violated");
755
+ this.logs = logs;
756
+ this.code = 2004;
757
+ this.name = "ConstraintOwner";
758
+ this.msg = "An owner constraint was violated";
759
+ }
760
+ };
761
+ ConstraintOwner.code = 2004;
762
+ var ConstraintRentExempt = class extends Error {
763
+ constructor(logs) {
764
+ super("2005: A rent exemption constraint was violated");
765
+ this.logs = logs;
766
+ this.code = 2005;
767
+ this.name = "ConstraintRentExempt";
768
+ this.msg = "A rent exemption constraint was violated";
769
+ }
770
+ };
771
+ ConstraintRentExempt.code = 2005;
772
+ var ConstraintSeeds = class extends Error {
773
+ constructor(logs) {
774
+ super("2006: A seeds constraint was violated");
775
+ this.logs = logs;
776
+ this.code = 2006;
777
+ this.name = "ConstraintSeeds";
778
+ this.msg = "A seeds constraint was violated";
779
+ }
780
+ };
781
+ ConstraintSeeds.code = 2006;
782
+ var ConstraintExecutable = class extends Error {
783
+ constructor(logs) {
784
+ super("2007: An executable constraint was violated");
785
+ this.logs = logs;
786
+ this.code = 2007;
787
+ this.name = "ConstraintExecutable";
788
+ this.msg = "An executable constraint was violated";
789
+ }
790
+ };
791
+ ConstraintExecutable.code = 2007;
792
+ var ConstraintState = class extends Error {
793
+ constructor(logs) {
794
+ super("2008: Deprecated Error, feel free to replace with something else");
795
+ this.logs = logs;
796
+ this.code = 2008;
797
+ this.name = "ConstraintState";
798
+ this.msg = "Deprecated Error, feel free to replace with something else";
799
+ }
800
+ };
801
+ ConstraintState.code = 2008;
802
+ var ConstraintAssociated = class extends Error {
803
+ constructor(logs) {
804
+ super("2009: An associated constraint was violated");
805
+ this.logs = logs;
806
+ this.code = 2009;
807
+ this.name = "ConstraintAssociated";
808
+ this.msg = "An associated constraint was violated";
809
+ }
810
+ };
811
+ ConstraintAssociated.code = 2009;
812
+ var ConstraintAssociatedInit = class extends Error {
813
+ constructor(logs) {
814
+ super("2010: An associated init constraint was violated");
815
+ this.logs = logs;
816
+ this.code = 2010;
817
+ this.name = "ConstraintAssociatedInit";
818
+ this.msg = "An associated init constraint was violated";
819
+ }
820
+ };
821
+ ConstraintAssociatedInit.code = 2010;
822
+ var ConstraintClose = class extends Error {
823
+ constructor(logs) {
824
+ super("2011: A close constraint was violated");
825
+ this.logs = logs;
826
+ this.code = 2011;
827
+ this.name = "ConstraintClose";
828
+ this.msg = "A close constraint was violated";
829
+ }
830
+ };
831
+ ConstraintClose.code = 2011;
832
+ var ConstraintAddress = class extends Error {
833
+ constructor(logs) {
834
+ super("2012: An address constraint was violated");
835
+ this.logs = logs;
836
+ this.code = 2012;
837
+ this.name = "ConstraintAddress";
838
+ this.msg = "An address constraint was violated";
839
+ }
840
+ };
841
+ ConstraintAddress.code = 2012;
842
+ var ConstraintZero = class extends Error {
843
+ constructor(logs) {
844
+ super("2013: Expected zero account discriminant");
845
+ this.logs = logs;
846
+ this.code = 2013;
847
+ this.name = "ConstraintZero";
848
+ this.msg = "Expected zero account discriminant";
849
+ }
850
+ };
851
+ ConstraintZero.code = 2013;
852
+ var ConstraintTokenMint = class extends Error {
853
+ constructor(logs) {
854
+ super("2014: A token mint constraint was violated");
855
+ this.logs = logs;
856
+ this.code = 2014;
857
+ this.name = "ConstraintTokenMint";
858
+ this.msg = "A token mint constraint was violated";
859
+ }
860
+ };
861
+ ConstraintTokenMint.code = 2014;
862
+ var ConstraintTokenOwner = class extends Error {
863
+ constructor(logs) {
864
+ super("2015: A token owner constraint was violated");
865
+ this.logs = logs;
866
+ this.code = 2015;
867
+ this.name = "ConstraintTokenOwner";
868
+ this.msg = "A token owner constraint was violated";
869
+ }
870
+ };
871
+ ConstraintTokenOwner.code = 2015;
872
+ var ConstraintMintMintAuthority = class extends Error {
873
+ constructor(logs) {
874
+ super("2016: A mint mint authority constraint was violated");
875
+ this.logs = logs;
876
+ this.code = 2016;
877
+ this.name = "ConstraintMintMintAuthority";
878
+ this.msg = "A mint mint authority constraint was violated";
879
+ }
880
+ };
881
+ ConstraintMintMintAuthority.code = 2016;
882
+ var ConstraintMintFreezeAuthority = class extends Error {
883
+ constructor(logs) {
884
+ super("2017: A mint freeze authority constraint was violated");
885
+ this.logs = logs;
886
+ this.code = 2017;
887
+ this.name = "ConstraintMintFreezeAuthority";
888
+ this.msg = "A mint freeze authority constraint was violated";
889
+ }
890
+ };
891
+ ConstraintMintFreezeAuthority.code = 2017;
892
+ var ConstraintMintDecimals = class extends Error {
893
+ constructor(logs) {
894
+ super("2018: A mint decimals constraint was violated");
895
+ this.logs = logs;
896
+ this.code = 2018;
897
+ this.name = "ConstraintMintDecimals";
898
+ this.msg = "A mint decimals constraint was violated";
899
+ }
900
+ };
901
+ ConstraintMintDecimals.code = 2018;
902
+ var ConstraintSpace = class extends Error {
903
+ constructor(logs) {
904
+ super("2019: A space constraint was violated");
905
+ this.logs = logs;
906
+ this.code = 2019;
907
+ this.name = "ConstraintSpace";
908
+ this.msg = "A space constraint was violated";
909
+ }
910
+ };
911
+ ConstraintSpace.code = 2019;
912
+ var ConstraintAccountIsNone = class extends Error {
913
+ constructor(logs) {
914
+ super("2020: A required account for the constraint is None");
915
+ this.logs = logs;
916
+ this.code = 2020;
917
+ this.name = "ConstraintAccountIsNone";
918
+ this.msg = "A required account for the constraint is None";
919
+ }
920
+ };
921
+ ConstraintAccountIsNone.code = 2020;
922
+ var RequireViolated = class extends Error {
923
+ constructor(logs) {
924
+ super("2500: A require expression was violated");
925
+ this.logs = logs;
926
+ this.code = 2500;
927
+ this.name = "RequireViolated";
928
+ this.msg = "A require expression was violated";
929
+ }
930
+ };
931
+ RequireViolated.code = 2500;
932
+ var RequireEqViolated = class extends Error {
933
+ constructor(logs) {
934
+ super("2501: A require_eq expression was violated");
935
+ this.logs = logs;
936
+ this.code = 2501;
937
+ this.name = "RequireEqViolated";
938
+ this.msg = "A require_eq expression was violated";
939
+ }
940
+ };
941
+ RequireEqViolated.code = 2501;
942
+ var RequireKeysEqViolated = class extends Error {
943
+ constructor(logs) {
944
+ super("2502: A require_keys_eq expression was violated");
945
+ this.logs = logs;
946
+ this.code = 2502;
947
+ this.name = "RequireKeysEqViolated";
948
+ this.msg = "A require_keys_eq expression was violated";
949
+ }
950
+ };
951
+ RequireKeysEqViolated.code = 2502;
952
+ var RequireNeqViolated = class extends Error {
953
+ constructor(logs) {
954
+ super("2503: A require_neq expression was violated");
955
+ this.logs = logs;
956
+ this.code = 2503;
957
+ this.name = "RequireNeqViolated";
958
+ this.msg = "A require_neq expression was violated";
959
+ }
960
+ };
961
+ RequireNeqViolated.code = 2503;
962
+ var RequireKeysNeqViolated = class extends Error {
963
+ constructor(logs) {
964
+ super("2504: A require_keys_neq expression was violated");
965
+ this.logs = logs;
966
+ this.code = 2504;
967
+ this.name = "RequireKeysNeqViolated";
968
+ this.msg = "A require_keys_neq expression was violated";
969
+ }
970
+ };
971
+ RequireKeysNeqViolated.code = 2504;
972
+ var RequireGtViolated = class extends Error {
973
+ constructor(logs) {
974
+ super("2505: A require_gt expression was violated");
975
+ this.logs = logs;
976
+ this.code = 2505;
977
+ this.name = "RequireGtViolated";
978
+ this.msg = "A require_gt expression was violated";
979
+ }
980
+ };
981
+ RequireGtViolated.code = 2505;
982
+ var RequireGteViolated = class extends Error {
983
+ constructor(logs) {
984
+ super("2506: A require_gte expression was violated");
985
+ this.logs = logs;
986
+ this.code = 2506;
987
+ this.name = "RequireGteViolated";
988
+ this.msg = "A require_gte expression was violated";
989
+ }
990
+ };
991
+ RequireGteViolated.code = 2506;
992
+ var AccountDiscriminatorAlreadySet = class extends Error {
993
+ constructor(logs) {
994
+ super("3000: The account discriminator was already set on this account");
995
+ this.logs = logs;
996
+ this.code = 3e3;
997
+ this.name = "AccountDiscriminatorAlreadySet";
998
+ this.msg = "The account discriminator was already set on this account";
999
+ }
1000
+ };
1001
+ AccountDiscriminatorAlreadySet.code = 3e3;
1002
+ var AccountDiscriminatorNotFound = class extends Error {
1003
+ constructor(logs) {
1004
+ super("3001: No 8 byte discriminator was found on the account");
1005
+ this.logs = logs;
1006
+ this.code = 3001;
1007
+ this.name = "AccountDiscriminatorNotFound";
1008
+ this.msg = "No 8 byte discriminator was found on the account";
1009
+ }
1010
+ };
1011
+ AccountDiscriminatorNotFound.code = 3001;
1012
+ var AccountDiscriminatorMismatch = class extends Error {
1013
+ constructor(logs) {
1014
+ super("3002: 8 byte discriminator did not match what was expected");
1015
+ this.logs = logs;
1016
+ this.code = 3002;
1017
+ this.name = "AccountDiscriminatorMismatch";
1018
+ this.msg = "8 byte discriminator did not match what was expected";
1019
+ }
1020
+ };
1021
+ AccountDiscriminatorMismatch.code = 3002;
1022
+ var AccountDidNotDeserialize = class extends Error {
1023
+ constructor(logs) {
1024
+ super("3003: Failed to deserialize the account");
1025
+ this.logs = logs;
1026
+ this.code = 3003;
1027
+ this.name = "AccountDidNotDeserialize";
1028
+ this.msg = "Failed to deserialize the account";
1029
+ }
1030
+ };
1031
+ AccountDidNotDeserialize.code = 3003;
1032
+ var AccountDidNotSerialize = class extends Error {
1033
+ constructor(logs) {
1034
+ super("3004: Failed to serialize the account");
1035
+ this.logs = logs;
1036
+ this.code = 3004;
1037
+ this.name = "AccountDidNotSerialize";
1038
+ this.msg = "Failed to serialize the account";
1039
+ }
1040
+ };
1041
+ AccountDidNotSerialize.code = 3004;
1042
+ var AccountNotEnoughKeys = class extends Error {
1043
+ constructor(logs) {
1044
+ super("3005: Not enough account keys given to the instruction");
1045
+ this.logs = logs;
1046
+ this.code = 3005;
1047
+ this.name = "AccountNotEnoughKeys";
1048
+ this.msg = "Not enough account keys given to the instruction";
1049
+ }
1050
+ };
1051
+ AccountNotEnoughKeys.code = 3005;
1052
+ var AccountNotMutable = class extends Error {
1053
+ constructor(logs) {
1054
+ super("3006: The given account is not mutable");
1055
+ this.logs = logs;
1056
+ this.code = 3006;
1057
+ this.name = "AccountNotMutable";
1058
+ this.msg = "The given account is not mutable";
1059
+ }
1060
+ };
1061
+ AccountNotMutable.code = 3006;
1062
+ var AccountOwnedByWrongProgram = class extends Error {
1063
+ constructor(logs) {
1064
+ super("3007: The given account is owned by a different program than expected");
1065
+ this.logs = logs;
1066
+ this.code = 3007;
1067
+ this.name = "AccountOwnedByWrongProgram";
1068
+ this.msg = "The given account is owned by a different program than expected";
1069
+ }
1070
+ };
1071
+ AccountOwnedByWrongProgram.code = 3007;
1072
+ var InvalidProgramId = class extends Error {
1073
+ constructor(logs) {
1074
+ super("3008: Program ID was not as expected");
1075
+ this.logs = logs;
1076
+ this.code = 3008;
1077
+ this.name = "InvalidProgramId";
1078
+ this.msg = "Program ID was not as expected";
1079
+ }
1080
+ };
1081
+ InvalidProgramId.code = 3008;
1082
+ var InvalidProgramExecutable = class extends Error {
1083
+ constructor(logs) {
1084
+ super("3009: Program account is not executable");
1085
+ this.logs = logs;
1086
+ this.code = 3009;
1087
+ this.name = "InvalidProgramExecutable";
1088
+ this.msg = "Program account is not executable";
1089
+ }
1090
+ };
1091
+ InvalidProgramExecutable.code = 3009;
1092
+ var AccountNotSigner = class extends Error {
1093
+ constructor(logs) {
1094
+ super("3010: The given account did not sign");
1095
+ this.logs = logs;
1096
+ this.code = 3010;
1097
+ this.name = "AccountNotSigner";
1098
+ this.msg = "The given account did not sign";
1099
+ }
1100
+ };
1101
+ AccountNotSigner.code = 3010;
1102
+ var AccountNotSystemOwned = class extends Error {
1103
+ constructor(logs) {
1104
+ super("3011: The given account is not owned by the system program");
1105
+ this.logs = logs;
1106
+ this.code = 3011;
1107
+ this.name = "AccountNotSystemOwned";
1108
+ this.msg = "The given account is not owned by the system program";
1109
+ }
1110
+ };
1111
+ AccountNotSystemOwned.code = 3011;
1112
+ var AccountNotInitialized = class extends Error {
1113
+ constructor(logs) {
1114
+ super("3012: The program expected this account to be already initialized");
1115
+ this.logs = logs;
1116
+ this.code = 3012;
1117
+ this.name = "AccountNotInitialized";
1118
+ this.msg = "The program expected this account to be already initialized";
1119
+ }
1120
+ };
1121
+ AccountNotInitialized.code = 3012;
1122
+ var AccountNotProgramData = class extends Error {
1123
+ constructor(logs) {
1124
+ super("3013: The given account is not a program data account");
1125
+ this.logs = logs;
1126
+ this.code = 3013;
1127
+ this.name = "AccountNotProgramData";
1128
+ this.msg = "The given account is not a program data account";
1129
+ }
1130
+ };
1131
+ AccountNotProgramData.code = 3013;
1132
+ var AccountNotAssociatedTokenAccount = class extends Error {
1133
+ constructor(logs) {
1134
+ super("3014: The given account is not the associated token account");
1135
+ this.logs = logs;
1136
+ this.code = 3014;
1137
+ this.name = "AccountNotAssociatedTokenAccount";
1138
+ this.msg = "The given account is not the associated token account";
1139
+ }
1140
+ };
1141
+ AccountNotAssociatedTokenAccount.code = 3014;
1142
+ var AccountSysvarMismatch = class extends Error {
1143
+ constructor(logs) {
1144
+ super("3015: The given public key does not match the required sysvar");
1145
+ this.logs = logs;
1146
+ this.code = 3015;
1147
+ this.name = "AccountSysvarMismatch";
1148
+ this.msg = "The given public key does not match the required sysvar";
1149
+ }
1150
+ };
1151
+ AccountSysvarMismatch.code = 3015;
1152
+ var AccountReallocExceedsLimit = class extends Error {
1153
+ constructor(logs) {
1154
+ super("3016: The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit");
1155
+ this.logs = logs;
1156
+ this.code = 3016;
1157
+ this.name = "AccountReallocExceedsLimit";
1158
+ this.msg = "The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit";
1159
+ }
1160
+ };
1161
+ AccountReallocExceedsLimit.code = 3016;
1162
+ var AccountDuplicateReallocs = class extends Error {
1163
+ constructor(logs) {
1164
+ super("3017: The account was duplicated for more than one reallocation");
1165
+ this.logs = logs;
1166
+ this.code = 3017;
1167
+ this.name = "AccountDuplicateReallocs";
1168
+ this.msg = "The account was duplicated for more than one reallocation";
1169
+ }
1170
+ };
1171
+ AccountDuplicateReallocs.code = 3017;
1172
+ var DeclaredProgramIdMismatch = class extends Error {
1173
+ constructor(logs) {
1174
+ super("4100: The declared program id does not match the actual program id");
1175
+ this.logs = logs;
1176
+ this.code = 4100;
1177
+ this.name = "DeclaredProgramIdMismatch";
1178
+ this.msg = "The declared program id does not match the actual program id";
1179
+ }
1180
+ };
1181
+ DeclaredProgramIdMismatch.code = 4100;
1182
+ var Deprecated = class extends Error {
1183
+ constructor(logs) {
1184
+ super("5000: The API being used is deprecated and should no longer be used");
1185
+ this.logs = logs;
1186
+ this.code = 5e3;
1187
+ this.name = "Deprecated";
1188
+ this.msg = "The API being used is deprecated and should no longer be used";
1189
+ }
1190
+ };
1191
+ Deprecated.code = 5e3;
1192
+ function fromCode(code, logs) {
1193
+ switch (code) {
1194
+ case 100:
1195
+ return new InstructionMissing(logs);
1196
+ case 101:
1197
+ return new InstructionFallbackNotFound(logs);
1198
+ case 102:
1199
+ return new InstructionDidNotDeserialize(logs);
1200
+ case 103:
1201
+ return new InstructionDidNotSerialize(logs);
1202
+ case 1e3:
1203
+ return new IdlInstructionStub(logs);
1204
+ case 1001:
1205
+ return new IdlInstructionInvalidProgram(logs);
1206
+ case 2e3:
1207
+ return new ConstraintMut(logs);
1208
+ case 2001:
1209
+ return new ConstraintHasOne(logs);
1210
+ case 2002:
1211
+ return new ConstraintSigner(logs);
1212
+ case 2003:
1213
+ return new ConstraintRaw(logs);
1214
+ case 2004:
1215
+ return new ConstraintOwner(logs);
1216
+ case 2005:
1217
+ return new ConstraintRentExempt(logs);
1218
+ case 2006:
1219
+ return new ConstraintSeeds(logs);
1220
+ case 2007:
1221
+ return new ConstraintExecutable(logs);
1222
+ case 2008:
1223
+ return new ConstraintState(logs);
1224
+ case 2009:
1225
+ return new ConstraintAssociated(logs);
1226
+ case 2010:
1227
+ return new ConstraintAssociatedInit(logs);
1228
+ case 2011:
1229
+ return new ConstraintClose(logs);
1230
+ case 2012:
1231
+ return new ConstraintAddress(logs);
1232
+ case 2013:
1233
+ return new ConstraintZero(logs);
1234
+ case 2014:
1235
+ return new ConstraintTokenMint(logs);
1236
+ case 2015:
1237
+ return new ConstraintTokenOwner(logs);
1238
+ case 2016:
1239
+ return new ConstraintMintMintAuthority(logs);
1240
+ case 2017:
1241
+ return new ConstraintMintFreezeAuthority(logs);
1242
+ case 2018:
1243
+ return new ConstraintMintDecimals(logs);
1244
+ case 2019:
1245
+ return new ConstraintSpace(logs);
1246
+ case 2020:
1247
+ return new ConstraintAccountIsNone(logs);
1248
+ case 2500:
1249
+ return new RequireViolated(logs);
1250
+ case 2501:
1251
+ return new RequireEqViolated(logs);
1252
+ case 2502:
1253
+ return new RequireKeysEqViolated(logs);
1254
+ case 2503:
1255
+ return new RequireNeqViolated(logs);
1256
+ case 2504:
1257
+ return new RequireKeysNeqViolated(logs);
1258
+ case 2505:
1259
+ return new RequireGtViolated(logs);
1260
+ case 2506:
1261
+ return new RequireGteViolated(logs);
1262
+ case 3e3:
1263
+ return new AccountDiscriminatorAlreadySet(logs);
1264
+ case 3001:
1265
+ return new AccountDiscriminatorNotFound(logs);
1266
+ case 3002:
1267
+ return new AccountDiscriminatorMismatch(logs);
1268
+ case 3003:
1269
+ return new AccountDidNotDeserialize(logs);
1270
+ case 3004:
1271
+ return new AccountDidNotSerialize(logs);
1272
+ case 3005:
1273
+ return new AccountNotEnoughKeys(logs);
1274
+ case 3006:
1275
+ return new AccountNotMutable(logs);
1276
+ case 3007:
1277
+ return new AccountOwnedByWrongProgram(logs);
1278
+ case 3008:
1279
+ return new InvalidProgramId(logs);
1280
+ case 3009:
1281
+ return new InvalidProgramExecutable(logs);
1282
+ case 3010:
1283
+ return new AccountNotSigner(logs);
1284
+ case 3011:
1285
+ return new AccountNotSystemOwned(logs);
1286
+ case 3012:
1287
+ return new AccountNotInitialized(logs);
1288
+ case 3013:
1289
+ return new AccountNotProgramData(logs);
1290
+ case 3014:
1291
+ return new AccountNotAssociatedTokenAccount(logs);
1292
+ case 3015:
1293
+ return new AccountSysvarMismatch(logs);
1294
+ case 3016:
1295
+ return new AccountReallocExceedsLimit(logs);
1296
+ case 3017:
1297
+ return new AccountDuplicateReallocs(logs);
1298
+ case 4100:
1299
+ return new DeclaredProgramIdMismatch(logs);
1300
+ case 5e3:
1301
+ return new Deprecated(logs);
1302
+ }
1303
+ return null;
1304
+ }
1305
+
1306
+ // solana/generated/errors/custom.ts
1307
+ var InsufficientUnlockedTokens = class extends Error {
1308
+ constructor(logs) {
1309
+ super("6000: Insufficient unlocked tokens");
1310
+ this.logs = logs;
1311
+ this.code = 6e3;
1312
+ this.name = "InsufficientUnlockedTokens";
1313
+ this.msg = "Insufficient unlocked tokens";
1314
+ }
1315
+ };
1316
+ InsufficientUnlockedTokens.code = 6e3;
1317
+ var InvalidProof = class extends Error {
1318
+ constructor(logs) {
1319
+ super("6001: Invalid Merkle proof");
1320
+ this.logs = logs;
1321
+ this.code = 6001;
1322
+ this.name = "InvalidProof";
1323
+ this.msg = "Invalid Merkle proof";
1324
+ }
1325
+ };
1326
+ InvalidProof.code = 6001;
1327
+ var ExceededMaxClaim = class extends Error {
1328
+ constructor(logs) {
1329
+ super("6002: Exceeded maximum claim amount");
1330
+ this.logs = logs;
1331
+ this.code = 6002;
1332
+ this.name = "ExceededMaxClaim";
1333
+ this.msg = "Exceeded maximum claim amount";
1334
+ }
1335
+ };
1336
+ ExceededMaxClaim.code = 6002;
1337
+ var MaxNodesExceeded = class extends Error {
1338
+ constructor(logs) {
1339
+ super("6003: Exceeded maximum node count");
1340
+ this.logs = logs;
1341
+ this.code = 6003;
1342
+ this.name = "MaxNodesExceeded";
1343
+ this.msg = "Exceeded maximum node count";
1344
+ }
1345
+ };
1346
+ MaxNodesExceeded.code = 6003;
1347
+ var Unauthorized = class extends Error {
1348
+ constructor(logs) {
1349
+ super("6004: Account is not authorized to execute this instruction");
1350
+ this.logs = logs;
1351
+ this.code = 6004;
1352
+ this.name = "Unauthorized";
1353
+ this.msg = "Account is not authorized to execute this instruction";
1354
+ }
1355
+ };
1356
+ Unauthorized.code = 6004;
1357
+ var OwnerMismatch = class extends Error {
1358
+ constructor(logs) {
1359
+ super("6005: Token account owner did not match intended owner");
1360
+ this.logs = logs;
1361
+ this.code = 6005;
1362
+ this.name = "OwnerMismatch";
1363
+ this.msg = "Token account owner did not match intended owner";
1364
+ }
1365
+ };
1366
+ OwnerMismatch.code = 6005;
1367
+ var ClawbackBeforeStart = class extends Error {
1368
+ constructor(logs) {
1369
+ super("6006: Attempted clawback before start");
1370
+ this.logs = logs;
1371
+ this.code = 6006;
1372
+ this.name = "ClawbackBeforeStart";
1373
+ this.msg = "Attempted clawback before start";
1374
+ }
1375
+ };
1376
+ ClawbackBeforeStart.code = 6006;
1377
+ var ClawbackAlreadyClaimed = class extends Error {
1378
+ constructor(logs) {
1379
+ super("6007: Clawback already claimed");
1380
+ this.logs = logs;
1381
+ this.code = 6007;
1382
+ this.name = "ClawbackAlreadyClaimed";
1383
+ this.msg = "Clawback already claimed";
1384
+ }
1385
+ };
1386
+ ClawbackAlreadyClaimed.code = 6007;
1387
+ var SameClawbackReceiver = class extends Error {
1388
+ constructor(logs) {
1389
+ super("6008: New and old Clawback receivers are identical");
1390
+ this.logs = logs;
1391
+ this.code = 6008;
1392
+ this.name = "SameClawbackReceiver";
1393
+ this.msg = "New and old Clawback receivers are identical";
1394
+ }
1395
+ };
1396
+ SameClawbackReceiver.code = 6008;
1397
+ var ClawbackReceiverIsTokenVault = class extends Error {
1398
+ constructor(logs) {
1399
+ super("6009: Clawback receiver can not be the Token Vault");
1400
+ this.logs = logs;
1401
+ this.code = 6009;
1402
+ this.name = "ClawbackReceiverIsTokenVault";
1403
+ this.msg = "Clawback receiver can not be the Token Vault";
1404
+ }
1405
+ };
1406
+ ClawbackReceiverIsTokenVault.code = 6009;
1407
+ var SameAdmin = class extends Error {
1408
+ constructor(logs) {
1409
+ super("6010: New and old admin are identical");
1410
+ this.logs = logs;
1411
+ this.code = 6010;
1412
+ this.name = "SameAdmin";
1413
+ this.msg = "New and old admin are identical";
1414
+ }
1415
+ };
1416
+ SameAdmin.code = 6010;
1417
+ var ClaimExpired = class extends Error {
1418
+ constructor(logs) {
1419
+ super("6011: Claim window expired");
1420
+ this.logs = logs;
1421
+ this.code = 6011;
1422
+ this.name = "ClaimExpired";
1423
+ this.msg = "Claim window expired";
1424
+ }
1425
+ };
1426
+ ClaimExpired.code = 6011;
1427
+ var ArithmeticError = class extends Error {
1428
+ constructor(logs) {
1429
+ super("6012: Arithmetic Error (overflow/underflow)");
1430
+ this.logs = logs;
1431
+ this.code = 6012;
1432
+ this.name = "ArithmeticError";
1433
+ this.msg = "Arithmetic Error (overflow/underflow)";
1434
+ }
1435
+ };
1436
+ ArithmeticError.code = 6012;
1437
+ var StartTimestampAfterEnd = class extends Error {
1438
+ constructor(logs) {
1439
+ super("6013: Start Timestamp cannot be after end Timestamp");
1440
+ this.logs = logs;
1441
+ this.code = 6013;
1442
+ this.name = "StartTimestampAfterEnd";
1443
+ this.msg = "Start Timestamp cannot be after end Timestamp";
1444
+ }
1445
+ };
1446
+ StartTimestampAfterEnd.code = 6013;
1447
+ var TimestampsNotInFuture = class extends Error {
1448
+ constructor(logs) {
1449
+ super("6014: Timestamps cannot be in the past");
1450
+ this.logs = logs;
1451
+ this.code = 6014;
1452
+ this.name = "TimestampsNotInFuture";
1453
+ this.msg = "Timestamps cannot be in the past";
1454
+ }
1455
+ };
1456
+ TimestampsNotInFuture.code = 6014;
1457
+ var InvalidMint = class extends Error {
1458
+ constructor(logs) {
1459
+ super("6015: Invalid Mint");
1460
+ this.logs = logs;
1461
+ this.code = 6015;
1462
+ this.name = "InvalidMint";
1463
+ this.msg = "Invalid Mint";
1464
+ }
1465
+ };
1466
+ InvalidMint.code = 6015;
1467
+ var ClaimIsClosed = class extends Error {
1468
+ constructor(logs) {
1469
+ super("6016: Claim is closed");
1470
+ this.logs = logs;
1471
+ this.code = 6016;
1472
+ this.name = "ClaimIsClosed";
1473
+ this.msg = "Claim is closed";
1474
+ }
1475
+ };
1476
+ ClaimIsClosed.code = 6016;
1477
+ var ClaimsAreNotClosable = class extends Error {
1478
+ constructor(logs) {
1479
+ super("6017: Claims are not closable");
1480
+ this.logs = logs;
1481
+ this.code = 6017;
1482
+ this.name = "ClaimsAreNotClosable";
1483
+ this.msg = "Claims are not closable";
1484
+ }
1485
+ };
1486
+ ClaimsAreNotClosable.code = 6017;
1487
+ var InvalidUnlockPeriod = class extends Error {
1488
+ constructor(logs) {
1489
+ super("6018: Invalid unlock period");
1490
+ this.logs = logs;
1491
+ this.code = 6018;
1492
+ this.name = "InvalidUnlockPeriod";
1493
+ this.msg = "Invalid unlock period";
1494
+ }
1495
+ };
1496
+ InvalidUnlockPeriod.code = 6018;
1497
+ var DurationUpdateNotAllowed = class extends Error {
1498
+ constructor(logs) {
1499
+ super("6019: Duration update is not allowed");
1500
+ this.logs = logs;
1501
+ this.code = 6019;
1502
+ this.name = "DurationUpdateNotAllowed";
1503
+ this.msg = "Duration update is not allowed";
1504
+ }
1505
+ };
1506
+ DurationUpdateNotAllowed.code = 6019;
1507
+ var NoVestingAmount = class extends Error {
1508
+ constructor(logs) {
1509
+ super("6020: Vesting amounts are not set");
1510
+ this.logs = logs;
1511
+ this.code = 6020;
1512
+ this.name = "NoVestingAmount";
1513
+ this.msg = "Vesting amounts are not set";
1514
+ }
1515
+ };
1516
+ NoVestingAmount.code = 6020;
1517
+ var VestingAlreadyFinished = class extends Error {
1518
+ constructor(logs) {
1519
+ super("6021: Vesting already finished");
1520
+ this.logs = logs;
1521
+ this.code = 6021;
1522
+ this.name = "VestingAlreadyFinished";
1523
+ this.msg = "Vesting already finished";
1524
+ }
1525
+ };
1526
+ VestingAlreadyFinished.code = 6021;
1527
+ var InvalidAmounts = class extends Error {
1528
+ constructor(logs) {
1529
+ super("6022: Provided amounts are invalid");
1530
+ this.logs = logs;
1531
+ this.code = 6022;
1532
+ this.name = "InvalidAmounts";
1533
+ this.msg = "Provided amounts are invalid";
1534
+ }
1535
+ };
1536
+ InvalidAmounts.code = 6022;
1537
+ var ClaimsLimitReached = class extends Error {
1538
+ constructor(logs) {
1539
+ super("6023: Claims limit has been reached");
1540
+ this.logs = logs;
1541
+ this.code = 6023;
1542
+ this.name = "ClaimsLimitReached";
1543
+ this.msg = "Claims limit has been reached";
1544
+ }
1545
+ };
1546
+ ClaimsLimitReached.code = 6023;
1547
+ function fromCode2(code, logs) {
1548
+ switch (code) {
1549
+ case 6e3:
1550
+ return new InsufficientUnlockedTokens(logs);
1551
+ case 6001:
1552
+ return new InvalidProof(logs);
1553
+ case 6002:
1554
+ return new ExceededMaxClaim(logs);
1555
+ case 6003:
1556
+ return new MaxNodesExceeded(logs);
1557
+ case 6004:
1558
+ return new Unauthorized(logs);
1559
+ case 6005:
1560
+ return new OwnerMismatch(logs);
1561
+ case 6006:
1562
+ return new ClawbackBeforeStart(logs);
1563
+ case 6007:
1564
+ return new ClawbackAlreadyClaimed(logs);
1565
+ case 6008:
1566
+ return new SameClawbackReceiver(logs);
1567
+ case 6009:
1568
+ return new ClawbackReceiverIsTokenVault(logs);
1569
+ case 6010:
1570
+ return new SameAdmin(logs);
1571
+ case 6011:
1572
+ return new ClaimExpired(logs);
1573
+ case 6012:
1574
+ return new ArithmeticError(logs);
1575
+ case 6013:
1576
+ return new StartTimestampAfterEnd(logs);
1577
+ case 6014:
1578
+ return new TimestampsNotInFuture(logs);
1579
+ case 6015:
1580
+ return new InvalidMint(logs);
1581
+ case 6016:
1582
+ return new ClaimIsClosed(logs);
1583
+ case 6017:
1584
+ return new ClaimsAreNotClosable(logs);
1585
+ case 6018:
1586
+ return new InvalidUnlockPeriod(logs);
1587
+ case 6019:
1588
+ return new DurationUpdateNotAllowed(logs);
1589
+ case 6020:
1590
+ return new NoVestingAmount(logs);
1591
+ case 6021:
1592
+ return new VestingAlreadyFinished(logs);
1593
+ case 6022:
1594
+ return new InvalidAmounts(logs);
1595
+ case 6023:
1596
+ return new ClaimsLimitReached(logs);
1597
+ }
1598
+ return null;
1599
+ }
1600
+
1601
+ // solana/generated/errors/index.ts
1602
+ function fromCode3(code, logs) {
1603
+ return code >= 6e3 ? fromCode2(code, logs) : fromCode(code, logs);
1604
+ }
1605
+ function hasOwnProperty(obj, prop) {
1606
+ return Object.hasOwnProperty.call(obj, prop);
1607
+ }
1608
+ var errorRe = /Program (\w+) failed: custom program error: (\w+)/;
1609
+ function fromTxError(err, programId = PROGRAM_ID) {
1610
+ if (typeof err !== "object" || err === null || !hasOwnProperty(err, "logs") || !Array.isArray(err.logs)) {
1611
+ return null;
1612
+ }
1613
+ let firstMatch = null;
1614
+ for (const logLine of err.logs) {
1615
+ firstMatch = errorRe.exec(logLine);
1616
+ if (firstMatch !== null) {
1617
+ break;
1618
+ }
1619
+ }
1620
+ if (firstMatch === null) {
1621
+ return null;
1622
+ }
1623
+ const [programIdRaw, codeRaw] = firstMatch.slice(1);
1624
+ if (programIdRaw !== programId.toString()) {
1625
+ return null;
1626
+ }
1627
+ let errorCode;
1628
+ try {
1629
+ errorCode = parseInt(codeRaw, 16);
1630
+ } catch (parseErr) {
1631
+ return null;
1632
+ }
1633
+ return fromCode3(errorCode, err.logs);
1634
+ }
1635
+
1636
+ // solana/utils.ts
1637
+ var getAlignedDistributorPda = (programId, distributor) => {
1638
+ return web3_js.PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
1639
+ };
1640
+ var getTestOraclePda = (programId, mint, creator) => {
1641
+ return web3_js.PublicKey.findProgramAddressSync([TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
1642
+ };
1643
+ function getDistributorPda(programId, mint, version) {
1644
+ const seeds = [
1645
+ DISTRIBUTOR_PREFIX,
1646
+ mint.toBuffer(),
1647
+ buffer.Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer))
1648
+ ];
1649
+ return web3_js.PublicKey.findProgramAddressSync(seeds, programId)[0];
1650
+ }
1651
+ function getClaimantStatusPda(programId, distributor, claimant) {
1652
+ const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
1653
+ return web3_js.PublicKey.findProgramAddressSync(seeds, programId)[0];
1654
+ }
1655
+ function getEventAuthorityPda(programId) {
1656
+ const seeds = [buffer.Buffer.from("__event_authority")];
1657
+ return web3_js.PublicKey.findProgramAddressSync(seeds, programId)[0];
1658
+ }
1659
+ async function wrappedSignAndExecuteTransaction(...args) {
1660
+ try {
1661
+ return await solana.signAndExecuteTransaction(...args);
1662
+ } catch (err) {
1663
+ if (err instanceof Error) {
1664
+ const parsed = fromTxError(err);
1665
+ if (parsed) {
1666
+ throw new common.ContractError(err, parsed.name, parsed.msg);
1667
+ }
1668
+ }
1669
+ throw err;
1670
+ }
1671
+ }
1672
+ async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
1673
+ const epoch = await connection.getEpochInfo();
1674
+ const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch ? transferFeeConfig.newerTransferFee : transferFeeConfig.olderTransferFee;
1675
+ const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
1676
+ let feeCharged = BigInt(0);
1677
+ if (transferFeeBasisPoints !== BigInt(0)) {
1678
+ const numerator = transferAmount * ONE_IN_BASIS_POINTS;
1679
+ const denominator = ONE_IN_BASIS_POINTS - transferFeeBasisPoints;
1680
+ const rawPreFeeAmount = common.divCeilN(numerator, denominator);
1681
+ const fee = rawPreFeeAmount - transferAmount;
1682
+ transferAmount = rawPreFeeAmount;
1683
+ feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
1684
+ }
1685
+ return { transferAmount, feeCharged };
1686
+ }
1687
+
1688
+ // solana/clients/BaseDistributorClient.ts
1689
+ var BaseDistributorClient = class {
1690
+ constructor({
1691
+ clusterUrl,
1692
+ cluster = common.ICluster.Mainnet,
1693
+ commitment = "confirmed",
1694
+ programId = "",
1695
+ sendRate = 1,
1696
+ sendThrottler
1697
+ }) {
1698
+ this.commitment = commitment;
1699
+ this.connection = new web3_js.Connection(clusterUrl, this.commitment);
1700
+ this.programId = programId !== "" ? new web3_js.PublicKey(programId) : new web3_js.PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
1701
+ this.sendThrottler = sendThrottler ?? solana.buildSendThrottler(sendRate);
1702
+ }
1703
+ getConnection() {
1704
+ return this.connection;
1705
+ }
1706
+ getCommitment() {
1707
+ return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
1708
+ }
1709
+ getDistributorProgramId() {
1710
+ return this.programId;
1711
+ }
1712
+ async prepareCreateInstructions(data, extParams) {
1713
+ if (!extParams.invoker.publicKey) {
1714
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
1715
+ }
1716
+ const { version, mint } = data;
1717
+ const ixs = solana.prepareBaseInstructions(this.connection, extParams);
1718
+ const mintPublicKey = extParams.isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
1719
+ const { mint: mintAccount, tokenProgramId } = await solana.getMintAndProgram(this.connection, mintPublicKey);
1720
+ const transferFeeConfig = splToken.getTransferFeeConfig(mintAccount);
1721
+ const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
1722
+ const tokenVault = await solana.ata(mintPublicKey, distributorPublicKey, tokenProgramId);
1723
+ const senderTokens = await solana.ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
1724
+ const accounts = {
1725
+ distributor: distributorPublicKey,
1726
+ clawbackReceiver: senderTokens,
1727
+ mint: mintPublicKey,
1728
+ tokenVault,
1729
+ admin: extParams.invoker.publicKey,
1730
+ systemProgram: web3_js.SystemProgram.programId,
1731
+ associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
1732
+ tokenProgram: tokenProgramId
1733
+ };
1734
+ if (extParams.isNative) {
1735
+ ixs.push(
1736
+ ...await solana.prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN6__default.default(data.maxTotalClaim))
1737
+ );
1738
+ }
1739
+ const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
1740
+ ixs.push(newDistributorInstruction);
1741
+ if (transferFeeConfig) {
1742
+ const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(
1743
+ this.connection,
1744
+ transferFeeConfig,
1745
+ BigInt(data.maxTotalClaim.toString())
1746
+ );
1747
+ ixs.push(
1748
+ splToken.createTransferCheckedWithFeeInstruction(
1749
+ senderTokens,
1750
+ mintPublicKey,
1751
+ tokenVault,
1752
+ extParams.invoker.publicKey,
1753
+ transferAmount,
1754
+ mintAccount.decimals,
1755
+ feeCharged,
1756
+ void 0,
1757
+ tokenProgramId
1758
+ )
1759
+ );
1760
+ } else {
1761
+ ixs.push(
1762
+ splToken.createTransferCheckedInstruction(
1763
+ senderTokens,
1764
+ mintPublicKey,
1765
+ tokenVault,
1766
+ extParams.invoker.publicKey,
1767
+ BigInt(data.maxTotalClaim.toString()),
1768
+ mintAccount.decimals,
1769
+ void 0,
1770
+ tokenProgramId
1771
+ )
1772
+ );
1773
+ }
1774
+ return { distributorPublicKey, ixs };
1775
+ }
1776
+ async create(data, extParams) {
1777
+ const invoker = extParams.invoker.publicKey;
1778
+ common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
1779
+ const executionParams = this.unwrapExecutionParams(extParams);
1780
+ const { ixs, distributorPublicKey } = await solana.createAndEstimateTransaction(
1781
+ (params) => this.prepareCreateInstructions(data, params),
1782
+ executionParams,
1783
+ (q) => q.ixs
1784
+ );
1785
+ const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
1786
+ const signature = await wrappedSignAndExecuteTransaction(
1787
+ this.connection,
1788
+ extParams.invoker,
1789
+ tx,
1790
+ {
1791
+ hash,
1792
+ context,
1793
+ commitment: this.getCommitment()
1794
+ },
1795
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1796
+ );
1797
+ return {
1798
+ ixs,
1799
+ txId: signature,
1800
+ metadataId: distributorPublicKey.toBase58()
1801
+ };
1802
+ }
1803
+ async claim(data, extParams) {
1804
+ const executionParams = this.unwrapExecutionParams(extParams);
1805
+ const invoker = executionParams.invoker.publicKey;
1806
+ common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
1807
+ const ixs = await solana.createAndEstimateTransaction(
1808
+ (params) => this.prepareClaimInstructions(data, params),
1809
+ executionParams
1810
+ );
1811
+ const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker);
1812
+ const signature = await wrappedSignAndExecuteTransaction(
1813
+ this.connection,
1814
+ executionParams.invoker,
1815
+ tx,
1816
+ {
1817
+ hash,
1818
+ context,
1819
+ commitment: this.getCommitment()
1820
+ },
1821
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1822
+ );
1823
+ return { ixs, txId: signature };
1824
+ }
1825
+ async prepareClaimInstructions(data, extParams) {
1826
+ if (!extParams.invoker.publicKey) {
1827
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
1828
+ }
1829
+ const distributorPublicKey = new web3_js.PublicKey(data.id);
1830
+ const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
1831
+ if (!distributor) {
1832
+ throw new Error("Couldn't get account info");
1833
+ }
1834
+ const { tokenProgramId } = await solana.getMintAndProgram(this.connection, distributor.mint);
1835
+ const ixs = solana.prepareBaseInstructions(this.connection, extParams);
1836
+ ixs.push(
1837
+ ...await solana.checkOrCreateAtaBatch(
1838
+ this.connection,
1839
+ [extParams.invoker.publicKey],
1840
+ distributor.mint,
1841
+ extParams.invoker,
1842
+ tokenProgramId
1843
+ )
1844
+ );
1845
+ const invokerTokens = await solana.ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
1846
+ const claimStatusPublicKey = getClaimantStatusPda(
1847
+ this.programId,
1848
+ distributorPublicKey,
1849
+ extParams.invoker.publicKey
1850
+ );
1851
+ const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
1852
+ const claimStatus = await ClaimStatus.fetch(this.connection, claimStatusPublicKey);
1853
+ const accounts = {
1854
+ distributor: distributorPublicKey,
1855
+ claimStatus: claimStatusPublicKey,
1856
+ from: distributor.tokenVault,
1857
+ to: invokerTokens,
1858
+ claimant: extParams.invoker.publicKey,
1859
+ mint: distributor.mint,
1860
+ tokenProgram: tokenProgramId,
1861
+ systemProgram: web3_js.SystemProgram.programId,
1862
+ eventAuthority: eventAuthorityPublicKey,
1863
+ program: this.programId
1864
+ };
1865
+ if (!claimStatus) {
1866
+ const args = {
1867
+ amountLocked: new BN6__default.default(data.amountLocked),
1868
+ amountUnlocked: new BN6__default.default(data.amountUnlocked),
1869
+ proof: data.proof
1870
+ };
1871
+ ixs.push(newClaim(args, accounts, this.programId));
1872
+ }
1873
+ const nowTs = new BN6__default.default(Math.floor(Date.now() / 1e3));
1874
+ if (claimStatus || new BN6__default.default(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
1875
+ ixs.push(claimLocked(accounts, this.programId));
1876
+ }
1877
+ ixs.push(this.prepareClaimFeeInstruction(extParams.invoker.publicKey));
1878
+ return ixs;
1879
+ }
1880
+ async closeClaim(data, extParams) {
1881
+ const executionParams = this.unwrapExecutionParams(extParams);
1882
+ const invoker = executionParams.invoker.publicKey;
1883
+ common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
1884
+ const ixs = await solana.createAndEstimateTransaction(
1885
+ (params) => this.prepareCloseClaimInstructions(data, params),
1886
+ executionParams
1887
+ );
1888
+ const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker);
1889
+ const signature = await wrappedSignAndExecuteTransaction(
1890
+ this.connection,
1891
+ executionParams.invoker,
1892
+ tx,
1893
+ {
1894
+ hash,
1895
+ context,
1896
+ commitment: this.getCommitment()
1897
+ },
1898
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1899
+ );
1900
+ return { ixs, txId: signature };
1901
+ }
1902
+ async prepareCloseClaimInstructions(data, extParams) {
1903
+ if (!extParams.invoker.publicKey) {
1904
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
1905
+ }
1906
+ const distributorPublicKey = new web3_js.PublicKey(data.id);
1907
+ const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
1908
+ const claimantPublicKey = solana.pk(data.claimant);
1909
+ if (!distributor) {
1910
+ throw new Error("Couldn't get distributor account info");
1911
+ }
1912
+ const ixs = solana.prepareBaseInstructions(this.connection, extParams);
1913
+ const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, claimantPublicKey);
1914
+ const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
1915
+ const closeClaimAccounts = {
1916
+ adminOrClaimant: extParams.invoker.publicKey,
1917
+ distributor: distributorPublicKey,
1918
+ claimStatus: claimStatusPublicKey,
1919
+ claimant: claimantPublicKey,
1920
+ systemProgram: web3_js.SystemProgram.programId,
1921
+ eventAuthority: eventAuthorityPublicKey,
1922
+ program: this.programId
1923
+ };
1924
+ const closeClaimArgs = {
1925
+ amountLocked: data.amountLocked ? new BN6__default.default(data.amountLocked) : void 0,
1926
+ amountUnlocked: data.amountUnlocked ? new BN6__default.default(data.amountUnlocked) : void 0,
1927
+ proof: data.proof
1928
+ };
1929
+ ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
1930
+ return ixs;
1931
+ }
1932
+ async prepareClawbackInstructions(data, extParams) {
1933
+ if (!extParams.invoker.publicKey) {
1934
+ throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
1935
+ }
1936
+ const distributorPublicKey = new web3_js.PublicKey(data.id);
1937
+ const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
1938
+ if (!distributor) {
1939
+ throw new Error("Couldn't get account info");
1940
+ }
1941
+ const { tokenProgramId } = await solana.getMintAndProgram(this.connection, distributor.mint);
1942
+ const ixs = solana.prepareBaseInstructions(this.connection, extParams);
1943
+ ixs.push(
1944
+ ...await solana.checkOrCreateAtaBatch(
1945
+ this.connection,
1946
+ [extParams.invoker.publicKey],
1947
+ distributor.mint,
1948
+ extParams.invoker,
1949
+ tokenProgramId
1950
+ )
1951
+ );
1952
+ const accounts = {
1953
+ distributor: distributorPublicKey,
1954
+ from: distributor.tokenVault,
1955
+ to: distributor.clawbackReceiver,
1956
+ admin: extParams.invoker.publicKey,
1957
+ mint: distributor.mint,
1958
+ systemProgram: web3_js.SystemProgram.programId,
1959
+ tokenProgram: tokenProgramId
1960
+ };
1961
+ const clawbackInstruction = await this.getClawbackInstruction(accounts);
1962
+ ixs.push(clawbackInstruction);
1963
+ return ixs;
1964
+ }
1965
+ async clawback(data, extParams) {
1966
+ const executionParams = this.unwrapExecutionParams(extParams);
1967
+ const invoker = executionParams.invoker.publicKey;
1968
+ common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
1969
+ const ixs = await solana.createAndEstimateTransaction(
1970
+ (params) => this.prepareClawbackInstructions(data, params),
1971
+ executionParams
1972
+ );
1973
+ const { tx, hash, context } = await solana.prepareTransaction(this.connection, ixs, invoker);
1974
+ const signature = await wrappedSignAndExecuteTransaction(
1975
+ this.connection,
1976
+ executionParams.invoker,
1977
+ tx,
1978
+ {
1979
+ hash,
1980
+ context,
1981
+ commitment: this.getCommitment()
1982
+ },
1983
+ { sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
1984
+ );
1985
+ return { ixs, txId: signature };
1986
+ }
1987
+ async getClaims(data) {
1988
+ const claimStatusPublicKeys = data.map(({ id, recipient }) => {
1989
+ return getClaimantStatusPda(this.programId, new web3_js.PublicKey(id), new web3_js.PublicKey(recipient));
1990
+ });
1991
+ return ClaimStatus.fetchMultiple(this.connection, claimStatusPublicKeys, this.programId);
1992
+ }
1993
+ async getDistributors(data) {
1994
+ const distributorPublicKeys = data.ids.map((distributorId) => new web3_js.PublicKey(distributorId));
1995
+ return MerkleDistributor.fetchMultiple(this.connection, distributorPublicKeys, this.programId);
1996
+ }
1997
+ async searchDistributors(data) {
1998
+ const filters = [{ memcmp: { offset: 0, bytes: bs58__default.default.encode(MerkleDistributor.discriminator) } }];
1999
+ if (data.mint) {
2000
+ filters.push({
2001
+ memcmp: {
2002
+ offset: DISTRIBUTOR_MINT_OFFSET,
2003
+ bytes: data.mint
2004
+ }
2005
+ });
2006
+ }
2007
+ if (data.admin) {
2008
+ filters.push({
2009
+ memcmp: {
2010
+ offset: DISTRIBUTOR_ADMIN_OFFSET,
2011
+ bytes: data.admin
2012
+ }
2013
+ });
2014
+ }
2015
+ const accounts = await this.connection.getProgramAccounts(this.programId, { filters });
2016
+ return accounts.map(({ pubkey, account }) => ({
2017
+ publicKey: pubkey,
2018
+ account: MerkleDistributor.decode(account.data)
2019
+ }));
2020
+ }
2021
+ prepareClaimFeeInstruction(payer) {
2022
+ return web3_js.SystemProgram.transfer({
2023
+ fromPubkey: payer,
2024
+ toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
2025
+ lamports: AIRDROP_CLAIM_FEE
2026
+ });
2027
+ }
2028
+ getNewDistributorArgs(data) {
2029
+ const args = {
2030
+ version: new BN6__default.default(data.version),
2031
+ root: data.root,
2032
+ maxTotalClaim: new BN6__default.default(data.maxTotalClaim),
2033
+ maxNumNodes: new BN6__default.default(data.maxNumNodes),
2034
+ unlockPeriod: new BN6__default.default(data.unlockPeriod),
2035
+ startVestingTs: new BN6__default.default(data.startVestingTs),
2036
+ endVestingTs: new BN6__default.default(data.endVestingTs),
2037
+ clawbackStartTs: new BN6__default.default(data.clawbackStartTs),
2038
+ claimsClosableByAdmin: data.claimsClosableByAdmin,
2039
+ claimsClosableByClaimant: data.claimsClosableByClaimant,
2040
+ claimsLimit: data.claimsLimit
2041
+ };
2042
+ const nowTs = new BN6__default.default(Math.floor(Date.now() / 1e3));
2043
+ const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
2044
+ const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
2045
+ if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
2046
+ throw new Error("The unlock period cannot be longer than the total vesting duration!");
2047
+ }
2048
+ return args;
2049
+ }
2050
+ unwrapExecutionParams(extParams) {
2051
+ return solana.unwrapExecutionParams(extParams, this.connection);
2052
+ }
2053
+ };
2054
+
2055
+ // solana/clients/SolanaDistributorClient.ts
2056
+ var SolanaDistributorClient = class extends BaseDistributorClient {
2057
+ async getNewDistributorInstruction(data, accounts) {
2058
+ const args = this.getNewDistributorArgs(data);
2059
+ return newDistributor(args, accounts, this.programId);
2060
+ }
2061
+ async getClawbackInstruction(accounts) {
2062
+ return clawback(accounts, this.programId);
2063
+ }
2064
+ };
2065
+
2066
+ // solana/descriptor/idl/aligned_distributor.json
2067
+ var aligned_distributor_default = {
2068
+ address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
2069
+ metadata: {
2070
+ name: "aligned_distributor",
2071
+ version: "1.3.2",
2072
+ spec: "0.1.0",
2073
+ description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
2074
+ },
2075
+ instructions: [
2076
+ {
2077
+ name: "change_oracle",
2078
+ discriminator: [177, 227, 230, 103, 13, 72, 141, 248],
2079
+ accounts: [
2080
+ {
2081
+ name: "aligned_distributor",
2082
+ docs: ["The [MerkleDistributor]."],
2083
+ writable: true
2084
+ },
2085
+ {
2086
+ name: "admin",
2087
+ docs: ["Admin signer"],
2088
+ writable: true,
2089
+ signer: true
2090
+ },
2091
+ {
2092
+ name: "new_price_oracle"
2093
+ }
2094
+ ],
2095
+ args: [
2096
+ {
2097
+ name: "ix",
2098
+ type: {
2099
+ defined: {
2100
+ name: "ChangeOracleParams"
2101
+ }
2102
+ }
2103
+ }
2104
+ ]
2105
+ },
2106
+ {
2107
+ name: "clawback",
2108
+ discriminator: [111, 92, 142, 79, 33, 234, 82, 27],
2109
+ accounts: [
2110
+ {
2111
+ name: "aligned_distributor",
2112
+ docs: ["The [AlignedDistributor]."],
2113
+ writable: true,
2114
+ pda: {
2115
+ seeds: [
2116
+ {
2117
+ kind: "const",
2118
+ value: [97, 108, 105, 103, 110, 101, 100, 45, 100, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
2119
+ },
2120
+ {
2121
+ kind: "account",
2122
+ path: "distributor"
2123
+ }
2124
+ ]
2125
+ }
2126
+ },
2127
+ {
2128
+ name: "distributor",
2129
+ docs: ["The [MerkleDistributor]."],
2130
+ writable: true
2131
+ },
2132
+ {
2133
+ name: "from",
2134
+ docs: ["Distributor ATA containing the tokens to distribute."],
2135
+ writable: true
2136
+ },
2137
+ {
2138
+ name: "to",
2139
+ docs: ["The Clawback token account."],
2140
+ writable: true
2141
+ },
2142
+ {
2143
+ name: "admin",
2144
+ docs: ["Only Admin can trigger the clawback of funds"],
2145
+ writable: true,
2146
+ signer: true
2147
+ },
2148
+ {
2149
+ name: "mint"
2150
+ },
2151
+ {
2152
+ name: "distributor_program",
2153
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
2154
+ },
2155
+ {
2156
+ name: "system_program",
2157
+ docs: ["The [System] program."],
2158
+ address: "11111111111111111111111111111111"
2159
+ },
2160
+ {
2161
+ name: "token_program",
2162
+ docs: ["SPL [Token] program."]
2163
+ }
2164
+ ],
2165
+ args: []
2166
+ },
2167
+ {
2168
+ name: "create_test_oracle",
2169
+ discriminator: [183, 110, 4, 11, 131, 220, 84, 12],
2170
+ accounts: [
2171
+ {
2172
+ name: "creator",
2173
+ writable: true,
2174
+ signer: true
2175
+ },
2176
+ {
2177
+ name: "mint"
2178
+ },
2179
+ {
2180
+ name: "test_oracle",
2181
+ writable: true,
2182
+ pda: {
2183
+ seeds: [
2184
+ {
2185
+ kind: "const",
2186
+ value: [116, 101, 115, 116, 45, 111, 114, 97, 99, 108, 101]
2187
+ },
2188
+ {
2189
+ kind: "account",
2190
+ path: "mint"
2191
+ },
2192
+ {
2193
+ kind: "account",
2194
+ path: "creator"
2195
+ }
2196
+ ]
2197
+ }
2198
+ },
2199
+ {
2200
+ name: "system_program",
2201
+ address: "11111111111111111111111111111111"
2202
+ }
2203
+ ],
2204
+ args: [
2205
+ {
2206
+ name: "ix",
2207
+ type: {
2208
+ defined: {
2209
+ name: "CreateTestOracleParams"
2210
+ }
2211
+ }
2212
+ }
2213
+ ]
2214
+ },
2215
+ {
2216
+ name: "new_distributor",
2217
+ discriminator: [32, 139, 112, 171, 0, 2, 225, 155],
2218
+ accounts: [
2219
+ {
2220
+ name: "aligned_distributor",
2221
+ writable: true,
2222
+ pda: {
2223
+ seeds: [
2224
+ {
2225
+ kind: "const",
2226
+ value: [97, 108, 105, 103, 110, 101, 100, 45, 100, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
2227
+ },
2228
+ {
2229
+ kind: "account",
2230
+ path: "distributor"
2231
+ }
2232
+ ]
2233
+ }
2234
+ },
2235
+ {
2236
+ name: "price_oracle"
2237
+ },
2238
+ {
2239
+ name: "withdrawor",
2240
+ writable: true,
2241
+ address: "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u"
2242
+ },
2243
+ {
2244
+ name: "clawback_receiver",
2245
+ docs: ["Clawback receiver token account"],
2246
+ writable: true
2247
+ },
2248
+ {
2249
+ name: "mint",
2250
+ docs: ["The mint to distribute."]
2251
+ },
2252
+ {
2253
+ name: "distributor",
2254
+ writable: true
2255
+ },
2256
+ {
2257
+ name: "token_vault",
2258
+ writable: true
2259
+ },
2260
+ {
2261
+ name: "admin",
2262
+ docs: [
2263
+ "Original Admin wallet, responsible for creating the distributor and paying for the transaction.",
2264
+ "Also has the authority to set the clawback receiver and change itself."
2265
+ ],
2266
+ writable: true,
2267
+ signer: true
2268
+ },
2269
+ {
2270
+ name: "distributor_program",
2271
+ docs: ["MerkleDistributor program"],
2272
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
2273
+ },
2274
+ {
2275
+ name: "system_program",
2276
+ docs: ["The [System] program."],
2277
+ address: "11111111111111111111111111111111"
2278
+ },
2279
+ {
2280
+ name: "associated_token_program",
2281
+ docs: ["The [Associated Token] program."],
2282
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
2283
+ },
2284
+ {
2285
+ name: "token_program",
2286
+ docs: ["The [Token] program."]
2287
+ }
2288
+ ],
2289
+ args: [
2290
+ {
2291
+ name: "ix",
2292
+ type: {
2293
+ defined: {
2294
+ name: "NewDistributorIx"
2295
+ }
2296
+ }
2297
+ }
2298
+ ]
2299
+ },
2300
+ {
2301
+ name: "set_admin",
2302
+ discriminator: [251, 163, 0, 52, 91, 194, 187, 92],
2303
+ accounts: [
2304
+ {
2305
+ name: "aligned_distributor",
2306
+ docs: ["The [MerkleDistributor]."],
2307
+ writable: true
2308
+ },
2309
+ {
2310
+ name: "admin",
2311
+ docs: ["Admin signer"],
2312
+ writable: true,
2313
+ signer: true
2314
+ },
2315
+ {
2316
+ name: "new_admin",
2317
+ docs: ["New admin account"],
2318
+ writable: true
2319
+ }
2320
+ ],
2321
+ args: []
2322
+ },
2323
+ {
2324
+ name: "set_test_oracle_authority",
2325
+ discriminator: [26, 66, 233, 99, 38, 118, 181, 247],
2326
+ accounts: [
2327
+ {
2328
+ name: "authority",
2329
+ writable: true,
2330
+ signer: true
2331
+ },
2332
+ {
2333
+ name: "test_oracle",
2334
+ writable: true
2335
+ },
2336
+ {
2337
+ name: "new_authority"
2338
+ }
2339
+ ],
2340
+ args: []
2341
+ },
2342
+ {
2343
+ name: "update_duration",
2344
+ discriminator: [69, 126, 172, 250, 164, 14, 10, 161],
2345
+ accounts: [
2346
+ {
2347
+ name: "authority",
2348
+ docs: ["Wallet authorised to call this method"],
2349
+ writable: true,
2350
+ signer: true
2351
+ },
2352
+ {
2353
+ name: "aligned_distributor",
2354
+ docs: ["The account holding the proxy parameters."],
2355
+ writable: true,
2356
+ pda: {
2357
+ seeds: [
2358
+ {
2359
+ kind: "const",
2360
+ value: [97, 108, 105, 103, 110, 101, 100, 45, 100, 105, 115, 116, 114, 105, 98, 117, 116, 111, 114]
2361
+ },
2362
+ {
2363
+ kind: "account",
2364
+ path: "distributor"
2365
+ }
2366
+ ]
2367
+ }
2368
+ },
2369
+ {
2370
+ name: "distributor",
2371
+ docs: ["The account holding the vesting parameters."],
2372
+ writable: true
2373
+ },
2374
+ {
2375
+ name: "price_oracle",
2376
+ relations: ["aligned_distributor"]
2377
+ },
2378
+ {
2379
+ name: "distributor_program",
2380
+ docs: ["MerkleDistributor program"],
2381
+ address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N"
2382
+ },
2383
+ {
2384
+ name: "system_program",
2385
+ address: "11111111111111111111111111111111"
2386
+ }
2387
+ ],
2388
+ args: []
2389
+ },
2390
+ {
2391
+ name: "update_test_oracle",
2392
+ discriminator: [158, 147, 215, 74, 34, 123, 80, 76],
2393
+ accounts: [
2394
+ {
2395
+ name: "authority",
2396
+ writable: true,
2397
+ signer: true
2398
+ },
2399
+ {
2400
+ name: "test_oracle",
2401
+ writable: true
2402
+ }
2403
+ ],
2404
+ args: [
2405
+ {
2406
+ name: "ix",
2407
+ type: {
2408
+ defined: {
2409
+ name: "UpdateTestOracleParams"
2410
+ }
2411
+ }
2412
+ }
2413
+ ]
2414
+ }
2415
+ ],
2416
+ accounts: [
2417
+ {
2418
+ name: "AlignedDistributor",
2419
+ discriminator: [128, 76, 80, 203, 248, 175, 3, 43]
2420
+ },
2421
+ {
2422
+ name: "MerkleDistributor",
2423
+ discriminator: [77, 119, 139, 70, 84, 247, 12, 26]
2424
+ },
2425
+ {
2426
+ name: "TestOracle",
2427
+ discriminator: [198, 49, 63, 134, 232, 251, 168, 28]
2428
+ }
2429
+ ],
2430
+ errors: [
2431
+ {
2432
+ code: 6e3,
2433
+ name: "Unauthorized",
2434
+ msg: "Account is not authorized to execute this instruction"
2435
+ },
2436
+ {
2437
+ code: 6001,
2438
+ name: "ArithmeticError",
2439
+ msg: "Arithmetic error"
2440
+ },
2441
+ {
2442
+ code: 6002,
2443
+ name: "NoLockedAmount",
2444
+ msg: "Provided Distributor has no locked amount"
2445
+ },
2446
+ {
2447
+ code: 6003,
2448
+ name: "InvalidUpdatePeriod",
2449
+ msg: "Provided is invalid, should be equal or more than 30 seconds and unlock_period"
2450
+ },
2451
+ {
2452
+ code: 6004,
2453
+ name: "InvalidTickSize",
2454
+ msg: "Provided percentage tick size is invalid"
2455
+ },
2456
+ {
2457
+ code: 6005,
2458
+ name: "InvalidPercentageBoundaries",
2459
+ msg: "Provided percentage bounds are invalid"
2460
+ },
2461
+ {
2462
+ code: 6006,
2463
+ name: "InvalidPriceBoundaries",
2464
+ msg: "Provided price bounds are invalid"
2465
+ },
2466
+ {
2467
+ code: 6007,
2468
+ name: "UnsupportedOracle",
2469
+ msg: "Unsupported price oracle"
2470
+ },
2471
+ {
2472
+ code: 6008,
2473
+ name: "InvalidOracleAccount",
2474
+ msg: "Invalid oracle account"
2475
+ },
2476
+ {
2477
+ code: 6009,
2478
+ name: "InvalidOraclePrice",
2479
+ msg: "Invalid oracle price"
2480
+ },
2481
+ {
2482
+ code: 6010,
2483
+ name: "DurationAlreadyUpdated",
2484
+ msg: "Duration has been already updated in this period"
2485
+ },
2486
+ {
2487
+ code: 6011,
2488
+ name: "VestingAlreadyFinished",
2489
+ msg: "Vesting already finished"
2490
+ },
2491
+ {
2492
+ code: 6012,
2493
+ name: "SameAdmin",
2494
+ msg: "New and old admin are identical"
2495
+ },
2496
+ {
2497
+ code: 6013,
2498
+ name: "InvalidMint",
2499
+ msg: "Invalid Mint"
2500
+ }
2501
+ ],
2502
+ types: [
2503
+ {
2504
+ name: "AlignedDistributor",
2505
+ docs: ["State for the account which distributes tokens."],
2506
+ type: {
2507
+ kind: "struct",
2508
+ fields: [
2509
+ {
2510
+ name: "bump",
2511
+ docs: ["Bump seed."],
2512
+ type: "u8"
2513
+ },
2514
+ {
2515
+ name: "distributor",
2516
+ docs: ["[Mint] of the token to be distributed."],
2517
+ type: "pubkey"
2518
+ },
2519
+ {
2520
+ name: "admin",
2521
+ docs: ["Admin wallet"],
2522
+ type: "pubkey"
2523
+ },
2524
+ {
2525
+ name: "price_oracle_type",
2526
+ docs: ["Type of the Oracle used to derive Token Price"],
2527
+ type: {
2528
+ defined: {
2529
+ name: "OracleType"
2530
+ }
2531
+ }
2532
+ },
2533
+ {
2534
+ name: "price_oracle",
2535
+ docs: ["Address of the Price Oracle"],
2536
+ type: "pubkey"
2537
+ },
2538
+ {
2539
+ name: "update_period",
2540
+ docs: ["Period of updates, can be different from unlock period if needed"],
2541
+ type: "u64"
2542
+ },
2543
+ {
2544
+ name: "min_price",
2545
+ docs: ["Min price boundary"],
2546
+ type: "u64"
2547
+ },
2548
+ {
2549
+ name: "max_price",
2550
+ docs: ["Max price boundary"],
2551
+ type: "u64"
2552
+ },
2553
+ {
2554
+ name: "min_percentage",
2555
+ docs: ["Min percentage boundary, can be 0 that equals 1 Raw Token"],
2556
+ type: "u64"
2557
+ },
2558
+ {
2559
+ name: "max_percentage",
2560
+ docs: ["Max percentage boundary"],
2561
+ type: "u64"
2562
+ },
2563
+ {
2564
+ name: "tick_size",
2565
+ docs: ["Ticket size for percentage boundaries"],
2566
+ type: "u64"
2567
+ },
2568
+ {
2569
+ name: "start_ts",
2570
+ docs: ["Copy start ts from the Distributor to be used in the worker"],
2571
+ type: "u64"
2572
+ },
2573
+ {
2574
+ name: "end_ts",
2575
+ docs: ["Copy end ts from the Distributor to be used in the worker"],
2576
+ type: "u64"
2577
+ },
2578
+ {
2579
+ name: "last_duration_update_ts",
2580
+ docs: [
2581
+ "Copy last_duration_update_ts from Distributor for our worker to be able to fetch it in one call with the proxy"
2582
+ ],
2583
+ type: "u64"
2584
+ },
2585
+ {
2586
+ name: "last_price",
2587
+ docs: ["Price used on last amount calculation"],
2588
+ type: "u64"
2589
+ },
2590
+ {
2591
+ name: "initial_duration",
2592
+ docs: ["Initial Airdrop Vesting duration"],
2593
+ type: "u64"
2594
+ },
2595
+ {
2596
+ name: "initial_price",
2597
+ docs: ["Initial token price at the time of Contract creation"],
2598
+ type: "u64"
2599
+ },
2600
+ {
2601
+ name: "distributor_clawed_back",
2602
+ docs: ["Whether distributor was clawed backed"],
2603
+ type: "bool"
2604
+ },
2605
+ {
2606
+ name: "mint",
2607
+ docs: ["Mint for which the distributor was created"],
2608
+ type: "pubkey"
2609
+ },
2610
+ {
2611
+ name: "buffer_2",
2612
+ docs: ["Buffer for additional fields"],
2613
+ type: {
2614
+ array: ["u8", 32]
2615
+ }
2616
+ },
2617
+ {
2618
+ name: "buffer_3",
2619
+ docs: ["Buffer for additional fields"],
2620
+ type: {
2621
+ array: ["u8", 32]
2622
+ }
2623
+ }
2624
+ ]
2625
+ }
2626
+ },
2627
+ {
2628
+ name: "ChangeOracleParams",
2629
+ type: {
2630
+ kind: "struct",
2631
+ fields: [
2632
+ {
2633
+ name: "oracle_type",
2634
+ type: {
2635
+ defined: {
2636
+ name: "OracleType"
2637
+ }
2638
+ }
2639
+ }
2640
+ ]
2641
+ }
2642
+ },
2643
+ {
2644
+ name: "CreateTestOracleParams",
2645
+ type: {
2646
+ kind: "struct",
2647
+ fields: [
2648
+ {
2649
+ name: "price",
2650
+ type: "u64"
2651
+ },
2652
+ {
2653
+ name: "expo",
2654
+ type: "i32"
2655
+ },
2656
+ {
2657
+ name: "conf",
2658
+ type: "u64"
2659
+ },
2660
+ {
2661
+ name: "publish_time",
2662
+ type: "i64"
2663
+ }
2664
+ ]
2665
+ }
2666
+ },
2667
+ {
2668
+ name: "MerkleDistributor",
2669
+ docs: ["State for the account which distributes tokens."],
2670
+ type: {
2671
+ kind: "struct",
2672
+ fields: [
2673
+ {
2674
+ name: "bump",
2675
+ docs: ["Bump seed."],
2676
+ type: "u8"
2677
+ },
2678
+ {
2679
+ name: "version",
2680
+ docs: ["Version of the airdrop"],
2681
+ type: "u64"
2682
+ },
2683
+ {
2684
+ name: "root",
2685
+ docs: ["The 256-bit merkle root."],
2686
+ type: {
2687
+ array: ["u8", 32]
2688
+ }
2689
+ },
2690
+ {
2691
+ name: "mint",
2692
+ docs: ["[Mint] of the token to be distributed."],
2693
+ type: "pubkey"
2694
+ },
2695
+ {
2696
+ name: "token_vault",
2697
+ docs: ["Token Address of the vault"],
2698
+ type: "pubkey"
2699
+ },
2700
+ {
2701
+ name: "max_total_claim",
2702
+ docs: ["Maximum number of tokens that can ever be claimed from this [MerkleDistributor]."],
2703
+ type: "u64"
2704
+ },
2705
+ {
2706
+ name: "max_num_nodes",
2707
+ docs: ["Maximum number of nodes in [MerkleDistributor]."],
2708
+ type: "u64"
2709
+ },
2710
+ {
2711
+ name: "unlock_period",
2712
+ docs: ["Time step (period) in seconds per which the unlock occurs"],
2713
+ type: "u64"
2714
+ },
2715
+ {
2716
+ name: "total_amount_claimed",
2717
+ docs: ["Total amount of tokens that have been claimed."],
2718
+ type: "u64"
2719
+ },
2720
+ {
2721
+ name: "num_nodes_claimed",
2722
+ docs: ["Number of nodes that have been claimed."],
2723
+ type: "u64"
2724
+ },
2725
+ {
2726
+ name: "start_ts",
2727
+ docs: ["Lockup time start (Unix Timestamp)"],
2728
+ type: "u64"
2729
+ },
2730
+ {
2731
+ name: "end_ts",
2732
+ docs: ["Lockup time end (Unix Timestamp)"],
2733
+ type: "u64"
2734
+ },
2735
+ {
2736
+ name: "clawback_start_ts",
2737
+ docs: ["Clawback start (Unix Timestamp)"],
2738
+ type: "u64"
2739
+ },
2740
+ {
2741
+ name: "clawback_receiver",
2742
+ docs: ["Clawback receiver"],
2743
+ type: "pubkey"
2744
+ },
2745
+ {
2746
+ name: "admin",
2747
+ docs: ["Admin wallet"],
2748
+ type: "pubkey"
2749
+ },
2750
+ {
2751
+ name: "clawed_back",
2752
+ docs: ["Whether or not the distributor has been clawed back"],
2753
+ type: "bool"
2754
+ },
2755
+ {
2756
+ name: "claims_closable_by_admin",
2757
+ docs: ["Whether claims are closable by the admin or not"],
2758
+ type: "bool"
2759
+ },
2760
+ {
2761
+ name: "can_update_duration",
2762
+ docs: ["Whether admin can update vesting duration"],
2763
+ type: "bool"
2764
+ },
2765
+ {
2766
+ name: "total_amount_unlocked",
2767
+ docs: ["Total amount of funds unlocked (cliff/instant)"],
2768
+ type: "u64"
2769
+ },
2770
+ {
2771
+ name: "total_amount_locked",
2772
+ docs: ["Total amount of funds locked (vested)"],
2773
+ type: "u64"
2774
+ },
2775
+ {
2776
+ name: "last_duration_update_ts",
2777
+ docs: ["Timestamp when update was last called"],
2778
+ type: "u64"
2779
+ },
2780
+ {
2781
+ name: "total_claimable_pre_update",
2782
+ docs: [
2783
+ "Total amount of locked amount claimable as of last duration update, ever increasing total, accumulates with each update"
2784
+ ],
2785
+ type: "u64"
2786
+ },
2787
+ {
2788
+ name: "clawed_back_ts",
2789
+ docs: ["Timestamp when funds were clawed back"],
2790
+ type: "u64"
2791
+ },
2792
+ {
2793
+ name: "claims_closable_by_claimant",
2794
+ docs: ["Whether claims are closable by claimant or not"],
2795
+ type: "bool"
2796
+ },
2797
+ {
2798
+ name: "claims_limit",
2799
+ docs: ["Limit number of claims"],
2800
+ type: "u16"
2801
+ },
2802
+ {
2803
+ name: "buffer_2",
2804
+ docs: ["Buffer for additional fields"],
2805
+ type: {
2806
+ array: ["u8", 20]
2807
+ }
2808
+ },
2809
+ {
2810
+ name: "buffer_3",
2811
+ docs: ["Buffer for additional fields"],
2812
+ type: {
2813
+ array: ["u8", 32]
2814
+ }
2815
+ }
2816
+ ]
2817
+ }
2818
+ },
2819
+ {
2820
+ name: "NewDistributorIx",
2821
+ type: {
2822
+ kind: "struct",
2823
+ fields: [
2824
+ {
2825
+ name: "version",
2826
+ type: "u64"
2827
+ },
2828
+ {
2829
+ name: "root",
2830
+ type: {
2831
+ array: ["u8", 32]
2832
+ }
2833
+ },
2834
+ {
2835
+ name: "max_total_claim",
2836
+ type: "u64"
2837
+ },
2838
+ {
2839
+ name: "max_num_nodes",
2840
+ type: "u64"
2841
+ },
2842
+ {
2843
+ name: "unlock_period",
2844
+ type: "u64"
2845
+ },
2846
+ {
2847
+ name: "start_vesting_ts",
2848
+ type: "u64"
2849
+ },
2850
+ {
2851
+ name: "end_vesting_ts",
2852
+ type: "u64"
2853
+ },
2854
+ {
2855
+ name: "clawback_start_ts",
2856
+ type: "u64"
2857
+ },
2858
+ {
2859
+ name: "claims_closable",
2860
+ type: "bool"
2861
+ },
2862
+ {
2863
+ name: "total_amount_unlocked",
2864
+ type: "u64"
2865
+ },
2866
+ {
2867
+ name: "total_amount_locked",
2868
+ type: "u64"
2869
+ },
2870
+ {
2871
+ name: "update_period",
2872
+ type: "u64"
2873
+ },
2874
+ {
2875
+ name: "oracle_type",
2876
+ type: {
2877
+ defined: {
2878
+ name: "OracleType"
2879
+ }
2880
+ }
2881
+ },
2882
+ {
2883
+ name: "min_price",
2884
+ type: "u64"
2885
+ },
2886
+ {
2887
+ name: "max_price",
2888
+ type: "u64"
2889
+ },
2890
+ {
2891
+ name: "min_percentage",
2892
+ type: "u64"
2893
+ },
2894
+ {
2895
+ name: "max_percentage",
2896
+ type: "u64"
2897
+ },
2898
+ {
2899
+ name: "tick_size",
2900
+ type: "u64"
2901
+ },
2902
+ {
2903
+ name: "skip_initial",
2904
+ type: "bool"
2905
+ }
2906
+ ]
2907
+ }
2908
+ },
2909
+ {
2910
+ name: "OracleType",
2911
+ type: {
2912
+ kind: "enum",
2913
+ variants: [
2914
+ {
2915
+ name: "None"
2916
+ },
2917
+ {
2918
+ name: "Test"
2919
+ },
2920
+ {
2921
+ name: "Pyth"
2922
+ },
2923
+ {
2924
+ name: "Switchboard"
2925
+ }
2926
+ ]
2927
+ }
2928
+ },
2929
+ {
2930
+ name: "TestOracle",
2931
+ type: {
2932
+ kind: "struct",
2933
+ fields: [
2934
+ {
2935
+ name: "price",
2936
+ type: "u64"
2937
+ },
2938
+ {
2939
+ name: "expo",
2940
+ type: "i32"
2941
+ },
2942
+ {
2943
+ name: "conf",
2944
+ type: "u64"
2945
+ },
2946
+ {
2947
+ name: "publish_time",
2948
+ type: "i64"
2949
+ },
2950
+ {
2951
+ name: "creator",
2952
+ type: "pubkey"
2953
+ },
2954
+ {
2955
+ name: "authority",
2956
+ type: "pubkey"
2957
+ },
2958
+ {
2959
+ name: "mint",
2960
+ type: "pubkey"
2961
+ }
2962
+ ]
2963
+ }
2964
+ },
2965
+ {
2966
+ name: "UpdateTestOracleParams",
2967
+ type: {
2968
+ kind: "struct",
2969
+ fields: [
2970
+ {
2971
+ name: "price",
2972
+ type: "u64"
2973
+ },
2974
+ {
2975
+ name: "expo",
2976
+ type: "i32"
2977
+ },
2978
+ {
2979
+ name: "conf",
2980
+ type: "u64"
2981
+ },
2982
+ {
2983
+ name: "publish_time",
2984
+ type: "i64"
2985
+ }
2986
+ ]
2987
+ }
2988
+ }
2989
+ ]
2990
+ };
2991
+
2992
+ // solana/clients/SolanaAlignedDistributorClient.ts
2993
+ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
2994
+ constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }) {
2995
+ super({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler });
2996
+ const alignedAirdropsProgram = {
2997
+ ...aligned_distributor_default
2998
+ };
2999
+ this.alignedProxyProgram = new anchor.Program(alignedAirdropsProgram, { connection: this.connection });
3000
+ }
3001
+ getAlignedDistributorProgramId() {
3002
+ return this.alignedProxyProgram.programId;
3003
+ }
3004
+ getAlignedDistributorAddress(distributorAddress) {
3005
+ const distributorKey = new web3_js.PublicKey(distributorAddress);
3006
+ return getAlignedDistributorPda(this.alignedProxyProgram.programId, distributorKey);
3007
+ }
3008
+ async getAlignedDistributorData(distributorAddress) {
3009
+ const alignedDistributorKey = this.getAlignedDistributorAddress(distributorAddress);
3010
+ const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
3011
+ common.invariant(alignedProxy, "Aligned Distributor proxy account not found");
3012
+ const oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key);
3013
+ return {
3014
+ oracleType,
3015
+ minPrice: common.getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW),
3016
+ maxPrice: common.getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW),
3017
+ minPercentage: common.getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW),
3018
+ maxPercentage: common.getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
3019
+ priceOracle: oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58(),
3020
+ sender: alignedProxy.admin.toBase58(),
3021
+ updatePeriod: common.getNumberFromBN(alignedProxy.updatePeriod, ALIGNED_PRECISION_FACTOR_POW),
3022
+ clawedBack: alignedProxy.distributorClawedBack,
3023
+ initialDuration: alignedProxy.initialDuration.toNumber(),
3024
+ initialPrice: common.getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW),
3025
+ lastPrice: common.getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW),
3026
+ lastDurationUpdateTs: alignedProxy.lastDurationUpdateTs.toNumber()
3027
+ };
3028
+ }
3029
+ async getNewDistributorInstruction(data, accounts) {
3030
+ const { distributor, mint, clawbackReceiver, tokenProgram, tokenVault, admin } = accounts;
3031
+ const baseArgs = this.getNewDistributorArgs(data);
3032
+ const alignedArgs = this.getNewAlignedDistributorArgs(data);
3033
+ const oracle = data.oracleAddress ? new web3_js.PublicKey(data.oracleAddress) : getTestOraclePda(this.alignedProxyProgram.programId, mint, admin);
3034
+ const newDistributorIx = await this.alignedProxyProgram.methods.newDistributor({
3035
+ claimsClosable: baseArgs.claimsClosableByAdmin,
3036
+ version: baseArgs.version,
3037
+ root: baseArgs.root,
3038
+ maxTotalClaim: baseArgs.maxTotalClaim,
3039
+ maxNumNodes: baseArgs.maxNumNodes,
3040
+ unlockPeriod: baseArgs.unlockPeriod,
3041
+ startVestingTs: baseArgs.startVestingTs,
3042
+ endVestingTs: baseArgs.endVestingTs,
3043
+ clawbackStartTs: baseArgs.clawbackStartTs,
3044
+ ...alignedArgs
3045
+ }).accounts({
3046
+ admin,
3047
+ tokenVault,
3048
+ distributor,
3049
+ clawbackReceiver,
3050
+ mint,
3051
+ tokenProgram,
3052
+ priceOracle: oracle
3053
+ }).instruction();
3054
+ return newDistributorIx;
3055
+ }
3056
+ async getClawbackInstruction(accounts) {
3057
+ const { distributor, from, to, mint, tokenProgram, admin } = accounts;
3058
+ const alignedDistributorKey = getAlignedDistributorPda(this.alignedProxyProgram.programId, distributor);
3059
+ const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
3060
+ common.invariant(alignedProxy, "Aligned Distributor proxy account not found");
3061
+ const clawbackInstruction = await this.alignedProxyProgram.methods.clawback().accounts({
3062
+ admin,
3063
+ distributor,
3064
+ from,
3065
+ to,
3066
+ mint,
3067
+ tokenProgram
3068
+ }).instruction();
3069
+ return clawbackInstruction;
3070
+ }
3071
+ getNewAlignedDistributorArgs(data) {
3072
+ const {
3073
+ oracleType,
3074
+ minPrice,
3075
+ maxPrice,
3076
+ minPercentage,
3077
+ maxPercentage,
3078
+ tickSize,
3079
+ skipInitial,
3080
+ totalAmountLocked,
3081
+ totalAmountUnlocked,
3082
+ unlockPeriod
3083
+ } = data;
3084
+ return {
3085
+ totalAmountLocked: new BN6__default.default(totalAmountLocked),
3086
+ totalAmountUnlocked: new BN6__default.default(totalAmountUnlocked),
3087
+ oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
3088
+ minPrice: common.getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
3089
+ maxPrice: common.getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
3090
+ minPercentage: common.getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
3091
+ maxPercentage: common.getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
3092
+ tickSize: new BN6__default.default(tickSize || 1),
3093
+ skipInitial: skipInitial ?? false,
3094
+ updatePeriod: unlockPeriod < 30 ? new BN6__default.default(30) : new BN6__default.default(unlockPeriod)
3095
+ };
3096
+ }
3097
+ };
3098
+
3099
+ exports.StreamflowDistributorSolana = solana_exports;
3100
+ //# sourceMappingURL=index.cjs.map
3101
+ //# sourceMappingURL=index.cjs.map