@streamflow/stream 3.0.18 → 3.0.19
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/Stream.d.ts +87 -0
- package/dist/Stream.js +503 -0
- package/dist/StreamClient.d.ts +146 -0
- package/dist/{solana/StreamClient.js → StreamClient.js} +397 -301
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +3 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +67 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +6 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop.js +215 -0
- package/dist/__tests__/test_dependencies/constants/index.d.ts +122 -0
- package/dist/__tests__/test_dependencies/constants/index.js +158 -0
- package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +27 -0
- package/dist/__tests__/test_dependencies/idl/airdrop.js +171 -0
- package/dist/{solana/constants.d.ts → constants.d.ts} +1 -1
- package/dist/{solana/constants.js → constants.js} +5 -5
- package/dist/{solana/timelockIDL.d.ts → idl/timelock.d.ts} +0 -0
- package/dist/{solana/timelockIDL.js → idl/timelock.js} +0 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +10 -19
- package/dist/{solana/instructions.d.ts → instructions.d.ts} +2 -8
- package/dist/{solana/instructions.js → instructions.js} +38 -55
- package/dist/layout.d.ts +22 -0
- package/dist/{solana/layout.js → layout.js} +3 -65
- package/dist/{solana/types.d.ts → types.d.ts} +34 -37
- package/dist/{solana/types.js → types.js} +20 -3
- package/dist/{common/utils.d.ts → utils.d.ts} +4 -0
- package/dist/utils.js +126 -0
- package/package.json +1 -1
- package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
- package/dist/__tests__/aptos/streamClient.spec.js +0 -160
- package/dist/aptos/StreamClient.d.ts +0 -49
- package/dist/aptos/StreamClient.js +0 -362
- package/dist/aptos/constants.d.ts +0 -2
- package/dist/aptos/constants.js +0 -12
- package/dist/aptos/index.d.ts +0 -2
- package/dist/aptos/index.js +0 -24
- package/dist/aptos/types.d.ts +0 -145
- package/dist/aptos/types.js +0 -65
- package/dist/common/BaseStreamClient.d.ts +0 -11
- package/dist/common/BaseStreamClient.js +0 -9
- package/dist/common/GenericStreamClient.d.ts +0 -60
- package/dist/common/GenericStreamClient.js +0 -137
- package/dist/common/types.d.ts +0 -71
- package/dist/common/types.js +0 -28
- package/dist/common/utils.js +0 -31
- package/dist/solana/StreamClient.d.ts +0 -71
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/solana/instructionTypes.d.ts +0 -86
- package/dist/solana/instructionTypes.js +0 -2
- package/dist/solana/layout.d.ts +0 -27
- package/dist/solana/utils.d.ts +0 -42
- package/dist/solana/utils.js +0 -271
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Wallet } from "@project-serum/anchor/src/provider";
|
|
3
|
+
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
|
|
4
|
+
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, TransactionInstruction } from "@solana/web3.js";
|
|
4
5
|
import BN from "bn.js";
|
|
5
|
-
import { IRecipient, StreamDirection, StreamType } from "../common/types";
|
|
6
6
|
export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
|
|
7
|
+
export declare enum StreamDirection {
|
|
8
|
+
Outgoing = "outgoing",
|
|
9
|
+
Incoming = "incoming",
|
|
10
|
+
All = "all"
|
|
11
|
+
}
|
|
12
|
+
export declare enum StreamType {
|
|
13
|
+
Stream = "stream",
|
|
14
|
+
Vesting = "vesting",
|
|
15
|
+
All = "all"
|
|
16
|
+
}
|
|
7
17
|
export interface Account {
|
|
8
18
|
pubkey: PublicKey;
|
|
9
19
|
account: AccountInfo<Buffer>;
|
|
10
20
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
partner?: string | null;
|
|
14
|
-
isNative?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface IInteractStreamSolanaExt {
|
|
17
|
-
invoker: SignerWalletAdapter | Keypair;
|
|
18
|
-
}
|
|
19
|
-
export interface ITopUpStreamSolanaExt {
|
|
20
|
-
invoker: SignerWalletAdapter | Keypair;
|
|
21
|
-
isNative?: boolean;
|
|
21
|
+
export declare enum LocalCluster {
|
|
22
|
+
Local = "local"
|
|
22
23
|
}
|
|
24
|
+
export declare type ClusterExtended = WalletAdapterNetwork | LocalCluster;
|
|
23
25
|
export interface CreateStreamData {
|
|
24
26
|
recipient: string;
|
|
25
27
|
mint: string;
|
|
@@ -61,16 +63,17 @@ export interface CreateMultiData {
|
|
|
61
63
|
}
|
|
62
64
|
export interface CreateStreamParams extends CreateStreamData {
|
|
63
65
|
connection: Connection;
|
|
64
|
-
sender:
|
|
66
|
+
sender: Wallet;
|
|
65
67
|
partner?: string;
|
|
68
|
+
cluster?: ClusterExtended;
|
|
66
69
|
}
|
|
67
70
|
export interface CreateParams extends CreateStreamData {
|
|
68
|
-
sender:
|
|
71
|
+
sender: Wallet | Keypair;
|
|
69
72
|
partner?: string | null;
|
|
70
73
|
isNative?: boolean;
|
|
71
74
|
}
|
|
72
75
|
export interface CreateMultiParams extends CreateMultiData {
|
|
73
|
-
sender:
|
|
76
|
+
sender: Wallet | Keypair;
|
|
74
77
|
partner?: string | null;
|
|
75
78
|
isNative?: boolean;
|
|
76
79
|
}
|
|
@@ -80,10 +83,11 @@ export interface WithdrawStreamData {
|
|
|
80
83
|
}
|
|
81
84
|
export interface WithdrawStreamParams extends WithdrawStreamData {
|
|
82
85
|
connection: Connection;
|
|
83
|
-
invoker:
|
|
86
|
+
invoker: Wallet;
|
|
87
|
+
cluster?: ClusterExtended;
|
|
84
88
|
}
|
|
85
89
|
export interface WithdrawParams extends WithdrawStreamData {
|
|
86
|
-
invoker:
|
|
90
|
+
invoker: Wallet | Keypair;
|
|
87
91
|
}
|
|
88
92
|
export interface TopupStreamData {
|
|
89
93
|
id: string;
|
|
@@ -91,10 +95,11 @@ export interface TopupStreamData {
|
|
|
91
95
|
}
|
|
92
96
|
export interface TopupStreamParams extends TopupStreamData {
|
|
93
97
|
connection: Connection;
|
|
94
|
-
invoker:
|
|
98
|
+
invoker: Wallet;
|
|
99
|
+
cluster?: ClusterExtended;
|
|
95
100
|
}
|
|
96
101
|
export interface TopupParams extends TopupStreamData {
|
|
97
|
-
invoker:
|
|
102
|
+
invoker: Wallet | Keypair;
|
|
98
103
|
isNative?: boolean;
|
|
99
104
|
}
|
|
100
105
|
export interface CancelStreamData {
|
|
@@ -102,10 +107,11 @@ export interface CancelStreamData {
|
|
|
102
107
|
}
|
|
103
108
|
export interface CancelStreamParams extends CancelStreamData {
|
|
104
109
|
connection: Connection;
|
|
105
|
-
invoker:
|
|
110
|
+
invoker: Wallet;
|
|
111
|
+
cluster?: ClusterExtended;
|
|
106
112
|
}
|
|
107
113
|
export interface CancelParams extends CancelStreamData {
|
|
108
|
-
invoker:
|
|
114
|
+
invoker: Wallet | Keypair;
|
|
109
115
|
}
|
|
110
116
|
export interface TransferStreamData {
|
|
111
117
|
id: string;
|
|
@@ -113,10 +119,11 @@ export interface TransferStreamData {
|
|
|
113
119
|
}
|
|
114
120
|
export interface TransferStreamParams extends TransferStreamData {
|
|
115
121
|
connection: Connection;
|
|
116
|
-
invoker:
|
|
122
|
+
invoker: Wallet;
|
|
123
|
+
cluster?: ClusterExtended;
|
|
117
124
|
}
|
|
118
125
|
export interface TransferParams extends TransferStreamData {
|
|
119
|
-
invoker:
|
|
126
|
+
invoker: Wallet | Keypair;
|
|
120
127
|
}
|
|
121
128
|
export interface GetStreamParams {
|
|
122
129
|
connection: Connection;
|
|
@@ -127,6 +134,7 @@ export interface GetStreamsParams {
|
|
|
127
134
|
wallet: PublicKey;
|
|
128
135
|
type?: StreamType;
|
|
129
136
|
direction?: StreamDirection;
|
|
137
|
+
cluster?: ClusterExtended;
|
|
130
138
|
}
|
|
131
139
|
export interface GetAllParams {
|
|
132
140
|
wallet: PublicKey;
|
|
@@ -268,7 +276,7 @@ export interface CreateResponse extends TxResponse {
|
|
|
268
276
|
metadata: Keypair;
|
|
269
277
|
}
|
|
270
278
|
export interface MetadataRecipientHashMap {
|
|
271
|
-
[metadataPubKey: string]:
|
|
279
|
+
[metadataPubKey: string]: MultiRecipient;
|
|
272
280
|
}
|
|
273
281
|
export interface CreateMultiError {
|
|
274
282
|
recipient: string;
|
|
@@ -308,14 +316,3 @@ export interface CreateMultipleStreamsValues {
|
|
|
308
316
|
referral: string;
|
|
309
317
|
recipients: Recipient[];
|
|
310
318
|
}
|
|
311
|
-
export interface BatchItem {
|
|
312
|
-
recipient: string;
|
|
313
|
-
tx: Transaction;
|
|
314
|
-
}
|
|
315
|
-
export interface BatchItemSuccess extends BatchItem {
|
|
316
|
-
signature: string;
|
|
317
|
-
}
|
|
318
|
-
export interface BatchItemError extends BatchItem {
|
|
319
|
-
error: string;
|
|
320
|
-
}
|
|
321
|
-
export declare type BatchItemResult = BatchItemSuccess | BatchItemError;
|
|
@@ -3,11 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
|
|
6
|
+
exports.TransferCancelOptions = exports.Contract = exports.LocalCluster = exports.StreamType = exports.StreamDirection = exports.Cluster = void 0;
|
|
7
7
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
-
var utils_1 = require("
|
|
8
|
+
var utils_1 = require("./utils");
|
|
9
9
|
var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
|
|
10
10
|
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
|
|
11
|
+
var StreamDirection;
|
|
12
|
+
(function (StreamDirection) {
|
|
13
|
+
StreamDirection["Outgoing"] = "outgoing";
|
|
14
|
+
StreamDirection["Incoming"] = "incoming";
|
|
15
|
+
StreamDirection["All"] = "all";
|
|
16
|
+
})(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
|
|
17
|
+
var StreamType;
|
|
18
|
+
(function (StreamType) {
|
|
19
|
+
StreamType["Stream"] = "stream";
|
|
20
|
+
StreamType["Vesting"] = "vesting";
|
|
21
|
+
StreamType["All"] = "all";
|
|
22
|
+
})(StreamType = exports.StreamType || (exports.StreamType = {}));
|
|
23
|
+
var LocalCluster;
|
|
24
|
+
(function (LocalCluster) {
|
|
25
|
+
LocalCluster["Local"] = "local";
|
|
26
|
+
})(LocalCluster = exports.LocalCluster || (exports.LocalCluster = {}));
|
|
11
27
|
var Contract = /** @class */ (function () {
|
|
12
28
|
function Contract(stream) {
|
|
13
29
|
var _a;
|
|
@@ -25,7 +41,8 @@ var Contract = /** @class */ (function () {
|
|
|
25
41
|
this.mint = stream.mint.toBase58();
|
|
26
42
|
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
27
43
|
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
28
|
-
this.streamflowTreasuryTokens =
|
|
44
|
+
this.streamflowTreasuryTokens =
|
|
45
|
+
stream.streamflowTreasuryTokens.toBase58();
|
|
29
46
|
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
30
47
|
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
31
48
|
this.streamflowFeePercent = stream.streamflowFeePercent.toNumber();
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
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;
|
|
2
6
|
/**
|
|
3
7
|
* Used for conversion of token amounts to their Big Number representation.
|
|
4
8
|
* Get Big Number representation in the smallest units from the same value in the highest units.
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
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 = exports.formatDecodedStream = exports.decodeStream = void 0;
|
|
7
|
+
var web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
9
|
+
var layout_1 = require("./layout");
|
|
10
|
+
var decoder = new TextDecoder("utf-8");
|
|
11
|
+
var LE = "le"; //little endian
|
|
12
|
+
var decodeStream = function (buf) {
|
|
13
|
+
var raw = layout_1.streamLayout.decode(buf);
|
|
14
|
+
return {
|
|
15
|
+
magic: new bn_js_1.default(raw.magic, LE),
|
|
16
|
+
version: new bn_js_1.default(raw.version, LE),
|
|
17
|
+
createdAt: new bn_js_1.default(raw.created_at, LE),
|
|
18
|
+
withdrawnAmount: new bn_js_1.default(raw.withdrawn_amount, LE),
|
|
19
|
+
canceledAt: new bn_js_1.default(raw.canceled_at, LE),
|
|
20
|
+
end: new bn_js_1.default(raw.end_time, LE),
|
|
21
|
+
lastWithdrawnAt: new bn_js_1.default(raw.last_withdrawn_at, LE),
|
|
22
|
+
sender: new web3_js_1.PublicKey(raw.sender),
|
|
23
|
+
senderTokens: new web3_js_1.PublicKey(raw.sender_tokens),
|
|
24
|
+
recipient: new web3_js_1.PublicKey(raw.recipient),
|
|
25
|
+
recipientTokens: new web3_js_1.PublicKey(raw.recipient_tokens),
|
|
26
|
+
mint: new web3_js_1.PublicKey(raw.mint),
|
|
27
|
+
escrowTokens: new web3_js_1.PublicKey(raw.escrow_tokens),
|
|
28
|
+
streamflowTreasury: new web3_js_1.PublicKey(raw.streamflow_treasury),
|
|
29
|
+
streamflowTreasuryTokens: new web3_js_1.PublicKey(raw.streamflow_treasury_tokens),
|
|
30
|
+
streamflowFeeTotal: new bn_js_1.default(raw.streamflow_fee_total, LE),
|
|
31
|
+
streamflowFeeWithdrawn: new bn_js_1.default(raw.streamflow_fee_withdrawn, LE),
|
|
32
|
+
streamflowFeePercent: new bn_js_1.default(raw.streamflow_fee_percent, LE),
|
|
33
|
+
partnerFeeTotal: new bn_js_1.default(raw.partner_fee_total, LE),
|
|
34
|
+
partnerFeeWithdrawn: new bn_js_1.default(raw.partner_fee_withdrawn, LE),
|
|
35
|
+
partnerFeePercent: new bn_js_1.default(raw.partner_fee_percent, LE),
|
|
36
|
+
partner: new web3_js_1.PublicKey(raw.partner),
|
|
37
|
+
partnerTokens: new web3_js_1.PublicKey(raw.partner_tokens),
|
|
38
|
+
start: new bn_js_1.default(raw.start_time, LE),
|
|
39
|
+
depositedAmount: new bn_js_1.default(raw.net_amount_deposited, LE),
|
|
40
|
+
period: new bn_js_1.default(raw.period, LE),
|
|
41
|
+
amountPerPeriod: new bn_js_1.default(raw.amount_per_period, LE),
|
|
42
|
+
cliff: new bn_js_1.default(raw.cliff, LE),
|
|
43
|
+
cliffAmount: new bn_js_1.default(raw.cliff_amount, LE),
|
|
44
|
+
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
45
|
+
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
46
|
+
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
47
|
+
transferableBySender: Boolean(raw.transferable_by_sender),
|
|
48
|
+
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
49
|
+
canTopup: Boolean(raw.can_topup),
|
|
50
|
+
name: decoder.decode(raw.stream_name),
|
|
51
|
+
withdrawFrequency: new bn_js_1.default(raw.withdraw_frequency, LE),
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.decodeStream = decodeStream;
|
|
55
|
+
// DeprecationWarning: This object will be deprecated starting from the version 4.0.0. Use
|
|
56
|
+
// types/Contract instead
|
|
57
|
+
var formatDecodedStream = function (stream) {
|
|
58
|
+
var _a;
|
|
59
|
+
var resp = {
|
|
60
|
+
magic: stream.magic.toNumber(),
|
|
61
|
+
version: stream.version.toNumber(),
|
|
62
|
+
createdAt: stream.createdAt.toNumber(),
|
|
63
|
+
withdrawnAmount: stream.withdrawnAmount,
|
|
64
|
+
canceledAt: stream.canceledAt.toNumber(),
|
|
65
|
+
end: stream.end.toNumber(),
|
|
66
|
+
lastWithdrawnAt: stream.lastWithdrawnAt.toNumber(),
|
|
67
|
+
sender: stream.sender.toBase58(),
|
|
68
|
+
senderTokens: stream.senderTokens.toBase58(),
|
|
69
|
+
recipient: stream.recipient.toBase58(),
|
|
70
|
+
recipientTokens: stream.recipientTokens.toBase58(),
|
|
71
|
+
mint: stream.mint.toBase58(),
|
|
72
|
+
escrowTokens: stream.escrowTokens.toBase58(),
|
|
73
|
+
streamflowTreasury: stream.streamflowTreasury.toBase58(),
|
|
74
|
+
streamflowTreasuryTokens: stream.streamflowTreasuryTokens.toBase58(),
|
|
75
|
+
streamflowFeeTotal: stream.streamflowFeeTotal,
|
|
76
|
+
streamflowFeeWithdrawn: stream.streamflowFeeWithdrawn,
|
|
77
|
+
streamflowFeePercent: stream.streamflowFeePercent.toNumber(),
|
|
78
|
+
partnerFeeTotal: stream.partnerFeeTotal,
|
|
79
|
+
partnerFeeWithdrawn: stream.partnerFeeWithdrawn,
|
|
80
|
+
partnerFeePercent: stream.partnerFeePercent.toNumber(),
|
|
81
|
+
partner: stream.partner.toBase58(),
|
|
82
|
+
partnerTokens: (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58(),
|
|
83
|
+
start: stream.start.toNumber(),
|
|
84
|
+
depositedAmount: stream.depositedAmount,
|
|
85
|
+
period: stream.period.toNumber(),
|
|
86
|
+
amountPerPeriod: stream.amountPerPeriod,
|
|
87
|
+
cliff: stream.cliff.toNumber(),
|
|
88
|
+
cliffAmount: stream.cliffAmount,
|
|
89
|
+
cancelableBySender: stream.cancelableBySender,
|
|
90
|
+
cancelableByRecipient: stream.cancelableByRecipient,
|
|
91
|
+
automaticWithdrawal: stream.automaticWithdrawal,
|
|
92
|
+
transferableBySender: stream.transferableBySender,
|
|
93
|
+
transferableByRecipient: stream.transferableByRecipient,
|
|
94
|
+
canTopup: stream.canTopup,
|
|
95
|
+
name: stream.name,
|
|
96
|
+
withdrawalFrequency: stream.withdrawFrequency.toNumber(),
|
|
97
|
+
unlocked: function () { return 0; },
|
|
98
|
+
withdrawn: function () { return new bn_js_1.default(0); } //phantom method to preserve partial support of this object
|
|
99
|
+
};
|
|
100
|
+
return resp;
|
|
101
|
+
};
|
|
102
|
+
exports.formatDecodedStream = formatDecodedStream;
|
|
103
|
+
/**
|
|
104
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
105
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
106
|
+
* @param {number} value - Number of tokens you want to convert to its BN representation.
|
|
107
|
+
* @param {number} decimals - Number of decimals the token has.
|
|
108
|
+
*/
|
|
109
|
+
var getBN = function (value, decimals) {
|
|
110
|
+
return value > (Math.pow(2, 53) - 1) / Math.pow(10, decimals)
|
|
111
|
+
? new bn_js_1.default(value).mul(new bn_js_1.default(Math.pow(10, decimals)))
|
|
112
|
+
: new bn_js_1.default(value * Math.pow(10, decimals));
|
|
113
|
+
};
|
|
114
|
+
exports.getBN = getBN;
|
|
115
|
+
/**
|
|
116
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
117
|
+
* Get value in the highest units from BN representation of the same value in the smallest units.
|
|
118
|
+
* @param {BN} value - Big Number representation of value in the smallest units.
|
|
119
|
+
* @param {number} decimals - Number of decimals the token has.
|
|
120
|
+
*/
|
|
121
|
+
var getNumberFromBN = function (value, decimals) {
|
|
122
|
+
return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1))
|
|
123
|
+
? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber()
|
|
124
|
+
: value.toNumber() / Math.pow(10, decimals);
|
|
125
|
+
};
|
|
126
|
+
exports.getNumberFromBN = getNumberFromBN;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var bn_js_1 = require("bn.js");
|
|
54
|
-
var StreamClient_1 = __importDefault(require("../../aptos/StreamClient"));
|
|
55
|
-
var types_1 = require("../../common/types");
|
|
56
|
-
describe("AptosStreamClient", function () {
|
|
57
|
-
describe("coreClient", function () {
|
|
58
|
-
it("should succesfully create AptosStreamInstance", function () {
|
|
59
|
-
var instance = new StreamClient_1.default(types_1.ICluster.Devnet);
|
|
60
|
-
expect(instance).toBeInstanceOf(StreamClient_1.default);
|
|
61
|
-
});
|
|
62
|
-
it("should correctly set passed params", function () {
|
|
63
|
-
var pid = "PID";
|
|
64
|
-
var gas = "30";
|
|
65
|
-
var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
|
|
66
|
-
expect(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
|
|
67
|
-
expect(instance.getProgramId()).toBe(pid);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("create", function () {
|
|
71
|
-
var pid = "PID";
|
|
72
|
-
var gas = "30";
|
|
73
|
-
var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
|
|
74
|
-
beforeEach(function () {
|
|
75
|
-
instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
|
|
76
|
-
});
|
|
77
|
-
test("should create a stream with passed parameters", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var mockSigner, mockWallet, mockRecipient, mockData, mockReturn, result, callParam, args;
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
switch (_a.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
mockSigner = jest.fn();
|
|
83
|
-
mockWallet = {
|
|
84
|
-
signAndSubmitTransaction: mockSigner,
|
|
85
|
-
};
|
|
86
|
-
mockRecipient = {
|
|
87
|
-
recipient: "0xtest",
|
|
88
|
-
amount: new bn_js_1.BN(1000),
|
|
89
|
-
name: "test name",
|
|
90
|
-
cliffAmount: new bn_js_1.BN(1),
|
|
91
|
-
amountPerPeriod: new bn_js_1.BN(1),
|
|
92
|
-
};
|
|
93
|
-
mockData = {
|
|
94
|
-
period: 100,
|
|
95
|
-
start: 10,
|
|
96
|
-
cliff: 12,
|
|
97
|
-
cancelableBySender: true,
|
|
98
|
-
cancelableByRecipient: false,
|
|
99
|
-
transferableBySender: false,
|
|
100
|
-
transferableByRecipient: true,
|
|
101
|
-
canTopup: true,
|
|
102
|
-
automaticWithdrawal: false,
|
|
103
|
-
withdrawalFrequency: 10,
|
|
104
|
-
tokenId: "0xtest::token::Token",
|
|
105
|
-
canPause: false,
|
|
106
|
-
canUpdateRate: false,
|
|
107
|
-
};
|
|
108
|
-
mockReturn = "hash";
|
|
109
|
-
mockSigner.mockResolvedValue({ hash: mockReturn });
|
|
110
|
-
return [4 /*yield*/, instance.create(__assign(__assign({}, mockData), mockRecipient), { senderWallet: mockWallet })];
|
|
111
|
-
case 1:
|
|
112
|
-
result = _a.sent();
|
|
113
|
-
// Assert
|
|
114
|
-
expect(mockSigner).toHaveBeenCalledTimes(1);
|
|
115
|
-
callParam = mockSigner.mock.calls[0][0];
|
|
116
|
-
args = callParam.arguments;
|
|
117
|
-
delete callParam.arguments;
|
|
118
|
-
args.shift();
|
|
119
|
-
expect(args).toEqual([
|
|
120
|
-
mockRecipient.amount.toString(),
|
|
121
|
-
100,
|
|
122
|
-
mockRecipient.amountPerPeriod.toString(),
|
|
123
|
-
10,
|
|
124
|
-
mockRecipient.cliffAmount.toString(),
|
|
125
|
-
true,
|
|
126
|
-
false,
|
|
127
|
-
false,
|
|
128
|
-
true,
|
|
129
|
-
true,
|
|
130
|
-
false,
|
|
131
|
-
false,
|
|
132
|
-
false,
|
|
133
|
-
10,
|
|
134
|
-
"test name",
|
|
135
|
-
"0xtest",
|
|
136
|
-
]);
|
|
137
|
-
expect(callParam).toEqual({
|
|
138
|
-
function: "PID::protocol::create",
|
|
139
|
-
type: "create",
|
|
140
|
-
type_arguments: ["0xtest::token::Token"],
|
|
141
|
-
});
|
|
142
|
-
expect(result).toEqual({ txId: mockReturn });
|
|
143
|
-
return [2 /*return*/];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}); });
|
|
147
|
-
});
|
|
148
|
-
// describe("createMultiple", () => {
|
|
149
|
-
// });
|
|
150
|
-
// describe("withdraw", () => {
|
|
151
|
-
// });
|
|
152
|
-
// describe("cancel", () => {
|
|
153
|
-
// });
|
|
154
|
-
// describe("transfer", () => {
|
|
155
|
-
// });
|
|
156
|
-
// describe("topup", () => {
|
|
157
|
-
// });
|
|
158
|
-
// describe("getOne", () => {
|
|
159
|
-
// });
|
|
160
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
|
-
import { Contract, ICreateStreamAptosExt, IMultiTransactionResult, ITransactionAptosExt, ITransactionResult } from "./types";
|
|
4
|
-
export default class AptosStreamClient extends BaseStreamClient {
|
|
5
|
-
private programId;
|
|
6
|
-
private maxGas;
|
|
7
|
-
private client;
|
|
8
|
-
constructor(clusterUrl: string, cluster?: ICluster, maxGas?: string, programId?: string);
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new stream/vesting contract.
|
|
11
|
-
*/
|
|
12
|
-
create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<ITransactionResult>;
|
|
13
|
-
/**
|
|
14
|
-
* Creates multiple stream/vesting contracts.
|
|
15
|
-
*/
|
|
16
|
-
createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<IMultiTransactionResult>;
|
|
17
|
-
/**
|
|
18
|
-
* Attempts withdrawing from the specified stream.
|
|
19
|
-
*/
|
|
20
|
-
withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
21
|
-
/**
|
|
22
|
-
* Attempts canceling the specified stream.
|
|
23
|
-
*/
|
|
24
|
-
cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
25
|
-
/**
|
|
26
|
-
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
27
|
-
*/
|
|
28
|
-
transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
29
|
-
/**
|
|
30
|
-
* Tops up stream account with specified amount.
|
|
31
|
-
*/
|
|
32
|
-
topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Fetch stream data by its id (address).
|
|
35
|
-
*/
|
|
36
|
-
getOne({ id }: IGetOneData): Promise<Contract>;
|
|
37
|
-
/**
|
|
38
|
-
* Attempts updating the stream auto withdrawal params and amount per period
|
|
39
|
-
*/
|
|
40
|
-
update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
41
|
-
/**
|
|
42
|
-
* Returns StreamClient protocol program ID.
|
|
43
|
-
*/
|
|
44
|
-
getProgramId(): string;
|
|
45
|
-
getMaxGas(): {
|
|
46
|
-
max_gas_amount: string;
|
|
47
|
-
};
|
|
48
|
-
private generateMultiPayloads;
|
|
49
|
-
}
|