@streamflow/stream 3.0.17 → 3.0.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/__tests__/aptos/streamClient.spec.d.ts +1 -0
- package/dist/__tests__/aptos/streamClient.spec.js +160 -0
- package/dist/aptos/StreamClient.d.ts +49 -0
- package/dist/aptos/StreamClient.js +362 -0
- package/dist/aptos/constants.d.ts +2 -0
- package/dist/aptos/constants.js +12 -0
- package/dist/aptos/index.d.ts +2 -0
- package/dist/aptos/index.js +24 -0
- package/dist/aptos/types.d.ts +145 -0
- package/dist/aptos/types.js +65 -0
- package/dist/common/BaseStreamClient.d.ts +11 -0
- package/dist/common/BaseStreamClient.js +9 -0
- package/dist/common/GenericStreamClient.d.ts +60 -0
- package/dist/common/GenericStreamClient.js +137 -0
- package/dist/common/types.d.ts +71 -0
- package/dist/common/types.js +28 -0
- package/dist/{utils.d.ts → common/utils.d.ts} +0 -4
- package/dist/common/utils.js +31 -0
- package/dist/index.d.ts +5 -6
- package/dist/index.js +19 -10
- package/dist/solana/StreamClient.d.ts +71 -0
- package/dist/{StreamClient.js → solana/StreamClient.js} +303 -396
- package/dist/{constants.d.ts → solana/constants.d.ts} +1 -1
- package/dist/{constants.js → solana/constants.js} +5 -5
- package/dist/solana/index.d.ts +7 -0
- package/dist/solana/index.js +43 -0
- package/dist/solana/instructionTypes.d.ts +86 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/{instructions.d.ts → solana/instructions.d.ts} +8 -2
- package/dist/{instructions.js → solana/instructions.js} +55 -38
- package/dist/solana/layout.d.ts +27 -0
- package/dist/{layout.js → solana/layout.js} +65 -3
- package/dist/{idl/timelock.d.ts → solana/timelockIDL.d.ts} +0 -0
- package/dist/{idl/timelock.js → solana/timelockIDL.js} +0 -0
- package/dist/{types.d.ts → solana/types.d.ts} +37 -34
- package/dist/{types.js → solana/types.js} +3 -20
- package/dist/solana/utils.d.ts +42 -0
- package/dist/solana/utils.js +271 -0
- package/package.json +1 -1
- package/dist/Stream.d.ts +0 -87
- package/dist/Stream.js +0 -503
- package/dist/StreamClient.d.ts +0 -146
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -3
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +0 -67
- package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +0 -6
- package/dist/__tests__/test_dependencies/airdrop/airdrop.js +0 -215
- package/dist/__tests__/test_dependencies/constants/index.d.ts +0 -122
- package/dist/__tests__/test_dependencies/constants/index.js +0 -158
- package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +0 -27
- package/dist/__tests__/test_dependencies/idl/airdrop.js +0 -171
- package/dist/layout.d.ts +0 -22
- package/dist/utils.js +0 -126
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
import { IRecipient } from "../common/types";
|
|
4
|
+
export interface ICreateStreamAptosExt {
|
|
5
|
+
senderWallet: WalletContextState;
|
|
6
|
+
}
|
|
7
|
+
declare type MetadataId = string;
|
|
8
|
+
export interface CreateMultiError {
|
|
9
|
+
recipient: string;
|
|
10
|
+
error: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IMultiTransactionResult {
|
|
13
|
+
txs: string[];
|
|
14
|
+
metadatas: MetadataId[];
|
|
15
|
+
metadataToRecipient: Record<MetadataId, IRecipient>;
|
|
16
|
+
errors: CreateMultiError[];
|
|
17
|
+
}
|
|
18
|
+
export interface ITransactionResult {
|
|
19
|
+
txId: string;
|
|
20
|
+
}
|
|
21
|
+
export declare type ITransactionAptosExt = ICreateStreamAptosExt & {
|
|
22
|
+
tokenId: string;
|
|
23
|
+
};
|
|
24
|
+
export interface StreamResource {
|
|
25
|
+
amount: string;
|
|
26
|
+
amount_per_period: string;
|
|
27
|
+
canceled_at: string;
|
|
28
|
+
cliff_amount: string;
|
|
29
|
+
closed: boolean;
|
|
30
|
+
contract_signer_cap: {
|
|
31
|
+
account: string;
|
|
32
|
+
};
|
|
33
|
+
created: string;
|
|
34
|
+
current_pause_start: string;
|
|
35
|
+
end: string;
|
|
36
|
+
fees: {
|
|
37
|
+
streamflow_fee: string;
|
|
38
|
+
streamflow_fee_percentage: string;
|
|
39
|
+
streamflow_fee_withdrawn: string;
|
|
40
|
+
};
|
|
41
|
+
funds_unlocked_at_last_rate_change: string;
|
|
42
|
+
last_rate_change_time: string;
|
|
43
|
+
last_withdrawn_at: string;
|
|
44
|
+
meta: {
|
|
45
|
+
automatic_withdrawal: boolean;
|
|
46
|
+
can_topup: boolean;
|
|
47
|
+
can_update_rate: boolean;
|
|
48
|
+
cancelable_by_recipient: boolean;
|
|
49
|
+
cancelable_by_sender: boolean;
|
|
50
|
+
contract_name: string;
|
|
51
|
+
pausable: boolean;
|
|
52
|
+
transferable_by_recipient: boolean;
|
|
53
|
+
transferable_by_sender: boolean;
|
|
54
|
+
withdrawal_frequency: string;
|
|
55
|
+
};
|
|
56
|
+
pause_cumulative: string;
|
|
57
|
+
period: string;
|
|
58
|
+
recipient: string;
|
|
59
|
+
sender: string;
|
|
60
|
+
start: string;
|
|
61
|
+
withdrawn: string;
|
|
62
|
+
}
|
|
63
|
+
export interface Stream {
|
|
64
|
+
magic: number;
|
|
65
|
+
version: number;
|
|
66
|
+
createdAt: number;
|
|
67
|
+
withdrawnAmount: BN;
|
|
68
|
+
canceledAt: number;
|
|
69
|
+
end: number;
|
|
70
|
+
lastWithdrawnAt: number;
|
|
71
|
+
sender: string;
|
|
72
|
+
senderTokens: string;
|
|
73
|
+
recipient: string;
|
|
74
|
+
recipientTokens: string;
|
|
75
|
+
mint: string;
|
|
76
|
+
escrowTokens: string;
|
|
77
|
+
streamflowTreasury: string;
|
|
78
|
+
streamflowTreasuryTokens: string;
|
|
79
|
+
streamflowFeeTotal: BN;
|
|
80
|
+
streamflowFeeWithdrawn: BN;
|
|
81
|
+
streamflowFeePercent: number;
|
|
82
|
+
partnerFeeTotal: BN;
|
|
83
|
+
partnerFeeWithdrawn: BN;
|
|
84
|
+
partnerFeePercent: number;
|
|
85
|
+
partner: string;
|
|
86
|
+
partnerTokens: string;
|
|
87
|
+
start: number;
|
|
88
|
+
depositedAmount: BN;
|
|
89
|
+
period: number;
|
|
90
|
+
amountPerPeriod: BN;
|
|
91
|
+
cliff: number;
|
|
92
|
+
cliffAmount: BN;
|
|
93
|
+
cancelableBySender: boolean;
|
|
94
|
+
cancelableByRecipient: boolean;
|
|
95
|
+
automaticWithdrawal: boolean;
|
|
96
|
+
transferableBySender: boolean;
|
|
97
|
+
transferableByRecipient: boolean;
|
|
98
|
+
canTopup: boolean;
|
|
99
|
+
name: string;
|
|
100
|
+
withdrawalFrequency: number;
|
|
101
|
+
unlocked(currentTimestamp: number, decimals: number): number;
|
|
102
|
+
}
|
|
103
|
+
export declare class Contract implements Stream {
|
|
104
|
+
magic: number;
|
|
105
|
+
version: number;
|
|
106
|
+
createdAt: number;
|
|
107
|
+
withdrawnAmount: BN;
|
|
108
|
+
canceledAt: number;
|
|
109
|
+
end: number;
|
|
110
|
+
lastWithdrawnAt: number;
|
|
111
|
+
sender: string;
|
|
112
|
+
senderTokens: string;
|
|
113
|
+
recipient: string;
|
|
114
|
+
recipientTokens: string;
|
|
115
|
+
mint: string;
|
|
116
|
+
escrowTokens: string;
|
|
117
|
+
streamflowTreasury: string;
|
|
118
|
+
streamflowTreasuryTokens: string;
|
|
119
|
+
streamflowFeeTotal: BN;
|
|
120
|
+
streamflowFeeWithdrawn: BN;
|
|
121
|
+
streamflowFeePercent: number;
|
|
122
|
+
partnerFeeTotal: BN;
|
|
123
|
+
partnerFeeWithdrawn: BN;
|
|
124
|
+
partnerFeePercent: number;
|
|
125
|
+
partner: string;
|
|
126
|
+
partnerTokens: string;
|
|
127
|
+
start: number;
|
|
128
|
+
depositedAmount: BN;
|
|
129
|
+
period: number;
|
|
130
|
+
amountPerPeriod: BN;
|
|
131
|
+
cliff: number;
|
|
132
|
+
cliffAmount: BN;
|
|
133
|
+
cancelableBySender: boolean;
|
|
134
|
+
cancelableByRecipient: boolean;
|
|
135
|
+
automaticWithdrawal: boolean;
|
|
136
|
+
transferableBySender: boolean;
|
|
137
|
+
transferableByRecipient: boolean;
|
|
138
|
+
canTopup: boolean;
|
|
139
|
+
name: string;
|
|
140
|
+
withdrawalFrequency: number;
|
|
141
|
+
constructor(stream: StreamResource, tokenId: string);
|
|
142
|
+
unlocked(currentTimestamp: number, decimals: number): number;
|
|
143
|
+
remaining(decimals: number): number;
|
|
144
|
+
}
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Contract = void 0;
|
|
7
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
var utils_1 = require("../common/utils");
|
|
9
|
+
var Contract = /** @class */ (function () {
|
|
10
|
+
function Contract(stream, tokenId) {
|
|
11
|
+
this.magic = 0;
|
|
12
|
+
this.version = 0;
|
|
13
|
+
this.createdAt = parseInt(stream.created);
|
|
14
|
+
this.withdrawnAmount = new bn_js_1.default(stream.withdrawn);
|
|
15
|
+
this.canceledAt = parseInt(stream.canceled_at);
|
|
16
|
+
this.end = parseInt(stream.end);
|
|
17
|
+
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
18
|
+
this.sender = stream.sender;
|
|
19
|
+
this.senderTokens = stream.sender;
|
|
20
|
+
this.recipient = stream.recipient;
|
|
21
|
+
this.recipientTokens = stream.recipient;
|
|
22
|
+
this.mint = tokenId;
|
|
23
|
+
this.escrowTokens = "";
|
|
24
|
+
this.streamflowTreasury = "";
|
|
25
|
+
this.streamflowTreasuryTokens = "";
|
|
26
|
+
this.streamflowFeeTotal = new bn_js_1.default(0);
|
|
27
|
+
this.streamflowFeeWithdrawn = new bn_js_1.default(0);
|
|
28
|
+
this.streamflowFeePercent = parseInt(stream.fees.streamflow_fee_percentage) / 10000;
|
|
29
|
+
this.partnerFeeTotal = new bn_js_1.default(0);
|
|
30
|
+
this.partnerFeeWithdrawn = new bn_js_1.default(0);
|
|
31
|
+
this.partnerFeePercent = 0;
|
|
32
|
+
this.partner = "";
|
|
33
|
+
this.partnerTokens = "";
|
|
34
|
+
this.start = parseInt(stream.start);
|
|
35
|
+
this.depositedAmount = new bn_js_1.default(stream.amount);
|
|
36
|
+
this.period = parseInt(stream.period);
|
|
37
|
+
this.amountPerPeriod = new bn_js_1.default(stream.amount_per_period);
|
|
38
|
+
this.cliff = parseInt(stream.start);
|
|
39
|
+
this.cliffAmount = new bn_js_1.default(stream.cliff_amount);
|
|
40
|
+
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
41
|
+
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
42
|
+
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
43
|
+
this.transferableBySender = stream.meta.transferable_by_sender;
|
|
44
|
+
this.transferableByRecipient = stream.meta.transferable_by_recipient;
|
|
45
|
+
this.canTopup = stream.meta.can_topup;
|
|
46
|
+
var name = stream.meta.contract_name.replace("0x", "");
|
|
47
|
+
this.name = Buffer.from(name, "hex").toString("utf8");
|
|
48
|
+
this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
|
|
49
|
+
}
|
|
50
|
+
Contract.prototype.unlocked = function (currentTimestamp, decimals) {
|
|
51
|
+
var deposited = (0, utils_1.getNumberFromBN)(this.depositedAmount, decimals);
|
|
52
|
+
if (currentTimestamp < this.cliff)
|
|
53
|
+
return 0;
|
|
54
|
+
if (currentTimestamp > this.end)
|
|
55
|
+
return deposited;
|
|
56
|
+
var streamedBN = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
57
|
+
var streamed = (0, utils_1.getNumberFromBN)(streamedBN, decimals);
|
|
58
|
+
return streamed < deposited ? streamed : deposited;
|
|
59
|
+
};
|
|
60
|
+
Contract.prototype.remaining = function (decimals) {
|
|
61
|
+
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
62
|
+
};
|
|
63
|
+
return Contract;
|
|
64
|
+
}());
|
|
65
|
+
exports.Contract = Contract;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ICreateStreamData, ICreateMultipleStreamData, IWithdrawData, ICancelData, ITransferData, ITopUpData, IGetOneData, IUpdateData } from "./types";
|
|
2
|
+
export declare abstract class BaseStreamClient {
|
|
3
|
+
protected abstract create(streamData: ICreateStreamData, chainSpecificParams: any): Promise<any>;
|
|
4
|
+
protected abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: any): Promise<any>;
|
|
5
|
+
protected abstract withdraw(withdrawData: IWithdrawData, chainSpecificParams: any): Promise<any>;
|
|
6
|
+
protected abstract cancel(cancelData: ICancelData, chainSpecificParams: any): Promise<any>;
|
|
7
|
+
protected abstract transfer(transferData: ITransferData, chainSpecificParams: any): Promise<any>;
|
|
8
|
+
protected abstract topup(topupData: ITopUpData, chainSpecificParams: any): Promise<any>;
|
|
9
|
+
protected abstract getOne(getOneData: IGetOneData, chainSpecificParams: any): Promise<any>;
|
|
10
|
+
protected abstract update(updateData: IUpdateData, chainSpecificParams: any): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseStreamClient = void 0;
|
|
4
|
+
var BaseStreamClient = /** @class */ (function () {
|
|
5
|
+
function BaseStreamClient() {
|
|
6
|
+
}
|
|
7
|
+
return BaseStreamClient;
|
|
8
|
+
}());
|
|
9
|
+
exports.BaseStreamClient = BaseStreamClient;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
|
+
import SolanaStreamClient from "../solana/StreamClient";
|
|
3
|
+
import AptosStreamClient from "../aptos/StreamClient";
|
|
4
|
+
import { BaseStreamClient } from "./BaseStreamClient";
|
|
5
|
+
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData } from "./types";
|
|
6
|
+
import { CreateMultiResponse, CreateResponse, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, Stream, TxResponse } from "../solana";
|
|
7
|
+
import { ICreateStreamAptosExt, IMultiTransactionResult, ITransactionAptosExt, ITransactionResult } from "../aptos";
|
|
8
|
+
export interface SolanaStreamClientOptions {
|
|
9
|
+
chain: IChain.Solana;
|
|
10
|
+
clusterUrl: string;
|
|
11
|
+
cluster?: ICluster;
|
|
12
|
+
programId?: string;
|
|
13
|
+
commitment?: Commitment | ConnectionConfig;
|
|
14
|
+
}
|
|
15
|
+
export interface AptosStreamClientOptions {
|
|
16
|
+
chain: IChain.Aptos;
|
|
17
|
+
clusterUrl: string;
|
|
18
|
+
cluster?: ICluster;
|
|
19
|
+
programId?: string;
|
|
20
|
+
maxGas?: string;
|
|
21
|
+
}
|
|
22
|
+
declare type GenericStreamClientOptions = SolanaStreamClientOptions | AptosStreamClientOptions;
|
|
23
|
+
export default class GenericStreamClient extends BaseStreamClient {
|
|
24
|
+
nativeStreamClient: SolanaStreamClient | AptosStreamClient;
|
|
25
|
+
chain: IChain;
|
|
26
|
+
constructor(options: GenericStreamClientOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new stream/vesting contract.
|
|
29
|
+
*/
|
|
30
|
+
create(streamData: ICreateStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<CreateResponse | ITransactionResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates multiple stream/vesting contracts.
|
|
33
|
+
*/
|
|
34
|
+
createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<CreateMultiResponse | IMultiTransactionResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Attempts withdrawing from the specified stream.
|
|
37
|
+
*/
|
|
38
|
+
withdraw(withdrawData: IWithdrawData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Attempts canceling the specified stream.
|
|
41
|
+
*/
|
|
42
|
+
cancel(cancelData: ICancelData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
45
|
+
*/
|
|
46
|
+
transfer(transferData: ITransferData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Tops up stream account with specified amount.
|
|
49
|
+
*/
|
|
50
|
+
topup(topupData: ITopUpData, chainSpecificParams: ITransactionAptosExt | ITopUpStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch stream data by its id (address).
|
|
53
|
+
*/
|
|
54
|
+
getOne(getOneData: IGetOneData): Promise<Stream>;
|
|
55
|
+
/**
|
|
56
|
+
* Attempts updating the stream auto withdrawal params and amount per period
|
|
57
|
+
*/
|
|
58
|
+
update(updateData: IUpdateData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var StreamClient_1 = __importDefault(require("../solana/StreamClient"));
|
|
22
|
+
var StreamClient_2 = __importDefault(require("../aptos/StreamClient"));
|
|
23
|
+
var BaseStreamClient_1 = require("./BaseStreamClient");
|
|
24
|
+
var types_1 = require("./types");
|
|
25
|
+
var GenericStreamClient = /** @class */ (function (_super) {
|
|
26
|
+
__extends(GenericStreamClient, _super);
|
|
27
|
+
function GenericStreamClient(options) {
|
|
28
|
+
var _this = _super.call(this) || this;
|
|
29
|
+
_this.chain = options.chain;
|
|
30
|
+
if (options.chain === types_1.IChain.Solana) {
|
|
31
|
+
_this.nativeStreamClient = new StreamClient_1.default(options.clusterUrl, options.cluster, options.commitment, options.programId);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
_this.nativeStreamClient = new StreamClient_2.default(options.clusterUrl, options.cluster, options.maxGas, options.programId);
|
|
35
|
+
}
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new stream/vesting contract.
|
|
40
|
+
*/
|
|
41
|
+
GenericStreamClient.prototype.create = function (streamData, chainSpecificParams) {
|
|
42
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
43
|
+
var params = chainSpecificParams;
|
|
44
|
+
return this.nativeStreamClient.create(streamData, params);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
var params = chainSpecificParams;
|
|
48
|
+
return this.nativeStreamClient.create(streamData, params);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Creates multiple stream/vesting contracts.
|
|
53
|
+
*/
|
|
54
|
+
GenericStreamClient.prototype.createMultiple = function (multipleStreamData, chainSpecificParams) {
|
|
55
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
56
|
+
var params = chainSpecificParams;
|
|
57
|
+
return this.nativeStreamClient.createMultiple(multipleStreamData, params);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
var params = chainSpecificParams;
|
|
61
|
+
return this.nativeStreamClient.createMultiple(multipleStreamData, params);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Attempts withdrawing from the specified stream.
|
|
66
|
+
*/
|
|
67
|
+
GenericStreamClient.prototype.withdraw = function (withdrawData, chainSpecificParams) {
|
|
68
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
69
|
+
var params = chainSpecificParams;
|
|
70
|
+
return this.nativeStreamClient.withdraw(withdrawData, params);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
var params = chainSpecificParams;
|
|
74
|
+
return this.nativeStreamClient.withdraw(withdrawData, params);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Attempts canceling the specified stream.
|
|
79
|
+
*/
|
|
80
|
+
GenericStreamClient.prototype.cancel = function (cancelData, chainSpecificParams) {
|
|
81
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
82
|
+
var params = chainSpecificParams;
|
|
83
|
+
return this.nativeStreamClient.cancel(cancelData, params);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
var params = chainSpecificParams;
|
|
87
|
+
return this.nativeStreamClient.cancel(cancelData, params);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
92
|
+
*/
|
|
93
|
+
GenericStreamClient.prototype.transfer = function (transferData, chainSpecificParams) {
|
|
94
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
95
|
+
var params = chainSpecificParams;
|
|
96
|
+
return this.nativeStreamClient.transfer(transferData, params);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
var params = chainSpecificParams;
|
|
100
|
+
return this.nativeStreamClient.transfer(transferData, params);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Tops up stream account with specified amount.
|
|
105
|
+
*/
|
|
106
|
+
GenericStreamClient.prototype.topup = function (topupData, chainSpecificParams) {
|
|
107
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
108
|
+
var params = chainSpecificParams;
|
|
109
|
+
return this.nativeStreamClient.topup(topupData, params);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
var params = chainSpecificParams;
|
|
113
|
+
return this.nativeStreamClient.topup(topupData, params);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Fetch stream data by its id (address).
|
|
118
|
+
*/
|
|
119
|
+
GenericStreamClient.prototype.getOne = function (getOneData) {
|
|
120
|
+
return this.nativeStreamClient.getOne(getOneData);
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Attempts updating the stream auto withdrawal params and amount per period
|
|
124
|
+
*/
|
|
125
|
+
GenericStreamClient.prototype.update = function (updateData, chainSpecificParams) {
|
|
126
|
+
if (this.nativeStreamClient instanceof StreamClient_1.default) {
|
|
127
|
+
var params = chainSpecificParams;
|
|
128
|
+
return this.nativeStreamClient.update(updateData, params);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
var params = chainSpecificParams;
|
|
132
|
+
return this.nativeStreamClient.update(updateData, params);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
return GenericStreamClient;
|
|
136
|
+
}(BaseStreamClient_1.BaseStreamClient));
|
|
137
|
+
exports.default = GenericStreamClient;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
export interface IRecipient {
|
|
3
|
+
recipient: string;
|
|
4
|
+
amount: BN;
|
|
5
|
+
name: string;
|
|
6
|
+
cliffAmount: BN;
|
|
7
|
+
amountPerPeriod: BN;
|
|
8
|
+
}
|
|
9
|
+
export interface IStreamConfig {
|
|
10
|
+
period: number;
|
|
11
|
+
start: number;
|
|
12
|
+
cliff: number;
|
|
13
|
+
cancelableBySender: boolean;
|
|
14
|
+
cancelableByRecipient: boolean;
|
|
15
|
+
transferableBySender: boolean;
|
|
16
|
+
transferableByRecipient: boolean;
|
|
17
|
+
canTopup: boolean;
|
|
18
|
+
automaticWithdrawal?: boolean;
|
|
19
|
+
withdrawalFrequency?: number;
|
|
20
|
+
tokenId: string;
|
|
21
|
+
canPause?: boolean;
|
|
22
|
+
canUpdateRate?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare type ICreateStreamData = IStreamConfig & IRecipient;
|
|
25
|
+
export declare type ICreateMultipleStreamData = IStreamConfig & {
|
|
26
|
+
recipients: IRecipient[];
|
|
27
|
+
};
|
|
28
|
+
export interface IWithdrawData {
|
|
29
|
+
id: string;
|
|
30
|
+
amount: BN;
|
|
31
|
+
}
|
|
32
|
+
export interface IUpdateData {
|
|
33
|
+
id: string;
|
|
34
|
+
enableAutomaticWithdrawal?: boolean;
|
|
35
|
+
withdrawFrequency?: BN;
|
|
36
|
+
amountPerPeriod?: BN;
|
|
37
|
+
}
|
|
38
|
+
export interface ICancelData {
|
|
39
|
+
id: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ITransferData {
|
|
42
|
+
id: string;
|
|
43
|
+
newRecipient: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ITopUpData {
|
|
46
|
+
id: string;
|
|
47
|
+
amount: BN;
|
|
48
|
+
}
|
|
49
|
+
export interface IGetOneData {
|
|
50
|
+
id: string;
|
|
51
|
+
}
|
|
52
|
+
export declare enum ICluster {
|
|
53
|
+
Mainnet = "mainnet",
|
|
54
|
+
Devnet = "devnet",
|
|
55
|
+
Testnet = "testnet",
|
|
56
|
+
Local = "local"
|
|
57
|
+
}
|
|
58
|
+
export declare enum StreamDirection {
|
|
59
|
+
Outgoing = "outgoing",
|
|
60
|
+
Incoming = "incoming",
|
|
61
|
+
All = "all"
|
|
62
|
+
}
|
|
63
|
+
export declare enum StreamType {
|
|
64
|
+
Stream = "stream",
|
|
65
|
+
Vesting = "vesting",
|
|
66
|
+
All = "all"
|
|
67
|
+
}
|
|
68
|
+
export declare enum IChain {
|
|
69
|
+
Solana = "Solana",
|
|
70
|
+
Aptos = "Aptos"
|
|
71
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IChain = exports.StreamType = exports.StreamDirection = exports.ICluster = void 0;
|
|
4
|
+
// Utility types
|
|
5
|
+
var ICluster;
|
|
6
|
+
(function (ICluster) {
|
|
7
|
+
ICluster["Mainnet"] = "mainnet";
|
|
8
|
+
ICluster["Devnet"] = "devnet";
|
|
9
|
+
ICluster["Testnet"] = "testnet";
|
|
10
|
+
ICluster["Local"] = "local";
|
|
11
|
+
})(ICluster = exports.ICluster || (exports.ICluster = {}));
|
|
12
|
+
var StreamDirection;
|
|
13
|
+
(function (StreamDirection) {
|
|
14
|
+
StreamDirection["Outgoing"] = "outgoing";
|
|
15
|
+
StreamDirection["Incoming"] = "incoming";
|
|
16
|
+
StreamDirection["All"] = "all";
|
|
17
|
+
})(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
|
|
18
|
+
var StreamType;
|
|
19
|
+
(function (StreamType) {
|
|
20
|
+
StreamType["Stream"] = "stream";
|
|
21
|
+
StreamType["Vesting"] = "vesting";
|
|
22
|
+
StreamType["All"] = "all";
|
|
23
|
+
})(StreamType = exports.StreamType || (exports.StreamType = {}));
|
|
24
|
+
var IChain;
|
|
25
|
+
(function (IChain) {
|
|
26
|
+
IChain["Solana"] = "Solana";
|
|
27
|
+
IChain["Aptos"] = "Aptos";
|
|
28
|
+
})(IChain = exports.IChain || (exports.IChain = {}));
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import BN from "bn.js";
|
|
3
|
-
import { Stream, DecodedStream } from "./types";
|
|
4
|
-
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
5
|
-
export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
|
|
6
2
|
/**
|
|
7
3
|
* Used for conversion of token amounts to their Big Number representation.
|
|
8
4
|
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getNumberFromBN = exports.getBN = void 0;
|
|
7
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
/**
|
|
9
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
10
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
11
|
+
* @param {number} value - Number of tokens you want to convert to its BN representation.
|
|
12
|
+
* @param {number} decimals - Number of decimals the token has.
|
|
13
|
+
*/
|
|
14
|
+
var getBN = function (value, decimals) {
|
|
15
|
+
return value > (Math.pow(2, 53) - 1) / Math.pow(10, decimals)
|
|
16
|
+
? new bn_js_1.default(value).mul(new bn_js_1.default(Math.pow(10, decimals)))
|
|
17
|
+
: new bn_js_1.default(value * Math.pow(10, decimals));
|
|
18
|
+
};
|
|
19
|
+
exports.getBN = getBN;
|
|
20
|
+
/**
|
|
21
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
22
|
+
* Get value in the highest units from BN representation of the same value in the smallest units.
|
|
23
|
+
* @param {BN} value - Big Number representation of value in the smallest units.
|
|
24
|
+
* @param {number} decimals - Number of decimals the token has.
|
|
25
|
+
*/
|
|
26
|
+
var getNumberFromBN = function (value, decimals) {
|
|
27
|
+
return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1))
|
|
28
|
+
? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber()
|
|
29
|
+
: value.toNumber() / Math.pow(10, decimals);
|
|
30
|
+
};
|
|
31
|
+
exports.getNumberFromBN = getNumberFromBN;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export
|
|
6
|
-
export { default as BN } from "bn.js";
|
|
1
|
+
export * as StreamflowSolana from "./solana";
|
|
2
|
+
export * as StreamflowAptos from "./aptos";
|
|
3
|
+
export * as Types from "./common/types";
|
|
4
|
+
export * from "./common/utils";
|
|
5
|
+
export { default as GenericStreamClient } from "./common/GenericStreamClient";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
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
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
@@ -17,13 +29,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
30
|
};
|
|
19
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
__exportStar(require("./instructions"), exports);
|
|
28
|
-
var bn_js_1 = require("bn.js");
|
|
29
|
-
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return __importDefault(bn_js_1).default; } });
|
|
32
|
+
exports.GenericStreamClient = exports.Types = exports.StreamflowAptos = exports.StreamflowSolana = void 0;
|
|
33
|
+
exports.StreamflowSolana = __importStar(require("./solana"));
|
|
34
|
+
exports.StreamflowAptos = __importStar(require("./aptos"));
|
|
35
|
+
exports.Types = __importStar(require("./common/types"));
|
|
36
|
+
__exportStar(require("./common/utils"), exports);
|
|
37
|
+
var GenericStreamClient_1 = require("./common/GenericStreamClient");
|
|
38
|
+
Object.defineProperty(exports, "GenericStreamClient", { enumerable: true, get: function () { return __importDefault(GenericStreamClient_1).default; } });
|