@streamflow/distributor 6.5.0 → 7.0.0-alpha.10
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/README.md +4 -5
- package/dist/{index.js → cjs/index.js} +1 -1
- package/dist/cjs/solana/client.js +216 -0
- package/dist/{solana → cjs/solana}/constants.js +7 -8
- package/dist/cjs/solana/generated/accounts/ClaimStatus.js +125 -0
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +180 -0
- package/dist/cjs/solana/generated/errors/anchor.js +712 -0
- package/dist/cjs/solana/generated/errors/custom.js +256 -0
- package/dist/cjs/solana/generated/errors/index.js +65 -0
- package/dist/{solana → cjs/solana}/generated/instructions/claimLocked.js +7 -8
- package/dist/{solana → cjs/solana}/generated/instructions/clawback.js +8 -8
- package/dist/{solana → cjs/solana}/generated/instructions/closeClaim.js +8 -8
- package/dist/{solana → cjs/solana}/generated/instructions/newClaim.js +10 -11
- package/dist/{solana → cjs/solana}/generated/instructions/newDistributor.js +11 -11
- package/dist/cjs/solana/generated/instructions/setAdmin.js +18 -0
- package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +18 -0
- package/dist/{solana → cjs/solana}/generated/programId.js +1 -1
- package/dist/{solana → cjs/solana}/index.js +6 -6
- package/dist/cjs/solana/utils.js +69 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/solana/client.js +214 -0
- package/dist/esm/solana/constants.js +11 -0
- package/dist/{solana → esm/solana}/generated/accounts/ClaimStatus.d.ts +11 -11
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +113 -0
- package/dist/{solana → esm/solana}/generated/accounts/MerkleDistributor.d.ts +19 -19
- 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/{solana → esm/solana}/generated/instructions/newClaim.d.ts +3 -3
- package/dist/esm/solana/generated/instructions/newClaim.js +32 -0
- package/dist/{solana → esm/solana}/generated/instructions/newDistributor.d.ts +8 -8
- package/dist/esm/solana/generated/instructions/newDistributor.js +73 -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.d.ts +7 -0
- package/dist/esm/solana/index.js +7 -0
- package/dist/{solana → esm/solana}/types.d.ts +5 -5
- package/dist/esm/solana/types.js +156 -0
- package/dist/esm/solana/utils.js +60 -0
- package/package.json +21 -21
- package/dist/index.d.ts +0 -1
- package/dist/solana/client.js +0 -402
- package/dist/solana/generated/accounts/ClaimStatus.js +0 -183
- package/dist/solana/generated/accounts/MerkleDistributor.js +0 -238
- package/dist/solana/generated/errors/anchor.js +0 -889
- package/dist/solana/generated/errors/custom.js +0 -328
- package/dist/solana/generated/errors/index.js +0 -104
- package/dist/solana/generated/instructions/setAdmin.js +0 -18
- package/dist/solana/generated/instructions/setClawbackReceiver.js +0 -18
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/utils.js +0 -122
- /package/dist/{solana → cjs/solana}/generated/accounts/index.js +0 -0
- /package/dist/{solana → cjs/solana}/generated/instructions/index.js +0 -0
- /package/dist/{solana → cjs/solana}/types.js +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/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/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}/utils.d.ts +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromCode = exports.InvalidUnlockPeriod = exports.ClaimsAreNotClosable = exports.ClaimIsClosed = exports.InvalidMint = exports.TimestampsNotInFuture = exports.StartTimestampAfterEnd = exports.ArithmeticError = exports.ClaimExpired = exports.SameAdmin = exports.ClawbackReceiverIsTokenVault = exports.SameClawbackReceiver = exports.ClawbackAlreadyClaimed = exports.ClawbackBeforeStart = exports.OwnerMismatch = exports.Unauthorized = exports.MaxNodesExceeded = exports.ExceededMaxClaim = exports.InvalidProof = exports.InsufficientUnlockedTokens = void 0;
|
|
4
|
+
class InsufficientUnlockedTokens extends Error {
|
|
5
|
+
constructor(logs) {
|
|
6
|
+
super("6000: Insufficient unlocked tokens");
|
|
7
|
+
this.logs = logs;
|
|
8
|
+
this.code = 6000;
|
|
9
|
+
this.name = "InsufficientUnlockedTokens";
|
|
10
|
+
this.msg = "Insufficient unlocked tokens";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.InsufficientUnlockedTokens = InsufficientUnlockedTokens;
|
|
14
|
+
InsufficientUnlockedTokens.code = 6000;
|
|
15
|
+
class InvalidProof extends Error {
|
|
16
|
+
constructor(logs) {
|
|
17
|
+
super("6001: Invalid Merkle proof");
|
|
18
|
+
this.logs = logs;
|
|
19
|
+
this.code = 6001;
|
|
20
|
+
this.name = "InvalidProof";
|
|
21
|
+
this.msg = "Invalid Merkle proof";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.InvalidProof = InvalidProof;
|
|
25
|
+
InvalidProof.code = 6001;
|
|
26
|
+
class ExceededMaxClaim extends Error {
|
|
27
|
+
constructor(logs) {
|
|
28
|
+
super("6002: Exceeded maximum claim amount");
|
|
29
|
+
this.logs = logs;
|
|
30
|
+
this.code = 6002;
|
|
31
|
+
this.name = "ExceededMaxClaim";
|
|
32
|
+
this.msg = "Exceeded maximum claim amount";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ExceededMaxClaim = ExceededMaxClaim;
|
|
36
|
+
ExceededMaxClaim.code = 6002;
|
|
37
|
+
class MaxNodesExceeded extends Error {
|
|
38
|
+
constructor(logs) {
|
|
39
|
+
super("6003: Exceeded maximum node count");
|
|
40
|
+
this.logs = logs;
|
|
41
|
+
this.code = 6003;
|
|
42
|
+
this.name = "MaxNodesExceeded";
|
|
43
|
+
this.msg = "Exceeded maximum node count";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.MaxNodesExceeded = MaxNodesExceeded;
|
|
47
|
+
MaxNodesExceeded.code = 6003;
|
|
48
|
+
class Unauthorized extends Error {
|
|
49
|
+
constructor(logs) {
|
|
50
|
+
super("6004: Account is not authorized to execute this instruction");
|
|
51
|
+
this.logs = logs;
|
|
52
|
+
this.code = 6004;
|
|
53
|
+
this.name = "Unauthorized";
|
|
54
|
+
this.msg = "Account is not authorized to execute this instruction";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.Unauthorized = Unauthorized;
|
|
58
|
+
Unauthorized.code = 6004;
|
|
59
|
+
class OwnerMismatch extends Error {
|
|
60
|
+
constructor(logs) {
|
|
61
|
+
super("6005: Token account owner did not match intended owner");
|
|
62
|
+
this.logs = logs;
|
|
63
|
+
this.code = 6005;
|
|
64
|
+
this.name = "OwnerMismatch";
|
|
65
|
+
this.msg = "Token account owner did not match intended owner";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.OwnerMismatch = OwnerMismatch;
|
|
69
|
+
OwnerMismatch.code = 6005;
|
|
70
|
+
class ClawbackBeforeStart extends Error {
|
|
71
|
+
constructor(logs) {
|
|
72
|
+
super("6006: Attempted clawback before start");
|
|
73
|
+
this.logs = logs;
|
|
74
|
+
this.code = 6006;
|
|
75
|
+
this.name = "ClawbackBeforeStart";
|
|
76
|
+
this.msg = "Attempted clawback before start";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.ClawbackBeforeStart = ClawbackBeforeStart;
|
|
80
|
+
ClawbackBeforeStart.code = 6006;
|
|
81
|
+
class ClawbackAlreadyClaimed extends Error {
|
|
82
|
+
constructor(logs) {
|
|
83
|
+
super("6007: Clawback already claimed");
|
|
84
|
+
this.logs = logs;
|
|
85
|
+
this.code = 6007;
|
|
86
|
+
this.name = "ClawbackAlreadyClaimed";
|
|
87
|
+
this.msg = "Clawback already claimed";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ClawbackAlreadyClaimed = ClawbackAlreadyClaimed;
|
|
91
|
+
ClawbackAlreadyClaimed.code = 6007;
|
|
92
|
+
class SameClawbackReceiver extends Error {
|
|
93
|
+
constructor(logs) {
|
|
94
|
+
super("6008: New and old Clawback receivers are identical");
|
|
95
|
+
this.logs = logs;
|
|
96
|
+
this.code = 6008;
|
|
97
|
+
this.name = "SameClawbackReceiver";
|
|
98
|
+
this.msg = "New and old Clawback receivers are identical";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.SameClawbackReceiver = SameClawbackReceiver;
|
|
102
|
+
SameClawbackReceiver.code = 6008;
|
|
103
|
+
class ClawbackReceiverIsTokenVault extends Error {
|
|
104
|
+
constructor(logs) {
|
|
105
|
+
super("6009: Clawback receiver can not be the Token Vault");
|
|
106
|
+
this.logs = logs;
|
|
107
|
+
this.code = 6009;
|
|
108
|
+
this.name = "ClawbackReceiverIsTokenVault";
|
|
109
|
+
this.msg = "Clawback receiver can not be the Token Vault";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.ClawbackReceiverIsTokenVault = ClawbackReceiverIsTokenVault;
|
|
113
|
+
ClawbackReceiverIsTokenVault.code = 6009;
|
|
114
|
+
class SameAdmin extends Error {
|
|
115
|
+
constructor(logs) {
|
|
116
|
+
super("6010: New and old admin are identical");
|
|
117
|
+
this.logs = logs;
|
|
118
|
+
this.code = 6010;
|
|
119
|
+
this.name = "SameAdmin";
|
|
120
|
+
this.msg = "New and old admin are identical";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.SameAdmin = SameAdmin;
|
|
124
|
+
SameAdmin.code = 6010;
|
|
125
|
+
class ClaimExpired extends Error {
|
|
126
|
+
constructor(logs) {
|
|
127
|
+
super("6011: Claim window expired");
|
|
128
|
+
this.logs = logs;
|
|
129
|
+
this.code = 6011;
|
|
130
|
+
this.name = "ClaimExpired";
|
|
131
|
+
this.msg = "Claim window expired";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.ClaimExpired = ClaimExpired;
|
|
135
|
+
ClaimExpired.code = 6011;
|
|
136
|
+
class ArithmeticError extends Error {
|
|
137
|
+
constructor(logs) {
|
|
138
|
+
super("6012: Arithmetic Error (overflow/underflow)");
|
|
139
|
+
this.logs = logs;
|
|
140
|
+
this.code = 6012;
|
|
141
|
+
this.name = "ArithmeticError";
|
|
142
|
+
this.msg = "Arithmetic Error (overflow/underflow)";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.ArithmeticError = ArithmeticError;
|
|
146
|
+
ArithmeticError.code = 6012;
|
|
147
|
+
class StartTimestampAfterEnd extends Error {
|
|
148
|
+
constructor(logs) {
|
|
149
|
+
super("6013: Start Timestamp cannot be after end Timestamp");
|
|
150
|
+
this.logs = logs;
|
|
151
|
+
this.code = 6013;
|
|
152
|
+
this.name = "StartTimestampAfterEnd";
|
|
153
|
+
this.msg = "Start Timestamp cannot be after end Timestamp";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.StartTimestampAfterEnd = StartTimestampAfterEnd;
|
|
157
|
+
StartTimestampAfterEnd.code = 6013;
|
|
158
|
+
class TimestampsNotInFuture extends Error {
|
|
159
|
+
constructor(logs) {
|
|
160
|
+
super("6014: Timestamps cannot be in the past");
|
|
161
|
+
this.logs = logs;
|
|
162
|
+
this.code = 6014;
|
|
163
|
+
this.name = "TimestampsNotInFuture";
|
|
164
|
+
this.msg = "Timestamps cannot be in the past";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.TimestampsNotInFuture = TimestampsNotInFuture;
|
|
168
|
+
TimestampsNotInFuture.code = 6014;
|
|
169
|
+
class InvalidMint extends Error {
|
|
170
|
+
constructor(logs) {
|
|
171
|
+
super("6015: Invalid Mint");
|
|
172
|
+
this.logs = logs;
|
|
173
|
+
this.code = 6015;
|
|
174
|
+
this.name = "InvalidMint";
|
|
175
|
+
this.msg = "Invalid Mint";
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.InvalidMint = InvalidMint;
|
|
179
|
+
InvalidMint.code = 6015;
|
|
180
|
+
class ClaimIsClosed extends Error {
|
|
181
|
+
constructor(logs) {
|
|
182
|
+
super("6016: Claim is closed");
|
|
183
|
+
this.logs = logs;
|
|
184
|
+
this.code = 6016;
|
|
185
|
+
this.name = "ClaimIsClosed";
|
|
186
|
+
this.msg = "Claim is closed";
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.ClaimIsClosed = ClaimIsClosed;
|
|
190
|
+
ClaimIsClosed.code = 6016;
|
|
191
|
+
class ClaimsAreNotClosable extends Error {
|
|
192
|
+
constructor(logs) {
|
|
193
|
+
super("6017: Claims are not closable");
|
|
194
|
+
this.logs = logs;
|
|
195
|
+
this.code = 6017;
|
|
196
|
+
this.name = "ClaimsAreNotClosable";
|
|
197
|
+
this.msg = "Claims are not closable";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.ClaimsAreNotClosable = ClaimsAreNotClosable;
|
|
201
|
+
ClaimsAreNotClosable.code = 6017;
|
|
202
|
+
class InvalidUnlockPeriod extends Error {
|
|
203
|
+
constructor(logs) {
|
|
204
|
+
super("6018: Invalid unlock period");
|
|
205
|
+
this.logs = logs;
|
|
206
|
+
this.code = 6018;
|
|
207
|
+
this.name = "InvalidUnlockPeriod";
|
|
208
|
+
this.msg = "Invalid unlock period";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.InvalidUnlockPeriod = InvalidUnlockPeriod;
|
|
212
|
+
InvalidUnlockPeriod.code = 6018;
|
|
213
|
+
function fromCode(code, logs) {
|
|
214
|
+
switch (code) {
|
|
215
|
+
case 6000:
|
|
216
|
+
return new InsufficientUnlockedTokens(logs);
|
|
217
|
+
case 6001:
|
|
218
|
+
return new InvalidProof(logs);
|
|
219
|
+
case 6002:
|
|
220
|
+
return new ExceededMaxClaim(logs);
|
|
221
|
+
case 6003:
|
|
222
|
+
return new MaxNodesExceeded(logs);
|
|
223
|
+
case 6004:
|
|
224
|
+
return new Unauthorized(logs);
|
|
225
|
+
case 6005:
|
|
226
|
+
return new OwnerMismatch(logs);
|
|
227
|
+
case 6006:
|
|
228
|
+
return new ClawbackBeforeStart(logs);
|
|
229
|
+
case 6007:
|
|
230
|
+
return new ClawbackAlreadyClaimed(logs);
|
|
231
|
+
case 6008:
|
|
232
|
+
return new SameClawbackReceiver(logs);
|
|
233
|
+
case 6009:
|
|
234
|
+
return new ClawbackReceiverIsTokenVault(logs);
|
|
235
|
+
case 6010:
|
|
236
|
+
return new SameAdmin(logs);
|
|
237
|
+
case 6011:
|
|
238
|
+
return new ClaimExpired(logs);
|
|
239
|
+
case 6012:
|
|
240
|
+
return new ArithmeticError(logs);
|
|
241
|
+
case 6013:
|
|
242
|
+
return new StartTimestampAfterEnd(logs);
|
|
243
|
+
case 6014:
|
|
244
|
+
return new TimestampsNotInFuture(logs);
|
|
245
|
+
case 6015:
|
|
246
|
+
return new InvalidMint(logs);
|
|
247
|
+
case 6016:
|
|
248
|
+
return new ClaimIsClosed(logs);
|
|
249
|
+
case 6017:
|
|
250
|
+
return new ClaimsAreNotClosable(logs);
|
|
251
|
+
case 6018:
|
|
252
|
+
return new InvalidUnlockPeriod(logs);
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
exports.fromCode = fromCode;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.fromTxError = exports.fromCode = void 0;
|
|
27
|
+
const programId_1 = require("../programId");
|
|
28
|
+
const anchor = __importStar(require("./anchor"));
|
|
29
|
+
const custom = __importStar(require("./custom"));
|
|
30
|
+
function fromCode(code, logs) {
|
|
31
|
+
return code >= 6000 ? custom.fromCode(code, logs) : anchor.fromCode(code, logs);
|
|
32
|
+
}
|
|
33
|
+
exports.fromCode = fromCode;
|
|
34
|
+
function hasOwnProperty(obj, prop) {
|
|
35
|
+
return Object.hasOwnProperty.call(obj, prop);
|
|
36
|
+
}
|
|
37
|
+
const errorRe = /Program (\w+) failed: custom program error: (\w+)/;
|
|
38
|
+
function fromTxError(err, programId = programId_1.PROGRAM_ID) {
|
|
39
|
+
if (typeof err !== "object" || err === null || !hasOwnProperty(err, "logs") || !Array.isArray(err.logs)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
let firstMatch = null;
|
|
43
|
+
for (const logLine of err.logs) {
|
|
44
|
+
firstMatch = errorRe.exec(logLine);
|
|
45
|
+
if (firstMatch !== null) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (firstMatch === null) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const [programIdRaw, codeRaw] = firstMatch.slice(1);
|
|
53
|
+
if (programIdRaw !== programId.toString()) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
let errorCode;
|
|
57
|
+
try {
|
|
58
|
+
errorCode = parseInt(codeRaw, 16);
|
|
59
|
+
}
|
|
60
|
+
catch (parseErr) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return fromCode(errorCode, err.logs);
|
|
64
|
+
}
|
|
65
|
+
exports.fromTxError = fromTxError;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.claimLocked = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function claimLocked(accounts, programId) {
|
|
7
|
-
|
|
8
|
-
var keys = [
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
const programId_1 = require("../programId");
|
|
6
|
+
function claimLocked(accounts, programId = programId_1.PROGRAM_ID) {
|
|
7
|
+
const keys = [
|
|
9
8
|
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
9
|
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
11
10
|
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
@@ -16,9 +15,9 @@ function claimLocked(accounts, programId) {
|
|
|
16
15
|
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
17
16
|
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
18
17
|
];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const identifier = Buffer.from([34, 206, 181, 23, 11, 207, 147, 90]);
|
|
19
|
+
const data = identifier;
|
|
20
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
22
21
|
return ix;
|
|
23
22
|
}
|
|
24
23
|
exports.claimLocked = claimLocked;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clawback = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
const buffer_1 = require("buffer");
|
|
6
|
+
const programId_1 = require("../programId");
|
|
7
|
+
function clawback(accounts, programId = programId_1.PROGRAM_ID) {
|
|
8
|
+
const keys = [
|
|
9
9
|
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
10
|
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
11
11
|
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
@@ -14,9 +14,9 @@ function clawback(accounts, programId) {
|
|
|
14
14
|
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
15
15
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
16
16
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const identifier = buffer_1.Buffer.from([111, 92, 142, 79, 33, 234, 82, 27]);
|
|
18
|
+
const data = identifier;
|
|
19
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
20
20
|
return ix;
|
|
21
21
|
}
|
|
22
22
|
exports.clawback = clawback;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.closeClaim = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
const buffer_1 = require("buffer");
|
|
6
|
+
const programId_1 = require("../programId");
|
|
7
|
+
function closeClaim(accounts, programId = programId_1.PROGRAM_ID) {
|
|
8
|
+
const keys = [
|
|
9
9
|
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
10
|
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
11
11
|
{ pubkey: accounts.claimant, isSigner: false, isWritable: false },
|
|
@@ -14,9 +14,9 @@ function closeClaim(accounts, programId) {
|
|
|
14
14
|
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
15
15
|
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
16
16
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const identifier = buffer_1.Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
|
|
18
|
+
const data = identifier;
|
|
19
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
20
20
|
return ix;
|
|
21
21
|
}
|
|
22
22
|
exports.closeClaim = closeClaim;
|
|
@@ -24,17 +24,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.newClaim = exports.layout = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
|
+
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
|
+
const programId_1 = require("../programId");
|
|
30
30
|
exports.layout = borsh.struct([
|
|
31
31
|
borsh.u64("amountUnlocked"),
|
|
32
32
|
borsh.u64("amountLocked"),
|
|
33
33
|
borsh.vec(borsh.array(borsh.u8(), 32), "proof"),
|
|
34
34
|
]);
|
|
35
|
-
function newClaim(args, accounts, programId) {
|
|
36
|
-
|
|
37
|
-
var keys = [
|
|
35
|
+
function newClaim(args, accounts, programId = programId_1.PROGRAM_ID) {
|
|
36
|
+
const keys = [
|
|
38
37
|
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
39
38
|
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
40
39
|
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
@@ -46,15 +45,15 @@ function newClaim(args, accounts, programId) {
|
|
|
46
45
|
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
|
|
47
46
|
{ pubkey: accounts.program, isSigner: false, isWritable: false },
|
|
48
47
|
];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
|
|
49
|
+
const buffer = Buffer.alloc(1000);
|
|
50
|
+
const len = exports.layout.encode({
|
|
52
51
|
amountUnlocked: args.amountUnlocked,
|
|
53
52
|
amountLocked: args.amountLocked,
|
|
54
53
|
proof: args.proof,
|
|
55
54
|
}, buffer);
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
56
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
58
57
|
return ix;
|
|
59
58
|
}
|
|
60
59
|
exports.newClaim = newClaim;
|
|
@@ -24,9 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.newDistributor = exports.layout = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
|
+
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
|
+
const buffer_1 = require("buffer");
|
|
30
|
+
const programId_1 = require("../programId");
|
|
30
31
|
exports.layout = borsh.struct([
|
|
31
32
|
borsh.u64("version"),
|
|
32
33
|
borsh.array(borsh.u8(), 32, "root"),
|
|
@@ -61,9 +62,8 @@ exports.layout = borsh.struct([
|
|
|
61
62
|
* assert the parameters are what you expect, most importantly the clawback_receiver and admin.
|
|
62
63
|
* - If your transaction fails, double check the value on-chain matches what you expect.
|
|
63
64
|
*/
|
|
64
|
-
function newDistributor(args, accounts, programId) {
|
|
65
|
-
|
|
66
|
-
var keys = [
|
|
65
|
+
function newDistributor(args, accounts, programId = programId_1.PROGRAM_ID) {
|
|
66
|
+
const keys = [
|
|
67
67
|
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
68
68
|
{ pubkey: accounts.clawbackReceiver, isSigner: false, isWritable: true },
|
|
69
69
|
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
@@ -77,9 +77,9 @@ function newDistributor(args, accounts, programId) {
|
|
|
77
77
|
},
|
|
78
78
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
79
79
|
];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const identifier = buffer_1.Buffer.from([32, 139, 112, 171, 0, 2, 225, 155]);
|
|
81
|
+
const buffer = buffer_1.Buffer.alloc(1000);
|
|
82
|
+
const len = exports.layout.encode({
|
|
83
83
|
version: args.version,
|
|
84
84
|
root: args.root,
|
|
85
85
|
maxTotalClaim: args.maxTotalClaim,
|
|
@@ -93,8 +93,8 @@ function newDistributor(args, accounts, programId) {
|
|
|
93
93
|
totalAmountUnlocked: null,
|
|
94
94
|
totalAmountLocked: null,
|
|
95
95
|
}, buffer);
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const data = buffer_1.Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
97
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
98
98
|
return ix;
|
|
99
99
|
}
|
|
100
100
|
exports.newDistributor = newDistributor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setAdmin = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
const buffer_1 = require("buffer");
|
|
6
|
+
const programId_1 = require("../programId");
|
|
7
|
+
function setAdmin(accounts, programId = programId_1.PROGRAM_ID) {
|
|
8
|
+
const keys = [
|
|
9
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
11
|
+
{ pubkey: accounts.newAdmin, isSigner: false, isWritable: true },
|
|
12
|
+
];
|
|
13
|
+
const identifier = buffer_1.Buffer.from([251, 163, 0, 52, 91, 194, 187, 92]);
|
|
14
|
+
const data = identifier;
|
|
15
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
16
|
+
return ix;
|
|
17
|
+
}
|
|
18
|
+
exports.setAdmin = setAdmin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setClawbackReceiver = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
const buffer_1 = require("buffer");
|
|
6
|
+
const programId_1 = require("../programId");
|
|
7
|
+
function setClawbackReceiver(accounts, programId = programId_1.PROGRAM_ID) {
|
|
8
|
+
const keys = [
|
|
9
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.newClawbackAccount, isSigner: false, isWritable: false },
|
|
11
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
12
|
+
];
|
|
13
|
+
const identifier = buffer_1.Buffer.from([153, 217, 34, 20, 19, 29, 229, 75]);
|
|
14
|
+
const data = identifier;
|
|
15
|
+
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
16
|
+
return ix;
|
|
17
|
+
}
|
|
18
|
+
exports.setClawbackReceiver = setClawbackReceiver;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROGRAM_ID = exports.PROGRAM_ID_CLI = void 0;
|
|
4
|
-
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
// Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
|
|
6
6
|
exports.PROGRAM_ID_CLI = new web3_js_1.PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N");
|
|
7
7
|
// This constant will not get overwritten on subsequent code generations and it's safe to modify it's value.
|
|
@@ -32,9 +32,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
exports.constants = exports.SolanaDistributorClient = void 0;
|
|
33
33
|
var client_1 = require("./client");
|
|
34
34
|
Object.defineProperty(exports, "SolanaDistributorClient", { enumerable: true, get: function () { return __importDefault(client_1).default; } });
|
|
35
|
-
__exportStar(require("./generated/accounts"), exports);
|
|
36
|
-
__exportStar(require("./generated/errors"), exports);
|
|
37
|
-
__exportStar(require("./generated/instructions"), exports);
|
|
38
|
-
__exportStar(require("./utils"), exports);
|
|
39
|
-
__exportStar(require("./types"), exports);
|
|
40
|
-
exports.constants = __importStar(require("./constants"));
|
|
35
|
+
__exportStar(require("./generated/accounts/index.js"), exports);
|
|
36
|
+
__exportStar(require("./generated/errors/index.js"), exports);
|
|
37
|
+
__exportStar(require("./generated/instructions/index.js"), exports);
|
|
38
|
+
__exportStar(require("./utils.js"), exports);
|
|
39
|
+
__exportStar(require("./types.js"), exports);
|
|
40
|
+
exports.constants = __importStar(require("./constants.js"));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateAmountWithTransferFees = exports.wrappedSignAndExecuteTransaction = exports.getEventAuthorityPda = exports.getClaimantStatusPda = exports.getDistributorPda = exports.divCeilN = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const common_1 = require("@streamflow/common");
|
|
7
|
+
const solana_1 = require("@streamflow/common/solana");
|
|
8
|
+
const errors_1 = require("./generated/errors");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const divCeilN = (n, d) => n / d + (n % d ? BigInt(1) : BigInt(0));
|
|
11
|
+
exports.divCeilN = divCeilN;
|
|
12
|
+
function getDistributorPda(programId, mint, version) {
|
|
13
|
+
// Constructing the seed for the PDA
|
|
14
|
+
const seeds = [
|
|
15
|
+
buffer_1.Buffer.from("MerkleDistributor"),
|
|
16
|
+
mint.toBuffer(),
|
|
17
|
+
buffer_1.Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer)),
|
|
18
|
+
];
|
|
19
|
+
// Finding the PDA
|
|
20
|
+
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
21
|
+
}
|
|
22
|
+
exports.getDistributorPda = getDistributorPda;
|
|
23
|
+
function getClaimantStatusPda(programId, distributor, claimant) {
|
|
24
|
+
// Constructing the seed for the PDA
|
|
25
|
+
const seeds = [buffer_1.Buffer.from("ClaimStatus"), claimant.toBuffer(), distributor.toBuffer()];
|
|
26
|
+
// Finding the PDA
|
|
27
|
+
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
28
|
+
}
|
|
29
|
+
exports.getClaimantStatusPda = getClaimantStatusPda;
|
|
30
|
+
function getEventAuthorityPda(programId) {
|
|
31
|
+
// Constructing the seed for the PDA
|
|
32
|
+
const seeds = [buffer_1.Buffer.from("__event_authority")];
|
|
33
|
+
// Finding the PDA
|
|
34
|
+
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
35
|
+
}
|
|
36
|
+
exports.getEventAuthorityPda = getEventAuthorityPda;
|
|
37
|
+
async function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams) {
|
|
38
|
+
try {
|
|
39
|
+
return await (0, solana_1.signAndExecuteTransaction)(connection, invoker, tx, confirmationParams, throttleParams);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err instanceof Error) {
|
|
43
|
+
const parsed = (0, errors_1.fromTxError)(err);
|
|
44
|
+
if (parsed) {
|
|
45
|
+
throw new common_1.ContractError(err, parsed.name, parsed.msg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.wrappedSignAndExecuteTransaction = wrappedSignAndExecuteTransaction;
|
|
52
|
+
async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
|
|
53
|
+
const epoch = await connection.getEpochInfo();
|
|
54
|
+
const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch
|
|
55
|
+
? transferFeeConfig.newerTransferFee
|
|
56
|
+
: transferFeeConfig.olderTransferFee;
|
|
57
|
+
const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
|
|
58
|
+
let feeCharged = BigInt(0);
|
|
59
|
+
if (transferFeeBasisPoints !== BigInt(0)) {
|
|
60
|
+
const numerator = transferAmount * constants_1.ONE_IN_BASIS_POINTS;
|
|
61
|
+
const denominator = constants_1.ONE_IN_BASIS_POINTS - transferFeeBasisPoints;
|
|
62
|
+
const rawPreFeeAmount = (0, exports.divCeilN)(numerator, denominator);
|
|
63
|
+
const fee = rawPreFeeAmount - transferAmount;
|
|
64
|
+
transferAmount = rawPreFeeAmount;
|
|
65
|
+
feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
|
|
66
|
+
}
|
|
67
|
+
return { transferAmount, feeCharged };
|
|
68
|
+
}
|
|
69
|
+
exports.calculateAmountWithTransferFees = calculateAmountWithTransferFees;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as StreamflowDistributorSolana from "./solana/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as StreamflowDistributorSolana from "./solana/index.js";
|