@streamflow/distributor 6.3.9 → 6.4.3
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 +16 -0
- package/dist/solana/client.d.ts +3 -1
- package/dist/solana/client.js +38 -0
- package/dist/solana/constants.d.ts +3 -0
- package/dist/solana/constants.js +4 -1
- package/dist/solana/types.d.ts +4 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ or
|
|
|
19
19
|
## Documentation
|
|
20
20
|
API Documentation available here: [docs site →](https://streamflow-finance.github.io/js-sdk/)
|
|
21
21
|
|
|
22
|
+
Automated Airdrop Creation: [notion doc →](https://streamflow.notion.site/Automated-Airdrop-Creation-45b84bfd2dda4d7196be5dd02eed29c8)
|
|
23
|
+
|
|
22
24
|
## Import SDK
|
|
23
25
|
|
|
24
26
|
Most common imports:
|
|
@@ -112,6 +114,20 @@ const solanaParams = {
|
|
|
112
114
|
const clawbackRes = await client.clawback({ id: res.metadataId }, solanaParams);
|
|
113
115
|
```
|
|
114
116
|
|
|
117
|
+
## Search Airdrops
|
|
118
|
+
|
|
119
|
+
As all the data is stored on-chain you can also search Airdrops with `searchDistributors` method:
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
// All parameters are optional, so in theory you just fetch all Distributors
|
|
123
|
+
const params = {
|
|
124
|
+
mint: "BZLbGTNCSFfoth2GYDtwr7e4imWzpR5jqcUuGEwr646K",
|
|
125
|
+
admin: "s3pWmY359mDrNRnDBZ3v5TrrqqxvxiW2t4U2WZyxRoA"
|
|
126
|
+
};
|
|
127
|
+
// Return an Array of objects {publicKey: PublicKey, account: Distributor}
|
|
128
|
+
const disributors = await client.searchDistributors(params);
|
|
129
|
+
```
|
|
130
|
+
|
|
115
131
|
## Handling errors
|
|
116
132
|
|
|
117
133
|
`GenericStreamClient` wraps all errors when making on-chain calls with `ContractError` error class:
|
package/dist/solana/client.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import PQueue from "p-queue";
|
|
2
2
|
import { PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
3
|
import { ICluster, ITransactionResult } from "@streamflow/common";
|
|
4
|
-
import {
|
|
4
|
+
import { IProgramAccount } from "@streamflow/common/solana";
|
|
5
|
+
import { IClaimData, IClawbackData, ICreateDistributorData, ICreateDistributorResult, IGetClaimData, IGetDistributors, ICreateSolanaExt, IInteractSolanaExt, ISearchDistributors } from "./types";
|
|
5
6
|
import { ClaimStatus, MerkleDistributor } from "./generated/accounts";
|
|
6
7
|
interface IInitOptions {
|
|
7
8
|
clusterUrl: string;
|
|
@@ -32,5 +33,6 @@ export default class SolanaDistributorClient {
|
|
|
32
33
|
prepareClawbackInstructions(data: IClawbackData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
33
34
|
getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]>;
|
|
34
35
|
getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
|
|
36
|
+
searchDistributors(data: ISearchDistributors): Promise<IProgramAccount<MerkleDistributor>[]>;
|
|
35
37
|
}
|
|
36
38
|
export {};
|
package/dist/solana/client.js
CHANGED
|
@@ -64,6 +64,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
64
64
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
65
|
};
|
|
66
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
var bs58_1 = __importDefault(require("bs58"));
|
|
67
68
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
68
69
|
var spl_token_1 = require("@solana/spl-token");
|
|
69
70
|
var web3_js_1 = require("@solana/web3.js");
|
|
@@ -359,6 +360,43 @@ var SolanaDistributorClient = /** @class */ (function () {
|
|
|
359
360
|
});
|
|
360
361
|
});
|
|
361
362
|
};
|
|
363
|
+
SolanaDistributorClient.prototype.searchDistributors = function (data) {
|
|
364
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
+
var filters, accounts;
|
|
366
|
+
return __generator(this, function (_a) {
|
|
367
|
+
switch (_a.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
filters = [{ memcmp: { offset: 0, bytes: bs58_1.default.encode(accounts_1.MerkleDistributor.discriminator) } }];
|
|
370
|
+
if (data.mint) {
|
|
371
|
+
filters.push({
|
|
372
|
+
memcmp: {
|
|
373
|
+
offset: constants_1.DISTRIBUTOR_MINT_OFFSET,
|
|
374
|
+
bytes: data.mint,
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
if (data.admin) {
|
|
379
|
+
filters.push({
|
|
380
|
+
memcmp: {
|
|
381
|
+
offset: constants_1.DISTRIBUTOR_ADMIN_OFFSET,
|
|
382
|
+
bytes: data.admin,
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return [4 /*yield*/, this.connection.getProgramAccounts(this.programId, { filters: filters })];
|
|
387
|
+
case 1:
|
|
388
|
+
accounts = _a.sent();
|
|
389
|
+
return [2 /*return*/, accounts.map(function (_a) {
|
|
390
|
+
var pubkey = _a.pubkey, account = _a.account;
|
|
391
|
+
return ({
|
|
392
|
+
publicKey: pubkey,
|
|
393
|
+
account: accounts_1.MerkleDistributor.decode(account.data),
|
|
394
|
+
});
|
|
395
|
+
})];
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
};
|
|
362
400
|
return SolanaDistributorClient;
|
|
363
401
|
}());
|
|
364
402
|
exports.default = SolanaDistributorClient;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
2
|
+
export declare const DISTRIBUTOR_MINT_OFFSET: number;
|
|
3
|
+
export declare const DISTRIBUTOR_ADMIN_OFFSET: number;
|
|
1
4
|
export declare const ONE_IN_BASIS_POINTS: bigint;
|
|
2
5
|
export declare const DISTRIBUTOR_PROGRAM_ID: {
|
|
3
6
|
devnet: string;
|
package/dist/solana/constants.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DISTRIBUTOR_PROGRAM_ID = exports.ONE_IN_BASIS_POINTS = void 0;
|
|
4
|
+
exports.DISTRIBUTOR_PROGRAM_ID = exports.ONE_IN_BASIS_POINTS = exports.DISTRIBUTOR_ADMIN_OFFSET = exports.DISTRIBUTOR_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET = void 0;
|
|
5
5
|
var common_1 = require("@streamflow/common");
|
|
6
|
+
exports.ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
7
|
+
exports.DISTRIBUTOR_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET + 41;
|
|
8
|
+
exports.DISTRIBUTOR_ADMIN_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET + 201;
|
|
6
9
|
exports.ONE_IN_BASIS_POINTS = BigInt(10000);
|
|
7
10
|
exports.DISTRIBUTOR_PROGRAM_ID = (_a = {},
|
|
8
11
|
_a[common_1.ICluster.Devnet] = "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
package/dist/solana/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/distributor",
|
|
3
|
-
"version": "6.3
|
|
3
|
+
"version": "6.4.3",
|
|
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/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"lint": "eslint --fix .",
|
|
23
23
|
"prepublishOnly": "npm run lint && npm run build"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "234546ef34a41540e93b05fb20e1675582e9c0c3",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@streamflow/eslint-config": "6.
|
|
27
|
+
"@streamflow/eslint-config": "6.4.2",
|
|
28
28
|
"@types/bn.js": "5.1.1",
|
|
29
29
|
"@types/jest": "29.2.4",
|
|
30
30
|
"date-fns": "2.28.0",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"typescript": "^4.9.5"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@coral-xyz/borsh": "
|
|
36
|
+
"@coral-xyz/borsh": "0.30.1",
|
|
37
37
|
"@solana/buffer-layout": "4.0.1 ",
|
|
38
38
|
"@solana/spl-token": "0.3.6",
|
|
39
39
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
40
|
-
"@solana/web3.js": "1.
|
|
41
|
-
"@streamflow/common": "6.3
|
|
40
|
+
"@solana/web3.js": "1.90.2",
|
|
41
|
+
"@streamflow/common": "6.4.3",
|
|
42
42
|
"bn.js": "5.2.1",
|
|
43
43
|
"borsh": "^2.0.0",
|
|
44
44
|
"bs58": "5.0.0",
|