@streamflow/distributor 7.5.3 → 8.0.0-alpha.p284.726ba98
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/cjs/index.cjs +3073 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +10 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.cjs +4 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.d.cts +932 -0
- package/dist/cjs/solana/descriptor/merkle_distributor.cjs +4 -0
- package/dist/cjs/solana/descriptor/merkle_distributor.cjs.map +1 -0
- package/dist/cjs/solana/descriptor/merkle_distributor.d.cts +1128 -0
- package/dist/cjs/solana/index.cjs +3067 -0
- package/dist/cjs/solana/index.cjs.map +1 -0
- package/dist/cjs/solana/index.d.cts +1485 -0
- package/dist/esm/index.d.ts +10 -1
- package/dist/esm/index.js +3047 -1
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +3 -1
- package/dist/esm/solana/descriptor/aligned_distributor.js +3 -1
- package/dist/esm/solana/descriptor/aligned_distributor.js.map +1 -0
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +851 -1182
- package/dist/esm/solana/descriptor/idl/merkle_distributor.json +1030 -0
- package/dist/esm/solana/descriptor/merkle_distributor.d.ts +3 -1
- package/dist/esm/solana/descriptor/merkle_distributor.js +3 -1
- package/dist/esm/solana/descriptor/merkle_distributor.js.map +1 -0
- package/dist/esm/solana/index.d.ts +1485 -7
- package/dist/esm/solana/index.js +3019 -7
- package/dist/esm/solana/index.js.map +1 -0
- package/package.json +56 -20
- package/dist/cjs/index.js +0 -27
- package/dist/cjs/solana/clients/BaseDistributorClient.js +0 -276
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +0 -116
- package/dist/cjs/solana/clients/SolanaDistributorClient.js +0 -17
- package/dist/cjs/solana/clients/index.js +0 -10
- package/dist/cjs/solana/constants.js +0 -28
- package/dist/cjs/solana/descriptor/aligned_distributor.js +0 -2
- package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +0 -1255
- package/dist/cjs/solana/descriptor/merkle_distributor.js +0 -2
- package/dist/cjs/solana/generated/accounts/ClaimStatus.js +0 -135
- package/dist/cjs/solana/generated/accounts/MerkleDistributor.js +0 -215
- package/dist/cjs/solana/generated/accounts/index.js +0 -7
- package/dist/cjs/solana/generated/errors/anchor.js +0 -712
- package/dist/cjs/solana/generated/errors/custom.js +0 -321
- package/dist/cjs/solana/generated/errors/index.js +0 -64
- package/dist/cjs/solana/generated/instructions/claimLocked.js +0 -22
- package/dist/cjs/solana/generated/instructions/clawback.js +0 -21
- package/dist/cjs/solana/generated/instructions/closeClaim.js +0 -57
- package/dist/cjs/solana/generated/instructions/index.js +0 -17
- package/dist/cjs/solana/generated/instructions/newClaim.js +0 -59
- package/dist/cjs/solana/generated/instructions/newDistributor.js +0 -104
- package/dist/cjs/solana/generated/instructions/setAdmin.js +0 -17
- package/dist/cjs/solana/generated/instructions/setClawbackReceiver.js +0 -17
- package/dist/cjs/solana/generated/programId.js +0 -8
- package/dist/cjs/solana/index.js +0 -36
- package/dist/cjs/solana/types.js +0 -159
- package/dist/cjs/solana/utils.js +0 -75
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +0 -43
- package/dist/esm/solana/clients/BaseDistributorClient.js +0 -274
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +0 -16
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +0 -111
- package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +0 -8
- package/dist/esm/solana/clients/SolanaDistributorClient.js +0 -11
- package/dist/esm/solana/clients/index.d.ts +0 -2
- package/dist/esm/solana/clients/index.js +0 -2
- package/dist/esm/solana/constants.d.ts +0 -24
- package/dist/esm/solana/constants.js +0 -25
- package/dist/esm/solana/generated/accounts/ClaimStatus.d.ts +0 -83
- package/dist/esm/solana/generated/accounts/ClaimStatus.js +0 -127
- package/dist/esm/solana/generated/accounts/MerkleDistributor.d.ts +0 -179
- package/dist/esm/solana/generated/accounts/MerkleDistributor.js +0 -239
- package/dist/esm/solana/generated/accounts/index.d.ts +0 -4
- package/dist/esm/solana/generated/accounts/index.js +0 -2
- package/dist/esm/solana/generated/errors/anchor.d.ts +0 -434
- package/dist/esm/solana/generated/errors/anchor.js +0 -707
- package/dist/esm/solana/generated/errors/custom.d.ts +0 -194
- package/dist/esm/solana/generated/errors/custom.js +0 -317
- package/dist/esm/solana/generated/errors/index.d.ts +0 -5
- package/dist/esm/solana/generated/errors/index.js +0 -37
- package/dist/esm/solana/generated/instructions/claimLocked.d.ts +0 -23
- package/dist/esm/solana/generated/instructions/claimLocked.js +0 -19
- package/dist/esm/solana/generated/instructions/clawback.d.ts +0 -17
- package/dist/esm/solana/generated/instructions/clawback.js +0 -18
- package/dist/esm/solana/generated/instructions/closeClaim.d.ts +0 -22
- package/dist/esm/solana/generated/instructions/closeClaim.js +0 -30
- package/dist/esm/solana/generated/instructions/index.d.ts +0 -14
- package/dist/esm/solana/generated/instructions/index.js +0 -7
- package/dist/esm/solana/generated/instructions/newClaim.d.ts +0 -29
- package/dist/esm/solana/generated/instructions/newClaim.js +0 -32
- package/dist/esm/solana/generated/instructions/newDistributor.d.ts +0 -58
- package/dist/esm/solana/generated/instructions/newDistributor.js +0 -77
- package/dist/esm/solana/generated/instructions/setAdmin.d.ts +0 -10
- package/dist/esm/solana/generated/instructions/setAdmin.js +0 -14
- package/dist/esm/solana/generated/instructions/setClawbackReceiver.d.ts +0 -10
- package/dist/esm/solana/generated/instructions/setClawbackReceiver.js +0 -14
- package/dist/esm/solana/generated/programId.d.ts +0 -3
- package/dist/esm/solana/generated/programId.js +0 -5
- package/dist/esm/solana/types.d.ts +0 -258
- package/dist/esm/solana/types.js +0 -156
- package/dist/esm/solana/utils.d.ts +0 -14
- package/dist/esm/solana/utils.js +0 -65
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setAdmin = setAdmin;
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setClawbackReceiver = setClawbackReceiver;
|
|
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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROGRAM_ID = exports.PROGRAM_ID_CLI = void 0;
|
|
4
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
// Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
|
|
6
|
-
exports.PROGRAM_ID_CLI = new web3_js_1.PublicKey("MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N");
|
|
7
|
-
// This constant will not get overwritten on subsequent code generations and it's safe to modify it's value.
|
|
8
|
-
exports.PROGRAM_ID = exports.PROGRAM_ID_CLI;
|
package/dist/cjs/solana/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.constants = void 0;
|
|
30
|
-
__exportStar(require("./clients/index.js"), exports);
|
|
31
|
-
__exportStar(require("./generated/accounts/index.js"), exports);
|
|
32
|
-
__exportStar(require("./generated/errors/index.js"), exports);
|
|
33
|
-
__exportStar(require("./generated/instructions/index.js"), exports);
|
|
34
|
-
__exportStar(require("./utils.js"), exports);
|
|
35
|
-
__exportStar(require("./types.js"), exports);
|
|
36
|
-
exports.constants = __importStar(require("./constants.js"));
|
package/dist/cjs/solana/types.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContractErrorCode = exports.AnchorErrorCode = void 0;
|
|
4
|
-
var AnchorErrorCode;
|
|
5
|
-
(function (AnchorErrorCode) {
|
|
6
|
-
/** 8 byte instruction identifier not provided */
|
|
7
|
-
AnchorErrorCode["InstructionMissing"] = "InstructionMissing";
|
|
8
|
-
/** Fallback functions are not supported */
|
|
9
|
-
AnchorErrorCode["InstructionFallbackNotFound"] = "InstructionFallbackNotFound";
|
|
10
|
-
/** The program could not deserialize the given instruction */
|
|
11
|
-
AnchorErrorCode["InstructionDidNotDeserialize"] = "InstructionDidNotDeserialize";
|
|
12
|
-
/** The program could not serialize the given instruction */
|
|
13
|
-
AnchorErrorCode["InstructionDidNotSerialize"] = "InstructionDidNotSerialize";
|
|
14
|
-
/** The program was compiled without idl instructions */
|
|
15
|
-
AnchorErrorCode["IdlInstructionStub"] = "IdlInstructionStub";
|
|
16
|
-
/** The transaction was given an invalid program for the IDL instruction */
|
|
17
|
-
AnchorErrorCode["IdlInstructionInvalidProgram"] = "IdlInstructionInvalidProgram";
|
|
18
|
-
/** A mut constraint was violated */
|
|
19
|
-
AnchorErrorCode["ConstraintMut"] = "ConstraintMut";
|
|
20
|
-
/** A has one constraint was violated */
|
|
21
|
-
AnchorErrorCode["ConstraintHasOne"] = "ConstraintHasOne";
|
|
22
|
-
/** A signer constraint was violated */
|
|
23
|
-
AnchorErrorCode["ConstraintSigner"] = "ConstraintSigner";
|
|
24
|
-
/** A raw constraint was violated */
|
|
25
|
-
AnchorErrorCode["ConstraintRaw"] = "ConstraintRaw";
|
|
26
|
-
/** An owner constraint was violated */
|
|
27
|
-
AnchorErrorCode["ConstraintOwner"] = "ConstraintOwner";
|
|
28
|
-
/** A rent exemption constraint was violated */
|
|
29
|
-
AnchorErrorCode["ConstraintRentExempt"] = "ConstraintRentExempt";
|
|
30
|
-
/** A seeds constraint was violated */
|
|
31
|
-
AnchorErrorCode["ConstraintSeeds"] = "ConstraintSeeds";
|
|
32
|
-
/** An executable constraint was violated */
|
|
33
|
-
AnchorErrorCode["ConstraintExecutable"] = "ConstraintExecutable";
|
|
34
|
-
/** Deprecated Error, feel free to replace with something else */
|
|
35
|
-
AnchorErrorCode["ConstraintState"] = "ConstraintState";
|
|
36
|
-
/** An associated constraint was violated */
|
|
37
|
-
AnchorErrorCode["ConstraintAssociated"] = "ConstraintAssociated";
|
|
38
|
-
/** An associated init constraint was violated */
|
|
39
|
-
AnchorErrorCode["ConstraintAssociatedInit"] = "ConstraintAssociatedInit";
|
|
40
|
-
/** A close constraint was violated */
|
|
41
|
-
AnchorErrorCode["ConstraintClose"] = "ConstraintClose";
|
|
42
|
-
/** An address constraint was violated */
|
|
43
|
-
AnchorErrorCode["ConstraintAddress"] = "ConstraintAddress";
|
|
44
|
-
/** Expected zero account discriminant */
|
|
45
|
-
AnchorErrorCode["ConstraintZero"] = "ConstraintZero";
|
|
46
|
-
/** A token mint constraint was violated */
|
|
47
|
-
AnchorErrorCode["ConstraintTokenMint"] = "ConstraintTokenMint";
|
|
48
|
-
/** A token owner constraint was violated */
|
|
49
|
-
AnchorErrorCode["ConstraintTokenOwner"] = "ConstraintTokenOwner";
|
|
50
|
-
/** A mint mint authority constraint was violated */
|
|
51
|
-
AnchorErrorCode["ConstraintMintMintAuthority"] = "ConstraintMintMintAuthority";
|
|
52
|
-
/** A mint freeze authority constraint was violated */
|
|
53
|
-
AnchorErrorCode["ConstraintMintFreezeAuthority"] = "ConstraintMintFreezeAuthority";
|
|
54
|
-
/** A mint decimals constraint was violated */
|
|
55
|
-
AnchorErrorCode["ConstraintMintDecimals"] = "ConstraintMintDecimals";
|
|
56
|
-
/** A space constraint was violated */
|
|
57
|
-
AnchorErrorCode["ConstraintSpace"] = "ConstraintSpace";
|
|
58
|
-
/** A required account for the constraint is None */
|
|
59
|
-
AnchorErrorCode["ConstraintAccountIsNone"] = "ConstraintAccountIsNone";
|
|
60
|
-
/** A require expression was violated */
|
|
61
|
-
AnchorErrorCode["RequireViolated"] = "RequireViolated";
|
|
62
|
-
/** A require_eq expression was violated */
|
|
63
|
-
AnchorErrorCode["RequireEqViolated"] = "RequireEqViolated";
|
|
64
|
-
/** A require_keys_eq expression was violated */
|
|
65
|
-
AnchorErrorCode["RequireKeysEqViolated"] = "RequireKeysEqViolated";
|
|
66
|
-
/** A require_neq expression was violated */
|
|
67
|
-
AnchorErrorCode["RequireNeqViolated"] = "RequireNeqViolated";
|
|
68
|
-
/** A require_keys_neq expression was violated */
|
|
69
|
-
AnchorErrorCode["RequireKeysNeqViolated"] = "RequireKeysNeqViolated";
|
|
70
|
-
/** A require_gt expression was violated */
|
|
71
|
-
AnchorErrorCode["RequireGtViolated"] = "RequireGtViolated";
|
|
72
|
-
/** A require_gte expression was violated */
|
|
73
|
-
AnchorErrorCode["RequireGteViolated"] = "RequireGteViolated";
|
|
74
|
-
/** The account discriminator was already set on this account */
|
|
75
|
-
AnchorErrorCode["AccountDiscriminatorAlreadySet"] = "AccountDiscriminatorAlreadySet";
|
|
76
|
-
/** No 8 byte discriminator was found on the account */
|
|
77
|
-
AnchorErrorCode["AccountDiscriminatorNotFound"] = "AccountDiscriminatorNotFound";
|
|
78
|
-
/** 8 byte discriminator did not match what was expected */
|
|
79
|
-
AnchorErrorCode["AccountDiscriminatorMismatch"] = "AccountDiscriminatorMismatch";
|
|
80
|
-
/** Failed to deserialize the account */
|
|
81
|
-
AnchorErrorCode["AccountDidNotDeserialize"] = "AccountDidNotDeserialize";
|
|
82
|
-
/** Failed to serialize the account */
|
|
83
|
-
AnchorErrorCode["AccountDidNotSerialize"] = "AccountDidNotSerialize";
|
|
84
|
-
/** Not enough account keys given to the instruction */
|
|
85
|
-
AnchorErrorCode["AccountNotEnoughKeys"] = "AccountNotEnoughKeys";
|
|
86
|
-
/** The given account is not mutable */
|
|
87
|
-
AnchorErrorCode["AccountNotMutable"] = "AccountNotMutable";
|
|
88
|
-
/** The given account is owned by a different program than expected */
|
|
89
|
-
AnchorErrorCode["AccountOwnedByWrongProgram"] = "AccountOwnedByWrongProgram";
|
|
90
|
-
/** Program ID was not as expected */
|
|
91
|
-
AnchorErrorCode["InvalidProgramId"] = "InvalidProgramId";
|
|
92
|
-
/** Program account is not executable */
|
|
93
|
-
AnchorErrorCode["InvalidProgramExecutable"] = "InvalidProgramExecutable";
|
|
94
|
-
/** The given account did not sign */
|
|
95
|
-
AnchorErrorCode["AccountNotSigner"] = "AccountNotSigner";
|
|
96
|
-
/** The given account is not owned by the system program */
|
|
97
|
-
AnchorErrorCode["AccountNotSystemOwned"] = "AccountNotSystemOwned";
|
|
98
|
-
/** The program expected this account to be already initialized */
|
|
99
|
-
AnchorErrorCode["AccountNotInitialized"] = "AccountNotInitialized";
|
|
100
|
-
/** The given account is not a program data account */
|
|
101
|
-
AnchorErrorCode["AccountNotProgramData"] = "AccountNotProgramData";
|
|
102
|
-
/** The given account is not the associated token account */
|
|
103
|
-
AnchorErrorCode["AccountNotAssociatedTokenAccount"] = "AccountNotAssociatedTokenAccount";
|
|
104
|
-
/** The given public key does not match the required sysvar */
|
|
105
|
-
AnchorErrorCode["AccountSysvarMismatch"] = "AccountSysvarMismatch";
|
|
106
|
-
/** The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit */
|
|
107
|
-
AnchorErrorCode["AccountReallocExceedsLimit"] = "AccountReallocExceedsLimit";
|
|
108
|
-
/** The account was duplicated for more than one reallocation */
|
|
109
|
-
AnchorErrorCode["AccountDuplicateReallocs"] = "AccountDuplicateReallocs";
|
|
110
|
-
/** The declared program id does not match the actual program id */
|
|
111
|
-
AnchorErrorCode["DeclaredProgramIdMismatch"] = "DeclaredProgramIdMismatch";
|
|
112
|
-
/** The API being used is deprecated and should no longer be used */
|
|
113
|
-
AnchorErrorCode["Deprecated"] = "Deprecated";
|
|
114
|
-
})(AnchorErrorCode || (exports.AnchorErrorCode = AnchorErrorCode = {}));
|
|
115
|
-
var ContractErrorCode;
|
|
116
|
-
(function (ContractErrorCode) {
|
|
117
|
-
/** Insufficient unlocked tokens */
|
|
118
|
-
ContractErrorCode["InsufficientUnlockedTokens"] = "InsufficientUnlockedTokens";
|
|
119
|
-
/** Deposit Start too far in future */
|
|
120
|
-
ContractErrorCode["StartTooFarInFuture"] = "StartTooFarInFuture";
|
|
121
|
-
/** Invalid Merkle proof */
|
|
122
|
-
ContractErrorCode["InvalidProof"] = "InvalidProof";
|
|
123
|
-
/** Exceeded maximum claim amount */
|
|
124
|
-
ContractErrorCode["ExceededMaxClaim"] = "ExceededMaxClaim";
|
|
125
|
-
/** Exceeded maximum node count */
|
|
126
|
-
ContractErrorCode["MaxNodesExceeded"] = "MaxNodesExceeded";
|
|
127
|
-
/** Account is not authorized to execute this instruction */
|
|
128
|
-
ContractErrorCode["Unauthorized"] = "Unauthorized";
|
|
129
|
-
/** Token account owner did not match intended owner */
|
|
130
|
-
ContractErrorCode["OwnerMismatch"] = "OwnerMismatch";
|
|
131
|
-
/** Clawback cannot be before vesting starts */
|
|
132
|
-
ContractErrorCode["ClawbackBeforeVesting"] = "ClawbackBeforeVesting";
|
|
133
|
-
/** Attempted clawback before start */
|
|
134
|
-
ContractErrorCode["ClawbackBeforeStart"] = "ClawbackBeforeStart";
|
|
135
|
-
/** Clawback already claimed */
|
|
136
|
-
ContractErrorCode["ClawbackAlreadyClaimed"] = "ClawbackAlreadyClaimed";
|
|
137
|
-
/** Clawback start must be at least one day after vesting end */
|
|
138
|
-
ContractErrorCode["InsufficientClawbackDelay"] = "InsufficientClawbackDelay";
|
|
139
|
-
/** New and old Clawback receivers are identical */
|
|
140
|
-
ContractErrorCode["SameClawbackReceiver"] = "SameClawbackReceiver";
|
|
141
|
-
/** New and old admin are identical */
|
|
142
|
-
ContractErrorCode["SameAdmin"] = "SameAdmin";
|
|
143
|
-
/** Claim window expired */
|
|
144
|
-
ContractErrorCode["ClaimExpired"] = "ClaimExpired";
|
|
145
|
-
/** Arithmetic Error (overflow/underflow) */
|
|
146
|
-
ContractErrorCode["ArithmeticError"] = "ArithmeticError";
|
|
147
|
-
/** Start Timestamp cannot be after end Timestamp */
|
|
148
|
-
ContractErrorCode["StartTimestampAfterEnd"] = "StartTimestampAfterEnd";
|
|
149
|
-
/** Timestamps cannot be in the past */
|
|
150
|
-
ContractErrorCode["TimestampsNotInFuture"] = "TimestampsNotInFuture";
|
|
151
|
-
/** Airdrop Version Mismatch */
|
|
152
|
-
ContractErrorCode["InvalidVersion"] = "InvalidVersion";
|
|
153
|
-
/** Invalid Mint */
|
|
154
|
-
ContractErrorCode["InvalidMint"] = "InvalidMint";
|
|
155
|
-
/** Claim is closed */
|
|
156
|
-
ContractErrorCode["ClaimIsClosed"] = "ClaimIsClosed";
|
|
157
|
-
/** Claims are not closable */
|
|
158
|
-
ContractErrorCode["ClaimsAreNotClosable"] = "ClaimsAreNotClosable";
|
|
159
|
-
})(ContractErrorCode || (exports.ContractErrorCode = ContractErrorCode = {}));
|
package/dist/cjs/solana/utils.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
9
|
-
const buffer_1 = require("buffer");
|
|
10
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
11
|
-
const common_1 = require("@streamflow/common");
|
|
12
|
-
const solana_1 = require("@streamflow/common/solana");
|
|
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;
|
|
23
|
-
function getDistributorPda(programId, mint, version) {
|
|
24
|
-
// Constructing the seed for the PDA
|
|
25
|
-
const seeds = [
|
|
26
|
-
constants_js_1.DISTRIBUTOR_PREFIX,
|
|
27
|
-
mint.toBuffer(),
|
|
28
|
-
buffer_1.Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer)),
|
|
29
|
-
];
|
|
30
|
-
// Finding the PDA
|
|
31
|
-
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
32
|
-
}
|
|
33
|
-
function getClaimantStatusPda(programId, distributor, claimant) {
|
|
34
|
-
// Constructing the seed for the PDA
|
|
35
|
-
const seeds = [constants_js_1.CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
36
|
-
// Finding the PDA
|
|
37
|
-
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
38
|
-
}
|
|
39
|
-
function getEventAuthorityPda(programId) {
|
|
40
|
-
// Constructing the seed for the PDA
|
|
41
|
-
const seeds = [buffer_1.Buffer.from("__event_authority")];
|
|
42
|
-
// Finding the PDA
|
|
43
|
-
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
44
|
-
}
|
|
45
|
-
async function wrappedSignAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams) {
|
|
46
|
-
try {
|
|
47
|
-
return await (0, solana_1.signAndExecuteTransaction)(connection, invoker, tx, confirmationParams, throttleParams);
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
if (err instanceof Error) {
|
|
51
|
-
const parsed = (0, index_js_1.fromTxError)(err);
|
|
52
|
-
if (parsed) {
|
|
53
|
-
throw new common_1.ContractError(err, parsed.name, parsed.msg);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function calculateAmountWithTransferFees(connection, transferFeeConfig, transferAmount) {
|
|
60
|
-
const epoch = await connection.getEpochInfo();
|
|
61
|
-
const transferFee = epoch.epoch >= transferFeeConfig.newerTransferFee.epoch
|
|
62
|
-
? transferFeeConfig.newerTransferFee
|
|
63
|
-
: transferFeeConfig.olderTransferFee;
|
|
64
|
-
const transferFeeBasisPoints = BigInt(transferFee.transferFeeBasisPoints);
|
|
65
|
-
let feeCharged = BigInt(0);
|
|
66
|
-
if (transferFeeBasisPoints !== BigInt(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);
|
|
70
|
-
const fee = rawPreFeeAmount - transferAmount;
|
|
71
|
-
transferAmount = rawPreFeeAmount;
|
|
72
|
-
feeCharged = fee > transferFee.maximumFee ? transferFee.maximumFee : fee;
|
|
73
|
-
}
|
|
74
|
-
return { transferAmount, feeCharged };
|
|
75
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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, ICloseClaimData } 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
|
-
getConnection(): Connection;
|
|
25
|
-
getCommitment(): Commitment | undefined;
|
|
26
|
-
getDistributorProgramId(): PublicKey;
|
|
27
|
-
prepareCreateInstructions(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<{
|
|
28
|
-
distributorPublicKey: PublicKey;
|
|
29
|
-
ixs: TransactionInstruction[];
|
|
30
|
-
}>;
|
|
31
|
-
create(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<ICreateDistributorResult>;
|
|
32
|
-
claim(data: IClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
33
|
-
prepareClaimInstructions(data: IClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
34
|
-
closeClaim(data: ICloseClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
35
|
-
prepareCloseClaimInstructions(data: ICloseClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
36
|
-
prepareClawbackInstructions(data: IClawbackData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
37
|
-
clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
38
|
-
getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]>;
|
|
39
|
-
getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
|
|
40
|
-
searchDistributors(data: ISearchDistributors): Promise<IProgramAccount<MerkleDistributor>[]>;
|
|
41
|
-
protected prepareClaimFeeInstruction(payer: PublicKey): TransactionInstruction;
|
|
42
|
-
protected getNewDistributorArgs(data: ICreateDistributorData): NewDistributorArgs;
|
|
43
|
-
}
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import BN from "bn.js";
|
|
2
|
-
import { Connection, PublicKey, SystemProgram, } from "@solana/web3.js";
|
|
3
|
-
import { ICluster } from "@streamflow/common";
|
|
4
|
-
import { ata, checkOrCreateAtaBatch, prepareBaseInstructions, prepareTransaction, getMintAndProgram, buildSendThrottler, prepareWrappedAccount, pk, } from "@streamflow/common/solana";
|
|
5
|
-
import { ASSOCIATED_TOKEN_PROGRAM_ID, createTransferCheckedInstruction, createTransferCheckedWithFeeInstruction, getTransferFeeConfig, NATIVE_MINT, } from "@solana/spl-token";
|
|
6
|
-
import bs58 from "bs58";
|
|
7
|
-
import { AIRDROP_CLAIM_FEE, DISTRIBUTOR_ADMIN_OFFSET, DISTRIBUTOR_MINT_OFFSET, DISTRIBUTOR_PROGRAM_ID, STREAMFLOW_TREASURY_PUBLIC_KEY, } from "../constants";
|
|
8
|
-
import { claimLocked, newClaim, } from "../generated/instructions";
|
|
9
|
-
import { ClaimStatus, MerkleDistributor } from "../generated/accounts";
|
|
10
|
-
import { calculateAmountWithTransferFees, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, wrappedSignAndExecuteTransaction, } from "../utils";
|
|
11
|
-
import { closeClaim } from "../generated/instructions/closeClaim";
|
|
12
|
-
export default class BaseDistributorClient {
|
|
13
|
-
connection;
|
|
14
|
-
programId;
|
|
15
|
-
commitment;
|
|
16
|
-
sendThrottler;
|
|
17
|
-
constructor({ clusterUrl, cluster = ICluster.Mainnet, commitment = "confirmed", programId = "", sendRate = 1, sendThrottler, }) {
|
|
18
|
-
this.commitment = commitment;
|
|
19
|
-
this.connection = new Connection(clusterUrl, this.commitment);
|
|
20
|
-
this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(DISTRIBUTOR_PROGRAM_ID[cluster]);
|
|
21
|
-
this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
|
|
22
|
-
}
|
|
23
|
-
getConnection() {
|
|
24
|
-
return this.connection;
|
|
25
|
-
}
|
|
26
|
-
getCommitment() {
|
|
27
|
-
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
28
|
-
}
|
|
29
|
-
getDistributorProgramId() {
|
|
30
|
-
return this.programId;
|
|
31
|
-
}
|
|
32
|
-
async prepareCreateInstructions(data, extParams) {
|
|
33
|
-
if (!extParams.invoker.publicKey) {
|
|
34
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
35
|
-
}
|
|
36
|
-
const { version, mint } = data;
|
|
37
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
38
|
-
const mintPublicKey = extParams.isNative ? NATIVE_MINT : new PublicKey(mint);
|
|
39
|
-
const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
|
|
40
|
-
const transferFeeConfig = getTransferFeeConfig(mintAccount);
|
|
41
|
-
const distributorPublicKey = getDistributorPda(this.programId, mintPublicKey, version);
|
|
42
|
-
const tokenVault = await ata(mintPublicKey, distributorPublicKey, tokenProgramId);
|
|
43
|
-
const senderTokens = await ata(mintPublicKey, extParams.invoker.publicKey, tokenProgramId);
|
|
44
|
-
const accounts = {
|
|
45
|
-
distributor: distributorPublicKey,
|
|
46
|
-
clawbackReceiver: senderTokens,
|
|
47
|
-
mint: mintPublicKey,
|
|
48
|
-
tokenVault,
|
|
49
|
-
admin: extParams.invoker.publicKey,
|
|
50
|
-
systemProgram: SystemProgram.programId,
|
|
51
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
52
|
-
tokenProgram: tokenProgramId,
|
|
53
|
-
};
|
|
54
|
-
if (extParams.isNative) {
|
|
55
|
-
ixs.push(...(await prepareWrappedAccount(this.connection, extParams.invoker.publicKey, new BN(data.maxTotalClaim))));
|
|
56
|
-
}
|
|
57
|
-
const newDistributorInstruction = await this.getNewDistributorInstruction(data, accounts);
|
|
58
|
-
ixs.push(newDistributorInstruction);
|
|
59
|
-
if (transferFeeConfig) {
|
|
60
|
-
const { transferAmount, feeCharged } = await calculateAmountWithTransferFees(this.connection, transferFeeConfig, BigInt(data.maxTotalClaim.toString()));
|
|
61
|
-
ixs.push(createTransferCheckedWithFeeInstruction(senderTokens, mintPublicKey, tokenVault, extParams.invoker.publicKey, transferAmount, mintAccount.decimals, feeCharged, undefined, tokenProgramId));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
ixs.push(createTransferCheckedInstruction(senderTokens, mintPublicKey, tokenVault, extParams.invoker.publicKey, BigInt(data.maxTotalClaim.toString()), mintAccount.decimals, undefined, tokenProgramId));
|
|
65
|
-
}
|
|
66
|
-
return { distributorPublicKey, ixs };
|
|
67
|
-
}
|
|
68
|
-
async create(data, extParams) {
|
|
69
|
-
const { ixs, distributorPublicKey } = await this.prepareCreateInstructions(data, extParams);
|
|
70
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
71
|
-
const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
|
|
72
|
-
hash,
|
|
73
|
-
context,
|
|
74
|
-
commitment: this.getCommitment(),
|
|
75
|
-
}, { sendThrottler: this.sendThrottler });
|
|
76
|
-
return {
|
|
77
|
-
ixs,
|
|
78
|
-
txId: signature,
|
|
79
|
-
metadataId: distributorPublicKey.toBase58(),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
async claim(data, extParams) {
|
|
83
|
-
const ixs = await this.prepareClaimInstructions(data, extParams);
|
|
84
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
85
|
-
const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
|
|
86
|
-
hash,
|
|
87
|
-
context,
|
|
88
|
-
commitment: this.getCommitment(),
|
|
89
|
-
}, { sendThrottler: this.sendThrottler });
|
|
90
|
-
return { ixs, txId: signature };
|
|
91
|
-
}
|
|
92
|
-
async prepareClaimInstructions(data, extParams) {
|
|
93
|
-
if (!extParams.invoker.publicKey) {
|
|
94
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
95
|
-
}
|
|
96
|
-
const distributorPublicKey = new PublicKey(data.id);
|
|
97
|
-
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
98
|
-
if (!distributor) {
|
|
99
|
-
throw new Error("Couldn't get account info");
|
|
100
|
-
}
|
|
101
|
-
const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
|
|
102
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
103
|
-
ixs.push(...(await checkOrCreateAtaBatch(this.connection, [extParams.invoker.publicKey], distributor.mint, extParams.invoker, tokenProgramId)));
|
|
104
|
-
const invokerTokens = await ata(distributor.mint, extParams.invoker.publicKey, tokenProgramId);
|
|
105
|
-
const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, extParams.invoker.publicKey);
|
|
106
|
-
const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
|
|
107
|
-
const claimStatus = await ClaimStatus.fetch(this.connection, claimStatusPublicKey);
|
|
108
|
-
const accounts = {
|
|
109
|
-
distributor: distributorPublicKey,
|
|
110
|
-
claimStatus: claimStatusPublicKey,
|
|
111
|
-
from: distributor.tokenVault,
|
|
112
|
-
to: invokerTokens,
|
|
113
|
-
claimant: extParams.invoker.publicKey,
|
|
114
|
-
mint: distributor.mint,
|
|
115
|
-
tokenProgram: tokenProgramId,
|
|
116
|
-
systemProgram: SystemProgram.programId,
|
|
117
|
-
eventAuthority: eventAuthorityPublicKey,
|
|
118
|
-
program: this.programId,
|
|
119
|
-
};
|
|
120
|
-
if (!claimStatus) {
|
|
121
|
-
const args = {
|
|
122
|
-
amountLocked: new BN(data.amountLocked),
|
|
123
|
-
amountUnlocked: new BN(data.amountUnlocked),
|
|
124
|
-
proof: data.proof,
|
|
125
|
-
};
|
|
126
|
-
ixs.push(newClaim(args, accounts, this.programId));
|
|
127
|
-
}
|
|
128
|
-
const nowTs = new BN(Math.floor(Date.now() / 1000));
|
|
129
|
-
if (claimStatus ||
|
|
130
|
-
(new BN(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod))) {
|
|
131
|
-
ixs.push(claimLocked(accounts, this.programId));
|
|
132
|
-
}
|
|
133
|
-
ixs.push(this.prepareClaimFeeInstruction(extParams.invoker.publicKey));
|
|
134
|
-
return ixs;
|
|
135
|
-
}
|
|
136
|
-
async closeClaim(data, extParams) {
|
|
137
|
-
const ixs = await this.prepareCloseClaimInstructions(data, extParams);
|
|
138
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
139
|
-
const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
|
|
140
|
-
hash,
|
|
141
|
-
context,
|
|
142
|
-
commitment: this.getCommitment(),
|
|
143
|
-
}, { sendThrottler: this.sendThrottler });
|
|
144
|
-
return { ixs, txId: signature };
|
|
145
|
-
}
|
|
146
|
-
async prepareCloseClaimInstructions(data, extParams) {
|
|
147
|
-
if (!extParams.invoker.publicKey) {
|
|
148
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
149
|
-
}
|
|
150
|
-
const distributorPublicKey = new PublicKey(data.id);
|
|
151
|
-
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
152
|
-
const claimantPublicKey = pk(data.claimant);
|
|
153
|
-
if (!distributor) {
|
|
154
|
-
throw new Error("Couldn't get distributor account info");
|
|
155
|
-
}
|
|
156
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
157
|
-
const claimStatusPublicKey = getClaimantStatusPda(this.programId, distributorPublicKey, claimantPublicKey);
|
|
158
|
-
const eventAuthorityPublicKey = getEventAuthorityPda(this.programId);
|
|
159
|
-
const closeClaimAccounts = {
|
|
160
|
-
adminOrClaimant: extParams.invoker.publicKey,
|
|
161
|
-
distributor: distributorPublicKey,
|
|
162
|
-
claimStatus: claimStatusPublicKey,
|
|
163
|
-
claimant: claimantPublicKey,
|
|
164
|
-
systemProgram: SystemProgram.programId,
|
|
165
|
-
eventAuthority: eventAuthorityPublicKey,
|
|
166
|
-
program: this.programId,
|
|
167
|
-
};
|
|
168
|
-
const closeClaimArgs = {
|
|
169
|
-
amountLocked: data.amountLocked ? new BN(data.amountLocked) : undefined,
|
|
170
|
-
amountUnlocked: data.amountUnlocked ? new BN(data.amountUnlocked) : undefined,
|
|
171
|
-
proof: data.proof,
|
|
172
|
-
};
|
|
173
|
-
ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
|
|
174
|
-
return ixs;
|
|
175
|
-
}
|
|
176
|
-
async prepareClawbackInstructions(data, extParams) {
|
|
177
|
-
if (!extParams.invoker.publicKey) {
|
|
178
|
-
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
179
|
-
}
|
|
180
|
-
const distributorPublicKey = new PublicKey(data.id);
|
|
181
|
-
const distributor = await MerkleDistributor.fetch(this.connection, distributorPublicKey);
|
|
182
|
-
if (!distributor) {
|
|
183
|
-
throw new Error("Couldn't get account info");
|
|
184
|
-
}
|
|
185
|
-
const { tokenProgramId } = await getMintAndProgram(this.connection, distributor.mint);
|
|
186
|
-
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
187
|
-
ixs.push(...(await checkOrCreateAtaBatch(this.connection, [extParams.invoker.publicKey], distributor.mint, extParams.invoker, tokenProgramId)));
|
|
188
|
-
const accounts = {
|
|
189
|
-
distributor: distributorPublicKey,
|
|
190
|
-
from: distributor.tokenVault,
|
|
191
|
-
to: distributor.clawbackReceiver,
|
|
192
|
-
admin: extParams.invoker.publicKey,
|
|
193
|
-
mint: distributor.mint,
|
|
194
|
-
systemProgram: SystemProgram.programId,
|
|
195
|
-
tokenProgram: tokenProgramId,
|
|
196
|
-
};
|
|
197
|
-
const clawbackInstruction = await this.getClawbackInstruction(accounts);
|
|
198
|
-
ixs.push(clawbackInstruction);
|
|
199
|
-
return ixs;
|
|
200
|
-
}
|
|
201
|
-
async clawback(data, extParams) {
|
|
202
|
-
const ixs = await this.prepareClawbackInstructions(data, extParams);
|
|
203
|
-
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
204
|
-
const signature = await wrappedSignAndExecuteTransaction(this.connection, extParams.invoker, tx, {
|
|
205
|
-
hash,
|
|
206
|
-
context,
|
|
207
|
-
commitment: this.getCommitment(),
|
|
208
|
-
}, { sendThrottler: this.sendThrottler });
|
|
209
|
-
return { ixs, txId: signature };
|
|
210
|
-
}
|
|
211
|
-
async getClaims(data) {
|
|
212
|
-
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
213
|
-
return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
|
|
214
|
-
});
|
|
215
|
-
return ClaimStatus.fetchMultiple(this.connection, claimStatusPublicKeys, this.programId);
|
|
216
|
-
}
|
|
217
|
-
async getDistributors(data) {
|
|
218
|
-
const distributorPublicKeys = data.ids.map((distributorId) => new PublicKey(distributorId));
|
|
219
|
-
return MerkleDistributor.fetchMultiple(this.connection, distributorPublicKeys, this.programId);
|
|
220
|
-
}
|
|
221
|
-
async searchDistributors(data) {
|
|
222
|
-
const filters = [{ memcmp: { offset: 0, bytes: bs58.encode(MerkleDistributor.discriminator) } }];
|
|
223
|
-
if (data.mint) {
|
|
224
|
-
filters.push({
|
|
225
|
-
memcmp: {
|
|
226
|
-
offset: DISTRIBUTOR_MINT_OFFSET,
|
|
227
|
-
bytes: data.mint,
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
if (data.admin) {
|
|
232
|
-
filters.push({
|
|
233
|
-
memcmp: {
|
|
234
|
-
offset: DISTRIBUTOR_ADMIN_OFFSET,
|
|
235
|
-
bytes: data.admin,
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
const accounts = await this.connection.getProgramAccounts(this.programId, { filters });
|
|
240
|
-
return accounts.map(({ pubkey, account }) => ({
|
|
241
|
-
publicKey: pubkey,
|
|
242
|
-
account: MerkleDistributor.decode(account.data),
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
prepareClaimFeeInstruction(payer) {
|
|
246
|
-
return SystemProgram.transfer({
|
|
247
|
-
fromPubkey: payer,
|
|
248
|
-
toPubkey: STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
249
|
-
lamports: AIRDROP_CLAIM_FEE,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
getNewDistributorArgs(data) {
|
|
253
|
-
const args = {
|
|
254
|
-
version: new BN(data.version),
|
|
255
|
-
root: data.root,
|
|
256
|
-
maxTotalClaim: new BN(data.maxTotalClaim),
|
|
257
|
-
maxNumNodes: new BN(data.maxNumNodes),
|
|
258
|
-
unlockPeriod: new BN(data.unlockPeriod),
|
|
259
|
-
startVestingTs: new BN(data.startVestingTs),
|
|
260
|
-
endVestingTs: new BN(data.endVestingTs),
|
|
261
|
-
clawbackStartTs: new BN(data.clawbackStartTs),
|
|
262
|
-
claimsClosableByAdmin: data.claimsClosableByAdmin,
|
|
263
|
-
claimsClosableByClaimant: data.claimsClosableByClaimant,
|
|
264
|
-
claimsLimit: data.claimsLimit,
|
|
265
|
-
};
|
|
266
|
-
const nowTs = new BN(Math.floor(Date.now() / 1000));
|
|
267
|
-
const endVestingTs = args.endVestingTs.isZero() ? nowTs : args.endVestingTs;
|
|
268
|
-
const startVestingTs = args.startVestingTs.isZero() ? nowTs : args.startVestingTs;
|
|
269
|
-
if (endVestingTs.gt(startVestingTs) && endVestingTs.sub(startVestingTs).lt(args.unlockPeriod)) {
|
|
270
|
-
throw new Error("The unlock period cannot be longer than the total vesting duration!");
|
|
271
|
-
}
|
|
272
|
-
return args;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import { Program } from "@coral-xyz/anchor";
|
|
3
|
-
import { ICreateAlignedDistributorData, AlignedDistributorData, NewAlignedDistributorArgs } from "../types";
|
|
4
|
-
import { ClawbackAccounts, NewDistributorAccounts } from "../generated/instructions";
|
|
5
|
-
import BaseDistributorClient, { IInitOptions } from "./BaseDistributorClient.js";
|
|
6
|
-
import { AlignedDistributor as AlignedAirdropsProgramType } from "../descriptor/aligned_distributor.js";
|
|
7
|
-
export default class SolanaAlignedDistributorClient extends BaseDistributorClient {
|
|
8
|
-
alignedProxyProgram: Program<AlignedAirdropsProgramType>;
|
|
9
|
-
constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }: IInitOptions);
|
|
10
|
-
getAlignedDistributorProgramId(): PublicKey;
|
|
11
|
-
getAlignedDistributorAddress(distributorAddress: string): PublicKey;
|
|
12
|
-
getAlignedDistributorData(distributorAddress: string): Promise<AlignedDistributorData>;
|
|
13
|
-
protected getNewDistributorInstruction(data: ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
|
|
14
|
-
protected getClawbackInstruction(accounts: ClawbackAccounts): Promise<TransactionInstruction>;
|
|
15
|
-
protected getNewAlignedDistributorArgs(data: ICreateAlignedDistributorData): NewAlignedDistributorArgs;
|
|
16
|
-
}
|