@streamflow/stream 5.6.0 → 5.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/package.json +5 -6
- package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
- package/dist/__tests__/aptos/streamClient.spec.js +0 -161
- package/dist/aptos/StreamClient.d.ts +0 -51
- package/dist/aptos/StreamClient.js +0 -387
- package/dist/aptos/constants.d.ts +0 -8
- package/dist/aptos/constants.js +0 -28
- package/dist/aptos/index.d.ts +0 -2
- package/dist/aptos/index.js +0 -24
- package/dist/aptos/types.d.ts +0 -97
- package/dist/aptos/types.js +0 -76
- package/dist/aptos/utils.d.ts +0 -1
- package/dist/aptos/utils.js +0 -12
- package/dist/aptos/wallet.d.ts +0 -9
- package/dist/aptos/wallet.js +0 -89
- package/dist/common/BaseStreamClient.d.ts +0 -13
- package/dist/common/BaseStreamClient.js +0 -13
- package/dist/common/GenericStreamClient.d.ts +0 -93
- package/dist/common/GenericStreamClient.js +0 -114
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +0 -4
- package/dist/common/contractUtils.d.ts +0 -47
- package/dist/common/contractUtils.js +0 -55
- package/dist/common/types.d.ts +0 -252
- package/dist/common/types.js +0 -165
- package/dist/common/utils.d.ts +0 -22
- package/dist/common/utils.js +0 -101
- package/dist/evm/StreamClient.d.ts +0 -30
- package/dist/evm/StreamClient.js +0 -461
- package/dist/evm/abi.d.ts +0 -111
- package/dist/evm/abi.js +0 -1257
- package/dist/evm/constants.d.ts +0 -20
- package/dist/evm/constants.js +0 -39
- package/dist/evm/ercAbi.d.ts +0 -39
- package/dist/evm/ercAbi.js +0 -224
- package/dist/evm/index.d.ts +0 -2
- package/dist/evm/index.js +0 -24
- package/dist/evm/types.d.ts +0 -93
- package/dist/evm/types.js +0 -75
- package/dist/evm/utils.d.ts +0 -1
- package/dist/evm/utils.js +0 -12
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -41
- package/dist/solana/StreamClient.d.ts +0 -72
- package/dist/solana/StreamClient.js +0 -927
- package/dist/solana/constants.d.ts +0 -22
- package/dist/solana/constants.js +0 -50
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/solana/instructionTypes.d.ts +0 -96
- package/dist/solana/instructionTypes.js +0 -2
- package/dist/solana/instructions.d.ts +0 -139
- package/dist/solana/instructions.js +0 -407
- package/dist/solana/layout.d.ts +0 -27
- package/dist/solana/layout.js +0 -170
- package/dist/solana/timelockIDL.d.ts +0 -22
- package/dist/solana/timelockIDL.js +0 -422
- package/dist/solana/types.d.ts +0 -292
- package/dist/solana/types.js +0 -81
- package/dist/solana/utils.d.ts +0 -44
- package/dist/solana/utils.js +0 -303
- package/dist/sui/StreamClient.d.ts +0 -79
- package/dist/sui/StreamClient.js +0 -571
- package/dist/sui/constants.d.ts +0 -10
- package/dist/sui/constants.js +0 -43
- package/dist/sui/index.d.ts +0 -2
- package/dist/sui/index.js +0 -23
- package/dist/sui/types.d.ts +0 -141
- package/dist/sui/types.js +0 -102
- package/dist/sui/utils.d.ts +0 -2
- package/dist/sui/utils.js +0 -29
- package/dist/sui/wallet.d.ts +0 -11
- package/dist/sui/wallet.js +0 -75
package/dist/solana/types.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
|
|
15
|
-
var contractUtils_1 = require("../common/contractUtils");
|
|
16
|
-
var utils_1 = require("../common/utils");
|
|
17
|
-
var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
|
|
18
|
-
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
|
|
19
|
-
var Contract = /** @class */ (function () {
|
|
20
|
-
function Contract(stream) {
|
|
21
|
-
var _a;
|
|
22
|
-
this.magic = stream.magic.toNumber();
|
|
23
|
-
this.version = stream.version.toNumber();
|
|
24
|
-
this.createdAt = stream.createdAt.toNumber();
|
|
25
|
-
this.withdrawnAmount = stream.withdrawnAmount;
|
|
26
|
-
this.canceledAt = stream.canceledAt.toNumber();
|
|
27
|
-
this.end = stream.end.toNumber();
|
|
28
|
-
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
29
|
-
this.sender = stream.sender.toBase58();
|
|
30
|
-
this.senderTokens = stream.senderTokens.toBase58();
|
|
31
|
-
this.recipient = stream.recipient.toBase58();
|
|
32
|
-
this.recipientTokens = stream.recipientTokens.toBase58();
|
|
33
|
-
this.mint = stream.mint.toBase58();
|
|
34
|
-
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
35
|
-
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
36
|
-
this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
|
|
37
|
-
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
38
|
-
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
39
|
-
this.streamflowFeePercent = stream.streamflowFeePercent.toNumber();
|
|
40
|
-
this.partnerFeeTotal = stream.partnerFeeTotal;
|
|
41
|
-
this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
|
|
42
|
-
this.partnerFeePercent = stream.partnerFeePercent.toNumber();
|
|
43
|
-
this.partner = stream.partner.toBase58();
|
|
44
|
-
this.partnerTokens = (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58();
|
|
45
|
-
this.start = stream.start.toNumber();
|
|
46
|
-
this.depositedAmount = stream.depositedAmount;
|
|
47
|
-
this.period = stream.period.toNumber();
|
|
48
|
-
this.amountPerPeriod = stream.amountPerPeriod;
|
|
49
|
-
this.cliff = stream.cliff.toNumber();
|
|
50
|
-
this.cliffAmount = stream.cliffAmount;
|
|
51
|
-
this.cancelableBySender = stream.cancelableBySender;
|
|
52
|
-
this.cancelableByRecipient = stream.cancelableByRecipient;
|
|
53
|
-
this.automaticWithdrawal = stream.automaticWithdrawal;
|
|
54
|
-
this.transferableBySender = stream.transferableBySender;
|
|
55
|
-
this.transferableByRecipient = stream.transferableByRecipient;
|
|
56
|
-
this.canTopup = stream.canTopup;
|
|
57
|
-
this.name = stream.name;
|
|
58
|
-
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
59
|
-
this.closed = stream.closed;
|
|
60
|
-
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
61
|
-
this.pauseCumulative = stream.pauseCumulative;
|
|
62
|
-
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
63
|
-
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
64
|
-
this.type = (0, contractUtils_1.buildStreamType)(this);
|
|
65
|
-
}
|
|
66
|
-
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
67
|
-
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
68
|
-
};
|
|
69
|
-
Contract.prototype.remaining = function (decimals) {
|
|
70
|
-
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
71
|
-
};
|
|
72
|
-
return Contract;
|
|
73
|
-
}());
|
|
74
|
-
exports.Contract = Contract;
|
|
75
|
-
var TransferCancelOptions;
|
|
76
|
-
(function (TransferCancelOptions) {
|
|
77
|
-
TransferCancelOptions["Recipient"] = "recipient";
|
|
78
|
-
TransferCancelOptions["Sender"] = "sender";
|
|
79
|
-
TransferCancelOptions["Both"] = "both";
|
|
80
|
-
TransferCancelOptions["Neither"] = "neither";
|
|
81
|
-
})(TransferCancelOptions = exports.TransferCancelOptions || (exports.TransferCancelOptions = {}));
|
package/dist/solana/utils.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
|
-
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
4
|
-
import { DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
|
|
5
|
-
import { Stream } from "../common/types";
|
|
6
|
-
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
7
|
-
export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
|
|
8
|
-
/**
|
|
9
|
-
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
10
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
11
|
-
* @param {PublicKey} wallet - PublicKey to compare against.
|
|
12
|
-
* @param {number} offset - Offset of bits of the PublicKey in the account binary.
|
|
13
|
-
* @param {PublicKey} programId - Solana program ID.
|
|
14
|
-
* @return {Promise<Account[]>} - Array of resulting accounts.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
|
|
17
|
-
/**
|
|
18
|
-
* Utility function to check if the transaction initiator is a Wallet object
|
|
19
|
-
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
20
|
-
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
21
|
-
*/
|
|
22
|
-
export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
25
|
-
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
26
|
-
* @param {BatchItem[]} items - Multiple recipient contracts split into separate items
|
|
27
|
-
* @return {BatchItem[]} - Returns items with signatures.
|
|
28
|
-
*/
|
|
29
|
-
export declare function signAllTransactionWithRecipients(sender: Keypair | SignerWalletAdapter, items: BatchItem[]): Promise<BatchItem[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
32
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
33
|
-
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
34
|
-
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
35
|
-
*/
|
|
36
|
-
export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem): Promise<BatchItemResult>;
|
|
37
|
-
/**
|
|
38
|
-
* Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
|
|
39
|
-
* @param {PublicKey} mint - SPL token Mint address.
|
|
40
|
-
* @param {PublicKey} owner - Owner of the Associated Token Address
|
|
41
|
-
* @return {Promise<PublicKey>} - Associated Token Address
|
|
42
|
-
*/
|
|
43
|
-
export declare function ata(mint: PublicKey, owner: PublicKey): Promise<PublicKey>;
|
|
44
|
-
export declare function extractSolanaErrorCode(errorText: string): string | null;
|
package/dist/solana/utils.js
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
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
|
-
exports.extractSolanaErrorCode = exports.ata = exports.sendAndConfirmStreamRawTransaction = exports.signAllTransactionWithRecipients = exports.isSignerWallet = exports.getProgramAccounts = exports.formatDecodedStream = exports.decodeStream = void 0;
|
|
54
|
-
var spl_token_1 = require("@solana/spl-token");
|
|
55
|
-
var web3_js_1 = require("@solana/web3.js");
|
|
56
|
-
var bn_js_1 = __importDefault(require("bn.js"));
|
|
57
|
-
var bs58_1 = __importDefault(require("bs58"));
|
|
58
|
-
var layout_1 = require("./layout");
|
|
59
|
-
var contractUtils_1 = require("../common/contractUtils");
|
|
60
|
-
var constants_1 = require("./constants");
|
|
61
|
-
var decoder = new TextDecoder("utf-8");
|
|
62
|
-
var LE = "le"; //little endian
|
|
63
|
-
var decodeStream = function (buf) {
|
|
64
|
-
var raw = layout_1.streamLayout.decode(buf);
|
|
65
|
-
return {
|
|
66
|
-
magic: new bn_js_1.default(raw.magic, LE),
|
|
67
|
-
version: new bn_js_1.default(raw.version, LE),
|
|
68
|
-
createdAt: new bn_js_1.default(raw.created_at, LE),
|
|
69
|
-
withdrawnAmount: new bn_js_1.default(raw.withdrawn_amount, LE),
|
|
70
|
-
canceledAt: new bn_js_1.default(raw.canceled_at, LE),
|
|
71
|
-
end: new bn_js_1.default(raw.end_time, LE),
|
|
72
|
-
lastWithdrawnAt: new bn_js_1.default(raw.last_withdrawn_at, LE),
|
|
73
|
-
sender: new web3_js_1.PublicKey(raw.sender),
|
|
74
|
-
senderTokens: new web3_js_1.PublicKey(raw.sender_tokens),
|
|
75
|
-
recipient: new web3_js_1.PublicKey(raw.recipient),
|
|
76
|
-
recipientTokens: new web3_js_1.PublicKey(raw.recipient_tokens),
|
|
77
|
-
mint: new web3_js_1.PublicKey(raw.mint),
|
|
78
|
-
escrowTokens: new web3_js_1.PublicKey(raw.escrow_tokens),
|
|
79
|
-
streamflowTreasury: new web3_js_1.PublicKey(raw.streamflow_treasury),
|
|
80
|
-
streamflowTreasuryTokens: new web3_js_1.PublicKey(raw.streamflow_treasury_tokens),
|
|
81
|
-
streamflowFeeTotal: new bn_js_1.default(raw.streamflow_fee_total, LE),
|
|
82
|
-
streamflowFeeWithdrawn: new bn_js_1.default(raw.streamflow_fee_withdrawn, LE),
|
|
83
|
-
streamflowFeePercent: new bn_js_1.default(raw.streamflow_fee_percent, LE),
|
|
84
|
-
partnerFeeTotal: new bn_js_1.default(raw.partner_fee_total, LE),
|
|
85
|
-
partnerFeeWithdrawn: new bn_js_1.default(raw.partner_fee_withdrawn, LE),
|
|
86
|
-
partnerFeePercent: new bn_js_1.default(raw.partner_fee_percent, LE),
|
|
87
|
-
partner: new web3_js_1.PublicKey(raw.partner),
|
|
88
|
-
partnerTokens: new web3_js_1.PublicKey(raw.partner_tokens),
|
|
89
|
-
start: new bn_js_1.default(raw.start_time, LE),
|
|
90
|
-
depositedAmount: new bn_js_1.default(raw.net_amount_deposited, LE),
|
|
91
|
-
period: new bn_js_1.default(raw.period, LE),
|
|
92
|
-
amountPerPeriod: new bn_js_1.default(raw.amount_per_period, LE),
|
|
93
|
-
cliff: new bn_js_1.default(raw.cliff, LE),
|
|
94
|
-
cliffAmount: new bn_js_1.default(raw.cliff_amount, LE),
|
|
95
|
-
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
96
|
-
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
97
|
-
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
98
|
-
transferableBySender: Boolean(raw.transferable_by_sender),
|
|
99
|
-
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
100
|
-
canTopup: Boolean(raw.can_topup),
|
|
101
|
-
name: decoder.decode(raw.stream_name),
|
|
102
|
-
withdrawFrequency: new bn_js_1.default(raw.withdraw_frequency, LE),
|
|
103
|
-
closed: Boolean(raw.closed),
|
|
104
|
-
currentPauseStart: new bn_js_1.default(raw.current_pause_start, LE),
|
|
105
|
-
pauseCumulative: new bn_js_1.default(raw.pause_cumulative, LE),
|
|
106
|
-
lastRateChangeTime: new bn_js_1.default(raw.last_rate_change_time, LE),
|
|
107
|
-
fundsUnlockedAtLastRateChange: new bn_js_1.default(raw.funds_unlocked_at_last_rate_change, LE),
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
exports.decodeStream = decodeStream;
|
|
111
|
-
// DeprecationWarning: This object will be deprecated starting from the version 4.0.0. Use
|
|
112
|
-
// types/Contract instead
|
|
113
|
-
var formatDecodedStream = function (stream) {
|
|
114
|
-
var _a;
|
|
115
|
-
var resp = {
|
|
116
|
-
magic: stream.magic.toNumber(),
|
|
117
|
-
version: stream.version.toNumber(),
|
|
118
|
-
createdAt: stream.createdAt.toNumber(),
|
|
119
|
-
withdrawnAmount: stream.withdrawnAmount,
|
|
120
|
-
canceledAt: stream.canceledAt.toNumber(),
|
|
121
|
-
end: stream.end.toNumber(),
|
|
122
|
-
lastWithdrawnAt: stream.lastWithdrawnAt.toNumber(),
|
|
123
|
-
sender: stream.sender.toBase58(),
|
|
124
|
-
senderTokens: stream.senderTokens.toBase58(),
|
|
125
|
-
recipient: stream.recipient.toBase58(),
|
|
126
|
-
recipientTokens: stream.recipientTokens.toBase58(),
|
|
127
|
-
mint: stream.mint.toBase58(),
|
|
128
|
-
escrowTokens: stream.escrowTokens.toBase58(),
|
|
129
|
-
streamflowTreasury: stream.streamflowTreasury.toBase58(),
|
|
130
|
-
streamflowTreasuryTokens: stream.streamflowTreasuryTokens.toBase58(),
|
|
131
|
-
streamflowFeeTotal: stream.streamflowFeeTotal,
|
|
132
|
-
streamflowFeeWithdrawn: stream.streamflowFeeWithdrawn,
|
|
133
|
-
streamflowFeePercent: stream.streamflowFeePercent.toNumber(),
|
|
134
|
-
partnerFeeTotal: stream.partnerFeeTotal,
|
|
135
|
-
partnerFeeWithdrawn: stream.partnerFeeWithdrawn,
|
|
136
|
-
partnerFeePercent: stream.partnerFeePercent.toNumber(),
|
|
137
|
-
partner: stream.partner.toBase58(),
|
|
138
|
-
partnerTokens: (_a = stream.partnerTokens) === null || _a === void 0 ? void 0 : _a.toBase58(),
|
|
139
|
-
start: stream.start.toNumber(),
|
|
140
|
-
depositedAmount: stream.depositedAmount,
|
|
141
|
-
period: stream.period.toNumber(),
|
|
142
|
-
amountPerPeriod: stream.amountPerPeriod,
|
|
143
|
-
cliff: stream.cliff.toNumber(),
|
|
144
|
-
cliffAmount: stream.cliffAmount,
|
|
145
|
-
cancelableBySender: stream.cancelableBySender,
|
|
146
|
-
cancelableByRecipient: stream.cancelableByRecipient,
|
|
147
|
-
automaticWithdrawal: stream.automaticWithdrawal,
|
|
148
|
-
transferableBySender: stream.transferableBySender,
|
|
149
|
-
transferableByRecipient: stream.transferableByRecipient,
|
|
150
|
-
canTopup: stream.canTopup,
|
|
151
|
-
name: stream.name,
|
|
152
|
-
withdrawalFrequency: stream.withdrawFrequency.toNumber(),
|
|
153
|
-
closed: stream.closed,
|
|
154
|
-
currentPauseStart: stream.currentPauseStart.toNumber(),
|
|
155
|
-
pauseCumulative: stream.pauseCumulative,
|
|
156
|
-
lastRateChangeTime: stream.lastRateChangeTime.toNumber(),
|
|
157
|
-
fundsUnlockedAtLastRateChange: stream.fundsUnlockedAtLastRateChange,
|
|
158
|
-
type: (0, contractUtils_1.buildStreamType)(stream),
|
|
159
|
-
unlocked: function () {
|
|
160
|
-
return new bn_js_1.default(0);
|
|
161
|
-
},
|
|
162
|
-
withdrawn: function () {
|
|
163
|
-
return new bn_js_1.default(0);
|
|
164
|
-
}, //phantom method to preserve partial support of this object
|
|
165
|
-
};
|
|
166
|
-
return resp;
|
|
167
|
-
};
|
|
168
|
-
exports.formatDecodedStream = formatDecodedStream;
|
|
169
|
-
/**
|
|
170
|
-
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
171
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
172
|
-
* @param {PublicKey} wallet - PublicKey to compare against.
|
|
173
|
-
* @param {number} offset - Offset of bits of the PublicKey in the account binary.
|
|
174
|
-
* @param {PublicKey} programId - Solana program ID.
|
|
175
|
-
* @return {Promise<Account[]>} - Array of resulting accounts.
|
|
176
|
-
*/
|
|
177
|
-
function getProgramAccounts(connection, wallet, offset, programId) {
|
|
178
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
179
|
-
return __generator(this, function (_a) {
|
|
180
|
-
return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(programId, {
|
|
181
|
-
filters: [
|
|
182
|
-
{
|
|
183
|
-
memcmp: {
|
|
184
|
-
offset: offset,
|
|
185
|
-
bytes: wallet.toBase58(),
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
})];
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
exports.getProgramAccounts = getProgramAccounts;
|
|
194
|
-
/**
|
|
195
|
-
* Utility function to check if the transaction initiator is a Wallet object
|
|
196
|
-
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
197
|
-
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
198
|
-
*/
|
|
199
|
-
function isSignerWallet(walletOrKeypair) {
|
|
200
|
-
return walletOrKeypair.signTransaction !== undefined;
|
|
201
|
-
}
|
|
202
|
-
exports.isSignerWallet = isSignerWallet;
|
|
203
|
-
/**
|
|
204
|
-
* Utility function to check if the transaction initiator a Keypair object, tries to mitigate version mismatch issues
|
|
205
|
-
* @param walletOrKeypair {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
|
|
206
|
-
* @returns {boolean} - Returns true if parameter is a Keypair.
|
|
207
|
-
*/
|
|
208
|
-
function isSignerKeypair(walletOrKeypair) {
|
|
209
|
-
return (walletOrKeypair instanceof web3_js_1.Keypair ||
|
|
210
|
-
walletOrKeypair.constructor === web3_js_1.Keypair ||
|
|
211
|
-
walletOrKeypair.constructor.name === web3_js_1.Keypair.prototype.constructor.name);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
215
|
-
* @param {Keypair | SignerWalletAdapter} sender - Wallet or Keypair of sendin account
|
|
216
|
-
* @param {BatchItem[]} items - Multiple recipient contracts split into separate items
|
|
217
|
-
* @return {BatchItem[]} - Returns items with signatures.
|
|
218
|
-
*/
|
|
219
|
-
function signAllTransactionWithRecipients(sender, items) {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
-
var isKeypair, isWallet, signedTxs_1;
|
|
222
|
-
return __generator(this, function (_a) {
|
|
223
|
-
switch (_a.label) {
|
|
224
|
-
case 0:
|
|
225
|
-
isKeypair = isSignerKeypair(sender);
|
|
226
|
-
isWallet = isSignerWallet(sender);
|
|
227
|
-
if (!isKeypair) return [3 /*break*/, 1];
|
|
228
|
-
return [2 /*return*/, items.map(function (t) {
|
|
229
|
-
t.tx.partialSign(sender);
|
|
230
|
-
return { tx: t.tx, recipient: t.recipient };
|
|
231
|
-
})];
|
|
232
|
-
case 1:
|
|
233
|
-
if (!isWallet) return [3 /*break*/, 3];
|
|
234
|
-
return [4 /*yield*/, sender.signAllTransactions(items.map(function (t) { return t.tx; }))];
|
|
235
|
-
case 2:
|
|
236
|
-
signedTxs_1 = _a.sent();
|
|
237
|
-
return [2 /*return*/, items.map(function (item, index) { return (__assign(__assign({}, item), { tx: signedTxs_1[index] })); })];
|
|
238
|
-
case 3:
|
|
239
|
-
// If signer is not passed
|
|
240
|
-
return [2 /*return*/, []];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
|
|
246
|
-
/**
|
|
247
|
-
* Sign passed BatchItems with wallet request or KeyPair
|
|
248
|
-
* @param {Connection} connection - Solana web3 connection object.
|
|
249
|
-
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
250
|
-
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
251
|
-
*/
|
|
252
|
-
function sendAndConfirmStreamRawTransaction(connection, batchItem) {
|
|
253
|
-
var _a, _b;
|
|
254
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
-
var rawTx, _c, lastValidBlockHeight, signature, recentBlockhash, confirmationStrategy, completedTxSignature, error_1;
|
|
256
|
-
return __generator(this, function (_d) {
|
|
257
|
-
switch (_d.label) {
|
|
258
|
-
case 0:
|
|
259
|
-
_d.trys.push([0, 2, , 3]);
|
|
260
|
-
rawTx = batchItem.tx.serialize();
|
|
261
|
-
_c = batchItem.tx, lastValidBlockHeight = _c.lastValidBlockHeight, signature = _c.signature, recentBlockhash = _c.recentBlockhash;
|
|
262
|
-
if (!lastValidBlockHeight || !signature || !recentBlockhash)
|
|
263
|
-
throw { recipient: batchItem.recipient, error: "no recent blockhash" };
|
|
264
|
-
confirmationStrategy = {
|
|
265
|
-
lastValidBlockHeight: lastValidBlockHeight,
|
|
266
|
-
signature: bs58_1.default.encode(signature),
|
|
267
|
-
blockhash: recentBlockhash,
|
|
268
|
-
};
|
|
269
|
-
return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
|
|
270
|
-
case 1:
|
|
271
|
-
completedTxSignature = _d.sent();
|
|
272
|
-
return [2 /*return*/, __assign(__assign({}, batchItem), { signature: completedTxSignature })];
|
|
273
|
-
case 2:
|
|
274
|
-
error_1 = _d.sent();
|
|
275
|
-
throw {
|
|
276
|
-
recipient: batchItem.recipient,
|
|
277
|
-
error: (_b = (_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.error) !== null && _a !== void 0 ? _a : error_1 === null || error_1 === void 0 ? void 0 : error_1.message) !== null && _b !== void 0 ? _b : error_1.toString(),
|
|
278
|
-
};
|
|
279
|
-
case 3: return [2 /*return*/];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
|
|
285
|
-
/**
|
|
286
|
-
* Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
|
|
287
|
-
* @param {PublicKey} mint - SPL token Mint address.
|
|
288
|
-
* @param {PublicKey} owner - Owner of the Associated Token Address
|
|
289
|
-
* @return {Promise<PublicKey>} - Associated Token Address
|
|
290
|
-
*/
|
|
291
|
-
function ata(mint, owner) {
|
|
292
|
-
return (0, spl_token_1.getAssociatedTokenAddress)(mint, owner, true);
|
|
293
|
-
}
|
|
294
|
-
exports.ata = ata;
|
|
295
|
-
function extractSolanaErrorCode(errorText) {
|
|
296
|
-
var match = constants_1.SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
297
|
-
if (!match) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
var errorCode = Number(match[1]);
|
|
301
|
-
return constants_1.SOLANA_ERROR_MAP[errorCode] || null;
|
|
302
|
-
}
|
|
303
|
-
exports.extractSolanaErrorCode = extractSolanaErrorCode;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
|
-
import { Contract, ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters } from "./types";
|
|
4
|
-
export default class SuiStreamClient extends BaseStreamClient {
|
|
5
|
-
private programId;
|
|
6
|
-
private configId;
|
|
7
|
-
private feeTableId;
|
|
8
|
-
private client;
|
|
9
|
-
constructor(clusterUrl: string, cluster?: ICluster, ids?: ISuiIdParameters);
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new stream/vesting contract.
|
|
12
|
-
*/
|
|
13
|
-
create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<ICreateResult>;
|
|
14
|
-
/**
|
|
15
|
-
* Creates multiple stream/vesting contracts.
|
|
16
|
-
* We don't chain transactions in one Block so that one failed transaction does not revert all others.
|
|
17
|
-
*/
|
|
18
|
-
createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<IMultiTransactionResult>;
|
|
19
|
-
/**
|
|
20
|
-
* Attempts withdrawing from the specified stream.
|
|
21
|
-
*/
|
|
22
|
-
withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
23
|
-
/**
|
|
24
|
-
* Attempts canceling the specified stream.
|
|
25
|
-
*/
|
|
26
|
-
cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
27
|
-
/**
|
|
28
|
-
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
29
|
-
*/
|
|
30
|
-
transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
31
|
-
/**
|
|
32
|
-
* Tops up stream account with specified amount.
|
|
33
|
-
*/
|
|
34
|
-
topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
35
|
-
/**
|
|
36
|
-
* Fetch stream data by its id (address).
|
|
37
|
-
*/
|
|
38
|
-
getOne({ id }: IGetOneData): Promise<Contract>;
|
|
39
|
-
get(): Promise<[string, Contract][]>;
|
|
40
|
-
/**
|
|
41
|
-
* Attempts updating the stream auto withdrawal params and amount per period
|
|
42
|
-
*/
|
|
43
|
-
update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
44
|
-
extractErrorCode(err: Error): string | null;
|
|
45
|
-
/**
|
|
46
|
-
* Returns StreamClient protocol program ID.
|
|
47
|
-
*/
|
|
48
|
-
getProgramId(): string;
|
|
49
|
-
/**
|
|
50
|
-
* Utility function to generate Transaction Block to create streams
|
|
51
|
-
*/
|
|
52
|
-
private generateCreateBlock;
|
|
53
|
-
/**
|
|
54
|
-
* Returns all coins owned by a Wallet
|
|
55
|
-
* @param walletAddress wallet address
|
|
56
|
-
* @param coinType coin type
|
|
57
|
-
* @returns Array of Coin Structs
|
|
58
|
-
*/
|
|
59
|
-
private getAllCoins;
|
|
60
|
-
/**
|
|
61
|
-
* Utility function to split Coin object and use splitted object for stream operations.
|
|
62
|
-
* We do it like thid to mitigate risk of Transaction reverting in case Stream is created for Sui Coin object.
|
|
63
|
-
* This way we can safely pass splitted Sui Coin object in Stream payload and use another object for gas/withdrawal fees.
|
|
64
|
-
* @param txb current transanction block
|
|
65
|
-
* @param amount minimal amount of coins requried
|
|
66
|
-
* @param coinType coin type
|
|
67
|
-
* @param coins array of owned coins of the same type
|
|
68
|
-
* @returns Coin Object to use in a Move Call
|
|
69
|
-
*/
|
|
70
|
-
private splitCoinObjectForAmount;
|
|
71
|
-
/**
|
|
72
|
-
* Return previously splitted Coin Object to owner and merge it to to rebate storage fees
|
|
73
|
-
* @param txb current transanction block
|
|
74
|
-
* @param coinType coin type
|
|
75
|
-
* @param coinObject splitted object
|
|
76
|
-
* @param coins array of objects used in
|
|
77
|
-
*/
|
|
78
|
-
private returnSplittedCoinObject;
|
|
79
|
-
}
|