@streamflow/stream 5.6.1 → 5.6.3
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 +161 -0
- package/dist/__tests__/common/GenericStreamClient.spec.d.ts +1 -0
- package/dist/__tests__/common/GenericStreamClient.spec.js +44 -0
- package/dist/aptos/StreamClient.d.ts +51 -0
- package/dist/aptos/StreamClient.js +391 -0
- package/dist/aptos/constants.d.ts +8 -0
- package/dist/aptos/constants.js +28 -0
- package/dist/aptos/index.d.ts +2 -0
- package/dist/aptos/index.js +24 -0
- package/dist/aptos/types.d.ts +97 -0
- package/dist/aptos/types.js +76 -0
- package/dist/aptos/utils.d.ts +1 -0
- package/dist/aptos/utils.js +12 -0
- package/dist/aptos/wallet.d.ts +9 -0
- package/dist/aptos/wallet.js +89 -0
- package/dist/common/BaseStreamClient.d.ts +13 -0
- package/dist/common/BaseStreamClient.js +13 -0
- package/dist/common/GenericStreamClient.d.ts +93 -0
- package/dist/common/GenericStreamClient.js +114 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +4 -0
- package/dist/common/contractUtils.d.ts +47 -0
- package/dist/common/contractUtils.js +55 -0
- package/dist/common/types.d.ts +252 -0
- package/dist/common/types.js +165 -0
- package/dist/common/utils.d.ts +22 -0
- package/dist/common/utils.js +101 -0
- package/dist/evm/StreamClient.d.ts +30 -0
- package/dist/evm/StreamClient.js +461 -0
- package/dist/evm/abi.d.ts +111 -0
- package/dist/evm/abi.js +1257 -0
- package/dist/evm/constants.d.ts +20 -0
- package/dist/evm/constants.js +39 -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 +93 -0
- package/dist/evm/types.js +75 -0
- package/dist/evm/utils.d.ts +1 -0
- package/dist/evm/utils.js +12 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +41 -0
- package/dist/solana/StreamClient.d.ts +72 -0
- package/dist/solana/StreamClient.js +927 -0
- package/dist/solana/constants.d.ts +22 -0
- package/dist/solana/constants.js +50 -0
- package/dist/solana/index.d.ts +7 -0
- package/dist/solana/index.js +43 -0
- package/dist/solana/instructionTypes.d.ts +96 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/solana/instructions.d.ts +139 -0
- package/dist/solana/instructions.js +407 -0
- package/dist/solana/layout.d.ts +27 -0
- package/dist/solana/layout.js +170 -0
- package/dist/solana/timelockIDL.d.ts +22 -0
- package/dist/solana/timelockIDL.js +422 -0
- package/dist/solana/types.d.ts +292 -0
- package/dist/solana/types.js +81 -0
- package/dist/solana/utils.d.ts +44 -0
- package/dist/solana/utils.js +303 -0
- package/dist/sui/StreamClient.d.ts +79 -0
- package/dist/sui/StreamClient.js +571 -0
- package/dist/sui/constants.d.ts +10 -0
- package/dist/sui/constants.js +43 -0
- package/dist/sui/index.d.ts +2 -0
- package/dist/sui/index.js +23 -0
- package/dist/sui/types.d.ts +141 -0
- package/dist/sui/types.js +102 -0
- package/dist/sui/utils.d.ts +2 -0
- package/dist/sui/utils.js +29 -0
- package/dist/sui/wallet.d.ts +11 -0
- package/dist/sui/wallet.js +75 -0
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ContractErrorCode, ICluster } from "../common/types";
|
|
2
|
+
export declare const ETHEREUM_PROGRAM_IDS: Record<ICluster, string>;
|
|
3
|
+
export declare const BNB_PROGRAM_IDS: Record<ICluster, string>;
|
|
4
|
+
export declare const POLYGON_PROGRAM_IDS: Record<ICluster, string>;
|
|
5
|
+
export declare const EVM_ERROR_MATCH_REGEX: RegExp;
|
|
6
|
+
export declare const EVM_ERROR_MAP: {
|
|
7
|
+
ECONTRACT_NOT_INIT: ContractErrorCode;
|
|
8
|
+
EBAD_AMOUNT: ContractErrorCode;
|
|
9
|
+
ENO_PERMISSIONS: ContractErrorCode;
|
|
10
|
+
EBADINPUT: ContractErrorCode;
|
|
11
|
+
ECLOSED: ContractErrorCode;
|
|
12
|
+
EBAD_INPUT_AMOUNT_PER_PERIOD: ContractErrorCode;
|
|
13
|
+
EBAD_INPUT_PAUSABLE: ContractErrorCode;
|
|
14
|
+
EBAD_INPUT_UPDATE_RATE: ContractErrorCode;
|
|
15
|
+
EBAD_INPUT_CLIFF_AMOUNT: ContractErrorCode;
|
|
16
|
+
EBAD_INPUT_PERIOD: ContractErrorCode;
|
|
17
|
+
EBAD_INPUT_START: ContractErrorCode;
|
|
18
|
+
EBAD_INSUFFICIENT_TOKEN_ALLOWANCE: ContractErrorCode;
|
|
19
|
+
EBAD_INSUFFICIENT_WITHDRAWAL_FEES: ContractErrorCode;
|
|
20
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.EVM_ERROR_MAP = exports.EVM_ERROR_MATCH_REGEX = exports.POLYGON_PROGRAM_IDS = exports.BNB_PROGRAM_IDS = exports.ETHEREUM_PROGRAM_IDS = void 0;
|
|
5
|
+
var types_1 = require("../common/types");
|
|
6
|
+
exports.ETHEREUM_PROGRAM_IDS = (_a = {},
|
|
7
|
+
_a[types_1.ICluster.Mainnet] = "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
|
|
8
|
+
_a[types_1.ICluster.Devnet] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
9
|
+
_a[types_1.ICluster.Testnet] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
10
|
+
_a[types_1.ICluster.Local] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
11
|
+
_a);
|
|
12
|
+
exports.BNB_PROGRAM_IDS = (_b = {},
|
|
13
|
+
_b[types_1.ICluster.Mainnet] = "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
|
|
14
|
+
_b[types_1.ICluster.Devnet] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
15
|
+
_b[types_1.ICluster.Testnet] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
16
|
+
_b[types_1.ICluster.Local] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
17
|
+
_b);
|
|
18
|
+
exports.POLYGON_PROGRAM_IDS = (_c = {},
|
|
19
|
+
_c[types_1.ICluster.Mainnet] = "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
|
|
20
|
+
_c[types_1.ICluster.Devnet] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
21
|
+
_c[types_1.ICluster.Testnet] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
22
|
+
_c[types_1.ICluster.Local] = "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
23
|
+
_c);
|
|
24
|
+
exports.EVM_ERROR_MATCH_REGEX = /execution reverted: ([A-Z_]+)/;
|
|
25
|
+
exports.EVM_ERROR_MAP = {
|
|
26
|
+
ECONTRACT_NOT_INIT: types_1.ContractErrorCode.ECONTRACT_NOT_INIT,
|
|
27
|
+
EBAD_AMOUNT: types_1.ContractErrorCode.EBAD_AMOUNT,
|
|
28
|
+
ENO_PERMISSIONS: types_1.ContractErrorCode.ENO_PERMISSIONS,
|
|
29
|
+
EBADINPUT: types_1.ContractErrorCode.EBADINPUT,
|
|
30
|
+
ECLOSED: types_1.ContractErrorCode.ECLOSED,
|
|
31
|
+
EBAD_INPUT_AMOUNT_PER_PERIOD: types_1.ContractErrorCode.EBAD_INPUT_AMOUNT_PER_PERIOD,
|
|
32
|
+
EBAD_INPUT_PAUSABLE: types_1.ContractErrorCode.EBAD_INPUT_PAUSABLE,
|
|
33
|
+
EBAD_INPUT_UPDATE_RATE: types_1.ContractErrorCode.EBAD_INPUT_UPDATE_RATE,
|
|
34
|
+
EBAD_INPUT_CLIFF_AMOUNT: types_1.ContractErrorCode.EBAD_INPUT_CLIFF_AMOUNT,
|
|
35
|
+
EBAD_INPUT_PERIOD: types_1.ContractErrorCode.EBAD_INPUT_PERIOD,
|
|
36
|
+
EBAD_INPUT_START: types_1.ContractErrorCode.EBAD_INPUT_START,
|
|
37
|
+
EBAD_INSUFFICIENT_TOKEN_ALLOWANCE: types_1.ContractErrorCode.EBAD_INSUFFICIENT_TOKEN_ALLOWANCE,
|
|
38
|
+
EBAD_INSUFFICIENT_WITHDRAWAL_FEES: types_1.ContractErrorCode.EBAD_INSUFFICIENT_WITHDRAWAL_FEES,
|
|
39
|
+
};
|
|
@@ -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,93 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
import { BigNumber } from "ethers";
|
|
3
|
+
import { Stream, StreamType } from "../common/types";
|
|
4
|
+
export interface StreamAbiResult {
|
|
5
|
+
amount: BigNumber;
|
|
6
|
+
amount_per_period: BigNumber;
|
|
7
|
+
canceled_at: BigNumber;
|
|
8
|
+
cliff_amount: BigNumber;
|
|
9
|
+
closed: boolean;
|
|
10
|
+
created: BigNumber;
|
|
11
|
+
current_pause_start: BigNumber;
|
|
12
|
+
end: BigNumber;
|
|
13
|
+
fees: {
|
|
14
|
+
streamflow_fee_percentage: BigNumber;
|
|
15
|
+
streamflow_fee: BigNumber;
|
|
16
|
+
streamflow_fee_withdrawn: BigNumber;
|
|
17
|
+
partner_fee_percentage: BigNumber;
|
|
18
|
+
partner_fee: BigNumber;
|
|
19
|
+
partner_fee_withdrawn: BigNumber;
|
|
20
|
+
tx_fee: BigNumber;
|
|
21
|
+
};
|
|
22
|
+
funds_unlocked_at_last_rate_change: BigNumber;
|
|
23
|
+
last_rate_change_time: BigNumber;
|
|
24
|
+
last_withdrawn_at: BigNumber;
|
|
25
|
+
meta: {
|
|
26
|
+
automatic_withdrawal: boolean;
|
|
27
|
+
can_topup: boolean;
|
|
28
|
+
can_update_rate: boolean;
|
|
29
|
+
cancelable_by_recipient: boolean;
|
|
30
|
+
cancelable_by_sender: boolean;
|
|
31
|
+
contract_name: string;
|
|
32
|
+
pausable: boolean;
|
|
33
|
+
transferable_by_recipient: boolean;
|
|
34
|
+
transferable_by_sender: boolean;
|
|
35
|
+
withdrawal_frequency: BigNumber;
|
|
36
|
+
};
|
|
37
|
+
pause_cumulative: BigNumber;
|
|
38
|
+
period: BigNumber;
|
|
39
|
+
recipient: string;
|
|
40
|
+
sender: string;
|
|
41
|
+
partner: string;
|
|
42
|
+
start: BigNumber;
|
|
43
|
+
token: string;
|
|
44
|
+
withdrawn: BigNumber;
|
|
45
|
+
}
|
|
46
|
+
export declare class EvmContract implements Stream {
|
|
47
|
+
magic: number;
|
|
48
|
+
version: number;
|
|
49
|
+
createdAt: number;
|
|
50
|
+
withdrawnAmount: BN;
|
|
51
|
+
canceledAt: number;
|
|
52
|
+
end: number;
|
|
53
|
+
lastWithdrawnAt: number;
|
|
54
|
+
sender: string;
|
|
55
|
+
senderTokens: string;
|
|
56
|
+
recipient: string;
|
|
57
|
+
recipientTokens: string;
|
|
58
|
+
mint: string;
|
|
59
|
+
escrowTokens: string;
|
|
60
|
+
streamflowTreasury: string;
|
|
61
|
+
streamflowTreasuryTokens: string;
|
|
62
|
+
streamflowFeeTotal: BN;
|
|
63
|
+
streamflowFeeWithdrawn: BN;
|
|
64
|
+
streamflowFeePercent: number;
|
|
65
|
+
partnerFeeTotal: BN;
|
|
66
|
+
partnerFeeWithdrawn: BN;
|
|
67
|
+
partnerFeePercent: number;
|
|
68
|
+
partner: string;
|
|
69
|
+
partnerTokens: string;
|
|
70
|
+
start: number;
|
|
71
|
+
depositedAmount: BN;
|
|
72
|
+
period: number;
|
|
73
|
+
amountPerPeriod: BN;
|
|
74
|
+
cliff: number;
|
|
75
|
+
cliffAmount: BN;
|
|
76
|
+
cancelableBySender: boolean;
|
|
77
|
+
cancelableByRecipient: boolean;
|
|
78
|
+
automaticWithdrawal: boolean;
|
|
79
|
+
transferableBySender: boolean;
|
|
80
|
+
transferableByRecipient: boolean;
|
|
81
|
+
canTopup: boolean;
|
|
82
|
+
name: string;
|
|
83
|
+
withdrawalFrequency: number;
|
|
84
|
+
closed: boolean;
|
|
85
|
+
currentPauseStart: number;
|
|
86
|
+
pauseCumulative: BN;
|
|
87
|
+
lastRateChangeTime: number;
|
|
88
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
89
|
+
type: StreamType;
|
|
90
|
+
constructor(stream: StreamAbiResult);
|
|
91
|
+
unlocked(currentTimestamp: number): BN;
|
|
92
|
+
remaining(decimals: number): number;
|
|
93
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.EvmContract = void 0;
|
|
18
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
19
|
+
var contractUtils_1 = require("../common/contractUtils");
|
|
20
|
+
var utils_1 = require("../common/utils");
|
|
21
|
+
var EvmContract = /** @class */ (function () {
|
|
22
|
+
function EvmContract(stream) {
|
|
23
|
+
this.magic = 0;
|
|
24
|
+
this.version = 0;
|
|
25
|
+
this.createdAt = stream.created.toNumber();
|
|
26
|
+
this.withdrawnAmount = new bn_js_1.default(stream.withdrawn.toString());
|
|
27
|
+
this.canceledAt = stream.canceled_at.toNumber();
|
|
28
|
+
this.end = stream.end.toNumber();
|
|
29
|
+
this.lastWithdrawnAt = stream.last_withdrawn_at.toNumber();
|
|
30
|
+
this.sender = stream.sender;
|
|
31
|
+
this.senderTokens = stream.sender;
|
|
32
|
+
this.recipient = stream.recipient;
|
|
33
|
+
this.recipientTokens = stream.recipient;
|
|
34
|
+
this.mint = stream.token.toLowerCase();
|
|
35
|
+
this.escrowTokens = "";
|
|
36
|
+
this.streamflowTreasury = "";
|
|
37
|
+
this.streamflowTreasuryTokens = "";
|
|
38
|
+
this.streamflowFeeTotal = new bn_js_1.default(stream.fees.streamflow_fee.toString());
|
|
39
|
+
this.streamflowFeeWithdrawn = new bn_js_1.default(stream.fees.streamflow_fee_withdrawn.toString());
|
|
40
|
+
this.streamflowFeePercent = stream.fees.streamflow_fee_percentage.toNumber() / 10000;
|
|
41
|
+
this.partnerFeeTotal = new bn_js_1.default(0);
|
|
42
|
+
this.partnerFeeWithdrawn = new bn_js_1.default(0);
|
|
43
|
+
this.partnerFeePercent = 0;
|
|
44
|
+
this.partner = "";
|
|
45
|
+
this.partnerTokens = "";
|
|
46
|
+
this.start = stream.start.toNumber();
|
|
47
|
+
this.depositedAmount = new bn_js_1.default(stream.amount.toString());
|
|
48
|
+
this.period = stream.period.toNumber();
|
|
49
|
+
this.amountPerPeriod = new bn_js_1.default(stream.amount_per_period.toString());
|
|
50
|
+
this.cliff = stream.start.toNumber();
|
|
51
|
+
this.cliffAmount = new bn_js_1.default(stream.cliff_amount.toString());
|
|
52
|
+
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
53
|
+
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
54
|
+
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
55
|
+
this.transferableBySender = stream.meta.transferable_by_sender;
|
|
56
|
+
this.transferableByRecipient = stream.meta.transferable_by_recipient;
|
|
57
|
+
this.canTopup = stream.meta.can_topup;
|
|
58
|
+
this.name = stream.meta.contract_name;
|
|
59
|
+
this.withdrawalFrequency = stream.meta.withdrawal_frequency.toNumber();
|
|
60
|
+
this.closed = stream.closed;
|
|
61
|
+
this.currentPauseStart = stream.current_pause_start.toNumber();
|
|
62
|
+
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative.toString());
|
|
63
|
+
this.lastRateChangeTime = stream.last_rate_change_time.toNumber();
|
|
64
|
+
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change.toString());
|
|
65
|
+
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
66
|
+
}
|
|
67
|
+
EvmContract.prototype.unlocked = function (currentTimestamp) {
|
|
68
|
+
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
69
|
+
};
|
|
70
|
+
EvmContract.prototype.remaining = function (decimals) {
|
|
71
|
+
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
72
|
+
};
|
|
73
|
+
return EvmContract;
|
|
74
|
+
}());
|
|
75
|
+
exports.EvmContract = EvmContract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractEvmErrorCode(errorText: string): string | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractEvmErrorCode = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
function extractEvmErrorCode(errorText) {
|
|
6
|
+
var match = constants_1.EVM_ERROR_MATCH_REGEX.exec(errorText);
|
|
7
|
+
if (!match) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return match[1];
|
|
11
|
+
}
|
|
12
|
+
exports.extractEvmErrorCode = extractEvmErrorCode;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * as StreamflowAptos from "./aptos";
|
|
2
|
+
export * as StreamflowEVM from "./evm";
|
|
3
|
+
export * as StreamflowSolana from "./solana";
|
|
4
|
+
export * as StreamflowSui from "./sui";
|
|
5
|
+
export * as Types from "./common/types";
|
|
6
|
+
export * from "./common/utils";
|
|
7
|
+
export * from "./common/constants";
|
|
8
|
+
export { default as GenericStreamClient } from "./common/GenericStreamClient";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 __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
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.GenericStreamClient = exports.Types = exports.StreamflowSui = exports.StreamflowSolana = exports.StreamflowEVM = exports.StreamflowAptos = void 0;
|
|
33
|
+
exports.StreamflowAptos = __importStar(require("./aptos"));
|
|
34
|
+
exports.StreamflowEVM = __importStar(require("./evm"));
|
|
35
|
+
exports.StreamflowSolana = __importStar(require("./solana"));
|
|
36
|
+
exports.StreamflowSui = __importStar(require("./sui"));
|
|
37
|
+
exports.Types = __importStar(require("./common/types"));
|
|
38
|
+
__exportStar(require("./common/utils"), exports);
|
|
39
|
+
__exportStar(require("./common/constants"), exports);
|
|
40
|
+
var GenericStreamClient_1 = require("./common/GenericStreamClient");
|
|
41
|
+
Object.defineProperty(exports, "GenericStreamClient", { enumerable: true, get: function () { return __importDefault(GenericStreamClient_1).default; } });
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
|
+
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
|
|
3
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
4
|
+
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
5
|
+
export default class SolanaStreamClient extends BaseStreamClient {
|
|
6
|
+
private connection;
|
|
7
|
+
private programId;
|
|
8
|
+
private commitment;
|
|
9
|
+
/**
|
|
10
|
+
* Create Stream instance
|
|
11
|
+
*/
|
|
12
|
+
constructor(clusterUrl: string, cluster?: ICluster, commitment?: Commitment | ConnectionConfig, programId?: string);
|
|
13
|
+
getConnection(): Connection;
|
|
14
|
+
getProgramId(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new stream/vesting contract.
|
|
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
|
+
*/
|
|
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
|
+
/**
|
|
21
|
+
* Creates a new stream/vesting contract using unchecked instruction.
|
|
22
|
+
*
|
|
23
|
+
* Unchecked instruction differes from the regular in:
|
|
24
|
+
* - does not check for initialized associated token account (wallets with no control over their ATA should not be used
|
|
25
|
+
* as sender/recipient/partner or there are risks of funds being locked in the contract)
|
|
26
|
+
* - initialized contract PDA off chain
|
|
27
|
+
*
|
|
28
|
+
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
29
|
+
*/
|
|
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
|
+
/**
|
|
32
|
+
* Creates multiple stream/vesting contracts.
|
|
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
|
+
*/
|
|
35
|
+
createMultiple(data: ICreateMultipleStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Attempts withdrawing from the specified stream.
|
|
38
|
+
*/
|
|
39
|
+
withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Attempts canceling the specified stream.
|
|
42
|
+
*/
|
|
43
|
+
cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
46
|
+
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
47
|
+
*/
|
|
48
|
+
transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Tops up stream account with specified amount.
|
|
51
|
+
*/
|
|
52
|
+
topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<ITransactionResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Fetch stream data by its id (address).
|
|
55
|
+
*/
|
|
56
|
+
getOne({ id }: IGetOneData): Promise<Stream>;
|
|
57
|
+
/**
|
|
58
|
+
* Fetch streams/contracts by providing direction.
|
|
59
|
+
* Streams are sorted by start time in ascending order.
|
|
60
|
+
*/
|
|
61
|
+
get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
|
|
62
|
+
private sign;
|
|
63
|
+
/**
|
|
64
|
+
* Attempts updating the stream auto withdrawal params and amount per period
|
|
65
|
+
*/
|
|
66
|
+
update(data: IUpdateData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
67
|
+
extractErrorCode(err: Error): string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
|
70
|
+
*/
|
|
71
|
+
private prepareStreamTransaction;
|
|
72
|
+
}
|