@streamflow/distributor 6.3.8 → 7.0.0-alpha.1
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.
- package/dist/{solana → cjs/solana}/generated/instructions/clawback.js +2 -1
- package/dist/{solana → cjs/solana}/generated/instructions/closeClaim.js +2 -1
- package/dist/{solana → cjs/solana}/generated/instructions/newDistributor.js +4 -3
- package/dist/{solana → cjs/solana}/generated/instructions/setAdmin.js +2 -1
- package/dist/{solana → cjs/solana}/generated/instructions/setClawbackReceiver.js +2 -1
- package/dist/{solana → cjs/solana}/utils.js +5 -4
- package/dist/esm/index.js +1 -0
- package/dist/esm/solana/client.js +188 -0
- package/dist/esm/solana/constants.js +8 -0
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +113 -0
- package/dist/esm/solana/generated/accounts/MerkleDistributor.js +190 -0
- package/dist/esm/solana/generated/accounts/index.js +2 -0
- package/dist/esm/solana/generated/errors/anchor.js +707 -0
- package/dist/esm/solana/generated/errors/custom.js +252 -0
- package/dist/esm/solana/generated/errors/index.js +37 -0
- package/dist/esm/solana/generated/instructions/claimLocked.js +19 -0
- package/dist/esm/solana/generated/instructions/clawback.js +18 -0
- package/dist/esm/solana/generated/instructions/closeClaim.js +18 -0
- package/dist/esm/solana/generated/instructions/index.js +7 -0
- package/dist/esm/solana/generated/instructions/newClaim.js +32 -0
- package/dist/esm/solana/generated/instructions/newDistributor.js +67 -0
- package/dist/esm/solana/generated/instructions/setAdmin.js +14 -0
- package/dist/esm/solana/generated/instructions/setClawbackReceiver.js +14 -0
- package/dist/esm/solana/generated/programId.js +5 -0
- package/dist/esm/solana/index.js +7 -0
- package/dist/esm/solana/types.js +156 -0
- package/dist/esm/solana/utils.js +60 -0
- package/package.json +20 -19
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{solana → cjs/solana}/client.js +0 -0
- /package/dist/{solana → cjs/solana}/constants.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/accounts/ClaimStatus.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/accounts/MerkleDistributor.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/accounts/index.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/errors/anchor.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/errors/custom.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/errors/index.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/instructions/claimLocked.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/instructions/index.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/instructions/newClaim.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/programId.js +0 -0
- /package/dist/{solana → cjs/solana}/index.js +0 -0
- /package/dist/{solana → cjs/solana}/types.js +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{solana → esm/solana}/client.d.ts +0 -0
- /package/dist/{solana → esm/solana}/constants.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/accounts/ClaimStatus.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/accounts/MerkleDistributor.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/accounts/index.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/errors/anchor.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/errors/custom.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/errors/index.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/claimLocked.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/clawback.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/closeClaim.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/index.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/newClaim.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/newDistributor.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/setAdmin.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/instructions/setClawbackReceiver.d.ts +0 -0
- /package/dist/{solana → esm/solana}/generated/programId.d.ts +0 -0
- /package/dist/{solana → esm/solana}/index.d.ts +0 -0
- /package/dist/{solana → esm/solana}/types.d.ts +0 -0
- /package/dist/{solana → esm/solana}/utils.d.ts +0 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
export class InsufficientUnlockedTokens extends Error {
|
|
2
|
+
logs;
|
|
3
|
+
static code = 6000;
|
|
4
|
+
code = 6000;
|
|
5
|
+
name = "InsufficientUnlockedTokens";
|
|
6
|
+
msg = "Insufficient unlocked tokens";
|
|
7
|
+
constructor(logs) {
|
|
8
|
+
super("6000: Insufficient unlocked tokens");
|
|
9
|
+
this.logs = logs;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class InvalidProof extends Error {
|
|
13
|
+
logs;
|
|
14
|
+
static code = 6001;
|
|
15
|
+
code = 6001;
|
|
16
|
+
name = "InvalidProof";
|
|
17
|
+
msg = "Invalid Merkle proof";
|
|
18
|
+
constructor(logs) {
|
|
19
|
+
super("6001: Invalid Merkle proof");
|
|
20
|
+
this.logs = logs;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class ExceededMaxClaim extends Error {
|
|
24
|
+
logs;
|
|
25
|
+
static code = 6002;
|
|
26
|
+
code = 6002;
|
|
27
|
+
name = "ExceededMaxClaim";
|
|
28
|
+
msg = "Exceeded maximum claim amount";
|
|
29
|
+
constructor(logs) {
|
|
30
|
+
super("6002: Exceeded maximum claim amount");
|
|
31
|
+
this.logs = logs;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class MaxNodesExceeded extends Error {
|
|
35
|
+
logs;
|
|
36
|
+
static code = 6003;
|
|
37
|
+
code = 6003;
|
|
38
|
+
name = "MaxNodesExceeded";
|
|
39
|
+
msg = "Exceeded maximum node count";
|
|
40
|
+
constructor(logs) {
|
|
41
|
+
super("6003: Exceeded maximum node count");
|
|
42
|
+
this.logs = logs;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class Unauthorized extends Error {
|
|
46
|
+
logs;
|
|
47
|
+
static code = 6004;
|
|
48
|
+
code = 6004;
|
|
49
|
+
name = "Unauthorized";
|
|
50
|
+
msg = "Account is not authorized to execute this instruction";
|
|
51
|
+
constructor(logs) {
|
|
52
|
+
super("6004: Account is not authorized to execute this instruction");
|
|
53
|
+
this.logs = logs;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class OwnerMismatch extends Error {
|
|
57
|
+
logs;
|
|
58
|
+
static code = 6005;
|
|
59
|
+
code = 6005;
|
|
60
|
+
name = "OwnerMismatch";
|
|
61
|
+
msg = "Token account owner did not match intended owner";
|
|
62
|
+
constructor(logs) {
|
|
63
|
+
super("6005: Token account owner did not match intended owner");
|
|
64
|
+
this.logs = logs;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class ClawbackBeforeStart extends Error {
|
|
68
|
+
logs;
|
|
69
|
+
static code = 6006;
|
|
70
|
+
code = 6006;
|
|
71
|
+
name = "ClawbackBeforeStart";
|
|
72
|
+
msg = "Attempted clawback before start";
|
|
73
|
+
constructor(logs) {
|
|
74
|
+
super("6006: Attempted clawback before start");
|
|
75
|
+
this.logs = logs;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class ClawbackAlreadyClaimed extends Error {
|
|
79
|
+
logs;
|
|
80
|
+
static code = 6007;
|
|
81
|
+
code = 6007;
|
|
82
|
+
name = "ClawbackAlreadyClaimed";
|
|
83
|
+
msg = "Clawback already claimed";
|
|
84
|
+
constructor(logs) {
|
|
85
|
+
super("6007: Clawback already claimed");
|
|
86
|
+
this.logs = logs;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export class SameClawbackReceiver extends Error {
|
|
90
|
+
logs;
|
|
91
|
+
static code = 6008;
|
|
92
|
+
code = 6008;
|
|
93
|
+
name = "SameClawbackReceiver";
|
|
94
|
+
msg = "New and old Clawback receivers are identical";
|
|
95
|
+
constructor(logs) {
|
|
96
|
+
super("6008: New and old Clawback receivers are identical");
|
|
97
|
+
this.logs = logs;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export class ClawbackReceiverIsTokenVault extends Error {
|
|
101
|
+
logs;
|
|
102
|
+
static code = 6009;
|
|
103
|
+
code = 6009;
|
|
104
|
+
name = "ClawbackReceiverIsTokenVault";
|
|
105
|
+
msg = "Clawback receiver can not be the Token Vault";
|
|
106
|
+
constructor(logs) {
|
|
107
|
+
super("6009: Clawback receiver can not be the Token Vault");
|
|
108
|
+
this.logs = logs;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export class SameAdmin extends Error {
|
|
112
|
+
logs;
|
|
113
|
+
static code = 6010;
|
|
114
|
+
code = 6010;
|
|
115
|
+
name = "SameAdmin";
|
|
116
|
+
msg = "New and old admin are identical";
|
|
117
|
+
constructor(logs) {
|
|
118
|
+
super("6010: New and old admin are identical");
|
|
119
|
+
this.logs = logs;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export class ClaimExpired extends Error {
|
|
123
|
+
logs;
|
|
124
|
+
static code = 6011;
|
|
125
|
+
code = 6011;
|
|
126
|
+
name = "ClaimExpired";
|
|
127
|
+
msg = "Claim window expired";
|
|
128
|
+
constructor(logs) {
|
|
129
|
+
super("6011: Claim window expired");
|
|
130
|
+
this.logs = logs;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export class ArithmeticError extends Error {
|
|
134
|
+
logs;
|
|
135
|
+
static code = 6012;
|
|
136
|
+
code = 6012;
|
|
137
|
+
name = "ArithmeticError";
|
|
138
|
+
msg = "Arithmetic Error (overflow/underflow)";
|
|
139
|
+
constructor(logs) {
|
|
140
|
+
super("6012: Arithmetic Error (overflow/underflow)");
|
|
141
|
+
this.logs = logs;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export class StartTimestampAfterEnd extends Error {
|
|
145
|
+
logs;
|
|
146
|
+
static code = 6013;
|
|
147
|
+
code = 6013;
|
|
148
|
+
name = "StartTimestampAfterEnd";
|
|
149
|
+
msg = "Start Timestamp cannot be after end Timestamp";
|
|
150
|
+
constructor(logs) {
|
|
151
|
+
super("6013: Start Timestamp cannot be after end Timestamp");
|
|
152
|
+
this.logs = logs;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export class TimestampsNotInFuture extends Error {
|
|
156
|
+
logs;
|
|
157
|
+
static code = 6014;
|
|
158
|
+
code = 6014;
|
|
159
|
+
name = "TimestampsNotInFuture";
|
|
160
|
+
msg = "Timestamps cannot be in the past";
|
|
161
|
+
constructor(logs) {
|
|
162
|
+
super("6014: Timestamps cannot be in the past");
|
|
163
|
+
this.logs = logs;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export class InvalidMint extends Error {
|
|
167
|
+
logs;
|
|
168
|
+
static code = 6015;
|
|
169
|
+
code = 6015;
|
|
170
|
+
name = "InvalidMint";
|
|
171
|
+
msg = "Invalid Mint";
|
|
172
|
+
constructor(logs) {
|
|
173
|
+
super("6015: Invalid Mint");
|
|
174
|
+
this.logs = logs;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
export class ClaimIsClosed extends Error {
|
|
178
|
+
logs;
|
|
179
|
+
static code = 6016;
|
|
180
|
+
code = 6016;
|
|
181
|
+
name = "ClaimIsClosed";
|
|
182
|
+
msg = "Claim is closed";
|
|
183
|
+
constructor(logs) {
|
|
184
|
+
super("6016: Claim is closed");
|
|
185
|
+
this.logs = logs;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export class ClaimsAreNotClosable extends Error {
|
|
189
|
+
logs;
|
|
190
|
+
static code = 6017;
|
|
191
|
+
code = 6017;
|
|
192
|
+
name = "ClaimsAreNotClosable";
|
|
193
|
+
msg = "Claims are not closable";
|
|
194
|
+
constructor(logs) {
|
|
195
|
+
super("6017: Claims are not closable");
|
|
196
|
+
this.logs = logs;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export class InvalidUnlockPeriod extends Error {
|
|
200
|
+
logs;
|
|
201
|
+
static code = 6018;
|
|
202
|
+
code = 6018;
|
|
203
|
+
name = "InvalidUnlockPeriod";
|
|
204
|
+
msg = "Invalid unlock period";
|
|
205
|
+
constructor(logs) {
|
|
206
|
+
super("6018: Invalid unlock period");
|
|
207
|
+
this.logs = logs;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
export function fromCode(code, logs) {
|
|
211
|
+
switch (code) {
|
|
212
|
+
case 6000:
|
|
213
|
+
return new InsufficientUnlockedTokens(logs);
|
|
214
|
+
case 6001:
|
|
215
|
+
return new InvalidProof(logs);
|
|
216
|
+
case 6002:
|
|
217
|
+
return new ExceededMaxClaim(logs);
|
|
218
|
+
case 6003:
|
|
219
|
+
return new MaxNodesExceeded(logs);
|
|
220
|
+
case 6004:
|
|
221
|
+
return new Unauthorized(logs);
|
|
222
|
+
case 6005:
|
|
223
|
+
return new OwnerMismatch(logs);
|
|
224
|
+
case 6006:
|
|
225
|
+
return new ClawbackBeforeStart(logs);
|
|
226
|
+
case 6007:
|
|
227
|
+
return new ClawbackAlreadyClaimed(logs);
|
|
228
|
+
case 6008:
|
|
229
|
+
return new SameClawbackReceiver(logs);
|
|
230
|
+
case 6009:
|
|
231
|
+
return new ClawbackReceiverIsTokenVault(logs);
|
|
232
|
+
case 6010:
|
|
233
|
+
return new SameAdmin(logs);
|
|
234
|
+
case 6011:
|
|
235
|
+
return new ClaimExpired(logs);
|
|
236
|
+
case 6012:
|
|
237
|
+
return new ArithmeticError(logs);
|
|
238
|
+
case 6013:
|
|
239
|
+
return new StartTimestampAfterEnd(logs);
|
|
240
|
+
case 6014:
|
|
241
|
+
return new TimestampsNotInFuture(logs);
|
|
242
|
+
case 6015:
|
|
243
|
+
return new InvalidMint(logs);
|
|
244
|
+
case 6016:
|
|
245
|
+
return new ClaimIsClosed(logs);
|
|
246
|
+
case 6017:
|
|
247
|
+
return new ClaimsAreNotClosable(logs);
|
|
248
|
+
case 6018:
|
|
249
|
+
return new InvalidUnlockPeriod(logs);
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PROGRAM_ID } from "../programId";
|
|
2
|
+
import * as anchor from "./anchor";
|
|
3
|
+
import * as custom from "./custom";
|
|
4
|
+
export function fromCode(code, logs) {
|
|
5
|
+
return code >= 6000 ? custom.fromCode(code, logs) : anchor.fromCode(code, logs);
|
|
6
|
+
}
|
|
7
|
+
function hasOwnProperty(obj, prop) {
|
|
8
|
+
return Object.hasOwnProperty.call(obj, prop);
|
|
9
|
+
}
|
|
10
|
+
const errorRe = /Program (\w+) failed: custom program error: (\w+)/;
|
|
11
|
+
export function fromTxError(err, programId = PROGRAM_ID) {
|
|
12
|
+
if (typeof err !== "object" || err === null || !hasOwnProperty(err, "logs") || !Array.isArray(err.logs)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
let firstMatch = null;
|
|
16
|
+
for (const logLine of err.logs) {
|
|
17
|
+
firstMatch = errorRe.exec(logLine);
|
|
18
|
+
if (firstMatch !== null) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (firstMatch === null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const [programIdRaw, codeRaw] = firstMatch.slice(1);
|
|
26
|
+
if (programIdRaw !== programId.toString()) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
let errorCode;
|
|
30
|
+
try {
|
|
31
|
+
errorCode = parseInt(codeRaw, 16);
|
|
32
|
+
}
|
|
33
|
+
catch (parseErr) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return fromCode(errorCode, err.logs);
|
|
37
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { PROGRAM_ID } from "../programId";
|
|
3
|
+
export function claimLocked(accounts, programId = PROGRAM_ID) {
|
|
4
|
+
const keys = [
|
|
5
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
6
|
+
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
7
|
+
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
8
|
+
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
9
|
+
{ pubkey: accounts.claimant, isSigner: true, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
11
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
12
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
13
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
14
|
+
];
|
|
15
|
+
const identifier = Buffer.from([34, 206, 181, 23, 11, 207, 147, 90]);
|
|
16
|
+
const data = identifier;
|
|
17
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
18
|
+
return ix;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { PROGRAM_ID } from "../programId";
|
|
4
|
+
export function clawback(accounts, programId = PROGRAM_ID) {
|
|
5
|
+
const keys = [
|
|
6
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
7
|
+
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
8
|
+
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
9
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
11
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
12
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
13
|
+
];
|
|
14
|
+
const identifier = Buffer.from([111, 92, 142, 79, 33, 234, 82, 27]);
|
|
15
|
+
const data = identifier;
|
|
16
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
17
|
+
return ix;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { PROGRAM_ID } from "../programId";
|
|
4
|
+
export function closeClaim(accounts, programId = PROGRAM_ID) {
|
|
5
|
+
const keys = [
|
|
6
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
7
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
8
|
+
{ pubkey: accounts.claimant, isSigner: false, isWritable: false },
|
|
9
|
+
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
11
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
12
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
13
|
+
];
|
|
14
|
+
const identifier = Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
|
|
15
|
+
const data = identifier;
|
|
16
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
17
|
+
return ix;
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { newDistributor } from "./newDistributor";
|
|
2
|
+
export { newClaim } from "./newClaim";
|
|
3
|
+
export { claimLocked } from "./claimLocked";
|
|
4
|
+
export { clawback } from "./clawback";
|
|
5
|
+
export { closeClaim } from "./closeClaim";
|
|
6
|
+
export { setClawbackReceiver } from "./setClawbackReceiver";
|
|
7
|
+
export { setAdmin } from "./setAdmin";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import { PROGRAM_ID } from "../programId";
|
|
4
|
+
export const layout = borsh.struct([
|
|
5
|
+
borsh.u64("amountUnlocked"),
|
|
6
|
+
borsh.u64("amountLocked"),
|
|
7
|
+
borsh.vec(borsh.array(borsh.u8(), 32), "proof"),
|
|
8
|
+
]);
|
|
9
|
+
export function newClaim(args, accounts, programId = PROGRAM_ID) {
|
|
10
|
+
const keys = [
|
|
11
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
12
|
+
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
13
|
+
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
14
|
+
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
15
|
+
{ pubkey: accounts.claimant, isSigner: true, isWritable: true },
|
|
16
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
17
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
18
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
19
|
+
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
20
|
+
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
21
|
+
];
|
|
22
|
+
const identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
|
|
23
|
+
const buffer = Buffer.alloc(1000);
|
|
24
|
+
const len = layout.encode({
|
|
25
|
+
amountUnlocked: args.amountUnlocked,
|
|
26
|
+
amountLocked: args.amountLocked,
|
|
27
|
+
proof: args.proof,
|
|
28
|
+
}, buffer);
|
|
29
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
30
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
31
|
+
return ix;
|
|
32
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
import { PROGRAM_ID } from "../programId";
|
|
5
|
+
export const layout = borsh.struct([
|
|
6
|
+
borsh.u64("version"),
|
|
7
|
+
borsh.array(borsh.u8(), 32, "root"),
|
|
8
|
+
borsh.u64("maxTotalClaim"),
|
|
9
|
+
borsh.u64("maxNumNodes"),
|
|
10
|
+
borsh.u64("unlockPeriod"),
|
|
11
|
+
borsh.u64("startVestingTs"),
|
|
12
|
+
borsh.u64("endVestingTs"),
|
|
13
|
+
borsh.u64("clawbackStartTs"),
|
|
14
|
+
borsh.bool("claimsClosable"),
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* READ THE FOLLOWING:
|
|
18
|
+
*
|
|
19
|
+
* This instruction is susceptible to frontrunning that could result in loss of funds if not handled properly.
|
|
20
|
+
*
|
|
21
|
+
* An attack could look like:
|
|
22
|
+
* - A legitimate user opens a new distributor.
|
|
23
|
+
* - Someone observes the call to this instruction.
|
|
24
|
+
* - They replace the clawback_receiver, admin, or time parameters with their own.
|
|
25
|
+
*
|
|
26
|
+
* One situation that could happen here is the attacker replaces the admin and clawback_receiver with their own
|
|
27
|
+
* and sets the clawback_start_ts with the minimal time allowed. After clawback_start_ts has elapsed,
|
|
28
|
+
* the attacker can steal all funds from the distributor to their own clawback_receiver account.
|
|
29
|
+
*
|
|
30
|
+
* HOW TO AVOID:
|
|
31
|
+
* - When you call into this instruction, ensure your transaction succeeds.
|
|
32
|
+
* - To be extra safe, after your transaction succeeds, read back the state of the created MerkleDistributor account and
|
|
33
|
+
* assert the parameters are what you expect, most importantly the clawback_receiver and admin.
|
|
34
|
+
* - If your transaction fails, double check the value on-chain matches what you expect.
|
|
35
|
+
*/
|
|
36
|
+
export function newDistributor(args, accounts, programId = PROGRAM_ID) {
|
|
37
|
+
const keys = [
|
|
38
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
39
|
+
{ pubkey: accounts.clawbackReceiver, isSigner: false, isWritable: true },
|
|
40
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
41
|
+
{ pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
|
|
42
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
43
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
44
|
+
{
|
|
45
|
+
pubkey: accounts.associatedTokenProgram,
|
|
46
|
+
isSigner: false,
|
|
47
|
+
isWritable: false,
|
|
48
|
+
},
|
|
49
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
50
|
+
];
|
|
51
|
+
const identifier = Buffer.from([32, 139, 112, 171, 0, 2, 225, 155]);
|
|
52
|
+
const buffer = Buffer.alloc(1000);
|
|
53
|
+
const len = layout.encode({
|
|
54
|
+
version: args.version,
|
|
55
|
+
root: args.root,
|
|
56
|
+
maxTotalClaim: args.maxTotalClaim,
|
|
57
|
+
maxNumNodes: args.maxNumNodes,
|
|
58
|
+
unlockPeriod: args.unlockPeriod,
|
|
59
|
+
startVestingTs: args.startVestingTs,
|
|
60
|
+
endVestingTs: args.endVestingTs,
|
|
61
|
+
clawbackStartTs: args.clawbackStartTs,
|
|
62
|
+
claimsClosable: args.claimsClosable,
|
|
63
|
+
}, buffer);
|
|
64
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
65
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
66
|
+
return ix;
|
|
67
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { PROGRAM_ID } from "../programId";
|
|
4
|
+
export function setAdmin(accounts, programId = PROGRAM_ID) {
|
|
5
|
+
const keys = [
|
|
6
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
7
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
8
|
+
{ pubkey: accounts.newAdmin, isSigner: false, isWritable: true },
|
|
9
|
+
];
|
|
10
|
+
const identifier = Buffer.from([251, 163, 0, 52, 91, 194, 187, 92]);
|
|
11
|
+
const data = identifier;
|
|
12
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
13
|
+
return ix;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { PROGRAM_ID } from "../programId";
|
|
4
|
+
export function setClawbackReceiver(accounts, programId = PROGRAM_ID) {
|
|
5
|
+
const keys = [
|
|
6
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
7
|
+
{ pubkey: accounts.newClawbackAccount, isSigner: false, isWritable: false },
|
|
8
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
9
|
+
];
|
|
10
|
+
const identifier = Buffer.from([153, 217, 34, 20, 19, 29, 229, 75]);
|
|
11
|
+
const data = identifier;
|
|
12
|
+
const ix = new TransactionInstruction({ keys, programId, data });
|
|
13
|
+
return ix;
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
// Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
|
|
3
|
+
export const PROGRAM_ID_CLI = new PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N");
|
|
4
|
+
// This constant will not get overwritten on subsequent code generations and it's safe to modify it's value.
|
|
5
|
+
export const PROGRAM_ID = PROGRAM_ID_CLI;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as SolanaDistributorClient } from "./client";
|
|
2
|
+
export * from "./generated/accounts";
|
|
3
|
+
export * from "./generated/errors";
|
|
4
|
+
export * from "./generated/instructions";
|
|
5
|
+
export * from "./utils";
|
|
6
|
+
export * from "./types";
|
|
7
|
+
export * as constants from "./constants";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export var AnchorErrorCode;
|
|
2
|
+
(function (AnchorErrorCode) {
|
|
3
|
+
/** 8 byte instruction identifier not provided */
|
|
4
|
+
AnchorErrorCode["InstructionMissing"] = "InstructionMissing";
|
|
5
|
+
/** Fallback functions are not supported */
|
|
6
|
+
AnchorErrorCode["InstructionFallbackNotFound"] = "InstructionFallbackNotFound";
|
|
7
|
+
/** The program could not deserialize the given instruction */
|
|
8
|
+
AnchorErrorCode["InstructionDidNotDeserialize"] = "InstructionDidNotDeserialize";
|
|
9
|
+
/** The program could not serialize the given instruction */
|
|
10
|
+
AnchorErrorCode["InstructionDidNotSerialize"] = "InstructionDidNotSerialize";
|
|
11
|
+
/** The program was compiled without idl instructions */
|
|
12
|
+
AnchorErrorCode["IdlInstructionStub"] = "IdlInstructionStub";
|
|
13
|
+
/** The transaction was given an invalid program for the IDL instruction */
|
|
14
|
+
AnchorErrorCode["IdlInstructionInvalidProgram"] = "IdlInstructionInvalidProgram";
|
|
15
|
+
/** A mut constraint was violated */
|
|
16
|
+
AnchorErrorCode["ConstraintMut"] = "ConstraintMut";
|
|
17
|
+
/** A has one constraint was violated */
|
|
18
|
+
AnchorErrorCode["ConstraintHasOne"] = "ConstraintHasOne";
|
|
19
|
+
/** A signer constraint was violated */
|
|
20
|
+
AnchorErrorCode["ConstraintSigner"] = "ConstraintSigner";
|
|
21
|
+
/** A raw constraint was violated */
|
|
22
|
+
AnchorErrorCode["ConstraintRaw"] = "ConstraintRaw";
|
|
23
|
+
/** An owner constraint was violated */
|
|
24
|
+
AnchorErrorCode["ConstraintOwner"] = "ConstraintOwner";
|
|
25
|
+
/** A rent exemption constraint was violated */
|
|
26
|
+
AnchorErrorCode["ConstraintRentExempt"] = "ConstraintRentExempt";
|
|
27
|
+
/** A seeds constraint was violated */
|
|
28
|
+
AnchorErrorCode["ConstraintSeeds"] = "ConstraintSeeds";
|
|
29
|
+
/** An executable constraint was violated */
|
|
30
|
+
AnchorErrorCode["ConstraintExecutable"] = "ConstraintExecutable";
|
|
31
|
+
/** Deprecated Error, feel free to replace with something else */
|
|
32
|
+
AnchorErrorCode["ConstraintState"] = "ConstraintState";
|
|
33
|
+
/** An associated constraint was violated */
|
|
34
|
+
AnchorErrorCode["ConstraintAssociated"] = "ConstraintAssociated";
|
|
35
|
+
/** An associated init constraint was violated */
|
|
36
|
+
AnchorErrorCode["ConstraintAssociatedInit"] = "ConstraintAssociatedInit";
|
|
37
|
+
/** A close constraint was violated */
|
|
38
|
+
AnchorErrorCode["ConstraintClose"] = "ConstraintClose";
|
|
39
|
+
/** An address constraint was violated */
|
|
40
|
+
AnchorErrorCode["ConstraintAddress"] = "ConstraintAddress";
|
|
41
|
+
/** Expected zero account discriminant */
|
|
42
|
+
AnchorErrorCode["ConstraintZero"] = "ConstraintZero";
|
|
43
|
+
/** A token mint constraint was violated */
|
|
44
|
+
AnchorErrorCode["ConstraintTokenMint"] = "ConstraintTokenMint";
|
|
45
|
+
/** A token owner constraint was violated */
|
|
46
|
+
AnchorErrorCode["ConstraintTokenOwner"] = "ConstraintTokenOwner";
|
|
47
|
+
/** A mint mint authority constraint was violated */
|
|
48
|
+
AnchorErrorCode["ConstraintMintMintAuthority"] = "ConstraintMintMintAuthority";
|
|
49
|
+
/** A mint freeze authority constraint was violated */
|
|
50
|
+
AnchorErrorCode["ConstraintMintFreezeAuthority"] = "ConstraintMintFreezeAuthority";
|
|
51
|
+
/** A mint decimals constraint was violated */
|
|
52
|
+
AnchorErrorCode["ConstraintMintDecimals"] = "ConstraintMintDecimals";
|
|
53
|
+
/** A space constraint was violated */
|
|
54
|
+
AnchorErrorCode["ConstraintSpace"] = "ConstraintSpace";
|
|
55
|
+
/** A required account for the constraint is None */
|
|
56
|
+
AnchorErrorCode["ConstraintAccountIsNone"] = "ConstraintAccountIsNone";
|
|
57
|
+
/** A require expression was violated */
|
|
58
|
+
AnchorErrorCode["RequireViolated"] = "RequireViolated";
|
|
59
|
+
/** A require_eq expression was violated */
|
|
60
|
+
AnchorErrorCode["RequireEqViolated"] = "RequireEqViolated";
|
|
61
|
+
/** A require_keys_eq expression was violated */
|
|
62
|
+
AnchorErrorCode["RequireKeysEqViolated"] = "RequireKeysEqViolated";
|
|
63
|
+
/** A require_neq expression was violated */
|
|
64
|
+
AnchorErrorCode["RequireNeqViolated"] = "RequireNeqViolated";
|
|
65
|
+
/** A require_keys_neq expression was violated */
|
|
66
|
+
AnchorErrorCode["RequireKeysNeqViolated"] = "RequireKeysNeqViolated";
|
|
67
|
+
/** A require_gt expression was violated */
|
|
68
|
+
AnchorErrorCode["RequireGtViolated"] = "RequireGtViolated";
|
|
69
|
+
/** A require_gte expression was violated */
|
|
70
|
+
AnchorErrorCode["RequireGteViolated"] = "RequireGteViolated";
|
|
71
|
+
/** The account discriminator was already set on this account */
|
|
72
|
+
AnchorErrorCode["AccountDiscriminatorAlreadySet"] = "AccountDiscriminatorAlreadySet";
|
|
73
|
+
/** No 8 byte discriminator was found on the account */
|
|
74
|
+
AnchorErrorCode["AccountDiscriminatorNotFound"] = "AccountDiscriminatorNotFound";
|
|
75
|
+
/** 8 byte discriminator did not match what was expected */
|
|
76
|
+
AnchorErrorCode["AccountDiscriminatorMismatch"] = "AccountDiscriminatorMismatch";
|
|
77
|
+
/** Failed to deserialize the account */
|
|
78
|
+
AnchorErrorCode["AccountDidNotDeserialize"] = "AccountDidNotDeserialize";
|
|
79
|
+
/** Failed to serialize the account */
|
|
80
|
+
AnchorErrorCode["AccountDidNotSerialize"] = "AccountDidNotSerialize";
|
|
81
|
+
/** Not enough account keys given to the instruction */
|
|
82
|
+
AnchorErrorCode["AccountNotEnoughKeys"] = "AccountNotEnoughKeys";
|
|
83
|
+
/** The given account is not mutable */
|
|
84
|
+
AnchorErrorCode["AccountNotMutable"] = "AccountNotMutable";
|
|
85
|
+
/** The given account is owned by a different program than expected */
|
|
86
|
+
AnchorErrorCode["AccountOwnedByWrongProgram"] = "AccountOwnedByWrongProgram";
|
|
87
|
+
/** Program ID was not as expected */
|
|
88
|
+
AnchorErrorCode["InvalidProgramId"] = "InvalidProgramId";
|
|
89
|
+
/** Program account is not executable */
|
|
90
|
+
AnchorErrorCode["InvalidProgramExecutable"] = "InvalidProgramExecutable";
|
|
91
|
+
/** The given account did not sign */
|
|
92
|
+
AnchorErrorCode["AccountNotSigner"] = "AccountNotSigner";
|
|
93
|
+
/** The given account is not owned by the system program */
|
|
94
|
+
AnchorErrorCode["AccountNotSystemOwned"] = "AccountNotSystemOwned";
|
|
95
|
+
/** The program expected this account to be already initialized */
|
|
96
|
+
AnchorErrorCode["AccountNotInitialized"] = "AccountNotInitialized";
|
|
97
|
+
/** The given account is not a program data account */
|
|
98
|
+
AnchorErrorCode["AccountNotProgramData"] = "AccountNotProgramData";
|
|
99
|
+
/** The given account is not the associated token account */
|
|
100
|
+
AnchorErrorCode["AccountNotAssociatedTokenAccount"] = "AccountNotAssociatedTokenAccount";
|
|
101
|
+
/** The given public key does not match the required sysvar */
|
|
102
|
+
AnchorErrorCode["AccountSysvarMismatch"] = "AccountSysvarMismatch";
|
|
103
|
+
/** The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit */
|
|
104
|
+
AnchorErrorCode["AccountReallocExceedsLimit"] = "AccountReallocExceedsLimit";
|
|
105
|
+
/** The account was duplicated for more than one reallocation */
|
|
106
|
+
AnchorErrorCode["AccountDuplicateReallocs"] = "AccountDuplicateReallocs";
|
|
107
|
+
/** The declared program id does not match the actual program id */
|
|
108
|
+
AnchorErrorCode["DeclaredProgramIdMismatch"] = "DeclaredProgramIdMismatch";
|
|
109
|
+
/** The API being used is deprecated and should no longer be used */
|
|
110
|
+
AnchorErrorCode["Deprecated"] = "Deprecated";
|
|
111
|
+
})(AnchorErrorCode || (AnchorErrorCode = {}));
|
|
112
|
+
export var ContractErrorCode;
|
|
113
|
+
(function (ContractErrorCode) {
|
|
114
|
+
/** Insufficient unlocked tokens */
|
|
115
|
+
ContractErrorCode["InsufficientUnlockedTokens"] = "InsufficientUnlockedTokens";
|
|
116
|
+
/** Deposit Start too far in future */
|
|
117
|
+
ContractErrorCode["StartTooFarInFuture"] = "StartTooFarInFuture";
|
|
118
|
+
/** Invalid Merkle proof */
|
|
119
|
+
ContractErrorCode["InvalidProof"] = "InvalidProof";
|
|
120
|
+
/** Exceeded maximum claim amount */
|
|
121
|
+
ContractErrorCode["ExceededMaxClaim"] = "ExceededMaxClaim";
|
|
122
|
+
/** Exceeded maximum node count */
|
|
123
|
+
ContractErrorCode["MaxNodesExceeded"] = "MaxNodesExceeded";
|
|
124
|
+
/** Account is not authorized to execute this instruction */
|
|
125
|
+
ContractErrorCode["Unauthorized"] = "Unauthorized";
|
|
126
|
+
/** Token account owner did not match intended owner */
|
|
127
|
+
ContractErrorCode["OwnerMismatch"] = "OwnerMismatch";
|
|
128
|
+
/** Clawback cannot be before vesting starts */
|
|
129
|
+
ContractErrorCode["ClawbackBeforeVesting"] = "ClawbackBeforeVesting";
|
|
130
|
+
/** Attempted clawback before start */
|
|
131
|
+
ContractErrorCode["ClawbackBeforeStart"] = "ClawbackBeforeStart";
|
|
132
|
+
/** Clawback already claimed */
|
|
133
|
+
ContractErrorCode["ClawbackAlreadyClaimed"] = "ClawbackAlreadyClaimed";
|
|
134
|
+
/** Clawback start must be at least one day after vesting end */
|
|
135
|
+
ContractErrorCode["InsufficientClawbackDelay"] = "InsufficientClawbackDelay";
|
|
136
|
+
/** New and old Clawback receivers are identical */
|
|
137
|
+
ContractErrorCode["SameClawbackReceiver"] = "SameClawbackReceiver";
|
|
138
|
+
/** New and old admin are identical */
|
|
139
|
+
ContractErrorCode["SameAdmin"] = "SameAdmin";
|
|
140
|
+
/** Claim window expired */
|
|
141
|
+
ContractErrorCode["ClaimExpired"] = "ClaimExpired";
|
|
142
|
+
/** Arithmetic Error (overflow/underflow) */
|
|
143
|
+
ContractErrorCode["ArithmeticError"] = "ArithmeticError";
|
|
144
|
+
/** Start Timestamp cannot be after end Timestamp */
|
|
145
|
+
ContractErrorCode["StartTimestampAfterEnd"] = "StartTimestampAfterEnd";
|
|
146
|
+
/** Timestamps cannot be in the past */
|
|
147
|
+
ContractErrorCode["TimestampsNotInFuture"] = "TimestampsNotInFuture";
|
|
148
|
+
/** Airdrop Version Mismatch */
|
|
149
|
+
ContractErrorCode["InvalidVersion"] = "InvalidVersion";
|
|
150
|
+
/** Invalid Mint */
|
|
151
|
+
ContractErrorCode["InvalidMint"] = "InvalidMint";
|
|
152
|
+
/** Claim is closed */
|
|
153
|
+
ContractErrorCode["ClaimIsClosed"] = "ClaimIsClosed";
|
|
154
|
+
/** Claims are not closable */
|
|
155
|
+
ContractErrorCode["ClaimsAreNotClosable"] = "ClaimsAreNotClosable";
|
|
156
|
+
})(ContractErrorCode || (ContractErrorCode = {}));
|