@streamflow/distributor 7.0.0-alpha.16 → 7.0.0-alpha.17
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/{client.js → clients/BaseDistributorClient.js} +65 -62
- package/dist/cjs/solana/clients/SolanaAlignedDistributorClient.js +98 -0
- package/dist/cjs/solana/clients/SolanaDistributorClient.js +17 -0
- package/dist/cjs/solana/clients/index.js +10 -0
- package/dist/cjs/solana/constants.js +4 -1
- package/dist/cjs/solana/descriptor/aligned_distributor.js +2 -0
- package/dist/cjs/solana/descriptor/idl/aligned_distributor.json +1242 -0
- package/dist/cjs/solana/index.js +2 -6
- package/dist/cjs/solana/utils.js +14 -6
- package/dist/esm/solana/clients/BaseDistributorClient.d.ts +38 -0
- package/dist/esm/solana/{client.js → clients/BaseDistributorClient.js} +65 -62
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.d.ts +12 -0
- package/dist/esm/solana/clients/SolanaAlignedDistributorClient.js +93 -0
- package/dist/esm/solana/clients/SolanaDistributorClient.d.ts +8 -0
- package/dist/esm/solana/clients/SolanaDistributorClient.js +11 -0
- package/dist/esm/solana/clients/index.d.ts +2 -0
- package/dist/esm/solana/clients/index.js +2 -0
- package/dist/esm/solana/constants.d.ts +4 -0
- package/dist/esm/solana/constants.js +3 -0
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +918 -0
- package/dist/esm/solana/descriptor/aligned_distributor.js +1 -0
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +1242 -0
- package/dist/esm/solana/index.d.ts +1 -1
- package/dist/esm/solana/index.js +1 -1
- package/dist/esm/solana/types.d.ts +40 -0
- package/dist/esm/solana/utils.d.ts +2 -0
- package/dist/esm/solana/utils.js +8 -2
- package/package.json +5 -4
- package/dist/esm/solana/client.d.ts +0 -38
package/dist/esm/solana/index.js
CHANGED
|
@@ -3,6 +3,10 @@ import { Keypair } from "@solana/web3.js";
|
|
|
3
3
|
import { ITransactionResult } from "@streamflow/common";
|
|
4
4
|
import { ITransactionSolanaExt } from "@streamflow/common/solana";
|
|
5
5
|
import BN from "bn.js";
|
|
6
|
+
import { IdlTypes } from "@coral-xyz/anchor";
|
|
7
|
+
import { AlignedDistributor as AlignedDistributorIDL } from "./descriptor/aligned_distributor.js";
|
|
8
|
+
export type OracleType = IdlTypes<AlignedDistributorIDL>["oracleType"];
|
|
9
|
+
export type OracleTypeName = "none" | "pyth" | "switchboard" | "test";
|
|
6
10
|
export interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
7
11
|
invoker: SignerWalletAdapter | Keypair;
|
|
8
12
|
}
|
|
@@ -21,6 +25,42 @@ export interface ICreateDistributorData {
|
|
|
21
25
|
clawbackStartTs: number;
|
|
22
26
|
claimsClosable: boolean;
|
|
23
27
|
}
|
|
28
|
+
export interface AlignedDistributorData {
|
|
29
|
+
sender: string;
|
|
30
|
+
minPrice: number;
|
|
31
|
+
maxPrice: number;
|
|
32
|
+
minPercentage: number;
|
|
33
|
+
maxPercentage: number;
|
|
34
|
+
oracleType: OracleTypeName;
|
|
35
|
+
priceOracle: string | undefined;
|
|
36
|
+
updatePeriod: number;
|
|
37
|
+
clawedBack: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface NewAlignedDistributorArgs {
|
|
40
|
+
totalAmountLocked: BN;
|
|
41
|
+
totalAmountUnlocked: BN;
|
|
42
|
+
oracleType: OracleType;
|
|
43
|
+
minPrice: BN;
|
|
44
|
+
maxPrice: BN;
|
|
45
|
+
minPercentage: BN;
|
|
46
|
+
maxPercentage: BN;
|
|
47
|
+
tickSize: BN;
|
|
48
|
+
skipInitial: boolean;
|
|
49
|
+
updatePeriod: BN;
|
|
50
|
+
}
|
|
51
|
+
export interface ICreateAlignedDistributorData extends ICreateDistributorData {
|
|
52
|
+
minPrice: number;
|
|
53
|
+
maxPrice: number;
|
|
54
|
+
minPercentage: number;
|
|
55
|
+
maxPercentage: number;
|
|
56
|
+
oracleType: OracleTypeName;
|
|
57
|
+
oracleAddress: string;
|
|
58
|
+
totalAmountLocked: BN | number | string;
|
|
59
|
+
totalAmountUnlocked: BN | number | string;
|
|
60
|
+
updatePeriod?: number;
|
|
61
|
+
tickSize?: number;
|
|
62
|
+
skipInitial?: boolean;
|
|
63
|
+
}
|
|
24
64
|
export interface IClaimData {
|
|
25
65
|
id: string;
|
|
26
66
|
amountUnlocked: BN;
|
|
@@ -2,6 +2,8 @@ import { TransferFeeConfig } from "@solana/spl-token";
|
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { Connection, Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
4
4
|
import { ConfirmationParams, ThrottleParams } from "@streamflow/common/solana";
|
|
5
|
+
export declare const getAlignedDistributorPda: (programId: PublicKey, distributor: PublicKey) => PublicKey;
|
|
6
|
+
export declare const getTestOraclePda: (programId: PublicKey, mint: PublicKey, creator: PublicKey) => PublicKey;
|
|
5
7
|
export declare function getDistributorPda(programId: PublicKey, mint: PublicKey, version: number): PublicKey;
|
|
6
8
|
export declare function getClaimantStatusPda(programId: PublicKey, distributor: PublicKey, claimant: PublicKey): PublicKey;
|
|
7
9
|
export declare function getEventAuthorityPda(programId: PublicKey): PublicKey;
|
package/dist/esm/solana/utils.js
CHANGED
|
@@ -2,8 +2,14 @@ import { Buffer } from "buffer";
|
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
import { ContractError, divCeilN } from "@streamflow/common";
|
|
4
4
|
import { signAndExecuteTransaction } from "@streamflow/common/solana";
|
|
5
|
-
import { fromTxError } from "./generated/errors";
|
|
6
|
-
import { ONE_IN_BASIS_POINTS } from "./constants";
|
|
5
|
+
import { fromTxError } from "./generated/errors/index.js";
|
|
6
|
+
import { ONE_IN_BASIS_POINTS, ALIGNED_DISTRIBUTOR_PREFIX, TEST_ORACLE_PREFIX } from "./constants.js";
|
|
7
|
+
export const getAlignedDistributorPda = (programId, distributor) => {
|
|
8
|
+
return PublicKey.findProgramAddressSync([ALIGNED_DISTRIBUTOR_PREFIX, distributor.toBuffer()], programId)[0];
|
|
9
|
+
};
|
|
10
|
+
export const getTestOraclePda = (programId, mint, creator) => {
|
|
11
|
+
return PublicKey.findProgramAddressSync([TEST_ORACLE_PREFIX, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
12
|
+
};
|
|
7
13
|
export function getDistributorPda(programId, mint, version) {
|
|
8
14
|
// Constructing the seed for the PDA
|
|
9
15
|
const seeds = [
|
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.17",
|
|
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,20 +26,21 @@
|
|
|
26
26
|
"lint": "eslint --fix .",
|
|
27
27
|
"prepublishOnly": "npm run lint && npm run build"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "ad633465d0c533b4dd582a96b52a08b3d8c4d8c7",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
31
|
+
"@streamflow/eslint-config": "7.0.0-alpha.17",
|
|
32
32
|
"@types/bn.js": "5.1.1",
|
|
33
33
|
"date-fns": "2.28.0",
|
|
34
34
|
"typescript": "^4.9.5"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@coral-xyz/anchor": "^0.30.0",
|
|
37
38
|
"@coral-xyz/borsh": "0.30.1",
|
|
38
39
|
"@solana/buffer-layout": "4.0.1 ",
|
|
39
40
|
"@solana/spl-token": "0.3.6",
|
|
40
41
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
41
42
|
"@solana/web3.js": "1.90.2",
|
|
42
|
-
"@streamflow/common": "7.0.0-alpha.
|
|
43
|
+
"@streamflow/common": "7.0.0-alpha.17",
|
|
43
44
|
"bn.js": "5.2.1",
|
|
44
45
|
"borsh": "^2.0.0",
|
|
45
46
|
"bs58": "5.0.0",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import PQueue from "p-queue";
|
|
2
|
-
import { 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, ICreateDistributorData, ICreateDistributorResult, IGetClaimData, IGetDistributors, ICreateSolanaExt, IInteractSolanaExt, ISearchDistributors } from "./types";
|
|
6
|
-
import { ClaimStatus, MerkleDistributor } from "./generated/accounts";
|
|
7
|
-
interface IInitOptions {
|
|
8
|
-
clusterUrl: string;
|
|
9
|
-
cluster?: ICluster;
|
|
10
|
-
commitment?: Commitment | ConnectionConfig;
|
|
11
|
-
programId?: string;
|
|
12
|
-
sendRate?: number;
|
|
13
|
-
sendThrottler?: PQueue;
|
|
14
|
-
}
|
|
15
|
-
export default class SolanaDistributorClient {
|
|
16
|
-
private connection;
|
|
17
|
-
private programId;
|
|
18
|
-
private commitment;
|
|
19
|
-
private sendThrottler;
|
|
20
|
-
/**
|
|
21
|
-
* Create Stream instance
|
|
22
|
-
*/
|
|
23
|
-
constructor({ clusterUrl, cluster, commitment, programId, sendRate, sendThrottler, }: IInitOptions);
|
|
24
|
-
getCommitment(): Commitment | undefined;
|
|
25
|
-
create(data: ICreateDistributorData, extParams: ICreateSolanaExt): Promise<ICreateDistributorResult>;
|
|
26
|
-
prepareCreateInstructions(data: ICreateDistributorData, extParams: ICreateSolanaExt): Promise<{
|
|
27
|
-
distributorPublicKey: PublicKey;
|
|
28
|
-
ixs: TransactionInstruction[];
|
|
29
|
-
}>;
|
|
30
|
-
claim(data: IClaimData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
31
|
-
prepareClaimInstructions(data: IClaimData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
32
|
-
clawback(data: IClawbackData, extParams: IInteractSolanaExt): Promise<ITransactionResult>;
|
|
33
|
-
prepareClawbackInstructions(data: IClawbackData, extParams: IInteractSolanaExt): Promise<TransactionInstruction[]>;
|
|
34
|
-
getClaims(data: IGetClaimData[]): Promise<(ClaimStatus | null)[]>;
|
|
35
|
-
getDistributors(data: IGetDistributors): Promise<(MerkleDistributor | null)[]>;
|
|
36
|
-
searchDistributors(data: ISearchDistributors): Promise<IProgramAccount<MerkleDistributor>[]>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|