@streamflow/stream 5.6.0 → 5.6.2
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/LICENSE +674 -0
- package/package.json +5 -6
- package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
- package/dist/__tests__/aptos/streamClient.spec.js +0 -161
- package/dist/aptos/StreamClient.d.ts +0 -51
- package/dist/aptos/StreamClient.js +0 -387
- package/dist/aptos/constants.d.ts +0 -8
- package/dist/aptos/constants.js +0 -28
- package/dist/aptos/index.d.ts +0 -2
- package/dist/aptos/index.js +0 -24
- package/dist/aptos/types.d.ts +0 -97
- package/dist/aptos/types.js +0 -76
- package/dist/aptos/utils.d.ts +0 -1
- package/dist/aptos/utils.js +0 -12
- package/dist/aptos/wallet.d.ts +0 -9
- package/dist/aptos/wallet.js +0 -89
- package/dist/common/BaseStreamClient.d.ts +0 -13
- package/dist/common/BaseStreamClient.js +0 -13
- package/dist/common/GenericStreamClient.d.ts +0 -93
- package/dist/common/GenericStreamClient.js +0 -114
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +0 -4
- package/dist/common/contractUtils.d.ts +0 -47
- package/dist/common/contractUtils.js +0 -55
- package/dist/common/types.d.ts +0 -252
- package/dist/common/types.js +0 -165
- package/dist/common/utils.d.ts +0 -22
- package/dist/common/utils.js +0 -101
- package/dist/evm/StreamClient.d.ts +0 -30
- package/dist/evm/StreamClient.js +0 -461
- package/dist/evm/abi.d.ts +0 -111
- package/dist/evm/abi.js +0 -1257
- package/dist/evm/constants.d.ts +0 -20
- package/dist/evm/constants.js +0 -39
- package/dist/evm/ercAbi.d.ts +0 -39
- package/dist/evm/ercAbi.js +0 -224
- package/dist/evm/index.d.ts +0 -2
- package/dist/evm/index.js +0 -24
- package/dist/evm/types.d.ts +0 -93
- package/dist/evm/types.js +0 -75
- package/dist/evm/utils.d.ts +0 -1
- package/dist/evm/utils.js +0 -12
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -41
- package/dist/solana/StreamClient.d.ts +0 -72
- package/dist/solana/StreamClient.js +0 -927
- package/dist/solana/constants.d.ts +0 -22
- package/dist/solana/constants.js +0 -50
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/solana/instructionTypes.d.ts +0 -96
- package/dist/solana/instructionTypes.js +0 -2
- package/dist/solana/instructions.d.ts +0 -139
- package/dist/solana/instructions.js +0 -407
- package/dist/solana/layout.d.ts +0 -27
- package/dist/solana/layout.js +0 -170
- package/dist/solana/timelockIDL.d.ts +0 -22
- package/dist/solana/timelockIDL.js +0 -422
- package/dist/solana/types.d.ts +0 -292
- package/dist/solana/types.js +0 -81
- package/dist/solana/utils.d.ts +0 -44
- package/dist/solana/utils.js +0 -303
- package/dist/sui/StreamClient.d.ts +0 -79
- package/dist/sui/StreamClient.js +0 -571
- package/dist/sui/constants.d.ts +0 -10
- package/dist/sui/constants.js +0 -43
- package/dist/sui/index.d.ts +0 -2
- package/dist/sui/index.js +0 -23
- package/dist/sui/types.d.ts +0 -141
- package/dist/sui/types.js +0 -102
- package/dist/sui/utils.d.ts +0 -2
- package/dist/sui/utils.js +0 -29
- package/dist/sui/wallet.d.ts +0 -11
- package/dist/sui/wallet.js +0 -75
package/dist/evm/StreamClient.js
DELETED
|
@@ -1,461 +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 __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (_) try {
|
|
44
|
-
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;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
65
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66
|
-
if (!m) return o;
|
|
67
|
-
var i = m.call(o), r, ar = [], e;
|
|
68
|
-
try {
|
|
69
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
70
|
-
}
|
|
71
|
-
catch (error) { e = { error: error }; }
|
|
72
|
-
finally {
|
|
73
|
-
try {
|
|
74
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
75
|
-
}
|
|
76
|
-
finally { if (e) throw e.error; }
|
|
77
|
-
}
|
|
78
|
-
return ar;
|
|
79
|
-
};
|
|
80
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
81
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
82
|
-
if (ar || !(i in from)) {
|
|
83
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
84
|
-
ar[i] = from[i];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
88
|
-
};
|
|
89
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
90
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
91
|
-
};
|
|
92
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
|
-
var ethers_1 = require("ethers");
|
|
94
|
-
var bn_js_1 = __importDefault(require("bn.js"));
|
|
95
|
-
var ethereum_checksum_address_1 = require("ethereum-checksum-address");
|
|
96
|
-
var BaseStreamClient_1 = require("../common/BaseStreamClient");
|
|
97
|
-
var types_1 = require("../common/types");
|
|
98
|
-
var constants_1 = require("./constants");
|
|
99
|
-
var abi_1 = __importDefault(require("./abi"));
|
|
100
|
-
var ercAbi_1 = __importDefault(require("./ercAbi"));
|
|
101
|
-
var constants_2 = require("../common/constants");
|
|
102
|
-
var types_2 = require("./types");
|
|
103
|
-
var utils_1 = require("./utils");
|
|
104
|
-
var EvmStreamClient = /** @class */ (function (_super) {
|
|
105
|
-
__extends(EvmStreamClient, _super);
|
|
106
|
-
function EvmStreamClient(clusterUrl, chain, signer, cluster, programId) {
|
|
107
|
-
if (cluster === void 0) { cluster = types_1.ICluster.Mainnet; }
|
|
108
|
-
var _this = _super.call(this) || this;
|
|
109
|
-
if (chain !== types_1.IChain.Ethereum && chain !== types_1.IChain.BNB && chain !== types_1.IChain.Polygon) {
|
|
110
|
-
throw new Error("Wrong chain. Supported chains are Ethereum , BNB and Polygon!");
|
|
111
|
-
}
|
|
112
|
-
if (programId) {
|
|
113
|
-
_this.programId = programId;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
switch (chain) {
|
|
117
|
-
case types_1.IChain.Ethereum:
|
|
118
|
-
_this.programId = constants_1.ETHEREUM_PROGRAM_IDS[cluster];
|
|
119
|
-
break;
|
|
120
|
-
case types_1.IChain.BNB:
|
|
121
|
-
_this.programId = constants_1.BNB_PROGRAM_IDS[cluster];
|
|
122
|
-
break;
|
|
123
|
-
case types_1.IChain.Polygon:
|
|
124
|
-
_this.programId = constants_1.POLYGON_PROGRAM_IDS[cluster];
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
_this.provider = new ethers_1.ethers.providers.JsonRpcProvider(clusterUrl);
|
|
129
|
-
_this.signer = signer;
|
|
130
|
-
var baseContract = new ethers_1.ethers.Contract(_this.programId, abi_1.default);
|
|
131
|
-
_this.readContract = baseContract.connect(_this.provider);
|
|
132
|
-
_this.writeContract = baseContract.connect(_this.signer);
|
|
133
|
-
return _this;
|
|
134
|
-
}
|
|
135
|
-
EvmStreamClient.prototype.create = function (streamData) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var multiParams, fees, args, sum, result, confirmedTx, metadataId;
|
|
138
|
-
var _a, _b;
|
|
139
|
-
return __generator(this, function (_c) {
|
|
140
|
-
switch (_c.label) {
|
|
141
|
-
case 0:
|
|
142
|
-
multiParams = __assign(__assign({}, streamData), { recipients: [streamData] });
|
|
143
|
-
return [4 /*yield*/, (_a = this.readContract).getWithdrawalFees.apply(_a, __spreadArray([], __read(this.getFeeParams(multiParams)), false))];
|
|
144
|
-
case 1:
|
|
145
|
-
fees = _c.sent();
|
|
146
|
-
return [4 /*yield*/, this.generateMultiPayloads(multiParams)];
|
|
147
|
-
case 2:
|
|
148
|
-
args = (_c.sent())[0];
|
|
149
|
-
sum = streamData.amount.mul(new bn_js_1.default(constants_2.BASE_FEE)).div(new bn_js_1.default(1000000));
|
|
150
|
-
return [4 /*yield*/, this.approveTokens(streamData.tokenId, sum)];
|
|
151
|
-
case 3:
|
|
152
|
-
_c.sent();
|
|
153
|
-
return [4 /*yield*/, (_b = this.writeContract).create.apply(_b, __spreadArray(__spreadArray([], __read(args), false), [{ value: fees.value }], false))];
|
|
154
|
-
case 4:
|
|
155
|
-
result = _c.sent();
|
|
156
|
-
return [4 /*yield*/, result.wait()];
|
|
157
|
-
case 5:
|
|
158
|
-
confirmedTx = _c.sent();
|
|
159
|
-
metadataId = this.formatMetadataId(confirmedTx.events.find(function (item) { return item.event === "ContractCreated"; }).args[0]);
|
|
160
|
-
return [2 /*return*/, {
|
|
161
|
-
ixs: [],
|
|
162
|
-
txId: result.hash,
|
|
163
|
-
metadataId: metadataId,
|
|
164
|
-
}];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
EvmStreamClient.prototype.createMultiple = function (multipleStreamData) {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
-
var fees, args, sum, creationPromises, signatures, results, confirmations, successes, metadatas, metadataToRecipient, failures;
|
|
172
|
-
var _a;
|
|
173
|
-
var _this = this;
|
|
174
|
-
return __generator(this, function (_b) {
|
|
175
|
-
switch (_b.label) {
|
|
176
|
-
case 0: return [4 /*yield*/, (_a = this.readContract).getWithdrawalFees.apply(_a, __spreadArray([], __read(this.getFeeParams(multipleStreamData)), false))];
|
|
177
|
-
case 1:
|
|
178
|
-
fees = _b.sent();
|
|
179
|
-
return [4 /*yield*/, this.generateMultiPayloads(multipleStreamData)];
|
|
180
|
-
case 2:
|
|
181
|
-
args = _b.sent();
|
|
182
|
-
sum = multipleStreamData.recipients
|
|
183
|
-
.reduce(function (acc, v) { return acc.add(v.amount); }, new bn_js_1.default(0))
|
|
184
|
-
.mul(new bn_js_1.default(constants_2.BASE_FEE))
|
|
185
|
-
.div(new bn_js_1.default(1000000));
|
|
186
|
-
return [4 /*yield*/, this.approveTokens(multipleStreamData.tokenId, sum)];
|
|
187
|
-
case 3:
|
|
188
|
-
_b.sent();
|
|
189
|
-
creationPromises = args.map(function (item) {
|
|
190
|
-
var _a;
|
|
191
|
-
return (_a = _this.writeContract).create.apply(_a, __spreadArray(__spreadArray([], __read(item), false), [{ value: fees.value }], false));
|
|
192
|
-
});
|
|
193
|
-
signatures = [];
|
|
194
|
-
return [4 /*yield*/, Promise.all(creationPromises)];
|
|
195
|
-
case 4:
|
|
196
|
-
results = _b.sent();
|
|
197
|
-
return [4 /*yield*/, Promise.allSettled(results.map(function (result) { return result.wait(); }))];
|
|
198
|
-
case 5:
|
|
199
|
-
confirmations = _b.sent();
|
|
200
|
-
successes = confirmations
|
|
201
|
-
.filter(function (el) { return el.status === "fulfilled"; })
|
|
202
|
-
.map(function (el) { return el.value; });
|
|
203
|
-
signatures.push.apply(signatures, __spreadArray([], __read(successes.map(function (el) { return el.hash; })), false));
|
|
204
|
-
metadatas = confirmations.map(function (result) {
|
|
205
|
-
return result.status === "fulfilled"
|
|
206
|
-
? _this.formatMetadataId(result.value.events.find(function (item) { return item.event === "ContractCreated"; })
|
|
207
|
-
.args[0])
|
|
208
|
-
: null;
|
|
209
|
-
});
|
|
210
|
-
metadataToRecipient = metadatas.reduce(function (acc, value, index) {
|
|
211
|
-
if (value) {
|
|
212
|
-
acc[value] = multipleStreamData.recipients[index];
|
|
213
|
-
}
|
|
214
|
-
return acc;
|
|
215
|
-
}, {});
|
|
216
|
-
failures = confirmations
|
|
217
|
-
.filter(function (el) { return el.status === "rejected"; })
|
|
218
|
-
.map(function (el) { return el.reason; });
|
|
219
|
-
return [2 /*return*/, {
|
|
220
|
-
txs: signatures,
|
|
221
|
-
metadatas: metadatas.filter(Boolean),
|
|
222
|
-
metadataToRecipient: metadataToRecipient,
|
|
223
|
-
errors: failures,
|
|
224
|
-
}];
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
EvmStreamClient.prototype.withdraw = function (withdrawData) {
|
|
230
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
-
var result;
|
|
232
|
-
return __generator(this, function (_a) {
|
|
233
|
-
switch (_a.label) {
|
|
234
|
-
case 0: return [4 /*yield*/, this.writeContract.withdraw(withdrawData.id, withdrawData.amount.toString())];
|
|
235
|
-
case 1:
|
|
236
|
-
result = _a.sent();
|
|
237
|
-
return [2 /*return*/, {
|
|
238
|
-
ixs: [],
|
|
239
|
-
txId: result.hash,
|
|
240
|
-
}];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
};
|
|
245
|
-
EvmStreamClient.prototype.cancel = function (cancelData) {
|
|
246
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
-
var result;
|
|
248
|
-
return __generator(this, function (_a) {
|
|
249
|
-
switch (_a.label) {
|
|
250
|
-
case 0: return [4 /*yield*/, this.writeContract.cancel(cancelData.id)];
|
|
251
|
-
case 1:
|
|
252
|
-
result = _a.sent();
|
|
253
|
-
return [2 /*return*/, {
|
|
254
|
-
ixs: [],
|
|
255
|
-
txId: result.hash,
|
|
256
|
-
}];
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
EvmStreamClient.prototype.transfer = function (transferData) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
-
var result;
|
|
264
|
-
return __generator(this, function (_a) {
|
|
265
|
-
switch (_a.label) {
|
|
266
|
-
case 0: return [4 /*yield*/, this.writeContract.transfer(transferData.id, transferData.newRecipient)];
|
|
267
|
-
case 1:
|
|
268
|
-
result = _a.sent();
|
|
269
|
-
return [2 /*return*/, {
|
|
270
|
-
ixs: [],
|
|
271
|
-
txId: result.hash,
|
|
272
|
-
}];
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
};
|
|
277
|
-
EvmStreamClient.prototype.topup = function (topupData) {
|
|
278
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
-
var fees, sum, stream, result;
|
|
280
|
-
return __generator(this, function (_a) {
|
|
281
|
-
switch (_a.label) {
|
|
282
|
-
case 0: return [4 /*yield*/, this.readContract.getTopUpWithdrawalFees(topupData.id, topupData.amount.toString())];
|
|
283
|
-
case 1:
|
|
284
|
-
fees = _a.sent();
|
|
285
|
-
sum = topupData.amount.mul(new bn_js_1.default(constants_2.BASE_FEE)).div(new bn_js_1.default(1000000));
|
|
286
|
-
return [4 /*yield*/, this.getOne({ id: topupData.id })];
|
|
287
|
-
case 2:
|
|
288
|
-
stream = _a.sent();
|
|
289
|
-
return [4 /*yield*/, this.approveTokens(stream.mint, sum)];
|
|
290
|
-
case 3:
|
|
291
|
-
_a.sent();
|
|
292
|
-
return [4 /*yield*/, this.writeContract.topUp(topupData.id, topupData.amount.toString(), {
|
|
293
|
-
value: fees.value,
|
|
294
|
-
})];
|
|
295
|
-
case 4:
|
|
296
|
-
result = _a.sent();
|
|
297
|
-
return [2 /*return*/, {
|
|
298
|
-
ixs: [],
|
|
299
|
-
txId: result.hash,
|
|
300
|
-
}];
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
EvmStreamClient.prototype.update = function (updateData) {
|
|
306
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
-
var result;
|
|
308
|
-
return __generator(this, function (_a) {
|
|
309
|
-
switch (_a.label) {
|
|
310
|
-
case 0: return [4 /*yield*/, this.writeContract.update(updateData.id, updateData.enableAutomaticWithdrawal ? [true] : [], updateData.withdrawFrequency ? [updateData.withdrawFrequency.toString()] : [], updateData.amountPerPeriod ? [updateData.amountPerPeriod.toString()] : [])];
|
|
311
|
-
case 1:
|
|
312
|
-
result = _a.sent();
|
|
313
|
-
return [2 /*return*/, {
|
|
314
|
-
ixs: [],
|
|
315
|
-
txId: result.hash,
|
|
316
|
-
}];
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
EvmStreamClient.prototype.getOne = function (_a) {
|
|
322
|
-
var id = _a.id;
|
|
323
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
324
|
-
var result;
|
|
325
|
-
return __generator(this, function (_b) {
|
|
326
|
-
switch (_b.label) {
|
|
327
|
-
case 0: return [4 /*yield*/, this.readContract.getById(id)];
|
|
328
|
-
case 1:
|
|
329
|
-
result = _b.sent();
|
|
330
|
-
return [2 /*return*/, new types_2.EvmContract(result)];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
};
|
|
335
|
-
EvmStreamClient.prototype.get = function (_a) {
|
|
336
|
-
var address = _a.address,
|
|
337
|
-
// type = StreamType.All,
|
|
338
|
-
_b = _a.direction,
|
|
339
|
-
// type = StreamType.All,
|
|
340
|
-
direction = _b === void 0 ? types_1.StreamDirection.All : _b;
|
|
341
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
342
|
-
var addresses, senderAddresses, recipientAddresses, uniqueAddresses, results;
|
|
343
|
-
return __generator(this, function (_c) {
|
|
344
|
-
switch (_c.label) {
|
|
345
|
-
case 0:
|
|
346
|
-
addresses = [];
|
|
347
|
-
if (!(direction === types_1.StreamDirection.All || direction === types_1.StreamDirection.Outgoing)) return [3 /*break*/, 2];
|
|
348
|
-
return [4 /*yield*/, this.readContract.getBySender(address)];
|
|
349
|
-
case 1:
|
|
350
|
-
senderAddresses = _c.sent();
|
|
351
|
-
addresses.push.apply(addresses, __spreadArray([], __read(senderAddresses), false));
|
|
352
|
-
_c.label = 2;
|
|
353
|
-
case 2:
|
|
354
|
-
if (!(direction === types_1.StreamDirection.All || direction === types_1.StreamDirection.Incoming)) return [3 /*break*/, 4];
|
|
355
|
-
return [4 /*yield*/, this.readContract.getByRecipient(address)];
|
|
356
|
-
case 3:
|
|
357
|
-
recipientAddresses = _c.sent();
|
|
358
|
-
addresses.push.apply(addresses, __spreadArray([], __read(recipientAddresses), false));
|
|
359
|
-
_c.label = 4;
|
|
360
|
-
case 4:
|
|
361
|
-
uniqueAddresses = __spreadArray([], __read(new Set(addresses)), false);
|
|
362
|
-
return [4 /*yield*/, this.readContract.getMultiple(uniqueAddresses)];
|
|
363
|
-
case 5:
|
|
364
|
-
results = _c.sent();
|
|
365
|
-
return [2 /*return*/, results.map(function (result, index) { return [uniqueAddresses[index], new types_2.EvmContract(result)]; })];
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
};
|
|
370
|
-
EvmStreamClient.prototype.extractErrorCode = function (err) {
|
|
371
|
-
var _a;
|
|
372
|
-
return (0, utils_1.extractEvmErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
|
|
373
|
-
};
|
|
374
|
-
/**
|
|
375
|
-
* Returns StreamClient protocol program ID.
|
|
376
|
-
*/
|
|
377
|
-
EvmStreamClient.prototype.getProgramId = function () {
|
|
378
|
-
return this.programId;
|
|
379
|
-
};
|
|
380
|
-
EvmStreamClient.prototype.approveTokens = function (tokenId, amount) {
|
|
381
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
382
|
-
var tokenContract, address, allowance, approvalTx;
|
|
383
|
-
return __generator(this, function (_a) {
|
|
384
|
-
switch (_a.label) {
|
|
385
|
-
case 0:
|
|
386
|
-
tokenContract = new ethers_1.ethers.Contract(tokenId, ercAbi_1.default, this.signer);
|
|
387
|
-
return [4 /*yield*/, this.signer.getAddress()];
|
|
388
|
-
case 1:
|
|
389
|
-
address = _a.sent();
|
|
390
|
-
return [4 /*yield*/, tokenContract.allowance(address, this.programId)];
|
|
391
|
-
case 2:
|
|
392
|
-
allowance = _a.sent();
|
|
393
|
-
if (new bn_js_1.default(allowance.toString()).gte(amount)) {
|
|
394
|
-
return [2 /*return*/];
|
|
395
|
-
}
|
|
396
|
-
return [4 /*yield*/, tokenContract.approve(this.programId, amount.toString())];
|
|
397
|
-
case 3:
|
|
398
|
-
approvalTx = _a.sent();
|
|
399
|
-
return [4 /*yield*/, approvalTx.wait()];
|
|
400
|
-
case 4:
|
|
401
|
-
_a.sent();
|
|
402
|
-
return [2 /*return*/];
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
// Utility function to prepare transaction payloads for multiple recipients.
|
|
408
|
-
EvmStreamClient.prototype.generateMultiPayloads = function (multipleStreamData) {
|
|
409
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
410
|
-
var sender;
|
|
411
|
-
return __generator(this, function (_a) {
|
|
412
|
-
switch (_a.label) {
|
|
413
|
-
case 0: return [4 /*yield*/, this.signer.getAddress()];
|
|
414
|
-
case 1:
|
|
415
|
-
sender = _a.sent();
|
|
416
|
-
return [2 /*return*/, multipleStreamData.recipients.map(function (recipient) {
|
|
417
|
-
return [
|
|
418
|
-
multipleStreamData.tokenId,
|
|
419
|
-
recipient.amount.toString(),
|
|
420
|
-
multipleStreamData.period,
|
|
421
|
-
recipient.amountPerPeriod.toString(),
|
|
422
|
-
multipleStreamData.start,
|
|
423
|
-
recipient.cliffAmount.toString(),
|
|
424
|
-
[
|
|
425
|
-
multipleStreamData.cancelableBySender,
|
|
426
|
-
multipleStreamData.cancelableByRecipient,
|
|
427
|
-
multipleStreamData.transferableBySender,
|
|
428
|
-
multipleStreamData.transferableByRecipient,
|
|
429
|
-
multipleStreamData.canTopup,
|
|
430
|
-
multipleStreamData.canPause || false,
|
|
431
|
-
multipleStreamData.canUpdateRate || false,
|
|
432
|
-
multipleStreamData.automaticWithdrawal || false,
|
|
433
|
-
multipleStreamData.withdrawalFrequency || 0,
|
|
434
|
-
recipient.name,
|
|
435
|
-
],
|
|
436
|
-
recipient.recipient,
|
|
437
|
-
multipleStreamData.partner || sender,
|
|
438
|
-
];
|
|
439
|
-
})];
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
});
|
|
443
|
-
};
|
|
444
|
-
EvmStreamClient.prototype.getFeeParams = function (multipleStreamData) {
|
|
445
|
-
return [
|
|
446
|
-
multipleStreamData.recipients[0].amount.toString(),
|
|
447
|
-
multipleStreamData.period,
|
|
448
|
-
multipleStreamData.recipients[0].amountPerPeriod.toString(),
|
|
449
|
-
multipleStreamData.start,
|
|
450
|
-
multipleStreamData.recipients[0].cliffAmount.toString(),
|
|
451
|
-
multipleStreamData.automaticWithdrawal || false,
|
|
452
|
-
multipleStreamData.withdrawalFrequency || 0,
|
|
453
|
-
];
|
|
454
|
-
};
|
|
455
|
-
EvmStreamClient.prototype.formatMetadataId = function (id) {
|
|
456
|
-
// 40 chars is ethereum address size
|
|
457
|
-
return (0, ethereum_checksum_address_1.toChecksumAddress)("0x".concat(id.slice(-40)));
|
|
458
|
-
};
|
|
459
|
-
return EvmStreamClient;
|
|
460
|
-
}(BaseStreamClient_1.BaseStreamClient));
|
|
461
|
-
exports.default = EvmStreamClient;
|
package/dist/evm/abi.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
declare const _default: ({
|
|
2
|
-
anonymous: boolean;
|
|
3
|
-
inputs: {
|
|
4
|
-
indexed: boolean;
|
|
5
|
-
internalType: string;
|
|
6
|
-
name: string;
|
|
7
|
-
type: string;
|
|
8
|
-
}[];
|
|
9
|
-
name: string;
|
|
10
|
-
type: string;
|
|
11
|
-
outputs?: undefined;
|
|
12
|
-
stateMutability?: undefined;
|
|
13
|
-
} | {
|
|
14
|
-
inputs: ({
|
|
15
|
-
internalType: string;
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
components?: undefined;
|
|
19
|
-
} | {
|
|
20
|
-
components: {
|
|
21
|
-
internalType: string;
|
|
22
|
-
name: string;
|
|
23
|
-
type: string;
|
|
24
|
-
}[];
|
|
25
|
-
internalType: string;
|
|
26
|
-
name: string;
|
|
27
|
-
type: string;
|
|
28
|
-
})[];
|
|
29
|
-
name: string;
|
|
30
|
-
outputs: never[];
|
|
31
|
-
stateMutability: string;
|
|
32
|
-
type: string;
|
|
33
|
-
anonymous?: undefined;
|
|
34
|
-
} | {
|
|
35
|
-
inputs: never[];
|
|
36
|
-
name: string;
|
|
37
|
-
outputs: ({
|
|
38
|
-
internalType: string;
|
|
39
|
-
name: string;
|
|
40
|
-
type: string;
|
|
41
|
-
components?: undefined;
|
|
42
|
-
} | {
|
|
43
|
-
components: ({
|
|
44
|
-
internalType: string;
|
|
45
|
-
name: string;
|
|
46
|
-
type: string;
|
|
47
|
-
components?: undefined;
|
|
48
|
-
} | {
|
|
49
|
-
components: {
|
|
50
|
-
internalType: string;
|
|
51
|
-
name: string;
|
|
52
|
-
type: string;
|
|
53
|
-
}[];
|
|
54
|
-
internalType: string;
|
|
55
|
-
name: string;
|
|
56
|
-
type: string;
|
|
57
|
-
})[];
|
|
58
|
-
internalType: string;
|
|
59
|
-
name: string;
|
|
60
|
-
type: string;
|
|
61
|
-
})[];
|
|
62
|
-
stateMutability: string;
|
|
63
|
-
type: string;
|
|
64
|
-
anonymous?: undefined;
|
|
65
|
-
} | {
|
|
66
|
-
inputs: {
|
|
67
|
-
internalType: string;
|
|
68
|
-
name: string;
|
|
69
|
-
type: string;
|
|
70
|
-
}[];
|
|
71
|
-
name: string;
|
|
72
|
-
outputs: {
|
|
73
|
-
components: ({
|
|
74
|
-
internalType: string;
|
|
75
|
-
name: string;
|
|
76
|
-
type: string;
|
|
77
|
-
components?: undefined;
|
|
78
|
-
} | {
|
|
79
|
-
components: {
|
|
80
|
-
internalType: string;
|
|
81
|
-
name: string;
|
|
82
|
-
type: string;
|
|
83
|
-
}[];
|
|
84
|
-
internalType: string;
|
|
85
|
-
name: string;
|
|
86
|
-
type: string;
|
|
87
|
-
})[];
|
|
88
|
-
internalType: string;
|
|
89
|
-
name: string;
|
|
90
|
-
type: string;
|
|
91
|
-
}[];
|
|
92
|
-
stateMutability: string;
|
|
93
|
-
type: string;
|
|
94
|
-
anonymous?: undefined;
|
|
95
|
-
} | {
|
|
96
|
-
inputs: {
|
|
97
|
-
internalType: string;
|
|
98
|
-
name: string;
|
|
99
|
-
type: string;
|
|
100
|
-
}[];
|
|
101
|
-
name: string;
|
|
102
|
-
outputs: {
|
|
103
|
-
internalType: string;
|
|
104
|
-
name: string;
|
|
105
|
-
type: string;
|
|
106
|
-
}[];
|
|
107
|
-
stateMutability: string;
|
|
108
|
-
type: string;
|
|
109
|
-
anonymous?: undefined;
|
|
110
|
-
})[];
|
|
111
|
-
export default _default;
|