@streamflow/stream 4.0.3 → 4.1.0-beta.1
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.js +1 -1
- package/dist/aptos/StreamClient.d.ts +4 -3
- package/dist/aptos/StreamClient.js +13 -6
- package/dist/aptos/types.d.ts +2 -18
- package/dist/aptos/types.js +5 -6
- package/dist/common/BaseStreamClient.d.ts +11 -9
- package/dist/common/GenericStreamClient.d.ts +25 -12
- package/dist/common/GenericStreamClient.js +18 -5
- package/dist/common/types.d.ts +30 -1
- package/dist/common/types.js +2 -0
- package/dist/common/utils.js +6 -3
- package/dist/evm/StreamClient.d.ts +28 -0
- package/dist/evm/StreamClient.js +419 -0
- package/dist/evm/abi.d.ts +111 -0
- package/dist/evm/abi.js +1257 -0
- package/dist/evm/constants.d.ts +3 -0
- package/dist/evm/constants.js +17 -0
- package/dist/evm/ercAbi.d.ts +39 -0
- package/dist/evm/ercAbi.js +224 -0
- package/dist/evm/index.d.ts +2 -0
- package/dist/evm/index.js +24 -0
- package/dist/evm/types.d.ts +126 -0
- package/dist/evm/types.js +63 -0
- package/dist/solana/StreamClient.d.ts +11 -11
- package/dist/solana/StreamClient.js +90 -89
- package/dist/solana/types.d.ts +2 -2
- package/dist/solana/types.js +5 -6
- package/dist/solana/utils.js +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BSC_PROGRAM_IDS = exports.ETHERIUM_PROGRAM_IDS = void 0;
|
|
5
|
+
var types_1 = require("../common/types");
|
|
6
|
+
exports.ETHERIUM_PROGRAM_IDS = (_a = {},
|
|
7
|
+
_a[types_1.ICluster.Mainnet] = "0x35fC2D13D97c13d6697Dc273fEDF93eBC92B7743",
|
|
8
|
+
_a[types_1.ICluster.Devnet] = "0x35fC2D13D97c13d6697Dc273fEDF93eBC92B7743",
|
|
9
|
+
_a[types_1.ICluster.Testnet] = "0x35fC2D13D97c13d6697Dc273fEDF93eBC92B7743",
|
|
10
|
+
_a[types_1.ICluster.Local] = "0x35fC2D13D97c13d6697Dc273fEDF93eBC92B7743",
|
|
11
|
+
_a);
|
|
12
|
+
exports.BSC_PROGRAM_IDS = (_b = {},
|
|
13
|
+
_b[types_1.ICluster.Mainnet] = "0xb09702834cba4c4BDb03CC7F0Fef48490a44BB50",
|
|
14
|
+
_b[types_1.ICluster.Devnet] = "0xb09702834cba4c4BDb03CC7F0Fef48490a44BB50",
|
|
15
|
+
_b[types_1.ICluster.Testnet] = "0xb09702834cba4c4BDb03CC7F0Fef48490a44BB50",
|
|
16
|
+
_b[types_1.ICluster.Local] = "0xb09702834cba4c4BDb03CC7F0Fef48490a44BB50",
|
|
17
|
+
_b);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
constant: boolean;
|
|
3
|
+
inputs: {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
name: string;
|
|
8
|
+
outputs: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
payable: boolean;
|
|
13
|
+
stateMutability: string;
|
|
14
|
+
type: string;
|
|
15
|
+
anonymous?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
payable: boolean;
|
|
18
|
+
stateMutability: string;
|
|
19
|
+
type: string;
|
|
20
|
+
constant?: undefined;
|
|
21
|
+
inputs?: undefined;
|
|
22
|
+
name?: undefined;
|
|
23
|
+
outputs?: undefined;
|
|
24
|
+
anonymous?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
anonymous: boolean;
|
|
27
|
+
inputs: {
|
|
28
|
+
indexed: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
constant?: undefined;
|
|
35
|
+
outputs?: undefined;
|
|
36
|
+
payable?: undefined;
|
|
37
|
+
stateMutability?: undefined;
|
|
38
|
+
})[];
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = [
|
|
4
|
+
{
|
|
5
|
+
constant: true,
|
|
6
|
+
inputs: [],
|
|
7
|
+
name: "name",
|
|
8
|
+
outputs: [
|
|
9
|
+
{
|
|
10
|
+
name: "",
|
|
11
|
+
type: "string",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
payable: false,
|
|
15
|
+
stateMutability: "view",
|
|
16
|
+
type: "function",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
constant: false,
|
|
20
|
+
inputs: [
|
|
21
|
+
{
|
|
22
|
+
name: "_spender",
|
|
23
|
+
type: "address",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "_value",
|
|
27
|
+
type: "uint256",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
name: "approve",
|
|
31
|
+
outputs: [
|
|
32
|
+
{
|
|
33
|
+
name: "",
|
|
34
|
+
type: "bool",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
payable: false,
|
|
38
|
+
stateMutability: "nonpayable",
|
|
39
|
+
type: "function",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
constant: true,
|
|
43
|
+
inputs: [],
|
|
44
|
+
name: "totalSupply",
|
|
45
|
+
outputs: [
|
|
46
|
+
{
|
|
47
|
+
name: "",
|
|
48
|
+
type: "uint256",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
payable: false,
|
|
52
|
+
stateMutability: "view",
|
|
53
|
+
type: "function",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
constant: false,
|
|
57
|
+
inputs: [
|
|
58
|
+
{
|
|
59
|
+
name: "_from",
|
|
60
|
+
type: "address",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "_to",
|
|
64
|
+
type: "address",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "_value",
|
|
68
|
+
type: "uint256",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
name: "transferFrom",
|
|
72
|
+
outputs: [
|
|
73
|
+
{
|
|
74
|
+
name: "",
|
|
75
|
+
type: "bool",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
payable: false,
|
|
79
|
+
stateMutability: "nonpayable",
|
|
80
|
+
type: "function",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
constant: true,
|
|
84
|
+
inputs: [],
|
|
85
|
+
name: "decimals",
|
|
86
|
+
outputs: [
|
|
87
|
+
{
|
|
88
|
+
name: "",
|
|
89
|
+
type: "uint8",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
payable: false,
|
|
93
|
+
stateMutability: "view",
|
|
94
|
+
type: "function",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
constant: true,
|
|
98
|
+
inputs: [
|
|
99
|
+
{
|
|
100
|
+
name: "_owner",
|
|
101
|
+
type: "address",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
name: "balanceOf",
|
|
105
|
+
outputs: [
|
|
106
|
+
{
|
|
107
|
+
name: "balance",
|
|
108
|
+
type: "uint256",
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
payable: false,
|
|
112
|
+
stateMutability: "view",
|
|
113
|
+
type: "function",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
constant: true,
|
|
117
|
+
inputs: [],
|
|
118
|
+
name: "symbol",
|
|
119
|
+
outputs: [
|
|
120
|
+
{
|
|
121
|
+
name: "",
|
|
122
|
+
type: "string",
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
payable: false,
|
|
126
|
+
stateMutability: "view",
|
|
127
|
+
type: "function",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
constant: false,
|
|
131
|
+
inputs: [
|
|
132
|
+
{
|
|
133
|
+
name: "_to",
|
|
134
|
+
type: "address",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "_value",
|
|
138
|
+
type: "uint256",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
name: "transfer",
|
|
142
|
+
outputs: [
|
|
143
|
+
{
|
|
144
|
+
name: "",
|
|
145
|
+
type: "bool",
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
payable: false,
|
|
149
|
+
stateMutability: "nonpayable",
|
|
150
|
+
type: "function",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
constant: true,
|
|
154
|
+
inputs: [
|
|
155
|
+
{
|
|
156
|
+
name: "_owner",
|
|
157
|
+
type: "address",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "_spender",
|
|
161
|
+
type: "address",
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
name: "allowance",
|
|
165
|
+
outputs: [
|
|
166
|
+
{
|
|
167
|
+
name: "",
|
|
168
|
+
type: "uint256",
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
payable: false,
|
|
172
|
+
stateMutability: "view",
|
|
173
|
+
type: "function",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
payable: true,
|
|
177
|
+
stateMutability: "payable",
|
|
178
|
+
type: "fallback",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
anonymous: false,
|
|
182
|
+
inputs: [
|
|
183
|
+
{
|
|
184
|
+
indexed: true,
|
|
185
|
+
name: "owner",
|
|
186
|
+
type: "address",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
indexed: true,
|
|
190
|
+
name: "spender",
|
|
191
|
+
type: "address",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
indexed: false,
|
|
195
|
+
name: "value",
|
|
196
|
+
type: "uint256",
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
name: "Approval",
|
|
200
|
+
type: "event",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
anonymous: false,
|
|
204
|
+
inputs: [
|
|
205
|
+
{
|
|
206
|
+
indexed: true,
|
|
207
|
+
name: "from",
|
|
208
|
+
type: "address",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
indexed: true,
|
|
212
|
+
name: "to",
|
|
213
|
+
type: "address",
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
indexed: false,
|
|
217
|
+
name: "value",
|
|
218
|
+
type: "uint256",
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
name: "Transfer",
|
|
222
|
+
type: "event",
|
|
223
|
+
},
|
|
224
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.EvmStreamClient = exports.default = void 0;
|
|
21
|
+
var StreamClient_1 = require("./StreamClient");
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
23
|
+
Object.defineProperty(exports, "EvmStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
import { BigNumber } from "ethers";
|
|
3
|
+
export interface StreamAbiResult {
|
|
4
|
+
amount: BigNumber;
|
|
5
|
+
amount_per_period: BigNumber;
|
|
6
|
+
canceled_at: BigNumber;
|
|
7
|
+
cliff_amount: BigNumber;
|
|
8
|
+
closed: boolean;
|
|
9
|
+
created: BigNumber;
|
|
10
|
+
current_pause_start: BigNumber;
|
|
11
|
+
end: BigNumber;
|
|
12
|
+
fees: {
|
|
13
|
+
streamflow_fee_percentage: BigNumber;
|
|
14
|
+
streamflow_fee: BigNumber;
|
|
15
|
+
streamflow_fee_withdrawn: BigNumber;
|
|
16
|
+
partner_fee_percentage: BigNumber;
|
|
17
|
+
partner_fee: BigNumber;
|
|
18
|
+
partner_fee_withdrawn: BigNumber;
|
|
19
|
+
tx_fee: BigNumber;
|
|
20
|
+
};
|
|
21
|
+
funds_unlocked_at_last_rate_change: BigNumber;
|
|
22
|
+
last_rate_change_time: BigNumber;
|
|
23
|
+
last_withdrawn_at: BigNumber;
|
|
24
|
+
meta: {
|
|
25
|
+
automatic_withdrawal: boolean;
|
|
26
|
+
can_topup: boolean;
|
|
27
|
+
can_update_rate: boolean;
|
|
28
|
+
cancelable_by_recipient: boolean;
|
|
29
|
+
cancelable_by_sender: boolean;
|
|
30
|
+
contract_name: string;
|
|
31
|
+
pausable: boolean;
|
|
32
|
+
transferable_by_recipient: boolean;
|
|
33
|
+
transferable_by_sender: boolean;
|
|
34
|
+
withdrawal_frequency: BigNumber;
|
|
35
|
+
};
|
|
36
|
+
pause_cumulative: BigNumber;
|
|
37
|
+
period: BigNumber;
|
|
38
|
+
recipient: string;
|
|
39
|
+
sender: string;
|
|
40
|
+
partner: string;
|
|
41
|
+
start: BigNumber;
|
|
42
|
+
token: string;
|
|
43
|
+
withdrawn: BigNumber;
|
|
44
|
+
}
|
|
45
|
+
export interface Stream {
|
|
46
|
+
magic: number;
|
|
47
|
+
version: number;
|
|
48
|
+
createdAt: number;
|
|
49
|
+
withdrawnAmount: BN;
|
|
50
|
+
canceledAt: number;
|
|
51
|
+
end: number;
|
|
52
|
+
lastWithdrawnAt: number;
|
|
53
|
+
sender: string;
|
|
54
|
+
senderTokens: string;
|
|
55
|
+
recipient: string;
|
|
56
|
+
recipientTokens: string;
|
|
57
|
+
mint: string;
|
|
58
|
+
escrowTokens: string;
|
|
59
|
+
streamflowTreasury: string;
|
|
60
|
+
streamflowTreasuryTokens: string;
|
|
61
|
+
streamflowFeeTotal: BN;
|
|
62
|
+
streamflowFeeWithdrawn: BN;
|
|
63
|
+
streamflowFeePercent: number;
|
|
64
|
+
partnerFeeTotal: BN;
|
|
65
|
+
partnerFeeWithdrawn: BN;
|
|
66
|
+
partnerFeePercent: number;
|
|
67
|
+
partner: string;
|
|
68
|
+
partnerTokens: string;
|
|
69
|
+
start: number;
|
|
70
|
+
depositedAmount: BN;
|
|
71
|
+
period: number;
|
|
72
|
+
amountPerPeriod: BN;
|
|
73
|
+
cliff: number;
|
|
74
|
+
cliffAmount: BN;
|
|
75
|
+
cancelableBySender: boolean;
|
|
76
|
+
cancelableByRecipient: boolean;
|
|
77
|
+
automaticWithdrawal: boolean;
|
|
78
|
+
transferableBySender: boolean;
|
|
79
|
+
transferableByRecipient: boolean;
|
|
80
|
+
canTopup: boolean;
|
|
81
|
+
name: string;
|
|
82
|
+
withdrawalFrequency: number;
|
|
83
|
+
unlocked(currentTimestamp: number, decimals: number): BN;
|
|
84
|
+
}
|
|
85
|
+
export declare class EvmContract implements Stream {
|
|
86
|
+
magic: number;
|
|
87
|
+
version: number;
|
|
88
|
+
createdAt: number;
|
|
89
|
+
withdrawnAmount: BN;
|
|
90
|
+
canceledAt: number;
|
|
91
|
+
end: number;
|
|
92
|
+
lastWithdrawnAt: number;
|
|
93
|
+
sender: string;
|
|
94
|
+
senderTokens: string;
|
|
95
|
+
recipient: string;
|
|
96
|
+
recipientTokens: string;
|
|
97
|
+
mint: string;
|
|
98
|
+
escrowTokens: string;
|
|
99
|
+
streamflowTreasury: string;
|
|
100
|
+
streamflowTreasuryTokens: string;
|
|
101
|
+
streamflowFeeTotal: BN;
|
|
102
|
+
streamflowFeeWithdrawn: BN;
|
|
103
|
+
streamflowFeePercent: number;
|
|
104
|
+
partnerFeeTotal: BN;
|
|
105
|
+
partnerFeeWithdrawn: BN;
|
|
106
|
+
partnerFeePercent: number;
|
|
107
|
+
partner: string;
|
|
108
|
+
partnerTokens: string;
|
|
109
|
+
start: number;
|
|
110
|
+
depositedAmount: BN;
|
|
111
|
+
period: number;
|
|
112
|
+
amountPerPeriod: BN;
|
|
113
|
+
cliff: number;
|
|
114
|
+
cliffAmount: BN;
|
|
115
|
+
cancelableBySender: boolean;
|
|
116
|
+
cancelableByRecipient: boolean;
|
|
117
|
+
automaticWithdrawal: boolean;
|
|
118
|
+
transferableBySender: boolean;
|
|
119
|
+
transferableByRecipient: boolean;
|
|
120
|
+
canTopup: boolean;
|
|
121
|
+
name: string;
|
|
122
|
+
withdrawalFrequency: number;
|
|
123
|
+
constructor(stream: StreamAbiResult);
|
|
124
|
+
unlocked(currentTimestamp: number): BN;
|
|
125
|
+
remaining(decimals: number): number;
|
|
126
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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.EvmContract = void 0;
|
|
7
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
var utils_1 = require("../common/utils");
|
|
9
|
+
var EvmContract = /** @class */ (function () {
|
|
10
|
+
function EvmContract(stream) {
|
|
11
|
+
this.magic = 0;
|
|
12
|
+
this.version = 0;
|
|
13
|
+
this.createdAt = stream.created.toNumber();
|
|
14
|
+
this.withdrawnAmount = new bn_js_1.default(stream.withdrawn.toString());
|
|
15
|
+
this.canceledAt = stream.canceled_at.toNumber();
|
|
16
|
+
this.end = stream.end.toNumber();
|
|
17
|
+
this.lastWithdrawnAt = stream.last_withdrawn_at.toNumber();
|
|
18
|
+
this.sender = stream.sender;
|
|
19
|
+
this.senderTokens = stream.sender;
|
|
20
|
+
this.recipient = stream.recipient;
|
|
21
|
+
this.recipientTokens = stream.recipient;
|
|
22
|
+
this.mint = stream.token.toLowerCase();
|
|
23
|
+
this.escrowTokens = "";
|
|
24
|
+
this.streamflowTreasury = "";
|
|
25
|
+
this.streamflowTreasuryTokens = "";
|
|
26
|
+
this.streamflowFeeTotal = new bn_js_1.default(stream.fees.streamflow_fee.toString());
|
|
27
|
+
this.streamflowFeeWithdrawn = new bn_js_1.default(stream.fees.streamflow_fee_withdrawn.toString());
|
|
28
|
+
this.streamflowFeePercent = stream.fees.streamflow_fee_percentage.toNumber() / 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 = stream.start.toNumber();
|
|
35
|
+
this.depositedAmount = new bn_js_1.default(stream.amount.toString());
|
|
36
|
+
this.period = stream.period.toNumber();
|
|
37
|
+
this.amountPerPeriod = new bn_js_1.default(stream.amount_per_period.toString());
|
|
38
|
+
this.cliff = stream.start.toNumber();
|
|
39
|
+
this.cliffAmount = new bn_js_1.default(stream.cliff_amount.toString());
|
|
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
|
+
this.name = stream.meta.contract_name;
|
|
47
|
+
this.withdrawalFrequency = stream.meta.withdrawal_frequency.toNumber();
|
|
48
|
+
}
|
|
49
|
+
EvmContract.prototype.unlocked = function (currentTimestamp) {
|
|
50
|
+
var deposited = this.depositedAmount;
|
|
51
|
+
if (currentTimestamp < this.cliff)
|
|
52
|
+
return new bn_js_1.default(0);
|
|
53
|
+
if (currentTimestamp > this.end)
|
|
54
|
+
return deposited;
|
|
55
|
+
var streamed = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
56
|
+
return streamed.lt(deposited) ? streamed : deposited;
|
|
57
|
+
};
|
|
58
|
+
EvmContract.prototype.remaining = function (decimals) {
|
|
59
|
+
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
60
|
+
};
|
|
61
|
+
return EvmContract;
|
|
62
|
+
}());
|
|
63
|
+
exports.EvmContract = EvmContract;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
|
-
import { Stream as StreamData,
|
|
3
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
2
|
+
import { Stream as StreamData, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
|
|
3
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
4
4
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
5
5
|
export default class SolanaStreamClient extends BaseStreamClient {
|
|
6
6
|
private connection;
|
|
@@ -16,7 +16,7 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
16
16
|
* Creates a new stream/vesting contract.
|
|
17
17
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
18
18
|
*/
|
|
19
|
-
create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender,
|
|
19
|
+
create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
|
|
20
20
|
/**
|
|
21
21
|
* Creates a new stream/vesting contract using unchecked instruction.
|
|
22
22
|
*
|
|
@@ -27,29 +27,29 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
27
27
|
*
|
|
28
28
|
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
29
29
|
*/
|
|
30
|
-
createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender,
|
|
30
|
+
createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
|
|
31
31
|
/**
|
|
32
32
|
* Creates multiple stream/vesting contracts.
|
|
33
33
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
34
34
|
*/
|
|
35
|
-
createMultiple(data: ICreateMultipleStreamData, { sender,
|
|
35
|
+
createMultiple(data: ICreateMultipleStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
|
|
36
36
|
/**
|
|
37
37
|
* Attempts withdrawing from the specified stream.
|
|
38
38
|
*/
|
|
39
|
-
withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<
|
|
39
|
+
withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
40
40
|
/**
|
|
41
41
|
* Attempts canceling the specified stream.
|
|
42
42
|
*/
|
|
43
|
-
cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<
|
|
43
|
+
cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
44
44
|
/**
|
|
45
45
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
46
46
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
47
47
|
*/
|
|
48
|
-
transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<
|
|
48
|
+
transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
49
49
|
/**
|
|
50
50
|
* Tops up stream account with specified amount.
|
|
51
51
|
*/
|
|
52
|
-
topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<
|
|
52
|
+
topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<ITransactionResult>;
|
|
53
53
|
/**
|
|
54
54
|
* Fetch stream data by its id (address).
|
|
55
55
|
*/
|
|
@@ -58,12 +58,12 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
58
58
|
* Fetch streams/contracts by providing direction.
|
|
59
59
|
* Streams are sorted by start time in ascending order.
|
|
60
60
|
*/
|
|
61
|
-
get({
|
|
61
|
+
get({ address, type, direction, }: IGetAllData): Promise<[string, StreamData][]>;
|
|
62
62
|
private sign;
|
|
63
63
|
/**
|
|
64
64
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
65
65
|
*/
|
|
66
|
-
update(data: IUpdateData, { invoker }: IInteractStreamSolanaExt): Promise<
|
|
66
|
+
update(data: IUpdateData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
67
67
|
/**
|
|
68
68
|
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
|
69
69
|
*/
|