@streamflow/stream 5.6.1 → 5.6.3

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.
Files changed (75) hide show
  1. package/dist/__tests__/aptos/streamClient.spec.d.ts +1 -0
  2. package/dist/__tests__/aptos/streamClient.spec.js +161 -0
  3. package/dist/__tests__/common/GenericStreamClient.spec.d.ts +1 -0
  4. package/dist/__tests__/common/GenericStreamClient.spec.js +44 -0
  5. package/dist/aptos/StreamClient.d.ts +51 -0
  6. package/dist/aptos/StreamClient.js +391 -0
  7. package/dist/aptos/constants.d.ts +8 -0
  8. package/dist/aptos/constants.js +28 -0
  9. package/dist/aptos/index.d.ts +2 -0
  10. package/dist/aptos/index.js +24 -0
  11. package/dist/aptos/types.d.ts +97 -0
  12. package/dist/aptos/types.js +76 -0
  13. package/dist/aptos/utils.d.ts +1 -0
  14. package/dist/aptos/utils.js +12 -0
  15. package/dist/aptos/wallet.d.ts +9 -0
  16. package/dist/aptos/wallet.js +89 -0
  17. package/dist/common/BaseStreamClient.d.ts +13 -0
  18. package/dist/common/BaseStreamClient.js +13 -0
  19. package/dist/common/GenericStreamClient.d.ts +93 -0
  20. package/dist/common/GenericStreamClient.js +114 -0
  21. package/dist/common/constants.d.ts +1 -0
  22. package/dist/common/constants.js +4 -0
  23. package/dist/common/contractUtils.d.ts +47 -0
  24. package/dist/common/contractUtils.js +55 -0
  25. package/dist/common/types.d.ts +252 -0
  26. package/dist/common/types.js +165 -0
  27. package/dist/common/utils.d.ts +22 -0
  28. package/dist/common/utils.js +101 -0
  29. package/dist/evm/StreamClient.d.ts +30 -0
  30. package/dist/evm/StreamClient.js +461 -0
  31. package/dist/evm/abi.d.ts +111 -0
  32. package/dist/evm/abi.js +1257 -0
  33. package/dist/evm/constants.d.ts +20 -0
  34. package/dist/evm/constants.js +39 -0
  35. package/dist/evm/ercAbi.d.ts +39 -0
  36. package/dist/evm/ercAbi.js +224 -0
  37. package/dist/evm/index.d.ts +2 -0
  38. package/dist/evm/index.js +24 -0
  39. package/dist/evm/types.d.ts +93 -0
  40. package/dist/evm/types.js +75 -0
  41. package/dist/evm/utils.d.ts +1 -0
  42. package/dist/evm/utils.js +12 -0
  43. package/dist/index.d.ts +8 -0
  44. package/dist/index.js +41 -0
  45. package/dist/solana/StreamClient.d.ts +72 -0
  46. package/dist/solana/StreamClient.js +927 -0
  47. package/dist/solana/constants.d.ts +22 -0
  48. package/dist/solana/constants.js +50 -0
  49. package/dist/solana/index.d.ts +7 -0
  50. package/dist/solana/index.js +43 -0
  51. package/dist/solana/instructionTypes.d.ts +96 -0
  52. package/dist/solana/instructionTypes.js +2 -0
  53. package/dist/solana/instructions.d.ts +139 -0
  54. package/dist/solana/instructions.js +407 -0
  55. package/dist/solana/layout.d.ts +27 -0
  56. package/dist/solana/layout.js +170 -0
  57. package/dist/solana/timelockIDL.d.ts +22 -0
  58. package/dist/solana/timelockIDL.js +422 -0
  59. package/dist/solana/types.d.ts +292 -0
  60. package/dist/solana/types.js +81 -0
  61. package/dist/solana/utils.d.ts +44 -0
  62. package/dist/solana/utils.js +303 -0
  63. package/dist/sui/StreamClient.d.ts +79 -0
  64. package/dist/sui/StreamClient.js +571 -0
  65. package/dist/sui/constants.d.ts +10 -0
  66. package/dist/sui/constants.js +43 -0
  67. package/dist/sui/index.d.ts +2 -0
  68. package/dist/sui/index.js +23 -0
  69. package/dist/sui/types.d.ts +141 -0
  70. package/dist/sui/types.js +102 -0
  71. package/dist/sui/utils.d.ts +2 -0
  72. package/dist/sui/utils.js +29 -0
  73. package/dist/sui/wallet.d.ts +11 -0
  74. package/dist/sui/wallet.js +75 -0
  75. package/package.json +2 -2
@@ -0,0 +1,141 @@
1
+ import { Keypair } from "@mysten/sui.js/cryptography";
2
+ import { WalletContextState } from "@suiet/wallet-kit";
3
+ import { TransactionBlock } from "@mysten/sui.js/transactions";
4
+ import { ExecuteTransactionRequestType, SuiTransactionBlockResponseOptions } from "@mysten/sui.js/client";
5
+ import BN from "bn.js";
6
+ import { Stream, StreamType } from "../common/types";
7
+ export interface ICreateStreamSuiExt {
8
+ senderWallet: WalletContextState | Keypair;
9
+ }
10
+ export interface ITransactionSuiExt {
11
+ senderWallet: WalletContextState | Keypair;
12
+ tokenId: string;
13
+ }
14
+ export interface ISuiIdParameters {
15
+ program: string;
16
+ config: string;
17
+ feeTable: string;
18
+ }
19
+ export interface IContractCreated {
20
+ address: string;
21
+ }
22
+ export interface IContractWithdrawn {
23
+ address: string;
24
+ amount: number;
25
+ streamflow_amount: number;
26
+ partner_amount: number;
27
+ }
28
+ export interface StreamResource {
29
+ id: {
30
+ id: string;
31
+ };
32
+ amount: string;
33
+ amount_per_period: string;
34
+ balance: string;
35
+ canceled_at: string;
36
+ cliff_amount: string;
37
+ closed: boolean;
38
+ created: string;
39
+ current_pause_start: string;
40
+ end: string;
41
+ fees: {
42
+ fields: {
43
+ partner_fee: string;
44
+ partner_fee_percentage: string;
45
+ partner_fee_withdrawn: string;
46
+ streamflow_fee: string;
47
+ streamflow_fee_percentage: string;
48
+ streamflow_fee_withdrawn: string;
49
+ };
50
+ type: string;
51
+ };
52
+ funds_unlocked_at_last_rate_change: string;
53
+ last_rate_change_time: string;
54
+ last_withdrawn_at: string;
55
+ meta: {
56
+ fields: {
57
+ automatic_withdrawal: boolean;
58
+ can_topup: boolean;
59
+ can_update_rate: boolean;
60
+ cancelable_by_recipient: boolean;
61
+ cancelable_by_sender: boolean;
62
+ contract_name: number[];
63
+ pausable: boolean;
64
+ transferable_by_recipient: boolean;
65
+ transferable_by_sender: boolean;
66
+ withdrawal_frequency: string;
67
+ };
68
+ type: string;
69
+ };
70
+ partner: string;
71
+ pause_cumulative: string;
72
+ period: string;
73
+ recipient: string;
74
+ sender: string;
75
+ start: string;
76
+ version: string;
77
+ withdrawn: string;
78
+ }
79
+ export declare class Contract implements Stream {
80
+ magic: number;
81
+ version: number;
82
+ createdAt: number;
83
+ withdrawnAmount: BN;
84
+ canceledAt: number;
85
+ end: number;
86
+ lastWithdrawnAt: number;
87
+ sender: string;
88
+ senderTokens: string;
89
+ recipient: string;
90
+ recipientTokens: string;
91
+ mint: string;
92
+ escrowTokens: string;
93
+ streamflowTreasury: string;
94
+ streamflowTreasuryTokens: string;
95
+ streamflowFeeTotal: BN;
96
+ streamflowFeeWithdrawn: BN;
97
+ streamflowFeePercent: number;
98
+ partnerFeeTotal: BN;
99
+ partnerFeeWithdrawn: BN;
100
+ partnerFeePercent: number;
101
+ partner: string;
102
+ partnerTokens: string;
103
+ start: number;
104
+ depositedAmount: BN;
105
+ period: number;
106
+ amountPerPeriod: BN;
107
+ cliff: number;
108
+ cliffAmount: BN;
109
+ cancelableBySender: boolean;
110
+ cancelableByRecipient: boolean;
111
+ automaticWithdrawal: boolean;
112
+ transferableBySender: boolean;
113
+ transferableByRecipient: boolean;
114
+ canTopup: boolean;
115
+ name: string;
116
+ withdrawalFrequency: number;
117
+ closed: boolean;
118
+ currentPauseStart: number;
119
+ pauseCumulative: BN;
120
+ lastRateChangeTime: number;
121
+ fundsUnlockedAtLastRateChange: BN;
122
+ type: StreamType;
123
+ constructor(stream: StreamResource, tokenId: string);
124
+ unlocked(currentTimestamp: number): BN;
125
+ remaining(decimals: number): number;
126
+ }
127
+ export interface SuiParsedError {
128
+ module: "protocol" | "admin" | "fee_manager";
129
+ code: number;
130
+ name: string;
131
+ }
132
+ export interface SuiErrorInfo {
133
+ index?: number;
134
+ text: string;
135
+ parsed?: SuiParsedError;
136
+ }
137
+ export interface SuiSignAndExecuteTransactionBlockInput {
138
+ transactionBlock: TransactionBlock;
139
+ requestType?: ExecuteTransactionRequestType;
140
+ options?: SuiTransactionBlockResponseOptions;
141
+ }
@@ -0,0 +1,102 @@
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 __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
29
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ if (ar || !(i in from)) {
32
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
+ ar[i] = from[i];
34
+ }
35
+ }
36
+ return to.concat(ar || Array.prototype.slice.call(from));
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.Contract = void 0;
43
+ var bn_js_1 = __importDefault(require("bn.js"));
44
+ var contractUtils_1 = require("../common/contractUtils");
45
+ var utils_1 = require("../common/utils");
46
+ var Contract = /** @class */ (function () {
47
+ function Contract(stream, tokenId) {
48
+ var meta = stream.meta.fields;
49
+ var fees = stream.fees.fields;
50
+ this.magic = 0;
51
+ this.version = parseInt(stream.version);
52
+ this.createdAt = parseInt(stream.created);
53
+ this.withdrawnAmount = new bn_js_1.default(stream.withdrawn);
54
+ this.canceledAt = parseInt(stream.canceled_at);
55
+ this.end = parseInt(stream.end);
56
+ this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
57
+ this.sender = stream.sender;
58
+ this.senderTokens = stream.sender;
59
+ this.recipient = stream.recipient;
60
+ this.recipientTokens = stream.recipient;
61
+ this.mint = tokenId;
62
+ this.escrowTokens = "";
63
+ this.streamflowTreasury = "";
64
+ this.streamflowTreasuryTokens = "";
65
+ this.streamflowFeeTotal = new bn_js_1.default(0);
66
+ this.streamflowFeeWithdrawn = new bn_js_1.default(0);
67
+ this.streamflowFeePercent = parseInt(fees.streamflow_fee_percentage) / 10000;
68
+ this.partnerFeeTotal = new bn_js_1.default(0);
69
+ this.partnerFeeWithdrawn = new bn_js_1.default(0);
70
+ this.partnerFeePercent = parseInt(fees.partner_fee_percentage) / 10000;
71
+ this.partner = stream.partner;
72
+ this.partnerTokens = "";
73
+ this.start = parseInt(stream.start);
74
+ this.depositedAmount = new bn_js_1.default(stream.amount);
75
+ this.period = parseInt(stream.period);
76
+ this.amountPerPeriod = new bn_js_1.default(stream.amount_per_period);
77
+ this.cliff = parseInt(stream.start);
78
+ this.cliffAmount = new bn_js_1.default(stream.cliff_amount);
79
+ this.cancelableBySender = meta.cancelable_by_sender;
80
+ this.cancelableByRecipient = meta.cancelable_by_recipient;
81
+ this.automaticWithdrawal = meta.automatic_withdrawal;
82
+ this.transferableBySender = meta.transferable_by_sender;
83
+ this.transferableByRecipient = meta.transferable_by_recipient;
84
+ this.canTopup = meta.can_topup;
85
+ this.name = String.fromCharCode.apply(String, __spreadArray([], __read(meta.contract_name), false));
86
+ this.withdrawalFrequency = parseInt(meta.withdrawal_frequency);
87
+ this.closed = stream.closed;
88
+ this.currentPauseStart = parseInt(stream.current_pause_start);
89
+ this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative);
90
+ this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
91
+ this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change);
92
+ this.type = (0, contractUtils_1.buildStreamType)(this);
93
+ }
94
+ Contract.prototype.unlocked = function (currentTimestamp) {
95
+ return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
96
+ };
97
+ Contract.prototype.remaining = function (decimals) {
98
+ return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
99
+ };
100
+ return Contract;
101
+ }());
102
+ exports.Contract = Contract;
@@ -0,0 +1,2 @@
1
+ import { SuiErrorInfo } from "./types";
2
+ export declare function extractSuiErrorInfo(errorText: string): SuiErrorInfo;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractSuiErrorInfo = void 0;
4
+ var constants_1 = require("./constants");
5
+ function extractSuiErrorInfo(errorText) {
6
+ var error = { text: errorText };
7
+ var match = constants_1.SUI_ERROR_MATCH_REGEX.exec(errorText);
8
+ if (!match) {
9
+ return error;
10
+ }
11
+ var moduleName = match[2];
12
+ var errorCode = Number(match[4]);
13
+ var errorName = constants_1.SUI_MODULE_ERROR_MAP[moduleName]
14
+ ? constants_1.SUI_MODULE_ERROR_MAP[moduleName][errorCode]
15
+ : undefined;
16
+ var index = Number(match[5]);
17
+ if (index) {
18
+ error.index = index;
19
+ }
20
+ if (errorName) {
21
+ error.parsed = {
22
+ module: moduleName,
23
+ code: errorCode,
24
+ name: errorName,
25
+ };
26
+ }
27
+ return error;
28
+ }
29
+ exports.extractSuiErrorInfo = extractSuiErrorInfo;
@@ -0,0 +1,11 @@
1
+ import { Keypair } from "@mysten/sui.js/cryptography";
2
+ import { WalletContextState } from "@suiet/wallet-kit";
3
+ import { SuiClient, SuiTransactionBlockResponse } from "@mysten/sui.js/client";
4
+ import { SuiSignAndExecuteTransactionBlockInput } from "./types";
5
+ export declare class SuiWalletWrapper<T extends WalletContextState | Keypair> {
6
+ wallet: T;
7
+ address: string;
8
+ client: SuiClient;
9
+ constructor(wallet: T, client: SuiClient);
10
+ signAndExecuteTransactionBlock(input: SuiSignAndExecuteTransactionBlockInput): Promise<SuiTransactionBlockResponse>;
11
+ }
@@ -0,0 +1,75 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.SuiWalletWrapper = void 0;
51
+ var cryptography_1 = require("@mysten/sui.js/cryptography");
52
+ var SuiWalletWrapper = /** @class */ (function () {
53
+ function SuiWalletWrapper(wallet, client) {
54
+ this.client = client;
55
+ this.wallet = wallet;
56
+ if (wallet instanceof cryptography_1.Keypair) {
57
+ this.address = wallet.toSuiAddress();
58
+ }
59
+ else {
60
+ this.address = wallet.address;
61
+ }
62
+ }
63
+ SuiWalletWrapper.prototype.signAndExecuteTransactionBlock = function (input) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ return __generator(this, function (_a) {
66
+ if (this.wallet instanceof cryptography_1.Keypair) {
67
+ return [2 /*return*/, this.client.signAndExecuteTransactionBlock(__assign(__assign({}, input), { signer: this.wallet }))];
68
+ }
69
+ return [2 /*return*/, this.wallet.signAndExecuteTransactionBlock(input)];
70
+ });
71
+ });
72
+ };
73
+ return SuiWalletWrapper;
74
+ }());
75
+ exports.SuiWalletWrapper = SuiWalletWrapper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "5.6.1",
3
+ "version": "5.6.3",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
@@ -11,7 +11,7 @@
11
11
  "lint": "eslint .",
12
12
  "prepublishOnly": "npm run lint && npm test && npm run build"
13
13
  },
14
- "gitHead": "b56d9fcaafd05576b7821076b3c745d996f78469",
14
+ "gitHead": "5ff6b4255eb81f8a92987b403df29c6dedb85c39",
15
15
  "devDependencies": {
16
16
  "@types/bn.js": "5.1.1",
17
17
  "@types/ethereum-checksum-address": "^0.0.0",