@streamflow/distributor 7.0.0-alpha.17 → 7.0.0-alpha.18
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/solana/clients/BaseDistributorClient.js +3 -0
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +8 -2
- package/dist/cjs/solana/constants.js +9 -1
- package/dist/cjs/solana/utils.js +2 -2
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +1 -0
- package/dist/esm/solana/clients/BaseDistributorClient.js +3 -0
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +3 -1
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +8 -2
- package/dist/esm/solana/constants.d.ts +8 -0
- package/dist/esm/solana/constants.js +8 -0
- package/dist/esm/solana/utils.js +3 -3
- package/package.json +4 -4
|
@@ -23,6 +23,9 @@ class BaseDistributorClient {
|
|
|
23
23
|
getCommitment() {
|
|
24
24
|
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
25
25
|
}
|
|
26
|
+
getDistributorProgramId() {
|
|
27
|
+
return this.programId;
|
|
28
|
+
}
|
|
26
29
|
async prepareCreateInstructions(data, extParams) {
|
|
27
30
|
if (!extParams.invoker.publicKey) {
|
|
28
31
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -19,9 +19,15 @@ class SolanaAlignedDistributorClient extends BaseDistributorClient_js_1.default
|
|
|
19
19
|
};
|
|
20
20
|
this.alignedProxyProgram = new anchor_1.Program(alignedAirdropsProgram, { connection: this.connection });
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
getAlignedDistributorProgramId() {
|
|
23
|
+
return this.alignedProxyProgram.programId;
|
|
24
|
+
}
|
|
25
|
+
getAlignedDistributorAddress(distributorAddress) {
|
|
23
26
|
const distributorKey = new web3_js_1.PublicKey(distributorAddress);
|
|
24
|
-
|
|
27
|
+
return (0, utils_js_1.getAlignedDistributorPda)(this.alignedProxyProgram.programId, distributorKey);
|
|
28
|
+
}
|
|
29
|
+
async getAlignedDistributorData(distributorAddress) {
|
|
30
|
+
const alignedDistributorKey = this.getAlignedDistributorAddress(distributorAddress);
|
|
25
31
|
const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
|
|
26
32
|
(0, common_1.invariant)(alignedProxy, "Aligned Distributor proxy account not found");
|
|
27
33
|
const oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key);
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DISTRIBUTOR_PROGRAM_ID = exports.ONE_IN_BASIS_POINTS = exports.ALIGNED_PRECISION_FACTOR_POW = exports.TEST_ORACLE_PREFIX = exports.ALIGNED_DISTRIBUTOR_PREFIX = exports.DISTRIBUTOR_ADMIN_OFFSET = exports.DISTRIBUTOR_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET = void 0;
|
|
3
|
+
exports.DISTRIBUTOR_PROGRAM_ID = exports.ALIGNED_DISTRIBUTOR_PROGRAM_ID = exports.ONE_IN_BASIS_POINTS = exports.ALIGNED_PRECISION_FACTOR_POW = exports.CLAIM_STATUS_PREFIX = exports.TEST_ORACLE_PREFIX = exports.ALIGNED_DISTRIBUTOR_PREFIX = exports.DISTRIBUTOR_PREFIX = exports.DISTRIBUTOR_ADMIN_OFFSET = exports.DISTRIBUTOR_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET = void 0;
|
|
4
4
|
const common_1 = require("@streamflow/common");
|
|
5
5
|
exports.ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
6
6
|
exports.DISTRIBUTOR_MINT_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET + 41;
|
|
7
7
|
exports.DISTRIBUTOR_ADMIN_OFFSET = exports.ANCHOR_DISCRIMINATOR_OFFSET + 201;
|
|
8
|
+
exports.DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
8
9
|
exports.ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
9
10
|
exports.TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
11
|
+
exports.CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
10
12
|
exports.ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
11
13
|
exports.ONE_IN_BASIS_POINTS = BigInt(10000);
|
|
14
|
+
exports.ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
15
|
+
[common_1.ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
16
|
+
[common_1.ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
17
|
+
[common_1.ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
18
|
+
[common_1.ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
19
|
+
};
|
|
12
20
|
exports.DISTRIBUTOR_PROGRAM_ID = {
|
|
13
21
|
[common_1.ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
14
22
|
[common_1.ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
package/dist/cjs/solana/utils.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.getTestOraclePda = getTestOraclePda;
|
|
|
18
18
|
function getDistributorPda(programId, mint, version) {
|
|
19
19
|
// Constructing the seed for the PDA
|
|
20
20
|
const seeds = [
|
|
21
|
-
|
|
21
|
+
constants_js_1.DISTRIBUTOR_PREFIX,
|
|
22
22
|
mint.toBuffer(),
|
|
23
23
|
buffer_1.Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer)),
|
|
24
24
|
];
|
|
@@ -28,7 +28,7 @@ function getDistributorPda(programId, mint, version) {
|
|
|
28
28
|
exports.getDistributorPda = getDistributorPda;
|
|
29
29
|
function getClaimantStatusPda(programId, distributor, claimant) {
|
|
30
30
|
// Constructing the seed for the PDA
|
|
31
|
-
const seeds = [
|
|
31
|
+
const seeds = [constants_js_1.CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
32
32
|
// Finding the PDA
|
|
33
33
|
return web3_js_1.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
34
34
|
}
|
|
@@ -22,6 +22,7 @@ export default abstract class BaseDistributorClient {
|
|
|
22
22
|
protected abstract getNewDistributorInstruction(data: ICreateDistributorData | ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
|
|
23
23
|
protected abstract getClawbackInstruction(account: ClawbackAccounts): Promise<TransactionInstruction>;
|
|
24
24
|
getCommitment(): Commitment | undefined;
|
|
25
|
+
getDistributorProgramId(): PublicKey;
|
|
25
26
|
prepareCreateInstructions(data: ICreateDistributorData | ICreateAlignedDistributorData, extParams: ICreateSolanaExt): Promise<{
|
|
26
27
|
distributorPublicKey: PublicKey;
|
|
27
28
|
ixs: TransactionInstruction[];
|
|
@@ -22,6 +22,9 @@ export default class BaseDistributorClient {
|
|
|
22
22
|
getCommitment() {
|
|
23
23
|
return typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
|
|
24
24
|
}
|
|
25
|
+
getDistributorProgramId() {
|
|
26
|
+
return this.programId;
|
|
27
|
+
}
|
|
25
28
|
async prepareCreateInstructions(data, extParams) {
|
|
26
29
|
if (!extParams.invoker.publicKey) {
|
|
27
30
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { TransactionInstruction } from "@solana/web3.js";
|
|
1
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
import { ICreateAlignedDistributorData, AlignedDistributorData, NewAlignedDistributorArgs } from "../types";
|
|
3
3
|
import { ClawbackAccounts, NewDistributorAccounts } from "../generated/instructions";
|
|
4
4
|
import BaseDistributorClient, { IInitOptions } from "./BaseDistributorClient.js";
|
|
5
5
|
export default class SolanaAlignedDistributorClient extends BaseDistributorClient {
|
|
6
6
|
private alignedProxyProgram;
|
|
7
7
|
constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler }: IInitOptions);
|
|
8
|
+
getAlignedDistributorProgramId(): PublicKey;
|
|
9
|
+
getAlignedDistributorAddress(distributorAddress: string): PublicKey;
|
|
8
10
|
getAlignedDistributorData(distributorAddress: string): Promise<AlignedDistributorData>;
|
|
9
11
|
protected getNewDistributorInstruction(data: ICreateAlignedDistributorData, accounts: NewDistributorAccounts): Promise<TransactionInstruction>;
|
|
10
12
|
protected getClawbackInstruction(accounts: ClawbackAccounts): Promise<TransactionInstruction>;
|
|
@@ -15,9 +15,15 @@ export default class SolanaAlignedDistributorClient extends BaseDistributorClien
|
|
|
15
15
|
};
|
|
16
16
|
this.alignedProxyProgram = new Program(alignedAirdropsProgram, { connection: this.connection });
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
getAlignedDistributorProgramId() {
|
|
19
|
+
return this.alignedProxyProgram.programId;
|
|
20
|
+
}
|
|
21
|
+
getAlignedDistributorAddress(distributorAddress) {
|
|
19
22
|
const distributorKey = new PublicKey(distributorAddress);
|
|
20
|
-
|
|
23
|
+
return getAlignedDistributorPda(this.alignedProxyProgram.programId, distributorKey);
|
|
24
|
+
}
|
|
25
|
+
async getAlignedDistributorData(distributorAddress) {
|
|
26
|
+
const alignedDistributorKey = this.getAlignedDistributorAddress(distributorAddress);
|
|
21
27
|
const alignedProxy = await this.alignedProxyProgram.account.alignedDistributor.fetch(alignedDistributorKey);
|
|
22
28
|
invariant(alignedProxy, "Aligned Distributor proxy account not found");
|
|
23
29
|
const oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key);
|
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
export declare const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
3
3
|
export declare const DISTRIBUTOR_MINT_OFFSET: number;
|
|
4
4
|
export declare const DISTRIBUTOR_ADMIN_OFFSET: number;
|
|
5
|
+
export declare const DISTRIBUTOR_PREFIX: Buffer;
|
|
5
6
|
export declare const ALIGNED_DISTRIBUTOR_PREFIX: Buffer;
|
|
6
7
|
export declare const TEST_ORACLE_PREFIX: Buffer;
|
|
8
|
+
export declare const CLAIM_STATUS_PREFIX: Buffer;
|
|
7
9
|
export declare const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
8
10
|
export declare const ONE_IN_BASIS_POINTS: bigint;
|
|
11
|
+
export declare const ALIGNED_DISTRIBUTOR_PROGRAM_ID: {
|
|
12
|
+
devnet: string;
|
|
13
|
+
mainnet: string;
|
|
14
|
+
testnet: string;
|
|
15
|
+
local: string;
|
|
16
|
+
};
|
|
9
17
|
export declare const DISTRIBUTOR_PROGRAM_ID: {
|
|
10
18
|
devnet: string;
|
|
11
19
|
mainnet: string;
|
|
@@ -2,10 +2,18 @@ import { ICluster } from "@streamflow/common";
|
|
|
2
2
|
export const ANCHOR_DISCRIMINATOR_OFFSET = 8;
|
|
3
3
|
export const DISTRIBUTOR_MINT_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 41;
|
|
4
4
|
export const DISTRIBUTOR_ADMIN_OFFSET = ANCHOR_DISCRIMINATOR_OFFSET + 201;
|
|
5
|
+
export const DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
5
6
|
export const ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
6
7
|
export const TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
8
|
+
export const CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
7
9
|
export const ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
8
10
|
export const ONE_IN_BASIS_POINTS = BigInt(10000);
|
|
11
|
+
export const ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
12
|
+
[ICluster.Devnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
13
|
+
[ICluster.Mainnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
14
|
+
[ICluster.Testnet]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
15
|
+
[ICluster.Local]: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
16
|
+
};
|
|
9
17
|
export const DISTRIBUTOR_PROGRAM_ID = {
|
|
10
18
|
[ICluster.Devnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
11
19
|
[ICluster.Mainnet]: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
package/dist/esm/solana/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
3
3
|
import { ContractError, divCeilN } from "@streamflow/common";
|
|
4
4
|
import { signAndExecuteTransaction } from "@streamflow/common/solana";
|
|
5
5
|
import { fromTxError } from "./generated/errors/index.js";
|
|
6
|
-
import { ONE_IN_BASIS_POINTS, ALIGNED_DISTRIBUTOR_PREFIX, TEST_ORACLE_PREFIX } from "./constants.js";
|
|
6
|
+
import { ONE_IN_BASIS_POINTS, ALIGNED_DISTRIBUTOR_PREFIX, TEST_ORACLE_PREFIX, DISTRIBUTOR_PREFIX, CLAIM_STATUS_PREFIX, } from "./constants.js";
|
|
7
7
|
export const getAlignedDistributorPda = (programId, distributor) => {
|
|
8
8
|
return PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
|
|
9
9
|
};
|
|
@@ -13,7 +13,7 @@ export const getTestOraclePda = (programId, mint, creator) => {
|
|
|
13
13
|
export function getDistributorPda(programId, mint, version) {
|
|
14
14
|
// Constructing the seed for the PDA
|
|
15
15
|
const seeds = [
|
|
16
|
-
|
|
16
|
+
DISTRIBUTOR_PREFIX,
|
|
17
17
|
mint.toBuffer(),
|
|
18
18
|
Buffer.from(new Uint8Array(new BigUint64Array([BigInt(version)]).buffer)),
|
|
19
19
|
];
|
|
@@ -22,7 +22,7 @@ export function getDistributorPda(programId, mint, version) {
|
|
|
22
22
|
}
|
|
23
23
|
export function getClaimantStatusPda(programId, distributor, claimant) {
|
|
24
24
|
// Constructing the seed for the PDA
|
|
25
|
-
const seeds = [
|
|
25
|
+
const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
26
26
|
// Finding the PDA
|
|
27
27
|
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/distributor",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.18",
|
|
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": "
|
|
29
|
+
"gitHead": "763e30b7c28578e17e61480852b010d343c3f30d",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
31
|
+
"@streamflow/eslint-config": "7.0.0-alpha.18",
|
|
32
32
|
"@types/bn.js": "5.1.1",
|
|
33
33
|
"date-fns": "2.28.0",
|
|
34
34
|
"typescript": "^4.9.5"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@solana/spl-token": "0.3.6",
|
|
41
41
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
42
42
|
"@solana/web3.js": "1.90.2",
|
|
43
|
-
"@streamflow/common": "7.0.0-alpha.
|
|
43
|
+
"@streamflow/common": "7.0.0-alpha.18",
|
|
44
44
|
"bn.js": "5.2.1",
|
|
45
45
|
"borsh": "^2.0.0",
|
|
46
46
|
"bs58": "5.0.0",
|