@streamflow/distributor 7.4.0 → 7.4.2

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 CHANGED
@@ -67,7 +67,9 @@ const res = await client.create(
67
67
  startVestingTs: 0, // Timestamp when Airdrop starts
68
68
  endVestingTs: now + 3600 * 24 * 7, // Timestamp when Airdrop ends
69
69
  clawbackStartTs: now + 5, // Timestamp after which Airdrop can be clawed back to the Sender address
70
- claimsClosable: false, // Whether individual Claims can be closed by the Sender
70
+ claimsClosableByAdmin: false, // Whether individual Claims can be closed by the Sender
71
+ claimsClosableByClaimant: false, // Whether the Recipient can close their own Claim
72
+ claimsLimit: null, // The number of times a Recipient can Claim the Airdrop - 0 or null for no limit on claims
71
73
  },
72
74
  solanaParams,
73
75
  );
@@ -100,6 +102,45 @@ const claimRes = await client.claim(
100
102
  );
101
103
  ```
102
104
 
105
+ ## Close a Claim
106
+
107
+ ```javascript
108
+ const solanaParams = {
109
+ invoker: recipient, // SignerWalletAdapter or Keypair of Recipient account
110
+ };
111
+
112
+ // By Admin
113
+ const closeRes = await client.closeClaim(
114
+ {
115
+ id: res.metadataId, // address of the Distributor Account
116
+ claimant: "s3pWmY359mDrNRnDBZ3v5TrrqqxvxiW2t4U2WZyxRoA" // address of the Recipient/Claimant
117
+ },
118
+ solanaParams,
119
+ );
120
+
121
+ // By Claimant
122
+ const closeRes = await client.closeClaim(
123
+ {
124
+ id: res.metadataId, // address of the Distributor Account
125
+ proof: [
126
+ [
127
+ 36, 11, 128, 61, 125, 228, 9, 50, 112, 51, 54, 201, 213, 81, 228, 216, 62, 191, 68, 63, 59, 125, 163, 77, 44,
128
+ 88, 170, 65, 139, 25, 147, 145,
129
+ ],
130
+ [
131
+ 53, 101, 204, 14, 202, 64, 98, 238, 49, 6, 119, 208, 98, 195, 150, 81, 191, 55, 46, 103, 91, 245, 121, 195,
132
+ 43, 104, 75, 183, 12, 38, 37, 153,
133
+ ],
134
+ ], // Merkle Proof used to verify claim
135
+ amountUnlocked: new BN("0"), // Total amount unlocked for a Recipient
136
+ amountLocked: new BN("1000000000"), // Total amount locked for a Recipient
137
+ claimant: "s3pWmY359mDrNRnDBZ3v5TrrqqxvxiW2t4U2WZyxRoA" // address of the Recipient/Claimant
138
+ },
139
+ solanaParams,
140
+ );
141
+ ```
142
+
143
+
103
144
  ## Clawback an Airdrop
104
145
 
105
146
  Returns all funds to the original Sender.
@@ -163,8 +163,8 @@ class BaseDistributorClient {
163
163
  program: this.programId,
164
164
  };
165
165
  const closeClaimArgs = {
166
- amountLocked: new bn_js_1.default(data.amountLocked),
167
- amountUnlocked: new bn_js_1.default(data.amountUnlocked),
166
+ amountLocked: data.amountLocked ? new bn_js_1.default(data.amountLocked) : undefined,
167
+ amountUnlocked: data.amountUnlocked ? new bn_js_1.default(data.amountUnlocked) : undefined,
168
168
  proof: data.proof,
169
169
  };
170
170
  ixs.push((0, closeClaim_1.closeClaim)(closeClaimArgs, closeClaimAccounts, this.programId));
@@ -47,9 +47,9 @@ function closeClaim(args, accounts, programId = programId_1.PROGRAM_ID) {
47
47
  const identifier = buffer_1.Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
48
48
  const buffer = buffer_1.Buffer.alloc(1000);
49
49
  const len = exports.layout.encode({
50
- amountUnlocked: args.amountUnlocked,
51
- amountLocked: args.amountLocked,
52
- proof: args.proof,
50
+ amountUnlocked: args.amountUnlocked ?? null,
51
+ amountLocked: args.amountLocked ?? null,
52
+ proof: args.proof ?? null,
53
53
  }, buffer);
54
54
  const data = buffer_1.Buffer.concat([identifier, buffer]).slice(0, 8 + len);
55
55
  const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
@@ -95,8 +95,8 @@ function newDistributor(args, accounts, programId = programId_1.PROGRAM_ID) {
95
95
  canUpdateDuration: null,
96
96
  totalAmountUnlocked: null,
97
97
  totalAmountLocked: null,
98
- claimsClosableByClaimant: args.claimsClosableByClaimant,
99
- claimsLimit: args.claimsLimit,
98
+ claimsClosableByClaimant: args.claimsClosableByClaimant ?? null,
99
+ claimsLimit: args.claimsLimit ?? null,
100
100
  }, buffer);
101
101
  const data = buffer_1.Buffer.concat([identifier, buffer]).slice(0, 8 + len);
102
102
  const ix = new web3_js_1.TransactionInstruction({ keys, programId, data });
@@ -162,8 +162,8 @@ export default class BaseDistributorClient {
162
162
  program: this.programId,
163
163
  };
164
164
  const closeClaimArgs = {
165
- amountLocked: new BN(data.amountLocked),
166
- amountUnlocked: new BN(data.amountUnlocked),
165
+ amountLocked: data.amountLocked ? new BN(data.amountLocked) : undefined,
166
+ amountUnlocked: data.amountUnlocked ? new BN(data.amountUnlocked) : undefined,
167
167
  proof: data.proof,
168
168
  };
169
169
  ixs.push(closeClaim(closeClaimArgs, closeClaimAccounts, this.programId));
@@ -20,9 +20,9 @@ export function closeClaim(args, accounts, programId = PROGRAM_ID) {
20
20
  const identifier = Buffer.from([42, 177, 165, 35, 213, 179, 211, 19]);
21
21
  const buffer = Buffer.alloc(1000);
22
22
  const len = layout.encode({
23
- amountUnlocked: args.amountUnlocked,
24
- amountLocked: args.amountLocked,
25
- proof: args.proof,
23
+ amountUnlocked: args.amountUnlocked ?? null,
24
+ amountLocked: args.amountLocked ?? null,
25
+ proof: args.proof ?? null,
26
26
  }, buffer);
27
27
  const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
28
28
  const ix = new TransactionInstruction({ keys, programId, data });
@@ -10,8 +10,8 @@ export interface NewDistributorArgs {
10
10
  endVestingTs: BN;
11
11
  clawbackStartTs: BN;
12
12
  claimsClosableByAdmin: boolean;
13
- claimsClosableByClaimant?: boolean;
14
- claimsLimit?: number;
13
+ claimsClosableByClaimant?: boolean | null;
14
+ claimsLimit?: number | null;
15
15
  }
16
16
  export interface NewDistributorAccounts {
17
17
  /** [MerkleDistributor]. */
@@ -68,8 +68,8 @@ export function newDistributor(args, accounts, programId = PROGRAM_ID) {
68
68
  canUpdateDuration: null,
69
69
  totalAmountUnlocked: null,
70
70
  totalAmountLocked: null,
71
- claimsClosableByClaimant: args.claimsClosableByClaimant,
72
- claimsLimit: args.claimsLimit,
71
+ claimsClosableByClaimant: args.claimsClosableByClaimant ?? null,
72
+ claimsLimit: args.claimsLimit ?? null,
73
73
  }, buffer);
74
74
  const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
75
75
  const ix = new TransactionInstruction({ keys, programId, data });
@@ -69,7 +69,8 @@ export interface IClaimData {
69
69
  amountLocked: BN;
70
70
  proof: Array<Array<number>>;
71
71
  }
72
- export interface ICloseClaimData extends IClaimData {
72
+ export interface ICloseClaimData extends Partial<Omit<IClaimData, "id">> {
73
+ id: string;
73
74
  claimant: string | PublicKey;
74
75
  }
75
76
  export interface IClawbackData {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/distributor",
3
- "version": "7.4.0",
3
+ "version": "7.4.2",
4
4
  "description": "JavaScript SDK to interact with Streamflow Airdrop protocol.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "dist/esm/index.js",
@@ -26,9 +26,9 @@
26
26
  "lint": "eslint --fix .",
27
27
  "prepublishOnly": "npm run lint && npm run build"
28
28
  },
29
- "gitHead": "7c307d2f70d9af073ceab20597865394295a459b",
29
+ "gitHead": "881c66c302f40bbc9810619def25f59cd6777d10",
30
30
  "devDependencies": {
31
- "@streamflow/eslint-config": "7.4.0",
31
+ "@streamflow/eslint-config": "7.4.2",
32
32
  "@types/bn.js": "5.1.1",
33
33
  "date-fns": "2.28.0",
34
34
  "typescript": "^5.6.3"
@@ -40,7 +40,7 @@
40
40
  "@solana/spl-token": "0.4.9",
41
41
  "@solana/wallet-adapter-base": "0.9.19",
42
42
  "@solana/web3.js": "1.95.4",
43
- "@streamflow/common": "7.4.0",
43
+ "@streamflow/common": "7.4.2",
44
44
  "bn.js": "5.2.1",
45
45
  "borsh": "^2.0.0",
46
46
  "bs58": "5.0.0",