@streamflow/stream 3.0.16-dev → 4.0.0-Alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StreamClient.d.ts +3 -4
- package/dist/StreamClient.js +35 -21
- package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
- package/dist/__tests__/aptos/streamClient.spec.js +160 -0
- package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +0 -1
- package/dist/aptos/StreamClient.d.ts +19 -0
- package/dist/aptos/StreamClient.js +296 -0
- package/dist/aptos/constants.d.ts +2 -0
- package/dist/aptos/constants.js +12 -0
- package/dist/aptos/index.d.ts +2 -0
- package/dist/aptos/index.js +23 -0
- package/dist/aptos/types.d.ts +10 -0
- package/dist/aptos/types.js +2 -0
- package/dist/common/types.d.ts +70 -0
- package/dist/common/types.js +29 -0
- package/dist/common/utils.d.ts +15 -0
- package/dist/common/utils.js +31 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +17 -13
- package/dist/instructionTypes.d.ts +81 -0
- package/dist/instructionTypes.js +2 -0
- package/dist/instructions.d.ts +0 -2
- package/dist/instructions.js +18 -29
- package/dist/layout.d.ts +7 -7
- package/dist/layout.js +78 -75
- package/dist/solana/StreamClient.d.ts +145 -0
- package/dist/solana/StreamClient.js +952 -0
- package/dist/solana/constants.d.ts +18 -0
- package/dist/solana/constants.js +23 -0
- package/dist/solana/index.d.ts +5 -0
- package/dist/solana/index.js +27 -0
- package/dist/solana/instructionTypes.d.ts +81 -0
- package/dist/solana/instructionTypes.js +2 -0
- package/dist/solana/instructions.d.ts +131 -0
- package/dist/solana/instructions.js +375 -0
- package/dist/solana/layout.d.ts +22 -0
- package/dist/solana/layout.js +96 -0
- package/dist/solana/timelockIDL.d.ts +22 -0
- package/dist/solana/timelockIDL.js +422 -0
- package/dist/solana/types.d.ts +321 -0
- package/dist/solana/types.js +74 -0
- package/dist/solana/utils.d.ts +42 -0
- package/dist/solana/utils.js +269 -0
- package/dist/types.d.ts +12 -13
- package/package.json +23 -10
package/dist/StreamClient.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
1
|
+
import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
2
|
import { Stream as StreamData, CreateParams, CreateMultiParams, WithdrawParams, TopupParams, CancelParams, TransferParams, ClusterExtended, GetAllParams, CreateResponse, CreateMultiResponse, TxResponse } from "./types";
|
|
4
3
|
export default class StreamClient {
|
|
5
4
|
private connection;
|
|
@@ -10,13 +9,13 @@ export default class StreamClient {
|
|
|
10
9
|
* Create Stream instance
|
|
11
10
|
*/
|
|
12
11
|
constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig, programId?: string);
|
|
13
|
-
getConnection():
|
|
12
|
+
getConnection(): Connection;
|
|
14
13
|
getProgramId(): string;
|
|
15
14
|
/**
|
|
16
15
|
* Creates a new stream/vesting contract.
|
|
17
16
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
18
17
|
* @param {CreateParams} data
|
|
19
|
-
* @param {
|
|
18
|
+
* @param {WalletAdapter | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
20
19
|
* @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
|
|
21
20
|
* @param {string} data.mint - SPL Token mint.
|
|
22
21
|
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
package/dist/StreamClient.js
CHANGED
|
@@ -89,14 +89,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
89
89
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
90
90
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
91
91
|
var buffer_1 = require("buffer");
|
|
92
|
-
var
|
|
92
|
+
var bs58_1 = __importDefault(require("bs58"));
|
|
93
93
|
var spl_token_1 = require("@solana/spl-token");
|
|
94
94
|
var web3_js_1 = require("@solana/web3.js");
|
|
95
95
|
var types_1 = require("./types");
|
|
96
96
|
var utils_1 = require("./utils");
|
|
97
97
|
var constants_1 = require("./constants");
|
|
98
98
|
var instructions_1 = require("./instructions");
|
|
99
|
-
var bs58_1 = require("@project-serum/anchor/dist/cjs/utils/bytes/bs58");
|
|
100
99
|
var METADATA_ACC_SIZE = 1104;
|
|
101
100
|
var StreamClient = /** @class */ (function () {
|
|
102
101
|
/**
|
|
@@ -124,7 +123,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
124
123
|
* Creates a new stream/vesting contract.
|
|
125
124
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
126
125
|
* @param {CreateParams} data
|
|
127
|
-
* @param {
|
|
126
|
+
* @param {WalletAdapter | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
|
|
128
127
|
* @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
|
|
129
128
|
* @param {string} data.mint - SPL Token mint.
|
|
130
129
|
* @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
|
|
@@ -152,6 +151,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
152
151
|
return __generator(this, function (_j) {
|
|
153
152
|
switch (_j.label) {
|
|
154
153
|
case 0:
|
|
154
|
+
if (!sender.publicKey) {
|
|
155
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
156
|
+
}
|
|
155
157
|
ixs = [];
|
|
156
158
|
mintPublicKey = isNative ? new web3_js_1.PublicKey(mint) : spl_token_1.NATIVE_MINT;
|
|
157
159
|
recipientPublicKey = new web3_js_1.PublicKey(recipient);
|
|
@@ -278,6 +280,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
278
280
|
return __generator(this, function (_j) {
|
|
279
281
|
switch (_j.label) {
|
|
280
282
|
case 0:
|
|
283
|
+
if (!sender.publicKey) {
|
|
284
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
285
|
+
}
|
|
281
286
|
mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
282
287
|
recipientPublicKey = new web3_js_1.PublicKey(recipient);
|
|
283
288
|
metadata = web3_js_1.Keypair.generate();
|
|
@@ -393,6 +398,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
393
398
|
switch (_d.label) {
|
|
394
399
|
case 0:
|
|
395
400
|
sender = data.sender, recipientsData = data.recipientsData;
|
|
401
|
+
if (!sender.publicKey) {
|
|
402
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
403
|
+
}
|
|
396
404
|
metadatas = [];
|
|
397
405
|
metadataToRecipient = {};
|
|
398
406
|
errors = [];
|
|
@@ -493,6 +501,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
493
501
|
return __generator(this, function (_c) {
|
|
494
502
|
switch (_c.label) {
|
|
495
503
|
case 0:
|
|
504
|
+
if (!invoker.publicKey) {
|
|
505
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
506
|
+
}
|
|
496
507
|
ixs = [];
|
|
497
508
|
streamPublicKey = new web3_js_1.PublicKey(id);
|
|
498
509
|
return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
|
|
@@ -554,6 +565,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
554
565
|
return __generator(this, function (_c) {
|
|
555
566
|
switch (_c.label) {
|
|
556
567
|
case 0:
|
|
568
|
+
if (!invoker.publicKey) {
|
|
569
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
570
|
+
}
|
|
557
571
|
streamPublicKey = new web3_js_1.PublicKey(id);
|
|
558
572
|
return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
|
|
559
573
|
case 1:
|
|
@@ -619,6 +633,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
619
633
|
return __generator(this, function (_c) {
|
|
620
634
|
switch (_c.label) {
|
|
621
635
|
case 0:
|
|
636
|
+
if (!invoker.publicKey) {
|
|
637
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
638
|
+
}
|
|
622
639
|
ixs = [];
|
|
623
640
|
stream = new web3_js_1.PublicKey(id);
|
|
624
641
|
newRecipient = new web3_js_1.PublicKey(recipientId);
|
|
@@ -677,6 +694,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
677
694
|
return __generator(this, function (_e) {
|
|
678
695
|
switch (_e.label) {
|
|
679
696
|
case 0:
|
|
697
|
+
if (!invoker.publicKey) {
|
|
698
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
699
|
+
}
|
|
680
700
|
ixs = [];
|
|
681
701
|
streamPublicKey = new web3_js_1.PublicKey(id);
|
|
682
702
|
return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
|
|
@@ -829,7 +849,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
829
849
|
throw Error("Error with transaction parameters.");
|
|
830
850
|
confirmationStrategy = {
|
|
831
851
|
lastValidBlockHeight: hash.lastValidBlockHeight,
|
|
832
|
-
signature:
|
|
852
|
+
signature: bs58_1.default.encode(tx.signature),
|
|
833
853
|
blockhash: hash.blockhash,
|
|
834
854
|
};
|
|
835
855
|
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx, confirmationStrategy)];
|
|
@@ -853,6 +873,9 @@ var StreamClient = /** @class */ (function () {
|
|
|
853
873
|
switch (_f.label) {
|
|
854
874
|
case 0:
|
|
855
875
|
sender = streamParams.sender, mint = streamParams.mint, start = streamParams.start, period = streamParams.period, cliff = streamParams.cliff, canTopup = streamParams.canTopup, cancelableBySender = streamParams.cancelableBySender, cancelableByRecipient = streamParams.cancelableByRecipient, transferableBySender = streamParams.transferableBySender, transferableByRecipient = streamParams.transferableByRecipient, _a = streamParams.automaticWithdrawal, automaticWithdrawal = _a === void 0 ? false : _a, _b = streamParams.withdrawalFrequency, withdrawalFrequency = _b === void 0 ? 0 : _b, _c = streamParams.partner, partner = _c === void 0 ? null : _c;
|
|
876
|
+
if (!sender.publicKey) {
|
|
877
|
+
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
878
|
+
}
|
|
856
879
|
ixs = [];
|
|
857
880
|
commitment = typeof this.commitment == "string"
|
|
858
881
|
? this.commitment
|
|
@@ -860,23 +883,21 @@ var StreamClient = /** @class */ (function () {
|
|
|
860
883
|
recipientPublicKey = new web3_js_1.PublicKey(recipient.recipient);
|
|
861
884
|
mintPublicKey = new web3_js_1.PublicKey(mint);
|
|
862
885
|
metadata = web3_js_1.Keypair.generate();
|
|
863
|
-
|
|
864
|
-
case 1:
|
|
865
|
-
_d = __read.apply(void 0, [_f.sent(), 1]), escrowTokens = _d[0];
|
|
886
|
+
_d = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId), 1), escrowTokens = _d[0];
|
|
866
887
|
return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
|
|
867
|
-
case
|
|
888
|
+
case 1:
|
|
868
889
|
senderTokens = _f.sent();
|
|
869
890
|
return [4 /*yield*/, ata(mintPublicKey, recipientPublicKey)];
|
|
870
|
-
case
|
|
891
|
+
case 2:
|
|
871
892
|
recipientTokens = _f.sent();
|
|
872
893
|
return [4 /*yield*/, ata(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
|
|
873
|
-
case
|
|
894
|
+
case 3:
|
|
874
895
|
streamflowTreasuryTokens = _f.sent();
|
|
875
896
|
partnerPublicKey = partner
|
|
876
897
|
? new web3_js_1.PublicKey(partner)
|
|
877
898
|
: constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
878
899
|
return [4 /*yield*/, ata(mintPublicKey, partnerPublicKey)];
|
|
879
|
-
case
|
|
900
|
+
case 4:
|
|
880
901
|
partnerTokens = _f.sent();
|
|
881
902
|
ixs.push((0, instructions_1.createStreamInstruction)({
|
|
882
903
|
start: new bn_js_1.default(start),
|
|
@@ -914,7 +935,7 @@ var StreamClient = /** @class */ (function () {
|
|
|
914
935
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
915
936
|
}));
|
|
916
937
|
return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
|
|
917
|
-
case
|
|
938
|
+
case 5:
|
|
918
939
|
hash = _f.sent();
|
|
919
940
|
tx = (_e = new web3_js_1.Transaction({
|
|
920
941
|
feePayer: sender.publicKey,
|
|
@@ -947,14 +968,7 @@ function getProgramAccounts(connection, wallet, offset, programId) {
|
|
|
947
968
|
});
|
|
948
969
|
}
|
|
949
970
|
function ata(mint, account) {
|
|
950
|
-
return
|
|
951
|
-
return __generator(this, function (_a) {
|
|
952
|
-
switch (_a.label) {
|
|
953
|
-
case 0: return [4 /*yield*/, spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, mint, account, true)];
|
|
954
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
});
|
|
971
|
+
return (0, spl_token_1.getAssociatedTokenAddress)(mint, account, true);
|
|
958
972
|
}
|
|
959
973
|
function isAnchorWallet(wallet) {
|
|
960
974
|
return wallet.signTransaction !== undefined;
|
|
@@ -1000,7 +1014,7 @@ function sendAndConfirmStreamRawTransaction(connection, batchItem) {
|
|
|
1000
1014
|
throw { recipient: batchItem.recipient, error: "no recent blockhash" };
|
|
1001
1015
|
confirmationStrategy = {
|
|
1002
1016
|
lastValidBlockHeight: lastValidBlockHeight,
|
|
1003
|
-
signature:
|
|
1017
|
+
signature: bs58_1.default.encode(signature),
|
|
1004
1018
|
blockhash: recentBlockhash,
|
|
1005
1019
|
};
|
|
1006
1020
|
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var bn_js_1 = require("bn.js");
|
|
54
|
+
var StreamClient_1 = __importDefault(require("../../aptos/StreamClient"));
|
|
55
|
+
var types_1 = require("../../common/types");
|
|
56
|
+
describe("AptosStreamClient", function () {
|
|
57
|
+
describe("coreClient", function () {
|
|
58
|
+
it("should succesfully create AptosStreamInstance", function () {
|
|
59
|
+
var instance = new StreamClient_1.default(types_1.ICluster.Devnet);
|
|
60
|
+
expect(instance).toBeInstanceOf(StreamClient_1.default);
|
|
61
|
+
});
|
|
62
|
+
it("should correctly set passed params", function () {
|
|
63
|
+
var pid = "PID";
|
|
64
|
+
var gas = "30";
|
|
65
|
+
var instance = new StreamClient_1.default(types_1.ICluster.Devnet, gas, pid);
|
|
66
|
+
expect(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
|
|
67
|
+
expect(instance.getProgramId()).toBe(pid);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe("create", function () {
|
|
71
|
+
var pid = "PID";
|
|
72
|
+
var gas = "30";
|
|
73
|
+
var instance = new StreamClient_1.default(types_1.ICluster.Devnet, gas, pid);
|
|
74
|
+
beforeEach(function () {
|
|
75
|
+
instance = new StreamClient_1.default(types_1.ICluster.Devnet, gas, pid);
|
|
76
|
+
});
|
|
77
|
+
test("should create a stream with passed parameters", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var mockSigner, mockWallet, mockRecipient, mockData, mockReturn, result, callParam, args;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
mockSigner = jest.fn();
|
|
83
|
+
mockWallet = {
|
|
84
|
+
signAndSubmitTransaction: mockSigner,
|
|
85
|
+
};
|
|
86
|
+
mockRecipient = {
|
|
87
|
+
recipient: "0xtest",
|
|
88
|
+
amount: new bn_js_1.BN(1000),
|
|
89
|
+
name: "test name",
|
|
90
|
+
cliffAmount: new bn_js_1.BN(1),
|
|
91
|
+
amountPerPeriod: new bn_js_1.BN(1),
|
|
92
|
+
};
|
|
93
|
+
mockData = {
|
|
94
|
+
period: 100,
|
|
95
|
+
start: 10,
|
|
96
|
+
cliff: 12,
|
|
97
|
+
cancelableBySender: true,
|
|
98
|
+
cancelableByRecipient: false,
|
|
99
|
+
transferableBySender: false,
|
|
100
|
+
transferableByRecipient: true,
|
|
101
|
+
canTopup: true,
|
|
102
|
+
automaticWithdrawal: false,
|
|
103
|
+
withdrawalFrequency: 10,
|
|
104
|
+
tokenId: "0xtest::token::Token",
|
|
105
|
+
canPause: false,
|
|
106
|
+
canUpdateRate: false,
|
|
107
|
+
};
|
|
108
|
+
mockReturn = "hash";
|
|
109
|
+
mockSigner.mockResolvedValue({ hash: mockReturn });
|
|
110
|
+
return [4 /*yield*/, instance.create(__assign(__assign({}, mockData), mockRecipient), { senderWallet: mockWallet })];
|
|
111
|
+
case 1:
|
|
112
|
+
result = _a.sent();
|
|
113
|
+
// Assert
|
|
114
|
+
expect(mockSigner).toHaveBeenCalledTimes(1);
|
|
115
|
+
callParam = mockSigner.mock.calls[0][0];
|
|
116
|
+
args = callParam.arguments;
|
|
117
|
+
delete callParam.arguments;
|
|
118
|
+
args.shift();
|
|
119
|
+
expect(args).toEqual([
|
|
120
|
+
mockRecipient.amount,
|
|
121
|
+
100,
|
|
122
|
+
mockRecipient.amountPerPeriod,
|
|
123
|
+
10,
|
|
124
|
+
mockRecipient.cliffAmount,
|
|
125
|
+
true,
|
|
126
|
+
false,
|
|
127
|
+
false,
|
|
128
|
+
true,
|
|
129
|
+
true,
|
|
130
|
+
false,
|
|
131
|
+
false,
|
|
132
|
+
false,
|
|
133
|
+
10,
|
|
134
|
+
"5354524d",
|
|
135
|
+
"0xtest",
|
|
136
|
+
]);
|
|
137
|
+
expect(callParam).toEqual({
|
|
138
|
+
function: "PID::protocol::create",
|
|
139
|
+
type: "create",
|
|
140
|
+
type_arguments: ["0xtest::token::Token"],
|
|
141
|
+
});
|
|
142
|
+
expect(result).toEqual({ txId: mockReturn });
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}); });
|
|
147
|
+
});
|
|
148
|
+
// describe("createMultiple", () => {
|
|
149
|
+
// });
|
|
150
|
+
// describe("withdraw", () => {
|
|
151
|
+
// });
|
|
152
|
+
// describe("cancel", () => {
|
|
153
|
+
// });
|
|
154
|
+
// describe("transfer", () => {
|
|
155
|
+
// });
|
|
156
|
+
// describe("topup", () => {
|
|
157
|
+
// });
|
|
158
|
+
// describe("getOne", () => {
|
|
159
|
+
// });
|
|
160
|
+
});
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { Wallet } from "@project-serum/anchor";
|
|
2
1
|
import { Connection } from "@solana/web3.js";
|
|
3
2
|
export declare const requestAirdrop: (wallet: Wallet, connection: Connection) => Promise<[import("@solana/web3.js").RpcResponseAndContext<import("@solana/web3.js").SignatureResult>] | undefined>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GenericStreamClient, ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, ITopUpData, ITransferData, IWithdrawData } from "../common/types";
|
|
2
|
+
import { ICreateStreamAptosExt, ITransactionAptosExt, ITransactionResult } from "./types";
|
|
3
|
+
export default class AptosStreamClient extends GenericStreamClient {
|
|
4
|
+
private programId;
|
|
5
|
+
private maxGas;
|
|
6
|
+
constructor(cluster: ICluster, maxGas?: string, programId?: string);
|
|
7
|
+
create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<ITransactionResult>;
|
|
8
|
+
createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<ITransactionResult[]>;
|
|
9
|
+
withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
10
|
+
cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
|
|
11
|
+
transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
|
|
12
|
+
topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
|
|
13
|
+
getOne(): Promise<any>;
|
|
14
|
+
getProgramId(): string;
|
|
15
|
+
getMaxGas(): {
|
|
16
|
+
max_gas_amount: string;
|
|
17
|
+
};
|
|
18
|
+
private generateMultiPayloads;
|
|
19
|
+
}
|