@streamflow/distributor 7.0.0-alpha.2 → 7.0.0-alpha.20
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 +19 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/solana/clients/BaseDistributorClient.js +222 -0
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +104 -0
- package/dist/cjs/solana/clients/SolanaDistributorClient.js +17 -0
- package/dist/cjs/solana/clients/index.js +10 -0
- package/dist/cjs/solana/constants.js +22 -9
- package/dist/cjs/solana/descriptor/aligned_distributor.js +2 -0
- package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +1242 -0
- package/dist/cjs/solana/generated/accounts/ClaimStatus.js +56 -114
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +96 -129
- package/dist/cjs/solana/generated/errors/anchor.js +540 -717
- package/dist/cjs/solana/generated/errors/custom.js +171 -243
- package/dist/cjs/solana/generated/errors/index.js +12 -51
- package/dist/cjs/solana/generated/instructions/claimLocked.js +7 -8
- package/dist/cjs/solana/generated/instructions/clawback.js +8 -9
- package/dist/cjs/solana/generated/instructions/closeClaim.js +8 -9
- package/dist/cjs/solana/generated/instructions/newClaim.js +10 -11
- package/dist/cjs/solana/generated/instructions/newDistributor.js +17 -12
- package/dist/cjs/solana/generated/instructions/setAdmin.js +8 -9
- package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +8 -9
- package/dist/cjs/solana/generated/programId.js +1 -1
- package/dist/cjs/solana/index.js +8 -12
- package/dist/cjs/solana/utils.js +46 -94
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +39 -0
- package/dist/esm/solana/{client.js → clients/BaseDistributorClient.js} +97 -66
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +14 -0
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +99 -0
- package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +8 -0
- package/dist/esm/solana/clients/SolanaDistributorClient.js +11 -0
- package/dist/esm/solana/clients/index.d.ts +2 -0
- package/dist/esm/solana/clients/index.js +2 -0
- package/dist/esm/solana/constants.d.ts +15 -0
- package/dist/esm/solana/constants.js +14 -0
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +918 -0
- package/dist/esm/solana/descriptor/aligned_distributor.js +1 -0
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +1242 -0
- package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +17 -17
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +13 -13
- package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +55 -25
- package/dist/esm/solana/generated/accounts/MerkleDistributor.js +53 -18
- package/dist/esm/solana/generated/instructions/newClaim.d.ts +3 -3
- package/dist/esm/solana/generated/instructions/newDistributor.d.ts +8 -8
- package/dist/esm/solana/generated/instructions/newDistributor.js +6 -0
- package/dist/esm/solana/index.d.ts +7 -7
- package/dist/esm/solana/index.js +7 -7
- package/dist/esm/solana/types.d.ts +49 -4
- package/dist/esm/solana/utils.d.ts +2 -1
- package/dist/esm/solana/utils.js +11 -6
- package/package.json +9 -7
- package/dist/cjs/solana/client.js +0 -365
- package/dist/esm/solana/client.d.ts +0 -36
|
@@ -22,54 +22,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
64
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
29
|
exports.ClaimStatus = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
30
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
31
|
+
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
|
+
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
|
+
const programId_1 = require("../programId");
|
|
70
34
|
/** Holds whether or not a claimant has claimed tokens. */
|
|
71
|
-
|
|
72
|
-
|
|
35
|
+
class ClaimStatus {
|
|
36
|
+
constructor(fields) {
|
|
73
37
|
this.claimant = fields.claimant;
|
|
74
38
|
this.lockedAmount = fields.lockedAmount;
|
|
75
39
|
this.lockedAmountWithdrawn = fields.lockedAmountWithdrawn;
|
|
@@ -77,57 +41,36 @@ var ClaimStatus = /** @class */ (function () {
|
|
|
77
41
|
this.lastClaimTs = fields.lastClaimTs;
|
|
78
42
|
this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
|
|
79
43
|
this.closed = fields.closed;
|
|
80
|
-
this.
|
|
44
|
+
this.distributor = fields.distributor;
|
|
81
45
|
this.buffer2 = fields.buffer2;
|
|
82
46
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ClaimStatus.fetchMultiple = function (c, addresses, programId) {
|
|
104
|
-
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
var infos;
|
|
107
|
-
var _this = this;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0: return [4 /*yield*/, c.getMultipleAccountsInfo(addresses)];
|
|
111
|
-
case 1:
|
|
112
|
-
infos = _a.sent();
|
|
113
|
-
return [2 /*return*/, infos.map(function (info) {
|
|
114
|
-
if (info === null) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
if (!info.owner.equals(programId)) {
|
|
118
|
-
throw new Error("account doesn't belong to this program");
|
|
119
|
-
}
|
|
120
|
-
return _this.decode(info.data);
|
|
121
|
-
})];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
47
|
+
static async fetch(c, address, programId = programId_1.PROGRAM_ID) {
|
|
48
|
+
const info = await c.getAccountInfo(address);
|
|
49
|
+
if (info === null) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (!info.owner.equals(programId)) {
|
|
53
|
+
throw new Error("account doesn't belong to this program");
|
|
54
|
+
}
|
|
55
|
+
return this.decode(info.data);
|
|
56
|
+
}
|
|
57
|
+
static async fetchMultiple(c, addresses, programId = programId_1.PROGRAM_ID) {
|
|
58
|
+
const infos = await c.getMultipleAccountsInfo(addresses);
|
|
59
|
+
return infos.map((info) => {
|
|
60
|
+
if (info === null) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (!info.owner.equals(programId)) {
|
|
64
|
+
throw new Error("account doesn't belong to this program");
|
|
65
|
+
}
|
|
66
|
+
return this.decode(info.data);
|
|
124
67
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
68
|
+
}
|
|
69
|
+
static decode(data) {
|
|
127
70
|
if (!data.slice(0, 8).equals(ClaimStatus.discriminator)) {
|
|
128
71
|
throw new Error("invalid account discriminator");
|
|
129
72
|
}
|
|
130
|
-
|
|
73
|
+
const dec = ClaimStatus.layout.decode(data.slice(8));
|
|
131
74
|
return new ClaimStatus({
|
|
132
75
|
claimant: dec.claimant,
|
|
133
76
|
lockedAmount: dec.lockedAmount,
|
|
@@ -136,11 +79,11 @@ var ClaimStatus = /** @class */ (function () {
|
|
|
136
79
|
lastClaimTs: dec.lastClaimTs,
|
|
137
80
|
lastAmountPerUnlock: dec.lastAmountPerUnlock,
|
|
138
81
|
closed: dec.closed,
|
|
139
|
-
|
|
82
|
+
distributor: dec.distributor,
|
|
140
83
|
buffer2: dec.buffer2,
|
|
141
84
|
});
|
|
142
|
-
}
|
|
143
|
-
|
|
85
|
+
}
|
|
86
|
+
toJSON() {
|
|
144
87
|
return {
|
|
145
88
|
claimant: this.claimant.toString(),
|
|
146
89
|
lockedAmount: this.lockedAmount.toString(),
|
|
@@ -149,35 +92,34 @@ var ClaimStatus = /** @class */ (function () {
|
|
|
149
92
|
lastClaimTs: this.lastClaimTs.toString(),
|
|
150
93
|
lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
|
|
151
94
|
closed: this.closed,
|
|
152
|
-
|
|
95
|
+
distributor: this.distributor.toString(),
|
|
153
96
|
buffer2: this.buffer2,
|
|
154
97
|
};
|
|
155
|
-
}
|
|
156
|
-
|
|
98
|
+
}
|
|
99
|
+
static fromJSON(obj) {
|
|
157
100
|
return new ClaimStatus({
|
|
158
101
|
claimant: new web3_js_1.PublicKey(obj.claimant),
|
|
159
|
-
lockedAmount:
|
|
160
|
-
lockedAmountWithdrawn:
|
|
161
|
-
unlockedAmount:
|
|
162
|
-
lastClaimTs:
|
|
163
|
-
lastAmountPerUnlock:
|
|
102
|
+
lockedAmount: new bn_js_1.default(obj.lockedAmount),
|
|
103
|
+
lockedAmountWithdrawn: new bn_js_1.default(obj.lockedAmountWithdrawn),
|
|
104
|
+
unlockedAmount: new bn_js_1.default(obj.unlockedAmount),
|
|
105
|
+
lastClaimTs: new bn_js_1.default(obj.lastClaimTs),
|
|
106
|
+
lastAmountPerUnlock: new bn_js_1.default(obj.lastAmountPerUnlock),
|
|
164
107
|
closed: obj.closed,
|
|
165
|
-
|
|
108
|
+
distributor: new web3_js_1.PublicKey(obj.distributor),
|
|
166
109
|
buffer2: obj.buffer2,
|
|
167
110
|
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
ClaimStatus.layout = borsh.struct([
|
|
171
|
-
borsh.publicKey("claimant"),
|
|
172
|
-
borsh.u64("lockedAmount"),
|
|
173
|
-
borsh.u64("lockedAmountWithdrawn"),
|
|
174
|
-
borsh.u64("unlockedAmount"),
|
|
175
|
-
borsh.u64("lastClaimTs"),
|
|
176
|
-
borsh.u64("lastAmountPerUnlock"),
|
|
177
|
-
borsh.bool("closed"),
|
|
178
|
-
borsh.array(borsh.u8(), 32, "buffer1"),
|
|
179
|
-
borsh.array(borsh.u8(), 32, "buffer2"),
|
|
180
|
-
]);
|
|
181
|
-
return ClaimStatus;
|
|
182
|
-
}());
|
|
111
|
+
}
|
|
112
|
+
}
|
|
183
113
|
exports.ClaimStatus = ClaimStatus;
|
|
114
|
+
ClaimStatus.discriminator = Buffer.from([22, 183, 249, 157, 247, 95, 150, 96]);
|
|
115
|
+
ClaimStatus.layout = borsh.struct([
|
|
116
|
+
borsh.publicKey("claimant"),
|
|
117
|
+
borsh.u64("lockedAmount"),
|
|
118
|
+
borsh.u64("lockedAmountWithdrawn"),
|
|
119
|
+
borsh.u64("unlockedAmount"),
|
|
120
|
+
borsh.u64("lastClaimTs"),
|
|
121
|
+
borsh.u64("lastAmountPerUnlock"),
|
|
122
|
+
borsh.bool("closed"),
|
|
123
|
+
borsh.publicKey("distributor"),
|
|
124
|
+
borsh.array(borsh.u8(), 32, "buffer2"),
|
|
125
|
+
]);
|
|
@@ -22,54 +22,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
64
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
29
|
exports.MerkleDistributor = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
30
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
31
|
+
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
|
+
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
|
+
const programId_1 = require("../programId");
|
|
70
34
|
/** State for the account which distributes tokens. */
|
|
71
|
-
|
|
72
|
-
|
|
35
|
+
class MerkleDistributor {
|
|
36
|
+
constructor(fields) {
|
|
73
37
|
this.bump = fields.bump;
|
|
74
38
|
this.version = fields.version;
|
|
75
39
|
this.root = fields.root;
|
|
@@ -87,58 +51,42 @@ var MerkleDistributor = /** @class */ (function () {
|
|
|
87
51
|
this.admin = fields.admin;
|
|
88
52
|
this.clawedBack = fields.clawedBack;
|
|
89
53
|
this.claimsClosable = fields.claimsClosable;
|
|
90
|
-
this.
|
|
54
|
+
this.canUpdateDuration = fields.canUpdateDuration;
|
|
55
|
+
this.totalAmountUnlocked = fields.totalAmountUnlocked;
|
|
56
|
+
this.totalAmountLocked = fields.totalAmountLocked;
|
|
57
|
+
this.lastDurationUpdateTs = fields.lastDurationUpdateTs;
|
|
58
|
+
this.totalClaimablePreUpdate = fields.totalClaimablePreUpdate;
|
|
59
|
+
this.clawedBackTs = fields.clawedBackTs;
|
|
91
60
|
this.buffer2 = fields.buffer2;
|
|
92
61
|
this.buffer3 = fields.buffer3;
|
|
93
62
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
MerkleDistributor.fetchMultiple = function (c, addresses, programId) {
|
|
115
|
-
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
116
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
var infos;
|
|
118
|
-
var _this = this;
|
|
119
|
-
return __generator(this, function (_a) {
|
|
120
|
-
switch (_a.label) {
|
|
121
|
-
case 0: return [4 /*yield*/, c.getMultipleAccountsInfo(addresses)];
|
|
122
|
-
case 1:
|
|
123
|
-
infos = _a.sent();
|
|
124
|
-
return [2 /*return*/, infos.map(function (info) {
|
|
125
|
-
if (info === null) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
if (!info.owner.equals(programId)) {
|
|
129
|
-
throw new Error("account doesn't belong to this program");
|
|
130
|
-
}
|
|
131
|
-
return _this.decode(info.data);
|
|
132
|
-
})];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
63
|
+
static async fetch(c, address, programId = programId_1.PROGRAM_ID) {
|
|
64
|
+
const info = await c.getAccountInfo(address);
|
|
65
|
+
if (info === null) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (!info.owner.equals(programId)) {
|
|
69
|
+
throw new Error("account doesn't belong to this program");
|
|
70
|
+
}
|
|
71
|
+
return this.decode(info.data);
|
|
72
|
+
}
|
|
73
|
+
static async fetchMultiple(c, addresses, programId = programId_1.PROGRAM_ID) {
|
|
74
|
+
const infos = await c.getMultipleAccountsInfo(addresses);
|
|
75
|
+
return infos.map((info) => {
|
|
76
|
+
if (info === null) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!info.owner.equals(programId)) {
|
|
80
|
+
throw new Error("account doesn't belong to this program");
|
|
81
|
+
}
|
|
82
|
+
return this.decode(info.data);
|
|
135
83
|
});
|
|
136
|
-
}
|
|
137
|
-
|
|
84
|
+
}
|
|
85
|
+
static decode(data) {
|
|
138
86
|
if (!data.slice(0, 8).equals(MerkleDistributor.discriminator)) {
|
|
139
87
|
throw new Error("invalid account discriminator");
|
|
140
88
|
}
|
|
141
|
-
|
|
89
|
+
const dec = MerkleDistributor.layout.decode(data.slice(8));
|
|
142
90
|
return new MerkleDistributor({
|
|
143
91
|
bump: dec.bump,
|
|
144
92
|
version: dec.version,
|
|
@@ -157,12 +105,17 @@ var MerkleDistributor = /** @class */ (function () {
|
|
|
157
105
|
admin: dec.admin,
|
|
158
106
|
clawedBack: dec.clawedBack,
|
|
159
107
|
claimsClosable: dec.claimsClosable,
|
|
160
|
-
|
|
108
|
+
canUpdateDuration: dec.canUpdateDuration,
|
|
109
|
+
totalAmountUnlocked: dec.totalAmountUnlocked,
|
|
110
|
+
totalAmountLocked: dec.totalAmountLocked,
|
|
111
|
+
lastDurationUpdateTs: dec.lastDurationUpdateTs,
|
|
112
|
+
totalClaimablePreUpdate: dec.totalClaimablePreUpdate,
|
|
113
|
+
clawedBackTs: dec.clawedBackTs,
|
|
161
114
|
buffer2: dec.buffer2,
|
|
162
115
|
buffer3: dec.buffer3,
|
|
163
116
|
});
|
|
164
|
-
}
|
|
165
|
-
|
|
117
|
+
}
|
|
118
|
+
toJSON() {
|
|
166
119
|
return {
|
|
167
120
|
bump: this.bump,
|
|
168
121
|
version: this.version.toString(),
|
|
@@ -181,58 +134,72 @@ var MerkleDistributor = /** @class */ (function () {
|
|
|
181
134
|
admin: this.admin.toString(),
|
|
182
135
|
clawedBack: this.clawedBack,
|
|
183
136
|
claimsClosable: this.claimsClosable,
|
|
184
|
-
|
|
137
|
+
canUpdateDuration: this.canUpdateDuration,
|
|
138
|
+
totalAmountUnlocked: this.totalAmountUnlocked.toString(),
|
|
139
|
+
totalAmountLocked: this.totalAmountLocked.toString(),
|
|
140
|
+
lastDurationUpdateTs: this.lastDurationUpdateTs.toString(),
|
|
141
|
+
totalClaimablePreUpdate: this.totalClaimablePreUpdate.toString(),
|
|
142
|
+
clawedBackTs: this.clawedBackTs.toString(),
|
|
185
143
|
buffer2: this.buffer2,
|
|
186
144
|
buffer3: this.buffer3,
|
|
187
145
|
};
|
|
188
|
-
}
|
|
189
|
-
|
|
146
|
+
}
|
|
147
|
+
static fromJSON(obj) {
|
|
190
148
|
return new MerkleDistributor({
|
|
191
149
|
bump: obj.bump,
|
|
192
|
-
version:
|
|
150
|
+
version: new bn_js_1.default(obj.version),
|
|
193
151
|
root: obj.root,
|
|
194
152
|
mint: new web3_js_1.PublicKey(obj.mint),
|
|
195
153
|
tokenVault: new web3_js_1.PublicKey(obj.tokenVault),
|
|
196
|
-
maxTotalClaim:
|
|
197
|
-
maxNumNodes:
|
|
198
|
-
unlockPeriod:
|
|
199
|
-
totalAmountClaimed:
|
|
200
|
-
numNodesClaimed:
|
|
201
|
-
startTs:
|
|
202
|
-
endTs:
|
|
203
|
-
clawbackStartTs:
|
|
154
|
+
maxTotalClaim: new bn_js_1.default(obj.maxTotalClaim),
|
|
155
|
+
maxNumNodes: new bn_js_1.default(obj.maxNumNodes),
|
|
156
|
+
unlockPeriod: new bn_js_1.default(obj.unlockPeriod),
|
|
157
|
+
totalAmountClaimed: new bn_js_1.default(obj.totalAmountClaimed),
|
|
158
|
+
numNodesClaimed: new bn_js_1.default(obj.numNodesClaimed),
|
|
159
|
+
startTs: new bn_js_1.default(obj.startTs),
|
|
160
|
+
endTs: new bn_js_1.default(obj.endTs),
|
|
161
|
+
clawbackStartTs: new bn_js_1.default(obj.clawbackStartTs),
|
|
204
162
|
clawbackReceiver: new web3_js_1.PublicKey(obj.clawbackReceiver),
|
|
205
163
|
admin: new web3_js_1.PublicKey(obj.admin),
|
|
206
164
|
clawedBack: obj.clawedBack,
|
|
207
165
|
claimsClosable: obj.claimsClosable,
|
|
208
|
-
|
|
166
|
+
canUpdateDuration: obj.canUpdateDuration,
|
|
167
|
+
totalAmountUnlocked: new bn_js_1.default(obj.totalAmountUnlocked),
|
|
168
|
+
totalAmountLocked: new bn_js_1.default(obj.totalAmountLocked),
|
|
169
|
+
lastDurationUpdateTs: new bn_js_1.default(obj.lastDurationUpdateTs),
|
|
170
|
+
totalClaimablePreUpdate: new bn_js_1.default(obj.totalClaimablePreUpdate),
|
|
171
|
+
clawedBackTs: new bn_js_1.default(obj.clawedBackTs),
|
|
209
172
|
buffer2: obj.buffer2,
|
|
210
173
|
buffer3: obj.buffer3,
|
|
211
174
|
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
MerkleDistributor.layout = borsh.struct([
|
|
215
|
-
borsh.u8("bump"),
|
|
216
|
-
borsh.u64("version"),
|
|
217
|
-
borsh.array(borsh.u8(), 32, "root"),
|
|
218
|
-
borsh.publicKey("mint"),
|
|
219
|
-
borsh.publicKey("tokenVault"),
|
|
220
|
-
borsh.u64("maxTotalClaim"),
|
|
221
|
-
borsh.u64("maxNumNodes"),
|
|
222
|
-
borsh.u64("unlockPeriod"),
|
|
223
|
-
borsh.u64("totalAmountClaimed"),
|
|
224
|
-
borsh.u64("numNodesClaimed"),
|
|
225
|
-
borsh.u64("startTs"),
|
|
226
|
-
borsh.u64("endTs"),
|
|
227
|
-
borsh.u64("clawbackStartTs"),
|
|
228
|
-
borsh.publicKey("clawbackReceiver"),
|
|
229
|
-
borsh.publicKey("admin"),
|
|
230
|
-
borsh.bool("clawedBack"),
|
|
231
|
-
borsh.bool("claimsClosable"),
|
|
232
|
-
borsh.array(borsh.u8(), 32, "buffer1"),
|
|
233
|
-
borsh.array(borsh.u8(), 32, "buffer2"),
|
|
234
|
-
borsh.array(borsh.u8(), 32, "buffer3"),
|
|
235
|
-
]);
|
|
236
|
-
return MerkleDistributor;
|
|
237
|
-
}());
|
|
175
|
+
}
|
|
176
|
+
}
|
|
238
177
|
exports.MerkleDistributor = MerkleDistributor;
|
|
178
|
+
MerkleDistributor.discriminator = Buffer.from([77, 119, 139, 70, 84, 247, 12, 26]);
|
|
179
|
+
MerkleDistributor.layout = borsh.struct([
|
|
180
|
+
borsh.u8("bump"),
|
|
181
|
+
borsh.u64("version"),
|
|
182
|
+
borsh.array(borsh.u8(), 32, "root"),
|
|
183
|
+
borsh.publicKey("mint"),
|
|
184
|
+
borsh.publicKey("tokenVault"),
|
|
185
|
+
borsh.u64("maxTotalClaim"),
|
|
186
|
+
borsh.u64("maxNumNodes"),
|
|
187
|
+
borsh.u64("unlockPeriod"),
|
|
188
|
+
borsh.u64("totalAmountClaimed"),
|
|
189
|
+
borsh.u64("numNodesClaimed"),
|
|
190
|
+
borsh.u64("startTs"),
|
|
191
|
+
borsh.u64("endTs"),
|
|
192
|
+
borsh.u64("clawbackStartTs"),
|
|
193
|
+
borsh.publicKey("clawbackReceiver"),
|
|
194
|
+
borsh.publicKey("admin"),
|
|
195
|
+
borsh.bool("clawedBack"),
|
|
196
|
+
borsh.bool("claimsClosable"),
|
|
197
|
+
borsh.bool("canUpdateDuration"),
|
|
198
|
+
borsh.u64("totalAmountUnlocked"),
|
|
199
|
+
borsh.u64("totalAmountLocked"),
|
|
200
|
+
borsh.u64("lastDurationUpdateTs"),
|
|
201
|
+
borsh.u64("totalClaimablePreUpdate"),
|
|
202
|
+
borsh.u64("clawedBackTs"),
|
|
203
|
+
borsh.array(borsh.u8(), 23, "buffer2"),
|
|
204
|
+
borsh.array(borsh.u8(), 32, "buffer3"),
|
|
205
|
+
]);
|