@zebec-network/zebec-stream-sdk 3.3.0 → 3.3.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.
@@ -13,6 +13,48 @@ export type ZebecStream = {
13
13
  description: "Created with Anchor";
14
14
  };
15
15
  instructions: [
16
+ {
17
+ name: "addFeeToken";
18
+ discriminator: [171, 6, 150, 97, 69, 55, 13, 136];
19
+ accounts: [
20
+ {
21
+ name: "admin";
22
+ writable: true;
23
+ signer: true;
24
+ },
25
+ {
26
+ name: "streamConfig";
27
+ writable: true;
28
+ pda: {
29
+ seeds: [
30
+ {
31
+ kind: "const";
32
+ value: [99, 111, 110, 102, 105, 103];
33
+ },
34
+ {
35
+ kind: "account";
36
+ path: "stream_config.config_name";
37
+ account: "streamConfig";
38
+ }
39
+ ];
40
+ };
41
+ },
42
+ {
43
+ name: "systemProgram";
44
+ address: "11111111111111111111111111111111";
45
+ }
46
+ ];
47
+ args: [
48
+ {
49
+ name: "params";
50
+ type: {
51
+ defined: {
52
+ name: "addFeeTokenParams";
53
+ };
54
+ };
55
+ }
56
+ ];
57
+ },
16
58
  {
17
59
  name: "cancelStream";
18
60
  discriminator: [218, 221, 38, 25, 177, 207, 188, 91];
@@ -504,6 +546,48 @@ export type ZebecStream = {
504
546
  ];
505
547
  args: [];
506
548
  },
549
+ {
550
+ name: "removeWhitelist";
551
+ discriminator: [148, 244, 73, 234, 131, 55, 247, 90];
552
+ accounts: [
553
+ {
554
+ name: "admin";
555
+ writable: true;
556
+ signer: true;
557
+ },
558
+ {
559
+ name: "streamConfig";
560
+ writable: true;
561
+ pda: {
562
+ seeds: [
563
+ {
564
+ kind: "const";
565
+ value: [99, 111, 110, 102, 105, 103];
566
+ },
567
+ {
568
+ kind: "account";
569
+ path: "stream_config.config_name";
570
+ account: "streamConfig";
571
+ }
572
+ ];
573
+ };
574
+ },
575
+ {
576
+ name: "systemProgram";
577
+ address: "11111111111111111111111111111111";
578
+ }
579
+ ];
580
+ args: [
581
+ {
582
+ name: "params";
583
+ type: {
584
+ defined: {
585
+ name: "removeWhitelistParams";
586
+ };
587
+ };
588
+ }
589
+ ];
590
+ },
507
591
  {
508
592
  name: "updateConfig";
509
593
  discriminator: [29, 158, 252, 191, 10, 83, 219, 99];
@@ -898,6 +982,18 @@ export type ZebecStream = {
898
982
  }
899
983
  ];
900
984
  types: [
985
+ {
986
+ name: "addFeeTokenParams";
987
+ type: {
988
+ kind: "struct";
989
+ fields: [
990
+ {
991
+ name: "token";
992
+ type: "pubkey";
993
+ }
994
+ ];
995
+ };
996
+ },
901
997
  {
902
998
  name: "burnEvent";
903
999
  type: {
@@ -1144,6 +1240,20 @@ export type ZebecStream = {
1144
1240
  ];
1145
1241
  };
1146
1242
  },
1243
+ {
1244
+ name: "removeWhitelistParams";
1245
+ type: {
1246
+ kind: "struct";
1247
+ fields: [
1248
+ {
1249
+ name: "tokens";
1250
+ type: {
1251
+ vec: "pubkey";
1252
+ };
1253
+ }
1254
+ ];
1255
+ };
1256
+ },
1147
1257
  {
1148
1258
  name: "streamCancelEvent";
1149
1259
  type: {
@@ -155,6 +155,48 @@
155
155
  }
156
156
  ],
157
157
  "instructions": [
158
+ {
159
+ "accounts": [
160
+ {
161
+ "name": "admin",
162
+ "signer": true,
163
+ "writable": true
164
+ },
165
+ {
166
+ "name": "stream_config",
167
+ "pda": {
168
+ "seeds": [
169
+ {
170
+ "kind": "const",
171
+ "value": [99, 111, 110, 102, 105, 103]
172
+ },
173
+ {
174
+ "account": "StreamConfig",
175
+ "kind": "account",
176
+ "path": "stream_config.config_name"
177
+ }
178
+ ]
179
+ },
180
+ "writable": true
181
+ },
182
+ {
183
+ "address": "11111111111111111111111111111111",
184
+ "name": "system_program"
185
+ }
186
+ ],
187
+ "args": [
188
+ {
189
+ "name": "params",
190
+ "type": {
191
+ "defined": {
192
+ "name": "AddFeeTokenParams"
193
+ }
194
+ }
195
+ }
196
+ ],
197
+ "discriminator": [171, 6, 150, 97, 69, 55, 13, 136],
198
+ "name": "add_fee_token"
199
+ },
158
200
  {
159
201
  "accounts": [
160
202
  {
@@ -472,6 +514,48 @@
472
514
  "discriminator": [173, 142, 243, 94, 154, 175, 5, 170],
473
515
  "name": "pause_resume_stream"
474
516
  },
517
+ {
518
+ "accounts": [
519
+ {
520
+ "name": "admin",
521
+ "signer": true,
522
+ "writable": true
523
+ },
524
+ {
525
+ "name": "stream_config",
526
+ "pda": {
527
+ "seeds": [
528
+ {
529
+ "kind": "const",
530
+ "value": [99, 111, 110, 102, 105, 103]
531
+ },
532
+ {
533
+ "account": "StreamConfig",
534
+ "kind": "account",
535
+ "path": "stream_config.config_name"
536
+ }
537
+ ]
538
+ },
539
+ "writable": true
540
+ },
541
+ {
542
+ "address": "11111111111111111111111111111111",
543
+ "name": "system_program"
544
+ }
545
+ ],
546
+ "args": [
547
+ {
548
+ "name": "params",
549
+ "type": {
550
+ "defined": {
551
+ "name": "RemoveWhitelistParams"
552
+ }
553
+ }
554
+ }
555
+ ],
556
+ "discriminator": [148, 244, 73, 234, 131, 55, 247, 90],
557
+ "name": "remove_whitelist"
558
+ },
475
559
  {
476
560
  "accounts": [
477
561
  {
@@ -667,6 +751,18 @@
667
751
  "version": "0.1.0"
668
752
  },
669
753
  "types": [
754
+ {
755
+ "name": "AddFeeTokenParams",
756
+ "type": {
757
+ "fields": [
758
+ {
759
+ "name": "token",
760
+ "type": "pubkey"
761
+ }
762
+ ],
763
+ "kind": "struct"
764
+ }
765
+ },
670
766
  {
671
767
  "name": "BurnEvent",
672
768
  "type": {
@@ -913,6 +1009,20 @@
913
1009
  "kind": "struct"
914
1010
  }
915
1011
  },
1012
+ {
1013
+ "name": "RemoveWhitelistParams",
1014
+ "type": {
1015
+ "fields": [
1016
+ {
1017
+ "name": "tokens",
1018
+ "type": {
1019
+ "vec": "pubkey"
1020
+ }
1021
+ }
1022
+ ],
1023
+ "kind": "struct"
1024
+ }
1025
+ },
916
1026
  {
917
1027
  "name": "StreamCancelEvent",
918
1028
  "type": {
@@ -1,4 +1,4 @@
1
- import type { RpcNetwork } from './types';
1
+ import type { RpcNetwork } from "./types";
2
2
  export declare const STREAM_NAME_BUFFER_SIZE = 128;
3
3
  export declare const STREAM_PROGRAM_ID: Record<RpcNetwork, string>;
4
4
  export declare const STREAM_PROGRAM_LOOKUP_TABLE_ADDRESS: Record<RpcNetwork, string>;
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ZebecStreamService = void 0;
7
4
  const anchor_1 = require("@coral-xyz/anchor");
@@ -12,7 +9,6 @@ const spl_token_1 = require("@solana/spl-token");
12
9
  const web3_js_1 = require("@solana/web3.js");
13
10
  const core_utils_1 = require("@zebec-network/core-utils");
14
11
  const solana_common_1 = require("@zebec-network/solana-common");
15
- const assert_1 = __importDefault(require("assert"));
16
12
  const bignumber_js_1 = require("bignumber.js");
17
13
  const artifacts_1 = require("../artifacts");
18
14
  const constants_1 = require("../constants");
@@ -104,7 +100,9 @@ class ZebecStreamService {
104
100
  .instruction();
105
101
  }
106
102
  async getCreateStreamInstruction(streamConfig, feePayer, receiver, senderAta, streamToken, withdrawAccount, sender, streamMetadata, streamData) {
107
- (0, assert_1.default)(streamData.streamName.length === constants_1.STREAM_NAME_BUFFER_SIZE, `Stream name buffer must be of size ${constants_1.STREAM_NAME_BUFFER_SIZE}`);
103
+ if (streamData.streamName.length !== constants_1.STREAM_NAME_BUFFER_SIZE) {
104
+ throw new Error(`Stream name buffer must be of size ${constants_1.STREAM_NAME_BUFFER_SIZE}`);
105
+ }
108
106
  return this.program.methods
109
107
  .createStream({
110
108
  amount: streamData.amount,
@@ -398,6 +396,7 @@ class ZebecStreamService {
398
396
  const [config] = (0, pda_1.deriveStreamConfigPda)(configName, this.programId);
399
397
  const configInfo = await this.program.account.streamConfig.fetch(config, commitment ?? this.connection.commitment);
400
398
  return {
399
+ configName,
401
400
  address: config,
402
401
  admin: configInfo.admin,
403
402
  withdrawerAccount: configInfo.withdrawAccount,
package/dist/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Keypair, PublicKey } from "@solana/web3.js";
3
3
  export type RpcNetwork = "mainnet-beta" | "devnet";
4
4
  export type Numeric = string | number;
5
5
  export type StreamConfigInfo = {
6
+ configName: string;
6
7
  address: PublicKey;
7
8
  admin: PublicKey;
8
9
  withdrawerAccount: PublicKey;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { PublicKey } from "@solana/web3.js";
2
+ import BigNumber from "bignumber.js";
2
3
  import type { FeeTier, RpcNetwork, StreamFeeInfo } from "./types";
3
4
  export declare function getFeeInfoForStream(streamToken: PublicKey, parsedStreamTokenAmount: BigNumber.Value, streamTokenDecimals: number, network: RpcNetwork): Promise<StreamFeeInfo>;
4
5
  export declare function getFeeRateForUsdAmount(amount: BigNumber.Value, feeTiers: FeeTier[]): string;
package/dist/utils.js CHANGED
@@ -1,15 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getFeeInfoForStream = getFeeInfoForStream;
4
7
  exports.getFeeRateForUsdAmount = getFeeRateForUsdAmount;
5
8
  const core_utils_1 = require("@zebec-network/core-utils");
6
- const bignumber_js_1 = require("bignumber.js");
9
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
7
10
  const constants_1 = require("./constants");
8
11
  async function getFeeInfoForStream(streamToken, parsedStreamTokenAmount, streamTokenDecimals, network) {
9
12
  const urlsParams = new URLSearchParams({
10
13
  mintAddress: streamToken.toBase58(),
11
14
  chain: "SOLANA",
12
- amount: (0, bignumber_js_1.BigNumber)(parsedStreamTokenAmount).toFixed(0),
15
+ amount: (0, bignumber_js_1.default)(parsedStreamTokenAmount).toFixed(0),
13
16
  decimals: streamTokenDecimals.toString(),
14
17
  });
15
18
  const url = `${constants_1.SUPERAPP_BACKEND_URL[network]}/l1-stream/fees/stream-quote?${urlsParams}`;
@@ -25,9 +28,9 @@ async function getFeeInfoForStream(streamToken, parsedStreamTokenAmount, streamT
25
28
  return data;
26
29
  }
27
30
  function getFeeRateForUsdAmount(amount, feeTiers) {
28
- feeTiers.sort((a, b) => (0, bignumber_js_1.BigNumber)(a.minThreshold).comparedTo((0, bignumber_js_1.BigNumber)(b.minThreshold)) ?? 0);
29
- const tier = feeTiers.find((tier) => (0, bignumber_js_1.BigNumber)(amount).gte(tier.minThreshold) &&
30
- (0, bignumber_js_1.BigNumber)(amount).lt(tier.maxThreshold));
31
+ feeTiers.sort((a, b) => (0, bignumber_js_1.default)(a.minThreshold).comparedTo((0, bignumber_js_1.default)(b.minThreshold)) ?? 0);
32
+ const tier = feeTiers.find((tier) => (0, bignumber_js_1.default)(amount).gte(tier.minThreshold) &&
33
+ (0, bignumber_js_1.default)(amount).lt(tier.maxThreshold));
31
34
  if (!tier) {
32
35
  throw new Error(`No fee tier found for amount: ${amount}`);
33
36
  }
package/package.json CHANGED
@@ -3,26 +3,26 @@
3
3
  "dependencies": {
4
4
  "@coral-xyz/anchor": "^0.31.1",
5
5
  "@metaplex-foundation/mpl-token-metadata": "^3.4.0",
6
- "@metaplex-foundation/umi": "^1.4.1",
7
- "@metaplex-foundation/umi-bundle-defaults": "^1.4.1",
8
- "@metaplex-foundation/umi-web3js-adapters": "^1.4.1",
6
+ "@metaplex-foundation/umi": "^1.5.1",
7
+ "@metaplex-foundation/umi-bundle-defaults": "^1.5.1",
8
+ "@metaplex-foundation/umi-web3js-adapters": "^1.5.1",
9
9
  "@solana/spl-token": "^0.4.14",
10
10
  "@solana/web3.js": "^1.98.2",
11
- "@zebec-network/core-utils": "^1.1.1",
12
- "@zebec-network/solana-common": "^2.3.1",
13
- "bignumber.js": "^9.3.1"
11
+ "@zebec-network/core-utils": "^1.2.0",
12
+ "@zebec-network/solana-common": "^2.5.1",
13
+ "bignumber.js": "^11.1.1"
14
14
  },
15
15
  "description": "This is an SDK for interacting with ZEBEC Stream Program in solana",
16
16
  "devDependencies": {
17
17
  "@types/bn.js": "^5.2.0",
18
18
  "@types/mocha": "^10.0.10",
19
- "@types/node": "^24.3.1",
20
- "dotenv": "^17.2.3",
19
+ "@types/node": "^25.7.0",
20
+ "dotenv": "^17.4.2",
21
21
  "mocha": "^11.7.5",
22
- "rimraf": "^6.1.2",
22
+ "rimraf": "^6.1.3",
23
23
  "ts-mocha": "^11.1.0",
24
24
  "ts-node": "^10.9.2",
25
- "typescript": "^5.9.2"
25
+ "typescript": "^6.0.3"
26
26
  },
27
27
  "files": [
28
28
  "dist"
@@ -34,10 +34,10 @@
34
34
  "build": "npm run clean && tsc",
35
35
  "clean": "rimraf ./dist",
36
36
  "format": "npx @biomejs/biome format --write",
37
- "start": "ts-node src/index.ts",
37
+ "prepare": "npm run format && npm run build",
38
38
  "test": "ts-mocha -p ./tsconfig.json -t 1000000000 test/**/*.test.ts",
39
39
  "test:single": "ts-mocha -p ./tsconfig.json -t 1000000000"
40
40
  },
41
41
  "types": "dist/index.d.ts",
42
- "version": "3.3.0"
43
- }
42
+ "version": "3.3.2"
43
+ }