@streamflow/stream 6.3.8 → 7.0.0-alpha.1
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 +33 -1
- package/dist/{__tests__ → cjs/__tests__}/aptos/streamClient.spec.js +22 -21
- package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +45 -0
- package/dist/{aptos → cjs/aptos}/StreamClient.js +20 -20
- package/dist/cjs/aptos/constants.js +28 -0
- package/dist/{aptos → cjs/aptos}/index.js +3 -3
- package/dist/{aptos → cjs/aptos}/types.js +12 -11
- package/dist/{aptos → cjs/aptos}/utils.js +2 -2
- package/dist/{common → cjs/common}/GenericStreamClient.js +19 -19
- package/dist/{common → cjs/common}/contractUtils.js +4 -4
- package/dist/{common → cjs/common}/utils.js +4 -6
- package/dist/{evm → cjs/evm}/StreamClient.js +29 -29
- package/dist/cjs/evm/constants.js +39 -0
- package/dist/{evm → cjs/evm}/index.js +8 -8
- package/dist/{evm → cjs/evm}/types.js +5 -5
- package/dist/{evm → cjs/evm}/utils.js +2 -2
- package/dist/{solana → cjs/solana}/StreamClient.js +73 -66
- package/dist/cjs/solana/constants.js +60 -0
- package/dist/cjs/solana/index.js +39 -0
- package/dist/{solana → cjs/solana}/instructions.js +20 -12
- package/dist/{solana → cjs/solana}/layout.js +8 -2
- package/dist/{solana → cjs/solana}/types.js +5 -5
- package/dist/{solana → cjs/solana}/utils.js +6 -6
- package/dist/{sui → cjs/sui}/StreamClient.js +25 -25
- package/dist/cjs/sui/constants.js +43 -0
- package/dist/{sui → cjs/sui}/index.js +5 -5
- package/dist/{sui → cjs/sui}/types.js +5 -5
- package/dist/{sui → cjs/sui}/utils.js +3 -3
- package/dist/esm/__tests__/aptos/streamClient.spec.js +106 -0
- package/dist/esm/__tests__/common/GenericStreamClient.spec.js +40 -0
- package/dist/{aptos → esm/aptos}/StreamClient.d.ts +3 -3
- package/dist/esm/aptos/StreamClient.js +226 -0
- package/dist/{aptos → esm/aptos}/constants.d.ts +1 -1
- package/dist/esm/aptos/constants.js +24 -0
- package/dist/{aptos → esm/aptos}/index.d.ts +1 -1
- package/dist/{sui/index.d.ts → esm/aptos/index.js} +1 -1
- package/dist/{aptos → esm/aptos}/types.d.ts +1 -1
- package/dist/esm/aptos/types.js +105 -0
- package/dist/esm/aptos/utils.js +30 -0
- package/dist/esm/aptos/wallet.js +33 -0
- package/dist/{common → esm/common}/BaseStreamClient.d.ts +1 -1
- package/dist/esm/common/BaseStreamClient.js +19 -0
- package/dist/{common → esm/common}/GenericStreamClient.d.ts +2 -2
- package/dist/esm/common/GenericStreamClient.js +101 -0
- package/dist/esm/common/constants.js +3 -0
- package/dist/{common → esm/common}/contractUtils.d.ts +1 -1
- package/dist/esm/common/contractUtils.js +42 -0
- package/dist/esm/common/types.js +106 -0
- package/dist/{common → esm/common}/utils.d.ts +0 -1
- package/dist/esm/common/utils.js +59 -0
- package/dist/{evm → esm/evm}/StreamClient.d.ts +2 -2
- package/dist/esm/evm/StreamClient.js +237 -0
- package/dist/esm/evm/abi.js +1255 -0
- package/dist/{evm → esm/evm}/constants.d.ts +1 -1
- package/dist/esm/evm/constants.js +35 -0
- package/dist/esm/evm/ercAbi.js +222 -0
- package/dist/esm/evm/index.d.ts +5 -0
- package/dist/esm/evm/index.js +5 -0
- package/dist/{evm → esm/evm}/types.d.ts +1 -1
- package/dist/esm/evm/types.js +102 -0
- package/dist/esm/evm/utils.js +8 -0
- package/dist/esm/index.js +9 -0
- package/dist/{solana → esm/solana}/StreamClient.d.ts +6 -6
- package/dist/esm/solana/StreamClient.js +695 -0
- package/dist/{solana → esm/solana}/constants.d.ts +2 -0
- package/dist/esm/solana/constants.js +56 -0
- package/dist/esm/solana/index.d.ts +6 -0
- package/dist/esm/solana/index.js +6 -0
- package/dist/esm/solana/instructionTypes.js +1 -0
- package/dist/{solana → esm/solana}/instructions.d.ts +5 -1
- package/dist/esm/solana/instructions.js +256 -0
- package/dist/{solana → esm/solana}/layout.d.ts +2 -1
- package/dist/esm/solana/layout.js +155 -0
- package/dist/esm/solana/timelockIDL.js +420 -0
- package/dist/{solana → esm/solana}/types.d.ts +2 -1
- package/dist/esm/solana/types.js +101 -0
- package/dist/{solana → esm/solana}/utils.d.ts +2 -1
- package/dist/esm/solana/utils.js +117 -0
- package/dist/{sui → esm/sui}/StreamClient.d.ts +3 -3
- package/dist/esm/sui/StreamClient.js +403 -0
- package/dist/{sui → esm/sui}/constants.d.ts +1 -1
- package/dist/esm/sui/constants.js +39 -0
- package/dist/esm/sui/index.d.ts +4 -0
- package/dist/esm/sui/index.js +4 -0
- package/dist/{sui → esm/sui}/types.d.ts +1 -1
- package/dist/esm/sui/types.js +104 -0
- package/dist/{sui → esm/sui}/utils.d.ts +1 -1
- package/dist/esm/sui/utils.js +23 -0
- package/dist/{sui → esm/sui}/wallet.d.ts +1 -1
- package/dist/esm/sui/wallet.js +38 -0
- package/package.json +36 -33
- package/dist/__tests__/common/GenericStreamClient.spec.js +0 -44
- package/dist/aptos/constants.js +0 -28
- package/dist/evm/constants.js +0 -39
- package/dist/evm/index.d.ts +0 -5
- package/dist/solana/constants.js +0 -59
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/sui/constants.js +0 -43
- /package/dist/{aptos → cjs/aptos}/wallet.js +0 -0
- /package/dist/{common → cjs/common}/BaseStreamClient.js +0 -0
- /package/dist/{common → cjs/common}/constants.js +0 -0
- /package/dist/{common → cjs/common}/types.js +0 -0
- /package/dist/{evm → cjs/evm}/abi.js +0 -0
- /package/dist/{evm → cjs/evm}/ercAbi.js +0 -0
- /package/dist/{index.js → cjs/index.js} +0 -0
- /package/dist/{solana → cjs/solana}/instructionTypes.js +0 -0
- /package/dist/{solana → cjs/solana}/timelockIDL.js +0 -0
- /package/dist/{sui → cjs/sui}/wallet.js +0 -0
- /package/dist/{__tests__ → esm/__tests__}/aptos/streamClient.spec.d.ts +0 -0
- /package/dist/{__tests__ → esm/__tests__}/common/GenericStreamClient.spec.d.ts +0 -0
- /package/dist/{aptos → esm/aptos}/utils.d.ts +0 -0
- /package/dist/{aptos → esm/aptos}/wallet.d.ts +0 -0
- /package/dist/{common → esm/common}/constants.d.ts +0 -0
- /package/dist/{common → esm/common}/types.d.ts +0 -0
- /package/dist/{evm → esm/evm}/abi.d.ts +0 -0
- /package/dist/{evm → esm/evm}/ercAbi.d.ts +0 -0
- /package/dist/{evm → esm/evm}/utils.d.ts +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{solana → esm/solana}/instructionTypes.d.ts +0 -0
- /package/dist/{solana → esm/solana}/timelockIDL.d.ts +0 -0
|
@@ -26,8 +26,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.updateStreamInstruction = exports.withdrawStreamInstruction = exports.createUncheckedStreamInstruction = exports.createStreamInstruction = void 0;
|
|
27
27
|
var buffer_1 = require("buffer");
|
|
28
28
|
var web3_js_1 = require("@solana/web3.js");
|
|
29
|
-
var
|
|
30
|
-
var Layout = __importStar(require("./layout"));
|
|
29
|
+
var node_crypto_1 = require("node:crypto");
|
|
30
|
+
var Layout = __importStar(require("./layout.js"));
|
|
31
|
+
var hasher = function () { return (0, node_crypto_1.createHash)("sha256"); };
|
|
32
|
+
var sha256 = {
|
|
33
|
+
digest: function (data) { return new Uint8Array(hasher().update(data).digest()); },
|
|
34
|
+
};
|
|
31
35
|
var createStreamInstruction = function (data, programId, accounts) {
|
|
32
36
|
var keys = [
|
|
33
37
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
|
@@ -77,12 +81,16 @@ var createStreamInstruction = function (data, programId, accounts) {
|
|
|
77
81
|
transferable_by_sender: Number(data.transferableBySender),
|
|
78
82
|
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
79
83
|
can_topup: Number(data.canTopup),
|
|
84
|
+
_pausable_discriminator: 1,
|
|
85
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
86
|
+
_can_update_rate_discriminator: 1,
|
|
87
|
+
pausable: Number(data.canPause),
|
|
80
88
|
stream_name: streamNameBuffer,
|
|
81
89
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
82
90
|
};
|
|
83
91
|
var encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
|
|
84
92
|
bufferData = bufferData.slice(0, encodeLength);
|
|
85
|
-
bufferData = buffer_1.Buffer.concat([buffer_1.Buffer.from(
|
|
93
|
+
bufferData = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:create")).slice(0, 8), bufferData, buffer_1.Buffer.alloc(10)]);
|
|
86
94
|
return new web3_js_1.TransactionInstruction({
|
|
87
95
|
keys: keys,
|
|
88
96
|
programId: programId,
|
|
@@ -131,14 +139,14 @@ var createUncheckedStreamInstruction = function (data, programId, accounts) {
|
|
|
131
139
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
|
|
132
140
|
recipient: data.recipient.toBuffer(),
|
|
133
141
|
partner: data.partner.toBuffer(),
|
|
134
|
-
pausable:
|
|
135
|
-
can_update_rate:
|
|
142
|
+
pausable: Number(data.canPause),
|
|
143
|
+
can_update_rate: Number(data.canUpdateRate),
|
|
136
144
|
};
|
|
137
145
|
var encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
138
146
|
bufferData = bufferData.slice(0, encodeLength);
|
|
139
147
|
var digest = accounts.payer
|
|
140
|
-
?
|
|
141
|
-
:
|
|
148
|
+
? sha256.digest("global:create_unchecked_with_payer")
|
|
149
|
+
: sha256.digest("global:create_unchecked");
|
|
142
150
|
bufferData = buffer_1.Buffer.concat([buffer_1.Buffer.from(digest).slice(0, 8), bufferData, buffer_1.Buffer.alloc(10)]);
|
|
143
151
|
return new web3_js_1.TransactionInstruction({
|
|
144
152
|
keys: keys,
|
|
@@ -170,7 +178,7 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
|
|
|
170
178
|
var decodedData = { amount: amount.toArrayLike(buffer_1.Buffer, "le", 8) };
|
|
171
179
|
var encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
|
|
172
180
|
data = data.slice(0, encodeLength);
|
|
173
|
-
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(
|
|
181
|
+
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:withdraw")).slice(0, 8), data, buffer_1.Buffer.alloc(10)]);
|
|
174
182
|
return new web3_js_1.TransactionInstruction({
|
|
175
183
|
keys: keys,
|
|
176
184
|
programId: programId,
|
|
@@ -194,7 +202,7 @@ var updateStreamInstruction = function (params, programId, _a) {
|
|
|
194
202
|
};
|
|
195
203
|
var encodeLength = Layout.encodeUpdateStream(decodedData, data);
|
|
196
204
|
data = data.slice(0, encodeLength);
|
|
197
|
-
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(
|
|
205
|
+
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:update")).slice(0, 8), data, buffer_1.Buffer.alloc(20)]);
|
|
198
206
|
return new web3_js_1.TransactionInstruction({
|
|
199
207
|
keys: keys,
|
|
200
208
|
programId: programId,
|
|
@@ -223,7 +231,7 @@ var cancelStreamInstruction = function (programId, _a) {
|
|
|
223
231
|
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
224
232
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
225
233
|
];
|
|
226
|
-
var data = buffer_1.Buffer.concat([buffer_1.Buffer.from(
|
|
234
|
+
var data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:cancel")).slice(0, 8), buffer_1.Buffer.alloc(10)]);
|
|
227
235
|
return new web3_js_1.TransactionInstruction({
|
|
228
236
|
keys: keys,
|
|
229
237
|
programId: programId,
|
|
@@ -244,7 +252,7 @@ var transferStreamInstruction = function (programId, _a) {
|
|
|
244
252
|
{ pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
|
|
245
253
|
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
246
254
|
];
|
|
247
|
-
var data = buffer_1.Buffer.concat([buffer_1.Buffer.from(
|
|
255
|
+
var data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:transfer_recipient")).slice(0, 8), buffer_1.Buffer.alloc(10)]);
|
|
248
256
|
return new web3_js_1.TransactionInstruction({
|
|
249
257
|
keys: keys,
|
|
250
258
|
programId: programId,
|
|
@@ -276,7 +284,7 @@ var topupStreamInstruction = function (amount, programId, _a) {
|
|
|
276
284
|
var decodedData = { amount: amount.toArrayLike(buffer_1.Buffer, "le", 8) };
|
|
277
285
|
var encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
|
|
278
286
|
data = data.slice(0, encodeLength);
|
|
279
|
-
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(
|
|
287
|
+
data = buffer_1.Buffer.concat([buffer_1.Buffer.from(sha256.digest("global:topup")).slice(0, 8), data, buffer_1.Buffer.alloc(10)]);
|
|
280
288
|
return new web3_js_1.TransactionInstruction({
|
|
281
289
|
keys: keys,
|
|
282
290
|
programId: programId,
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.topupStreamLayout = exports.encodeUpdateStream = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.partnerLayout = exports.streamLayout = void 0;
|
|
27
27
|
var BufferLayout = __importStar(require("@solana/buffer-layout"));
|
|
28
|
-
var
|
|
28
|
+
var constants_js_1 = require("./constants.js");
|
|
29
29
|
/**
|
|
30
30
|
* Stream layout
|
|
31
31
|
*/
|
|
@@ -72,7 +72,7 @@ exports.streamLayout = BufferLayout.struct([
|
|
|
72
72
|
BufferLayout.u8("pausable"),
|
|
73
73
|
BufferLayout.u8("can_update_rate"),
|
|
74
74
|
BufferLayout.blob(4, "create_stream_params_padding_length"),
|
|
75
|
-
BufferLayout.seq(BufferLayout.u8(),
|
|
75
|
+
BufferLayout.seq(BufferLayout.u8(), constants_js_1.CREATE_PARAMS_PADDING, "create_params_padding"),
|
|
76
76
|
BufferLayout.u8("closed"),
|
|
77
77
|
BufferLayout.blob(8, "current_pause_start"),
|
|
78
78
|
BufferLayout.blob(8, "pause_cumulative"),
|
|
@@ -102,6 +102,12 @@ exports.createStreamLayout = BufferLayout.struct([
|
|
|
102
102
|
BufferLayout.u8("can_topup"),
|
|
103
103
|
BufferLayout.blob(64, "stream_name"),
|
|
104
104
|
BufferLayout.blob(8, "withdraw_frequency"),
|
|
105
|
+
// discriminator for optional field
|
|
106
|
+
BufferLayout.u8("_pausable_discriminator"),
|
|
107
|
+
BufferLayout.u8("pausable"),
|
|
108
|
+
// discriminator for optional field
|
|
109
|
+
BufferLayout.u8("_can_update_rate_discriminator"),
|
|
110
|
+
BufferLayout.u8("can_update_rate"),
|
|
105
111
|
]);
|
|
106
112
|
/**
|
|
107
113
|
* Create unchecked stream instruction layout
|
|
@@ -12,8 +12,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Contract = void 0;
|
|
15
|
-
var
|
|
16
|
-
var
|
|
15
|
+
var contractUtils_js_1 = require("../common/contractUtils.js");
|
|
16
|
+
var utils_js_1 = require("../common/utils.js");
|
|
17
17
|
var Contract = /** @class */ (function () {
|
|
18
18
|
function Contract(stream) {
|
|
19
19
|
var _a;
|
|
@@ -59,13 +59,13 @@ var Contract = /** @class */ (function () {
|
|
|
59
59
|
this.pauseCumulative = stream.pauseCumulative;
|
|
60
60
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
61
61
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
62
|
-
this.type = (0,
|
|
62
|
+
this.type = (0, contractUtils_js_1.buildStreamType)(this);
|
|
63
63
|
}
|
|
64
64
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
65
|
-
return (0,
|
|
65
|
+
return (0, contractUtils_js_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
66
66
|
};
|
|
67
67
|
Contract.prototype.remaining = function (decimals) {
|
|
68
|
-
return (0,
|
|
68
|
+
return (0, utils_js_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
69
69
|
};
|
|
70
70
|
return Contract;
|
|
71
71
|
}());
|
|
@@ -65,12 +65,12 @@ exports.extractSolanaErrorCode = exports.sendAndConfirmStreamRawTransaction = ex
|
|
|
65
65
|
var web3_js_1 = require("@solana/web3.js");
|
|
66
66
|
var solana_1 = require("@streamflow/common/solana");
|
|
67
67
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
68
|
-
var
|
|
69
|
-
var
|
|
68
|
+
var layout_js_1 = require("./layout.js");
|
|
69
|
+
var constants_js_1 = require("./constants.js");
|
|
70
70
|
var decoder = new TextDecoder("utf-8");
|
|
71
71
|
var LE = "le"; //little endian
|
|
72
72
|
var decodeStream = function (buf) {
|
|
73
|
-
var raw =
|
|
73
|
+
var raw = layout_js_1.streamLayout.decode(buf);
|
|
74
74
|
return {
|
|
75
75
|
magic: new bn_js_1.default(raw.magic, LE),
|
|
76
76
|
version: new bn_js_1.default(raw.version, LE),
|
|
@@ -183,12 +183,12 @@ function sendAndConfirmStreamRawTransaction(connection, batchItem, confirmationP
|
|
|
183
183
|
exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
|
|
184
184
|
function extractSolanaErrorCode(errorText, logs) {
|
|
185
185
|
var e_1, _a;
|
|
186
|
-
var match =
|
|
186
|
+
var match = constants_js_1.SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
187
187
|
if (!match && logs) {
|
|
188
188
|
try {
|
|
189
189
|
for (var logs_1 = __values(logs), logs_1_1 = logs_1.next(); !logs_1_1.done; logs_1_1 = logs_1.next()) {
|
|
190
190
|
var logLine = logs_1_1.value;
|
|
191
|
-
match =
|
|
191
|
+
match = constants_js_1.SOLANA_ERROR_MATCH_REGEX.exec(logLine);
|
|
192
192
|
if (match !== null) {
|
|
193
193
|
break;
|
|
194
194
|
}
|
|
@@ -206,6 +206,6 @@ function extractSolanaErrorCode(errorText, logs) {
|
|
|
206
206
|
return null;
|
|
207
207
|
}
|
|
208
208
|
var errorCode = Number(match[1]);
|
|
209
|
-
return
|
|
209
|
+
return constants_js_1.SOLANA_ERROR_MAP[errorCode] || null;
|
|
210
210
|
}
|
|
211
211
|
exports.extractSolanaErrorCode = extractSolanaErrorCode;
|
|
@@ -90,22 +90,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
90
90
|
var client_1 = require("@mysten/sui.js/client");
|
|
91
91
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
92
92
|
var utils_1 = require("@mysten/sui.js/utils");
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
var
|
|
100
|
-
var
|
|
93
|
+
var BaseStreamClient_js_1 = require("../common/BaseStreamClient.js");
|
|
94
|
+
var types_js_1 = require("../common/types.js");
|
|
95
|
+
var constants_js_1 = require("./constants.js");
|
|
96
|
+
var types_js_2 = require("./types.js");
|
|
97
|
+
var utils_js_1 = require("./utils.js");
|
|
98
|
+
var wallet_js_1 = require("./wallet.js");
|
|
99
|
+
var utils_js_2 = require("../common/utils.js");
|
|
100
|
+
var constants_js_2 = require("../common/constants.js");
|
|
101
101
|
var SuiStreamClient = /** @class */ (function (_super) {
|
|
102
102
|
__extends(SuiStreamClient, _super);
|
|
103
103
|
function SuiStreamClient(clusterUrl, cluster, ids) {
|
|
104
|
-
if (cluster === void 0) { cluster =
|
|
104
|
+
if (cluster === void 0) { cluster = types_js_1.ICluster.Mainnet; }
|
|
105
105
|
var _this = _super.call(this) || this;
|
|
106
|
-
_this.programId = (ids === null || ids === void 0 ? void 0 : ids.program) ? ids.program :
|
|
107
|
-
_this.configId = (ids === null || ids === void 0 ? void 0 : ids.config) ? ids.config :
|
|
108
|
-
_this.feeTableId = (ids === null || ids === void 0 ? void 0 : ids.feeTable) ? ids.feeTable :
|
|
106
|
+
_this.programId = (ids === null || ids === void 0 ? void 0 : ids.program) ? ids.program : constants_js_1.SUI_PROGRAM_IDS[cluster];
|
|
107
|
+
_this.configId = (ids === null || ids === void 0 ? void 0 : ids.config) ? ids.config : constants_js_1.SUI_CONFIG_IDS[cluster];
|
|
108
|
+
_this.feeTableId = (ids === null || ids === void 0 ? void 0 : ids.feeTable) ? ids.feeTable : constants_js_1.SUI_FEE_TABLE_IDS[cluster];
|
|
109
109
|
_this.client = new client_1.SuiClient({ url: clusterUrl });
|
|
110
110
|
return _this;
|
|
111
111
|
}
|
|
@@ -120,7 +120,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
120
120
|
return __generator(this, function (_e) {
|
|
121
121
|
switch (_e.label) {
|
|
122
122
|
case 0:
|
|
123
|
-
wallet = new
|
|
123
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
124
124
|
return [4 /*yield*/, this.getTotalFee({
|
|
125
125
|
address: (_b = streamData.partner) !== null && _b !== void 0 ? _b : wallet.address,
|
|
126
126
|
})];
|
|
@@ -156,7 +156,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
156
156
|
return __generator(this, function (_f) {
|
|
157
157
|
switch (_f.label) {
|
|
158
158
|
case 0:
|
|
159
|
-
wallet = new
|
|
159
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
160
160
|
return [4 /*yield*/, this.getTotalFee({
|
|
161
161
|
address: (_b = multipleStreamData.partner) !== null && _b !== void 0 ? _b : wallet.address,
|
|
162
162
|
})];
|
|
@@ -198,7 +198,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
198
198
|
return [3 /*break*/, 6];
|
|
199
199
|
case 5:
|
|
200
200
|
e_1 = _f.sent();
|
|
201
|
-
errorInfo_1 = (0,
|
|
201
|
+
errorInfo_1 = (0, utils_js_1.extractSuiErrorInfo)((_c = e_1.toString()) !== null && _c !== void 0 ? _c : "Unknown error!");
|
|
202
202
|
multipleStreamData.recipients.forEach(function (recipient, index) {
|
|
203
203
|
var _a;
|
|
204
204
|
if (errorInfo_1.index === undefined ||
|
|
@@ -227,14 +227,14 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
227
227
|
* Attempts withdrawing from the specified stream.
|
|
228
228
|
*/
|
|
229
229
|
SuiStreamClient.prototype.withdraw = function (_a, _b) {
|
|
230
|
-
var id = _a.id, _c = _a.amount, amount = _c === void 0 ?
|
|
230
|
+
var id = _a.id, _c = _a.amount, amount = _c === void 0 ? constants_js_2.WITHDRAW_AVAILABLE_AMOUNT : _c;
|
|
231
231
|
var senderWallet = _b.senderWallet, tokenId = _b.tokenId;
|
|
232
232
|
return __awaiter(this, void 0, void 0, function () {
|
|
233
233
|
var wallet, txb, digest;
|
|
234
234
|
return __generator(this, function (_d) {
|
|
235
235
|
switch (_d.label) {
|
|
236
236
|
case 0:
|
|
237
|
-
wallet = new
|
|
237
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
238
238
|
txb = new transactions_1.TransactionBlock();
|
|
239
239
|
txb.moveCall({
|
|
240
240
|
target: "".concat(this.programId, "::protocol::withdraw"),
|
|
@@ -269,7 +269,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
269
269
|
return __generator(this, function (_b) {
|
|
270
270
|
switch (_b.label) {
|
|
271
271
|
case 0:
|
|
272
|
-
wallet = new
|
|
272
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
273
273
|
txb = new transactions_1.TransactionBlock();
|
|
274
274
|
txb.moveCall({
|
|
275
275
|
target: "".concat(this.programId, "::protocol::cancel"),
|
|
@@ -299,7 +299,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
299
299
|
return __generator(this, function (_b) {
|
|
300
300
|
switch (_b.label) {
|
|
301
301
|
case 0:
|
|
302
|
-
wallet = new
|
|
302
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
303
303
|
txb = new transactions_1.TransactionBlock();
|
|
304
304
|
txb.moveCall({
|
|
305
305
|
target: "".concat(this.programId, "::protocol::transfer"),
|
|
@@ -329,7 +329,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
329
329
|
return __generator(this, function (_b) {
|
|
330
330
|
switch (_b.label) {
|
|
331
331
|
case 0:
|
|
332
|
-
wallet = new
|
|
332
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
333
333
|
txb = new transactions_1.TransactionBlock();
|
|
334
334
|
return [4 /*yield*/, this.getAllCoins(wallet.address, tokenId)];
|
|
335
335
|
case 1:
|
|
@@ -388,7 +388,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
388
388
|
if (content.dataType !== "moveObject") {
|
|
389
389
|
throw new Error("Not a Move Object!");
|
|
390
390
|
}
|
|
391
|
-
return [2 /*return*/, new
|
|
391
|
+
return [2 /*return*/, new types_js_2.Contract(content.fields, "0x97e9a9fb1392e9785319f5512d0bfde6ecf7757b09c6de41cec89e798dd361f2::strmt::STRMT")];
|
|
392
392
|
}
|
|
393
393
|
});
|
|
394
394
|
});
|
|
@@ -410,7 +410,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
410
410
|
return __generator(this, function (_b) {
|
|
411
411
|
switch (_b.label) {
|
|
412
412
|
case 0:
|
|
413
|
-
wallet = new
|
|
413
|
+
wallet = new wallet_js_1.SuiWalletWrapper(senderWallet, this.client);
|
|
414
414
|
txb = new transactions_1.TransactionBlock();
|
|
415
415
|
txb.moveCall({
|
|
416
416
|
target: "".concat(this.programId, "::protocol::update"),
|
|
@@ -440,7 +440,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
440
440
|
};
|
|
441
441
|
SuiStreamClient.prototype.extractErrorCode = function (err) {
|
|
442
442
|
var _a, _b;
|
|
443
|
-
var errorInfo = (0,
|
|
443
|
+
var errorInfo = (0, utils_js_1.extractSuiErrorInfo)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
|
|
444
444
|
return ((_b = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.parsed) === null || _b === void 0 ? void 0 : _b.name) || null;
|
|
445
445
|
};
|
|
446
446
|
SuiStreamClient.prototype.getFees = function (_a) {
|
|
@@ -629,7 +629,7 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
629
629
|
if (coins.length > 1) {
|
|
630
630
|
txb.mergeCoins(coinObject, coins.slice(1).map(function (item) { return txb.object(item.coinObjectId); }));
|
|
631
631
|
}
|
|
632
|
-
var totalAmount = (0,
|
|
632
|
+
var totalAmount = (0, utils_js_2.calculateTotalAmountToDeposit)(amount, totalFee);
|
|
633
633
|
return txb.splitCoins(coinObject, [txb.pure(totalAmount.toString())])[0];
|
|
634
634
|
};
|
|
635
635
|
/**
|
|
@@ -644,5 +644,5 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
644
644
|
txb.mergeCoins(firstCoinObject, [coinObject]);
|
|
645
645
|
};
|
|
646
646
|
return SuiStreamClient;
|
|
647
|
-
}(
|
|
647
|
+
}(BaseStreamClient_js_1.BaseStreamClient));
|
|
648
648
|
exports.default = SuiStreamClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SUI_MODULE_ERROR_MAP = exports.SUI_ERROR_MATCH_REGEX = exports.SUI_FEE_TABLE_IDS = exports.SUI_CONFIG_IDS = exports.SUI_PROGRAM_IDS = void 0;
|
|
5
|
+
var types_js_1 = require("../common/types.js");
|
|
6
|
+
// TODO: remove Devnet and Local addresses as they are not deployed, they are just a copy Testnet values
|
|
7
|
+
exports.SUI_PROGRAM_IDS = (_a = {},
|
|
8
|
+
_a[types_js_1.ICluster.Mainnet] = "0xe456a3a1d4e58e85b4b7175fabe6dae895b983f1379bb8948d6ec2f137b08a7b",
|
|
9
|
+
_a[types_js_1.ICluster.Devnet] = "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
10
|
+
_a[types_js_1.ICluster.Testnet] = "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
11
|
+
_a[types_js_1.ICluster.Local] = "0x34dacd839e1758ebb70bdcd4e08f18fbfef5e2b96d9aa7ce2b4a71d96ca0df5a",
|
|
12
|
+
_a);
|
|
13
|
+
exports.SUI_CONFIG_IDS = (_b = {},
|
|
14
|
+
_b[types_js_1.ICluster.Mainnet] = "0x6cf6760b64245b8d23ef57c28ddceb6adbd540a23a509fef29b82237da4ab87b",
|
|
15
|
+
_b[types_js_1.ICluster.Devnet] = "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
16
|
+
_b[types_js_1.ICluster.Testnet] = "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
17
|
+
_b[types_js_1.ICluster.Local] = "0xd6c9f5074584f58074ce56e3c5cc436d82258ec3285f186a0d6438a60bacdbf8",
|
|
18
|
+
_b);
|
|
19
|
+
exports.SUI_FEE_TABLE_IDS = (_c = {},
|
|
20
|
+
_c[types_js_1.ICluster.Mainnet] = "0xad9b75399632583fb9fcae6b5bcca34e6542ab3bedb630ecbd3f15cb1cc48dbe",
|
|
21
|
+
_c[types_js_1.ICluster.Devnet] = "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
22
|
+
_c[types_js_1.ICluster.Testnet] = "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
23
|
+
_c[types_js_1.ICluster.Local] = "0x6057b093904c5bdfec1067d2b8a4dc35f65bcab03b3029ad716c4882b0f36078",
|
|
24
|
+
_c);
|
|
25
|
+
exports.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+)/;
|
|
26
|
+
exports.SUI_MODULE_ERROR_MAP = {
|
|
27
|
+
protocol: {
|
|
28
|
+
1: types_js_1.ContractErrorCode.ECONTRACT_NOT_INIT,
|
|
29
|
+
2: types_js_1.ContractErrorCode.EBAD_AMOUNT,
|
|
30
|
+
3: types_js_1.ContractErrorCode.ENO_PERMISSIONS,
|
|
31
|
+
4: types_js_1.ContractErrorCode.EBADINPUT,
|
|
32
|
+
5: types_js_1.ContractErrorCode.ECLOSED,
|
|
33
|
+
6: types_js_1.ContractErrorCode.EBAD_INPUT_AMOUNT_PER_PERIOD,
|
|
34
|
+
8: types_js_1.ContractErrorCode.EBAD_INPUT_UPDATE_RATE,
|
|
35
|
+
9: types_js_1.ContractErrorCode.EBAD_INPUT_CLIFF_AMOUNT,
|
|
36
|
+
10: types_js_1.ContractErrorCode.EBAD_INPUT_PERIOD,
|
|
37
|
+
11: types_js_1.ContractErrorCode.EBAD_INPUT_START,
|
|
38
|
+
13: types_js_1.ContractErrorCode.EBAD_INSUFFICIENT_WITHDRAWAL_FEES,
|
|
39
|
+
14: types_js_1.ContractErrorCode.EBAD_INSUFFICIENT_AMOUNT,
|
|
40
|
+
15: types_js_1.ContractErrorCode.EPAUSED,
|
|
41
|
+
16: types_js_1.ContractErrorCode.ENOTPAUSED,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -30,8 +30,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.constants = exports.SuiStreamClient = void 0;
|
|
33
|
-
var
|
|
34
|
-
Object.defineProperty(exports, "SuiStreamClient", { enumerable: true, get: function () { return __importDefault(
|
|
35
|
-
__exportStar(require("./utils"), exports);
|
|
36
|
-
__exportStar(require("./types"), exports);
|
|
37
|
-
exports.constants = __importStar(require("./constants"));
|
|
33
|
+
var StreamClient_js_1 = require("./StreamClient.js");
|
|
34
|
+
Object.defineProperty(exports, "SuiStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_js_1).default; } });
|
|
35
|
+
__exportStar(require("./utils.js"), exports);
|
|
36
|
+
__exportStar(require("./types.js"), exports);
|
|
37
|
+
exports.constants = __importStar(require("./constants.js"));
|
|
@@ -41,8 +41,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.Contract = void 0;
|
|
43
43
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
44
|
-
var
|
|
45
|
-
var
|
|
44
|
+
var contractUtils_js_1 = require("../common/contractUtils.js");
|
|
45
|
+
var utils_js_1 = require("../common/utils.js");
|
|
46
46
|
var Contract = /** @class */ (function () {
|
|
47
47
|
function Contract(stream, tokenId) {
|
|
48
48
|
var meta = stream.meta.fields;
|
|
@@ -89,13 +89,13 @@ var Contract = /** @class */ (function () {
|
|
|
89
89
|
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative);
|
|
90
90
|
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
91
91
|
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change);
|
|
92
|
-
this.type = (0,
|
|
92
|
+
this.type = (0, contractUtils_js_1.buildStreamType)(this);
|
|
93
93
|
}
|
|
94
94
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
95
|
-
return (0,
|
|
95
|
+
return (0, contractUtils_js_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
96
96
|
};
|
|
97
97
|
Contract.prototype.remaining = function (decimals) {
|
|
98
|
-
return (0,
|
|
98
|
+
return (0, utils_js_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
99
99
|
};
|
|
100
100
|
return Contract;
|
|
101
101
|
}());
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractSuiErrorInfo = void 0;
|
|
4
|
-
var
|
|
4
|
+
var constants_js_1 = require("./constants.js");
|
|
5
5
|
function extractSuiErrorInfo(errorText) {
|
|
6
6
|
var error = { text: errorText };
|
|
7
|
-
var match =
|
|
7
|
+
var match = constants_js_1.SUI_ERROR_MATCH_REGEX.exec(errorText);
|
|
8
8
|
if (!match) {
|
|
9
9
|
return error;
|
|
10
10
|
}
|
|
11
11
|
var moduleName = match[2];
|
|
12
12
|
var errorCode = Number(match[4]);
|
|
13
|
-
var errorName =
|
|
13
|
+
var errorName = constants_js_1.SUI_MODULE_ERROR_MAP[moduleName] ? constants_js_1.SUI_MODULE_ERROR_MAP[moduleName][errorCode] : undefined;
|
|
14
14
|
var index = Number(match[5]);
|
|
15
15
|
if (index) {
|
|
16
16
|
error.index = index;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BN } from "bn.js";
|
|
2
|
+
import { describe, expect, test, beforeEach, vi } from "vitest";
|
|
3
|
+
import AptosStreamClient from "../../aptos/StreamClient.js";
|
|
4
|
+
import { ICluster } from "../../common/types.js";
|
|
5
|
+
describe("AptosStreamClient", () => {
|
|
6
|
+
describe("init", () => {
|
|
7
|
+
test("should successfully create AptosStreamInstance", () => {
|
|
8
|
+
const instance = new AptosStreamClient(ICluster.Devnet);
|
|
9
|
+
expect(instance).toBeInstanceOf(AptosStreamClient);
|
|
10
|
+
});
|
|
11
|
+
test("should correctly set passed params", () => {
|
|
12
|
+
const pid = "PID";
|
|
13
|
+
const gas = "30";
|
|
14
|
+
const instance = new AptosStreamClient("https://cluster", ICluster.Devnet, gas, pid);
|
|
15
|
+
expect(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
|
|
16
|
+
expect(instance.getProgramId()).toBe(pid);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe("create", () => {
|
|
20
|
+
const pid = "PID";
|
|
21
|
+
const gas = "30";
|
|
22
|
+
let instance = new AptosStreamClient("https://cluster", ICluster.Devnet, gas, pid);
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
instance = new AptosStreamClient("https://cluster", ICluster.Devnet, gas, pid);
|
|
25
|
+
});
|
|
26
|
+
test("should create a stream with passed parameters", async () => {
|
|
27
|
+
// Arrange
|
|
28
|
+
const mockSigner = vi.fn();
|
|
29
|
+
const mockWallet = {
|
|
30
|
+
signAndSubmitTransaction: mockSigner,
|
|
31
|
+
account: { address: "" },
|
|
32
|
+
};
|
|
33
|
+
const mockRecipient = {
|
|
34
|
+
recipient: "0xtest",
|
|
35
|
+
amount: new BN(1000),
|
|
36
|
+
name: "test name",
|
|
37
|
+
cliffAmount: new BN(1),
|
|
38
|
+
amountPerPeriod: new BN(1),
|
|
39
|
+
};
|
|
40
|
+
const mockData = {
|
|
41
|
+
period: 100,
|
|
42
|
+
start: 10,
|
|
43
|
+
cliff: 12,
|
|
44
|
+
cancelableBySender: true,
|
|
45
|
+
cancelableByRecipient: false,
|
|
46
|
+
transferableBySender: false,
|
|
47
|
+
transferableByRecipient: true,
|
|
48
|
+
canTopup: true,
|
|
49
|
+
automaticWithdrawal: false,
|
|
50
|
+
withdrawalFrequency: 10,
|
|
51
|
+
tokenId: "0xtest::token::Token",
|
|
52
|
+
canPause: false,
|
|
53
|
+
canUpdateRate: false,
|
|
54
|
+
};
|
|
55
|
+
const mockReturn = "hash";
|
|
56
|
+
mockSigner.mockResolvedValue({ hash: mockReturn });
|
|
57
|
+
// Act
|
|
58
|
+
const result = await instance.create({
|
|
59
|
+
...mockData,
|
|
60
|
+
...mockRecipient,
|
|
61
|
+
}, { senderWallet: mockWallet });
|
|
62
|
+
// Assert
|
|
63
|
+
expect(mockSigner).toHaveBeenCalledTimes(1);
|
|
64
|
+
const callParam = mockSigner.mock.calls[0][0];
|
|
65
|
+
const args = callParam.arguments;
|
|
66
|
+
delete callParam.arguments;
|
|
67
|
+
args.shift();
|
|
68
|
+
expect(args).toEqual([
|
|
69
|
+
mockRecipient.amount.toString(),
|
|
70
|
+
100,
|
|
71
|
+
mockRecipient.amountPerPeriod.toString(),
|
|
72
|
+
10,
|
|
73
|
+
mockRecipient.cliffAmount.toString(),
|
|
74
|
+
true,
|
|
75
|
+
false,
|
|
76
|
+
false,
|
|
77
|
+
true,
|
|
78
|
+
true,
|
|
79
|
+
false,
|
|
80
|
+
false,
|
|
81
|
+
false,
|
|
82
|
+
10,
|
|
83
|
+
"test name",
|
|
84
|
+
"0xtest",
|
|
85
|
+
]);
|
|
86
|
+
expect(callParam).toEqual({
|
|
87
|
+
function: "PID::protocol::create",
|
|
88
|
+
type: "create",
|
|
89
|
+
type_arguments: ["0xtest::token::Token"],
|
|
90
|
+
});
|
|
91
|
+
expect(result.txId).toEqual(mockReturn);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
// describe("createMultiple", () => {
|
|
95
|
+
// });
|
|
96
|
+
// describe("withdraw", () => {
|
|
97
|
+
// });
|
|
98
|
+
// describe("cancel", () => {
|
|
99
|
+
// });
|
|
100
|
+
// describe("transfer", () => {
|
|
101
|
+
// });
|
|
102
|
+
// describe("topup", () => {
|
|
103
|
+
// });
|
|
104
|
+
// describe("getOne", () => {
|
|
105
|
+
// });
|
|
106
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Wallet } from "ethers";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { StreamflowAptos, StreamflowEVM, StreamflowSolana, StreamflowSui } from "../../index.js";
|
|
4
|
+
import { default as GenericStreamClient, } from "../../common/GenericStreamClient.js";
|
|
5
|
+
import { IChain, ICluster } from "../../common/types.js";
|
|
6
|
+
describe("GenericStreamClient", () => {
|
|
7
|
+
describe.each([
|
|
8
|
+
{
|
|
9
|
+
chain: IChain.Aptos,
|
|
10
|
+
cluster: ICluster.Devnet,
|
|
11
|
+
clusterUrl: "https://cluster",
|
|
12
|
+
expected: StreamflowAptos.AptosStreamClient,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
chain: IChain.Solana,
|
|
16
|
+
cluster: ICluster.Devnet,
|
|
17
|
+
clusterUrl: "https://cluster",
|
|
18
|
+
expected: StreamflowSolana.SolanaStreamClient,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
chain: IChain.Ethereum,
|
|
22
|
+
cluster: ICluster.Devnet,
|
|
23
|
+
clusterUrl: "https://cluster",
|
|
24
|
+
signer: Wallet.createRandom(),
|
|
25
|
+
expected: StreamflowEVM.EvmStreamClient,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
chain: IChain.Sui,
|
|
29
|
+
cluster: ICluster.Devnet,
|
|
30
|
+
clusterUrl: "https://cluster",
|
|
31
|
+
expected: StreamflowSui.SuiStreamClient,
|
|
32
|
+
},
|
|
33
|
+
])(".init($chain)", (config) => {
|
|
34
|
+
test("should successfully create GenericStreamClient instance", () => {
|
|
35
|
+
const instance = new GenericStreamClient(config);
|
|
36
|
+
expect(instance).toBeInstanceOf(GenericStreamClient);
|
|
37
|
+
expect(instance.nativeStreamClient).toBeInstanceOf(config.expected);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
|
-
import { Contract, ICreateStreamAptosExt, ITransactionAptosExt } from "./types";
|
|
1
|
+
import { BaseStreamClient } from "../common/BaseStreamClient.js";
|
|
2
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types.js";
|
|
3
|
+
import { Contract, ICreateStreamAptosExt, ITransactionAptosExt } from "./types.js";
|
|
4
4
|
export default class AptosStreamClient extends BaseStreamClient {
|
|
5
5
|
private programId;
|
|
6
6
|
private maxGas;
|