@streamflow/stream 5.7.1 → 5.8.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/aptos/StreamClient.d.ts +3 -1
- package/dist/aptos/StreamClient.js +38 -0
- package/dist/aptos/types.d.ts +12 -0
- package/dist/common/BaseStreamClient.d.ts +3 -1
- package/dist/common/GenericStreamClient.d.ts +9 -1
- package/dist/common/GenericStreamClient.js +12 -0
- package/dist/common/types.d.ts +7 -0
- package/dist/evm/StreamClient.d.ts +3 -1
- package/dist/evm/StreamClient.js +33 -0
- package/dist/evm/types.d.ts +5 -0
- package/dist/solana/StreamClient.d.ts +3 -1
- package/dist/solana/StreamClient.js +58 -0
- package/dist/solana/constants.d.ts +32 -0
- package/dist/solana/constants.js +8 -1
- package/dist/solana/instructionTypes.d.ts +5 -0
- package/dist/solana/layout.d.ts +2 -1
- package/dist/solana/layout.js +6 -1
- package/dist/sui/StreamClient.d.ts +3 -1
- package/dist/sui/StreamClient.js +72 -0
- package/dist/sui/types.d.ts +26 -0
- package/package.json +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
2
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
3
|
import { Contract, ICreateStreamAptosExt, ITransactionAptosExt } from "./types";
|
|
4
4
|
export default class AptosStreamClient extends BaseStreamClient {
|
|
5
5
|
private programId;
|
|
@@ -39,6 +39,8 @@ export default class AptosStreamClient extends BaseStreamClient {
|
|
|
39
39
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
40
40
|
*/
|
|
41
41
|
update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
|
|
42
|
+
getFees({ address }: IGetFeesData): Promise<IFees | null>;
|
|
43
|
+
getDefaultStreamflowFee(): Promise<number>;
|
|
42
44
|
extractErrorCode(err: Error): string | null;
|
|
43
45
|
/**
|
|
44
46
|
* Returns StreamClient protocol program ID.
|
|
@@ -333,6 +333,44 @@ var AptosStreamClient = /** @class */ (function (_super) {
|
|
|
333
333
|
});
|
|
334
334
|
});
|
|
335
335
|
};
|
|
336
|
+
AptosStreamClient.prototype.getFees = function (_a) {
|
|
337
|
+
var address = _a.address;
|
|
338
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
339
|
+
var resource, data, value;
|
|
340
|
+
return __generator(this, function (_b) {
|
|
341
|
+
switch (_b.label) {
|
|
342
|
+
case 0: return [4 /*yield*/, this.client.getAccountResource(this.programId, "".concat(this.programId, "::fees::FeeTable"))];
|
|
343
|
+
case 1:
|
|
344
|
+
resource = _b.sent();
|
|
345
|
+
data = resource.data;
|
|
346
|
+
return [4 /*yield*/, this.client.getTableItem(data.values.handle, {
|
|
347
|
+
key_type: "address",
|
|
348
|
+
key: address,
|
|
349
|
+
value_type: "u64",
|
|
350
|
+
})];
|
|
351
|
+
case 2:
|
|
352
|
+
value = _b.sent();
|
|
353
|
+
if (!value) {
|
|
354
|
+
return [2 /*return*/, null];
|
|
355
|
+
}
|
|
356
|
+
return [2 /*return*/, { streamflowFee: Number(value) / 100, partnerFee: 0 }];
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
AptosStreamClient.prototype.getDefaultStreamflowFee = function () {
|
|
362
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
363
|
+
var resource;
|
|
364
|
+
return __generator(this, function (_a) {
|
|
365
|
+
switch (_a.label) {
|
|
366
|
+
case 0: return [4 /*yield*/, this.client.getAccountResource(this.programId, "".concat(this.programId, "::admin::ConfigV2"))];
|
|
367
|
+
case 1:
|
|
368
|
+
resource = _a.sent();
|
|
369
|
+
return [2 /*return*/, Number(resource.data.streamflow_fees) / 100];
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
};
|
|
336
374
|
AptosStreamClient.prototype.extractErrorCode = function (err) {
|
|
337
375
|
var _a;
|
|
338
376
|
return (0, utils_1.extractAptosErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
|
package/dist/aptos/types.d.ts
CHANGED
|
@@ -47,6 +47,18 @@ export interface StreamResource {
|
|
|
47
47
|
start: string;
|
|
48
48
|
withdrawn: string;
|
|
49
49
|
}
|
|
50
|
+
export interface FeeTableResource {
|
|
51
|
+
values: {
|
|
52
|
+
handle: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export interface ConfigResource {
|
|
56
|
+
admin: string;
|
|
57
|
+
streamflow_fees: string;
|
|
58
|
+
treasury: string;
|
|
59
|
+
tx_fee: string;
|
|
60
|
+
withdrawor: string;
|
|
61
|
+
}
|
|
50
62
|
export declare class Contract implements Stream {
|
|
51
63
|
magic: number;
|
|
52
64
|
version: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICreateStreamData, ICreateMultipleStreamData, IWithdrawData, ICancelData, ITransferData, ITopUpData, IGetOneData, IUpdateData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData, Stream } from "./types";
|
|
1
|
+
import { ICreateStreamData, ICreateMultipleStreamData, IFees, IWithdrawData, ICancelData, ITransferData, ITopUpData, IGetFeesData, IGetOneData, IUpdateData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData, Stream } from "./types";
|
|
2
2
|
export declare abstract class BaseStreamClient {
|
|
3
3
|
abstract create(streamData: ICreateStreamData, chainSpecificParams: any): Promise<ICreateResult>;
|
|
4
4
|
abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: any): Promise<IMultiTransactionResult>;
|
|
@@ -9,5 +9,7 @@ export declare abstract class BaseStreamClient {
|
|
|
9
9
|
abstract getOne(getOneData: IGetOneData, chainSpecificParams: any): Promise<Stream>;
|
|
10
10
|
abstract get(getAllData: IGetAllData, chainSpecificParams: any): Promise<[string, Stream][]>;
|
|
11
11
|
abstract update(updateData: IUpdateData, chainSpecificParams: any): Promise<ITransactionResult>;
|
|
12
|
+
abstract getFees(getFeesData: IGetFeesData, chainSpecificParams: any): Promise<IFees | null>;
|
|
13
|
+
abstract getDefaultStreamflowFee(chainSpecificParams: any): Promise<number>;
|
|
12
14
|
extractErrorCode(err: Error): string | null;
|
|
13
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
2
|
import { Signer } from "ethers";
|
|
3
3
|
import { BaseStreamClient } from "./BaseStreamClient";
|
|
4
|
-
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData, Stream } from "./types";
|
|
4
|
+
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData, Stream, IFees, IGetFeesData } from "./types";
|
|
5
5
|
import { AptosStreamClient, ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos";
|
|
6
6
|
import { EvmStreamClient } from "../evm";
|
|
7
7
|
import { SolanaStreamClient, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "../solana";
|
|
@@ -89,5 +89,13 @@ export default class GenericStreamClient<T extends IChain> extends BaseStreamCli
|
|
|
89
89
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
90
90
|
*/
|
|
91
91
|
update(updateData: IUpdateData, chainSpecificParams?: InteractSpecificParams<T>): Promise<ITransactionResult>;
|
|
92
|
+
/**
|
|
93
|
+
* Returns streamflow and partner fees for the specific wallet in %
|
|
94
|
+
*/
|
|
95
|
+
getFees(getFeesData: IGetFeesData): Promise<IFees | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns default Streamflow Fee in %
|
|
98
|
+
*/
|
|
99
|
+
getDefaultStreamflowFee(): Promise<number>;
|
|
92
100
|
}
|
|
93
101
|
export {};
|
|
@@ -109,6 +109,18 @@ var GenericStreamClient = /** @class */ (function (_super) {
|
|
|
109
109
|
var _this = this;
|
|
110
110
|
return (0, utils_1.handleContractError)(function () { return _this.nativeStreamClient.update(updateData, chainSpecificParams); }, this.nativeStreamClient.extractErrorCode);
|
|
111
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Returns streamflow and partner fees for the specific wallet in %
|
|
114
|
+
*/
|
|
115
|
+
GenericStreamClient.prototype.getFees = function (getFeesData) {
|
|
116
|
+
return this.nativeStreamClient.getFees(getFeesData);
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Returns default Streamflow Fee in %
|
|
120
|
+
*/
|
|
121
|
+
GenericStreamClient.prototype.getDefaultStreamflowFee = function () {
|
|
122
|
+
return this.nativeStreamClient.getDefaultStreamflowFee();
|
|
123
|
+
};
|
|
112
124
|
return GenericStreamClient;
|
|
113
125
|
}(BaseStreamClient_1.BaseStreamClient));
|
|
114
126
|
exports.default = GenericStreamClient;
|
package/dist/common/types.d.ts
CHANGED
|
@@ -52,6 +52,9 @@ export interface ITopUpData {
|
|
|
52
52
|
export interface IGetOneData {
|
|
53
53
|
id: string;
|
|
54
54
|
}
|
|
55
|
+
export interface IGetFeesData {
|
|
56
|
+
address: string;
|
|
57
|
+
}
|
|
55
58
|
export interface IGetAllData {
|
|
56
59
|
address: string;
|
|
57
60
|
type?: StreamType;
|
|
@@ -67,6 +70,10 @@ export interface ITransactionResult {
|
|
|
67
70
|
ixs: (TransactionInstruction | Types.TransactionPayload)[];
|
|
68
71
|
txId: string;
|
|
69
72
|
}
|
|
73
|
+
export interface IFees {
|
|
74
|
+
streamflowFee: number;
|
|
75
|
+
partnerFee: number;
|
|
76
|
+
}
|
|
70
77
|
export interface ICreateResult extends ITransactionResult {
|
|
71
78
|
metadataId: MetadataId;
|
|
72
79
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import BN from "bn.js";
|
|
3
3
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
4
|
-
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
4
|
+
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetAllData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
5
5
|
export default class EvmStreamClient extends BaseStreamClient {
|
|
6
6
|
private programId;
|
|
7
7
|
private provider;
|
|
@@ -19,6 +19,8 @@ export default class EvmStreamClient extends BaseStreamClient {
|
|
|
19
19
|
getOne({ id }: IGetOneData): Promise<Stream>;
|
|
20
20
|
get({ address, direction, }: IGetAllData): Promise<[string, Stream][]>;
|
|
21
21
|
extractErrorCode(err: Error): string | null;
|
|
22
|
+
getFees({ address }: IGetFeesData): Promise<IFees | null>;
|
|
23
|
+
getDefaultStreamflowFee(): Promise<number>;
|
|
22
24
|
/**
|
|
23
25
|
* Returns StreamClient protocol program ID.
|
|
24
26
|
*/
|
package/dist/evm/StreamClient.js
CHANGED
|
@@ -371,6 +371,39 @@ var EvmStreamClient = /** @class */ (function (_super) {
|
|
|
371
371
|
var _a;
|
|
372
372
|
return (0, utils_1.extractEvmErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
|
|
373
373
|
};
|
|
374
|
+
EvmStreamClient.prototype.getFees = function (_a) {
|
|
375
|
+
var address = _a.address;
|
|
376
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
+
var fees;
|
|
378
|
+
return __generator(this, function (_b) {
|
|
379
|
+
switch (_b.label) {
|
|
380
|
+
case 0: return [4 /*yield*/, this.readContract.getFees(address)];
|
|
381
|
+
case 1:
|
|
382
|
+
fees = _b.sent();
|
|
383
|
+
if (!fees.exists) {
|
|
384
|
+
return [2 /*return*/, null];
|
|
385
|
+
}
|
|
386
|
+
return [2 /*return*/, {
|
|
387
|
+
streamflowFee: fees.streamflow_fee.toNumber() / 100,
|
|
388
|
+
partnerFee: fees.partner_fee.toNumber() / 100,
|
|
389
|
+
}];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
EvmStreamClient.prototype.getDefaultStreamflowFee = function () {
|
|
395
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
396
|
+
var fee;
|
|
397
|
+
return __generator(this, function (_a) {
|
|
398
|
+
switch (_a.label) {
|
|
399
|
+
case 0: return [4 /*yield*/, this.readContract.getStreamflowFees()];
|
|
400
|
+
case 1:
|
|
401
|
+
fee = _a.sent();
|
|
402
|
+
return [2 /*return*/, fee.toNumber() / 100];
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
};
|
|
374
407
|
/**
|
|
375
408
|
* Returns StreamClient protocol program ID.
|
|
376
409
|
*/
|
package/dist/evm/types.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export interface StreamAbiResult {
|
|
|
43
43
|
token: string;
|
|
44
44
|
withdrawn: BigNumber;
|
|
45
45
|
}
|
|
46
|
+
export interface FeesAbiResult {
|
|
47
|
+
exists: boolean;
|
|
48
|
+
streamflow_fee: BigNumber;
|
|
49
|
+
partner_fee: BigNumber;
|
|
50
|
+
}
|
|
46
51
|
export declare class EvmContract implements Stream {
|
|
47
52
|
magic: number;
|
|
48
53
|
version: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
2
|
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
|
|
3
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
3
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
4
4
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
5
5
|
export default class SolanaStreamClient extends BaseStreamClient {
|
|
6
6
|
private connection;
|
|
@@ -64,6 +64,8 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
64
64
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
65
65
|
*/
|
|
66
66
|
update(data: IUpdateData, { invoker }: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
67
|
+
getFees({ address }: IGetFeesData): Promise<IFees | null>;
|
|
68
|
+
getDefaultStreamflowFee(): Promise<number>;
|
|
67
69
|
extractErrorCode(err: Error): string | null;
|
|
68
70
|
/**
|
|
69
71
|
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
|
@@ -26,6 +26,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
26
26
|
};
|
|
27
27
|
return __assign.apply(this, arguments);
|
|
28
28
|
};
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
41
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
42
|
+
}) : function(o, v) {
|
|
43
|
+
o["default"] = v;
|
|
44
|
+
});
|
|
45
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
46
|
+
if (mod && mod.__esModule) return mod;
|
|
47
|
+
var result = {};
|
|
48
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
29
52
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
30
53
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
54
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -107,6 +130,7 @@ var buffer_1 = require("buffer");
|
|
|
107
130
|
var bs58_1 = __importDefault(require("bs58"));
|
|
108
131
|
var spl_token_1 = require("@solana/spl-token");
|
|
109
132
|
var web3_js_1 = require("@solana/web3.js");
|
|
133
|
+
var borsh = __importStar(require("borsh"));
|
|
110
134
|
var types_1 = require("./types");
|
|
111
135
|
var utils_1 = require("./utils");
|
|
112
136
|
var constants_1 = require("./constants");
|
|
@@ -861,6 +885,40 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
861
885
|
});
|
|
862
886
|
});
|
|
863
887
|
};
|
|
888
|
+
SolanaStreamClient.prototype.getFees = function (_a) {
|
|
889
|
+
var address = _a.address;
|
|
890
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
891
|
+
var _b, metadataPubKey, data, partners, filteredPartners;
|
|
892
|
+
return __generator(this, function (_c) {
|
|
893
|
+
switch (_c.label) {
|
|
894
|
+
case 0:
|
|
895
|
+
_b = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from(constants_1.FEES_METADATA_SEED)], new web3_js_1.PublicKey(constants_1.PARTNER_ORACLE_PROGRAM_ID)), 1), metadataPubKey = _b[0];
|
|
896
|
+
return [4 /*yield*/, this.connection.getAccountInfo(metadataPubKey)];
|
|
897
|
+
case 1:
|
|
898
|
+
data = _c.sent();
|
|
899
|
+
if (!data) {
|
|
900
|
+
return [2 /*return*/, null];
|
|
901
|
+
}
|
|
902
|
+
partners = borsh.deserialize(constants_1.PARTNERS_SCHEMA, data.data);
|
|
903
|
+
filteredPartners = partners.filter(function (item) { return new web3_js_1.PublicKey(item.pubkey).toString() === address; });
|
|
904
|
+
if (filteredPartners.length === 0) {
|
|
905
|
+
return [2 /*return*/, null];
|
|
906
|
+
}
|
|
907
|
+
return [2 /*return*/, {
|
|
908
|
+
streamflowFee: Number(filteredPartners[0].strm_fee.toFixed(4)),
|
|
909
|
+
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4)),
|
|
910
|
+
}];
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
SolanaStreamClient.prototype.getDefaultStreamflowFee = function () {
|
|
916
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
917
|
+
return __generator(this, function (_a) {
|
|
918
|
+
return [2 /*return*/, constants_1.DEFAULT_STREAMFLOW_FEE];
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
};
|
|
864
922
|
SolanaStreamClient.prototype.extractErrorCode = function (err) {
|
|
865
923
|
var _a;
|
|
866
924
|
return (0, utils_1.extractSolanaErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { PublicKey } from "@solana/web3.js";
|
|
2
3
|
export declare const TX_FINALITY_CONFIRMED = "confirmed";
|
|
3
4
|
export declare const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
@@ -11,11 +12,42 @@ export declare const PROGRAM_ID: {
|
|
|
11
12
|
};
|
|
12
13
|
export declare const STREAMFLOW_PROGRAM_ID = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m";
|
|
13
14
|
export declare const STREAMFLOW_DEVNET_PROGRAM_ID = "FGjLaVo5zLGdzCxMo9gu9tXr1kzTToKd8C8K7YS5hNM1";
|
|
15
|
+
export declare const PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
14
16
|
export declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
|
|
15
17
|
export declare const WITHDRAWOR_PUBLIC_KEY: PublicKey;
|
|
16
18
|
export declare const FEE_ORACLE_PUBLIC_KEY: PublicKey;
|
|
17
19
|
export declare const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
20
|
+
export declare const FEES_METADATA_SEED: Buffer;
|
|
21
|
+
export declare const DEFAULT_STREAMFLOW_FEE = 0.99;
|
|
18
22
|
export declare const AIRDROP_AMOUNT = 1;
|
|
23
|
+
export declare const PARTNER_SCHEMA: {
|
|
24
|
+
struct: {
|
|
25
|
+
pubkey: {
|
|
26
|
+
array: {
|
|
27
|
+
type: string;
|
|
28
|
+
len: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
partner_fee: string;
|
|
32
|
+
strm_fee: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const PARTNERS_SCHEMA: {
|
|
36
|
+
array: {
|
|
37
|
+
type: {
|
|
38
|
+
struct: {
|
|
39
|
+
pubkey: {
|
|
40
|
+
array: {
|
|
41
|
+
type: string;
|
|
42
|
+
len: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
partner_fee: string;
|
|
46
|
+
strm_fee: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
19
51
|
export declare const SOLANA_ERROR_MATCH_REGEX: RegExp;
|
|
20
52
|
export declare const SOLANA_ERROR_MAP: {
|
|
21
53
|
[key: number]: string;
|
package/dist/solana/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SOLANA_ERROR_MAP = exports.SOLANA_ERROR_MATCH_REGEX = exports.AIRDROP_AMOUNT = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.STREAMFLOW_DEVNET_PROGRAM_ID = exports.STREAMFLOW_PROGRAM_ID = exports.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
4
|
+
exports.SOLANA_ERROR_MAP = exports.SOLANA_ERROR_MATCH_REGEX = exports.PARTNERS_SCHEMA = exports.PARTNER_SCHEMA = exports.AIRDROP_AMOUNT = exports.DEFAULT_STREAMFLOW_FEE = exports.FEES_METADATA_SEED = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.PARTNER_ORACLE_PROGRAM_ID = exports.STREAMFLOW_DEVNET_PROGRAM_ID = exports.STREAMFLOW_PROGRAM_ID = exports.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
5
5
|
var web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
var types_1 = require("../common/types");
|
|
7
7
|
exports.TX_FINALITY_CONFIRMED = "confirmed";
|
|
@@ -17,11 +17,18 @@ exports.PROGRAM_ID = (_a = {},
|
|
|
17
17
|
_a);
|
|
18
18
|
exports.STREAMFLOW_PROGRAM_ID = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m";
|
|
19
19
|
exports.STREAMFLOW_DEVNET_PROGRAM_ID = "FGjLaVo5zLGdzCxMo9gu9tXr1kzTToKd8C8K7YS5hNM1";
|
|
20
|
+
exports.PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
20
21
|
exports.STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js_1.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
21
22
|
exports.WITHDRAWOR_PUBLIC_KEY = new web3_js_1.PublicKey("wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u");
|
|
22
23
|
exports.FEE_ORACLE_PUBLIC_KEY = new web3_js_1.PublicKey("B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT");
|
|
23
24
|
exports.AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
25
|
+
exports.FEES_METADATA_SEED = Buffer.from("strm_fees");
|
|
26
|
+
exports.DEFAULT_STREAMFLOW_FEE = 0.99;
|
|
24
27
|
exports.AIRDROP_AMOUNT = 1; // 1 SOL is the cap on the testnet
|
|
28
|
+
exports.PARTNER_SCHEMA = {
|
|
29
|
+
struct: { pubkey: { array: { type: "u8", len: 32 } }, partner_fee: "f32", strm_fee: "f32" },
|
|
30
|
+
};
|
|
31
|
+
exports.PARTNERS_SCHEMA = { array: { type: exports.PARTNER_SCHEMA } };
|
|
25
32
|
exports.SOLANA_ERROR_MATCH_REGEX = /custom program error: (0x\d{2})/;
|
|
26
33
|
exports.SOLANA_ERROR_MAP = {
|
|
27
34
|
0x60: types_1.SolanaContractErrorCode.AccountsNotWritable,
|
package/dist/solana/layout.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as BufferLayout from "@solana/buffer-layout";
|
|
3
|
-
import { ICreateStreamLayout, ICreateUncheckedStreamLayout, IStreamLayout, ITopupStreamLayout, IUpdateStreamLayout, IWithdrawStreamLayout } from "./instructionTypes";
|
|
3
|
+
import { ICreateStreamLayout, ICreateUncheckedStreamLayout, IPartnerLayout, IStreamLayout, ITopupStreamLayout, IUpdateStreamLayout, IWithdrawStreamLayout } from "./instructionTypes";
|
|
4
4
|
/**
|
|
5
5
|
* Stream layout
|
|
6
6
|
*/
|
|
7
7
|
export declare const streamLayout: BufferLayout.Structure<IStreamLayout>;
|
|
8
|
+
export declare const partnerLayout: BufferLayout.Structure<IPartnerLayout>;
|
|
8
9
|
/**
|
|
9
10
|
* Create stream instruction layout
|
|
10
11
|
*/
|
package/dist/solana/layout.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.topupStreamLayout = exports.encodeUpdateStream = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
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
28
|
var constants_1 = require("./constants");
|
|
29
29
|
/**
|
|
@@ -79,6 +79,11 @@ exports.streamLayout = BufferLayout.struct([
|
|
|
79
79
|
BufferLayout.blob(8, "last_rate_change_time"),
|
|
80
80
|
BufferLayout.blob(8, "funds_unlocked_at_last_rate_change"),
|
|
81
81
|
]);
|
|
82
|
+
exports.partnerLayout = BufferLayout.struct([
|
|
83
|
+
BufferLayout.blob(32, "pubkey"),
|
|
84
|
+
BufferLayout.f32("partner_fee"),
|
|
85
|
+
BufferLayout.f32("strm_fee"),
|
|
86
|
+
]);
|
|
82
87
|
/**
|
|
83
88
|
* Create stream instruction layout
|
|
84
89
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
2
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
3
|
import { Contract, ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters } from "./types";
|
|
4
4
|
export default class SuiStreamClient extends BaseStreamClient {
|
|
5
5
|
private programId;
|
|
@@ -42,6 +42,8 @@ export default class SuiStreamClient extends BaseStreamClient {
|
|
|
42
42
|
*/
|
|
43
43
|
update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
44
44
|
extractErrorCode(err: Error): string | null;
|
|
45
|
+
getFees({ address }: IGetFeesData): Promise<IFees | null>;
|
|
46
|
+
getDefaultStreamflowFee(): Promise<number>;
|
|
45
47
|
/**
|
|
46
48
|
* Returns StreamClient protocol program ID.
|
|
47
49
|
*/
|
package/dist/sui/StreamClient.js
CHANGED
|
@@ -438,6 +438,78 @@ var SuiStreamClient = /** @class */ (function (_super) {
|
|
|
438
438
|
var errorInfo = (0, utils_2.extractSuiErrorInfo)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!");
|
|
439
439
|
return ((_b = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.parsed) === null || _b === void 0 ? void 0 : _b.name) || null;
|
|
440
440
|
};
|
|
441
|
+
SuiStreamClient.prototype.getFees = function (_a) {
|
|
442
|
+
var address = _a.address;
|
|
443
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
444
|
+
var response, content, fields, fieldsResponse, partnerDynamicField, valueResponse, valueContent, valueFields;
|
|
445
|
+
return __generator(this, function (_b) {
|
|
446
|
+
switch (_b.label) {
|
|
447
|
+
case 0: return [4 /*yield*/, this.client.getObject({
|
|
448
|
+
id: this.feeTableId,
|
|
449
|
+
options: {
|
|
450
|
+
showContent: true,
|
|
451
|
+
},
|
|
452
|
+
})];
|
|
453
|
+
case 1:
|
|
454
|
+
response = _b.sent();
|
|
455
|
+
content = response.data.content;
|
|
456
|
+
if (content.dataType !== "moveObject") {
|
|
457
|
+
throw new Error("Not a Move Object!");
|
|
458
|
+
}
|
|
459
|
+
fields = content.fields;
|
|
460
|
+
return [4 /*yield*/, this.client.getDynamicFields({
|
|
461
|
+
parentId: fields.values.fields.id.id,
|
|
462
|
+
})];
|
|
463
|
+
case 2:
|
|
464
|
+
fieldsResponse = _b.sent();
|
|
465
|
+
partnerDynamicField = fieldsResponse.data.filter(function (item) { return item.name.value === address; })[0];
|
|
466
|
+
if (!partnerDynamicField) {
|
|
467
|
+
return [2 /*return*/, null];
|
|
468
|
+
}
|
|
469
|
+
return [4 /*yield*/, this.client.getObject({
|
|
470
|
+
id: partnerDynamicField.objectId,
|
|
471
|
+
options: {
|
|
472
|
+
showContent: true,
|
|
473
|
+
},
|
|
474
|
+
})];
|
|
475
|
+
case 3:
|
|
476
|
+
valueResponse = _b.sent();
|
|
477
|
+
valueContent = valueResponse.data.content;
|
|
478
|
+
if (valueContent.dataType !== "moveObject") {
|
|
479
|
+
throw new Error("Not a Move Object!");
|
|
480
|
+
}
|
|
481
|
+
valueFields = valueContent.fields.value.fields;
|
|
482
|
+
return [2 /*return*/, {
|
|
483
|
+
streamflowFee: Number(valueFields.streamflow_fee) / 100,
|
|
484
|
+
partnerFee: Number(valueFields.partner_fee) / 100,
|
|
485
|
+
}];
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
SuiStreamClient.prototype.getDefaultStreamflowFee = function () {
|
|
491
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
492
|
+
var response, content, fields;
|
|
493
|
+
return __generator(this, function (_a) {
|
|
494
|
+
switch (_a.label) {
|
|
495
|
+
case 0: return [4 /*yield*/, this.client.getObject({
|
|
496
|
+
id: this.configId,
|
|
497
|
+
options: {
|
|
498
|
+
showContent: true,
|
|
499
|
+
},
|
|
500
|
+
})];
|
|
501
|
+
case 1:
|
|
502
|
+
response = _a.sent();
|
|
503
|
+
content = response.data.content;
|
|
504
|
+
if (content.dataType !== "moveObject") {
|
|
505
|
+
throw new Error("Not a Move Object!");
|
|
506
|
+
}
|
|
507
|
+
fields = content.fields;
|
|
508
|
+
return [2 /*return*/, Number(fields.streamflow_fee) / 100];
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
};
|
|
441
513
|
/**
|
|
442
514
|
* Returns StreamClient protocol program ID.
|
|
443
515
|
*/
|
package/dist/sui/types.d.ts
CHANGED
|
@@ -76,6 +76,32 @@ export interface StreamResource {
|
|
|
76
76
|
version: string;
|
|
77
77
|
withdrawn: string;
|
|
78
78
|
}
|
|
79
|
+
export interface ClassResource {
|
|
80
|
+
streamflow_fee: string;
|
|
81
|
+
treasury: string;
|
|
82
|
+
tx_fee: string;
|
|
83
|
+
withdrawor: string;
|
|
84
|
+
}
|
|
85
|
+
export interface FeeTableResource {
|
|
86
|
+
values: {
|
|
87
|
+
type: string;
|
|
88
|
+
fields: {
|
|
89
|
+
id: {
|
|
90
|
+
id: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export interface FeeValueResource {
|
|
96
|
+
name: string;
|
|
97
|
+
value: {
|
|
98
|
+
type: string;
|
|
99
|
+
fields: {
|
|
100
|
+
partner_fee: string;
|
|
101
|
+
streamflow_fee: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
}
|
|
79
105
|
export declare class Contract implements Stream {
|
|
80
106
|
magic: number;
|
|
81
107
|
version: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
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": "
|
|
14
|
+
"gitHead": "ecf966f368ec55343cb346827a8e26b8b5237db7",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/bn.js": "5.1.1",
|
|
17
17
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@suiet/wallet-kit": "0.2.18",
|
|
39
39
|
"aptos": "1.4.0",
|
|
40
40
|
"bn.js": "5.2.1",
|
|
41
|
+
"borsh": "^2.0.0",
|
|
41
42
|
"bs58": "5.0.0",
|
|
42
43
|
"ethereum-checksum-address": "0.0.8",
|
|
43
44
|
"ethers": "5.7.2",
|