@streamflow/distributor 7.0.0-alpha.8 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/solana/{client.js → clients/BaseDistributorClient.js} +73 -67
- 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 +12 -1
- 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 +11 -11
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +41 -16
- package/dist/cjs/solana/generated/errors/anchor.js +2 -2
- package/dist/cjs/solana/generated/errors/custom.js +2 -2
- package/dist/cjs/solana/generated/errors/index.js +2 -3
- package/dist/cjs/solana/generated/instructions/claimLocked.js +1 -2
- package/dist/cjs/solana/generated/instructions/clawback.js +1 -2
- package/dist/cjs/solana/generated/instructions/closeClaim.js +1 -2
- package/dist/cjs/solana/generated/instructions/newClaim.js +2 -2
- package/dist/cjs/solana/generated/instructions/newDistributor.js +2 -2
- package/dist/cjs/solana/generated/instructions/setAdmin.js +1 -2
- package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +1 -2
- package/dist/cjs/solana/index.js +2 -6
- package/dist/cjs/solana/types.js +2 -2
- package/dist/cjs/solana/utils.js +22 -16
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +39 -0
- package/dist/esm/solana/{client.js → clients/BaseDistributorClient.js} +73 -67
- 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 +11 -0
- package/dist/esm/solana/constants.js +12 -1
- 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 -18
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +13 -13
- package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +55 -26
- 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/index.d.ts +1 -1
- package/dist/esm/solana/index.js +1 -1
- package/dist/esm/solana/types.d.ts +45 -5
- package/dist/esm/solana/utils.d.ts +2 -1
- package/dist/esm/solana/utils.js +11 -6
- package/package.json +11 -9
- package/dist/esm/solana/client.d.ts +0 -38
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ClaimStatus = void 0;
|
|
30
30
|
const web3_js_1 = require("@solana/web3.js");
|
|
31
|
-
const
|
|
31
|
+
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
32
|
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
33
|
const programId_1 = require("../programId");
|
|
34
34
|
/** Holds whether or not a claimant has claimed tokens. */
|
|
@@ -41,7 +41,7 @@ class ClaimStatus {
|
|
|
41
41
|
this.lastClaimTs = fields.lastClaimTs;
|
|
42
42
|
this.lastAmountPerUnlock = fields.lastAmountPerUnlock;
|
|
43
43
|
this.closed = fields.closed;
|
|
44
|
-
this.
|
|
44
|
+
this.distributor = fields.distributor;
|
|
45
45
|
this.buffer2 = fields.buffer2;
|
|
46
46
|
}
|
|
47
47
|
static async fetch(c, address, programId = programId_1.PROGRAM_ID) {
|
|
@@ -79,7 +79,7 @@ class ClaimStatus {
|
|
|
79
79
|
lastClaimTs: dec.lastClaimTs,
|
|
80
80
|
lastAmountPerUnlock: dec.lastAmountPerUnlock,
|
|
81
81
|
closed: dec.closed,
|
|
82
|
-
|
|
82
|
+
distributor: dec.distributor,
|
|
83
83
|
buffer2: dec.buffer2,
|
|
84
84
|
});
|
|
85
85
|
}
|
|
@@ -92,20 +92,20 @@ class ClaimStatus {
|
|
|
92
92
|
lastClaimTs: this.lastClaimTs.toString(),
|
|
93
93
|
lastAmountPerUnlock: this.lastAmountPerUnlock.toString(),
|
|
94
94
|
closed: this.closed,
|
|
95
|
-
|
|
95
|
+
distributor: this.distributor.toString(),
|
|
96
96
|
buffer2: this.buffer2,
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
static fromJSON(obj) {
|
|
100
100
|
return new ClaimStatus({
|
|
101
101
|
claimant: new web3_js_1.PublicKey(obj.claimant),
|
|
102
|
-
lockedAmount:
|
|
103
|
-
lockedAmountWithdrawn:
|
|
104
|
-
unlockedAmount:
|
|
105
|
-
lastClaimTs:
|
|
106
|
-
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),
|
|
107
107
|
closed: obj.closed,
|
|
108
|
-
|
|
108
|
+
distributor: new web3_js_1.PublicKey(obj.distributor),
|
|
109
109
|
buffer2: obj.buffer2,
|
|
110
110
|
});
|
|
111
111
|
}
|
|
@@ -120,6 +120,6 @@ ClaimStatus.layout = borsh.struct([
|
|
|
120
120
|
borsh.u64("lastClaimTs"),
|
|
121
121
|
borsh.u64("lastAmountPerUnlock"),
|
|
122
122
|
borsh.bool("closed"),
|
|
123
|
-
borsh.
|
|
123
|
+
borsh.publicKey("distributor"),
|
|
124
124
|
borsh.array(borsh.u8(), 32, "buffer2"),
|
|
125
125
|
]);
|
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.MerkleDistributor = void 0;
|
|
30
30
|
const web3_js_1 = require("@solana/web3.js");
|
|
31
|
-
const
|
|
31
|
+
const bn_js_1 = __importDefault(require("bn.js")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
32
32
|
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
33
33
|
const programId_1 = require("../programId");
|
|
34
34
|
/** State for the account which distributes tokens. */
|
|
@@ -51,7 +51,12 @@ class MerkleDistributor {
|
|
|
51
51
|
this.admin = fields.admin;
|
|
52
52
|
this.clawedBack = fields.clawedBack;
|
|
53
53
|
this.claimsClosable = fields.claimsClosable;
|
|
54
|
-
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;
|
|
55
60
|
this.buffer2 = fields.buffer2;
|
|
56
61
|
this.buffer3 = fields.buffer3;
|
|
57
62
|
}
|
|
@@ -100,7 +105,12 @@ class MerkleDistributor {
|
|
|
100
105
|
admin: dec.admin,
|
|
101
106
|
clawedBack: dec.clawedBack,
|
|
102
107
|
claimsClosable: dec.claimsClosable,
|
|
103
|
-
|
|
108
|
+
canUpdateDuration: dec.canUpdateDuration,
|
|
109
|
+
totalAmountUnlocked: dec.totalAmountUnlocked,
|
|
110
|
+
totalAmountLocked: dec.totalAmountLocked,
|
|
111
|
+
lastDurationUpdateTs: dec.lastDurationUpdateTs,
|
|
112
|
+
totalClaimablePreUpdate: dec.totalClaimablePreUpdate,
|
|
113
|
+
clawedBackTs: dec.clawedBackTs,
|
|
104
114
|
buffer2: dec.buffer2,
|
|
105
115
|
buffer3: dec.buffer3,
|
|
106
116
|
});
|
|
@@ -124,7 +134,12 @@ class MerkleDistributor {
|
|
|
124
134
|
admin: this.admin.toString(),
|
|
125
135
|
clawedBack: this.clawedBack,
|
|
126
136
|
claimsClosable: this.claimsClosable,
|
|
127
|
-
|
|
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(),
|
|
128
143
|
buffer2: this.buffer2,
|
|
129
144
|
buffer3: this.buffer3,
|
|
130
145
|
};
|
|
@@ -132,23 +147,28 @@ class MerkleDistributor {
|
|
|
132
147
|
static fromJSON(obj) {
|
|
133
148
|
return new MerkleDistributor({
|
|
134
149
|
bump: obj.bump,
|
|
135
|
-
version:
|
|
150
|
+
version: new bn_js_1.default(obj.version),
|
|
136
151
|
root: obj.root,
|
|
137
152
|
mint: new web3_js_1.PublicKey(obj.mint),
|
|
138
153
|
tokenVault: new web3_js_1.PublicKey(obj.tokenVault),
|
|
139
|
-
maxTotalClaim:
|
|
140
|
-
maxNumNodes:
|
|
141
|
-
unlockPeriod:
|
|
142
|
-
totalAmountClaimed:
|
|
143
|
-
numNodesClaimed:
|
|
144
|
-
startTs:
|
|
145
|
-
endTs:
|
|
146
|
-
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),
|
|
147
162
|
clawbackReceiver: new web3_js_1.PublicKey(obj.clawbackReceiver),
|
|
148
163
|
admin: new web3_js_1.PublicKey(obj.admin),
|
|
149
164
|
clawedBack: obj.clawedBack,
|
|
150
165
|
claimsClosable: obj.claimsClosable,
|
|
151
|
-
|
|
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),
|
|
152
172
|
buffer2: obj.buffer2,
|
|
153
173
|
buffer3: obj.buffer3,
|
|
154
174
|
});
|
|
@@ -174,7 +194,12 @@ MerkleDistributor.layout = borsh.struct([
|
|
|
174
194
|
borsh.publicKey("admin"),
|
|
175
195
|
borsh.bool("clawedBack"),
|
|
176
196
|
borsh.bool("claimsClosable"),
|
|
177
|
-
borsh.
|
|
178
|
-
borsh.
|
|
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"),
|
|
179
204
|
borsh.array(borsh.u8(), 32, "buffer3"),
|
|
180
205
|
]);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AccountSysvarMismatch = exports.AccountNotAssociatedTokenAccount = exports.AccountNotProgramData = exports.AccountNotInitialized = exports.AccountNotSystemOwned = exports.AccountNotSigner = exports.InvalidProgramExecutable = exports.InvalidProgramId = exports.AccountOwnedByWrongProgram = exports.AccountNotMutable = exports.AccountNotEnoughKeys = exports.AccountDidNotSerialize = exports.AccountDidNotDeserialize = exports.AccountDiscriminatorMismatch = exports.AccountDiscriminatorNotFound = exports.AccountDiscriminatorAlreadySet = exports.RequireGteViolated = exports.RequireGtViolated = exports.RequireKeysNeqViolated = exports.RequireNeqViolated = exports.RequireKeysEqViolated = exports.RequireEqViolated = exports.RequireViolated = exports.ConstraintAccountIsNone = exports.ConstraintSpace = exports.ConstraintMintDecimals = exports.ConstraintMintFreezeAuthority = exports.ConstraintMintMintAuthority = exports.ConstraintTokenOwner = exports.ConstraintTokenMint = exports.ConstraintZero = exports.ConstraintAddress = exports.ConstraintClose = exports.ConstraintAssociatedInit = exports.ConstraintAssociated = exports.ConstraintState = exports.ConstraintExecutable = exports.ConstraintSeeds = exports.ConstraintRentExempt = exports.ConstraintOwner = exports.ConstraintRaw = exports.ConstraintSigner = exports.ConstraintHasOne = exports.ConstraintMut = exports.IdlInstructionInvalidProgram = exports.IdlInstructionStub = exports.InstructionDidNotSerialize = exports.InstructionDidNotDeserialize = exports.InstructionFallbackNotFound = exports.InstructionMissing = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.Deprecated = exports.DeclaredProgramIdMismatch = exports.AccountDuplicateReallocs = exports.AccountReallocExceedsLimit = void 0;
|
|
5
|
+
exports.fromCode = fromCode;
|
|
5
6
|
class InstructionMissing extends Error {
|
|
6
7
|
constructor(logs) {
|
|
7
8
|
super("100: 8 byte instruction identifier not provided");
|
|
@@ -709,4 +710,3 @@ function fromCode(code, logs) {
|
|
|
709
710
|
}
|
|
710
711
|
return null;
|
|
711
712
|
}
|
|
712
|
-
exports.fromCode = fromCode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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
|
+
exports.fromCode = fromCode;
|
|
4
5
|
class InsufficientUnlockedTokens extends Error {
|
|
5
6
|
constructor(logs) {
|
|
6
7
|
super("6000: Insufficient unlocked tokens");
|
|
@@ -253,4 +254,3 @@ function fromCode(code, logs) {
|
|
|
253
254
|
}
|
|
254
255
|
return null;
|
|
255
256
|
}
|
|
256
|
-
exports.fromCode = fromCode;
|
|
@@ -23,14 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.fromCode = fromCode;
|
|
27
|
+
exports.fromTxError = fromTxError;
|
|
27
28
|
const programId_1 = require("../programId");
|
|
28
29
|
const anchor = __importStar(require("./anchor"));
|
|
29
30
|
const custom = __importStar(require("./custom"));
|
|
30
31
|
function fromCode(code, logs) {
|
|
31
32
|
return code >= 6000 ? custom.fromCode(code, logs) : anchor.fromCode(code, logs);
|
|
32
33
|
}
|
|
33
|
-
exports.fromCode = fromCode;
|
|
34
34
|
function hasOwnProperty(obj, prop) {
|
|
35
35
|
return Object.hasOwnProperty.call(obj, prop);
|
|
36
36
|
}
|
|
@@ -62,4 +62,3 @@ function fromTxError(err, programId = programId_1.PROGRAM_ID) {
|
|
|
62
62
|
}
|
|
63
63
|
return fromCode(errorCode, err.logs);
|
|
64
64
|
}
|
|
65
|
-
exports.fromTxError = fromTxError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.claimLocked =
|
|
3
|
+
exports.claimLocked = claimLocked;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
5
|
const programId_1 = require("../programId");
|
|
6
6
|
function claimLocked(accounts, programId = programId_1.PROGRAM_ID) {
|
|
@@ -20,4 +20,3 @@ function claimLocked(accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
20
20
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
21
21
|
return ix;
|
|
22
22
|
}
|
|
23
|
-
exports.claimLocked = claimLocked;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clawback =
|
|
3
|
+
exports.clawback = clawback;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
5
|
const buffer_1 = require("buffer");
|
|
6
6
|
const programId_1 = require("../programId");
|
|
@@ -19,4 +19,3 @@ function clawback(accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
19
19
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
20
20
|
return ix;
|
|
21
21
|
}
|
|
22
|
-
exports.clawback = clawback;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.closeClaim =
|
|
3
|
+
exports.closeClaim = closeClaim;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
5
|
const buffer_1 = require("buffer");
|
|
6
6
|
const programId_1 = require("../programId");
|
|
@@ -19,4 +19,3 @@ function closeClaim(accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
19
19
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
20
20
|
return ix;
|
|
21
21
|
}
|
|
22
|
-
exports.closeClaim = closeClaim;
|
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.layout = void 0;
|
|
27
|
+
exports.newClaim = newClaim;
|
|
27
28
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
29
|
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
30
|
const programId_1 = require("../programId");
|
|
@@ -56,4 +57,3 @@ function newClaim(args, accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
56
57
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
57
58
|
return ix;
|
|
58
59
|
}
|
|
59
|
-
exports.newClaim = newClaim;
|
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.layout = void 0;
|
|
27
|
+
exports.newDistributor = newDistributor;
|
|
27
28
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
29
|
const borsh = __importStar(require("@coral-xyz/borsh")); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
29
30
|
const buffer_1 = require("buffer");
|
|
@@ -97,4 +98,3 @@ function newDistributor(args, accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
97
98
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
98
99
|
return ix;
|
|
99
100
|
}
|
|
100
|
-
exports.newDistributor = newDistributor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setAdmin =
|
|
3
|
+
exports.setAdmin = setAdmin;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
5
|
const buffer_1 = require("buffer");
|
|
6
6
|
const programId_1 = require("../programId");
|
|
@@ -15,4 +15,3 @@ function setAdmin(accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
15
15
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
16
16
|
return ix;
|
|
17
17
|
}
|
|
18
|
-
exports.setAdmin = setAdmin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setClawbackReceiver =
|
|
3
|
+
exports.setClawbackReceiver = setClawbackReceiver;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js"); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
5
|
const buffer_1 = require("buffer");
|
|
6
6
|
const programId_1 = require("../programId");
|
|
@@ -15,4 +15,3 @@ function setClawbackReceiver(accounts, programId = programId_1.PROGRAM_ID) {
|
|
|
15
15
|
const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
16
16
|
return ix;
|
|
17
17
|
}
|
|
18
|
-
exports.setClawbackReceiver = setClawbackReceiver;
|
package/dist/cjs/solana/index.js
CHANGED
|
@@ -25,13 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
__setModuleDefault(result, mod);
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
-
};
|
|
31
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.constants =
|
|
33
|
-
|
|
34
|
-
Object.defineProperty(exports, "SolanaDistributorClient", { enumerable: true, get: function () { return __importDefault(client_1).default; } });
|
|
29
|
+
exports.constants = void 0;
|
|
30
|
+
__exportStar(require("./clients/index.js"), exports);
|
|
35
31
|
__exportStar(require("./generated/accounts/index.js"), exports);
|
|
36
32
|
__exportStar(require("./generated/errors/index.js"), exports);
|
|
37
33
|
__exportStar(require("./generated/instructions/index.js"), exports);
|
package/dist/cjs/solana/types.js
CHANGED
|
@@ -111,7 +111,7 @@ var AnchorErrorCode;
|
|
|
111
111
|
AnchorErrorCode["DeclaredProgramIdMismatch"] = "DeclaredProgramIdMismatch";
|
|
112
112
|
/** The API being used is deprecated and should no longer be used */
|
|
113
113
|
AnchorErrorCode["Deprecated"] = "Deprecated";
|
|
114
|
-
})(AnchorErrorCode
|
|
114
|
+
})(AnchorErrorCode || (exports.AnchorErrorCode = AnchorErrorCode = {}));
|
|
115
115
|
var ContractErrorCode;
|
|
116
116
|
(function (ContractErrorCode) {
|
|
117
117
|
/** Insufficient unlocked tokens */
|
|
@@ -156,4 +156,4 @@ var ContractErrorCode;
|
|
|
156
156
|
ContractErrorCode["ClaimIsClosed"] = "ClaimIsClosed";
|
|
157
157
|
/** Claims are not closable */
|
|
158
158
|
ContractErrorCode["ClaimsAreNotClosable"] = "ClaimsAreNotClosable";
|
|
159
|
-
})(ContractErrorCode
|
|
159
|
+
})(ContractErrorCode || (exports.ContractErrorCode = ContractErrorCode = {}));
|
package/dist/cjs/solana/utils.js
CHANGED
|
@@ -1,46 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTestOraclePda = exports.getAlignedDistributorPda = void 0;
|
|
4
|
+
exports.getDistributorPda = getDistributorPda;
|
|
5
|
+
exports.getClaimantStatusPda = getClaimantStatusPda;
|
|
6
|
+
exports.getEventAuthorityPda = getEventAuthorityPda;
|
|
7
|
+
exports.wrappedSignAndExecuteTransaction = wrappedSignAndExecuteTransaction;
|
|
8
|
+
exports.calculateAmountWithTransferFees = calculateAmountWithTransferFees;
|
|
4
9
|
const buffer_1 = require("buffer");
|
|
5
10
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
11
|
const common_1 = require("@streamflow/common");
|
|
7
12
|
const solana_1 = require("@streamflow/common/solana");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
13
|
+
const index_js_1 = require("./generated/errors/index.js");
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const getAlignedDistributorPda = (programId, distributor) => {
|
|
16
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
|
|
17
|
+
};
|
|
18
|
+
exports.getAlignedDistributorPda = getAlignedDistributorPda;
|
|
19
|
+
const getTestOraclePda = (programId, mint, creator) => {
|
|
20
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_js_1.TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
21
|
+
};
|
|
22
|
+
exports.getTestOraclePda = getTestOraclePda;
|
|
12
23
|
function getDistributorPda(programId, mint, version) {
|
|
13
24
|
// Constructing the seed for the PDA
|
|
14
25
|
const seeds = [
|
|
15
|
-
|
|
26
|
+
constants_js_1.DISTRIBUTOR_PREFIX,
|
|
16
27
|
mint.toBuffer(),
|
|
17
28
|
buffer_1.Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer)),
|
|
18
29
|
];
|
|
19
30
|
// Finding the PDA
|
|
20
31
|
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
21
32
|
}
|
|
22
|
-
exports.getDistributorPda = getDistributorPda;
|
|
23
33
|
function getClaimantStatusPda(programId, distributor, claimant) {
|
|
24
34
|
// Constructing the seed for the PDA
|
|
25
|
-
const seeds = [
|
|
35
|
+
const seeds = [constants_js_1.CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
26
36
|
// Finding the PDA
|
|
27
37
|
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
28
38
|
}
|
|
29
|
-
exports.getClaimantStatusPda = getClaimantStatusPda;
|
|
30
39
|
function getEventAuthorityPda(programId) {
|
|
31
40
|
// Constructing the seed for the PDA
|
|
32
41
|
const seeds = [buffer_1.Buffer.from("__event_authority")];
|
|
33
42
|
// Finding the PDA
|
|
34
43
|
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
35
44
|
}
|
|
36
|
-
exports.getEventAuthorityPda = getEventAuthorityPda;
|
|
37
45
|
async function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams) {
|
|
38
46
|
try {
|
|
39
47
|
return await (0, solana_1.signAndExecuteTransaction)(connection, invoker, tx, confirmationParams, throttleParams);
|
|
40
48
|
}
|
|
41
49
|
catch (err) {
|
|
42
50
|
if (err instanceof Error) {
|
|
43
|
-
const parsed = (0,
|
|
51
|
+
const parsed = (0, index_js_1.fromTxError)(err);
|
|
44
52
|
if (parsed) {
|
|
45
53
|
throw new common_1.ContractError(err, parsed.name, parsed.msg);
|
|
46
54
|
}
|
|
@@ -48,7 +56,6 @@ async function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirm
|
|
|
48
56
|
throw err;
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
|
-
exports.wrappedSignAndExecuteTransaction = wrappedSignAndExecuteTransaction;
|
|
52
59
|
async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
|
|
53
60
|
const epoch = await connection.getEpochInfo();
|
|
54
61
|
const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch
|
|
@@ -57,13 +64,12 @@ async function calculateAmountWithTransferFees(connection, transferFeeConfig, tr
|
|
|
57
64
|
const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
|
|
58
65
|
let feeCharged = BigInt(0);
|
|
59
66
|
if (transferFeeBasisPoints !== BigInt(0)) {
|
|
60
|
-
const numerator = transferAmount *
|
|
61
|
-
const denominator =
|
|
62
|
-
const rawPreFeeAmount = (0,
|
|
67
|
+
const numerator = transferAmount * constants_js_1.ONE_IN_BASIS_POINTS;
|
|
68
|
+
const denominator = constants_js_1.ONE_IN_BASIS_POINTS - transferFeeBasisPoints;
|
|
69
|
+
const rawPreFeeAmount = (0, common_1.divCeilN)(numerator, denominator);
|
|
63
70
|
const fee = rawPreFeeAmount - transferAmount;
|
|
64
71
|
transferAmount = rawPreFeeAmount;
|
|
65
72
|
feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
|
|
66
73
|
}
|
|
67
74
|
return { transferAmount, feeCharged };
|
|
68
75
|
}
|
|
69
|
-
exports.calculateAmountWithTransferFees = calculateAmountWithTransferFees;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import PQueue from "p-queue";
|
|
2
|
+
import { Connection, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
|
+
import { ICluster, ITransactionResult } from "@streamflow/common";
|
|
4
|
+
import { IProgramAccount } from "@streamflow/common/solana";
|
|
5
|
+
import { IClaimData, IClawbackData, ICreateDistributorResult, IGetClaimData, IGetDistributors, ICreateSolanaExt, IInteractSolanaExt, ICreateDistributorData, ICreateAlignedDistributorData, ISearchDistributors } from "../types";
|
|
6
|
+
import { ClawbackAccounts, NewDistributorAccounts, NewDistributorArgs } from "../generated/instructions";
|
|
7
|
+
import { ClaimStatus, MerkleDistributor } from "../generated/accounts";
|
|
8
|
+
export interface IInitOptions {
|
|
9
|
+
clusterUrl: string;
|
|
10
|
+
cluster?: ICluster;
|
|
11
|
+
commitment?: Commitment | ConnectionConfig;
|
|
12
|
+
programId?: string;
|
|
13
|
+
sendRate?: number;
|
|
14
|
+
sendThrottler?: PQueue;
|
|
15
|
+
}
|
|
16
|
+
export default abstract class BaseDistributorClient {
|
|
17
|
+
protected connection: Connection;
|
|
18
|
+
protected programId: PublicKey;
|
|
19
|
+
protected commitment: Commitment | ConnectionConfig;
|
|
20
|
+
protected sendThrottler: PQueue;
|
|
21
|
+
constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, }: IInitOptions);
|
|
22
|
+
protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
|
|
23
|
+
protected abstract getClawbackInstruction(account: ClawbackAccounts): Promise<TransactionInstruction>;
|
|
24
|
+
getCommitment(): Commitment | undefined;
|
|
25
|
+
getDistributorProgramId(): PublicKey;
|
|
26
|
+
prepareCreateInstructions(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<{
|
|
27
|
+
distributorPublicKey: PublicKey;
|
|
28
|
+
ixs: TransactionInstruction[];
|
|
29
|
+
}>;
|
|
30
|
+
create(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<ICreateDistributorResult>;
|
|
31
|
+
claim(data: IClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
32
|
+
prepareClaimInstructions(data: IClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
33
|
+
prepareClawbackInstructions(data: IClawbackData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
34
|
+
clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
35
|
+
getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]>;
|
|
36
|
+
getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
|
|
37
|
+
searchDistributors(data: ISearchDistributors): Promise<IProgramAccount<MerkleDistributor>[]>;
|
|
38
|
+
protected getNewDistributorArgs(data: ICreateDistributorData): NewDistributorArgs;
|
|
39
|
+
}
|