@streamflow/stream 10.0.0-alpha.p311.10f340e → 10.0.0-alpha.p313.3ce4d29
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/README.md +8 -64
- package/dist/cjs/index.cjs +440 -3794
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -182
- package/dist/cjs/solana/index.cjs +393 -309
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1134 -17
- package/dist/esm/index.d.ts +3 -182
- package/dist/esm/index.js +258 -3626
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1134 -17
- package/dist/esm/solana/index.js +274 -240
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -43
- package/dist/cjs/BaseStreamClient-Dvs8yWEE.d.cts +0 -550
- package/dist/cjs/aptos/index.cjs +0 -450
- package/dist/cjs/aptos/index.cjs.map +0 -1
- package/dist/cjs/aptos/index.d.cts +0 -14
- package/dist/cjs/evm/index.cjs +0 -1909
- package/dist/cjs/evm/index.cjs.map +0 -1
- package/dist/cjs/evm/index.d.cts +0 -13
- package/dist/cjs/index-BHKWsVnx.d.cts +0 -849
- package/dist/cjs/index-CGNg22mO.d.cts +0 -203
- package/dist/cjs/index-Dk1hKzM3.d.cts +0 -213
- package/dist/cjs/index-dSxy_PVV.d.cts +0 -136
- package/dist/cjs/sui/index.cjs +0 -1015
- package/dist/cjs/sui/index.cjs.map +0 -1
- package/dist/cjs/sui/index.d.cts +0 -13
- package/dist/esm/BaseStreamClient-Dvs8yWEE.d.ts +0 -550
- package/dist/esm/aptos/index.d.ts +0 -14
- package/dist/esm/aptos/index.js +0 -437
- package/dist/esm/aptos/index.js.map +0 -1
- package/dist/esm/evm/index.d.ts +0 -13
- package/dist/esm/evm/index.js +0 -1896
- package/dist/esm/evm/index.js.map +0 -1
- package/dist/esm/index-CRXW7eZy.d.ts +0 -203
- package/dist/esm/index-CgDmuCzv.d.ts +0 -849
- package/dist/esm/index-DED7TgAo.d.ts +0 -136
- package/dist/esm/index-li6QZ_tF.d.ts +0 -213
- package/dist/esm/sui/index.d.ts +0 -13
- package/dist/esm/sui/index.js +0 -1005
- package/dist/esm/sui/index.js.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,424 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ICluster, ContractError, IChain, assertHasPublicKey, invariant, getBN as getBN$1 } from '@streamflow/common';
|
|
3
|
-
export { ContractError, IChain, ICluster } from '@streamflow/common';
|
|
4
|
-
import BN7 from 'bn.js';
|
|
5
|
-
import { Buffer } from 'buffer';
|
|
6
|
-
import '@manahippo/aptos-wallet-adapter';
|
|
7
|
-
import { ethers } from 'ethers';
|
|
8
|
-
import { toChecksumAddress } from 'ethereum-checksum-address';
|
|
1
|
+
import BN3 from 'bn.js';
|
|
9
2
|
import bs58 from 'bs58';
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
10
4
|
import { NATIVE_MINT, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
11
5
|
import { PublicKey, TransactionInstruction, Connection, Keypair, SYSVAR_RENT_PUBKEY, SystemProgram, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
|
|
12
|
-
import { isSignerKeypair, isSignerWallet, executeTransaction, buildSendThrottler, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, getMintAndProgram, prepareBaseInstructions, ata, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, checkOrCreateAtaBatch } from '@streamflow/common
|
|
6
|
+
import { ICluster, getNumberFromBN, isSignerKeypair, isSignerWallet, executeTransaction, ContractError, buildSendThrottler, assertHasPublicKey, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, invariant, getMintAndProgram, prepareBaseInstructions, getBN, ata, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, checkOrCreateAtaBatch } from '@streamflow/common';
|
|
7
|
+
export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
|
|
13
8
|
import * as borsh from 'borsh';
|
|
14
9
|
import { Program } from '@coral-xyz/anchor';
|
|
15
10
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
16
|
-
import { SuiClient } from '@mysten/sui/client';
|
|
17
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
18
|
-
import { SUI_CLOCK_OBJECT_ID, SUI_TYPE_ARG } from '@mysten/sui/utils';
|
|
19
|
-
import { bcs } from '@mysten/sui/bcs';
|
|
20
|
-
import { Keypair as Keypair$1 } from '@mysten/sui/cryptography';
|
|
21
|
-
|
|
22
|
-
var __create = Object.create;
|
|
23
|
-
var __defProp = Object.defineProperty;
|
|
24
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
25
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
26
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
27
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
28
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
29
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
30
|
-
};
|
|
31
|
-
var __export = (target, all) => {
|
|
32
|
-
for (var name in all)
|
|
33
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
34
|
-
};
|
|
35
|
-
var __copyProps = (to, from, except, desc) => {
|
|
36
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
37
|
-
for (let key of __getOwnPropNames(from))
|
|
38
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
39
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
40
|
-
}
|
|
41
|
-
return to;
|
|
42
|
-
};
|
|
43
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
44
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
45
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
46
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
47
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
48
|
-
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
49
|
-
mod
|
|
50
|
-
));
|
|
51
|
-
|
|
52
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
|
53
|
-
var require_retry_operation = __commonJS({
|
|
54
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
55
|
-
function RetryOperation(timeouts, options) {
|
|
56
|
-
if (typeof options === "boolean") {
|
|
57
|
-
options = { forever: options };
|
|
58
|
-
}
|
|
59
|
-
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
60
|
-
this._timeouts = timeouts;
|
|
61
|
-
this._options = options || {};
|
|
62
|
-
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
63
|
-
this._fn = null;
|
|
64
|
-
this._errors = [];
|
|
65
|
-
this._attempts = 1;
|
|
66
|
-
this._operationTimeout = null;
|
|
67
|
-
this._operationTimeoutCb = null;
|
|
68
|
-
this._timeout = null;
|
|
69
|
-
this._operationStart = null;
|
|
70
|
-
this._timer = null;
|
|
71
|
-
if (this._options.forever) {
|
|
72
|
-
this._cachedTimeouts = this._timeouts.slice(0);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
module.exports = RetryOperation;
|
|
76
|
-
RetryOperation.prototype.reset = function() {
|
|
77
|
-
this._attempts = 1;
|
|
78
|
-
this._timeouts = this._originalTimeouts.slice(0);
|
|
79
|
-
};
|
|
80
|
-
RetryOperation.prototype.stop = function() {
|
|
81
|
-
if (this._timeout) {
|
|
82
|
-
clearTimeout(this._timeout);
|
|
83
|
-
}
|
|
84
|
-
if (this._timer) {
|
|
85
|
-
clearTimeout(this._timer);
|
|
86
|
-
}
|
|
87
|
-
this._timeouts = [];
|
|
88
|
-
this._cachedTimeouts = null;
|
|
89
|
-
};
|
|
90
|
-
RetryOperation.prototype.retry = function(err) {
|
|
91
|
-
if (this._timeout) {
|
|
92
|
-
clearTimeout(this._timeout);
|
|
93
|
-
}
|
|
94
|
-
if (!err) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
98
|
-
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
99
|
-
this._errors.push(err);
|
|
100
|
-
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
this._errors.push(err);
|
|
104
|
-
var timeout = this._timeouts.shift();
|
|
105
|
-
if (timeout === void 0) {
|
|
106
|
-
if (this._cachedTimeouts) {
|
|
107
|
-
this._errors.splice(0, this._errors.length - 1);
|
|
108
|
-
timeout = this._cachedTimeouts.slice(-1);
|
|
109
|
-
} else {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
var self = this;
|
|
114
|
-
this._timer = setTimeout(function() {
|
|
115
|
-
self._attempts++;
|
|
116
|
-
if (self._operationTimeoutCb) {
|
|
117
|
-
self._timeout = setTimeout(function() {
|
|
118
|
-
self._operationTimeoutCb(self._attempts);
|
|
119
|
-
}, self._operationTimeout);
|
|
120
|
-
if (self._options.unref) {
|
|
121
|
-
self._timeout.unref();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
self._fn(self._attempts);
|
|
125
|
-
}, timeout);
|
|
126
|
-
if (this._options.unref) {
|
|
127
|
-
this._timer.unref();
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
};
|
|
131
|
-
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
132
|
-
this._fn = fn;
|
|
133
|
-
if (timeoutOps) {
|
|
134
|
-
if (timeoutOps.timeout) {
|
|
135
|
-
this._operationTimeout = timeoutOps.timeout;
|
|
136
|
-
}
|
|
137
|
-
if (timeoutOps.cb) {
|
|
138
|
-
this._operationTimeoutCb = timeoutOps.cb;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
var self = this;
|
|
142
|
-
if (this._operationTimeoutCb) {
|
|
143
|
-
this._timeout = setTimeout(function() {
|
|
144
|
-
self._operationTimeoutCb();
|
|
145
|
-
}, self._operationTimeout);
|
|
146
|
-
}
|
|
147
|
-
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
148
|
-
this._fn(this._attempts);
|
|
149
|
-
};
|
|
150
|
-
RetryOperation.prototype.try = function(fn) {
|
|
151
|
-
console.log("Using RetryOperation.try() is deprecated");
|
|
152
|
-
this.attempt(fn);
|
|
153
|
-
};
|
|
154
|
-
RetryOperation.prototype.start = function(fn) {
|
|
155
|
-
console.log("Using RetryOperation.start() is deprecated");
|
|
156
|
-
this.attempt(fn);
|
|
157
|
-
};
|
|
158
|
-
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
159
|
-
RetryOperation.prototype.errors = function() {
|
|
160
|
-
return this._errors;
|
|
161
|
-
};
|
|
162
|
-
RetryOperation.prototype.attempts = function() {
|
|
163
|
-
return this._attempts;
|
|
164
|
-
};
|
|
165
|
-
RetryOperation.prototype.mainError = function() {
|
|
166
|
-
if (this._errors.length === 0) {
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
var counts = {};
|
|
170
|
-
var mainError = null;
|
|
171
|
-
var mainErrorCount = 0;
|
|
172
|
-
for (var i = 0; i < this._errors.length; i++) {
|
|
173
|
-
var error = this._errors[i];
|
|
174
|
-
var message = error.message;
|
|
175
|
-
var count = (counts[message] || 0) + 1;
|
|
176
|
-
counts[message] = count;
|
|
177
|
-
if (count >= mainErrorCount) {
|
|
178
|
-
mainError = error;
|
|
179
|
-
mainErrorCount = count;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return mainError;
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
|
|
188
|
-
var require_retry = __commonJS({
|
|
189
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
|
|
190
|
-
var RetryOperation = require_retry_operation();
|
|
191
|
-
exports.operation = function(options) {
|
|
192
|
-
var timeouts = exports.timeouts(options);
|
|
193
|
-
return new RetryOperation(timeouts, {
|
|
194
|
-
forever: options && (options.forever || options.retries === Infinity),
|
|
195
|
-
unref: options && options.unref,
|
|
196
|
-
maxRetryTime: options && options.maxRetryTime
|
|
197
|
-
});
|
|
198
|
-
};
|
|
199
|
-
exports.timeouts = function(options) {
|
|
200
|
-
if (options instanceof Array) {
|
|
201
|
-
return [].concat(options);
|
|
202
|
-
}
|
|
203
|
-
var opts = {
|
|
204
|
-
retries: 10,
|
|
205
|
-
factor: 2,
|
|
206
|
-
minTimeout: 1 * 1e3,
|
|
207
|
-
maxTimeout: Infinity,
|
|
208
|
-
randomize: false
|
|
209
|
-
};
|
|
210
|
-
for (var key in options) {
|
|
211
|
-
opts[key] = options[key];
|
|
212
|
-
}
|
|
213
|
-
if (opts.minTimeout > opts.maxTimeout) {
|
|
214
|
-
throw new Error("minTimeout is greater than maxTimeout");
|
|
215
|
-
}
|
|
216
|
-
var timeouts = [];
|
|
217
|
-
for (var i = 0; i < opts.retries; i++) {
|
|
218
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
219
|
-
}
|
|
220
|
-
if (options && options.forever && !timeouts.length) {
|
|
221
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
222
|
-
}
|
|
223
|
-
timeouts.sort(function(a, b) {
|
|
224
|
-
return a - b;
|
|
225
|
-
});
|
|
226
|
-
return timeouts;
|
|
227
|
-
};
|
|
228
|
-
exports.createTimeout = function(attempt, opts) {
|
|
229
|
-
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
230
|
-
var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
|
|
231
|
-
timeout = Math.min(timeout, opts.maxTimeout);
|
|
232
|
-
return timeout;
|
|
233
|
-
};
|
|
234
|
-
exports.wrap = function(obj, options, methods) {
|
|
235
|
-
if (options instanceof Array) {
|
|
236
|
-
methods = options;
|
|
237
|
-
options = null;
|
|
238
|
-
}
|
|
239
|
-
if (!methods) {
|
|
240
|
-
methods = [];
|
|
241
|
-
for (var key in obj) {
|
|
242
|
-
if (typeof obj[key] === "function") {
|
|
243
|
-
methods.push(key);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
for (var i = 0; i < methods.length; i++) {
|
|
248
|
-
var method = methods[i];
|
|
249
|
-
var original = obj[method];
|
|
250
|
-
obj[method] = function retryWrapper(original2) {
|
|
251
|
-
var op = exports.operation(options);
|
|
252
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
253
|
-
var callback = args.pop();
|
|
254
|
-
args.push(function(err) {
|
|
255
|
-
if (op.retry(err)) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
if (err) {
|
|
259
|
-
arguments[0] = op.mainError();
|
|
260
|
-
}
|
|
261
|
-
callback.apply(this, arguments);
|
|
262
|
-
});
|
|
263
|
-
op.attempt(function() {
|
|
264
|
-
original2.apply(obj, args);
|
|
265
|
-
});
|
|
266
|
-
}.bind(obj, original);
|
|
267
|
-
obj[method].options = options;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
|
|
274
|
-
var require_retry2 = __commonJS({
|
|
275
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
|
|
276
|
-
module.exports = require_retry();
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
// aptos/index.ts
|
|
281
|
-
var aptos_exports = {};
|
|
282
|
-
__export(aptos_exports, {
|
|
283
|
-
AptosStreamClient: () => AptosStreamClient,
|
|
284
|
-
Contract: () => Contract,
|
|
285
|
-
constants: () => constants_exports,
|
|
286
|
-
default: () => AptosStreamClient,
|
|
287
|
-
extractAptosErrorCode: () => extractAptosErrorCode,
|
|
288
|
-
normalizeAptosAddress: () => normalizeAptosAddress
|
|
289
|
-
});
|
|
290
|
-
var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
|
|
291
|
-
StreamDirection2["Outgoing"] = "outgoing";
|
|
292
|
-
StreamDirection2["Incoming"] = "incoming";
|
|
293
|
-
StreamDirection2["All"] = "all";
|
|
294
|
-
return StreamDirection2;
|
|
295
|
-
})(StreamDirection || {});
|
|
296
|
-
var StreamType = /* @__PURE__ */ ((StreamType2) => {
|
|
297
|
-
StreamType2["All"] = "all";
|
|
298
|
-
StreamType2["Vesting"] = "vesting";
|
|
299
|
-
StreamType2["Lock"] = "lock";
|
|
300
|
-
return StreamType2;
|
|
301
|
-
})(StreamType || {});
|
|
302
|
-
var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
|
|
303
|
-
ContractErrorCode2["ECONTRACT_NOT_INIT"] = "ECONTRACT_NOT_INIT";
|
|
304
|
-
ContractErrorCode2["EBAD_AMOUNT"] = "EBAD_AMOUNT";
|
|
305
|
-
ContractErrorCode2["ENO_PERMISSIONS"] = "ENO_PERMISSIONS";
|
|
306
|
-
ContractErrorCode2["EBADINPUT"] = "EBADINPUT";
|
|
307
|
-
ContractErrorCode2["ECLOSED"] = "ECLOSED";
|
|
308
|
-
ContractErrorCode2["EBAD_INPUT_AMOUNT_PER_PERIOD"] = "EBAD_INPUT_AMOUNT_PER_PERIOD";
|
|
309
|
-
ContractErrorCode2["EBAD_INPUT_PAUSABLE"] = "EBAD_INPUT_PAUSABLE";
|
|
310
|
-
ContractErrorCode2["EBAD_INPUT_UPDATE_RATE"] = "EBAD_INPUT_UPDATE_RATE";
|
|
311
|
-
ContractErrorCode2["EBAD_INPUT_CLIFF_AMOUNT"] = "EBAD_INPUT_CLIFF_AMOUNT";
|
|
312
|
-
ContractErrorCode2["EBAD_INPUT_PERIOD"] = "EBAD_INPUT_PERIOD";
|
|
313
|
-
ContractErrorCode2["EBAD_INPUT_START"] = "EBAD_INPUT_START";
|
|
314
|
-
ContractErrorCode2["EBAD_INSUFFICIENT_TOKEN_ALLOWANCE"] = "EBAD_INSUFFICIENT_TOKEN_ALLOWANCE";
|
|
315
|
-
ContractErrorCode2["EBAD_INSUFFICIENT_WITHDRAWAL_FEES"] = "EBAD_INSUFFICIENT_WITHDRAWAL_FEES";
|
|
316
|
-
ContractErrorCode2["EBAD_INSUFFICIENT_AMOUNT"] = "EBAD_INSUFFICIENT_AMOUNT";
|
|
317
|
-
ContractErrorCode2["EPAUSED"] = "EPAUSED";
|
|
318
|
-
ContractErrorCode2["ENOTPAUSED"] = "ENOTPAUSED";
|
|
319
|
-
ContractErrorCode2["ENO_RECIPIENT_COIN_ADDRESS"] = "ENO_RECIPIENT_COIN_ADDRESS";
|
|
320
|
-
return ContractErrorCode2;
|
|
321
|
-
})(ContractErrorCode || {});
|
|
322
|
-
var SolanaContractErrorCode = /* @__PURE__ */ ((SolanaContractErrorCode2) => {
|
|
323
|
-
SolanaContractErrorCode2["AccountsNotWritable"] = "AccountsNotWritable";
|
|
324
|
-
SolanaContractErrorCode2["InvalidMetadata"] = "InvalidMetadata";
|
|
325
|
-
SolanaContractErrorCode2["InvalidMetadataAccount"] = "InvalidMetadataAccount";
|
|
326
|
-
SolanaContractErrorCode2["MetadataAccountMismatch"] = "MetadataAccountMismatch";
|
|
327
|
-
SolanaContractErrorCode2["InvalidEscrowAccount"] = "InvalidEscrowAccount";
|
|
328
|
-
SolanaContractErrorCode2["NotAssociated"] = "NotAssociated";
|
|
329
|
-
SolanaContractErrorCode2["MintMismatch"] = "MintMismatch";
|
|
330
|
-
SolanaContractErrorCode2["TransferNotAllowed"] = "TransferNotAllowed";
|
|
331
|
-
SolanaContractErrorCode2["ContractClosed"] = "ContractClosed";
|
|
332
|
-
SolanaContractErrorCode2["InvalidTreasury"] = "InvalidTreasury";
|
|
333
|
-
SolanaContractErrorCode2["InvalidTimestamps"] = "InvalidTimestamps";
|
|
334
|
-
SolanaContractErrorCode2["InvalidDepositConfiguration"] = "InvalidDepositConfiguration";
|
|
335
|
-
SolanaContractErrorCode2["AmountIsZero"] = "AmountIsZero";
|
|
336
|
-
SolanaContractErrorCode2["AmountMoreThanAvailable"] = "AmountMoreThanAvailable";
|
|
337
|
-
SolanaContractErrorCode2["AmountAvailableIsZero"] = "AmountAvailableIsZero";
|
|
338
|
-
SolanaContractErrorCode2["ArithmeticError"] = "ArithmeticError";
|
|
339
|
-
SolanaContractErrorCode2["InvalidMetadataSize"] = "InvalidMetadataSize";
|
|
340
|
-
SolanaContractErrorCode2["UninitializedMetadata"] = "UninitializedMetadata";
|
|
341
|
-
SolanaContractErrorCode2["Unauthorized"] = "Unauthorized";
|
|
342
|
-
SolanaContractErrorCode2["SelfTransfer"] = "SelfTransfer";
|
|
343
|
-
SolanaContractErrorCode2["AlreadyPaused"] = "AlreadyPaused";
|
|
344
|
-
SolanaContractErrorCode2["NotPaused"] = "NotPaused";
|
|
345
|
-
SolanaContractErrorCode2["MetadataNotRentExempt"] = "MetadataNotRentExempt";
|
|
346
|
-
return SolanaContractErrorCode2;
|
|
347
|
-
})(SolanaContractErrorCode || {});
|
|
348
|
-
var SolanaAlignedProxyErrorCode = /* @__PURE__ */ ((SolanaAlignedProxyErrorCode2) => {
|
|
349
|
-
SolanaAlignedProxyErrorCode2["Unauthorized"] = "Unauthorized";
|
|
350
|
-
SolanaAlignedProxyErrorCode2["ArithmeticError"] = "ArithmeticError";
|
|
351
|
-
SolanaAlignedProxyErrorCode2["UnsupportedTokenExtensions"] = "UnsupportedTokenExtensions";
|
|
352
|
-
SolanaAlignedProxyErrorCode2["PeriodTooShort"] = "PeriodTooShort";
|
|
353
|
-
SolanaAlignedProxyErrorCode2["InvalidTickSize"] = "InvalidTickSize";
|
|
354
|
-
SolanaAlignedProxyErrorCode2["InvalidPercentageBoundaries"] = "InvalidPercentageBoundaries";
|
|
355
|
-
SolanaAlignedProxyErrorCode2["InvalidPriceBoundaries"] = "InvalidPriceBoundaries";
|
|
356
|
-
SolanaAlignedProxyErrorCode2["UnsupportedOracle"] = "UnsupportedOracle";
|
|
357
|
-
SolanaAlignedProxyErrorCode2["InvalidOracleAccount"] = "InvalidOracleAccount";
|
|
358
|
-
SolanaAlignedProxyErrorCode2["InvalidOraclePrice"] = "InvalidOraclePrice";
|
|
359
|
-
SolanaAlignedProxyErrorCode2["InvalidStreamMetadata"] = "InvalidStreamMetadata";
|
|
360
|
-
SolanaAlignedProxyErrorCode2["AmountAlreadyUpdated"] = "AmountAlreadyUpdated";
|
|
361
|
-
SolanaAlignedProxyErrorCode2["AllFundsUnlocked"] = "AllFundsUnlocked";
|
|
362
|
-
return SolanaAlignedProxyErrorCode2;
|
|
363
|
-
})(SolanaAlignedProxyErrorCode || {});
|
|
364
|
-
|
|
365
|
-
// common/BaseStreamClient.ts
|
|
366
|
-
var BaseStreamClient = class {
|
|
367
|
-
/**
|
|
368
|
-
* Returns total fee percent, streamflow fees + partner fees
|
|
369
|
-
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
370
|
-
* @param chainSpecificParams additional parameters required by chain client
|
|
371
|
-
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
372
|
-
*/
|
|
373
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
374
|
-
async getTotalFee(getFeesData, chainSpecificParams) {
|
|
375
|
-
const fees = await this.getFees(getFeesData, chainSpecificParams);
|
|
376
|
-
if (fees) {
|
|
377
|
-
return fees.partnerFee + fees.streamflowFee;
|
|
378
|
-
}
|
|
379
|
-
return this.getDefaultStreamflowFee(chainSpecificParams);
|
|
380
|
-
}
|
|
381
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
382
|
-
extractErrorCode(err) {
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
11
|
|
|
387
|
-
//
|
|
388
|
-
var constants_exports = {};
|
|
389
|
-
__export(constants_exports, {
|
|
390
|
-
APTOS_ERROR_MATCH_REGEX: () => APTOS_ERROR_MATCH_REGEX,
|
|
391
|
-
APTOS_MODULE_ERROR_MAP: () => APTOS_MODULE_ERROR_MAP,
|
|
392
|
-
APTOS_PROGRAM_IDS: () => APTOS_PROGRAM_IDS
|
|
393
|
-
});
|
|
394
|
-
var APTOS_PROGRAM_IDS = {
|
|
395
|
-
[ICluster.Mainnet]: "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0",
|
|
396
|
-
// TODO: Add a correct programID for Test net
|
|
397
|
-
[ICluster.Devnet]: "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
|
|
398
|
-
[ICluster.Testnet]: "0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688",
|
|
399
|
-
[ICluster.Local]: "0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0"
|
|
400
|
-
};
|
|
401
|
-
var APTOS_ERROR_MATCH_REGEX = /Move abort in [a-z0-9]+::([^:]+): ([A-Z_]+)/;
|
|
402
|
-
var APTOS_MODULE_ERROR_MAP = {
|
|
403
|
-
protocol: {
|
|
404
|
-
1: "ECONTRACT_NOT_INIT" /* ECONTRACT_NOT_INIT */,
|
|
405
|
-
2: "EBAD_AMOUNT" /* EBAD_AMOUNT */,
|
|
406
|
-
3: "ENO_PERMISSIONS" /* ENO_PERMISSIONS */,
|
|
407
|
-
4: "EBADINPUT" /* EBADINPUT */,
|
|
408
|
-
5: "ECLOSED" /* ECLOSED */,
|
|
409
|
-
6: "EBAD_INPUT_AMOUNT_PER_PERIOD" /* EBAD_INPUT_AMOUNT_PER_PERIOD */,
|
|
410
|
-
8: "EBAD_INPUT_UPDATE_RATE" /* EBAD_INPUT_UPDATE_RATE */,
|
|
411
|
-
9: "EBAD_INPUT_CLIFF_AMOUNT" /* EBAD_INPUT_CLIFF_AMOUNT */,
|
|
412
|
-
10: "EBAD_INPUT_PERIOD" /* EBAD_INPUT_PERIOD */,
|
|
413
|
-
11: "EBAD_INPUT_START" /* EBAD_INPUT_START */,
|
|
414
|
-
12: "ENO_RECIPIENT_COIN_ADDRESS" /* ENO_RECIPIENT_COIN_ADDRESS */
|
|
415
|
-
}
|
|
416
|
-
};
|
|
12
|
+
// solana/StreamClient.ts
|
|
417
13
|
var MAX_SAFE_UNIX_TIME_VALUE = 864e10;
|
|
418
|
-
var BASE_FEE = 1009900;
|
|
419
|
-
var WITHDRAW_AVAILABLE_AMOUNT = new BN7("18446744073709551615");
|
|
420
|
-
|
|
421
|
-
// common/contractUtils.ts
|
|
422
14
|
var calculateUnlockedAmount = ({
|
|
423
15
|
depositedAmount,
|
|
424
16
|
cliff,
|
|
@@ -431,18 +23,21 @@ var calculateUnlockedAmount = ({
|
|
|
431
23
|
fundsUnlockedAtLastRateChange
|
|
432
24
|
}) => {
|
|
433
25
|
const deposited = depositedAmount;
|
|
434
|
-
if (currentTimestamp < cliff) return new
|
|
26
|
+
if (currentTimestamp < cliff) return new BN3(0);
|
|
435
27
|
if (currentTimestamp > end) return deposited;
|
|
436
28
|
const savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
|
|
437
29
|
const savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
|
|
438
|
-
const streamed = new
|
|
30
|
+
const streamed = new BN3(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period)).mul(amountPerPeriod).add(savedUnlockedFunds);
|
|
439
31
|
return streamed.lt(deposited) ? streamed : deposited;
|
|
440
32
|
};
|
|
441
33
|
var isCliffCloseToDepositedAmount = (streamData) => {
|
|
442
|
-
return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new
|
|
34
|
+
return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3(1)));
|
|
35
|
+
};
|
|
36
|
+
var isPayment = (streamData) => {
|
|
37
|
+
return streamData.canTopup;
|
|
443
38
|
};
|
|
444
39
|
var isVesting = (streamData) => {
|
|
445
|
-
return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
40
|
+
return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
446
41
|
};
|
|
447
42
|
var isAligned = (stream) => {
|
|
448
43
|
return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
|
|
@@ -457,1957 +52,122 @@ var isTokenLock = (streamData) => {
|
|
|
457
52
|
return !streamData.canTopup && !streamData.automaticWithdrawal && !streamData.cancelableBySender && !streamData.cancelableByRecipient && !streamData.transferableBySender && (isCliffCloseToDepositedAmount(streamData) || isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
|
|
458
53
|
};
|
|
459
54
|
var buildStreamType = (streamData) => {
|
|
55
|
+
if (isVesting(streamData)) {
|
|
56
|
+
return "vesting" /* Vesting */;
|
|
57
|
+
}
|
|
460
58
|
if (isTokenLock(streamData)) {
|
|
461
59
|
return "lock" /* Lock */;
|
|
462
60
|
}
|
|
463
|
-
return "
|
|
61
|
+
return "payment" /* Payment */;
|
|
464
62
|
};
|
|
465
63
|
var decodeEndTime = (endTime) => {
|
|
466
|
-
if (endTime.gt(new
|
|
64
|
+
if (endTime.gt(new BN3(MAX_SAFE_UNIX_TIME_VALUE))) {
|
|
467
65
|
return MAX_SAFE_UNIX_TIME_VALUE;
|
|
468
66
|
}
|
|
469
67
|
return endTime.toNumber();
|
|
470
68
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
69
|
+
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
70
|
+
var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
|
|
71
|
+
StreamDirection2["Outgoing"] = "outgoing";
|
|
72
|
+
StreamDirection2["Incoming"] = "incoming";
|
|
73
|
+
StreamDirection2["All"] = "all";
|
|
74
|
+
return StreamDirection2;
|
|
75
|
+
})(StreamDirection || {});
|
|
76
|
+
var StreamType = /* @__PURE__ */ ((StreamType2) => {
|
|
77
|
+
StreamType2["All"] = "all";
|
|
78
|
+
StreamType2["Payment"] = "payment";
|
|
79
|
+
StreamType2["Vesting"] = "vesting";
|
|
80
|
+
StreamType2["Lock"] = "lock";
|
|
81
|
+
return StreamType2;
|
|
82
|
+
})(StreamType || {});
|
|
83
|
+
var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
|
|
84
|
+
ContractErrorCode2["AccountsNotWritable"] = "AccountsNotWritable";
|
|
85
|
+
ContractErrorCode2["InvalidMetadata"] = "InvalidMetadata";
|
|
86
|
+
ContractErrorCode2["InvalidMetadataAccount"] = "InvalidMetadataAccount";
|
|
87
|
+
ContractErrorCode2["MetadataAccountMismatch"] = "MetadataAccountMismatch";
|
|
88
|
+
ContractErrorCode2["InvalidEscrowAccount"] = "InvalidEscrowAccount";
|
|
89
|
+
ContractErrorCode2["NotAssociated"] = "NotAssociated";
|
|
90
|
+
ContractErrorCode2["MintMismatch"] = "MintMismatch";
|
|
91
|
+
ContractErrorCode2["TransferNotAllowed"] = "TransferNotAllowed";
|
|
92
|
+
ContractErrorCode2["ContractClosed"] = "ContractClosed";
|
|
93
|
+
ContractErrorCode2["InvalidTreasury"] = "InvalidTreasury";
|
|
94
|
+
ContractErrorCode2["InvalidTimestamps"] = "InvalidTimestamps";
|
|
95
|
+
ContractErrorCode2["InvalidDepositConfiguration"] = "InvalidDepositConfiguration";
|
|
96
|
+
ContractErrorCode2["AmountIsZero"] = "AmountIsZero";
|
|
97
|
+
ContractErrorCode2["AmountMoreThanAvailable"] = "AmountMoreThanAvailable";
|
|
98
|
+
ContractErrorCode2["AmountAvailableIsZero"] = "AmountAvailableIsZero";
|
|
99
|
+
ContractErrorCode2["ArithmeticError"] = "ArithmeticError";
|
|
100
|
+
ContractErrorCode2["InvalidMetadataSize"] = "InvalidMetadataSize";
|
|
101
|
+
ContractErrorCode2["UninitializedMetadata"] = "UninitializedMetadata";
|
|
102
|
+
ContractErrorCode2["Unauthorized"] = "Unauthorized";
|
|
103
|
+
ContractErrorCode2["SelfTransfer"] = "SelfTransfer";
|
|
104
|
+
ContractErrorCode2["AlreadyPaused"] = "AlreadyPaused";
|
|
105
|
+
ContractErrorCode2["NotPaused"] = "NotPaused";
|
|
106
|
+
ContractErrorCode2["MetadataNotRentExempt"] = "MetadataNotRentExempt";
|
|
107
|
+
return ContractErrorCode2;
|
|
108
|
+
})(ContractErrorCode || {});
|
|
109
|
+
var AlignedProxyErrorCode = /* @__PURE__ */ ((AlignedProxyErrorCode2) => {
|
|
110
|
+
AlignedProxyErrorCode2["Unauthorized"] = "Unauthorized";
|
|
111
|
+
AlignedProxyErrorCode2["ArithmeticError"] = "ArithmeticError";
|
|
112
|
+
AlignedProxyErrorCode2["UnsupportedTokenExtensions"] = "UnsupportedTokenExtensions";
|
|
113
|
+
AlignedProxyErrorCode2["PeriodTooShort"] = "PeriodTooShort";
|
|
114
|
+
AlignedProxyErrorCode2["InvalidTickSize"] = "InvalidTickSize";
|
|
115
|
+
AlignedProxyErrorCode2["InvalidPercentageBoundaries"] = "InvalidPercentageBoundaries";
|
|
116
|
+
AlignedProxyErrorCode2["InvalidPriceBoundaries"] = "InvalidPriceBoundaries";
|
|
117
|
+
AlignedProxyErrorCode2["UnsupportedOracle"] = "UnsupportedOracle";
|
|
118
|
+
AlignedProxyErrorCode2["InvalidOracleAccount"] = "InvalidOracleAccount";
|
|
119
|
+
AlignedProxyErrorCode2["InvalidOraclePrice"] = "InvalidOraclePrice";
|
|
120
|
+
AlignedProxyErrorCode2["InvalidStreamMetadata"] = "InvalidStreamMetadata";
|
|
121
|
+
AlignedProxyErrorCode2["AmountAlreadyUpdated"] = "AmountAlreadyUpdated";
|
|
122
|
+
AlignedProxyErrorCode2["AllFundsUnlocked"] = "AllFundsUnlocked";
|
|
123
|
+
return AlignedProxyErrorCode2;
|
|
124
|
+
})(AlignedProxyErrorCode || {});
|
|
525
125
|
var Contract = class {
|
|
526
|
-
constructor(stream, tokenId) {
|
|
527
|
-
this.magic = 0;
|
|
528
|
-
this.version = 0;
|
|
529
|
-
this.createdAt = parseInt(stream.created);
|
|
530
|
-
this.withdrawnAmount = new BN7(stream.withdrawn);
|
|
531
|
-
this.canceledAt = parseInt(stream.canceled_at);
|
|
532
|
-
this.end = parseInt(stream.end);
|
|
533
|
-
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
534
|
-
this.sender = normalizeAptosAddress(stream.sender);
|
|
535
|
-
this.senderTokens = normalizeAptosAddress(stream.sender);
|
|
536
|
-
this.recipient = normalizeAptosAddress(stream.recipient);
|
|
537
|
-
this.recipientTokens = normalizeAptosAddress(stream.recipient);
|
|
538
|
-
this.mint = tokenId;
|
|
539
|
-
this.escrowTokens = "";
|
|
540
|
-
this.streamflowTreasury = "";
|
|
541
|
-
this.streamflowTreasuryTokens = "";
|
|
542
|
-
this.streamflowFeeTotal = new BN7(0);
|
|
543
|
-
this.streamflowFeeWithdrawn = new BN7(0);
|
|
544
|
-
this.streamflowFeePercent = parseInt(stream.fees.streamflow_fee_percentage) / 1e4;
|
|
545
|
-
this.partnerFeeTotal = new BN7(0);
|
|
546
|
-
this.partnerFeeWithdrawn = new BN7(0);
|
|
547
|
-
this.partnerFeePercent = 0;
|
|
548
|
-
this.partner = "";
|
|
549
|
-
this.partnerTokens = "";
|
|
550
|
-
this.start = parseInt(stream.start);
|
|
551
|
-
this.depositedAmount = new BN7(stream.amount);
|
|
552
|
-
this.period = parseInt(stream.period);
|
|
553
|
-
this.amountPerPeriod = new BN7(stream.amount_per_period);
|
|
554
|
-
this.cliff = parseInt(stream.start);
|
|
555
|
-
this.cliffAmount = new BN7(stream.cliff_amount);
|
|
556
|
-
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
557
|
-
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
558
|
-
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
559
|
-
this.transferableBySender = stream.meta.transferable_by_sender;
|
|
560
|
-
this.transferableByRecipient = stream.meta.transferable_by_recipient;
|
|
561
|
-
this.canTopup = stream.meta.can_topup;
|
|
562
|
-
const name = stream.meta.contract_name.replace("0x", "");
|
|
563
|
-
this.name = Buffer.from(name, "hex").toString("utf8");
|
|
564
|
-
this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
|
|
565
|
-
this.closed = stream.closed;
|
|
566
|
-
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
567
|
-
this.pauseCumulative = new BN7(stream.pause_cumulative);
|
|
568
|
-
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
569
|
-
this.fundsUnlockedAtLastRateChange = new BN7(stream.funds_unlocked_at_last_rate_change);
|
|
570
|
-
this.type = buildStreamType(this);
|
|
571
|
-
}
|
|
572
|
-
unlocked(currentTimestamp) {
|
|
573
|
-
return calculateUnlockedAmount({
|
|
574
|
-
...this,
|
|
575
|
-
currentTimestamp
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
remaining(decimals) {
|
|
579
|
-
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
var AptosWalletWrapper = class {
|
|
583
|
-
constructor(wallet, client) {
|
|
584
|
-
this.client = client;
|
|
585
|
-
this.wallet = wallet;
|
|
586
|
-
if (wallet instanceof AptosAccount) {
|
|
587
|
-
this.address = wallet.address();
|
|
588
|
-
} else {
|
|
589
|
-
this.address = wallet.account.address;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
async signAndSubmitTransaction(input) {
|
|
593
|
-
if (this.wallet instanceof AptosAccount) {
|
|
594
|
-
const builder = new TransactionBuilderRemoteABI(this.client, {
|
|
595
|
-
sender: this.address
|
|
596
|
-
});
|
|
597
|
-
const rawTxn = await builder.build(input.function, input.type_arguments, input.arguments);
|
|
598
|
-
const res = await this.client.simulateTransaction(this.wallet, rawTxn);
|
|
599
|
-
if (!res[0].success) {
|
|
600
|
-
throw new Error(`Transaction Simulation failed: ${JSON.stringify(res)}`);
|
|
601
|
-
}
|
|
602
|
-
const signedTx = await this.client.signTransaction(this.wallet, rawTxn);
|
|
603
|
-
const tx = await this.client.submitSignedBCSTransaction(signedTx);
|
|
604
|
-
await this.client.waitForTransaction(tx.hash);
|
|
605
|
-
return tx.hash;
|
|
606
|
-
}
|
|
607
|
-
return (await this.wallet.signAndSubmitTransaction(input)).hash;
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
|
|
611
|
-
// aptos/StreamClient.ts
|
|
612
|
-
var AptosStreamClient = class extends BaseStreamClient {
|
|
613
|
-
constructor(clusterUrl, cluster = ICluster.Mainnet, maxGas = "10000", programId) {
|
|
614
|
-
super();
|
|
615
|
-
this.programId = programId ? programId : APTOS_PROGRAM_IDS[cluster];
|
|
616
|
-
this.maxGas = maxGas;
|
|
617
|
-
this.client = new AptosClient(clusterUrl);
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Creates a new stream/vesting contract.
|
|
621
|
-
*/
|
|
622
|
-
async create(streamData, { senderWallet }) {
|
|
623
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
624
|
-
const result = this.generateMultiPayloads(
|
|
625
|
-
{
|
|
626
|
-
...streamData,
|
|
627
|
-
recipients: [{ ...streamData }]
|
|
628
|
-
},
|
|
629
|
-
wallet
|
|
630
|
-
)[0];
|
|
631
|
-
if (!result) {
|
|
632
|
-
throw new Error("Failed to generate payload");
|
|
633
|
-
}
|
|
634
|
-
const [metadataId, payload] = result;
|
|
635
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
636
|
-
return { ixs: [payload], txId: hash, metadataId };
|
|
637
|
-
}
|
|
638
|
-
/**
|
|
639
|
-
* Creates multiple stream/vesting contracts.
|
|
640
|
-
*/
|
|
641
|
-
async createMultiple(multipleStreamData, { senderWallet }) {
|
|
642
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
643
|
-
const payloads = this.generateMultiPayloads(multipleStreamData, wallet);
|
|
644
|
-
const txs = [];
|
|
645
|
-
const metadatas = [];
|
|
646
|
-
const metadataToRecipient = {};
|
|
647
|
-
const errors = [];
|
|
648
|
-
for (let i = 0; i < payloads.length; i++) {
|
|
649
|
-
const [metadataId, payload] = payloads[i];
|
|
650
|
-
const recipient = multipleStreamData.recipients[i];
|
|
651
|
-
try {
|
|
652
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
653
|
-
txs.push(hash);
|
|
654
|
-
} catch (e) {
|
|
655
|
-
errors.push({
|
|
656
|
-
error: e?.toString() ?? "Unknown error!",
|
|
657
|
-
recipient: recipient.recipient
|
|
658
|
-
});
|
|
659
|
-
} finally {
|
|
660
|
-
metadatas.push(metadataId);
|
|
661
|
-
metadataToRecipient[metadataId] = recipient;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
return {
|
|
665
|
-
txs,
|
|
666
|
-
metadatas,
|
|
667
|
-
metadataToRecipient,
|
|
668
|
-
errors
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Attempts withdrawing from the specified stream.
|
|
673
|
-
*/
|
|
674
|
-
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { senderWallet, tokenId }) {
|
|
675
|
-
const payload = {
|
|
676
|
-
type: "withdraw",
|
|
677
|
-
function: `${this.programId}::protocol::withdraw`,
|
|
678
|
-
type_arguments: [tokenId],
|
|
679
|
-
arguments: [id, amount.toString()]
|
|
680
|
-
};
|
|
681
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
682
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
683
|
-
return { ixs: [payload], txId: hash };
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Attempts canceling the specified stream.
|
|
687
|
-
*/
|
|
688
|
-
async cancel(cancelData, { senderWallet, tokenId }) {
|
|
689
|
-
const payload = {
|
|
690
|
-
type: "cancel",
|
|
691
|
-
function: `${this.programId}::protocol::cancel`,
|
|
692
|
-
type_arguments: [tokenId],
|
|
693
|
-
arguments: [cancelData.id]
|
|
694
|
-
};
|
|
695
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
696
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
697
|
-
return { ixs: [payload], txId: hash };
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
701
|
-
*/
|
|
702
|
-
async transfer(transferData, { senderWallet, tokenId }) {
|
|
703
|
-
const payload = {
|
|
704
|
-
type: "transfer",
|
|
705
|
-
function: `${this.programId}::protocol::transfer`,
|
|
706
|
-
type_arguments: [tokenId],
|
|
707
|
-
arguments: [transferData.id, transferData.newRecipient]
|
|
708
|
-
};
|
|
709
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
710
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
711
|
-
return { ixs: [payload], txId: hash };
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Tops up stream account with specified amount.
|
|
715
|
-
*/
|
|
716
|
-
async topup(topupData, { senderWallet, tokenId }) {
|
|
717
|
-
const payload = {
|
|
718
|
-
type: "topup",
|
|
719
|
-
function: `${this.programId}::protocol::topup`,
|
|
720
|
-
type_arguments: [tokenId],
|
|
721
|
-
arguments: [topupData.id, topupData.amount.toString()]
|
|
722
|
-
};
|
|
723
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
724
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
725
|
-
return { ixs: [payload], txId: hash };
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* Fetch stream data by its id (address).
|
|
729
|
-
*/
|
|
730
|
-
async getOne({ id }) {
|
|
731
|
-
const contractResources = await this.client.getAccountResources(id);
|
|
732
|
-
const contract = contractResources.find((r) => r.type.includes("protocol::Contract"));
|
|
733
|
-
if (!contract) {
|
|
734
|
-
throw new Error(`Contract with id ${id} could not be found!`);
|
|
735
|
-
}
|
|
736
|
-
const tokenIdMatch = contract.type.match(/0x[0-9a-f]+::protocol::Contract<(.*)>/);
|
|
737
|
-
const tokenId = tokenIdMatch?.[1] ?? "";
|
|
738
|
-
const { data } = contract;
|
|
739
|
-
return new Contract(data, tokenId);
|
|
740
|
-
}
|
|
741
|
-
async get() {
|
|
742
|
-
throw new Error("Get all method is not supported for Aptos chain!");
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Attempts updating the stream auto withdrawal params and amount per period
|
|
746
|
-
*/
|
|
747
|
-
async update(updateData, { senderWallet, tokenId }) {
|
|
748
|
-
const wallet = new AptosWalletWrapper(senderWallet, this.client);
|
|
749
|
-
const payload = {
|
|
750
|
-
type: "update",
|
|
751
|
-
function: `${this.programId}::protocol::update`,
|
|
752
|
-
type_arguments: [tokenId],
|
|
753
|
-
arguments: [
|
|
754
|
-
updateData.id,
|
|
755
|
-
updateData.enableAutomaticWithdrawal ? [true] : [],
|
|
756
|
-
updateData.withdrawFrequency ? [updateData.withdrawFrequency.toString()] : [],
|
|
757
|
-
updateData.amountPerPeriod ? [updateData.amountPerPeriod.toString()] : []
|
|
758
|
-
]
|
|
759
|
-
};
|
|
760
|
-
const hash = await wallet.signAndSubmitTransaction(payload);
|
|
761
|
-
return { ixs: [payload], txId: hash };
|
|
762
|
-
}
|
|
763
|
-
async getFees({ address }) {
|
|
764
|
-
const resource = await this.client.getAccountResource(this.programId, `${this.programId}::fees::FeeTable`);
|
|
765
|
-
const data = resource.data;
|
|
766
|
-
const value = await this.client.getTableItem(data.values.handle, {
|
|
767
|
-
key_type: "address",
|
|
768
|
-
key: address,
|
|
769
|
-
value_type: "u64"
|
|
770
|
-
});
|
|
771
|
-
if (!value) {
|
|
772
|
-
return null;
|
|
773
|
-
}
|
|
774
|
-
return { streamflowFee: Number(value) / 100, partnerFee: 0 };
|
|
775
|
-
}
|
|
776
|
-
async getDefaultStreamflowFee() {
|
|
777
|
-
const resource = await this.client.getAccountResource(this.programId, `${this.programId}::admin::ConfigV2`);
|
|
778
|
-
return Number(resource.data.streamflow_fees) / 100;
|
|
779
|
-
}
|
|
780
|
-
extractErrorCode(err) {
|
|
781
|
-
return extractAptosErrorCode(err.toString() ?? "Unknown error!");
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Returns StreamClient protocol program ID.
|
|
785
|
-
*/
|
|
786
|
-
getProgramId() {
|
|
787
|
-
return this.programId;
|
|
788
|
-
}
|
|
789
|
-
getMaxGas() {
|
|
790
|
-
return { max_gas_amount: this.maxGas };
|
|
791
|
-
}
|
|
792
|
-
// Utility function to prepare transaction payloads for multiple recipients.
|
|
793
|
-
generateMultiPayloads(multipleStreamData, wallet) {
|
|
794
|
-
return multipleStreamData.recipients.map((recipient) => {
|
|
795
|
-
const acc = new AptosAccount();
|
|
796
|
-
const seeds = acc.address();
|
|
797
|
-
const encoder = new TextEncoder();
|
|
798
|
-
const actualSeeds = encoder.encode(seeds.hex());
|
|
799
|
-
const metadataId = AptosAccount.getResourceAccountAddress(wallet.address, actualSeeds);
|
|
800
|
-
return [
|
|
801
|
-
metadataId.toString(),
|
|
802
|
-
{
|
|
803
|
-
type: "create",
|
|
804
|
-
function: `${this.programId}::protocol::create`,
|
|
805
|
-
type_arguments: [multipleStreamData.tokenId],
|
|
806
|
-
arguments: [
|
|
807
|
-
seeds.hex(),
|
|
808
|
-
recipient.amount.toString(),
|
|
809
|
-
multipleStreamData.period,
|
|
810
|
-
recipient.amountPerPeriod.toString(),
|
|
811
|
-
multipleStreamData.start,
|
|
812
|
-
recipient.cliffAmount.toString(),
|
|
813
|
-
multipleStreamData.cancelableBySender,
|
|
814
|
-
multipleStreamData.cancelableByRecipient,
|
|
815
|
-
multipleStreamData.transferableBySender,
|
|
816
|
-
multipleStreamData.transferableByRecipient,
|
|
817
|
-
multipleStreamData.canTopup,
|
|
818
|
-
multipleStreamData.canPause || false,
|
|
819
|
-
multipleStreamData.canUpdateRate || false,
|
|
820
|
-
multipleStreamData.automaticWithdrawal || false,
|
|
821
|
-
multipleStreamData.withdrawalFrequency || 0,
|
|
822
|
-
recipient.name,
|
|
823
|
-
recipient.recipient
|
|
824
|
-
]
|
|
825
|
-
}
|
|
826
|
-
];
|
|
827
|
-
});
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
|
|
831
|
-
// evm/index.ts
|
|
832
|
-
var evm_exports = {};
|
|
833
|
-
__export(evm_exports, {
|
|
834
|
-
EvmContract: () => EvmContract,
|
|
835
|
-
EvmStreamClient: () => EvmStreamClient,
|
|
836
|
-
constants: () => constants_exports2,
|
|
837
|
-
default: () => EvmStreamClient,
|
|
838
|
-
ercAbi: () => ercAbi_default,
|
|
839
|
-
extractEvmErrorCode: () => extractEvmErrorCode
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
// evm/constants.ts
|
|
843
|
-
var constants_exports2 = {};
|
|
844
|
-
__export(constants_exports2, {
|
|
845
|
-
BNB_PROGRAM_IDS: () => BNB_PROGRAM_IDS,
|
|
846
|
-
ETHEREUM_PROGRAM_IDS: () => ETHEREUM_PROGRAM_IDS,
|
|
847
|
-
EVM_ERROR_MAP: () => EVM_ERROR_MAP,
|
|
848
|
-
EVM_ERROR_MATCH_REGEX: () => EVM_ERROR_MATCH_REGEX,
|
|
849
|
-
POLYGON_PROGRAM_IDS: () => POLYGON_PROGRAM_IDS
|
|
850
|
-
});
|
|
851
|
-
var ETHEREUM_PROGRAM_IDS = {
|
|
852
|
-
[ICluster.Mainnet]: "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
|
|
853
|
-
[ICluster.Devnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
854
|
-
[ICluster.Testnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
855
|
-
[ICluster.Local]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d"
|
|
856
|
-
};
|
|
857
|
-
var BNB_PROGRAM_IDS = {
|
|
858
|
-
[ICluster.Mainnet]: "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
|
|
859
|
-
[ICluster.Devnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
860
|
-
[ICluster.Testnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
861
|
-
[ICluster.Local]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d"
|
|
862
|
-
};
|
|
863
|
-
var POLYGON_PROGRAM_IDS = {
|
|
864
|
-
[ICluster.Mainnet]: "0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2",
|
|
865
|
-
[ICluster.Devnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
866
|
-
[ICluster.Testnet]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d",
|
|
867
|
-
[ICluster.Local]: "0x5Db7a43D20De64E3a3BC765334a477026FD13E7d"
|
|
868
|
-
};
|
|
869
|
-
var EVM_ERROR_MATCH_REGEX = /execution reverted: ([A-Z_]+)/;
|
|
870
|
-
var EVM_ERROR_MAP = {
|
|
871
|
-
ECONTRACT_NOT_INIT: "ECONTRACT_NOT_INIT" /* ECONTRACT_NOT_INIT */,
|
|
872
|
-
EBAD_AMOUNT: "EBAD_AMOUNT" /* EBAD_AMOUNT */,
|
|
873
|
-
ENO_PERMISSIONS: "ENO_PERMISSIONS" /* ENO_PERMISSIONS */,
|
|
874
|
-
EBADINPUT: "EBADINPUT" /* EBADINPUT */,
|
|
875
|
-
ECLOSED: "ECLOSED" /* ECLOSED */,
|
|
876
|
-
EBAD_INPUT_AMOUNT_PER_PERIOD: "EBAD_INPUT_AMOUNT_PER_PERIOD" /* EBAD_INPUT_AMOUNT_PER_PERIOD */,
|
|
877
|
-
EBAD_INPUT_PAUSABLE: "EBAD_INPUT_PAUSABLE" /* EBAD_INPUT_PAUSABLE */,
|
|
878
|
-
EBAD_INPUT_UPDATE_RATE: "EBAD_INPUT_UPDATE_RATE" /* EBAD_INPUT_UPDATE_RATE */,
|
|
879
|
-
EBAD_INPUT_CLIFF_AMOUNT: "EBAD_INPUT_CLIFF_AMOUNT" /* EBAD_INPUT_CLIFF_AMOUNT */,
|
|
880
|
-
EBAD_INPUT_PERIOD: "EBAD_INPUT_PERIOD" /* EBAD_INPUT_PERIOD */,
|
|
881
|
-
EBAD_INPUT_START: "EBAD_INPUT_START" /* EBAD_INPUT_START */,
|
|
882
|
-
EBAD_INSUFFICIENT_TOKEN_ALLOWANCE: "EBAD_INSUFFICIENT_TOKEN_ALLOWANCE" /* EBAD_INSUFFICIENT_TOKEN_ALLOWANCE */,
|
|
883
|
-
EBAD_INSUFFICIENT_WITHDRAWAL_FEES: "EBAD_INSUFFICIENT_WITHDRAWAL_FEES" /* EBAD_INSUFFICIENT_WITHDRAWAL_FEES */
|
|
884
|
-
};
|
|
885
|
-
|
|
886
|
-
// evm/abi.ts
|
|
887
|
-
var abi_default = [
|
|
888
|
-
{
|
|
889
|
-
anonymous: false,
|
|
890
|
-
inputs: [
|
|
891
|
-
{
|
|
892
|
-
indexed: false,
|
|
893
|
-
internalType: "address",
|
|
894
|
-
name: "",
|
|
895
|
-
type: "address"
|
|
896
|
-
}
|
|
897
|
-
],
|
|
898
|
-
name: "ContractCreated",
|
|
899
|
-
type: "event"
|
|
900
|
-
},
|
|
901
|
-
{
|
|
902
|
-
inputs: [
|
|
903
|
-
{
|
|
904
|
-
internalType: "address",
|
|
905
|
-
name: "_stream_id",
|
|
906
|
-
type: "address"
|
|
907
|
-
}
|
|
908
|
-
],
|
|
909
|
-
name: "cancel",
|
|
910
|
-
outputs: [],
|
|
911
|
-
stateMutability: "nonpayable",
|
|
912
|
-
type: "function"
|
|
913
|
-
},
|
|
914
|
-
{
|
|
915
|
-
inputs: [
|
|
916
|
-
{
|
|
917
|
-
internalType: "uint256",
|
|
918
|
-
name: "_new_fees",
|
|
919
|
-
type: "uint256"
|
|
920
|
-
}
|
|
921
|
-
],
|
|
922
|
-
name: "changeStreamflowFees",
|
|
923
|
-
outputs: [],
|
|
924
|
-
stateMutability: "nonpayable",
|
|
925
|
-
type: "function"
|
|
926
|
-
},
|
|
927
|
-
{
|
|
928
|
-
inputs: [
|
|
929
|
-
{
|
|
930
|
-
internalType: "address payable",
|
|
931
|
-
name: "_new_treasury",
|
|
932
|
-
type: "address"
|
|
933
|
-
}
|
|
934
|
-
],
|
|
935
|
-
name: "changeTreasury",
|
|
936
|
-
outputs: [],
|
|
937
|
-
stateMutability: "nonpayable",
|
|
938
|
-
type: "function"
|
|
939
|
-
},
|
|
940
|
-
{
|
|
941
|
-
inputs: [
|
|
942
|
-
{
|
|
943
|
-
internalType: "uint256",
|
|
944
|
-
name: "_new_fee",
|
|
945
|
-
type: "uint256"
|
|
946
|
-
}
|
|
947
|
-
],
|
|
948
|
-
name: "changeTxFee",
|
|
949
|
-
outputs: [],
|
|
950
|
-
stateMutability: "nonpayable",
|
|
951
|
-
type: "function"
|
|
952
|
-
},
|
|
953
|
-
{
|
|
954
|
-
inputs: [
|
|
955
|
-
{
|
|
956
|
-
internalType: "address payable",
|
|
957
|
-
name: "_new_withdawor",
|
|
958
|
-
type: "address"
|
|
959
|
-
}
|
|
960
|
-
],
|
|
961
|
-
name: "changeWithdrawor",
|
|
962
|
-
outputs: [],
|
|
963
|
-
stateMutability: "nonpayable",
|
|
964
|
-
type: "function"
|
|
965
|
-
},
|
|
966
|
-
{
|
|
967
|
-
inputs: [],
|
|
968
|
-
name: "config",
|
|
969
|
-
outputs: [
|
|
970
|
-
{
|
|
971
|
-
internalType: "address",
|
|
972
|
-
name: "admin",
|
|
973
|
-
type: "address"
|
|
974
|
-
},
|
|
975
|
-
{
|
|
976
|
-
internalType: "uint256",
|
|
977
|
-
name: "streamflow_fees",
|
|
978
|
-
type: "uint256"
|
|
979
|
-
},
|
|
980
|
-
{
|
|
981
|
-
internalType: "address payable",
|
|
982
|
-
name: "treasury",
|
|
983
|
-
type: "address"
|
|
984
|
-
},
|
|
985
|
-
{
|
|
986
|
-
internalType: "address payable",
|
|
987
|
-
name: "withdrawor",
|
|
988
|
-
type: "address"
|
|
989
|
-
},
|
|
990
|
-
{
|
|
991
|
-
internalType: "uint256",
|
|
992
|
-
name: "tx_fee",
|
|
993
|
-
type: "uint256"
|
|
994
|
-
}
|
|
995
|
-
],
|
|
996
|
-
stateMutability: "view",
|
|
997
|
-
type: "function"
|
|
998
|
-
},
|
|
999
|
-
{
|
|
1000
|
-
inputs: [
|
|
1001
|
-
{
|
|
1002
|
-
internalType: "contract IERC20",
|
|
1003
|
-
name: "_token",
|
|
1004
|
-
type: "address"
|
|
1005
|
-
},
|
|
1006
|
-
{
|
|
1007
|
-
internalType: "uint256",
|
|
1008
|
-
name: "_amount",
|
|
1009
|
-
type: "uint256"
|
|
1010
|
-
},
|
|
1011
|
-
{
|
|
1012
|
-
internalType: "uint256",
|
|
1013
|
-
name: "_period",
|
|
1014
|
-
type: "uint256"
|
|
1015
|
-
},
|
|
1016
|
-
{
|
|
1017
|
-
internalType: "uint256",
|
|
1018
|
-
name: "_amount_per_period",
|
|
1019
|
-
type: "uint256"
|
|
1020
|
-
},
|
|
1021
|
-
{
|
|
1022
|
-
internalType: "uint256",
|
|
1023
|
-
name: "_start",
|
|
1024
|
-
type: "uint256"
|
|
1025
|
-
},
|
|
1026
|
-
{
|
|
1027
|
-
internalType: "uint256",
|
|
1028
|
-
name: "_cliff_amount",
|
|
1029
|
-
type: "uint256"
|
|
1030
|
-
},
|
|
1031
|
-
{
|
|
1032
|
-
components: [
|
|
1033
|
-
{
|
|
1034
|
-
internalType: "bool",
|
|
1035
|
-
name: "cancelable_by_sender",
|
|
1036
|
-
type: "bool"
|
|
1037
|
-
},
|
|
1038
|
-
{
|
|
1039
|
-
internalType: "bool",
|
|
1040
|
-
name: "cancelable_by_recipient",
|
|
1041
|
-
type: "bool"
|
|
1042
|
-
},
|
|
1043
|
-
{
|
|
1044
|
-
internalType: "bool",
|
|
1045
|
-
name: "transferable_by_sender",
|
|
1046
|
-
type: "bool"
|
|
1047
|
-
},
|
|
1048
|
-
{
|
|
1049
|
-
internalType: "bool",
|
|
1050
|
-
name: "transferable_by_recipient",
|
|
1051
|
-
type: "bool"
|
|
1052
|
-
},
|
|
1053
|
-
{
|
|
1054
|
-
internalType: "bool",
|
|
1055
|
-
name: "can_topup",
|
|
1056
|
-
type: "bool"
|
|
1057
|
-
},
|
|
1058
|
-
{
|
|
1059
|
-
internalType: "bool",
|
|
1060
|
-
name: "pausable",
|
|
1061
|
-
type: "bool"
|
|
1062
|
-
},
|
|
1063
|
-
{
|
|
1064
|
-
internalType: "bool",
|
|
1065
|
-
name: "can_update_rate",
|
|
1066
|
-
type: "bool"
|
|
1067
|
-
},
|
|
1068
|
-
{
|
|
1069
|
-
internalType: "bool",
|
|
1070
|
-
name: "automatic_withdrawal",
|
|
1071
|
-
type: "bool"
|
|
1072
|
-
},
|
|
1073
|
-
{
|
|
1074
|
-
internalType: "uint256",
|
|
1075
|
-
name: "withdrawal_frequency",
|
|
1076
|
-
type: "uint256"
|
|
1077
|
-
},
|
|
1078
|
-
{
|
|
1079
|
-
internalType: "string",
|
|
1080
|
-
name: "contract_name",
|
|
1081
|
-
type: "string"
|
|
1082
|
-
}
|
|
1083
|
-
],
|
|
1084
|
-
internalType: "struct ContractMeta",
|
|
1085
|
-
name: "_meta",
|
|
1086
|
-
type: "tuple"
|
|
1087
|
-
},
|
|
1088
|
-
{
|
|
1089
|
-
internalType: "address",
|
|
1090
|
-
name: "_recipient",
|
|
1091
|
-
type: "address"
|
|
1092
|
-
},
|
|
1093
|
-
{
|
|
1094
|
-
internalType: "address",
|
|
1095
|
-
name: "_partner",
|
|
1096
|
-
type: "address"
|
|
1097
|
-
}
|
|
1098
|
-
],
|
|
1099
|
-
name: "create",
|
|
1100
|
-
outputs: [],
|
|
1101
|
-
stateMutability: "payable",
|
|
1102
|
-
type: "function"
|
|
1103
|
-
},
|
|
1104
|
-
{
|
|
1105
|
-
inputs: [
|
|
1106
|
-
{
|
|
1107
|
-
internalType: "address",
|
|
1108
|
-
name: "_address",
|
|
1109
|
-
type: "address"
|
|
1110
|
-
}
|
|
1111
|
-
],
|
|
1112
|
-
name: "feesRemove",
|
|
1113
|
-
outputs: [],
|
|
1114
|
-
stateMutability: "nonpayable",
|
|
1115
|
-
type: "function"
|
|
1116
|
-
},
|
|
1117
|
-
{
|
|
1118
|
-
inputs: [
|
|
1119
|
-
{
|
|
1120
|
-
internalType: "address",
|
|
1121
|
-
name: "_address",
|
|
1122
|
-
type: "address"
|
|
1123
|
-
},
|
|
1124
|
-
{
|
|
1125
|
-
internalType: "uint256",
|
|
1126
|
-
name: "streamflow_fee",
|
|
1127
|
-
type: "uint256"
|
|
1128
|
-
},
|
|
1129
|
-
{
|
|
1130
|
-
internalType: "uint256",
|
|
1131
|
-
name: "partner_fee",
|
|
1132
|
-
type: "uint256"
|
|
1133
|
-
}
|
|
1134
|
-
],
|
|
1135
|
-
name: "feesWrite",
|
|
1136
|
-
outputs: [],
|
|
1137
|
-
stateMutability: "nonpayable",
|
|
1138
|
-
type: "function"
|
|
1139
|
-
},
|
|
1140
|
-
{
|
|
1141
|
-
inputs: [],
|
|
1142
|
-
name: "getAdmin",
|
|
1143
|
-
outputs: [
|
|
1144
|
-
{
|
|
1145
|
-
internalType: "address",
|
|
1146
|
-
name: "",
|
|
1147
|
-
type: "address"
|
|
1148
|
-
}
|
|
1149
|
-
],
|
|
1150
|
-
stateMutability: "view",
|
|
1151
|
-
type: "function"
|
|
1152
|
-
},
|
|
1153
|
-
{
|
|
1154
|
-
inputs: [],
|
|
1155
|
-
name: "getAll",
|
|
1156
|
-
outputs: [
|
|
1157
|
-
{
|
|
1158
|
-
internalType: "address[]",
|
|
1159
|
-
name: "",
|
|
1160
|
-
type: "address[]"
|
|
1161
|
-
},
|
|
1162
|
-
{
|
|
1163
|
-
components: [
|
|
1164
|
-
{
|
|
1165
|
-
internalType: "contract IERC20",
|
|
1166
|
-
name: "token",
|
|
1167
|
-
type: "address"
|
|
1168
|
-
},
|
|
1169
|
-
{
|
|
1170
|
-
components: [
|
|
1171
|
-
{
|
|
1172
|
-
internalType: "bool",
|
|
1173
|
-
name: "cancelable_by_sender",
|
|
1174
|
-
type: "bool"
|
|
1175
|
-
},
|
|
1176
|
-
{
|
|
1177
|
-
internalType: "bool",
|
|
1178
|
-
name: "cancelable_by_recipient",
|
|
1179
|
-
type: "bool"
|
|
1180
|
-
},
|
|
1181
|
-
{
|
|
1182
|
-
internalType: "bool",
|
|
1183
|
-
name: "transferable_by_sender",
|
|
1184
|
-
type: "bool"
|
|
1185
|
-
},
|
|
1186
|
-
{
|
|
1187
|
-
internalType: "bool",
|
|
1188
|
-
name: "transferable_by_recipient",
|
|
1189
|
-
type: "bool"
|
|
1190
|
-
},
|
|
1191
|
-
{
|
|
1192
|
-
internalType: "bool",
|
|
1193
|
-
name: "can_topup",
|
|
1194
|
-
type: "bool"
|
|
1195
|
-
},
|
|
1196
|
-
{
|
|
1197
|
-
internalType: "bool",
|
|
1198
|
-
name: "pausable",
|
|
1199
|
-
type: "bool"
|
|
1200
|
-
},
|
|
1201
|
-
{
|
|
1202
|
-
internalType: "bool",
|
|
1203
|
-
name: "can_update_rate",
|
|
1204
|
-
type: "bool"
|
|
1205
|
-
},
|
|
1206
|
-
{
|
|
1207
|
-
internalType: "bool",
|
|
1208
|
-
name: "automatic_withdrawal",
|
|
1209
|
-
type: "bool"
|
|
1210
|
-
},
|
|
1211
|
-
{
|
|
1212
|
-
internalType: "uint256",
|
|
1213
|
-
name: "withdrawal_frequency",
|
|
1214
|
-
type: "uint256"
|
|
1215
|
-
},
|
|
1216
|
-
{
|
|
1217
|
-
internalType: "string",
|
|
1218
|
-
name: "contract_name",
|
|
1219
|
-
type: "string"
|
|
1220
|
-
}
|
|
1221
|
-
],
|
|
1222
|
-
internalType: "struct ContractMeta",
|
|
1223
|
-
name: "meta",
|
|
1224
|
-
type: "tuple"
|
|
1225
|
-
},
|
|
1226
|
-
{
|
|
1227
|
-
internalType: "uint256",
|
|
1228
|
-
name: "amount",
|
|
1229
|
-
type: "uint256"
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
internalType: "uint256",
|
|
1233
|
-
name: "period",
|
|
1234
|
-
type: "uint256"
|
|
1235
|
-
},
|
|
1236
|
-
{
|
|
1237
|
-
internalType: "uint256",
|
|
1238
|
-
name: "amount_per_period",
|
|
1239
|
-
type: "uint256"
|
|
1240
|
-
},
|
|
1241
|
-
{
|
|
1242
|
-
internalType: "uint256",
|
|
1243
|
-
name: "start",
|
|
1244
|
-
type: "uint256"
|
|
1245
|
-
},
|
|
1246
|
-
{
|
|
1247
|
-
internalType: "uint256",
|
|
1248
|
-
name: "end",
|
|
1249
|
-
type: "uint256"
|
|
1250
|
-
},
|
|
1251
|
-
{
|
|
1252
|
-
internalType: "uint256",
|
|
1253
|
-
name: "cliff_amount",
|
|
1254
|
-
type: "uint256"
|
|
1255
|
-
},
|
|
1256
|
-
{
|
|
1257
|
-
internalType: "uint256",
|
|
1258
|
-
name: "withdrawn",
|
|
1259
|
-
type: "uint256"
|
|
1260
|
-
},
|
|
1261
|
-
{
|
|
1262
|
-
internalType: "uint256",
|
|
1263
|
-
name: "last_withdrawn_at",
|
|
1264
|
-
type: "uint256"
|
|
1265
|
-
},
|
|
1266
|
-
{
|
|
1267
|
-
internalType: "uint256",
|
|
1268
|
-
name: "created",
|
|
1269
|
-
type: "uint256"
|
|
1270
|
-
},
|
|
1271
|
-
{
|
|
1272
|
-
internalType: "uint256",
|
|
1273
|
-
name: "canceled_at",
|
|
1274
|
-
type: "uint256"
|
|
1275
|
-
},
|
|
1276
|
-
{
|
|
1277
|
-
internalType: "address",
|
|
1278
|
-
name: "recipient",
|
|
1279
|
-
type: "address"
|
|
1280
|
-
},
|
|
1281
|
-
{
|
|
1282
|
-
internalType: "address",
|
|
1283
|
-
name: "sender",
|
|
1284
|
-
type: "address"
|
|
1285
|
-
},
|
|
1286
|
-
{
|
|
1287
|
-
internalType: "address",
|
|
1288
|
-
name: "partner",
|
|
1289
|
-
type: "address"
|
|
1290
|
-
},
|
|
1291
|
-
{
|
|
1292
|
-
components: [
|
|
1293
|
-
{
|
|
1294
|
-
internalType: "uint256",
|
|
1295
|
-
name: "streamflow_fee_percentage",
|
|
1296
|
-
type: "uint256"
|
|
1297
|
-
},
|
|
1298
|
-
{
|
|
1299
|
-
internalType: "uint256",
|
|
1300
|
-
name: "streamflow_fee",
|
|
1301
|
-
type: "uint256"
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
internalType: "uint256",
|
|
1305
|
-
name: "streamflow_fee_withdrawn",
|
|
1306
|
-
type: "uint256"
|
|
1307
|
-
},
|
|
1308
|
-
{
|
|
1309
|
-
internalType: "uint256",
|
|
1310
|
-
name: "partner_fee_percentage",
|
|
1311
|
-
type: "uint256"
|
|
1312
|
-
},
|
|
1313
|
-
{
|
|
1314
|
-
internalType: "uint256",
|
|
1315
|
-
name: "partner_fee",
|
|
1316
|
-
type: "uint256"
|
|
1317
|
-
},
|
|
1318
|
-
{
|
|
1319
|
-
internalType: "uint256",
|
|
1320
|
-
name: "partner_fee_withdrawn",
|
|
1321
|
-
type: "uint256"
|
|
1322
|
-
},
|
|
1323
|
-
{
|
|
1324
|
-
internalType: "uint256",
|
|
1325
|
-
name: "tx_fee",
|
|
1326
|
-
type: "uint256"
|
|
1327
|
-
}
|
|
1328
|
-
],
|
|
1329
|
-
internalType: "struct FeesData",
|
|
1330
|
-
name: "fees",
|
|
1331
|
-
type: "tuple"
|
|
1332
|
-
},
|
|
1333
|
-
{
|
|
1334
|
-
internalType: "bool",
|
|
1335
|
-
name: "closed",
|
|
1336
|
-
type: "bool"
|
|
1337
|
-
},
|
|
1338
|
-
{
|
|
1339
|
-
internalType: "uint256",
|
|
1340
|
-
name: "current_pause_start",
|
|
1341
|
-
type: "uint256"
|
|
1342
|
-
},
|
|
1343
|
-
{
|
|
1344
|
-
internalType: "uint256",
|
|
1345
|
-
name: "pause_cumulative",
|
|
1346
|
-
type: "uint256"
|
|
1347
|
-
},
|
|
1348
|
-
{
|
|
1349
|
-
internalType: "uint256",
|
|
1350
|
-
name: "last_rate_change_time",
|
|
1351
|
-
type: "uint256"
|
|
1352
|
-
},
|
|
1353
|
-
{
|
|
1354
|
-
internalType: "uint256",
|
|
1355
|
-
name: "funds_unlocked_at_last_rate_change",
|
|
1356
|
-
type: "uint256"
|
|
1357
|
-
}
|
|
1358
|
-
],
|
|
1359
|
-
internalType: "struct Contract[]",
|
|
1360
|
-
name: "",
|
|
1361
|
-
type: "tuple[]"
|
|
1362
|
-
}
|
|
1363
|
-
],
|
|
1364
|
-
stateMutability: "view",
|
|
1365
|
-
type: "function"
|
|
1366
|
-
},
|
|
1367
|
-
{
|
|
1368
|
-
inputs: [
|
|
1369
|
-
{
|
|
1370
|
-
internalType: "address",
|
|
1371
|
-
name: "_id",
|
|
1372
|
-
type: "address"
|
|
1373
|
-
}
|
|
1374
|
-
],
|
|
1375
|
-
name: "getById",
|
|
1376
|
-
outputs: [
|
|
1377
|
-
{
|
|
1378
|
-
components: [
|
|
1379
|
-
{
|
|
1380
|
-
internalType: "contract IERC20",
|
|
1381
|
-
name: "token",
|
|
1382
|
-
type: "address"
|
|
1383
|
-
},
|
|
1384
|
-
{
|
|
1385
|
-
components: [
|
|
1386
|
-
{
|
|
1387
|
-
internalType: "bool",
|
|
1388
|
-
name: "cancelable_by_sender",
|
|
1389
|
-
type: "bool"
|
|
1390
|
-
},
|
|
1391
|
-
{
|
|
1392
|
-
internalType: "bool",
|
|
1393
|
-
name: "cancelable_by_recipient",
|
|
1394
|
-
type: "bool"
|
|
1395
|
-
},
|
|
1396
|
-
{
|
|
1397
|
-
internalType: "bool",
|
|
1398
|
-
name: "transferable_by_sender",
|
|
1399
|
-
type: "bool"
|
|
1400
|
-
},
|
|
1401
|
-
{
|
|
1402
|
-
internalType: "bool",
|
|
1403
|
-
name: "transferable_by_recipient",
|
|
1404
|
-
type: "bool"
|
|
1405
|
-
},
|
|
1406
|
-
{
|
|
1407
|
-
internalType: "bool",
|
|
1408
|
-
name: "can_topup",
|
|
1409
|
-
type: "bool"
|
|
1410
|
-
},
|
|
1411
|
-
{
|
|
1412
|
-
internalType: "bool",
|
|
1413
|
-
name: "pausable",
|
|
1414
|
-
type: "bool"
|
|
1415
|
-
},
|
|
1416
|
-
{
|
|
1417
|
-
internalType: "bool",
|
|
1418
|
-
name: "can_update_rate",
|
|
1419
|
-
type: "bool"
|
|
1420
|
-
},
|
|
1421
|
-
{
|
|
1422
|
-
internalType: "bool",
|
|
1423
|
-
name: "automatic_withdrawal",
|
|
1424
|
-
type: "bool"
|
|
1425
|
-
},
|
|
1426
|
-
{
|
|
1427
|
-
internalType: "uint256",
|
|
1428
|
-
name: "withdrawal_frequency",
|
|
1429
|
-
type: "uint256"
|
|
1430
|
-
},
|
|
1431
|
-
{
|
|
1432
|
-
internalType: "string",
|
|
1433
|
-
name: "contract_name",
|
|
1434
|
-
type: "string"
|
|
1435
|
-
}
|
|
1436
|
-
],
|
|
1437
|
-
internalType: "struct ContractMeta",
|
|
1438
|
-
name: "meta",
|
|
1439
|
-
type: "tuple"
|
|
1440
|
-
},
|
|
1441
|
-
{
|
|
1442
|
-
internalType: "uint256",
|
|
1443
|
-
name: "amount",
|
|
1444
|
-
type: "uint256"
|
|
1445
|
-
},
|
|
1446
|
-
{
|
|
1447
|
-
internalType: "uint256",
|
|
1448
|
-
name: "period",
|
|
1449
|
-
type: "uint256"
|
|
1450
|
-
},
|
|
1451
|
-
{
|
|
1452
|
-
internalType: "uint256",
|
|
1453
|
-
name: "amount_per_period",
|
|
1454
|
-
type: "uint256"
|
|
1455
|
-
},
|
|
1456
|
-
{
|
|
1457
|
-
internalType: "uint256",
|
|
1458
|
-
name: "start",
|
|
1459
|
-
type: "uint256"
|
|
1460
|
-
},
|
|
1461
|
-
{
|
|
1462
|
-
internalType: "uint256",
|
|
1463
|
-
name: "end",
|
|
1464
|
-
type: "uint256"
|
|
1465
|
-
},
|
|
1466
|
-
{
|
|
1467
|
-
internalType: "uint256",
|
|
1468
|
-
name: "cliff_amount",
|
|
1469
|
-
type: "uint256"
|
|
1470
|
-
},
|
|
1471
|
-
{
|
|
1472
|
-
internalType: "uint256",
|
|
1473
|
-
name: "withdrawn",
|
|
1474
|
-
type: "uint256"
|
|
1475
|
-
},
|
|
1476
|
-
{
|
|
1477
|
-
internalType: "uint256",
|
|
1478
|
-
name: "last_withdrawn_at",
|
|
1479
|
-
type: "uint256"
|
|
1480
|
-
},
|
|
1481
|
-
{
|
|
1482
|
-
internalType: "uint256",
|
|
1483
|
-
name: "created",
|
|
1484
|
-
type: "uint256"
|
|
1485
|
-
},
|
|
1486
|
-
{
|
|
1487
|
-
internalType: "uint256",
|
|
1488
|
-
name: "canceled_at",
|
|
1489
|
-
type: "uint256"
|
|
1490
|
-
},
|
|
1491
|
-
{
|
|
1492
|
-
internalType: "address",
|
|
1493
|
-
name: "recipient",
|
|
1494
|
-
type: "address"
|
|
1495
|
-
},
|
|
1496
|
-
{
|
|
1497
|
-
internalType: "address",
|
|
1498
|
-
name: "sender",
|
|
1499
|
-
type: "address"
|
|
1500
|
-
},
|
|
1501
|
-
{
|
|
1502
|
-
internalType: "address",
|
|
1503
|
-
name: "partner",
|
|
1504
|
-
type: "address"
|
|
1505
|
-
},
|
|
1506
|
-
{
|
|
1507
|
-
components: [
|
|
1508
|
-
{
|
|
1509
|
-
internalType: "uint256",
|
|
1510
|
-
name: "streamflow_fee_percentage",
|
|
1511
|
-
type: "uint256"
|
|
1512
|
-
},
|
|
1513
|
-
{
|
|
1514
|
-
internalType: "uint256",
|
|
1515
|
-
name: "streamflow_fee",
|
|
1516
|
-
type: "uint256"
|
|
1517
|
-
},
|
|
1518
|
-
{
|
|
1519
|
-
internalType: "uint256",
|
|
1520
|
-
name: "streamflow_fee_withdrawn",
|
|
1521
|
-
type: "uint256"
|
|
1522
|
-
},
|
|
1523
|
-
{
|
|
1524
|
-
internalType: "uint256",
|
|
1525
|
-
name: "partner_fee_percentage",
|
|
1526
|
-
type: "uint256"
|
|
1527
|
-
},
|
|
1528
|
-
{
|
|
1529
|
-
internalType: "uint256",
|
|
1530
|
-
name: "partner_fee",
|
|
1531
|
-
type: "uint256"
|
|
1532
|
-
},
|
|
1533
|
-
{
|
|
1534
|
-
internalType: "uint256",
|
|
1535
|
-
name: "partner_fee_withdrawn",
|
|
1536
|
-
type: "uint256"
|
|
1537
|
-
},
|
|
1538
|
-
{
|
|
1539
|
-
internalType: "uint256",
|
|
1540
|
-
name: "tx_fee",
|
|
1541
|
-
type: "uint256"
|
|
1542
|
-
}
|
|
1543
|
-
],
|
|
1544
|
-
internalType: "struct FeesData",
|
|
1545
|
-
name: "fees",
|
|
1546
|
-
type: "tuple"
|
|
1547
|
-
},
|
|
1548
|
-
{
|
|
1549
|
-
internalType: "bool",
|
|
1550
|
-
name: "closed",
|
|
1551
|
-
type: "bool"
|
|
1552
|
-
},
|
|
1553
|
-
{
|
|
1554
|
-
internalType: "uint256",
|
|
1555
|
-
name: "current_pause_start",
|
|
1556
|
-
type: "uint256"
|
|
1557
|
-
},
|
|
1558
|
-
{
|
|
1559
|
-
internalType: "uint256",
|
|
1560
|
-
name: "pause_cumulative",
|
|
1561
|
-
type: "uint256"
|
|
1562
|
-
},
|
|
1563
|
-
{
|
|
1564
|
-
internalType: "uint256",
|
|
1565
|
-
name: "last_rate_change_time",
|
|
1566
|
-
type: "uint256"
|
|
1567
|
-
},
|
|
1568
|
-
{
|
|
1569
|
-
internalType: "uint256",
|
|
1570
|
-
name: "funds_unlocked_at_last_rate_change",
|
|
1571
|
-
type: "uint256"
|
|
1572
|
-
}
|
|
1573
|
-
],
|
|
1574
|
-
internalType: "struct Contract",
|
|
1575
|
-
name: "",
|
|
1576
|
-
type: "tuple"
|
|
1577
|
-
}
|
|
1578
|
-
],
|
|
1579
|
-
stateMutability: "view",
|
|
1580
|
-
type: "function"
|
|
1581
|
-
},
|
|
1582
|
-
{
|
|
1583
|
-
inputs: [
|
|
1584
|
-
{
|
|
1585
|
-
internalType: "address",
|
|
1586
|
-
name: "_recipient",
|
|
1587
|
-
type: "address"
|
|
1588
|
-
}
|
|
1589
|
-
],
|
|
1590
|
-
name: "getByRecipient",
|
|
1591
|
-
outputs: [
|
|
1592
|
-
{
|
|
1593
|
-
internalType: "address[]",
|
|
1594
|
-
name: "",
|
|
1595
|
-
type: "address[]"
|
|
1596
|
-
}
|
|
1597
|
-
],
|
|
1598
|
-
stateMutability: "view",
|
|
1599
|
-
type: "function"
|
|
1600
|
-
},
|
|
1601
|
-
{
|
|
1602
|
-
inputs: [
|
|
1603
|
-
{
|
|
1604
|
-
internalType: "address",
|
|
1605
|
-
name: "_sender",
|
|
1606
|
-
type: "address"
|
|
1607
|
-
}
|
|
1608
|
-
],
|
|
1609
|
-
name: "getBySender",
|
|
1610
|
-
outputs: [
|
|
1611
|
-
{
|
|
1612
|
-
internalType: "address[]",
|
|
1613
|
-
name: "",
|
|
1614
|
-
type: "address[]"
|
|
1615
|
-
}
|
|
1616
|
-
],
|
|
1617
|
-
stateMutability: "view",
|
|
1618
|
-
type: "function"
|
|
1619
|
-
},
|
|
1620
|
-
{
|
|
1621
|
-
inputs: [
|
|
1622
|
-
{
|
|
1623
|
-
internalType: "address",
|
|
1624
|
-
name: "_address",
|
|
1625
|
-
type: "address"
|
|
1626
|
-
}
|
|
1627
|
-
],
|
|
1628
|
-
name: "getFees",
|
|
1629
|
-
outputs: [
|
|
1630
|
-
{
|
|
1631
|
-
components: [
|
|
1632
|
-
{
|
|
1633
|
-
internalType: "bool",
|
|
1634
|
-
name: "exists",
|
|
1635
|
-
type: "bool"
|
|
1636
|
-
},
|
|
1637
|
-
{
|
|
1638
|
-
internalType: "uint256",
|
|
1639
|
-
name: "streamflow_fee",
|
|
1640
|
-
type: "uint256"
|
|
1641
|
-
},
|
|
1642
|
-
{
|
|
1643
|
-
internalType: "uint256",
|
|
1644
|
-
name: "partner_fee",
|
|
1645
|
-
type: "uint256"
|
|
1646
|
-
}
|
|
1647
|
-
],
|
|
1648
|
-
internalType: "struct StreamflowFeeManager.FeeValue",
|
|
1649
|
-
name: "",
|
|
1650
|
-
type: "tuple"
|
|
1651
|
-
}
|
|
1652
|
-
],
|
|
1653
|
-
stateMutability: "view",
|
|
1654
|
-
type: "function"
|
|
1655
|
-
},
|
|
1656
|
-
{
|
|
1657
|
-
inputs: [
|
|
1658
|
-
{
|
|
1659
|
-
internalType: "address[]",
|
|
1660
|
-
name: "_ids",
|
|
1661
|
-
type: "address[]"
|
|
1662
|
-
}
|
|
1663
|
-
],
|
|
1664
|
-
name: "getMultiple",
|
|
1665
|
-
outputs: [
|
|
1666
|
-
{
|
|
1667
|
-
components: [
|
|
1668
|
-
{
|
|
1669
|
-
internalType: "contract IERC20",
|
|
1670
|
-
name: "token",
|
|
1671
|
-
type: "address"
|
|
1672
|
-
},
|
|
1673
|
-
{
|
|
1674
|
-
components: [
|
|
1675
|
-
{
|
|
1676
|
-
internalType: "bool",
|
|
1677
|
-
name: "cancelable_by_sender",
|
|
1678
|
-
type: "bool"
|
|
1679
|
-
},
|
|
1680
|
-
{
|
|
1681
|
-
internalType: "bool",
|
|
1682
|
-
name: "cancelable_by_recipient",
|
|
1683
|
-
type: "bool"
|
|
1684
|
-
},
|
|
1685
|
-
{
|
|
1686
|
-
internalType: "bool",
|
|
1687
|
-
name: "transferable_by_sender",
|
|
1688
|
-
type: "bool"
|
|
1689
|
-
},
|
|
1690
|
-
{
|
|
1691
|
-
internalType: "bool",
|
|
1692
|
-
name: "transferable_by_recipient",
|
|
1693
|
-
type: "bool"
|
|
1694
|
-
},
|
|
1695
|
-
{
|
|
1696
|
-
internalType: "bool",
|
|
1697
|
-
name: "can_topup",
|
|
1698
|
-
type: "bool"
|
|
1699
|
-
},
|
|
1700
|
-
{
|
|
1701
|
-
internalType: "bool",
|
|
1702
|
-
name: "pausable",
|
|
1703
|
-
type: "bool"
|
|
1704
|
-
},
|
|
1705
|
-
{
|
|
1706
|
-
internalType: "bool",
|
|
1707
|
-
name: "can_update_rate",
|
|
1708
|
-
type: "bool"
|
|
1709
|
-
},
|
|
1710
|
-
{
|
|
1711
|
-
internalType: "bool",
|
|
1712
|
-
name: "automatic_withdrawal",
|
|
1713
|
-
type: "bool"
|
|
1714
|
-
},
|
|
1715
|
-
{
|
|
1716
|
-
internalType: "uint256",
|
|
1717
|
-
name: "withdrawal_frequency",
|
|
1718
|
-
type: "uint256"
|
|
1719
|
-
},
|
|
1720
|
-
{
|
|
1721
|
-
internalType: "string",
|
|
1722
|
-
name: "contract_name",
|
|
1723
|
-
type: "string"
|
|
1724
|
-
}
|
|
1725
|
-
],
|
|
1726
|
-
internalType: "struct ContractMeta",
|
|
1727
|
-
name: "meta",
|
|
1728
|
-
type: "tuple"
|
|
1729
|
-
},
|
|
1730
|
-
{
|
|
1731
|
-
internalType: "uint256",
|
|
1732
|
-
name: "amount",
|
|
1733
|
-
type: "uint256"
|
|
1734
|
-
},
|
|
1735
|
-
{
|
|
1736
|
-
internalType: "uint256",
|
|
1737
|
-
name: "period",
|
|
1738
|
-
type: "uint256"
|
|
1739
|
-
},
|
|
1740
|
-
{
|
|
1741
|
-
internalType: "uint256",
|
|
1742
|
-
name: "amount_per_period",
|
|
1743
|
-
type: "uint256"
|
|
1744
|
-
},
|
|
1745
|
-
{
|
|
1746
|
-
internalType: "uint256",
|
|
1747
|
-
name: "start",
|
|
1748
|
-
type: "uint256"
|
|
1749
|
-
},
|
|
1750
|
-
{
|
|
1751
|
-
internalType: "uint256",
|
|
1752
|
-
name: "end",
|
|
1753
|
-
type: "uint256"
|
|
1754
|
-
},
|
|
1755
|
-
{
|
|
1756
|
-
internalType: "uint256",
|
|
1757
|
-
name: "cliff_amount",
|
|
1758
|
-
type: "uint256"
|
|
1759
|
-
},
|
|
1760
|
-
{
|
|
1761
|
-
internalType: "uint256",
|
|
1762
|
-
name: "withdrawn",
|
|
1763
|
-
type: "uint256"
|
|
1764
|
-
},
|
|
1765
|
-
{
|
|
1766
|
-
internalType: "uint256",
|
|
1767
|
-
name: "last_withdrawn_at",
|
|
1768
|
-
type: "uint256"
|
|
1769
|
-
},
|
|
1770
|
-
{
|
|
1771
|
-
internalType: "uint256",
|
|
1772
|
-
name: "created",
|
|
1773
|
-
type: "uint256"
|
|
1774
|
-
},
|
|
1775
|
-
{
|
|
1776
|
-
internalType: "uint256",
|
|
1777
|
-
name: "canceled_at",
|
|
1778
|
-
type: "uint256"
|
|
1779
|
-
},
|
|
1780
|
-
{
|
|
1781
|
-
internalType: "address",
|
|
1782
|
-
name: "recipient",
|
|
1783
|
-
type: "address"
|
|
1784
|
-
},
|
|
1785
|
-
{
|
|
1786
|
-
internalType: "address",
|
|
1787
|
-
name: "sender",
|
|
1788
|
-
type: "address"
|
|
1789
|
-
},
|
|
1790
|
-
{
|
|
1791
|
-
internalType: "address",
|
|
1792
|
-
name: "partner",
|
|
1793
|
-
type: "address"
|
|
1794
|
-
},
|
|
1795
|
-
{
|
|
1796
|
-
components: [
|
|
1797
|
-
{
|
|
1798
|
-
internalType: "uint256",
|
|
1799
|
-
name: "streamflow_fee_percentage",
|
|
1800
|
-
type: "uint256"
|
|
1801
|
-
},
|
|
1802
|
-
{
|
|
1803
|
-
internalType: "uint256",
|
|
1804
|
-
name: "streamflow_fee",
|
|
1805
|
-
type: "uint256"
|
|
1806
|
-
},
|
|
1807
|
-
{
|
|
1808
|
-
internalType: "uint256",
|
|
1809
|
-
name: "streamflow_fee_withdrawn",
|
|
1810
|
-
type: "uint256"
|
|
1811
|
-
},
|
|
1812
|
-
{
|
|
1813
|
-
internalType: "uint256",
|
|
1814
|
-
name: "partner_fee_percentage",
|
|
1815
|
-
type: "uint256"
|
|
1816
|
-
},
|
|
1817
|
-
{
|
|
1818
|
-
internalType: "uint256",
|
|
1819
|
-
name: "partner_fee",
|
|
1820
|
-
type: "uint256"
|
|
1821
|
-
},
|
|
1822
|
-
{
|
|
1823
|
-
internalType: "uint256",
|
|
1824
|
-
name: "partner_fee_withdrawn",
|
|
1825
|
-
type: "uint256"
|
|
1826
|
-
},
|
|
1827
|
-
{
|
|
1828
|
-
internalType: "uint256",
|
|
1829
|
-
name: "tx_fee",
|
|
1830
|
-
type: "uint256"
|
|
1831
|
-
}
|
|
1832
|
-
],
|
|
1833
|
-
internalType: "struct FeesData",
|
|
1834
|
-
name: "fees",
|
|
1835
|
-
type: "tuple"
|
|
1836
|
-
},
|
|
1837
|
-
{
|
|
1838
|
-
internalType: "bool",
|
|
1839
|
-
name: "closed",
|
|
1840
|
-
type: "bool"
|
|
1841
|
-
},
|
|
1842
|
-
{
|
|
1843
|
-
internalType: "uint256",
|
|
1844
|
-
name: "current_pause_start",
|
|
1845
|
-
type: "uint256"
|
|
1846
|
-
},
|
|
1847
|
-
{
|
|
1848
|
-
internalType: "uint256",
|
|
1849
|
-
name: "pause_cumulative",
|
|
1850
|
-
type: "uint256"
|
|
1851
|
-
},
|
|
1852
|
-
{
|
|
1853
|
-
internalType: "uint256",
|
|
1854
|
-
name: "last_rate_change_time",
|
|
1855
|
-
type: "uint256"
|
|
1856
|
-
},
|
|
1857
|
-
{
|
|
1858
|
-
internalType: "uint256",
|
|
1859
|
-
name: "funds_unlocked_at_last_rate_change",
|
|
1860
|
-
type: "uint256"
|
|
1861
|
-
}
|
|
1862
|
-
],
|
|
1863
|
-
internalType: "struct Contract[]",
|
|
1864
|
-
name: "",
|
|
1865
|
-
type: "tuple[]"
|
|
1866
|
-
}
|
|
1867
|
-
],
|
|
1868
|
-
stateMutability: "view",
|
|
1869
|
-
type: "function"
|
|
1870
|
-
},
|
|
1871
|
-
{
|
|
1872
|
-
inputs: [
|
|
1873
|
-
{
|
|
1874
|
-
internalType: "address",
|
|
1875
|
-
name: "_address",
|
|
1876
|
-
type: "address"
|
|
1877
|
-
}
|
|
1878
|
-
],
|
|
1879
|
-
name: "getStreamflowFee",
|
|
1880
|
-
outputs: [
|
|
1881
|
-
{
|
|
1882
|
-
internalType: "uint256",
|
|
1883
|
-
name: "",
|
|
1884
|
-
type: "uint256"
|
|
1885
|
-
}
|
|
1886
|
-
],
|
|
1887
|
-
stateMutability: "view",
|
|
1888
|
-
type: "function"
|
|
1889
|
-
},
|
|
1890
|
-
{
|
|
1891
|
-
inputs: [],
|
|
1892
|
-
name: "getStreamflowFees",
|
|
1893
|
-
outputs: [
|
|
1894
|
-
{
|
|
1895
|
-
internalType: "uint256",
|
|
1896
|
-
name: "",
|
|
1897
|
-
type: "uint256"
|
|
1898
|
-
}
|
|
1899
|
-
],
|
|
1900
|
-
stateMutability: "view",
|
|
1901
|
-
type: "function"
|
|
1902
|
-
},
|
|
1903
|
-
{
|
|
1904
|
-
inputs: [
|
|
1905
|
-
{
|
|
1906
|
-
internalType: "address",
|
|
1907
|
-
name: "_stream_id",
|
|
1908
|
-
type: "address"
|
|
1909
|
-
},
|
|
1910
|
-
{
|
|
1911
|
-
internalType: "uint256",
|
|
1912
|
-
name: "_amount",
|
|
1913
|
-
type: "uint256"
|
|
1914
|
-
}
|
|
1915
|
-
],
|
|
1916
|
-
name: "getTopUpWithdrawalFees",
|
|
1917
|
-
outputs: [
|
|
1918
|
-
{
|
|
1919
|
-
components: [
|
|
1920
|
-
{
|
|
1921
|
-
internalType: "uint256",
|
|
1922
|
-
name: "value",
|
|
1923
|
-
type: "uint256"
|
|
1924
|
-
},
|
|
1925
|
-
{
|
|
1926
|
-
internalType: "uint256",
|
|
1927
|
-
name: "tx_fee",
|
|
1928
|
-
type: "uint256"
|
|
1929
|
-
}
|
|
1930
|
-
],
|
|
1931
|
-
internalType: "struct WithdrawalFeesData",
|
|
1932
|
-
name: "",
|
|
1933
|
-
type: "tuple"
|
|
1934
|
-
}
|
|
1935
|
-
],
|
|
1936
|
-
stateMutability: "view",
|
|
1937
|
-
type: "function"
|
|
1938
|
-
},
|
|
1939
|
-
{
|
|
1940
|
-
inputs: [],
|
|
1941
|
-
name: "getTreasuryAddress",
|
|
1942
|
-
outputs: [
|
|
1943
|
-
{
|
|
1944
|
-
internalType: "address payable",
|
|
1945
|
-
name: "",
|
|
1946
|
-
type: "address"
|
|
1947
|
-
}
|
|
1948
|
-
],
|
|
1949
|
-
stateMutability: "view",
|
|
1950
|
-
type: "function"
|
|
1951
|
-
},
|
|
1952
|
-
{
|
|
1953
|
-
inputs: [],
|
|
1954
|
-
name: "getTxFee",
|
|
1955
|
-
outputs: [
|
|
1956
|
-
{
|
|
1957
|
-
internalType: "uint256",
|
|
1958
|
-
name: "",
|
|
1959
|
-
type: "uint256"
|
|
1960
|
-
}
|
|
1961
|
-
],
|
|
1962
|
-
stateMutability: "view",
|
|
1963
|
-
type: "function"
|
|
1964
|
-
},
|
|
1965
|
-
{
|
|
1966
|
-
inputs: [
|
|
1967
|
-
{
|
|
1968
|
-
internalType: "uint256",
|
|
1969
|
-
name: "_amount",
|
|
1970
|
-
type: "uint256"
|
|
1971
|
-
},
|
|
1972
|
-
{
|
|
1973
|
-
internalType: "uint256",
|
|
1974
|
-
name: "_period",
|
|
1975
|
-
type: "uint256"
|
|
1976
|
-
},
|
|
1977
|
-
{
|
|
1978
|
-
internalType: "uint256",
|
|
1979
|
-
name: "_amount_per_period",
|
|
1980
|
-
type: "uint256"
|
|
1981
|
-
},
|
|
1982
|
-
{
|
|
1983
|
-
internalType: "uint256",
|
|
1984
|
-
name: "_start",
|
|
1985
|
-
type: "uint256"
|
|
1986
|
-
},
|
|
1987
|
-
{
|
|
1988
|
-
internalType: "uint256",
|
|
1989
|
-
name: "_cliff_amount",
|
|
1990
|
-
type: "uint256"
|
|
1991
|
-
},
|
|
1992
|
-
{
|
|
1993
|
-
internalType: "bool",
|
|
1994
|
-
name: "_automatic_withdrawal",
|
|
1995
|
-
type: "bool"
|
|
1996
|
-
},
|
|
1997
|
-
{
|
|
1998
|
-
internalType: "uint256",
|
|
1999
|
-
name: "_withdrawal_frequency",
|
|
2000
|
-
type: "uint256"
|
|
2001
|
-
}
|
|
2002
|
-
],
|
|
2003
|
-
name: "getWithdrawalFees",
|
|
2004
|
-
outputs: [
|
|
2005
|
-
{
|
|
2006
|
-
components: [
|
|
2007
|
-
{
|
|
2008
|
-
internalType: "uint256",
|
|
2009
|
-
name: "value",
|
|
2010
|
-
type: "uint256"
|
|
2011
|
-
},
|
|
2012
|
-
{
|
|
2013
|
-
internalType: "uint256",
|
|
2014
|
-
name: "tx_fee",
|
|
2015
|
-
type: "uint256"
|
|
2016
|
-
}
|
|
2017
|
-
],
|
|
2018
|
-
internalType: "struct WithdrawalFeesData",
|
|
2019
|
-
name: "",
|
|
2020
|
-
type: "tuple"
|
|
2021
|
-
}
|
|
2022
|
-
],
|
|
2023
|
-
stateMutability: "view",
|
|
2024
|
-
type: "function"
|
|
2025
|
-
},
|
|
2026
|
-
{
|
|
2027
|
-
inputs: [],
|
|
2028
|
-
name: "getWithdraworAddress",
|
|
2029
|
-
outputs: [
|
|
2030
|
-
{
|
|
2031
|
-
internalType: "address payable",
|
|
2032
|
-
name: "",
|
|
2033
|
-
type: "address"
|
|
2034
|
-
}
|
|
2035
|
-
],
|
|
2036
|
-
stateMutability: "view",
|
|
2037
|
-
type: "function"
|
|
2038
|
-
},
|
|
2039
|
-
{
|
|
2040
|
-
inputs: [],
|
|
2041
|
-
name: "initialize",
|
|
2042
|
-
outputs: [],
|
|
2043
|
-
stateMutability: "nonpayable",
|
|
2044
|
-
type: "function"
|
|
2045
|
-
},
|
|
2046
|
-
{
|
|
2047
|
-
inputs: [
|
|
2048
|
-
{
|
|
2049
|
-
internalType: "address",
|
|
2050
|
-
name: "_stream_id",
|
|
2051
|
-
type: "address"
|
|
2052
|
-
},
|
|
2053
|
-
{
|
|
2054
|
-
internalType: "uint256",
|
|
2055
|
-
name: "_amount",
|
|
2056
|
-
type: "uint256"
|
|
2057
|
-
}
|
|
2058
|
-
],
|
|
2059
|
-
name: "topUp",
|
|
2060
|
-
outputs: [],
|
|
2061
|
-
stateMutability: "payable",
|
|
2062
|
-
type: "function"
|
|
2063
|
-
},
|
|
2064
|
-
{
|
|
2065
|
-
inputs: [
|
|
2066
|
-
{
|
|
2067
|
-
internalType: "address",
|
|
2068
|
-
name: "_stream_id",
|
|
2069
|
-
type: "address"
|
|
2070
|
-
},
|
|
2071
|
-
{
|
|
2072
|
-
internalType: "address",
|
|
2073
|
-
name: "new_recipient",
|
|
2074
|
-
type: "address"
|
|
2075
|
-
}
|
|
2076
|
-
],
|
|
2077
|
-
name: "transfer",
|
|
2078
|
-
outputs: [],
|
|
2079
|
-
stateMutability: "nonpayable",
|
|
2080
|
-
type: "function"
|
|
2081
|
-
},
|
|
2082
|
-
{
|
|
2083
|
-
inputs: [
|
|
2084
|
-
{
|
|
2085
|
-
internalType: "address",
|
|
2086
|
-
name: "_new_admin",
|
|
2087
|
-
type: "address"
|
|
2088
|
-
}
|
|
2089
|
-
],
|
|
2090
|
-
name: "transferAdmin",
|
|
2091
|
-
outputs: [],
|
|
2092
|
-
stateMutability: "nonpayable",
|
|
2093
|
-
type: "function"
|
|
2094
|
-
},
|
|
2095
|
-
{
|
|
2096
|
-
inputs: [
|
|
2097
|
-
{
|
|
2098
|
-
internalType: "address",
|
|
2099
|
-
name: "_stream_id",
|
|
2100
|
-
type: "address"
|
|
2101
|
-
},
|
|
2102
|
-
{
|
|
2103
|
-
internalType: "bool[]",
|
|
2104
|
-
name: "_automatic_withdrawal",
|
|
2105
|
-
type: "bool[]"
|
|
2106
|
-
},
|
|
2107
|
-
{
|
|
2108
|
-
internalType: "uint256[]",
|
|
2109
|
-
name: "_withdrawal_frequency",
|
|
2110
|
-
type: "uint256[]"
|
|
2111
|
-
},
|
|
2112
|
-
{
|
|
2113
|
-
internalType: "uint256[]",
|
|
2114
|
-
name: "_amount_per_period",
|
|
2115
|
-
type: "uint256[]"
|
|
2116
|
-
}
|
|
2117
|
-
],
|
|
2118
|
-
name: "update",
|
|
2119
|
-
outputs: [],
|
|
2120
|
-
stateMutability: "payable",
|
|
2121
|
-
type: "function"
|
|
2122
|
-
},
|
|
2123
|
-
{
|
|
2124
|
-
inputs: [
|
|
2125
|
-
{
|
|
2126
|
-
internalType: "address",
|
|
2127
|
-
name: "_stream_id",
|
|
2128
|
-
type: "address"
|
|
2129
|
-
},
|
|
2130
|
-
{
|
|
2131
|
-
internalType: "uint256",
|
|
2132
|
-
name: "_amount",
|
|
2133
|
-
type: "uint256"
|
|
2134
|
-
}
|
|
2135
|
-
],
|
|
2136
|
-
name: "withdraw",
|
|
2137
|
-
outputs: [],
|
|
2138
|
-
stateMutability: "nonpayable",
|
|
2139
|
-
type: "function"
|
|
2140
|
-
}
|
|
2141
|
-
];
|
|
2142
|
-
|
|
2143
|
-
// evm/ercAbi.ts
|
|
2144
|
-
var ercAbi_default = [
|
|
2145
|
-
{
|
|
2146
|
-
constant: true,
|
|
2147
|
-
inputs: [],
|
|
2148
|
-
name: "name",
|
|
2149
|
-
outputs: [
|
|
2150
|
-
{
|
|
2151
|
-
name: "",
|
|
2152
|
-
type: "string"
|
|
2153
|
-
}
|
|
2154
|
-
],
|
|
2155
|
-
payable: false,
|
|
2156
|
-
stateMutability: "view",
|
|
2157
|
-
type: "function"
|
|
2158
|
-
},
|
|
2159
|
-
{
|
|
2160
|
-
constant: false,
|
|
2161
|
-
inputs: [
|
|
2162
|
-
{
|
|
2163
|
-
name: "_spender",
|
|
2164
|
-
type: "address"
|
|
2165
|
-
},
|
|
2166
|
-
{
|
|
2167
|
-
name: "_value",
|
|
2168
|
-
type: "uint256"
|
|
2169
|
-
}
|
|
2170
|
-
],
|
|
2171
|
-
name: "approve",
|
|
2172
|
-
outputs: [
|
|
2173
|
-
{
|
|
2174
|
-
name: "",
|
|
2175
|
-
type: "bool"
|
|
2176
|
-
}
|
|
2177
|
-
],
|
|
2178
|
-
payable: false,
|
|
2179
|
-
stateMutability: "nonpayable",
|
|
2180
|
-
type: "function"
|
|
2181
|
-
},
|
|
2182
|
-
{
|
|
2183
|
-
constant: true,
|
|
2184
|
-
inputs: [],
|
|
2185
|
-
name: "totalSupply",
|
|
2186
|
-
outputs: [
|
|
2187
|
-
{
|
|
2188
|
-
name: "",
|
|
2189
|
-
type: "uint256"
|
|
2190
|
-
}
|
|
2191
|
-
],
|
|
2192
|
-
payable: false,
|
|
2193
|
-
stateMutability: "view",
|
|
2194
|
-
type: "function"
|
|
2195
|
-
},
|
|
2196
|
-
{
|
|
2197
|
-
constant: false,
|
|
2198
|
-
inputs: [
|
|
2199
|
-
{
|
|
2200
|
-
name: "_from",
|
|
2201
|
-
type: "address"
|
|
2202
|
-
},
|
|
2203
|
-
{
|
|
2204
|
-
name: "_to",
|
|
2205
|
-
type: "address"
|
|
2206
|
-
},
|
|
2207
|
-
{
|
|
2208
|
-
name: "_value",
|
|
2209
|
-
type: "uint256"
|
|
2210
|
-
}
|
|
2211
|
-
],
|
|
2212
|
-
name: "transferFrom",
|
|
2213
|
-
outputs: [
|
|
2214
|
-
{
|
|
2215
|
-
name: "",
|
|
2216
|
-
type: "bool"
|
|
2217
|
-
}
|
|
2218
|
-
],
|
|
2219
|
-
payable: false,
|
|
2220
|
-
stateMutability: "nonpayable",
|
|
2221
|
-
type: "function"
|
|
2222
|
-
},
|
|
2223
|
-
{
|
|
2224
|
-
constant: true,
|
|
2225
|
-
inputs: [],
|
|
2226
|
-
name: "decimals",
|
|
2227
|
-
outputs: [
|
|
2228
|
-
{
|
|
2229
|
-
name: "",
|
|
2230
|
-
type: "uint8"
|
|
2231
|
-
}
|
|
2232
|
-
],
|
|
2233
|
-
payable: false,
|
|
2234
|
-
stateMutability: "view",
|
|
2235
|
-
type: "function"
|
|
2236
|
-
},
|
|
2237
|
-
{
|
|
2238
|
-
constant: true,
|
|
2239
|
-
inputs: [
|
|
2240
|
-
{
|
|
2241
|
-
name: "_owner",
|
|
2242
|
-
type: "address"
|
|
2243
|
-
}
|
|
2244
|
-
],
|
|
2245
|
-
name: "balanceOf",
|
|
2246
|
-
outputs: [
|
|
2247
|
-
{
|
|
2248
|
-
name: "balance",
|
|
2249
|
-
type: "uint256"
|
|
2250
|
-
}
|
|
2251
|
-
],
|
|
2252
|
-
payable: false,
|
|
2253
|
-
stateMutability: "view",
|
|
2254
|
-
type: "function"
|
|
2255
|
-
},
|
|
2256
|
-
{
|
|
2257
|
-
constant: true,
|
|
2258
|
-
inputs: [],
|
|
2259
|
-
name: "symbol",
|
|
2260
|
-
outputs: [
|
|
2261
|
-
{
|
|
2262
|
-
name: "",
|
|
2263
|
-
type: "string"
|
|
2264
|
-
}
|
|
2265
|
-
],
|
|
2266
|
-
payable: false,
|
|
2267
|
-
stateMutability: "view",
|
|
2268
|
-
type: "function"
|
|
2269
|
-
},
|
|
2270
|
-
{
|
|
2271
|
-
constant: false,
|
|
2272
|
-
inputs: [
|
|
2273
|
-
{
|
|
2274
|
-
name: "_to",
|
|
2275
|
-
type: "address"
|
|
2276
|
-
},
|
|
2277
|
-
{
|
|
2278
|
-
name: "_value",
|
|
2279
|
-
type: "uint256"
|
|
2280
|
-
}
|
|
2281
|
-
],
|
|
2282
|
-
name: "transfer",
|
|
2283
|
-
outputs: [
|
|
2284
|
-
{
|
|
2285
|
-
name: "",
|
|
2286
|
-
type: "bool"
|
|
2287
|
-
}
|
|
2288
|
-
],
|
|
2289
|
-
payable: false,
|
|
2290
|
-
stateMutability: "nonpayable",
|
|
2291
|
-
type: "function"
|
|
2292
|
-
},
|
|
2293
|
-
{
|
|
2294
|
-
constant: true,
|
|
2295
|
-
inputs: [
|
|
2296
|
-
{
|
|
2297
|
-
name: "_owner",
|
|
2298
|
-
type: "address"
|
|
2299
|
-
},
|
|
2300
|
-
{
|
|
2301
|
-
name: "_spender",
|
|
2302
|
-
type: "address"
|
|
2303
|
-
}
|
|
2304
|
-
],
|
|
2305
|
-
name: "allowance",
|
|
2306
|
-
outputs: [
|
|
2307
|
-
{
|
|
2308
|
-
name: "",
|
|
2309
|
-
type: "uint256"
|
|
2310
|
-
}
|
|
2311
|
-
],
|
|
2312
|
-
payable: false,
|
|
2313
|
-
stateMutability: "view",
|
|
2314
|
-
type: "function"
|
|
2315
|
-
},
|
|
2316
|
-
{
|
|
2317
|
-
payable: true,
|
|
2318
|
-
stateMutability: "payable",
|
|
2319
|
-
type: "fallback"
|
|
2320
|
-
},
|
|
2321
|
-
{
|
|
2322
|
-
anonymous: false,
|
|
2323
|
-
inputs: [
|
|
2324
|
-
{
|
|
2325
|
-
indexed: true,
|
|
2326
|
-
name: "owner",
|
|
2327
|
-
type: "address"
|
|
2328
|
-
},
|
|
2329
|
-
{
|
|
2330
|
-
indexed: true,
|
|
2331
|
-
name: "spender",
|
|
2332
|
-
type: "address"
|
|
2333
|
-
},
|
|
2334
|
-
{
|
|
2335
|
-
indexed: false,
|
|
2336
|
-
name: "value",
|
|
2337
|
-
type: "uint256"
|
|
2338
|
-
}
|
|
2339
|
-
],
|
|
2340
|
-
name: "Approval",
|
|
2341
|
-
type: "event"
|
|
2342
|
-
},
|
|
2343
|
-
{
|
|
2344
|
-
anonymous: false,
|
|
2345
|
-
inputs: [
|
|
2346
|
-
{
|
|
2347
|
-
indexed: true,
|
|
2348
|
-
name: "from",
|
|
2349
|
-
type: "address"
|
|
2350
|
-
},
|
|
2351
|
-
{
|
|
2352
|
-
indexed: true,
|
|
2353
|
-
name: "to",
|
|
2354
|
-
type: "address"
|
|
2355
|
-
},
|
|
2356
|
-
{
|
|
2357
|
-
indexed: false,
|
|
2358
|
-
name: "value",
|
|
2359
|
-
type: "uint256"
|
|
2360
|
-
}
|
|
2361
|
-
],
|
|
2362
|
-
name: "Transfer",
|
|
2363
|
-
type: "event"
|
|
2364
|
-
}
|
|
2365
|
-
];
|
|
2366
|
-
var EvmContract = class {
|
|
2367
126
|
constructor(stream) {
|
|
2368
|
-
this.magic =
|
|
2369
|
-
this.version =
|
|
2370
|
-
this.createdAt = stream.
|
|
2371
|
-
this.withdrawnAmount =
|
|
2372
|
-
this.canceledAt = stream.
|
|
2373
|
-
this.end = stream.end
|
|
2374
|
-
this.lastWithdrawnAt = stream.
|
|
2375
|
-
this.sender = stream.sender;
|
|
2376
|
-
this.senderTokens = stream.
|
|
2377
|
-
this.recipient = stream.recipient;
|
|
2378
|
-
this.recipientTokens = stream.
|
|
2379
|
-
this.mint = stream.
|
|
2380
|
-
this.escrowTokens =
|
|
2381
|
-
this.streamflowTreasury =
|
|
2382
|
-
this.streamflowTreasuryTokens =
|
|
2383
|
-
this.streamflowFeeTotal =
|
|
2384
|
-
this.streamflowFeeWithdrawn =
|
|
2385
|
-
this.streamflowFeePercent = stream.
|
|
2386
|
-
this.partnerFeeTotal =
|
|
2387
|
-
this.partnerFeeWithdrawn =
|
|
2388
|
-
this.partnerFeePercent =
|
|
2389
|
-
this.partner =
|
|
2390
|
-
this.partnerTokens =
|
|
127
|
+
this.magic = stream.magic.toNumber();
|
|
128
|
+
this.version = stream.version.toNumber();
|
|
129
|
+
this.createdAt = stream.createdAt.toNumber();
|
|
130
|
+
this.withdrawnAmount = stream.withdrawnAmount;
|
|
131
|
+
this.canceledAt = stream.canceledAt.toNumber();
|
|
132
|
+
this.end = decodeEndTime(stream.end);
|
|
133
|
+
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
134
|
+
this.sender = stream.sender.toBase58();
|
|
135
|
+
this.senderTokens = stream.senderTokens.toBase58();
|
|
136
|
+
this.recipient = stream.recipient.toBase58();
|
|
137
|
+
this.recipientTokens = stream.recipientTokens.toBase58();
|
|
138
|
+
this.mint = stream.mint.toBase58();
|
|
139
|
+
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
140
|
+
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
141
|
+
this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
|
|
142
|
+
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
143
|
+
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
144
|
+
this.streamflowFeePercent = stream.streamflowFeePercent;
|
|
145
|
+
this.partnerFeeTotal = stream.partnerFeeTotal;
|
|
146
|
+
this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
|
|
147
|
+
this.partnerFeePercent = stream.partnerFeePercent;
|
|
148
|
+
this.partner = stream.partner.toBase58();
|
|
149
|
+
this.partnerTokens = stream.partnerTokens?.toBase58();
|
|
2391
150
|
this.start = stream.start.toNumber();
|
|
2392
|
-
this.depositedAmount =
|
|
151
|
+
this.depositedAmount = stream.depositedAmount;
|
|
2393
152
|
this.period = stream.period.toNumber();
|
|
2394
|
-
this.amountPerPeriod =
|
|
2395
|
-
this.cliff = stream.
|
|
2396
|
-
this.cliffAmount =
|
|
2397
|
-
this.cancelableBySender = stream.
|
|
2398
|
-
this.cancelableByRecipient = stream.
|
|
2399
|
-
this.automaticWithdrawal = stream.
|
|
2400
|
-
this.transferableBySender = stream.
|
|
2401
|
-
this.transferableByRecipient = stream.
|
|
2402
|
-
this.canTopup = stream.
|
|
2403
|
-
this.name = stream.
|
|
2404
|
-
this.withdrawalFrequency = stream.
|
|
153
|
+
this.amountPerPeriod = stream.amountPerPeriod;
|
|
154
|
+
this.cliff = stream.cliff.toNumber();
|
|
155
|
+
this.cliffAmount = stream.cliffAmount;
|
|
156
|
+
this.cancelableBySender = stream.cancelableBySender;
|
|
157
|
+
this.cancelableByRecipient = stream.cancelableByRecipient;
|
|
158
|
+
this.automaticWithdrawal = stream.automaticWithdrawal;
|
|
159
|
+
this.transferableBySender = stream.transferableBySender;
|
|
160
|
+
this.transferableByRecipient = stream.transferableByRecipient;
|
|
161
|
+
this.canTopup = stream.canTopup;
|
|
162
|
+
this.name = stream.name;
|
|
163
|
+
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
2405
164
|
this.closed = stream.closed;
|
|
2406
|
-
this.currentPauseStart = stream.
|
|
2407
|
-
this.pauseCumulative =
|
|
2408
|
-
this.lastRateChangeTime = stream.
|
|
2409
|
-
this.fundsUnlockedAtLastRateChange =
|
|
165
|
+
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
166
|
+
this.pauseCumulative = stream.pauseCumulative;
|
|
167
|
+
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
168
|
+
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
2410
169
|
this.type = buildStreamType(this);
|
|
170
|
+
this.isAligned = false;
|
|
2411
171
|
}
|
|
2412
172
|
unlocked(currentTimestamp) {
|
|
2413
173
|
return calculateUnlockedAmount({
|
|
@@ -2419,313 +179,40 @@ var EvmContract = class {
|
|
|
2419
179
|
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
2420
180
|
}
|
|
2421
181
|
};
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
break;
|
|
2446
|
-
case IChain.BNB:
|
|
2447
|
-
this.programId = BNB_PROGRAM_IDS[cluster];
|
|
2448
|
-
break;
|
|
2449
|
-
case IChain.Polygon:
|
|
2450
|
-
this.programId = POLYGON_PROGRAM_IDS[cluster];
|
|
2451
|
-
break;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
this.provider = new ethers.providers.JsonRpcProvider(clusterUrl);
|
|
2455
|
-
this.signer = signer;
|
|
2456
|
-
const baseContract = new ethers.Contract(this.programId, abi_default);
|
|
2457
|
-
this.readContract = baseContract.connect(this.provider);
|
|
2458
|
-
this.writeContract = baseContract.connect(this.signer);
|
|
2459
|
-
}
|
|
2460
|
-
async create(streamData) {
|
|
2461
|
-
const multiParams = {
|
|
2462
|
-
...streamData,
|
|
2463
|
-
recipients: [streamData]
|
|
2464
|
-
};
|
|
2465
|
-
const fees = await this.readContract.getWithdrawalFees(...this.getFeeParams(multiParams));
|
|
2466
|
-
const args = (await this.generateMultiPayloads(multiParams))[0];
|
|
2467
|
-
const sum = streamData.amount.mul(new BN7(BASE_FEE)).div(new BN7(1e6));
|
|
2468
|
-
await this.approveTokens(streamData.tokenId, sum);
|
|
2469
|
-
const result = await this.writeContract.create(...args, {
|
|
2470
|
-
value: fees.value
|
|
2471
|
-
});
|
|
2472
|
-
const confirmedTx = await result.wait();
|
|
2473
|
-
const metadataId = this.formatMetadataId(
|
|
2474
|
-
confirmedTx.events.find((item) => item.event === "ContractCreated").args[0]
|
|
2475
|
-
);
|
|
2476
|
-
return {
|
|
2477
|
-
ixs: [],
|
|
2478
|
-
txId: result.hash,
|
|
2479
|
-
metadataId
|
|
2480
|
-
};
|
|
2481
|
-
}
|
|
2482
|
-
async createMultiple(multipleStreamData) {
|
|
2483
|
-
const fees = await this.readContract.getWithdrawalFees(...this.getFeeParams(multipleStreamData));
|
|
2484
|
-
const args = await this.generateMultiPayloads(multipleStreamData);
|
|
2485
|
-
const sum = multipleStreamData.recipients.reduce((acc, v) => acc.add(v.amount), new BN7(0)).mul(new BN7(BASE_FEE)).div(new BN7(1e6));
|
|
2486
|
-
await this.approveTokens(multipleStreamData.tokenId, sum);
|
|
2487
|
-
const creationPromises = args.map((item) => this.writeContract.create(...item, { value: fees.value }));
|
|
2488
|
-
const signatures = [];
|
|
2489
|
-
const results = await Promise.all(creationPromises);
|
|
2490
|
-
const confirmations = await Promise.allSettled(results.map((result) => result.wait()));
|
|
2491
|
-
const successes = confirmations.filter((el) => el.status === "fulfilled").map((el) => el.value);
|
|
2492
|
-
signatures.push(...successes.map((el) => el.hash));
|
|
2493
|
-
const metadatas = confirmations.map(
|
|
2494
|
-
(result) => result.status === "fulfilled" ? this.formatMetadataId(
|
|
2495
|
-
result.value.events.find((item) => item.event === "ContractCreated").args[0]
|
|
2496
|
-
) : null
|
|
2497
|
-
);
|
|
2498
|
-
const metadataToRecipient = metadatas.reduce(
|
|
2499
|
-
(acc, value, index) => {
|
|
2500
|
-
if (value) {
|
|
2501
|
-
acc[value] = multipleStreamData.recipients[index];
|
|
2502
|
-
}
|
|
2503
|
-
return acc;
|
|
2504
|
-
},
|
|
2505
|
-
{}
|
|
2506
|
-
);
|
|
2507
|
-
const failures = confirmations.filter((el) => el.status === "rejected").map((el) => el.reason);
|
|
2508
|
-
return {
|
|
2509
|
-
txs: signatures,
|
|
2510
|
-
metadatas: metadatas.filter(Boolean),
|
|
2511
|
-
metadataToRecipient,
|
|
2512
|
-
errors: failures
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
2515
|
-
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }) {
|
|
2516
|
-
const result = await this.writeContract.withdraw(id, amount.toString());
|
|
2517
|
-
return {
|
|
2518
|
-
ixs: [],
|
|
2519
|
-
txId: result.hash
|
|
2520
|
-
};
|
|
2521
|
-
}
|
|
2522
|
-
async cancel(cancelData) {
|
|
2523
|
-
const result = await this.writeContract.cancel(cancelData.id);
|
|
2524
|
-
return {
|
|
2525
|
-
ixs: [],
|
|
2526
|
-
txId: result.hash
|
|
2527
|
-
};
|
|
2528
|
-
}
|
|
2529
|
-
async transfer(transferData) {
|
|
2530
|
-
const result = await this.writeContract.transfer(transferData.id, transferData.newRecipient);
|
|
2531
|
-
return {
|
|
2532
|
-
ixs: [],
|
|
2533
|
-
txId: result.hash
|
|
2534
|
-
};
|
|
2535
|
-
}
|
|
2536
|
-
async topup(topupData) {
|
|
2537
|
-
const fees = await this.readContract.getTopUpWithdrawalFees(topupData.id, topupData.amount.toString());
|
|
2538
|
-
const sum = topupData.amount.mul(new BN7(BASE_FEE)).div(new BN7(1e6));
|
|
2539
|
-
const stream = await this.getOne({ id: topupData.id });
|
|
2540
|
-
await this.approveTokens(stream.mint, sum);
|
|
2541
|
-
const result = await this.writeContract.topUp(topupData.id, topupData.amount.toString(), {
|
|
2542
|
-
value: fees.value
|
|
2543
|
-
});
|
|
2544
|
-
return {
|
|
2545
|
-
ixs: [],
|
|
2546
|
-
txId: result.hash
|
|
2547
|
-
};
|
|
2548
|
-
}
|
|
2549
|
-
async update(updateData) {
|
|
2550
|
-
const result = await this.writeContract.update(
|
|
2551
|
-
updateData.id,
|
|
2552
|
-
updateData.enableAutomaticWithdrawal ? [true] : [],
|
|
2553
|
-
updateData.withdrawFrequency ? [updateData.withdrawFrequency.toString()] : [],
|
|
2554
|
-
updateData.amountPerPeriod ? [updateData.amountPerPeriod.toString()] : []
|
|
2555
|
-
);
|
|
2556
|
-
return {
|
|
2557
|
-
ixs: [],
|
|
2558
|
-
txId: result.hash
|
|
2559
|
-
};
|
|
2560
|
-
}
|
|
2561
|
-
async getOne({ id }) {
|
|
2562
|
-
const result = await this.readContract.getById(id);
|
|
2563
|
-
return new EvmContract(result);
|
|
2564
|
-
}
|
|
2565
|
-
async get({
|
|
2566
|
-
address,
|
|
2567
|
-
// type = StreamType.All,
|
|
2568
|
-
direction = "all" /* All */
|
|
2569
|
-
}) {
|
|
2570
|
-
const addresses = [];
|
|
2571
|
-
if (direction === "all" /* All */ || direction === "outgoing" /* Outgoing */) {
|
|
2572
|
-
const senderAddresses = await this.readContract.getBySender(address);
|
|
2573
|
-
addresses.push(...senderAddresses);
|
|
2574
|
-
}
|
|
2575
|
-
if (direction === "all" /* All */ || direction === "incoming" /* Incoming */) {
|
|
2576
|
-
const recipientAddresses = await this.readContract.getByRecipient(address);
|
|
2577
|
-
addresses.push(...recipientAddresses);
|
|
2578
|
-
}
|
|
2579
|
-
const uniqueAddresses = [...new Set(addresses)];
|
|
2580
|
-
const results = await this.readContract.getMultiple(uniqueAddresses);
|
|
2581
|
-
return results.map((result, index) => [uniqueAddresses[index], new EvmContract(result)]);
|
|
2582
|
-
}
|
|
2583
|
-
extractErrorCode(err) {
|
|
2584
|
-
return extractEvmErrorCode(err.toString() ?? "Unknown error!");
|
|
2585
|
-
}
|
|
2586
|
-
async getFees({ address }) {
|
|
2587
|
-
const fees = await this.readContract.getFees(address);
|
|
2588
|
-
if (!fees.exists) {
|
|
2589
|
-
return null;
|
|
2590
|
-
}
|
|
2591
|
-
return {
|
|
2592
|
-
streamflowFee: fees.streamflow_fee.toNumber() / 100,
|
|
2593
|
-
partnerFee: fees.partner_fee.toNumber() / 100
|
|
2594
|
-
};
|
|
2595
|
-
}
|
|
2596
|
-
async getDefaultStreamflowFee() {
|
|
2597
|
-
const fee = await this.readContract.getStreamflowFees();
|
|
2598
|
-
return fee.toNumber() / 100;
|
|
2599
|
-
}
|
|
2600
|
-
/**
|
|
2601
|
-
* Returns StreamClient protocol program ID.
|
|
2602
|
-
*/
|
|
2603
|
-
getProgramId() {
|
|
2604
|
-
return this.programId;
|
|
2605
|
-
}
|
|
2606
|
-
async approveTokens(tokenId, amount) {
|
|
2607
|
-
const tokenContract = new ethers.Contract(tokenId, ercAbi_default, this.signer);
|
|
2608
|
-
const address = await this.signer.getAddress();
|
|
2609
|
-
const allowance = await tokenContract.allowance(address, this.programId);
|
|
2610
|
-
if (new BN7(allowance.toString()).gte(amount)) {
|
|
2611
|
-
return;
|
|
2612
|
-
}
|
|
2613
|
-
const approvalTx = await tokenContract.approve(this.programId, amount.toString());
|
|
2614
|
-
await approvalTx.wait();
|
|
2615
|
-
}
|
|
2616
|
-
// Utility function to prepare transaction payloads for multiple recipients.
|
|
2617
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2618
|
-
async generateMultiPayloads(multipleStreamData) {
|
|
2619
|
-
const sender = await this.signer.getAddress();
|
|
2620
|
-
return multipleStreamData.recipients.map((recipient) => {
|
|
2621
|
-
return [
|
|
2622
|
-
multipleStreamData.tokenId,
|
|
2623
|
-
recipient.amount.toString(),
|
|
2624
|
-
multipleStreamData.period,
|
|
2625
|
-
recipient.amountPerPeriod.toString(),
|
|
2626
|
-
multipleStreamData.start,
|
|
2627
|
-
recipient.cliffAmount.toString(),
|
|
2628
|
-
[
|
|
2629
|
-
multipleStreamData.cancelableBySender,
|
|
2630
|
-
multipleStreamData.cancelableByRecipient,
|
|
2631
|
-
multipleStreamData.transferableBySender,
|
|
2632
|
-
multipleStreamData.transferableByRecipient,
|
|
2633
|
-
multipleStreamData.canTopup,
|
|
2634
|
-
multipleStreamData.canPause || false,
|
|
2635
|
-
multipleStreamData.canUpdateRate || false,
|
|
2636
|
-
multipleStreamData.automaticWithdrawal || false,
|
|
2637
|
-
multipleStreamData.withdrawalFrequency || 0,
|
|
2638
|
-
recipient.name
|
|
2639
|
-
],
|
|
2640
|
-
recipient.recipient,
|
|
2641
|
-
multipleStreamData.partner || sender
|
|
2642
|
-
];
|
|
2643
|
-
});
|
|
2644
|
-
}
|
|
2645
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2646
|
-
getFeeParams(multipleStreamData) {
|
|
2647
|
-
return [
|
|
2648
|
-
multipleStreamData.recipients[0].amount.toString(),
|
|
2649
|
-
multipleStreamData.period,
|
|
2650
|
-
multipleStreamData.recipients[0].amountPerPeriod.toString(),
|
|
2651
|
-
multipleStreamData.start,
|
|
2652
|
-
multipleStreamData.recipients[0].cliffAmount.toString(),
|
|
2653
|
-
multipleStreamData.automaticWithdrawal || false,
|
|
2654
|
-
multipleStreamData.withdrawalFrequency || 0
|
|
2655
|
-
];
|
|
2656
|
-
}
|
|
2657
|
-
formatMetadataId(id) {
|
|
2658
|
-
return toChecksumAddress(`0x${id.slice(-40)}`);
|
|
182
|
+
var AlignedContract = class extends Contract {
|
|
183
|
+
constructor(stream, alignedProxy) {
|
|
184
|
+
super(stream);
|
|
185
|
+
this.minPrice = getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
186
|
+
this.maxPrice = getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
187
|
+
this.minPercentage = getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
188
|
+
this.maxPercentage = getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
189
|
+
this.oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none";
|
|
190
|
+
this.tickSize = alignedProxy.tickSize.toNumber();
|
|
191
|
+
this.priceOracle = this.oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58();
|
|
192
|
+
this.sender = alignedProxy.sender.toBase58();
|
|
193
|
+
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
194
|
+
this.proxyAddress = stream.sender.toBase58();
|
|
195
|
+
this.initialAmountPerPeriod = alignedProxy.initialAmountPerPeriod;
|
|
196
|
+
this.initialPrice = getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
197
|
+
this.lastPrice = getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
198
|
+
this.lastAmountUpdateTime = alignedProxy.lastAmountUpdateTime.toNumber();
|
|
199
|
+
this.initialNetAmount = alignedProxy.initialNetAmount;
|
|
200
|
+
this.expiryTime = alignedProxy.expiryTime.toNumber();
|
|
201
|
+
this.expiryPercentage = getNumberFromBN(alignedProxy.expiryPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
202
|
+
this.floorPrice = getNumberFromBN(alignedProxy.floorPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
203
|
+
this.type = buildStreamType(this);
|
|
204
|
+
this.isAligned = true;
|
|
2659
205
|
}
|
|
2660
206
|
};
|
|
2661
|
-
|
|
2662
|
-
// solana/index.ts
|
|
2663
|
-
var solana_exports = {};
|
|
2664
|
-
__export(solana_exports, {
|
|
2665
|
-
AlignedContract: () => AlignedContract,
|
|
2666
|
-
Contract: () => Contract2,
|
|
2667
|
-
ContractError: () => ContractError,
|
|
2668
|
-
IChain: () => IChain,
|
|
2669
|
-
ICluster: () => ICluster,
|
|
2670
|
-
SolanaStreamClient: () => SolanaStreamClient,
|
|
2671
|
-
cancelStreamInstruction: () => cancelStreamInstruction,
|
|
2672
|
-
constants: () => constants_exports3,
|
|
2673
|
-
createStreamInstruction: () => createStreamInstruction,
|
|
2674
|
-
createUncheckedStreamInstruction: () => createUncheckedStreamInstruction,
|
|
2675
|
-
decodeStream: () => decodeStream,
|
|
2676
|
-
deriveContractPDA: () => deriveContractPDA,
|
|
2677
|
-
deriveEscrowPDA: () => deriveEscrowPDA,
|
|
2678
|
-
deriveTestOraclePDA: () => deriveTestOraclePDA,
|
|
2679
|
-
extractSolanaErrorCode: () => extractSolanaErrorCode,
|
|
2680
|
-
sendAndConfirmStreamRawTransaction: () => sendAndConfirmStreamRawTransaction,
|
|
2681
|
-
signAllTransactionWithRecipients: () => signAllTransactionWithRecipients,
|
|
2682
|
-
timelockIDL: () => timelockIDL_default,
|
|
2683
|
-
topupStreamInstruction: () => topupStreamInstruction,
|
|
2684
|
-
transferStreamInstruction: () => transferStreamInstruction,
|
|
2685
|
-
updateStreamInstruction: () => updateStreamInstruction,
|
|
2686
|
-
withdrawStreamInstruction: () => withdrawStreamInstruction
|
|
2687
|
-
});
|
|
2688
|
-
|
|
2689
|
-
// solana/constants.ts
|
|
2690
|
-
var constants_exports3 = {};
|
|
2691
|
-
__export(constants_exports3, {
|
|
2692
|
-
AIRDROP_AMOUNT: () => AIRDROP_AMOUNT,
|
|
2693
|
-
AIRDROP_TEST_TOKEN: () => AIRDROP_TEST_TOKEN,
|
|
2694
|
-
ALIGNED_COMPUTE_LIMIT: () => ALIGNED_COMPUTE_LIMIT,
|
|
2695
|
-
ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
|
|
2696
|
-
ALIGNED_UNLOCKS_PROGRAM_ID: () => ALIGNED_UNLOCKS_PROGRAM_ID,
|
|
2697
|
-
CONTRACT_DISCRIMINATOR: () => CONTRACT_DISCRIMINATOR,
|
|
2698
|
-
CONTRACT_SEED: () => CONTRACT_SEED,
|
|
2699
|
-
CREATE_PARAMS_PADDING: () => CREATE_PARAMS_PADDING,
|
|
2700
|
-
DEFAULT_STREAMFLOW_FEE: () => DEFAULT_STREAMFLOW_FEE,
|
|
2701
|
-
ESCROW_SEED: () => ESCROW_SEED,
|
|
2702
|
-
FEES_METADATA_SEED: () => FEES_METADATA_SEED,
|
|
2703
|
-
FEE_ORACLE_PUBLIC_KEY: () => FEE_ORACLE_PUBLIC_KEY,
|
|
2704
|
-
ORIGINAL_CONTRACT_SENDER_OFFSET: () => ORIGINAL_CONTRACT_SENDER_OFFSET,
|
|
2705
|
-
PARTNERS_SCHEMA: () => PARTNERS_SCHEMA,
|
|
2706
|
-
PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
|
|
2707
|
-
PARTNER_SCHEMA: () => PARTNER_SCHEMA,
|
|
2708
|
-
PROGRAM_ID: () => PROGRAM_ID,
|
|
2709
|
-
SOLANA_ERROR_MAP: () => SOLANA_ERROR_MAP,
|
|
2710
|
-
SOLANA_ERROR_MATCH_REGEX: () => SOLANA_ERROR_MATCH_REGEX,
|
|
2711
|
-
STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
2712
|
-
STREAM_STRUCT_OFFSETS: () => STREAM_STRUCT_OFFSETS,
|
|
2713
|
-
STREAM_STRUCT_OFFSET_CLOSED: () => STREAM_STRUCT_OFFSET_CLOSED,
|
|
2714
|
-
STREAM_STRUCT_OFFSET_MINT: () => STREAM_STRUCT_OFFSET_MINT,
|
|
2715
|
-
STREAM_STRUCT_OFFSET_RECIPIENT: () => STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
2716
|
-
STREAM_STRUCT_OFFSET_SENDER: () => STREAM_STRUCT_OFFSET_SENDER,
|
|
2717
|
-
TEST_ORACLE_DISCRIMINATOR: () => TEST_ORACLE_DISCRIMINATOR,
|
|
2718
|
-
TEST_ORACLE_SEED: () => TEST_ORACLE_SEED,
|
|
2719
|
-
TX_FINALITY_CONFIRMED: () => TX_FINALITY_CONFIRMED,
|
|
2720
|
-
WITHDRAWOR_PUBLIC_KEY: () => WITHDRAWOR_PUBLIC_KEY
|
|
2721
|
-
});
|
|
2722
207
|
var TX_FINALITY_CONFIRMED = "confirmed";
|
|
2723
208
|
var ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
2724
209
|
var STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
2725
210
|
var STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
2726
211
|
var STREAM_STRUCT_OFFSET_MINT = 177;
|
|
2727
212
|
var STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
2728
|
-
var
|
|
213
|
+
var MAX_SAFE_UNIX_TIME_VALUE2 = 864e10;
|
|
214
|
+
var WITHDRAW_AVAILABLE_AMOUNT = new BN3("18446744073709551615");
|
|
215
|
+
var ALIGNED_PRECISION_FACTOR_POW2 = 9;
|
|
2729
216
|
var STREAM_STRUCT_OFFSETS = {
|
|
2730
217
|
mint: STREAM_STRUCT_OFFSET_MINT,
|
|
2731
218
|
recipient: STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
@@ -2806,88 +293,8 @@ var SOLANA_ERROR_MAP = {
|
|
|
2806
293
|
6011: "AmountAlreadyUpdated" /* AmountAlreadyUpdated */,
|
|
2807
294
|
6012: "AllFundsUnlocked" /* AllFundsUnlocked */
|
|
2808
295
|
};
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
this.magic = stream.magic.toNumber();
|
|
2812
|
-
this.version = stream.version.toNumber();
|
|
2813
|
-
this.createdAt = stream.createdAt.toNumber();
|
|
2814
|
-
this.withdrawnAmount = stream.withdrawnAmount;
|
|
2815
|
-
this.canceledAt = stream.canceledAt.toNumber();
|
|
2816
|
-
this.end = decodeEndTime(stream.end);
|
|
2817
|
-
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
2818
|
-
this.sender = stream.sender.toBase58();
|
|
2819
|
-
this.senderTokens = stream.senderTokens.toBase58();
|
|
2820
|
-
this.recipient = stream.recipient.toBase58();
|
|
2821
|
-
this.recipientTokens = stream.recipientTokens.toBase58();
|
|
2822
|
-
this.mint = stream.mint.toBase58();
|
|
2823
|
-
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
2824
|
-
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
2825
|
-
this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
|
|
2826
|
-
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
2827
|
-
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
2828
|
-
this.streamflowFeePercent = stream.streamflowFeePercent;
|
|
2829
|
-
this.partnerFeeTotal = stream.partnerFeeTotal;
|
|
2830
|
-
this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
|
|
2831
|
-
this.partnerFeePercent = stream.partnerFeePercent;
|
|
2832
|
-
this.partner = stream.partner.toBase58();
|
|
2833
|
-
this.partnerTokens = stream.partnerTokens?.toBase58();
|
|
2834
|
-
this.start = stream.start.toNumber();
|
|
2835
|
-
this.depositedAmount = stream.depositedAmount;
|
|
2836
|
-
this.period = stream.period.toNumber();
|
|
2837
|
-
this.amountPerPeriod = stream.amountPerPeriod;
|
|
2838
|
-
this.cliff = stream.cliff.toNumber();
|
|
2839
|
-
this.cliffAmount = stream.cliffAmount;
|
|
2840
|
-
this.cancelableBySender = stream.cancelableBySender;
|
|
2841
|
-
this.cancelableByRecipient = stream.cancelableByRecipient;
|
|
2842
|
-
this.automaticWithdrawal = stream.automaticWithdrawal;
|
|
2843
|
-
this.transferableBySender = stream.transferableBySender;
|
|
2844
|
-
this.transferableByRecipient = stream.transferableByRecipient;
|
|
2845
|
-
this.canTopup = stream.canTopup;
|
|
2846
|
-
this.name = stream.name;
|
|
2847
|
-
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
2848
|
-
this.closed = stream.closed;
|
|
2849
|
-
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
2850
|
-
this.pauseCumulative = stream.pauseCumulative;
|
|
2851
|
-
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
2852
|
-
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
2853
|
-
this.type = buildStreamType(this);
|
|
2854
|
-
this.isAligned = false;
|
|
2855
|
-
}
|
|
2856
|
-
unlocked(currentTimestamp) {
|
|
2857
|
-
return calculateUnlockedAmount({
|
|
2858
|
-
...this,
|
|
2859
|
-
currentTimestamp
|
|
2860
|
-
});
|
|
2861
|
-
}
|
|
2862
|
-
remaining(decimals) {
|
|
2863
|
-
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
2864
|
-
}
|
|
2865
|
-
};
|
|
2866
|
-
var AlignedContract = class extends Contract2 {
|
|
2867
|
-
constructor(stream, alignedProxy) {
|
|
2868
|
-
super(stream);
|
|
2869
|
-
this.minPrice = getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
2870
|
-
this.maxPrice = getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
2871
|
-
this.minPercentage = getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
2872
|
-
this.maxPercentage = getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
2873
|
-
this.oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none";
|
|
2874
|
-
this.tickSize = alignedProxy.tickSize.toNumber();
|
|
2875
|
-
this.priceOracle = this.oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58();
|
|
2876
|
-
this.sender = alignedProxy.sender.toBase58();
|
|
2877
|
-
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
2878
|
-
this.proxyAddress = stream.sender.toBase58();
|
|
2879
|
-
this.initialAmountPerPeriod = alignedProxy.initialAmountPerPeriod;
|
|
2880
|
-
this.initialPrice = getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
2881
|
-
this.lastPrice = getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
2882
|
-
this.lastAmountUpdateTime = alignedProxy.lastAmountUpdateTime.toNumber();
|
|
2883
|
-
this.initialNetAmount = alignedProxy.initialNetAmount;
|
|
2884
|
-
this.expiryTime = alignedProxy.expiryTime.toNumber();
|
|
2885
|
-
this.expiryPercentage = getNumberFromBN(alignedProxy.expiryPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
2886
|
-
this.floorPrice = getNumberFromBN(alignedProxy.floorPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
2887
|
-
this.type = buildStreamType(this);
|
|
2888
|
-
this.isAligned = true;
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
296
|
+
|
|
297
|
+
// solana/layout.ts
|
|
2891
298
|
var streamLayout = BufferLayout.struct([
|
|
2892
299
|
BufferLayout.blob(8, "magic"),
|
|
2893
300
|
BufferLayout.blob(1, "version"),
|
|
@@ -3047,20 +454,25 @@ var encodeUpdateStream = (values, data) => {
|
|
|
3047
454
|
var topupStreamLayout = BufferLayout.struct([
|
|
3048
455
|
BufferLayout.blob(8, "amount")
|
|
3049
456
|
]);
|
|
3050
|
-
|
|
3051
|
-
|
|
457
|
+
var FEE_PRECISION = 4;
|
|
458
|
+
var FEE_NORMALIZER = 10 ** FEE_PRECISION;
|
|
459
|
+
var FEE_MULTIPLIER = new BN3(10 ** 6);
|
|
3052
460
|
var decoder = new TextDecoder("utf-8");
|
|
3053
461
|
var LE = "le";
|
|
462
|
+
var calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
|
|
463
|
+
const totalFeeNormalized = new BN3(totalFee * FEE_NORMALIZER);
|
|
464
|
+
return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
|
|
465
|
+
};
|
|
3054
466
|
var decodeStream = (buf) => {
|
|
3055
467
|
const raw = streamLayout.decode(buf);
|
|
3056
468
|
return {
|
|
3057
|
-
magic: new
|
|
3058
|
-
version: new
|
|
3059
|
-
createdAt: new
|
|
3060
|
-
withdrawnAmount: new
|
|
3061
|
-
canceledAt: new
|
|
3062
|
-
end: new
|
|
3063
|
-
lastWithdrawnAt: new
|
|
469
|
+
magic: new BN3(raw.magic, LE),
|
|
470
|
+
version: new BN3(raw.version, LE),
|
|
471
|
+
createdAt: new BN3(raw.created_at, LE),
|
|
472
|
+
withdrawnAmount: new BN3(raw.withdrawn_amount, LE),
|
|
473
|
+
canceledAt: new BN3(raw.canceled_at, LE),
|
|
474
|
+
end: new BN3(raw.end_time, LE),
|
|
475
|
+
lastWithdrawnAt: new BN3(raw.last_withdrawn_at, LE),
|
|
3064
476
|
sender: new PublicKey(raw.sender),
|
|
3065
477
|
senderTokens: new PublicKey(raw.sender_tokens),
|
|
3066
478
|
recipient: new PublicKey(raw.recipient),
|
|
@@ -3069,20 +481,20 @@ var decodeStream = (buf) => {
|
|
|
3069
481
|
escrowTokens: new PublicKey(raw.escrow_tokens),
|
|
3070
482
|
streamflowTreasury: new PublicKey(raw.streamflow_treasury),
|
|
3071
483
|
streamflowTreasuryTokens: new PublicKey(raw.streamflow_treasury_tokens),
|
|
3072
|
-
streamflowFeeTotal: new
|
|
3073
|
-
streamflowFeeWithdrawn: new
|
|
484
|
+
streamflowFeeTotal: new BN3(raw.streamflow_fee_total, LE),
|
|
485
|
+
streamflowFeeWithdrawn: new BN3(raw.streamflow_fee_withdrawn, LE),
|
|
3074
486
|
streamflowFeePercent: raw.streamflow_fee_percent,
|
|
3075
|
-
partnerFeeTotal: new
|
|
3076
|
-
partnerFeeWithdrawn: new
|
|
487
|
+
partnerFeeTotal: new BN3(raw.partner_fee_total, LE),
|
|
488
|
+
partnerFeeWithdrawn: new BN3(raw.partner_fee_withdrawn, LE),
|
|
3077
489
|
partnerFeePercent: raw.partner_fee_percent,
|
|
3078
490
|
partner: new PublicKey(raw.partner),
|
|
3079
491
|
partnerTokens: new PublicKey(raw.partner_tokens),
|
|
3080
|
-
start: new
|
|
3081
|
-
depositedAmount: new
|
|
3082
|
-
period: new
|
|
3083
|
-
amountPerPeriod: new
|
|
3084
|
-
cliff: new
|
|
3085
|
-
cliffAmount: new
|
|
492
|
+
start: new BN3(raw.start_time, LE),
|
|
493
|
+
depositedAmount: new BN3(raw.net_amount_deposited, LE),
|
|
494
|
+
period: new BN3(raw.period, LE),
|
|
495
|
+
amountPerPeriod: new BN3(raw.amount_per_period, LE),
|
|
496
|
+
cliff: new BN3(raw.cliff, LE),
|
|
497
|
+
cliffAmount: new BN3(raw.cliff_amount, LE),
|
|
3086
498
|
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
3087
499
|
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
3088
500
|
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
@@ -3090,12 +502,12 @@ var decodeStream = (buf) => {
|
|
|
3090
502
|
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
3091
503
|
canTopup: Boolean(raw.can_topup),
|
|
3092
504
|
name: decoder.decode(raw.stream_name),
|
|
3093
|
-
withdrawFrequency: new
|
|
505
|
+
withdrawFrequency: new BN3(raw.withdraw_frequency, LE),
|
|
3094
506
|
closed: Boolean(raw.closed),
|
|
3095
|
-
currentPauseStart: new
|
|
3096
|
-
pauseCumulative: new
|
|
3097
|
-
lastRateChangeTime: new
|
|
3098
|
-
fundsUnlockedAtLastRateChange: new
|
|
507
|
+
currentPauseStart: new BN3(raw.current_pause_start, LE),
|
|
508
|
+
pauseCumulative: new BN3(raw.pause_cumulative, LE),
|
|
509
|
+
lastRateChangeTime: new BN3(raw.last_rate_change_time, LE),
|
|
510
|
+
fundsUnlockedAtLastRateChange: new BN3(raw.funds_unlocked_at_last_rate_change, LE)
|
|
3099
511
|
};
|
|
3100
512
|
};
|
|
3101
513
|
async function signAllTransactionWithRecipients(sender, items) {
|
|
@@ -3127,6 +539,19 @@ async function sendAndConfirmStreamRawTransaction(connection, batchItem, confirm
|
|
|
3127
539
|
};
|
|
3128
540
|
}
|
|
3129
541
|
}
|
|
542
|
+
async function handleContractError(func, callback) {
|
|
543
|
+
try {
|
|
544
|
+
return await func();
|
|
545
|
+
} catch (err) {
|
|
546
|
+
if (err instanceof Error) {
|
|
547
|
+
if (callback) {
|
|
548
|
+
throw new ContractError(err, callback(err));
|
|
549
|
+
}
|
|
550
|
+
throw new ContractError(err);
|
|
551
|
+
}
|
|
552
|
+
throw err;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
3130
555
|
function extractSolanaErrorCode(errorText, logs) {
|
|
3131
556
|
let match = SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
3132
557
|
if (!match && logs) {
|
|
@@ -4969,12 +2394,11 @@ var deriveTestOraclePDA = (programId, mint, creator) => {
|
|
|
4969
2394
|
// solana/StreamClient.ts
|
|
4970
2395
|
var METADATA_ACC_SIZE = 1104;
|
|
4971
2396
|
var ALIGNED_METADATA_ACC_SIZE = 320;
|
|
4972
|
-
var SolanaStreamClient = class
|
|
2397
|
+
var SolanaStreamClient = class {
|
|
4973
2398
|
/**
|
|
4974
2399
|
* Create Stream instance
|
|
4975
2400
|
*/
|
|
4976
2401
|
constructor(optionsOrClusterUrl, cluster = ICluster.Mainnet, commitment = "confirmed", programId = "", sendRate = 1, sendThrottler) {
|
|
4977
|
-
super();
|
|
4978
2402
|
if (typeof optionsOrClusterUrl === "string") {
|
|
4979
2403
|
this.commitment = commitment;
|
|
4980
2404
|
this.connection = new Connection(optionsOrClusterUrl, this.commitment);
|
|
@@ -5015,6 +2439,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5015
2439
|
getProgramId() {
|
|
5016
2440
|
return this.programId.toBase58();
|
|
5017
2441
|
}
|
|
2442
|
+
getAlignedProxyProgramId() {
|
|
2443
|
+
return this.alignedProxyProgram.programId.toBase58();
|
|
2444
|
+
}
|
|
5018
2445
|
/**
|
|
5019
2446
|
* Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
|
|
5020
2447
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
@@ -5023,7 +2450,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5023
2450
|
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
5024
2451
|
*
|
|
5025
2452
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5026
|
-
* @param {Omit<
|
|
2453
|
+
* @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5027
2454
|
* @returns Transaction instructions and metadata ID
|
|
5028
2455
|
*/
|
|
5029
2456
|
async buildCreateTransactionInstructions(data, extParams) {
|
|
@@ -5070,7 +2497,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5070
2497
|
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
5071
2498
|
*
|
|
5072
2499
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5073
|
-
* @param {Omit<
|
|
2500
|
+
* @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5074
2501
|
* @returns Transaction and metadata information
|
|
5075
2502
|
*/
|
|
5076
2503
|
async buildCreateTransaction(data, extParams) {
|
|
@@ -5091,7 +2518,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5091
2518
|
* Creates a new stream/vesting contract.
|
|
5092
2519
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5093
2520
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5094
|
-
* @param {
|
|
2521
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
|
|
5095
2522
|
* @returns Create result
|
|
5096
2523
|
*/
|
|
5097
2524
|
async create(data, extParams) {
|
|
@@ -5179,11 +2606,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5179
2606
|
const encodedUIntArray = new TextEncoder().encode(streamName);
|
|
5180
2607
|
const streamNameArray = Array.from(encodedUIntArray);
|
|
5181
2608
|
const createIx = await this.alignedProxyProgram.methods.create({
|
|
5182
|
-
startTime: new
|
|
2609
|
+
startTime: new BN3(start),
|
|
5183
2610
|
netAmountDeposited: depositedAmount,
|
|
5184
|
-
period: new
|
|
2611
|
+
period: new BN3(period),
|
|
5185
2612
|
amountPerPeriod,
|
|
5186
|
-
cliff: new
|
|
2613
|
+
cliff: new BN3(cliff),
|
|
5187
2614
|
cliffAmount,
|
|
5188
2615
|
transferableBySender,
|
|
5189
2616
|
transferableByRecipient,
|
|
@@ -5192,15 +2619,15 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5192
2619
|
canTopup,
|
|
5193
2620
|
oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
|
|
5194
2621
|
streamName: streamNameArray,
|
|
5195
|
-
minPrice: typeof minPrice === "number" ? getBN
|
|
5196
|
-
maxPrice: typeof maxPrice === "number" ? getBN
|
|
5197
|
-
minPercentage: typeof minPercentage === "number" ? getBN
|
|
5198
|
-
maxPercentage: typeof maxPercentage === "number" ? getBN
|
|
5199
|
-
tickSize: new
|
|
2622
|
+
minPrice: typeof minPrice === "number" ? getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW2) : minPrice,
|
|
2623
|
+
maxPrice: typeof maxPrice === "number" ? getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW2) : maxPrice,
|
|
2624
|
+
minPercentage: typeof minPercentage === "number" ? getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW2) : minPercentage,
|
|
2625
|
+
maxPercentage: typeof maxPercentage === "number" ? getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW2) : maxPercentage,
|
|
2626
|
+
tickSize: new BN3(tickSize || 1),
|
|
5200
2627
|
skipInitial: skipInitial ?? false,
|
|
5201
|
-
expiryTime: new
|
|
5202
|
-
expiryPercentage: typeof expiryPercentage === "number" ? getBN
|
|
5203
|
-
floorPrice: typeof floorPrice === "number" ? getBN
|
|
2628
|
+
expiryTime: new BN3(expiryTime ?? 0),
|
|
2629
|
+
expiryPercentage: typeof expiryPercentage === "number" ? getBN(expiryPercentage, ALIGNED_PRECISION_FACTOR_POW2) : expiryPercentage ?? new BN3(0),
|
|
2630
|
+
floorPrice: typeof floorPrice === "number" ? getBN(floorPrice, ALIGNED_PRECISION_FACTOR_POW2) : floorPrice ?? new BN3(0)
|
|
5204
2631
|
}).accountsPartial({
|
|
5205
2632
|
payer: sender.publicKey,
|
|
5206
2633
|
sender: sender.publicKey,
|
|
@@ -5222,7 +2649,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5222
2649
|
* Creates a new stream/vesting contract.
|
|
5223
2650
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5224
2651
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5225
|
-
* @param {
|
|
2652
|
+
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5226
2653
|
* @returns Create stream instructions
|
|
5227
2654
|
*/
|
|
5228
2655
|
async prepareCreateStreamInstructions({
|
|
@@ -5271,12 +2698,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5271
2698
|
ixs.push(
|
|
5272
2699
|
await createStreamInstruction(
|
|
5273
2700
|
{
|
|
5274
|
-
start: new
|
|
2701
|
+
start: new BN3(start),
|
|
5275
2702
|
depositedAmount,
|
|
5276
|
-
period: new
|
|
2703
|
+
period: new BN3(period),
|
|
5277
2704
|
amountPerPeriod,
|
|
5278
|
-
cliff: new
|
|
5279
|
-
cliffAmount: new
|
|
2705
|
+
cliff: new BN3(cliff),
|
|
2706
|
+
cliffAmount: new BN3(cliffAmount),
|
|
5280
2707
|
cancelableBySender,
|
|
5281
2708
|
cancelableByRecipient,
|
|
5282
2709
|
automaticWithdrawal,
|
|
@@ -5286,7 +2713,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5286
2713
|
canUpdateRate: !!canUpdateRate,
|
|
5287
2714
|
canPause: !!canPause,
|
|
5288
2715
|
name,
|
|
5289
|
-
withdrawFrequency: new
|
|
2716
|
+
withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period)
|
|
5290
2717
|
},
|
|
5291
2718
|
this.programId,
|
|
5292
2719
|
{
|
|
@@ -5323,7 +2750,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5323
2750
|
*
|
|
5324
2751
|
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
5325
2752
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
5326
|
-
* @param {
|
|
2753
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5327
2754
|
* @returns Create result
|
|
5328
2755
|
*/
|
|
5329
2756
|
async createUnchecked(data, extParams) {
|
|
@@ -5405,12 +2832,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5405
2832
|
}
|
|
5406
2833
|
const createInstruction = await createUncheckedStreamInstruction(
|
|
5407
2834
|
{
|
|
5408
|
-
start: new
|
|
2835
|
+
start: new BN3(start),
|
|
5409
2836
|
depositedAmount,
|
|
5410
|
-
period: new
|
|
2837
|
+
period: new BN3(period),
|
|
5411
2838
|
amountPerPeriod,
|
|
5412
|
-
cliff: new
|
|
5413
|
-
cliffAmount: new
|
|
2839
|
+
cliff: new BN3(cliff),
|
|
2840
|
+
cliffAmount: new BN3(cliffAmount),
|
|
5414
2841
|
cancelableBySender,
|
|
5415
2842
|
cancelableByRecipient,
|
|
5416
2843
|
automaticWithdrawal,
|
|
@@ -5420,7 +2847,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5420
2847
|
canUpdateRate: !!canUpdateRate,
|
|
5421
2848
|
canPause: !!canPause,
|
|
5422
2849
|
name,
|
|
5423
|
-
withdrawFrequency: new
|
|
2850
|
+
withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period),
|
|
5424
2851
|
recipient: recipientPublicKey,
|
|
5425
2852
|
partner: partnerPublicKey
|
|
5426
2853
|
},
|
|
@@ -5446,7 +2873,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5446
2873
|
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
5447
2874
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5448
2875
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5449
|
-
* @param {
|
|
2876
|
+
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5450
2877
|
* @returns Create multiple transaction instructions
|
|
5451
2878
|
*/
|
|
5452
2879
|
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
@@ -5489,7 +2916,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5489
2916
|
true
|
|
5490
2917
|
);
|
|
5491
2918
|
if (isNative) {
|
|
5492
|
-
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new
|
|
2919
|
+
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3(0));
|
|
5493
2920
|
const nativeInstructions = await prepareWrappedAccount(
|
|
5494
2921
|
this.connection,
|
|
5495
2922
|
sender.publicKey,
|
|
@@ -5527,7 +2954,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5527
2954
|
* ```
|
|
5528
2955
|
*
|
|
5529
2956
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5530
|
-
* @param {
|
|
2957
|
+
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
5531
2958
|
* @returns Multiple transaction information
|
|
5532
2959
|
*/
|
|
5533
2960
|
async buildCreateMultipleTransactions(data, extParams) {
|
|
@@ -5555,7 +2982,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5555
2982
|
* Creates multiple stream/vesting contracts.
|
|
5556
2983
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5557
2984
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5558
|
-
* @param {
|
|
2985
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5559
2986
|
* @returns Multiple transaction information
|
|
5560
2987
|
*/
|
|
5561
2988
|
async createMultiple(data, extParams) {
|
|
@@ -5620,7 +3047,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5620
3047
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
5621
3048
|
* In most cases, createMultiple should be used instead.
|
|
5622
3049
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
5623
|
-
* @param {
|
|
3050
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
5624
3051
|
* @returns Multiple transaction information
|
|
5625
3052
|
*/
|
|
5626
3053
|
async createMultipleSequential(data, extParams) {
|
|
@@ -5686,7 +3113,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5686
3113
|
/**
|
|
5687
3114
|
* Attempts withdrawing from the specified stream.
|
|
5688
3115
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5689
|
-
* @param {
|
|
3116
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5690
3117
|
* @returns Transaction result
|
|
5691
3118
|
*/
|
|
5692
3119
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
@@ -5715,7 +3142,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5715
3142
|
/**
|
|
5716
3143
|
* Creates Transaction Instructions for withdrawal
|
|
5717
3144
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
5718
|
-
* @param {
|
|
3145
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
5719
3146
|
* @returns Transaction instructions
|
|
5720
3147
|
*/
|
|
5721
3148
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
@@ -5760,7 +3187,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5760
3187
|
/**
|
|
5761
3188
|
* Attempts canceling the specified stream.
|
|
5762
3189
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5763
|
-
* @param {
|
|
3190
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5764
3191
|
* @returns Transaction result
|
|
5765
3192
|
*/
|
|
5766
3193
|
async cancel(cancelData, extParams) {
|
|
@@ -5782,7 +3209,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5782
3209
|
/**
|
|
5783
3210
|
* Creates Transaction Instructions for cancel
|
|
5784
3211
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5785
|
-
* @param {
|
|
3212
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
5786
3213
|
* @returns Transaction instructions
|
|
5787
3214
|
*/
|
|
5788
3215
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
@@ -5799,7 +3226,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5799
3226
|
/**
|
|
5800
3227
|
* Creates Transaction Instructions for cancel
|
|
5801
3228
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5802
|
-
* @param {
|
|
3229
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5803
3230
|
* @returns Transaction instructions
|
|
5804
3231
|
*/
|
|
5805
3232
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
@@ -5838,7 +3265,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5838
3265
|
/**
|
|
5839
3266
|
* Creates Transaction Instructions for cancel
|
|
5840
3267
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
5841
|
-
* @param {
|
|
3268
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
5842
3269
|
* @returns Transaction instructions
|
|
5843
3270
|
*/
|
|
5844
3271
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
@@ -5886,7 +3313,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5886
3313
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5887
3314
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5888
3315
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5889
|
-
* @param {
|
|
3316
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5890
3317
|
* @returns Transaction result
|
|
5891
3318
|
*/
|
|
5892
3319
|
async transfer({ id, newRecipient }, extParams) {
|
|
@@ -5909,7 +3336,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5909
3336
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
5910
3337
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
5911
3338
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
5912
|
-
* @param {
|
|
3339
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
5913
3340
|
* @returns Transaction instructions
|
|
5914
3341
|
*/
|
|
5915
3342
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
@@ -5943,7 +3370,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5943
3370
|
/**
|
|
5944
3371
|
* Tops up stream account with specified amount.
|
|
5945
3372
|
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
5946
|
-
* @param {
|
|
3373
|
+
* @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
5947
3374
|
* @returns Transaction result
|
|
5948
3375
|
*/
|
|
5949
3376
|
async topup({ id, amount }, extParams) {
|
|
@@ -5965,7 +3392,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
5965
3392
|
/**
|
|
5966
3393
|
* Create Transaction instructions for topup
|
|
5967
3394
|
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
5968
|
-
* @param {
|
|
3395
|
+
* @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
5969
3396
|
* @returns Transaction instructions
|
|
5970
3397
|
*/
|
|
5971
3398
|
async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
|
|
@@ -6027,7 +3454,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6027
3454
|
}
|
|
6028
3455
|
return new AlignedContract(stream, alignedProxy);
|
|
6029
3456
|
}
|
|
6030
|
-
return new
|
|
3457
|
+
return new Contract(stream);
|
|
6031
3458
|
}
|
|
6032
3459
|
/**
|
|
6033
3460
|
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
@@ -6097,7 +3524,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6097
3524
|
this.programId
|
|
6098
3525
|
);
|
|
6099
3526
|
outgoingStreamAccounts.forEach((account) => {
|
|
6100
|
-
streams[account.pubkey.toBase58()] = new
|
|
3527
|
+
streams[account.pubkey.toBase58()] = new Contract(decodeStream(account.account.data));
|
|
6101
3528
|
});
|
|
6102
3529
|
if (shouldFetchAligned) {
|
|
6103
3530
|
const alignedStreams = await this.getOutgoingAlignedStreams(address);
|
|
@@ -6117,7 +3544,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6117
3544
|
if (this.isAlignedUnlock(account.pubkey, allIncomingStreams[index].sender)) {
|
|
6118
3545
|
alignedDecoded[account.pubkey.toBase58()] = allIncomingStreams[index];
|
|
6119
3546
|
} else {
|
|
6120
|
-
streams[account.pubkey.toBase58()] = new
|
|
3547
|
+
streams[account.pubkey.toBase58()] = new Contract(allIncomingStreams[index]);
|
|
6121
3548
|
}
|
|
6122
3549
|
});
|
|
6123
3550
|
if (shouldFetchAligned) {
|
|
@@ -6147,13 +3574,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6147
3574
|
});
|
|
6148
3575
|
return accounts.map(({ pubkey, account }) => ({
|
|
6149
3576
|
publicKey: pubkey,
|
|
6150
|
-
account: new
|
|
3577
|
+
account: new Contract(decodeStream(account.data))
|
|
6151
3578
|
}));
|
|
6152
3579
|
}
|
|
6153
3580
|
/**
|
|
6154
3581
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
6155
3582
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6156
|
-
* @param {
|
|
3583
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6157
3584
|
* @returns Transaction result
|
|
6158
3585
|
*/
|
|
6159
3586
|
async update(data, extParams) {
|
|
@@ -6181,7 +3608,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6181
3608
|
/**
|
|
6182
3609
|
* Create Transaction instructions for update
|
|
6183
3610
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
6184
|
-
* @param {
|
|
3611
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
6185
3612
|
* @returns Transaction instructions
|
|
6186
3613
|
*/
|
|
6187
3614
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
@@ -6234,6 +3661,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6234
3661
|
async getDefaultStreamflowFee() {
|
|
6235
3662
|
return DEFAULT_STREAMFLOW_FEE;
|
|
6236
3663
|
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Returns total fee percent, streamflow fees + partner fees
|
|
3666
|
+
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3667
|
+
* @param chainSpecificParams additional parameters required by chain client
|
|
3668
|
+
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3669
|
+
*/
|
|
3670
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3671
|
+
async getTotalFee(getFeesData) {
|
|
3672
|
+
const fees = await this.getFees(getFeesData);
|
|
3673
|
+
if (fees) {
|
|
3674
|
+
return fees.partnerFee + fees.streamflowFee;
|
|
3675
|
+
}
|
|
3676
|
+
return this.getDefaultStreamflowFee();
|
|
3677
|
+
}
|
|
6237
3678
|
/**
|
|
6238
3679
|
* Extracts error code from an error
|
|
6239
3680
|
* @param {Error} err - Error
|
|
@@ -6243,6 +3684,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6243
3684
|
const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
|
|
6244
3685
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
6245
3686
|
}
|
|
3687
|
+
/**
|
|
3688
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
3689
|
+
*/
|
|
3690
|
+
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3691
|
+
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3692
|
+
return senderPublicKey.equals(pda);
|
|
3693
|
+
}
|
|
6246
3694
|
/**
|
|
6247
3695
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
6248
3696
|
*/
|
|
@@ -6254,15 +3702,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
6254
3702
|
metadataPubKey = metadata.publicKey;
|
|
6255
3703
|
} else {
|
|
6256
3704
|
metadataPubKey = metadataPubKeys[0];
|
|
6257
|
-
}
|
|
6258
|
-
return { metadata, metadataPubKey };
|
|
6259
|
-
}
|
|
6260
|
-
/**
|
|
6261
|
-
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
6262
|
-
*/
|
|
6263
|
-
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
6264
|
-
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
6265
|
-
return senderPublicKey.equals(pda);
|
|
3705
|
+
}
|
|
3706
|
+
return { metadata, metadataPubKey };
|
|
6266
3707
|
}
|
|
6267
3708
|
/**
|
|
6268
3709
|
* Returns insrtuctions for creating associated token accounts for the provided owners
|
|
@@ -6709,815 +4150,6 @@ var timelockIDL_default = {
|
|
|
6709
4150
|
]
|
|
6710
4151
|
};
|
|
6711
4152
|
|
|
6712
|
-
|
|
6713
|
-
var sui_exports = {};
|
|
6714
|
-
__export(sui_exports, {
|
|
6715
|
-
Contract: () => Contract3,
|
|
6716
|
-
SuiStreamClient: () => SuiStreamClient,
|
|
6717
|
-
constants: () => constants_exports4,
|
|
6718
|
-
extractSuiErrorInfo: () => extractSuiErrorInfo,
|
|
6719
|
-
getTransactionBlock: () => getTransactionBlock
|
|
6720
|
-
});
|
|
6721
|
-
|
|
6722
|
-
// sui/constants.ts
|
|
6723
|
-
var constants_exports4 = {};
|
|
6724
|
-
__export(constants_exports4, {
|
|
6725
|
-
SUI_CONFIG_IDS: () => SUI_CONFIG_IDS,
|
|
6726
|
-
SUI_ERROR_MATCH_REGEX: () => SUI_ERROR_MATCH_REGEX,
|
|
6727
|
-
SUI_FEE_TABLE_IDS: () => SUI_FEE_TABLE_IDS,
|
|
6728
|
-
SUI_MODULE_ERROR_MAP: () => SUI_MODULE_ERROR_MAP,
|
|
6729
|
-
SUI_PROGRAM_IDS: () => SUI_PROGRAM_IDS
|
|
6730
|
-
});
|
|
6731
|
-
var SUI_PROGRAM_IDS = {
|
|
6732
|
-
[ICluster.Mainnet]: "0xe456a3a1d4e58e85b4b7175fabe6dae895b983f1379bb8948d6ec2f137b08a7b",
|
|
6733
|
-
[ICluster.Devnet]: "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
6734
|
-
[ICluster.Testnet]: "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
6735
|
-
[ICluster.Local]: "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a"
|
|
6736
|
-
};
|
|
6737
|
-
var SUI_CONFIG_IDS = {
|
|
6738
|
-
[ICluster.Mainnet]: "0x6cf6760b64245b8d23ef57c28ddceb6adbd540a23a509fef29b82237da4ab87b",
|
|
6739
|
-
[ICluster.Devnet]: "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
6740
|
-
[ICluster.Testnet]: "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
6741
|
-
[ICluster.Local]: "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8"
|
|
6742
|
-
};
|
|
6743
|
-
var SUI_FEE_TABLE_IDS = {
|
|
6744
|
-
[ICluster.Mainnet]: "0xad9b75399632583fb9fcae6b5bcca34e6542ab3bedb630ecbd3f15cb1cc48dbe",
|
|
6745
|
-
[ICluster.Devnet]: "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
6746
|
-
[ICluster.Testnet]: "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
6747
|
-
[ICluster.Local]: "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078"
|
|
6748
|
-
};
|
|
6749
|
-
var SUI_ERROR_MATCH_REGEX = /MoveAbort\(MoveLocation \{ module: ModuleId \{ address: (\w+), name: Identifier\("([\w_]+)"\) }, function: \d+, instruction: \d+, function_name: Some\("([\w_]+)"\) }, (\d+)\) in command (\d+)/;
|
|
6750
|
-
var SUI_MODULE_ERROR_MAP = {
|
|
6751
|
-
protocol: {
|
|
6752
|
-
1: "ECONTRACT_NOT_INIT" /* ECONTRACT_NOT_INIT */,
|
|
6753
|
-
2: "EBAD_AMOUNT" /* EBAD_AMOUNT */,
|
|
6754
|
-
3: "ENO_PERMISSIONS" /* ENO_PERMISSIONS */,
|
|
6755
|
-
4: "EBADINPUT" /* EBADINPUT */,
|
|
6756
|
-
5: "ECLOSED" /* ECLOSED */,
|
|
6757
|
-
6: "EBAD_INPUT_AMOUNT_PER_PERIOD" /* EBAD_INPUT_AMOUNT_PER_PERIOD */,
|
|
6758
|
-
8: "EBAD_INPUT_UPDATE_RATE" /* EBAD_INPUT_UPDATE_RATE */,
|
|
6759
|
-
9: "EBAD_INPUT_CLIFF_AMOUNT" /* EBAD_INPUT_CLIFF_AMOUNT */,
|
|
6760
|
-
10: "EBAD_INPUT_PERIOD" /* EBAD_INPUT_PERIOD */,
|
|
6761
|
-
11: "EBAD_INPUT_START" /* EBAD_INPUT_START */,
|
|
6762
|
-
13: "EBAD_INSUFFICIENT_WITHDRAWAL_FEES" /* EBAD_INSUFFICIENT_WITHDRAWAL_FEES */,
|
|
6763
|
-
14: "EBAD_INSUFFICIENT_AMOUNT" /* EBAD_INSUFFICIENT_AMOUNT */,
|
|
6764
|
-
15: "EPAUSED" /* EPAUSED */,
|
|
6765
|
-
16: "ENOTPAUSED" /* ENOTPAUSED */
|
|
6766
|
-
}
|
|
6767
|
-
};
|
|
6768
|
-
var Contract3 = class {
|
|
6769
|
-
constructor(stream, tokenId) {
|
|
6770
|
-
const meta = stream.meta.fields;
|
|
6771
|
-
const fees = stream.fees.fields;
|
|
6772
|
-
this.magic = 0;
|
|
6773
|
-
this.version = parseInt(stream.version);
|
|
6774
|
-
this.createdAt = parseInt(stream.created);
|
|
6775
|
-
this.withdrawnAmount = new BN7(stream.withdrawn);
|
|
6776
|
-
this.canceledAt = parseInt(stream.canceled_at);
|
|
6777
|
-
this.end = parseInt(stream.end);
|
|
6778
|
-
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
6779
|
-
this.sender = stream.sender;
|
|
6780
|
-
this.senderTokens = stream.sender;
|
|
6781
|
-
this.recipient = stream.recipient;
|
|
6782
|
-
this.recipientTokens = stream.recipient;
|
|
6783
|
-
this.mint = tokenId;
|
|
6784
|
-
this.escrowTokens = "";
|
|
6785
|
-
this.streamflowTreasury = "";
|
|
6786
|
-
this.streamflowTreasuryTokens = "";
|
|
6787
|
-
this.streamflowFeeTotal = new BN7(0);
|
|
6788
|
-
this.streamflowFeeWithdrawn = new BN7(0);
|
|
6789
|
-
this.streamflowFeePercent = parseInt(fees.streamflow_fee_percentage) / 1e4;
|
|
6790
|
-
this.partnerFeeTotal = new BN7(0);
|
|
6791
|
-
this.partnerFeeWithdrawn = new BN7(0);
|
|
6792
|
-
this.partnerFeePercent = parseInt(fees.partner_fee_percentage) / 1e4;
|
|
6793
|
-
this.partner = stream.partner;
|
|
6794
|
-
this.partnerTokens = "";
|
|
6795
|
-
this.start = parseInt(stream.start);
|
|
6796
|
-
this.depositedAmount = new BN7(stream.amount);
|
|
6797
|
-
this.period = parseInt(stream.period);
|
|
6798
|
-
this.amountPerPeriod = new BN7(stream.amount_per_period);
|
|
6799
|
-
this.cliff = parseInt(stream.start);
|
|
6800
|
-
this.cliffAmount = new BN7(stream.cliff_amount);
|
|
6801
|
-
this.cancelableBySender = meta.cancelable_by_sender;
|
|
6802
|
-
this.cancelableByRecipient = meta.cancelable_by_recipient;
|
|
6803
|
-
this.automaticWithdrawal = meta.automatic_withdrawal;
|
|
6804
|
-
this.transferableBySender = meta.transferable_by_sender;
|
|
6805
|
-
this.transferableByRecipient = meta.transferable_by_recipient;
|
|
6806
|
-
this.canTopup = meta.can_topup;
|
|
6807
|
-
this.name = String.fromCharCode(...meta.contract_name);
|
|
6808
|
-
this.withdrawalFrequency = parseInt(meta.withdrawal_frequency);
|
|
6809
|
-
this.closed = stream.closed;
|
|
6810
|
-
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
6811
|
-
this.pauseCumulative = new BN7(stream.pause_cumulative);
|
|
6812
|
-
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
6813
|
-
this.fundsUnlockedAtLastRateChange = new BN7(stream.funds_unlocked_at_last_rate_change);
|
|
6814
|
-
this.type = buildStreamType(this);
|
|
6815
|
-
}
|
|
6816
|
-
unlocked(currentTimestamp) {
|
|
6817
|
-
return calculateUnlockedAmount({
|
|
6818
|
-
...this,
|
|
6819
|
-
currentTimestamp
|
|
6820
|
-
});
|
|
6821
|
-
}
|
|
6822
|
-
remaining(decimals) {
|
|
6823
|
-
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
6824
|
-
}
|
|
6825
|
-
};
|
|
6826
|
-
|
|
6827
|
-
// ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
6828
|
-
var import_retry = __toESM(require_retry2());
|
|
6829
|
-
|
|
6830
|
-
// ../../node_modules/.pnpm/is-network-error@1.1.0/node_modules/is-network-error/index.js
|
|
6831
|
-
var objectToString = Object.prototype.toString;
|
|
6832
|
-
var isError = (value) => objectToString.call(value) === "[object Error]";
|
|
6833
|
-
var errorMessages = /* @__PURE__ */ new Set([
|
|
6834
|
-
"network error",
|
|
6835
|
-
// Chrome
|
|
6836
|
-
"Failed to fetch",
|
|
6837
|
-
// Chrome
|
|
6838
|
-
"NetworkError when attempting to fetch resource.",
|
|
6839
|
-
// Firefox
|
|
6840
|
-
"The Internet connection appears to be offline.",
|
|
6841
|
-
// Safari 16
|
|
6842
|
-
"Load failed",
|
|
6843
|
-
// Safari 17+
|
|
6844
|
-
"Network request failed",
|
|
6845
|
-
// `cross-fetch`
|
|
6846
|
-
"fetch failed",
|
|
6847
|
-
// Undici (Node.js)
|
|
6848
|
-
"terminated"
|
|
6849
|
-
// Undici (Node.js)
|
|
6850
|
-
]);
|
|
6851
|
-
function isNetworkError(error) {
|
|
6852
|
-
const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
6853
|
-
if (!isValid) {
|
|
6854
|
-
return false;
|
|
6855
|
-
}
|
|
6856
|
-
if (error.message === "Load failed") {
|
|
6857
|
-
return error.stack === void 0;
|
|
6858
|
-
}
|
|
6859
|
-
return errorMessages.has(error.message);
|
|
6860
|
-
}
|
|
6861
|
-
|
|
6862
|
-
// ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
6863
|
-
var AbortError = class extends Error {
|
|
6864
|
-
constructor(message) {
|
|
6865
|
-
super();
|
|
6866
|
-
if (message instanceof Error) {
|
|
6867
|
-
this.originalError = message;
|
|
6868
|
-
({ message } = message);
|
|
6869
|
-
} else {
|
|
6870
|
-
this.originalError = new Error(message);
|
|
6871
|
-
this.originalError.stack = this.stack;
|
|
6872
|
-
}
|
|
6873
|
-
this.name = "AbortError";
|
|
6874
|
-
this.message = message;
|
|
6875
|
-
}
|
|
6876
|
-
};
|
|
6877
|
-
var decorateErrorWithCounts = (error, attemptNumber, options) => {
|
|
6878
|
-
const retriesLeft = options.retries - (attemptNumber - 1);
|
|
6879
|
-
error.attemptNumber = attemptNumber;
|
|
6880
|
-
error.retriesLeft = retriesLeft;
|
|
6881
|
-
return error;
|
|
6882
|
-
};
|
|
6883
|
-
async function pRetry(input, options) {
|
|
6884
|
-
return new Promise((resolve, reject) => {
|
|
6885
|
-
options = { ...options };
|
|
6886
|
-
options.onFailedAttempt ?? (options.onFailedAttempt = () => {
|
|
6887
|
-
});
|
|
6888
|
-
options.shouldRetry ?? (options.shouldRetry = () => true);
|
|
6889
|
-
options.retries ?? (options.retries = 10);
|
|
6890
|
-
const operation = import_retry.default.operation(options);
|
|
6891
|
-
const abortHandler = () => {
|
|
6892
|
-
operation.stop();
|
|
6893
|
-
reject(options.signal?.reason);
|
|
6894
|
-
};
|
|
6895
|
-
if (options.signal && !options.signal.aborted) {
|
|
6896
|
-
options.signal.addEventListener("abort", abortHandler, { once: true });
|
|
6897
|
-
}
|
|
6898
|
-
const cleanUp = () => {
|
|
6899
|
-
options.signal?.removeEventListener("abort", abortHandler);
|
|
6900
|
-
operation.stop();
|
|
6901
|
-
};
|
|
6902
|
-
operation.attempt(async (attemptNumber) => {
|
|
6903
|
-
try {
|
|
6904
|
-
const result = await input(attemptNumber);
|
|
6905
|
-
cleanUp();
|
|
6906
|
-
resolve(result);
|
|
6907
|
-
} catch (error) {
|
|
6908
|
-
try {
|
|
6909
|
-
if (!(error instanceof Error)) {
|
|
6910
|
-
throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
6911
|
-
}
|
|
6912
|
-
if (error instanceof AbortError) {
|
|
6913
|
-
throw error.originalError;
|
|
6914
|
-
}
|
|
6915
|
-
if (error instanceof TypeError && !isNetworkError(error)) {
|
|
6916
|
-
throw error;
|
|
6917
|
-
}
|
|
6918
|
-
decorateErrorWithCounts(error, attemptNumber, options);
|
|
6919
|
-
if (!await options.shouldRetry(error)) {
|
|
6920
|
-
operation.stop();
|
|
6921
|
-
reject(error);
|
|
6922
|
-
}
|
|
6923
|
-
await options.onFailedAttempt(error);
|
|
6924
|
-
if (!operation.retry(error)) {
|
|
6925
|
-
throw operation.mainError();
|
|
6926
|
-
}
|
|
6927
|
-
} catch (finalError) {
|
|
6928
|
-
decorateErrorWithCounts(finalError, attemptNumber, options);
|
|
6929
|
-
cleanUp();
|
|
6930
|
-
reject(finalError);
|
|
6931
|
-
}
|
|
6932
|
-
}
|
|
6933
|
-
});
|
|
6934
|
-
});
|
|
6935
|
-
}
|
|
6936
|
-
|
|
6937
|
-
// sui/utils.ts
|
|
6938
|
-
function extractSuiErrorInfo(errorText) {
|
|
6939
|
-
const error = { text: errorText };
|
|
6940
|
-
const match = SUI_ERROR_MATCH_REGEX.exec(errorText);
|
|
6941
|
-
if (!match) {
|
|
6942
|
-
return error;
|
|
6943
|
-
}
|
|
6944
|
-
const moduleName = match[2];
|
|
6945
|
-
const errorCode = Number(match[4]);
|
|
6946
|
-
const errorName = SUI_MODULE_ERROR_MAP[moduleName] ? SUI_MODULE_ERROR_MAP[moduleName][errorCode] : void 0;
|
|
6947
|
-
const index = Number(match[5]);
|
|
6948
|
-
if (index) {
|
|
6949
|
-
error.index = index;
|
|
6950
|
-
}
|
|
6951
|
-
if (errorName) {
|
|
6952
|
-
error.parsed = {
|
|
6953
|
-
module: moduleName,
|
|
6954
|
-
code: errorCode,
|
|
6955
|
-
name: errorName
|
|
6956
|
-
};
|
|
6957
|
-
}
|
|
6958
|
-
return error;
|
|
6959
|
-
}
|
|
6960
|
-
function getTransactionBlock(client, input) {
|
|
6961
|
-
return pRetry(() => client.getTransactionBlock(input), {
|
|
6962
|
-
retries: 5,
|
|
6963
|
-
shouldRetry: (error) => error.message.includes("Could not find the referenced transaction"),
|
|
6964
|
-
minTimeout: 500,
|
|
6965
|
-
maxTimeout: 1e3
|
|
6966
|
-
});
|
|
6967
|
-
}
|
|
6968
|
-
function isSignerKeypair2(walletOrKeypair) {
|
|
6969
|
-
return walletOrKeypair instanceof Keypair$1 || walletOrKeypair.constructor === Keypair$1 || walletOrKeypair.constructor.name === Keypair$1.prototype.constructor.name || "getSecretKey" in walletOrKeypair;
|
|
6970
|
-
}
|
|
6971
|
-
var SuiWalletWrapper = class {
|
|
6972
|
-
constructor(wallet, client) {
|
|
6973
|
-
this.client = client;
|
|
6974
|
-
this.wallet = wallet;
|
|
6975
|
-
if (isSignerKeypair2(wallet)) {
|
|
6976
|
-
this.address = wallet.toSuiAddress();
|
|
6977
|
-
} else {
|
|
6978
|
-
this.address = wallet.address;
|
|
6979
|
-
}
|
|
6980
|
-
}
|
|
6981
|
-
async signAndExecuteTransaction(input) {
|
|
6982
|
-
if (isSignerKeypair2(this.wallet)) {
|
|
6983
|
-
return this.client.signAndExecuteTransaction({
|
|
6984
|
-
...input,
|
|
6985
|
-
// @ts-ignore
|
|
6986
|
-
signer: this.wallet
|
|
6987
|
-
});
|
|
6988
|
-
}
|
|
6989
|
-
return this.wallet.signAndExecuteTransaction(input);
|
|
6990
|
-
}
|
|
6991
|
-
};
|
|
6992
|
-
|
|
6993
|
-
// sui/StreamClient.ts
|
|
6994
|
-
var SuiStreamClient = class extends BaseStreamClient {
|
|
6995
|
-
constructor(clusterUrl, cluster = ICluster.Mainnet, ids) {
|
|
6996
|
-
super();
|
|
6997
|
-
this.programId = ids?.program ? ids.program : SUI_PROGRAM_IDS[cluster];
|
|
6998
|
-
this.configId = ids?.config ? ids.config : SUI_CONFIG_IDS[cluster];
|
|
6999
|
-
this.feeTableId = ids?.feeTable ? ids.feeTable : SUI_FEE_TABLE_IDS[cluster];
|
|
7000
|
-
this.client = new SuiClient({ url: clusterUrl });
|
|
7001
|
-
}
|
|
7002
|
-
/**
|
|
7003
|
-
* Creates a new stream/vesting contract.
|
|
7004
|
-
*/
|
|
7005
|
-
async create(streamData, { senderWallet }) {
|
|
7006
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7007
|
-
const totalFee = await this.getTotalFee({
|
|
7008
|
-
address: streamData.partner ?? wallet.address
|
|
7009
|
-
});
|
|
7010
|
-
const [tx] = await this.generateCreateBlock(
|
|
7011
|
-
wallet.address,
|
|
7012
|
-
{
|
|
7013
|
-
...streamData,
|
|
7014
|
-
recipients: [{ ...streamData }]
|
|
7015
|
-
},
|
|
7016
|
-
totalFee
|
|
7017
|
-
);
|
|
7018
|
-
const { digest, events } = await wallet.signAndExecuteTransaction({
|
|
7019
|
-
transaction: tx,
|
|
7020
|
-
options: { showEvents: true }
|
|
7021
|
-
});
|
|
7022
|
-
return {
|
|
7023
|
-
ixs: [],
|
|
7024
|
-
txId: digest,
|
|
7025
|
-
metadataId: events[0].parsedJson.address
|
|
7026
|
-
};
|
|
7027
|
-
}
|
|
7028
|
-
/**
|
|
7029
|
-
* Creates multiple stream/vesting contracts.
|
|
7030
|
-
* We don't chain transactions in one Block so that one failed transaction does not revert all others.
|
|
7031
|
-
*/
|
|
7032
|
-
async createMultiple(multipleStreamData, { senderWallet }) {
|
|
7033
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7034
|
-
const totalFee = await this.getTotalFee({
|
|
7035
|
-
address: multipleStreamData.partner ?? wallet.address
|
|
7036
|
-
});
|
|
7037
|
-
const [tx, firstIndex] = await this.generateCreateBlock(wallet.address, multipleStreamData, totalFee);
|
|
7038
|
-
const txs = [];
|
|
7039
|
-
const metadatas = [];
|
|
7040
|
-
const metadataToRecipient = {};
|
|
7041
|
-
const errors = [];
|
|
7042
|
-
try {
|
|
7043
|
-
const executedTx = await wallet.signAndExecuteTransaction({
|
|
7044
|
-
transaction: tx,
|
|
7045
|
-
options: { showEffects: true, showEvents: true }
|
|
7046
|
-
});
|
|
7047
|
-
const digest = executedTx.digest;
|
|
7048
|
-
const { events, effects } = !executedTx.effects || typeof executedTx.effects === "string" ? await getTransactionBlock(this.client, { digest, options: { showEvents: true, showEffects: true } }) : executedTx;
|
|
7049
|
-
txs.push(digest);
|
|
7050
|
-
if (effects.status.status === "failure") {
|
|
7051
|
-
multipleStreamData.recipients.forEach((recipient) => {
|
|
7052
|
-
errors.push({
|
|
7053
|
-
error: effects.status.error ?? "Unknown error!",
|
|
7054
|
-
recipient: recipient.recipient
|
|
7055
|
-
});
|
|
7056
|
-
});
|
|
7057
|
-
} else {
|
|
7058
|
-
multipleStreamData.recipients.forEach((recipient, index) => {
|
|
7059
|
-
const metadataId = events[index].parsedJson.address;
|
|
7060
|
-
metadatas.push(metadataId);
|
|
7061
|
-
metadataToRecipient[metadataId] = recipient;
|
|
7062
|
-
});
|
|
7063
|
-
}
|
|
7064
|
-
} catch (e) {
|
|
7065
|
-
const errorInfo = extractSuiErrorInfo(e.toString() ?? "Unknown error!");
|
|
7066
|
-
multipleStreamData.recipients.forEach((recipient, index) => {
|
|
7067
|
-
if (errorInfo.index === void 0 || errorInfo.index < index + firstIndex || errorInfo.index >= multipleStreamData.recipients.length + firstIndex || errorInfo.index === index + firstIndex) {
|
|
7068
|
-
errors.push({
|
|
7069
|
-
error: errorInfo.text,
|
|
7070
|
-
recipient: recipient.recipient,
|
|
7071
|
-
contractErrorCode: errorInfo.parsed?.name
|
|
7072
|
-
});
|
|
7073
|
-
}
|
|
7074
|
-
});
|
|
7075
|
-
}
|
|
7076
|
-
return {
|
|
7077
|
-
txs,
|
|
7078
|
-
metadatas,
|
|
7079
|
-
metadataToRecipient,
|
|
7080
|
-
errors
|
|
7081
|
-
};
|
|
7082
|
-
}
|
|
7083
|
-
/**
|
|
7084
|
-
* Attempts withdrawing from the specified stream.
|
|
7085
|
-
*/
|
|
7086
|
-
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { senderWallet, tokenId }) {
|
|
7087
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7088
|
-
const tx = new Transaction();
|
|
7089
|
-
tx.moveCall({
|
|
7090
|
-
target: `${this.programId}::protocol::withdraw`,
|
|
7091
|
-
typeArguments: [tokenId],
|
|
7092
|
-
arguments: [
|
|
7093
|
-
tx.object(id),
|
|
7094
|
-
tx.object(this.configId),
|
|
7095
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
7096
|
-
tx.pure.u64(amount.toString())
|
|
7097
|
-
]
|
|
7098
|
-
});
|
|
7099
|
-
const { digest } = await wallet.signAndExecuteTransaction({
|
|
7100
|
-
transaction: tx
|
|
7101
|
-
});
|
|
7102
|
-
return {
|
|
7103
|
-
ixs: [],
|
|
7104
|
-
txId: digest
|
|
7105
|
-
};
|
|
7106
|
-
}
|
|
7107
|
-
/**
|
|
7108
|
-
* Attempts canceling the specified stream.
|
|
7109
|
-
*/
|
|
7110
|
-
async cancel(cancelData, { senderWallet, tokenId }) {
|
|
7111
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7112
|
-
const tx = new Transaction();
|
|
7113
|
-
tx.moveCall({
|
|
7114
|
-
target: `${this.programId}::protocol::cancel`,
|
|
7115
|
-
typeArguments: [tokenId],
|
|
7116
|
-
arguments: [tx.object(cancelData.id), tx.object(this.configId), tx.object(SUI_CLOCK_OBJECT_ID)]
|
|
7117
|
-
});
|
|
7118
|
-
const { digest } = await wallet.signAndExecuteTransaction({
|
|
7119
|
-
transaction: tx
|
|
7120
|
-
});
|
|
7121
|
-
return {
|
|
7122
|
-
ixs: [],
|
|
7123
|
-
txId: digest
|
|
7124
|
-
};
|
|
7125
|
-
}
|
|
7126
|
-
/**
|
|
7127
|
-
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
7128
|
-
*/
|
|
7129
|
-
async transfer(transferData, { senderWallet, tokenId }) {
|
|
7130
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7131
|
-
const tx = new Transaction();
|
|
7132
|
-
tx.moveCall({
|
|
7133
|
-
target: `${this.programId}::protocol::transfer`,
|
|
7134
|
-
typeArguments: [tokenId],
|
|
7135
|
-
arguments: [tx.object(transferData.id), tx.pure.address(transferData.newRecipient)]
|
|
7136
|
-
});
|
|
7137
|
-
const { digest } = await wallet.signAndExecuteTransaction({
|
|
7138
|
-
transaction: tx
|
|
7139
|
-
});
|
|
7140
|
-
return {
|
|
7141
|
-
ixs: [],
|
|
7142
|
-
txId: digest
|
|
7143
|
-
};
|
|
7144
|
-
}
|
|
7145
|
-
/**
|
|
7146
|
-
* Tops up stream account with specified amount.
|
|
7147
|
-
*/
|
|
7148
|
-
async topup(topupData, { senderWallet, tokenId }) {
|
|
7149
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7150
|
-
const tx = new Transaction();
|
|
7151
|
-
const coins = await this.getAllCoins(wallet.address, tokenId);
|
|
7152
|
-
const stream = await this.getOne({ id: topupData.id });
|
|
7153
|
-
const totalFee = (stream.partnerFeePercent + stream.streamflowFeePercent) / 100;
|
|
7154
|
-
const coinObject = this.splitCoinObjectForAmount(tx, topupData.amount, tokenId, coins, totalFee);
|
|
7155
|
-
tx.moveCall({
|
|
7156
|
-
target: `${this.programId}::protocol::topup`,
|
|
7157
|
-
typeArguments: [tokenId],
|
|
7158
|
-
arguments: [
|
|
7159
|
-
tx.object(topupData.id),
|
|
7160
|
-
tx.object(this.configId),
|
|
7161
|
-
coinObject,
|
|
7162
|
-
tx.gas,
|
|
7163
|
-
tx.pure.u64(topupData.amount.toString())
|
|
7164
|
-
]
|
|
7165
|
-
});
|
|
7166
|
-
this.returnSplittedCoinObject(tx, tokenId, coins, coinObject);
|
|
7167
|
-
const { digest } = await wallet.signAndExecuteTransaction({
|
|
7168
|
-
transaction: tx
|
|
7169
|
-
});
|
|
7170
|
-
return {
|
|
7171
|
-
ixs: [],
|
|
7172
|
-
txId: digest
|
|
7173
|
-
};
|
|
7174
|
-
}
|
|
7175
|
-
/**
|
|
7176
|
-
* Fetch stream data by its id (address).
|
|
7177
|
-
*/
|
|
7178
|
-
async getOne({ id }) {
|
|
7179
|
-
const response = await this.client.getObject({
|
|
7180
|
-
id,
|
|
7181
|
-
options: {
|
|
7182
|
-
showContent: true
|
|
7183
|
-
}
|
|
7184
|
-
});
|
|
7185
|
-
if (!response.data) {
|
|
7186
|
-
throw new Error(`Contract with id ${id} could not be found!`);
|
|
7187
|
-
}
|
|
7188
|
-
const content = response.data.content;
|
|
7189
|
-
if (content.dataType !== "moveObject") {
|
|
7190
|
-
throw new Error(`Not a Move Object!`);
|
|
7191
|
-
}
|
|
7192
|
-
return new Contract3(
|
|
7193
|
-
content.fields,
|
|
7194
|
-
"0x97e9a9fb1392e9785319f5512d0bfde6ecf7757b09c6de41cec89e798dd361f2::strmt::STRMT"
|
|
7195
|
-
);
|
|
7196
|
-
}
|
|
7197
|
-
async get() {
|
|
7198
|
-
throw new Error("Get all method is not supported for Sui chain!");
|
|
7199
|
-
}
|
|
7200
|
-
/**
|
|
7201
|
-
* Attempts updating the stream auto withdrawal params and amount per period
|
|
7202
|
-
*/
|
|
7203
|
-
async update(updateData, { senderWallet, tokenId }) {
|
|
7204
|
-
const wallet = new SuiWalletWrapper(senderWallet, this.client);
|
|
7205
|
-
const tx = new Transaction();
|
|
7206
|
-
tx.moveCall({
|
|
7207
|
-
target: `${this.programId}::protocol::update`,
|
|
7208
|
-
typeArguments: [tokenId],
|
|
7209
|
-
arguments: [
|
|
7210
|
-
tx.object(updateData.id),
|
|
7211
|
-
tx.object(this.configId),
|
|
7212
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
7213
|
-
tx.gas,
|
|
7214
|
-
bcs.vector(bcs.bool()).serialize(updateData.enableAutomaticWithdrawal !== void 0 ? [updateData.enableAutomaticWithdrawal] : []),
|
|
7215
|
-
bcs.vector(bcs.u64()).serialize(updateData.withdrawFrequency !== void 0 ? [updateData.withdrawFrequency.toString()] : []),
|
|
7216
|
-
bcs.vector(bcs.u64()).serialize(updateData.amountPerPeriod !== void 0 ? [updateData.amountPerPeriod.toString()] : [])
|
|
7217
|
-
]
|
|
7218
|
-
});
|
|
7219
|
-
const { digest } = await wallet.signAndExecuteTransaction({
|
|
7220
|
-
transaction: tx
|
|
7221
|
-
});
|
|
7222
|
-
return {
|
|
7223
|
-
ixs: [],
|
|
7224
|
-
txId: digest
|
|
7225
|
-
};
|
|
7226
|
-
}
|
|
7227
|
-
extractErrorCode(err) {
|
|
7228
|
-
const errorInfo = extractSuiErrorInfo(err.toString() ?? "Unknown error!");
|
|
7229
|
-
return errorInfo?.parsed?.name || null;
|
|
7230
|
-
}
|
|
7231
|
-
async getFees({ address }) {
|
|
7232
|
-
const response = await this.client.getObject({
|
|
7233
|
-
id: this.feeTableId,
|
|
7234
|
-
options: {
|
|
7235
|
-
showContent: true
|
|
7236
|
-
}
|
|
7237
|
-
});
|
|
7238
|
-
const content = response.data.content;
|
|
7239
|
-
if (content.dataType !== "moveObject") {
|
|
7240
|
-
throw new Error(`Not a Move Object!`);
|
|
7241
|
-
}
|
|
7242
|
-
const fields = content.fields;
|
|
7243
|
-
const fieldsResponse = await this.client.getDynamicFields({
|
|
7244
|
-
parentId: fields.values.fields.id.id
|
|
7245
|
-
});
|
|
7246
|
-
const partnerDynamicField = fieldsResponse.data.filter((item) => item.name.value === address)[0];
|
|
7247
|
-
if (!partnerDynamicField) {
|
|
7248
|
-
return null;
|
|
7249
|
-
}
|
|
7250
|
-
const valueResponse = await this.client.getObject({
|
|
7251
|
-
id: partnerDynamicField.objectId,
|
|
7252
|
-
options: {
|
|
7253
|
-
showContent: true
|
|
7254
|
-
}
|
|
7255
|
-
});
|
|
7256
|
-
const valueContent = valueResponse.data.content;
|
|
7257
|
-
if (valueContent.dataType !== "moveObject") {
|
|
7258
|
-
throw new Error(`Not a Move Object!`);
|
|
7259
|
-
}
|
|
7260
|
-
const valueFields = valueContent.fields.value.fields;
|
|
7261
|
-
return {
|
|
7262
|
-
streamflowFee: Number(valueFields.streamflow_fee) / 100,
|
|
7263
|
-
partnerFee: Number(valueFields.partner_fee) / 100
|
|
7264
|
-
};
|
|
7265
|
-
}
|
|
7266
|
-
async getDefaultStreamflowFee() {
|
|
7267
|
-
const response = await this.client.getObject({
|
|
7268
|
-
id: this.configId,
|
|
7269
|
-
options: {
|
|
7270
|
-
showContent: true
|
|
7271
|
-
}
|
|
7272
|
-
});
|
|
7273
|
-
const content = response.data.content;
|
|
7274
|
-
if (content.dataType !== "moveObject") {
|
|
7275
|
-
throw new Error(`Not a Move Object!`);
|
|
7276
|
-
}
|
|
7277
|
-
const fields = content.fields;
|
|
7278
|
-
return Number(fields.streamflow_fee) / 100;
|
|
7279
|
-
}
|
|
7280
|
-
/**
|
|
7281
|
-
* Returns StreamClient protocol program ID.
|
|
7282
|
-
*/
|
|
7283
|
-
getProgramId() {
|
|
7284
|
-
return this.programId;
|
|
7285
|
-
}
|
|
7286
|
-
/**
|
|
7287
|
-
* Utility function to generate Transaction Block to create streams
|
|
7288
|
-
*/
|
|
7289
|
-
async generateCreateBlock(walletAddress, multipleStreamData, totalFee) {
|
|
7290
|
-
let coins = await this.getAllCoins(walletAddress, multipleStreamData.tokenId);
|
|
7291
|
-
const totalAmount = multipleStreamData.recipients.map((recipiient) => recipiient.amount).reduce((prev, current) => current.add(prev));
|
|
7292
|
-
const tx = new Transaction();
|
|
7293
|
-
const coinObject = this.splitCoinObjectForAmount(tx, totalAmount, multipleStreamData.tokenId, coins, totalFee);
|
|
7294
|
-
coins = [coins[0]];
|
|
7295
|
-
let firstIndex = null;
|
|
7296
|
-
multipleStreamData.recipients.forEach((recipient) => {
|
|
7297
|
-
const result = tx.moveCall({
|
|
7298
|
-
target: `${this.programId}::protocol::create`,
|
|
7299
|
-
typeArguments: [multipleStreamData.tokenId],
|
|
7300
|
-
arguments: [
|
|
7301
|
-
tx.object(this.configId),
|
|
7302
|
-
tx.object(this.feeTableId),
|
|
7303
|
-
tx.object(SUI_CLOCK_OBJECT_ID),
|
|
7304
|
-
coinObject,
|
|
7305
|
-
tx.gas,
|
|
7306
|
-
tx.pure.u64(recipient.amount.toString()),
|
|
7307
|
-
tx.pure.u64(multipleStreamData.period),
|
|
7308
|
-
tx.pure.u64(recipient.amountPerPeriod.toString()),
|
|
7309
|
-
tx.pure.u64(multipleStreamData.start),
|
|
7310
|
-
tx.pure.u64(recipient.cliffAmount.toString()),
|
|
7311
|
-
tx.pure.bool(multipleStreamData.cancelableBySender),
|
|
7312
|
-
tx.pure.bool(multipleStreamData.cancelableByRecipient),
|
|
7313
|
-
tx.pure.bool(multipleStreamData.transferableBySender),
|
|
7314
|
-
tx.pure.bool(multipleStreamData.transferableByRecipient),
|
|
7315
|
-
tx.pure.bool(multipleStreamData.canTopup),
|
|
7316
|
-
tx.pure.bool(!!multipleStreamData.canPause),
|
|
7317
|
-
tx.pure.bool(!!multipleStreamData.canUpdateRate),
|
|
7318
|
-
tx.pure.bool(!!multipleStreamData.automaticWithdrawal),
|
|
7319
|
-
tx.pure.u64(multipleStreamData.withdrawalFrequency || 0),
|
|
7320
|
-
tx.pure.string(recipient.name),
|
|
7321
|
-
tx.pure.address(recipient.recipient),
|
|
7322
|
-
tx.pure.address(multipleStreamData.partner || walletAddress)
|
|
7323
|
-
]
|
|
7324
|
-
});
|
|
7325
|
-
if (result.$kind === "Result" && firstIndex === null) {
|
|
7326
|
-
firstIndex = result.Result;
|
|
7327
|
-
}
|
|
7328
|
-
});
|
|
7329
|
-
this.returnSplittedCoinObject(tx, multipleStreamData.tokenId, coins, coinObject);
|
|
7330
|
-
return [tx, firstIndex];
|
|
7331
|
-
}
|
|
7332
|
-
/**
|
|
7333
|
-
* Returns all coins owned by a Wallet
|
|
7334
|
-
* @param walletAddress wallet address
|
|
7335
|
-
* @param coinType coin type
|
|
7336
|
-
* @returns Array of Coin Structs
|
|
7337
|
-
*/
|
|
7338
|
-
async getAllCoins(walletAddress, coinType) {
|
|
7339
|
-
let coinsResponse = await this.client.getCoins({
|
|
7340
|
-
owner: walletAddress,
|
|
7341
|
-
coinType
|
|
7342
|
-
});
|
|
7343
|
-
const coins = coinsResponse.data;
|
|
7344
|
-
while (coinsResponse.hasNextPage) {
|
|
7345
|
-
coinsResponse = await this.client.getCoins({
|
|
7346
|
-
owner: walletAddress,
|
|
7347
|
-
coinType,
|
|
7348
|
-
cursor: coinsResponse.nextCursor
|
|
7349
|
-
});
|
|
7350
|
-
coins.push(...coinsResponse.data);
|
|
7351
|
-
}
|
|
7352
|
-
return coins;
|
|
7353
|
-
}
|
|
7354
|
-
/**
|
|
7355
|
-
* Utility function to split Coin object and use splitted object for stream operations.
|
|
7356
|
-
* We do it like thid to mitigate risk of Transaction reverting in case Stream is created for Sui Coin object.
|
|
7357
|
-
* This way we can safely pass splitted Sui Coin object in Stream payload and use another object for gas/withdrawal fees.
|
|
7358
|
-
* @param tx current transanction block
|
|
7359
|
-
* @param amount minimal amount of coins requried
|
|
7360
|
-
* @param coinType coin type
|
|
7361
|
-
* @param coins array of owned coins of the same type
|
|
7362
|
-
* @param totalFee partner and treasury fees
|
|
7363
|
-
* @returns Coin Object to use in a Move Call
|
|
7364
|
-
*/
|
|
7365
|
-
splitCoinObjectForAmount(tx, amount, coinType, coins, totalFee) {
|
|
7366
|
-
const coinObject = coinType === SUI_TYPE_ARG ? tx.gas : tx.object(coins[0].coinObjectId);
|
|
7367
|
-
if (coins.length > 1) {
|
|
7368
|
-
tx.mergeCoins(
|
|
7369
|
-
coinObject,
|
|
7370
|
-
coins.slice(1).map((item) => tx.object(item.coinObjectId))
|
|
7371
|
-
);
|
|
7372
|
-
}
|
|
7373
|
-
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
7374
|
-
return tx.splitCoins(coinObject, [tx.pure.u64(totalAmount.toString())])[0];
|
|
7375
|
-
}
|
|
7376
|
-
/**
|
|
7377
|
-
* Return previously splitted Coin Object to owner and merge it to to rebate storage fees
|
|
7378
|
-
* @param tx current transaction
|
|
7379
|
-
* @param coinType coin type
|
|
7380
|
-
* @param coinObject splitted object
|
|
7381
|
-
* @param coins array of objects used in
|
|
7382
|
-
*/
|
|
7383
|
-
returnSplittedCoinObject(tx, coinType, coins, coinObject) {
|
|
7384
|
-
const firstCoinObject = coinType === SUI_TYPE_ARG ? tx.gas : tx.object(coins[0].coinObjectId);
|
|
7385
|
-
tx.mergeCoins(firstCoinObject, [coinObject]);
|
|
7386
|
-
}
|
|
7387
|
-
};
|
|
7388
|
-
|
|
7389
|
-
// common/GenericStreamClient.ts
|
|
7390
|
-
var GenericStreamClient = class extends BaseStreamClient {
|
|
7391
|
-
constructor(options) {
|
|
7392
|
-
super();
|
|
7393
|
-
this.chain = options.chain;
|
|
7394
|
-
switch (options.chain) {
|
|
7395
|
-
case IChain.Solana:
|
|
7396
|
-
this.nativeStreamClient = new SolanaStreamClient(options);
|
|
7397
|
-
break;
|
|
7398
|
-
case IChain.Aptos:
|
|
7399
|
-
this.nativeStreamClient = new AptosStreamClient(
|
|
7400
|
-
options.clusterUrl,
|
|
7401
|
-
options.cluster,
|
|
7402
|
-
options.maxGas,
|
|
7403
|
-
options.programId
|
|
7404
|
-
);
|
|
7405
|
-
break;
|
|
7406
|
-
case IChain.BNB:
|
|
7407
|
-
case IChain.Ethereum:
|
|
7408
|
-
case IChain.Polygon:
|
|
7409
|
-
this.nativeStreamClient = new EvmStreamClient(
|
|
7410
|
-
options.clusterUrl,
|
|
7411
|
-
options.chain,
|
|
7412
|
-
options.signer,
|
|
7413
|
-
options.cluster,
|
|
7414
|
-
options.programId
|
|
7415
|
-
);
|
|
7416
|
-
break;
|
|
7417
|
-
case IChain.Sui:
|
|
7418
|
-
this.nativeStreamClient = new SuiStreamClient(
|
|
7419
|
-
options.clusterUrl,
|
|
7420
|
-
options.cluster,
|
|
7421
|
-
options.ids
|
|
7422
|
-
);
|
|
7423
|
-
}
|
|
7424
|
-
}
|
|
7425
|
-
/**
|
|
7426
|
-
* Creates a new stream/vesting contract.
|
|
7427
|
-
*/
|
|
7428
|
-
create(streamData, chainSpecificParams) {
|
|
7429
|
-
return handleContractError(
|
|
7430
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7431
|
-
() => this.nativeStreamClient.create(streamData, chainSpecificParams),
|
|
7432
|
-
this.nativeStreamClient.extractErrorCode
|
|
7433
|
-
);
|
|
7434
|
-
}
|
|
7435
|
-
/**
|
|
7436
|
-
* Creates multiple stream/vesting contracts.
|
|
7437
|
-
*/
|
|
7438
|
-
createMultiple(multipleStreamData, chainSpecificParams) {
|
|
7439
|
-
return handleContractError(
|
|
7440
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7441
|
-
() => this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams),
|
|
7442
|
-
this.nativeStreamClient.extractErrorCode
|
|
7443
|
-
);
|
|
7444
|
-
}
|
|
7445
|
-
/**
|
|
7446
|
-
* Attempts withdrawing from the specified stream.
|
|
7447
|
-
*/
|
|
7448
|
-
withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, chainSpecificParams) {
|
|
7449
|
-
return handleContractError(
|
|
7450
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7451
|
-
() => this.nativeStreamClient.withdraw({ id, amount }, chainSpecificParams),
|
|
7452
|
-
this.nativeStreamClient.extractErrorCode
|
|
7453
|
-
);
|
|
7454
|
-
}
|
|
7455
|
-
/**
|
|
7456
|
-
* Attempts canceling the specified stream.
|
|
7457
|
-
*/
|
|
7458
|
-
cancel(cancelData, chainSpecificParams) {
|
|
7459
|
-
return handleContractError(
|
|
7460
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7461
|
-
() => this.nativeStreamClient.cancel(cancelData, chainSpecificParams),
|
|
7462
|
-
this.nativeStreamClient.extractErrorCode
|
|
7463
|
-
);
|
|
7464
|
-
}
|
|
7465
|
-
/**
|
|
7466
|
-
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
7467
|
-
*/
|
|
7468
|
-
transfer(transferData, chainSpecificParams) {
|
|
7469
|
-
return handleContractError(
|
|
7470
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7471
|
-
() => this.nativeStreamClient.transfer(transferData, chainSpecificParams),
|
|
7472
|
-
this.nativeStreamClient.extractErrorCode
|
|
7473
|
-
);
|
|
7474
|
-
}
|
|
7475
|
-
/**
|
|
7476
|
-
* Tops up stream account with specified amount.
|
|
7477
|
-
*/
|
|
7478
|
-
topup(topupData, chainSpecificParams) {
|
|
7479
|
-
return handleContractError(
|
|
7480
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7481
|
-
() => this.nativeStreamClient.topup(topupData, chainSpecificParams),
|
|
7482
|
-
this.nativeStreamClient.extractErrorCode
|
|
7483
|
-
);
|
|
7484
|
-
}
|
|
7485
|
-
/**
|
|
7486
|
-
* Fetch stream data by its id (address).
|
|
7487
|
-
*/
|
|
7488
|
-
getOne(getOneData) {
|
|
7489
|
-
return this.nativeStreamClient.getOne(getOneData);
|
|
7490
|
-
}
|
|
7491
|
-
/**
|
|
7492
|
-
* Fetch streams by sender or recipient address.
|
|
7493
|
-
*/
|
|
7494
|
-
get(getAllData) {
|
|
7495
|
-
return this.nativeStreamClient.get(getAllData);
|
|
7496
|
-
}
|
|
7497
|
-
/**
|
|
7498
|
-
* Attempts updating the stream auto withdrawal params and amount per period
|
|
7499
|
-
*/
|
|
7500
|
-
update(updateData, chainSpecificParams) {
|
|
7501
|
-
return handleContractError(
|
|
7502
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7503
|
-
() => this.nativeStreamClient.update(updateData, chainSpecificParams),
|
|
7504
|
-
this.nativeStreamClient.extractErrorCode
|
|
7505
|
-
);
|
|
7506
|
-
}
|
|
7507
|
-
/**
|
|
7508
|
-
* Returns streamflow and partner fees for the specific wallet in %
|
|
7509
|
-
*/
|
|
7510
|
-
getFees(getFeesData) {
|
|
7511
|
-
return this.nativeStreamClient.getFees(getFeesData);
|
|
7512
|
-
}
|
|
7513
|
-
/**
|
|
7514
|
-
* Returns default Streamflow Fee in %
|
|
7515
|
-
*/
|
|
7516
|
-
getDefaultStreamflowFee() {
|
|
7517
|
-
return this.nativeStreamClient.getDefaultStreamflowFee();
|
|
7518
|
-
}
|
|
7519
|
-
};
|
|
7520
|
-
|
|
7521
|
-
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, BASE_FEE, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ContractErrorCode, DEFAULT_STREAMFLOW_FEE, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, GenericStreamClient, MAX_SAFE_UNIX_TIME_VALUE, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaAlignedProxyErrorCode, SolanaContractErrorCode, StreamDirection, StreamType, aptos_exports as StreamflowAptos, evm_exports as StreamflowEVM, solana_exports as StreamflowSolana, sui_exports as StreamflowSui, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, decodeEndTime, getBN, getNumberFromBN, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting };
|
|
4153
|
+
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW2 as ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, AlignedContract, AlignedProxyErrorCode, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Contract, ContractErrorCode, DEFAULT_STREAMFLOW_FEE, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, MAX_SAFE_UNIX_TIME_VALUE2 as MAX_SAFE_UNIX_TIME_VALUE, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isPayment, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction };
|
|
7522
4154
|
//# sourceMappingURL=index.js.map
|
|
7523
4155
|
//# sourceMappingURL=index.js.map
|