@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,362 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
var aptos_1 = require("aptos");
|
|
55
|
-
var BaseStreamClient_1 = require("../common/BaseStreamClient");
|
|
56
|
-
var types_1 = require("../common/types");
|
|
57
|
-
var constants_1 = require("./constants");
|
|
58
|
-
var types_2 = require("./types");
|
|
59
|
-
var AptosStreamClient = /** @class */ (function (_super) {
|
|
60
|
-
__extends(AptosStreamClient, _super);
|
|
61
|
-
function AptosStreamClient(clusterUrl, cluster, maxGas, programId) {
|
|
62
|
-
if (cluster === void 0) { cluster = types_1.ICluster.Mainnet; }
|
|
63
|
-
if (maxGas === void 0) { maxGas = "10000"; }
|
|
64
|
-
var _this = _super.call(this) || this;
|
|
65
|
-
_this.programId = programId ? programId : constants_1.APTOS_PROGRAM_IDS[cluster];
|
|
66
|
-
_this.maxGas = maxGas;
|
|
67
|
-
_this.client = new aptos_1.AptosClient(clusterUrl);
|
|
68
|
-
return _this;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Creates a new stream/vesting contract.
|
|
72
|
-
*/
|
|
73
|
-
AptosStreamClient.prototype.create = function (streamData, _a) {
|
|
74
|
-
var senderWallet = _a.senderWallet;
|
|
75
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var acc, seeds, payload, hash;
|
|
77
|
-
return __generator(this, function (_b) {
|
|
78
|
-
switch (_b.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
acc = new aptos_1.AptosAccount();
|
|
81
|
-
seeds = acc.address().hex();
|
|
82
|
-
payload = {
|
|
83
|
-
type: "create",
|
|
84
|
-
function: "".concat(this.programId, "::protocol::create"),
|
|
85
|
-
type_arguments: [streamData.tokenId],
|
|
86
|
-
arguments: [
|
|
87
|
-
seeds,
|
|
88
|
-
streamData.amount.toString(),
|
|
89
|
-
streamData.period,
|
|
90
|
-
streamData.amountPerPeriod.toString(),
|
|
91
|
-
streamData.start,
|
|
92
|
-
streamData.cliffAmount.toString(),
|
|
93
|
-
streamData.cancelableBySender,
|
|
94
|
-
streamData.cancelableByRecipient,
|
|
95
|
-
streamData.transferableBySender,
|
|
96
|
-
streamData.transferableByRecipient,
|
|
97
|
-
streamData.canTopup,
|
|
98
|
-
streamData.canPause || false,
|
|
99
|
-
streamData.canUpdateRate || false,
|
|
100
|
-
streamData.automaticWithdrawal || false,
|
|
101
|
-
streamData.withdrawalFrequency || 0,
|
|
102
|
-
streamData.name,
|
|
103
|
-
streamData.recipient,
|
|
104
|
-
],
|
|
105
|
-
};
|
|
106
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
107
|
-
case 1:
|
|
108
|
-
hash = (_b.sent()).hash;
|
|
109
|
-
return [2 /*return*/, { txId: hash }];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Creates multiple stream/vesting contracts.
|
|
116
|
-
*/
|
|
117
|
-
AptosStreamClient.prototype.createMultiple = function (multipleStreamData, _a) {
|
|
118
|
-
var _b;
|
|
119
|
-
var senderWallet = _a.senderWallet;
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var payloads, txs, metadatas, metadataToRecipient, errors, i, payload, recipient, hash, e_1, metadataId;
|
|
122
|
-
return __generator(this, function (_c) {
|
|
123
|
-
switch (_c.label) {
|
|
124
|
-
case 0:
|
|
125
|
-
payloads = this.generateMultiPayloads(multipleStreamData);
|
|
126
|
-
txs = [];
|
|
127
|
-
metadatas = [];
|
|
128
|
-
metadataToRecipient = {};
|
|
129
|
-
errors = [];
|
|
130
|
-
i = 0;
|
|
131
|
-
_c.label = 1;
|
|
132
|
-
case 1:
|
|
133
|
-
if (!(i < payloads.length)) return [3 /*break*/, 7];
|
|
134
|
-
payload = payloads[i];
|
|
135
|
-
recipient = multipleStreamData.recipients[i];
|
|
136
|
-
_c.label = 2;
|
|
137
|
-
case 2:
|
|
138
|
-
_c.trys.push([2, 4, 5, 6]);
|
|
139
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
140
|
-
case 3:
|
|
141
|
-
hash = (_c.sent()).hash;
|
|
142
|
-
txs.push(hash);
|
|
143
|
-
return [3 /*break*/, 6];
|
|
144
|
-
case 4:
|
|
145
|
-
e_1 = _c.sent();
|
|
146
|
-
errors.push({
|
|
147
|
-
error: (_b = e_1 === null || e_1 === void 0 ? void 0 : e_1.toString()) !== null && _b !== void 0 ? _b : "Unkown error!",
|
|
148
|
-
recipient: recipient.recipient,
|
|
149
|
-
});
|
|
150
|
-
return [3 /*break*/, 6];
|
|
151
|
-
case 5:
|
|
152
|
-
metadataId = payload.arguments[0];
|
|
153
|
-
metadatas.push(metadataId);
|
|
154
|
-
metadataToRecipient[metadataId] = recipient;
|
|
155
|
-
return [7 /*endfinally*/];
|
|
156
|
-
case 6:
|
|
157
|
-
i++;
|
|
158
|
-
return [3 /*break*/, 1];
|
|
159
|
-
case 7: return [2 /*return*/, {
|
|
160
|
-
txs: txs,
|
|
161
|
-
metadatas: metadatas,
|
|
162
|
-
metadataToRecipient: metadataToRecipient,
|
|
163
|
-
errors: errors,
|
|
164
|
-
}];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Attempts withdrawing from the specified stream.
|
|
171
|
-
*/
|
|
172
|
-
AptosStreamClient.prototype.withdraw = function (withdrawData, _a) {
|
|
173
|
-
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
174
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
-
var payload, hash;
|
|
176
|
-
return __generator(this, function (_b) {
|
|
177
|
-
switch (_b.label) {
|
|
178
|
-
case 0:
|
|
179
|
-
payload = {
|
|
180
|
-
type: "withdraw",
|
|
181
|
-
function: "".concat(this.programId, "::protocol::withdraw"),
|
|
182
|
-
type_arguments: [tokenId],
|
|
183
|
-
arguments: [withdrawData.id, withdrawData.amount.toString()],
|
|
184
|
-
};
|
|
185
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
186
|
-
case 1:
|
|
187
|
-
hash = (_b.sent()).hash;
|
|
188
|
-
return [2 /*return*/, { txId: hash }];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Attempts canceling the specified stream.
|
|
195
|
-
*/
|
|
196
|
-
AptosStreamClient.prototype.cancel = function (cancelData, _a) {
|
|
197
|
-
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
198
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
-
var payload, hash;
|
|
200
|
-
return __generator(this, function (_b) {
|
|
201
|
-
switch (_b.label) {
|
|
202
|
-
case 0:
|
|
203
|
-
payload = {
|
|
204
|
-
type: "cancel",
|
|
205
|
-
function: "".concat(this.programId, "::protocol::cancel"),
|
|
206
|
-
type_arguments: [tokenId],
|
|
207
|
-
arguments: [cancelData.id],
|
|
208
|
-
};
|
|
209
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
210
|
-
case 1:
|
|
211
|
-
hash = (_b.sent()).hash;
|
|
212
|
-
return [2 /*return*/, { txId: hash }];
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
219
|
-
*/
|
|
220
|
-
AptosStreamClient.prototype.transfer = function (transferData, _a) {
|
|
221
|
-
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
222
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
223
|
-
var payload, hash;
|
|
224
|
-
return __generator(this, function (_b) {
|
|
225
|
-
switch (_b.label) {
|
|
226
|
-
case 0:
|
|
227
|
-
payload = {
|
|
228
|
-
type: "transfer",
|
|
229
|
-
function: "".concat(this.programId, "::protocol::transfer"),
|
|
230
|
-
type_arguments: [tokenId],
|
|
231
|
-
arguments: [transferData.id, transferData.newRecipient],
|
|
232
|
-
};
|
|
233
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
234
|
-
case 1:
|
|
235
|
-
hash = (_b.sent()).hash;
|
|
236
|
-
return [2 /*return*/, { txId: hash }];
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* Tops up stream account with specified amount.
|
|
243
|
-
*/
|
|
244
|
-
AptosStreamClient.prototype.topup = function (topupData, _a) {
|
|
245
|
-
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
246
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
-
var payload, hash;
|
|
248
|
-
return __generator(this, function (_b) {
|
|
249
|
-
switch (_b.label) {
|
|
250
|
-
case 0:
|
|
251
|
-
payload = {
|
|
252
|
-
type: "topup",
|
|
253
|
-
function: "".concat(this.programId, "::protocol::topup"),
|
|
254
|
-
type_arguments: [tokenId],
|
|
255
|
-
arguments: [topupData.id, topupData.amount.toString()],
|
|
256
|
-
};
|
|
257
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
258
|
-
case 1:
|
|
259
|
-
hash = (_b.sent()).hash;
|
|
260
|
-
return [2 /*return*/, { txId: hash }];
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Fetch stream data by its id (address).
|
|
267
|
-
*/
|
|
268
|
-
AptosStreamClient.prototype.getOne = function (_a) {
|
|
269
|
-
var _b;
|
|
270
|
-
var id = _a.id;
|
|
271
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
-
var contractResources, contract, tokenIdMatch, tokenId, data;
|
|
273
|
-
return __generator(this, function (_c) {
|
|
274
|
-
switch (_c.label) {
|
|
275
|
-
case 0: return [4 /*yield*/, this.client.getAccountResources(id)];
|
|
276
|
-
case 1:
|
|
277
|
-
contractResources = _c.sent();
|
|
278
|
-
contract = contractResources.find(function (r) { return r.type.includes("protocol::Contract"); });
|
|
279
|
-
if (!contract) {
|
|
280
|
-
throw new Error("Contract with id ".concat(id, " could not be found!"));
|
|
281
|
-
}
|
|
282
|
-
tokenIdMatch = contract.type.match(/0x[0-9a-f]+::protocol::Contract<(.*)>/);
|
|
283
|
-
tokenId = (_b = tokenIdMatch === null || tokenIdMatch === void 0 ? void 0 : tokenIdMatch[1]) !== null && _b !== void 0 ? _b : "";
|
|
284
|
-
data = contract.data;
|
|
285
|
-
return [2 /*return*/, new types_2.Contract(data, tokenId)];
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* Attempts updating the stream auto withdrawal params and amount per period
|
|
292
|
-
*/
|
|
293
|
-
AptosStreamClient.prototype.update = function (updateData, _a) {
|
|
294
|
-
var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
|
|
295
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
var payload, hash;
|
|
297
|
-
return __generator(this, function (_b) {
|
|
298
|
-
switch (_b.label) {
|
|
299
|
-
case 0:
|
|
300
|
-
payload = {
|
|
301
|
-
type: "update",
|
|
302
|
-
function: "".concat(this.programId, "::protocol::update"),
|
|
303
|
-
type_arguments: [tokenId],
|
|
304
|
-
arguments: [
|
|
305
|
-
updateData.id,
|
|
306
|
-
updateData.enableAutomaticWithdrawal ? [true] : [],
|
|
307
|
-
updateData.withdrawFrequency ? [updateData.withdrawFrequency.toString()] : [],
|
|
308
|
-
updateData.amountPerPeriod ? [updateData.amountPerPeriod.toString()] : [],
|
|
309
|
-
],
|
|
310
|
-
};
|
|
311
|
-
return [4 /*yield*/, senderWallet.signAndSubmitTransaction(payload)];
|
|
312
|
-
case 1:
|
|
313
|
-
hash = (_b.sent()).hash;
|
|
314
|
-
return [2 /*return*/, { txId: hash }];
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* Returns StreamClient protocol program ID.
|
|
321
|
-
*/
|
|
322
|
-
AptosStreamClient.prototype.getProgramId = function () {
|
|
323
|
-
return this.programId;
|
|
324
|
-
};
|
|
325
|
-
AptosStreamClient.prototype.getMaxGas = function () {
|
|
326
|
-
return { max_gas_amount: this.maxGas };
|
|
327
|
-
};
|
|
328
|
-
// Utility function to prepare transaction payloads for multiple recipients.
|
|
329
|
-
AptosStreamClient.prototype.generateMultiPayloads = function (multipleStreamData) {
|
|
330
|
-
var _this = this;
|
|
331
|
-
return multipleStreamData.recipients.map(function (recipient) {
|
|
332
|
-
var acc = new aptos_1.AptosAccount(); // Generate random address as seeds for derriving "escrow" account
|
|
333
|
-
var seeds = acc.address().hex();
|
|
334
|
-
return {
|
|
335
|
-
type: "create",
|
|
336
|
-
function: "".concat(_this.programId, "::protocol::create"),
|
|
337
|
-
type_arguments: [multipleStreamData.tokenId],
|
|
338
|
-
arguments: [
|
|
339
|
-
seeds,
|
|
340
|
-
recipient.amount.toString(),
|
|
341
|
-
multipleStreamData.period,
|
|
342
|
-
recipient.amountPerPeriod.toString(),
|
|
343
|
-
multipleStreamData.start,
|
|
344
|
-
recipient.cliffAmount.toString(),
|
|
345
|
-
multipleStreamData.cancelableBySender,
|
|
346
|
-
multipleStreamData.cancelableByRecipient,
|
|
347
|
-
multipleStreamData.transferableBySender,
|
|
348
|
-
multipleStreamData.transferableByRecipient,
|
|
349
|
-
multipleStreamData.canTopup,
|
|
350
|
-
multipleStreamData.canPause || false,
|
|
351
|
-
multipleStreamData.canUpdateRate || false,
|
|
352
|
-
multipleStreamData.automaticWithdrawal || false,
|
|
353
|
-
multipleStreamData.withdrawalFrequency || 0,
|
|
354
|
-
recipient.name,
|
|
355
|
-
recipient.recipient,
|
|
356
|
-
],
|
|
357
|
-
};
|
|
358
|
-
});
|
|
359
|
-
};
|
|
360
|
-
return AptosStreamClient;
|
|
361
|
-
}(BaseStreamClient_1.BaseStreamClient));
|
|
362
|
-
exports.default = AptosStreamClient;
|
package/dist/aptos/constants.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
// TODO: Add a correct programID for Test net
|
|
9
|
-
_a[types_1.ICluster.Devnet] = "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
|
|
10
|
-
_a[types_1.ICluster.Testnet] = "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
|
|
11
|
-
_a[types_1.ICluster.Local] = "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
|
|
12
|
-
_a);
|
package/dist/aptos/index.d.ts
DELETED
package/dist/aptos/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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.AptosStreamClient = 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, "AptosStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
|
|
24
|
-
__exportStar(require("./types"), exports);
|
package/dist/aptos/types.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
|
|
2
|
-
import BN from "bn.js";
|
|
3
|
-
import { IRecipient } from "../common/types";
|
|
4
|
-
export interface ICreateStreamAptosExt {
|
|
5
|
-
senderWallet: WalletContextState;
|
|
6
|
-
}
|
|
7
|
-
declare type MetadataId = string;
|
|
8
|
-
export interface CreateMultiError {
|
|
9
|
-
recipient: string;
|
|
10
|
-
error: string;
|
|
11
|
-
}
|
|
12
|
-
export interface IMultiTransactionResult {
|
|
13
|
-
txs: string[];
|
|
14
|
-
metadatas: MetadataId[];
|
|
15
|
-
metadataToRecipient: Record<MetadataId, IRecipient>;
|
|
16
|
-
errors: CreateMultiError[];
|
|
17
|
-
}
|
|
18
|
-
export interface ITransactionResult {
|
|
19
|
-
txId: string;
|
|
20
|
-
}
|
|
21
|
-
export declare type ITransactionAptosExt = ICreateStreamAptosExt & {
|
|
22
|
-
tokenId: string;
|
|
23
|
-
};
|
|
24
|
-
export interface StreamResource {
|
|
25
|
-
amount: string;
|
|
26
|
-
amount_per_period: string;
|
|
27
|
-
canceled_at: string;
|
|
28
|
-
cliff_amount: string;
|
|
29
|
-
closed: boolean;
|
|
30
|
-
contract_signer_cap: {
|
|
31
|
-
account: string;
|
|
32
|
-
};
|
|
33
|
-
created: string;
|
|
34
|
-
current_pause_start: string;
|
|
35
|
-
end: string;
|
|
36
|
-
fees: {
|
|
37
|
-
streamflow_fee: string;
|
|
38
|
-
streamflow_fee_percentage: string;
|
|
39
|
-
streamflow_fee_withdrawn: string;
|
|
40
|
-
};
|
|
41
|
-
funds_unlocked_at_last_rate_change: string;
|
|
42
|
-
last_rate_change_time: string;
|
|
43
|
-
last_withdrawn_at: string;
|
|
44
|
-
meta: {
|
|
45
|
-
automatic_withdrawal: boolean;
|
|
46
|
-
can_topup: boolean;
|
|
47
|
-
can_update_rate: boolean;
|
|
48
|
-
cancelable_by_recipient: boolean;
|
|
49
|
-
cancelable_by_sender: boolean;
|
|
50
|
-
contract_name: string;
|
|
51
|
-
pausable: boolean;
|
|
52
|
-
transferable_by_recipient: boolean;
|
|
53
|
-
transferable_by_sender: boolean;
|
|
54
|
-
withdrawal_frequency: string;
|
|
55
|
-
};
|
|
56
|
-
pause_cumulative: string;
|
|
57
|
-
period: string;
|
|
58
|
-
recipient: string;
|
|
59
|
-
sender: string;
|
|
60
|
-
start: string;
|
|
61
|
-
withdrawn: string;
|
|
62
|
-
}
|
|
63
|
-
export interface Stream {
|
|
64
|
-
magic: number;
|
|
65
|
-
version: number;
|
|
66
|
-
createdAt: number;
|
|
67
|
-
withdrawnAmount: BN;
|
|
68
|
-
canceledAt: number;
|
|
69
|
-
end: number;
|
|
70
|
-
lastWithdrawnAt: number;
|
|
71
|
-
sender: string;
|
|
72
|
-
senderTokens: string;
|
|
73
|
-
recipient: string;
|
|
74
|
-
recipientTokens: string;
|
|
75
|
-
mint: string;
|
|
76
|
-
escrowTokens: string;
|
|
77
|
-
streamflowTreasury: string;
|
|
78
|
-
streamflowTreasuryTokens: string;
|
|
79
|
-
streamflowFeeTotal: BN;
|
|
80
|
-
streamflowFeeWithdrawn: BN;
|
|
81
|
-
streamflowFeePercent: number;
|
|
82
|
-
partnerFeeTotal: BN;
|
|
83
|
-
partnerFeeWithdrawn: BN;
|
|
84
|
-
partnerFeePercent: number;
|
|
85
|
-
partner: string;
|
|
86
|
-
partnerTokens: string;
|
|
87
|
-
start: number;
|
|
88
|
-
depositedAmount: BN;
|
|
89
|
-
period: number;
|
|
90
|
-
amountPerPeriod: BN;
|
|
91
|
-
cliff: number;
|
|
92
|
-
cliffAmount: BN;
|
|
93
|
-
cancelableBySender: boolean;
|
|
94
|
-
cancelableByRecipient: boolean;
|
|
95
|
-
automaticWithdrawal: boolean;
|
|
96
|
-
transferableBySender: boolean;
|
|
97
|
-
transferableByRecipient: boolean;
|
|
98
|
-
canTopup: boolean;
|
|
99
|
-
name: string;
|
|
100
|
-
withdrawalFrequency: number;
|
|
101
|
-
unlocked(currentTimestamp: number, decimals: number): number;
|
|
102
|
-
}
|
|
103
|
-
export declare class Contract implements Stream {
|
|
104
|
-
magic: number;
|
|
105
|
-
version: number;
|
|
106
|
-
createdAt: number;
|
|
107
|
-
withdrawnAmount: BN;
|
|
108
|
-
canceledAt: number;
|
|
109
|
-
end: number;
|
|
110
|
-
lastWithdrawnAt: number;
|
|
111
|
-
sender: string;
|
|
112
|
-
senderTokens: string;
|
|
113
|
-
recipient: string;
|
|
114
|
-
recipientTokens: string;
|
|
115
|
-
mint: string;
|
|
116
|
-
escrowTokens: string;
|
|
117
|
-
streamflowTreasury: string;
|
|
118
|
-
streamflowTreasuryTokens: string;
|
|
119
|
-
streamflowFeeTotal: BN;
|
|
120
|
-
streamflowFeeWithdrawn: BN;
|
|
121
|
-
streamflowFeePercent: number;
|
|
122
|
-
partnerFeeTotal: BN;
|
|
123
|
-
partnerFeeWithdrawn: BN;
|
|
124
|
-
partnerFeePercent: number;
|
|
125
|
-
partner: string;
|
|
126
|
-
partnerTokens: string;
|
|
127
|
-
start: number;
|
|
128
|
-
depositedAmount: BN;
|
|
129
|
-
period: number;
|
|
130
|
-
amountPerPeriod: BN;
|
|
131
|
-
cliff: number;
|
|
132
|
-
cliffAmount: BN;
|
|
133
|
-
cancelableBySender: boolean;
|
|
134
|
-
cancelableByRecipient: boolean;
|
|
135
|
-
automaticWithdrawal: boolean;
|
|
136
|
-
transferableBySender: boolean;
|
|
137
|
-
transferableByRecipient: boolean;
|
|
138
|
-
canTopup: boolean;
|
|
139
|
-
name: string;
|
|
140
|
-
withdrawalFrequency: number;
|
|
141
|
-
constructor(stream: StreamResource, tokenId: string);
|
|
142
|
-
unlocked(currentTimestamp: number, decimals: number): number;
|
|
143
|
-
remaining(decimals: number): number;
|
|
144
|
-
}
|
|
145
|
-
export {};
|
package/dist/aptos/types.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Contract = void 0;
|
|
7
|
-
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
-
var utils_1 = require("../common/utils");
|
|
9
|
-
var Contract = /** @class */ (function () {
|
|
10
|
-
function Contract(stream, tokenId) {
|
|
11
|
-
this.magic = 0;
|
|
12
|
-
this.version = 0;
|
|
13
|
-
this.createdAt = parseInt(stream.created);
|
|
14
|
-
this.withdrawnAmount = new bn_js_1.default(stream.withdrawn);
|
|
15
|
-
this.canceledAt = parseInt(stream.canceled_at);
|
|
16
|
-
this.end = parseInt(stream.end);
|
|
17
|
-
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
18
|
-
this.sender = stream.sender;
|
|
19
|
-
this.senderTokens = stream.sender;
|
|
20
|
-
this.recipient = stream.recipient;
|
|
21
|
-
this.recipientTokens = stream.recipient;
|
|
22
|
-
this.mint = tokenId;
|
|
23
|
-
this.escrowTokens = "";
|
|
24
|
-
this.streamflowTreasury = "";
|
|
25
|
-
this.streamflowTreasuryTokens = "";
|
|
26
|
-
this.streamflowFeeTotal = new bn_js_1.default(0);
|
|
27
|
-
this.streamflowFeeWithdrawn = new bn_js_1.default(0);
|
|
28
|
-
this.streamflowFeePercent = parseInt(stream.fees.streamflow_fee_percentage) / 10000;
|
|
29
|
-
this.partnerFeeTotal = new bn_js_1.default(0);
|
|
30
|
-
this.partnerFeeWithdrawn = new bn_js_1.default(0);
|
|
31
|
-
this.partnerFeePercent = 0;
|
|
32
|
-
this.partner = "";
|
|
33
|
-
this.partnerTokens = "";
|
|
34
|
-
this.start = parseInt(stream.start);
|
|
35
|
-
this.depositedAmount = new bn_js_1.default(stream.amount);
|
|
36
|
-
this.period = parseInt(stream.period);
|
|
37
|
-
this.amountPerPeriod = new bn_js_1.default(stream.amount_per_period);
|
|
38
|
-
this.cliff = parseInt(stream.start);
|
|
39
|
-
this.cliffAmount = new bn_js_1.default(stream.cliff_amount);
|
|
40
|
-
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
41
|
-
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
42
|
-
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
43
|
-
this.transferableBySender = stream.meta.transferable_by_sender;
|
|
44
|
-
this.transferableByRecipient = stream.meta.transferable_by_recipient;
|
|
45
|
-
this.canTopup = stream.meta.can_topup;
|
|
46
|
-
var name = stream.meta.contract_name.replace("0x", "");
|
|
47
|
-
this.name = Buffer.from(name, "hex").toString("utf8");
|
|
48
|
-
this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
|
|
49
|
-
}
|
|
50
|
-
Contract.prototype.unlocked = function (currentTimestamp, decimals) {
|
|
51
|
-
var deposited = (0, utils_1.getNumberFromBN)(this.depositedAmount, decimals);
|
|
52
|
-
if (currentTimestamp < this.cliff)
|
|
53
|
-
return 0;
|
|
54
|
-
if (currentTimestamp > this.end)
|
|
55
|
-
return deposited;
|
|
56
|
-
var streamedBN = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
57
|
-
var streamed = (0, utils_1.getNumberFromBN)(streamedBN, decimals);
|
|
58
|
-
return streamed < deposited ? streamed : deposited;
|
|
59
|
-
};
|
|
60
|
-
Contract.prototype.remaining = function (decimals) {
|
|
61
|
-
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
62
|
-
};
|
|
63
|
-
return Contract;
|
|
64
|
-
}());
|
|
65
|
-
exports.Contract = Contract;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ICreateStreamData, ICreateMultipleStreamData, IWithdrawData, ICancelData, ITransferData, ITopUpData, IGetOneData, IUpdateData } from "./types";
|
|
2
|
-
export declare abstract class BaseStreamClient {
|
|
3
|
-
protected abstract create(streamData: ICreateStreamData, chainSpecificParams: any): Promise<any>;
|
|
4
|
-
protected abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: any): Promise<any>;
|
|
5
|
-
protected abstract withdraw(withdrawData: IWithdrawData, chainSpecificParams: any): Promise<any>;
|
|
6
|
-
protected abstract cancel(cancelData: ICancelData, chainSpecificParams: any): Promise<any>;
|
|
7
|
-
protected abstract transfer(transferData: ITransferData, chainSpecificParams: any): Promise<any>;
|
|
8
|
-
protected abstract topup(topupData: ITopUpData, chainSpecificParams: any): Promise<any>;
|
|
9
|
-
protected abstract getOne(getOneData: IGetOneData, chainSpecificParams: any): Promise<any>;
|
|
10
|
-
protected abstract update(updateData: IUpdateData, chainSpecificParams: any): Promise<any>;
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseStreamClient = void 0;
|
|
4
|
-
var BaseStreamClient = /** @class */ (function () {
|
|
5
|
-
function BaseStreamClient() {
|
|
6
|
-
}
|
|
7
|
-
return BaseStreamClient;
|
|
8
|
-
}());
|
|
9
|
-
exports.BaseStreamClient = BaseStreamClient;
|