@streamflow/distributor 6.0.0-alpha.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/LICENSE +674 -0
- package/README.md +127 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +27 -0
- package/dist/solana/client.d.ts +25 -0
- package/dist/solana/client.js +300 -0
- package/dist/solana/constants.d.ts +6 -0
- package/dist/solana/constants.js +11 -0
- package/dist/solana/generated/accounts/ClaimStatus.d.ts +72 -0
- package/dist/solana/generated/accounts/ClaimStatus.js +183 -0
- package/dist/solana/generated/accounts/MerkleDistributor.d.ts +138 -0
- package/dist/solana/generated/accounts/MerkleDistributor.js +238 -0
- package/dist/solana/generated/accounts/index.d.ts +4 -0
- package/dist/solana/generated/accounts/index.js +7 -0
- package/dist/solana/generated/errors/anchor.d.ts +434 -0
- package/dist/solana/generated/errors/anchor.js +889 -0
- package/dist/solana/generated/errors/custom.d.ts +162 -0
- package/dist/solana/generated/errors/custom.js +344 -0
- package/dist/solana/generated/errors/index.d.ts +5 -0
- package/dist/solana/generated/errors/index.js +104 -0
- package/dist/solana/generated/instructions/claimLocked.d.ts +21 -0
- package/dist/solana/generated/instructions/claimLocked.js +22 -0
- package/dist/solana/generated/instructions/clawback.d.ts +20 -0
- package/dist/solana/generated/instructions/clawback.js +22 -0
- package/dist/solana/generated/instructions/closeClaim.d.ts +13 -0
- package/dist/solana/generated/instructions/closeClaim.js +20 -0
- package/dist/solana/generated/instructions/index.d.ts +14 -0
- package/dist/solana/generated/instructions/index.js +17 -0
- package/dist/solana/generated/instructions/newClaim.d.ts +27 -0
- package/dist/solana/generated/instructions/newClaim.js +58 -0
- package/dist/solana/generated/instructions/newDistributor.d.ts +56 -0
- package/dist/solana/generated/instructions/newDistributor.js +94 -0
- package/dist/solana/generated/instructions/setAdmin.d.ts +10 -0
- package/dist/solana/generated/instructions/setAdmin.js +18 -0
- package/dist/solana/generated/instructions/setClawbackReceiver.d.ts +10 -0
- package/dist/solana/generated/instructions/setClawbackReceiver.js +18 -0
- package/dist/solana/generated/programId.d.ts +3 -0
- package/dist/solana/generated/programId.js +8 -0
- package/dist/solana/index.d.ts +4 -0
- package/dist/solana/index.js +37 -0
- package/dist/solana/types.d.ts +203 -0
- package/dist/solana/types.js +159 -0
- package/dist/solana/utils.d.ts +5 -0
- package/dist/solana/utils.js +87 -0
- package/package.json +46 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clawback = void 0;
|
|
4
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
var programId_1 = require("../programId");
|
|
6
|
+
function clawback(accounts, programId) {
|
|
7
|
+
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
8
|
+
var keys = [
|
|
9
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
11
|
+
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
12
|
+
{ pubkey: accounts.claimant, isSigner: true, isWritable: false },
|
|
13
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
14
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
15
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
16
|
+
];
|
|
17
|
+
var identifier = Buffer.from([111, 92, 142, 79, 33, 234, 82, 27]);
|
|
18
|
+
var data = identifier;
|
|
19
|
+
var ix = new web3_js_1.TransactionInstruction({ keys: keys, programId: programId, data: data });
|
|
20
|
+
return ix;
|
|
21
|
+
}
|
|
22
|
+
exports.clawback = clawback;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey } from "@solana/web3.js";
|
|
2
|
+
export interface CloseClaimAccounts {
|
|
3
|
+
/** The [MerkleDistributor]. */
|
|
4
|
+
distributor: PublicKey;
|
|
5
|
+
/** Admin signer */
|
|
6
|
+
admin: PublicKey;
|
|
7
|
+
claimant: PublicKey;
|
|
8
|
+
/** Claim Status PDA */
|
|
9
|
+
claimStatus: PublicKey;
|
|
10
|
+
/** The [System] program. */
|
|
11
|
+
systemProgram: PublicKey;
|
|
12
|
+
}
|
|
13
|
+
export declare function closeClaim(accounts: CloseClaimAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.closeClaim = void 0;
|
|
4
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
var programId_1 = require("../programId");
|
|
6
|
+
function closeClaim(accounts, programId) {
|
|
7
|
+
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
8
|
+
var keys = [
|
|
9
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
10
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
11
|
+
{ pubkey: accounts.claimant, isSigner: false, isWritable: false },
|
|
12
|
+
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
13
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
14
|
+
];
|
|
15
|
+
var identifier = Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
|
|
16
|
+
var data = identifier;
|
|
17
|
+
var ix = new web3_js_1.TransactionInstruction({ keys: keys, programId: programId, data: data });
|
|
18
|
+
return ix;
|
|
19
|
+
}
|
|
20
|
+
exports.closeClaim = closeClaim;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { newDistributor } from "./newDistributor";
|
|
2
|
+
export type { NewDistributorArgs, NewDistributorAccounts } from "./newDistributor";
|
|
3
|
+
export { newClaim } from "./newClaim";
|
|
4
|
+
export type { NewClaimArgs, NewClaimAccounts } from "./newClaim";
|
|
5
|
+
export { claimLocked } from "./claimLocked";
|
|
6
|
+
export type { ClaimLockedAccounts } from "./claimLocked";
|
|
7
|
+
export { clawback } from "./clawback";
|
|
8
|
+
export type { ClawbackAccounts } from "./clawback";
|
|
9
|
+
export { closeClaim } from "./closeClaim";
|
|
10
|
+
export type { CloseClaimAccounts } from "./closeClaim";
|
|
11
|
+
export { setClawbackReceiver } from "./setClawbackReceiver";
|
|
12
|
+
export type { SetClawbackReceiverAccounts } from "./setClawbackReceiver";
|
|
13
|
+
export { setAdmin } from "./setAdmin";
|
|
14
|
+
export type { SetAdminAccounts } from "./setAdmin";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setAdmin = exports.setClawbackReceiver = exports.closeClaim = exports.clawback = exports.claimLocked = exports.newClaim = exports.newDistributor = void 0;
|
|
4
|
+
var newDistributor_1 = require("./newDistributor");
|
|
5
|
+
Object.defineProperty(exports, "newDistributor", { enumerable: true, get: function () { return newDistributor_1.newDistributor; } });
|
|
6
|
+
var newClaim_1 = require("./newClaim");
|
|
7
|
+
Object.defineProperty(exports, "newClaim", { enumerable: true, get: function () { return newClaim_1.newClaim; } });
|
|
8
|
+
var claimLocked_1 = require("./claimLocked");
|
|
9
|
+
Object.defineProperty(exports, "claimLocked", { enumerable: true, get: function () { return claimLocked_1.claimLocked; } });
|
|
10
|
+
var clawback_1 = require("./clawback");
|
|
11
|
+
Object.defineProperty(exports, "clawback", { enumerable: true, get: function () { return clawback_1.clawback; } });
|
|
12
|
+
var closeClaim_1 = require("./closeClaim");
|
|
13
|
+
Object.defineProperty(exports, "closeClaim", { enumerable: true, get: function () { return closeClaim_1.closeClaim; } });
|
|
14
|
+
var setClawbackReceiver_1 = require("./setClawbackReceiver");
|
|
15
|
+
Object.defineProperty(exports, "setClawbackReceiver", { enumerable: true, get: function () { return setClawbackReceiver_1.setClawbackReceiver; } });
|
|
16
|
+
var setAdmin_1 = require("./setAdmin");
|
|
17
|
+
Object.defineProperty(exports, "setAdmin", { enumerable: true, get: function () { return setAdmin_1.setAdmin; } });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
export interface NewClaimArgs {
|
|
4
|
+
amountUnlocked: BN;
|
|
5
|
+
amountLocked: BN;
|
|
6
|
+
proof: Array<Array<number>>;
|
|
7
|
+
}
|
|
8
|
+
export interface NewClaimAccounts {
|
|
9
|
+
/** The [MerkleDistributor]. */
|
|
10
|
+
distributor: PublicKey;
|
|
11
|
+
/** Claim status PDA */
|
|
12
|
+
claimStatus: PublicKey;
|
|
13
|
+
/** Distributor ATA containing the tokens to distribute. */
|
|
14
|
+
from: PublicKey;
|
|
15
|
+
/** Account to send the claimed tokens to. */
|
|
16
|
+
to: PublicKey;
|
|
17
|
+
/** Who is claiming the tokens. */
|
|
18
|
+
claimant: PublicKey;
|
|
19
|
+
/** The mint to claim. */
|
|
20
|
+
mint: PublicKey;
|
|
21
|
+
/** SPL [Token] program. */
|
|
22
|
+
tokenProgram: PublicKey;
|
|
23
|
+
/** The [System] program. */
|
|
24
|
+
systemProgram: PublicKey;
|
|
25
|
+
}
|
|
26
|
+
export declare const layout: any;
|
|
27
|
+
export declare function newClaim(args: NewClaimArgs, accounts: NewClaimAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.newClaim = exports.layout = void 0;
|
|
27
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
28
|
+
var borsh = __importStar(require("@coral-xyz/borsh"));
|
|
29
|
+
var programId_1 = require("../programId");
|
|
30
|
+
exports.layout = borsh.struct([
|
|
31
|
+
borsh.u64("amountUnlocked"),
|
|
32
|
+
borsh.u64("amountLocked"),
|
|
33
|
+
borsh.vec(borsh.array(borsh.u8(), 32), "proof"),
|
|
34
|
+
]);
|
|
35
|
+
function newClaim(args, accounts, programId) {
|
|
36
|
+
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
37
|
+
var keys = [
|
|
38
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
39
|
+
{ pubkey: accounts.claimStatus, isSigner: false, isWritable: true },
|
|
40
|
+
{ pubkey: accounts.from, isSigner: false, isWritable: true },
|
|
41
|
+
{ pubkey: accounts.to, isSigner: false, isWritable: true },
|
|
42
|
+
{ pubkey: accounts.claimant, isSigner: true, isWritable: true },
|
|
43
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
44
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
45
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
46
|
+
];
|
|
47
|
+
var identifier = Buffer.from([78, 177, 98, 123, 210, 21, 187, 83]);
|
|
48
|
+
var buffer = Buffer.alloc(1000);
|
|
49
|
+
var len = exports.layout.encode({
|
|
50
|
+
amountUnlocked: args.amountUnlocked,
|
|
51
|
+
amountLocked: args.amountLocked,
|
|
52
|
+
proof: args.proof,
|
|
53
|
+
}, buffer);
|
|
54
|
+
var data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
55
|
+
var ix = new web3_js_1.TransactionInstruction({ keys: keys, programId: programId, data: data });
|
|
56
|
+
return ix;
|
|
57
|
+
}
|
|
58
|
+
exports.newClaim = newClaim;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
export interface NewDistributorArgs {
|
|
4
|
+
version: BN;
|
|
5
|
+
root: Array<number>;
|
|
6
|
+
maxTotalClaim: BN;
|
|
7
|
+
maxNumNodes: BN;
|
|
8
|
+
unlockPeriod: BN;
|
|
9
|
+
startVestingTs: BN;
|
|
10
|
+
endVestingTs: BN;
|
|
11
|
+
clawbackStartTs: BN;
|
|
12
|
+
claimsClosable: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface NewDistributorAccounts {
|
|
15
|
+
/** [MerkleDistributor]. */
|
|
16
|
+
distributor: PublicKey;
|
|
17
|
+
/** Clawback receiver token account */
|
|
18
|
+
clawbackReceiver: PublicKey;
|
|
19
|
+
/** The mint to distribute. */
|
|
20
|
+
mint: PublicKey;
|
|
21
|
+
/** Token vault */
|
|
22
|
+
tokenVault: PublicKey;
|
|
23
|
+
/**
|
|
24
|
+
* Admin wallet, responsible for creating the distributor and paying for the transaction.
|
|
25
|
+
* Also has the authority to set the clawback receiver and change itself.
|
|
26
|
+
*/
|
|
27
|
+
admin: PublicKey;
|
|
28
|
+
/** The [System] program. */
|
|
29
|
+
systemProgram: PublicKey;
|
|
30
|
+
/** The [Associated Token] program. */
|
|
31
|
+
associatedTokenProgram: PublicKey;
|
|
32
|
+
/** The [Token] program. */
|
|
33
|
+
tokenProgram: PublicKey;
|
|
34
|
+
}
|
|
35
|
+
export declare const layout: any;
|
|
36
|
+
/**
|
|
37
|
+
* READ THE FOLLOWING:
|
|
38
|
+
*
|
|
39
|
+
* This instruction is susceptible to frontrunning that could result in loss of funds if not handled properly.
|
|
40
|
+
*
|
|
41
|
+
* An attack could look like:
|
|
42
|
+
* - A legitimate user opens a new distributor.
|
|
43
|
+
* - Someone observes the call to this instruction.
|
|
44
|
+
* - They replace the clawback_receiver, admin, or time parameters with their own.
|
|
45
|
+
*
|
|
46
|
+
* One situation that could happen here is the attacker replaces the admin and clawback_receiver with their own
|
|
47
|
+
* and sets the clawback_start_ts with the minimal time allowed. After clawback_start_ts has elapsed,
|
|
48
|
+
* the attacker can steal all funds from the distributor to their own clawback_receiver account.
|
|
49
|
+
*
|
|
50
|
+
* HOW TO AVOID:
|
|
51
|
+
* - When you call into this instruction, ensure your transaction succeeds.
|
|
52
|
+
* - To be extra safe, after your transaction succeeds, read back the state of the created MerkleDistributor account and
|
|
53
|
+
* assert the parameters are what you expect, most importantly the clawback_receiver and admin.
|
|
54
|
+
* - If your transaction fails, double check the value on-chain matches what you expect.
|
|
55
|
+
*/
|
|
56
|
+
export declare function newDistributor(args: NewDistributorArgs, accounts: NewDistributorAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.newDistributor = exports.layout = void 0;
|
|
27
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
28
|
+
var borsh = __importStar(require("@coral-xyz/borsh"));
|
|
29
|
+
var programId_1 = require("../programId");
|
|
30
|
+
exports.layout = borsh.struct([
|
|
31
|
+
borsh.u64("version"),
|
|
32
|
+
borsh.array(borsh.u8(), 32, "root"),
|
|
33
|
+
borsh.u64("maxTotalClaim"),
|
|
34
|
+
borsh.u64("maxNumNodes"),
|
|
35
|
+
borsh.u64("unlockPeriod"),
|
|
36
|
+
borsh.u64("startVestingTs"),
|
|
37
|
+
borsh.u64("endVestingTs"),
|
|
38
|
+
borsh.u64("clawbackStartTs"),
|
|
39
|
+
borsh.bool("claimsClosable"),
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* READ THE FOLLOWING:
|
|
43
|
+
*
|
|
44
|
+
* This instruction is susceptible to frontrunning that could result in loss of funds if not handled properly.
|
|
45
|
+
*
|
|
46
|
+
* An attack could look like:
|
|
47
|
+
* - A legitimate user opens a new distributor.
|
|
48
|
+
* - Someone observes the call to this instruction.
|
|
49
|
+
* - They replace the clawback_receiver, admin, or time parameters with their own.
|
|
50
|
+
*
|
|
51
|
+
* One situation that could happen here is the attacker replaces the admin and clawback_receiver with their own
|
|
52
|
+
* and sets the clawback_start_ts with the minimal time allowed. After clawback_start_ts has elapsed,
|
|
53
|
+
* the attacker can steal all funds from the distributor to their own clawback_receiver account.
|
|
54
|
+
*
|
|
55
|
+
* HOW TO AVOID:
|
|
56
|
+
* - When you call into this instruction, ensure your transaction succeeds.
|
|
57
|
+
* - To be extra safe, after your transaction succeeds, read back the state of the created MerkleDistributor account and
|
|
58
|
+
* assert the parameters are what you expect, most importantly the clawback_receiver and admin.
|
|
59
|
+
* - If your transaction fails, double check the value on-chain matches what you expect.
|
|
60
|
+
*/
|
|
61
|
+
function newDistributor(args, accounts, programId) {
|
|
62
|
+
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
63
|
+
var keys = [
|
|
64
|
+
{ pubkey: accounts.distributor, isSigner: false, isWritable: true },
|
|
65
|
+
{ pubkey: accounts.clawbackReceiver, isSigner: false, isWritable: true },
|
|
66
|
+
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
|
67
|
+
{ pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
|
|
68
|
+
{ pubkey: accounts.admin, isSigner: true, isWritable: true },
|
|
69
|
+
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
70
|
+
{
|
|
71
|
+
pubkey: accounts.associatedTokenProgram,
|
|
72
|
+
isSigner: false,
|
|
73
|
+
isWritable: false,
|
|
74
|
+
},
|
|
75
|
+
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
76
|
+
];
|
|
77
|
+
var identifier = Buffer.from([32, 139, 112, 171, 0, 2, 225, 155]);
|
|
78
|
+
var buffer = Buffer.alloc(1000);
|
|
79
|
+
var len = exports.layout.encode({
|
|
80
|
+
version: args.version,
|
|
81
|
+
root: args.root,
|
|
82
|
+
maxTotalClaim: args.maxTotalClaim,
|
|
83
|
+
maxNumNodes: args.maxNumNodes,
|
|
84
|
+
unlockPeriod: args.unlockPeriod,
|
|
85
|
+
startVestingTs: args.startVestingTs,
|
|
86
|
+
endVestingTs: args.endVestingTs,
|
|
87
|
+
clawbackStartTs: args.clawbackStartTs,
|
|
88
|
+
claimsClosable: args.claimsClosable,
|
|
89
|
+
}, buffer);
|
|
90
|
+
var data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
|
91
|
+
var ix = new web3_js_1.TransactionInstruction({ keys: keys, programId: programId, data: data });
|
|
92
|
+
return ix;
|
|
93
|
+
}
|
|
94
|
+
exports.newDistributor = newDistributor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey } from "@solana/web3.js";
|
|
2
|
+
export interface SetAdminAccounts {
|
|
3
|
+
/** The [MerkleDistributor]. */
|
|
4
|
+
distributor: PublicKey;
|
|
5
|
+
/** Admin signer */
|
|
6
|
+
admin: PublicKey;
|
|
7
|
+
/** New admin account */
|
|
8
|
+
newAdmin: PublicKey;
|
|
9
|
+
}
|
|
10
|
+
export declare function setAdmin(accounts: SetAdminAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setAdmin = void 0;
|
|
4
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
var programId_1 = require("../programId");
|
|
6
|
+
function setAdmin(accounts, programId) {
|
|
7
|
+
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
8
|
+
var 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
|
+
var identifier = Buffer.from([251, 163, 0, 52, 91, 194, 187, 92]);
|
|
14
|
+
var data = identifier;
|
|
15
|
+
var ix = new web3_js_1.TransactionInstruction({ keys: keys, programId: programId, data: data });
|
|
16
|
+
return ix;
|
|
17
|
+
}
|
|
18
|
+
exports.setAdmin = setAdmin;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey } from "@solana/web3.js";
|
|
2
|
+
export interface SetClawbackReceiverAccounts {
|
|
3
|
+
/** The [MerkleDistributor]. */
|
|
4
|
+
distributor: PublicKey;
|
|
5
|
+
/** New clawback account */
|
|
6
|
+
newClawbackAccount: PublicKey;
|
|
7
|
+
/** Admin signer */
|
|
8
|
+
admin: PublicKey;
|
|
9
|
+
}
|
|
10
|
+
export declare function setClawbackReceiver(accounts: SetClawbackReceiverAccounts, programId?: PublicKey): TransactionInstruction;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setClawbackReceiver = void 0;
|
|
4
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
var programId_1 = require("../programId");
|
|
6
|
+
function setClawbackReceiver(accounts, programId) {
|
|
7
|
+
if (programId === void 0) { programId = programId_1.PROGRAM_ID; }
|
|
8
|
+
var 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
|
+
var identifier = Buffer.from([153, 217, 34, 20, 19, 29, 229, 75]);
|
|
14
|
+
var data = identifier;
|
|
15
|
+
var ix = new web3_js_1.TransactionInstruction({ keys: keys, programId: programId, data: data });
|
|
16
|
+
return ix;
|
|
17
|
+
}
|
|
18
|
+
exports.setClawbackReceiver = setClawbackReceiver;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROGRAM_ID = exports.PROGRAM_ID_CLI = void 0;
|
|
4
|
+
var 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;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.constants = exports.SolanaDistributorClient = void 0;
|
|
33
|
+
var client_1 = require("./client");
|
|
34
|
+
Object.defineProperty(exports, "SolanaDistributorClient", { enumerable: true, get: function () { return __importDefault(client_1).default; } });
|
|
35
|
+
__exportStar(require("./utils"), exports);
|
|
36
|
+
__exportStar(require("./types"), exports);
|
|
37
|
+
exports.constants = __importStar(require("./constants"));
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
+
import { Keypair } from "@solana/web3.js";
|
|
4
|
+
import { ITransactionResult } from "@streamflow/common";
|
|
5
|
+
export interface IInteractSolanaExt {
|
|
6
|
+
invoker: SignerWalletAdapter | Keypair;
|
|
7
|
+
}
|
|
8
|
+
export interface ICreateSolanaExt extends IInteractSolanaExt {
|
|
9
|
+
isNative?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ICreateDistributorData {
|
|
12
|
+
mint: string;
|
|
13
|
+
version: number;
|
|
14
|
+
root: Array<number>;
|
|
15
|
+
maxTotalClaim: BN;
|
|
16
|
+
maxNumNodes: BN;
|
|
17
|
+
unlockPeriod: number;
|
|
18
|
+
startVestingTs: number;
|
|
19
|
+
endVestingTs: number;
|
|
20
|
+
clawbackStartTs: number;
|
|
21
|
+
claimsClosable: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface IClaimData {
|
|
24
|
+
id: string;
|
|
25
|
+
amountUnlocked: BN;
|
|
26
|
+
amountLocked: BN;
|
|
27
|
+
proof: Array<Array<number>>;
|
|
28
|
+
}
|
|
29
|
+
export interface IClawbackData {
|
|
30
|
+
id: string;
|
|
31
|
+
}
|
|
32
|
+
export interface IGetClaimsData {
|
|
33
|
+
id: string;
|
|
34
|
+
recipients: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface IGetDistributors {
|
|
37
|
+
ids: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface ISetDataAdmin {
|
|
40
|
+
id: string;
|
|
41
|
+
newAdmin: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ISetClawbackReceiverData {
|
|
44
|
+
id: string;
|
|
45
|
+
newReceiver: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ICreateDistributorResult extends ITransactionResult {
|
|
48
|
+
metadataId: string;
|
|
49
|
+
}
|
|
50
|
+
export declare enum AnchorErrorCode {
|
|
51
|
+
/** 8 byte instruction identifier not provided */
|
|
52
|
+
InstructionMissing = "InstructionMissing",
|
|
53
|
+
/** Fallback functions are not supported */
|
|
54
|
+
InstructionFallbackNotFound = "InstructionFallbackNotFound",
|
|
55
|
+
/** The program could not deserialize the given instruction */
|
|
56
|
+
InstructionDidNotDeserialize = "InstructionDidNotDeserialize",
|
|
57
|
+
/** The program could not serialize the given instruction */
|
|
58
|
+
InstructionDidNotSerialize = "InstructionDidNotSerialize",
|
|
59
|
+
/** The program was compiled without idl instructions */
|
|
60
|
+
IdlInstructionStub = "IdlInstructionStub",
|
|
61
|
+
/** The transaction was given an invalid program for the IDL instruction */
|
|
62
|
+
IdlInstructionInvalidProgram = "IdlInstructionInvalidProgram",
|
|
63
|
+
/** A mut constraint was violated */
|
|
64
|
+
ConstraintMut = "ConstraintMut",
|
|
65
|
+
/** A has one constraint was violated */
|
|
66
|
+
ConstraintHasOne = "ConstraintHasOne",
|
|
67
|
+
/** A signer constraint was violated */
|
|
68
|
+
ConstraintSigner = "ConstraintSigner",
|
|
69
|
+
/** A raw constraint was violated */
|
|
70
|
+
ConstraintRaw = "ConstraintRaw",
|
|
71
|
+
/** An owner constraint was violated */
|
|
72
|
+
ConstraintOwner = "ConstraintOwner",
|
|
73
|
+
/** A rent exemption constraint was violated */
|
|
74
|
+
ConstraintRentExempt = "ConstraintRentExempt",
|
|
75
|
+
/** A seeds constraint was violated */
|
|
76
|
+
ConstraintSeeds = "ConstraintSeeds",
|
|
77
|
+
/** An executable constraint was violated */
|
|
78
|
+
ConstraintExecutable = "ConstraintExecutable",
|
|
79
|
+
/** Deprecated Error, feel free to replace with something else */
|
|
80
|
+
ConstraintState = "ConstraintState",
|
|
81
|
+
/** An associated constraint was violated */
|
|
82
|
+
ConstraintAssociated = "ConstraintAssociated",
|
|
83
|
+
/** An associated init constraint was violated */
|
|
84
|
+
ConstraintAssociatedInit = "ConstraintAssociatedInit",
|
|
85
|
+
/** A close constraint was violated */
|
|
86
|
+
ConstraintClose = "ConstraintClose",
|
|
87
|
+
/** An address constraint was violated */
|
|
88
|
+
ConstraintAddress = "ConstraintAddress",
|
|
89
|
+
/** Expected zero account discriminant */
|
|
90
|
+
ConstraintZero = "ConstraintZero",
|
|
91
|
+
/** A token mint constraint was violated */
|
|
92
|
+
ConstraintTokenMint = "ConstraintTokenMint",
|
|
93
|
+
/** A token owner constraint was violated */
|
|
94
|
+
ConstraintTokenOwner = "ConstraintTokenOwner",
|
|
95
|
+
/** A mint mint authority constraint was violated */
|
|
96
|
+
ConstraintMintMintAuthority = "ConstraintMintMintAuthority",
|
|
97
|
+
/** A mint freeze authority constraint was violated */
|
|
98
|
+
ConstraintMintFreezeAuthority = "ConstraintMintFreezeAuthority",
|
|
99
|
+
/** A mint decimals constraint was violated */
|
|
100
|
+
ConstraintMintDecimals = "ConstraintMintDecimals",
|
|
101
|
+
/** A space constraint was violated */
|
|
102
|
+
ConstraintSpace = "ConstraintSpace",
|
|
103
|
+
/** A required account for the constraint is None */
|
|
104
|
+
ConstraintAccountIsNone = "ConstraintAccountIsNone",
|
|
105
|
+
/** A require expression was violated */
|
|
106
|
+
RequireViolated = "RequireViolated",
|
|
107
|
+
/** A require_eq expression was violated */
|
|
108
|
+
RequireEqViolated = "RequireEqViolated",
|
|
109
|
+
/** A require_keys_eq expression was violated */
|
|
110
|
+
RequireKeysEqViolated = "RequireKeysEqViolated",
|
|
111
|
+
/** A require_neq expression was violated */
|
|
112
|
+
RequireNeqViolated = "RequireNeqViolated",
|
|
113
|
+
/** A require_keys_neq expression was violated */
|
|
114
|
+
RequireKeysNeqViolated = "RequireKeysNeqViolated",
|
|
115
|
+
/** A require_gt expression was violated */
|
|
116
|
+
RequireGtViolated = "RequireGtViolated",
|
|
117
|
+
/** A require_gte expression was violated */
|
|
118
|
+
RequireGteViolated = "RequireGteViolated",
|
|
119
|
+
/** The account discriminator was already set on this account */
|
|
120
|
+
AccountDiscriminatorAlreadySet = "AccountDiscriminatorAlreadySet",
|
|
121
|
+
/** No 8 byte discriminator was found on the account */
|
|
122
|
+
AccountDiscriminatorNotFound = "AccountDiscriminatorNotFound",
|
|
123
|
+
/** 8 byte discriminator did not match what was expected */
|
|
124
|
+
AccountDiscriminatorMismatch = "AccountDiscriminatorMismatch",
|
|
125
|
+
/** Failed to deserialize the account */
|
|
126
|
+
AccountDidNotDeserialize = "AccountDidNotDeserialize",
|
|
127
|
+
/** Failed to serialize the account */
|
|
128
|
+
AccountDidNotSerialize = "AccountDidNotSerialize",
|
|
129
|
+
/** Not enough account keys given to the instruction */
|
|
130
|
+
AccountNotEnoughKeys = "AccountNotEnoughKeys",
|
|
131
|
+
/** The given account is not mutable */
|
|
132
|
+
AccountNotMutable = "AccountNotMutable",
|
|
133
|
+
/** The given account is owned by a different program than expected */
|
|
134
|
+
AccountOwnedByWrongProgram = "AccountOwnedByWrongProgram",
|
|
135
|
+
/** Program ID was not as expected */
|
|
136
|
+
InvalidProgramId = "InvalidProgramId",
|
|
137
|
+
/** Program account is not executable */
|
|
138
|
+
InvalidProgramExecutable = "InvalidProgramExecutable",
|
|
139
|
+
/** The given account did not sign */
|
|
140
|
+
AccountNotSigner = "AccountNotSigner",
|
|
141
|
+
/** The given account is not owned by the system program */
|
|
142
|
+
AccountNotSystemOwned = "AccountNotSystemOwned",
|
|
143
|
+
/** The program expected this account to be already initialized */
|
|
144
|
+
AccountNotInitialized = "AccountNotInitialized",
|
|
145
|
+
/** The given account is not a program data account */
|
|
146
|
+
AccountNotProgramData = "AccountNotProgramData",
|
|
147
|
+
/** The given account is not the associated token account */
|
|
148
|
+
AccountNotAssociatedTokenAccount = "AccountNotAssociatedTokenAccount",
|
|
149
|
+
/** The given public key does not match the required sysvar */
|
|
150
|
+
AccountSysvarMismatch = "AccountSysvarMismatch",
|
|
151
|
+
/** The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit */
|
|
152
|
+
AccountReallocExceedsLimit = "AccountReallocExceedsLimit",
|
|
153
|
+
/** The account was duplicated for more than one reallocation */
|
|
154
|
+
AccountDuplicateReallocs = "AccountDuplicateReallocs",
|
|
155
|
+
/** The declared program id does not match the actual program id */
|
|
156
|
+
DeclaredProgramIdMismatch = "DeclaredProgramIdMismatch",
|
|
157
|
+
/** The API being used is deprecated and should no longer be used */
|
|
158
|
+
Deprecated = "Deprecated"
|
|
159
|
+
}
|
|
160
|
+
export declare enum ContractErrorCode {
|
|
161
|
+
/** Insufficient unlocked tokens */
|
|
162
|
+
InsufficientUnlockedTokens = "InsufficientUnlockedTokens",
|
|
163
|
+
/** Deposit Start too far in future */
|
|
164
|
+
StartTooFarInFuture = "StartTooFarInFuture",
|
|
165
|
+
/** Invalid Merkle proof */
|
|
166
|
+
InvalidProof = "InvalidProof",
|
|
167
|
+
/** Exceeded maximum claim amount */
|
|
168
|
+
ExceededMaxClaim = "ExceededMaxClaim",
|
|
169
|
+
/** Exceeded maximum node count */
|
|
170
|
+
MaxNodesExceeded = "MaxNodesExceeded",
|
|
171
|
+
/** Account is not authorized to execute this instruction */
|
|
172
|
+
Unauthorized = "Unauthorized",
|
|
173
|
+
/** Token account owner did not match intended owner */
|
|
174
|
+
OwnerMismatch = "OwnerMismatch",
|
|
175
|
+
/** Clawback cannot be before vesting starts */
|
|
176
|
+
ClawbackBeforeVesting = "ClawbackBeforeVesting",
|
|
177
|
+
/** Attempted clawback before start */
|
|
178
|
+
ClawbackBeforeStart = "ClawbackBeforeStart",
|
|
179
|
+
/** Clawback already claimed */
|
|
180
|
+
ClawbackAlreadyClaimed = "ClawbackAlreadyClaimed",
|
|
181
|
+
/** Clawback start must be at least one day after vesting end */
|
|
182
|
+
InsufficientClawbackDelay = "InsufficientClawbackDelay",
|
|
183
|
+
/** New and old Clawback receivers are identical */
|
|
184
|
+
SameClawbackReceiver = "SameClawbackReceiver",
|
|
185
|
+
/** New and old admin are identical */
|
|
186
|
+
SameAdmin = "SameAdmin",
|
|
187
|
+
/** Claim window expired */
|
|
188
|
+
ClaimExpired = "ClaimExpired",
|
|
189
|
+
/** Arithmetic Error (overflow/underflow) */
|
|
190
|
+
ArithmeticError = "ArithmeticError",
|
|
191
|
+
/** Start Timestamp cannot be after end Timestamp */
|
|
192
|
+
StartTimestampAfterEnd = "StartTimestampAfterEnd",
|
|
193
|
+
/** Timestamps cannot be in the past */
|
|
194
|
+
TimestampsNotInFuture = "TimestampsNotInFuture",
|
|
195
|
+
/** Airdrop Version Mismatch */
|
|
196
|
+
InvalidVersion = "InvalidVersion",
|
|
197
|
+
/** Invalid Mint */
|
|
198
|
+
InvalidMint = "InvalidMint",
|
|
199
|
+
/** Claim is closed */
|
|
200
|
+
ClaimIsClosed = "ClaimIsClosed",
|
|
201
|
+
/** Claims are not closable */
|
|
202
|
+
ClaimsAreNotClosable = "ClaimsAreNotClosable"
|
|
203
|
+
}
|