@streamflow/stream 3.0.16 → 4.0.0-Alpha.0
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/StreamClient.d.ts +3 -4
- package/dist/StreamClient.js +35 -21
- package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
- package/dist/__tests__/aptos/streamClient.spec.js +160 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -1
- package/dist/aptos/StreamClient.d.ts +19 -0
- package/dist/aptos/StreamClient.js +296 -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 +23 -0
- package/dist/aptos/types.d.ts +10 -0
- package/dist/aptos/types.js +2 -0
- package/dist/common/types.d.ts +70 -0
- package/dist/common/types.js +29 -0
- package/dist/common/utils.d.ts +15 -0
- package/dist/common/utils.js +31 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +17 -13
- package/dist/instructionTypes.d.ts +81 -0
- package/dist/instructionTypes.js +2 -0
- package/dist/instructions.d.ts +0 -2
- package/dist/instructions.js +18 -29
- package/dist/layout.d.ts +7 -7
- package/dist/layout.js +78 -75
- package/dist/solana/StreamClient.d.ts +145 -0
- package/dist/solana/StreamClient.js +952 -0
- package/dist/solana/constants.d.ts +18 -0
- package/dist/solana/constants.js +23 -0
- package/dist/solana/index.d.ts +5 -0
- package/dist/solana/index.js +27 -0
- package/dist/solana/instructionTypes.d.ts +81 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/solana/instructions.d.ts +131 -0
- package/dist/solana/instructions.js +375 -0
- package/dist/solana/layout.d.ts +22 -0
- package/dist/solana/layout.js +96 -0
- package/dist/solana/timelockIDL.d.ts +22 -0
- package/dist/solana/timelockIDL.js +422 -0
- package/dist/solana/types.d.ts +321 -0
- package/dist/solana/types.js +74 -0
- package/dist/solana/utils.d.ts +42 -0
- package/dist/solana/utils.js +269 -0
- package/dist/types.d.ts +12 -13
- package/package.json +23 -10
|
@@ -0,0 +1,296 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __values = (this && this.__values) || function(o) {
|
|
54
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
55
|
+
if (m) return m.call(o);
|
|
56
|
+
if (o && typeof o.length === "number") return {
|
|
57
|
+
next: function () {
|
|
58
|
+
if (o && i >= o.length) o = void 0;
|
|
59
|
+
return { value: o && o[i++], done: !o };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
var aptos_1 = require("aptos");
|
|
66
|
+
var types_1 = require("../common/types");
|
|
67
|
+
var constants_1 = require("./constants");
|
|
68
|
+
var AptosStreamClient = /** @class */ (function (_super) {
|
|
69
|
+
__extends(AptosStreamClient, _super);
|
|
70
|
+
function AptosStreamClient(cluster, maxGas, programId) {
|
|
71
|
+
if (maxGas === void 0) { maxGas = "10000"; }
|
|
72
|
+
var _this = _super.call(this) || this;
|
|
73
|
+
_this.programId = programId
|
|
74
|
+
? programId
|
|
75
|
+
: constants_1.APTOS_PROGRAM_IDS[cluster] || constants_1.APTOS_PROGRAM_IDS[types_1.ICluster.Mainnet];
|
|
76
|
+
_this.maxGas = maxGas;
|
|
77
|
+
return _this;
|
|
78
|
+
}
|
|
79
|
+
AptosStreamClient.prototype.create = function (streamData, _a) {
|
|
80
|
+
var senderWallet = _a.senderWallet;
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var acc, seeds, strmEncoded, name, payload, hash;
|
|
83
|
+
return __generator(this, function (_b) {
|
|
84
|
+
switch (_b.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
acc = new aptos_1.AptosAccount();
|
|
87
|
+
seeds = acc.address().hex();
|
|
88
|
+
strmEncoded = new TextEncoder().encode("STRM");
|
|
89
|
+
name = Buffer.from(strmEncoded).toString("hex");
|
|
90
|
+
payload = {
|
|
91
|
+
type: "create",
|
|
92
|
+
function: "".concat(this.programId, "::protocol::create"),
|
|
93
|
+
type_arguments: [streamData.tokenId],
|
|
94
|
+
arguments: [
|
|
95
|
+
seeds,
|
|
96
|
+
streamData.amount,
|
|
97
|
+
streamData.period,
|
|
98
|
+
streamData.amountPerPeriod,
|
|
99
|
+
streamData.start,
|
|
100
|
+
streamData.cliffAmount,
|
|
101
|
+
streamData.cancelableBySender,
|
|
102
|
+
streamData.cancelableByRecipient,
|
|
103
|
+
streamData.transferableBySender,
|
|
104
|
+
streamData.transferableByRecipient,
|
|
105
|
+
streamData.canTopup,
|
|
106
|
+
streamData.canPause,
|
|
107
|
+
streamData.canUpdateRate,
|
|
108
|
+
streamData.automaticWithdrawal,
|
|
109
|
+
streamData.withdrawalFrequency,
|
|
110
|
+
name,
|
|
111
|
+
streamData.recipient,
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
115
|
+
case 1:
|
|
116
|
+
hash = (_b.sent()).hash;
|
|
117
|
+
return [2 /*return*/, { txId: hash }];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
AptosStreamClient.prototype.createMultiple = function (multipleStreamData, _a) {
|
|
123
|
+
var senderWallet = _a.senderWallet;
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var payloads, ids, payloads_1, payloads_1_1, payload, hash, e_1_1;
|
|
126
|
+
var e_1, _b;
|
|
127
|
+
return __generator(this, function (_c) {
|
|
128
|
+
switch (_c.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
payloads = this.generateMultiPayloads(multipleStreamData);
|
|
131
|
+
ids = [];
|
|
132
|
+
_c.label = 1;
|
|
133
|
+
case 1:
|
|
134
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
135
|
+
payloads_1 = __values(payloads), payloads_1_1 = payloads_1.next();
|
|
136
|
+
_c.label = 2;
|
|
137
|
+
case 2:
|
|
138
|
+
if (!!payloads_1_1.done) return [3 /*break*/, 5];
|
|
139
|
+
payload = payloads_1_1.value;
|
|
140
|
+
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
141
|
+
case 3:
|
|
142
|
+
hash = (_c.sent()).hash;
|
|
143
|
+
ids.push({ txId: hash });
|
|
144
|
+
_c.label = 4;
|
|
145
|
+
case 4:
|
|
146
|
+
payloads_1_1 = payloads_1.next();
|
|
147
|
+
return [3 /*break*/, 2];
|
|
148
|
+
case 5: return [3 /*break*/, 8];
|
|
149
|
+
case 6:
|
|
150
|
+
e_1_1 = _c.sent();
|
|
151
|
+
e_1 = { error: e_1_1 };
|
|
152
|
+
return [3 /*break*/, 8];
|
|
153
|
+
case 7:
|
|
154
|
+
try {
|
|
155
|
+
if (payloads_1_1 && !payloads_1_1.done && (_b = payloads_1.return)) _b.call(payloads_1);
|
|
156
|
+
}
|
|
157
|
+
finally { if (e_1) throw e_1.error; }
|
|
158
|
+
return [7 /*endfinally*/];
|
|
159
|
+
case 8: return [2 /*return*/, ids];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
AptosStreamClient.prototype.withdraw = function (withdrawData, _a) {
|
|
165
|
+
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
166
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
+
var payload, hash;
|
|
168
|
+
return __generator(this, function (_b) {
|
|
169
|
+
switch (_b.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
payload = {
|
|
172
|
+
type: "withdraw",
|
|
173
|
+
function: "".concat(this.programId, "::protocol::withdraw"),
|
|
174
|
+
type_arguments: [tokenId],
|
|
175
|
+
arguments: [withdrawData.id, withdrawData.amount.toString()],
|
|
176
|
+
};
|
|
177
|
+
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
178
|
+
case 1:
|
|
179
|
+
hash = (_b.sent()).hash;
|
|
180
|
+
return [2 /*return*/, { txId: hash }];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
AptosStreamClient.prototype.cancel = function (cancelData, _a) {
|
|
186
|
+
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
187
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
188
|
+
var payload, hash;
|
|
189
|
+
return __generator(this, function (_b) {
|
|
190
|
+
switch (_b.label) {
|
|
191
|
+
case 0:
|
|
192
|
+
payload = {
|
|
193
|
+
type: "cancel",
|
|
194
|
+
function: "".concat(this.programId, "::protocol::cancel"),
|
|
195
|
+
type_arguments: [tokenId],
|
|
196
|
+
arguments: [cancelData.id],
|
|
197
|
+
};
|
|
198
|
+
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
199
|
+
case 1:
|
|
200
|
+
hash = (_b.sent()).hash;
|
|
201
|
+
return [2 /*return*/, { txId: hash }];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
AptosStreamClient.prototype.transfer = function (transferData, _a) {
|
|
207
|
+
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
208
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
+
var payload, hash;
|
|
210
|
+
return __generator(this, function (_b) {
|
|
211
|
+
switch (_b.label) {
|
|
212
|
+
case 0:
|
|
213
|
+
payload = {
|
|
214
|
+
type: "transfer",
|
|
215
|
+
function: "".concat(this.programId, "::protocol::transfer"),
|
|
216
|
+
type_arguments: [tokenId],
|
|
217
|
+
arguments: [transferData.id, transferData.newRecipient],
|
|
218
|
+
};
|
|
219
|
+
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
220
|
+
case 1:
|
|
221
|
+
hash = (_b.sent()).hash;
|
|
222
|
+
return [2 /*return*/, { txId: hash }];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
AptosStreamClient.prototype.topup = function (topupData, _a) {
|
|
228
|
+
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
229
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
+
var payload, hash;
|
|
231
|
+
return __generator(this, function (_b) {
|
|
232
|
+
switch (_b.label) {
|
|
233
|
+
case 0:
|
|
234
|
+
payload = {
|
|
235
|
+
type: "topup",
|
|
236
|
+
function: "".concat(this.programId, "::protocol::topup"),
|
|
237
|
+
type_arguments: [tokenId],
|
|
238
|
+
arguments: [topupData.id, topupData.amount.toString()],
|
|
239
|
+
};
|
|
240
|
+
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
241
|
+
case 1:
|
|
242
|
+
hash = (_b.sent()).hash;
|
|
243
|
+
return [2 /*return*/, { txId: hash }];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
AptosStreamClient.prototype.getOne = function () {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
throw new Error("Not implemented.");
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
AptosStreamClient.prototype.getProgramId = function () {
|
|
256
|
+
return this.programId;
|
|
257
|
+
};
|
|
258
|
+
AptosStreamClient.prototype.getMaxGas = function () {
|
|
259
|
+
return { max_gas_amount: this.maxGas };
|
|
260
|
+
};
|
|
261
|
+
AptosStreamClient.prototype.generateMultiPayloads = function (multipleStreamData) {
|
|
262
|
+
var _this = this;
|
|
263
|
+
return multipleStreamData.recipients.map(function (recipient) {
|
|
264
|
+
var acc = new aptos_1.AptosAccount(); // Generate random address as seeds for derriving "escrow" account
|
|
265
|
+
var seeds = acc.address().hex();
|
|
266
|
+
var strmEncoded = new TextEncoder().encode("STRM");
|
|
267
|
+
var name = Buffer.from(strmEncoded).toString("hex");
|
|
268
|
+
return {
|
|
269
|
+
type: "create",
|
|
270
|
+
function: "".concat(_this.programId, "::protocol::create"),
|
|
271
|
+
type_arguments: [multipleStreamData.tokenId],
|
|
272
|
+
arguments: [
|
|
273
|
+
seeds,
|
|
274
|
+
recipient.amount,
|
|
275
|
+
multipleStreamData.period,
|
|
276
|
+
recipient.amountPerPeriod,
|
|
277
|
+
multipleStreamData.start,
|
|
278
|
+
recipient.cliffAmount,
|
|
279
|
+
multipleStreamData.cancelableBySender,
|
|
280
|
+
multipleStreamData.cancelableByRecipient,
|
|
281
|
+
multipleStreamData.transferableBySender,
|
|
282
|
+
multipleStreamData.transferableByRecipient,
|
|
283
|
+
multipleStreamData.canTopup,
|
|
284
|
+
multipleStreamData.canPause,
|
|
285
|
+
multipleStreamData.canUpdateRate,
|
|
286
|
+
multipleStreamData.automaticWithdrawal,
|
|
287
|
+
multipleStreamData.withdrawalFrequency,
|
|
288
|
+
name,
|
|
289
|
+
recipient.recipient,
|
|
290
|
+
],
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
return AptosStreamClient;
|
|
295
|
+
}(types_1.GenericStreamClient));
|
|
296
|
+
exports.default = AptosStreamClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.APTOS_PROGRAM_IDS = void 0;
|
|
5
|
+
var types_1 = require("../common/types");
|
|
6
|
+
exports.APTOS_PROGRAM_IDS = (_a = {},
|
|
7
|
+
_a[types_1.ICluster.Mainnet] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
|
|
8
|
+
_a[types_1.ICluster.Devnet] = "0x1dda724347d7776cb1817054eaf49d03cb6f58dae92c90d62edd5d3b90ba733c",
|
|
9
|
+
// TODO: Add a correct programID for Test net
|
|
10
|
+
_a[types_1.ICluster.Testnet] = "0x1dda724347d7776cb1817054eaf49d03cb6f58dae92c90d62edd5d3b90ba733c",
|
|
11
|
+
_a[types_1.ICluster.Local] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
|
|
12
|
+
_a);
|
|
@@ -0,0 +1,23 @@
|
|
|
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.default = void 0;
|
|
21
|
+
var StreamClient_1 = require("./StreamClient");
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
|
|
2
|
+
export interface ICreateStreamAptosExt {
|
|
3
|
+
senderWallet: WalletContextState;
|
|
4
|
+
}
|
|
5
|
+
export interface ITransactionResult {
|
|
6
|
+
txId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare type ITransactionAptosExt = ICreateStreamAptosExt & {
|
|
9
|
+
tokenId: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 ICancelData {
|
|
33
|
+
id: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ITransferData {
|
|
36
|
+
id: string;
|
|
37
|
+
newRecipient: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ITopUpData {
|
|
40
|
+
id: string;
|
|
41
|
+
amount: BN;
|
|
42
|
+
}
|
|
43
|
+
export interface IGetOneData {
|
|
44
|
+
id: string;
|
|
45
|
+
}
|
|
46
|
+
export declare abstract class GenericStreamClient {
|
|
47
|
+
abstract create(streamData: ICreateStreamData, ...chainSpecificParams: any[]): Promise<any>;
|
|
48
|
+
abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, ...chainSpecificParams: any[]): Promise<any>;
|
|
49
|
+
abstract withdraw(withdrawData: IWithdrawData, ...chainSpecificParams: any[]): Promise<any>;
|
|
50
|
+
abstract cancel(cancelData: ICancelData, ...chainSpecificParams: any[]): Promise<any>;
|
|
51
|
+
abstract transfer(transferData: ITransferData, ...chainSpecificParams: any[]): Promise<any>;
|
|
52
|
+
abstract topup(topupData: ITopUpData, ...chainSpecificParams: any[]): Promise<any>;
|
|
53
|
+
abstract getOne(getOneData: IGetOneData, ...chainSpecificParams: any[]): Promise<any>;
|
|
54
|
+
}
|
|
55
|
+
export declare enum ICluster {
|
|
56
|
+
Mainnet = "mainnet",
|
|
57
|
+
Devnet = "devnet",
|
|
58
|
+
Testnet = "testnet",
|
|
59
|
+
Local = "local"
|
|
60
|
+
}
|
|
61
|
+
export declare enum StreamDirection {
|
|
62
|
+
Outgoing = "outgoing",
|
|
63
|
+
Incoming = "incoming",
|
|
64
|
+
All = "all"
|
|
65
|
+
}
|
|
66
|
+
export declare enum StreamType {
|
|
67
|
+
Stream = "stream",
|
|
68
|
+
Vesting = "vesting",
|
|
69
|
+
All = "all"
|
|
70
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamType = exports.StreamDirection = exports.ICluster = exports.GenericStreamClient = void 0;
|
|
4
|
+
var GenericStreamClient = /** @class */ (function () {
|
|
5
|
+
function GenericStreamClient() {
|
|
6
|
+
}
|
|
7
|
+
return GenericStreamClient;
|
|
8
|
+
}());
|
|
9
|
+
exports.GenericStreamClient = GenericStreamClient;
|
|
10
|
+
// Utility types
|
|
11
|
+
var ICluster;
|
|
12
|
+
(function (ICluster) {
|
|
13
|
+
ICluster["Mainnet"] = "mainnet";
|
|
14
|
+
ICluster["Devnet"] = "devnet";
|
|
15
|
+
ICluster["Testnet"] = "testnet";
|
|
16
|
+
ICluster["Local"] = "local";
|
|
17
|
+
})(ICluster = exports.ICluster || (exports.ICluster = {}));
|
|
18
|
+
var StreamDirection;
|
|
19
|
+
(function (StreamDirection) {
|
|
20
|
+
StreamDirection["Outgoing"] = "outgoing";
|
|
21
|
+
StreamDirection["Incoming"] = "incoming";
|
|
22
|
+
StreamDirection["All"] = "all";
|
|
23
|
+
})(StreamDirection = exports.StreamDirection || (exports.StreamDirection = {}));
|
|
24
|
+
var StreamType;
|
|
25
|
+
(function (StreamType) {
|
|
26
|
+
StreamType["Stream"] = "stream";
|
|
27
|
+
StreamType["Vesting"] = "vesting";
|
|
28
|
+
StreamType["All"] = "all";
|
|
29
|
+
})(StreamType = exports.StreamType || (exports.StreamType = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BN from "bn.js";
|
|
2
|
+
/**
|
|
3
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
4
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
5
|
+
* @param {number} value - Number of tokens you want to convert to its BN representation.
|
|
6
|
+
* @param {number} decimals - Number of decimals the token has.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getBN: (value: number, decimals: number) => BN;
|
|
9
|
+
/**
|
|
10
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
11
|
+
* Get value in the highest units from BN representation of the same value in the smallest units.
|
|
12
|
+
* @param {BN} value - Big Number representation of value in the smallest units.
|
|
13
|
+
* @param {number} decimals - Number of decimals the token has.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getNumberFromBN: (value: BN, decimals: number) => number;
|
|
@@ -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,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./instructions";
|
|
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";
|
package/dist/index.js
CHANGED
|
@@ -10,20 +10,24 @@ 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
|
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
__exportStar(require("./utils"), exports);
|
|
26
|
-
__exportStar(require("./types"), exports);
|
|
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; } });
|
|
29
|
+
exports.Types = exports.StreamflowAptos = exports.StreamflowSolana = void 0;
|
|
30
|
+
exports.StreamflowSolana = __importStar(require("./solana"));
|
|
31
|
+
exports.StreamflowAptos = __importStar(require("./aptos"));
|
|
32
|
+
exports.Types = __importStar(require("./common/types"));
|
|
33
|
+
__exportStar(require("./common/utils"), exports);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface IStreamLayout {
|
|
2
|
+
magic: Uint8Array;
|
|
3
|
+
version: Uint8Array;
|
|
4
|
+
created_at: Uint8Array;
|
|
5
|
+
withdrawn_amount: Uint8Array;
|
|
6
|
+
canceled_at: Uint8Array;
|
|
7
|
+
end_time: Uint8Array;
|
|
8
|
+
last_withdrawn_at: Uint8Array;
|
|
9
|
+
sender: Uint8Array;
|
|
10
|
+
sender_tokens: Uint8Array;
|
|
11
|
+
recipient: Uint8Array;
|
|
12
|
+
recipient_tokens: Uint8Array;
|
|
13
|
+
mint: Uint8Array;
|
|
14
|
+
escrow_tokens: Uint8Array;
|
|
15
|
+
streamflow_treasury: Uint8Array;
|
|
16
|
+
streamflow_treasury_tokens: Uint8Array;
|
|
17
|
+
streamflow_fee_total: Uint8Array;
|
|
18
|
+
streamflow_fee_withdrawn: Uint8Array;
|
|
19
|
+
streamflow_fee_percent: number;
|
|
20
|
+
partner: Uint8Array;
|
|
21
|
+
partner_tokens: Uint8Array;
|
|
22
|
+
partner_fee_total: Uint8Array;
|
|
23
|
+
partner_fee_withdrawn: Uint8Array;
|
|
24
|
+
partner_fee_percent: number;
|
|
25
|
+
start_time: Uint8Array;
|
|
26
|
+
net_amount_deposited: Uint8Array;
|
|
27
|
+
period: Uint8Array;
|
|
28
|
+
amount_per_period: Uint8Array;
|
|
29
|
+
cliff: Uint8Array;
|
|
30
|
+
cliff_amount: Uint8Array;
|
|
31
|
+
cancelable_by_sender: number;
|
|
32
|
+
cancelable_by_recipient: number;
|
|
33
|
+
automatic_withdrawal: number;
|
|
34
|
+
transferable_by_sender: number;
|
|
35
|
+
transferable_by_recipient: number;
|
|
36
|
+
can_topup: number;
|
|
37
|
+
stream_name: Uint8Array;
|
|
38
|
+
withdraw_frequency: Uint8Array;
|
|
39
|
+
}
|
|
40
|
+
export interface ICreateStreamLayout {
|
|
41
|
+
start_time: Uint8Array;
|
|
42
|
+
net_amount_deposited: Uint8Array;
|
|
43
|
+
period: Uint8Array;
|
|
44
|
+
amount_per_period: Uint8Array;
|
|
45
|
+
cliff: Uint8Array;
|
|
46
|
+
cliff_amount: Uint8Array;
|
|
47
|
+
cancelable_by_sender: number;
|
|
48
|
+
cancelable_by_recipient: number;
|
|
49
|
+
automatic_withdrawal: number;
|
|
50
|
+
transferable_by_sender: number;
|
|
51
|
+
transferable_by_recipient: number;
|
|
52
|
+
can_topup: number;
|
|
53
|
+
stream_name: Uint8Array;
|
|
54
|
+
withdraw_frequency: Uint8Array;
|
|
55
|
+
}
|
|
56
|
+
export interface ICreateUncheckedStreamLayout {
|
|
57
|
+
start_time: Uint8Array;
|
|
58
|
+
net_amount_deposited: Uint8Array;
|
|
59
|
+
period: Uint8Array;
|
|
60
|
+
amount_per_period: Uint8Array;
|
|
61
|
+
cliff: Uint8Array;
|
|
62
|
+
cliff_amount: Uint8Array;
|
|
63
|
+
cancelable_by_sender: number;
|
|
64
|
+
cancelable_by_recipient: number;
|
|
65
|
+
automatic_withdrawal: number;
|
|
66
|
+
transferable_by_sender: number;
|
|
67
|
+
transferable_by_recipient: number;
|
|
68
|
+
can_topup: number;
|
|
69
|
+
stream_name: Uint8Array;
|
|
70
|
+
withdraw_frequency: Uint8Array;
|
|
71
|
+
recipient: Uint8Array;
|
|
72
|
+
partner: Uint8Array;
|
|
73
|
+
pausable: number;
|
|
74
|
+
can_update_rate: number;
|
|
75
|
+
}
|
|
76
|
+
export interface IWithdrawStreamLayout {
|
|
77
|
+
amount: Uint8Array;
|
|
78
|
+
}
|
|
79
|
+
export interface ITopupStreamLayout {
|
|
80
|
+
amount: Uint8Array;
|
|
81
|
+
}
|
package/dist/instructions.d.ts
CHANGED
|
@@ -127,7 +127,5 @@ interface TopupAccounts {
|
|
|
127
127
|
systemProgram: PublicKey;
|
|
128
128
|
}
|
|
129
129
|
export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction;
|
|
130
|
-
export declare const syncNativeInstructionData: import("@solana/buffer-layout").Structure<any>;
|
|
131
|
-
export declare const createSyncNativeInstruction: (account: PublicKey) => TransactionInstruction;
|
|
132
130
|
export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
|
|
133
131
|
export {};
|