@zebec-network/zebec-stream-sdk 1.2.0 → 1.3.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.
@@ -22,12 +22,12 @@ export type ZebecStream = {
22
22
  writable: true;
23
23
  },
24
24
  {
25
- name: "ztokenPda";
25
+ name: "ztokenConfig";
26
26
  pda: {
27
27
  seeds: [
28
28
  {
29
29
  kind: "const";
30
- value: [122, 116, 111, 107, 101, 110];
30
+ value: [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103];
31
31
  }
32
32
  ];
33
33
  };
@@ -494,6 +494,30 @@ export type ZebecStream = {
494
494
  }
495
495
  ];
496
496
  },
497
+ {
498
+ name: "emergencyPause";
499
+ discriminator: [21, 143, 27, 142, 200, 181, 210, 255];
500
+ accounts: [
501
+ {
502
+ name: "admin";
503
+ writable: true;
504
+ signer: true;
505
+ },
506
+ {
507
+ name: "ztokenConfig";
508
+ writable: true;
509
+ pda: {
510
+ seeds: [
511
+ {
512
+ kind: "const";
513
+ value: [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103];
514
+ }
515
+ ];
516
+ };
517
+ }
518
+ ];
519
+ args: [];
520
+ },
497
521
  {
498
522
  name: "initZtokenConfig";
499
523
  discriminator: [208, 17, 124, 131, 67, 225, 25, 51];
@@ -504,13 +528,13 @@ export type ZebecStream = {
504
528
  signer: true;
505
529
  },
506
530
  {
507
- name: "ztokenPda";
531
+ name: "ztokenConfig";
508
532
  writable: true;
509
533
  pda: {
510
534
  seeds: [
511
535
  {
512
536
  kind: "const";
513
- value: [122, 116, 111, 107, 101, 110];
537
+ value: [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103];
514
538
  }
515
539
  ];
516
540
  };
@@ -617,12 +641,12 @@ export type ZebecStream = {
617
641
  };
618
642
  },
619
643
  {
620
- name: "ztokenPda";
644
+ name: "ztokenConfig";
621
645
  pda: {
622
646
  seeds: [
623
647
  {
624
648
  kind: "const";
625
- value: [122, 116, 111, 107, 101, 110];
649
+ value: [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103];
626
650
  }
627
651
  ];
628
652
  };
@@ -784,13 +808,13 @@ export type ZebecStream = {
784
808
  signer: true;
785
809
  },
786
810
  {
787
- name: "ztokenPda";
811
+ name: "ztokenConfig";
788
812
  writable: true;
789
813
  pda: {
790
814
  seeds: [
791
815
  {
792
816
  kind: "const";
793
- value: [122, 116, 111, 107, 101, 110];
817
+ value: [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103];
794
818
  }
795
819
  ];
796
820
  };
@@ -848,6 +872,39 @@ export type ZebecStream = {
848
872
  }
849
873
  ];
850
874
  },
875
+ {
876
+ name: "updateZtokenConfig";
877
+ discriminator: [171, 103, 122, 120, 219, 73, 113, 252];
878
+ accounts: [
879
+ {
880
+ name: "admin";
881
+ writable: true;
882
+ signer: true;
883
+ },
884
+ {
885
+ name: "ztokenConfig";
886
+ writable: true;
887
+ pda: {
888
+ seeds: [
889
+ {
890
+ kind: "const";
891
+ value: [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103];
892
+ }
893
+ ];
894
+ };
895
+ }
896
+ ];
897
+ args: [
898
+ {
899
+ name: "params";
900
+ type: {
901
+ defined: {
902
+ name: "updateZtokenConfigParams";
903
+ };
904
+ };
905
+ }
906
+ ];
907
+ },
851
908
  {
852
909
  name: "whitelistTokens";
853
910
  discriminator: [27, 206, 128, 157, 199, 65, 149, 189];
@@ -1383,7 +1440,7 @@ export type ZebecStream = {
1383
1440
  type: "pubkey";
1384
1441
  },
1385
1442
  {
1386
- name: "destination";
1443
+ name: "mintedTo";
1387
1444
  type: "pubkey";
1388
1445
  },
1389
1446
  {
@@ -1767,6 +1824,26 @@ export type ZebecStream = {
1767
1824
  ];
1768
1825
  };
1769
1826
  },
1827
+ {
1828
+ name: "updateZtokenConfigParams";
1829
+ type: {
1830
+ kind: "struct";
1831
+ fields: [
1832
+ {
1833
+ name: "fee";
1834
+ type: "u32";
1835
+ },
1836
+ {
1837
+ name: "minAmount";
1838
+ type: "u64";
1839
+ },
1840
+ {
1841
+ name: "feeVault";
1842
+ type: "pubkey";
1843
+ }
1844
+ ];
1845
+ };
1846
+ },
1770
1847
  {
1771
1848
  name: "whitelistTokensParams";
1772
1849
  type: {
@@ -1818,9 +1895,19 @@ export type ZebecStream = {
1818
1895
  ];
1819
1896
  constants: [
1820
1897
  {
1821
- name: "seed";
1898
+ name: "streamConfig";
1899
+ type: "string";
1900
+ value: '"config"';
1901
+ },
1902
+ {
1903
+ name: "ztokenConfig";
1904
+ type: "string";
1905
+ value: '"ztoken_config"';
1906
+ },
1907
+ {
1908
+ name: "ztokenMinter";
1822
1909
  type: "string";
1823
- value: '"anchor"';
1910
+ value: '"ztoken_minter"';
1824
1911
  }
1825
1912
  ];
1826
1913
  };
@@ -16,12 +16,12 @@
16
16
  "writable": true
17
17
  },
18
18
  {
19
- "name": "ztoken_pda",
19
+ "name": "ztoken_config",
20
20
  "pda": {
21
21
  "seeds": [
22
22
  {
23
23
  "kind": "const",
24
- "value": [122, 116, 111, 107, 101, 110]
24
+ "value": [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103]
25
25
  }
26
26
  ]
27
27
  }
@@ -308,6 +308,30 @@
308
308
  }
309
309
  ]
310
310
  },
311
+ {
312
+ "name": "emergency_pause",
313
+ "discriminator": [21, 143, 27, 142, 200, 181, 210, 255],
314
+ "accounts": [
315
+ {
316
+ "name": "admin",
317
+ "writable": true,
318
+ "signer": true
319
+ },
320
+ {
321
+ "name": "ztoken_config",
322
+ "writable": true,
323
+ "pda": {
324
+ "seeds": [
325
+ {
326
+ "kind": "const",
327
+ "value": [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103]
328
+ }
329
+ ]
330
+ }
331
+ }
332
+ ],
333
+ "args": []
334
+ },
311
335
  {
312
336
  "name": "init_ztoken_config",
313
337
  "discriminator": [208, 17, 124, 131, 67, 225, 25, 51],
@@ -318,13 +342,13 @@
318
342
  "signer": true
319
343
  },
320
344
  {
321
- "name": "ztoken_pda",
345
+ "name": "ztoken_config",
322
346
  "writable": true,
323
347
  "pda": {
324
348
  "seeds": [
325
349
  {
326
350
  "kind": "const",
327
- "value": [122, 116, 111, 107, 101, 110]
351
+ "value": [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103]
328
352
  }
329
353
  ]
330
354
  }
@@ -431,12 +455,12 @@
431
455
  }
432
456
  },
433
457
  {
434
- "name": "ztoken_pda",
458
+ "name": "ztoken_config",
435
459
  "pda": {
436
460
  "seeds": [
437
461
  {
438
462
  "kind": "const",
439
- "value": [122, 116, 111, 107, 101, 110]
463
+ "value": [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103]
440
464
  }
441
465
  ]
442
466
  }
@@ -538,13 +562,13 @@
538
562
  "signer": true
539
563
  },
540
564
  {
541
- "name": "ztoken_pda",
565
+ "name": "ztoken_config",
542
566
  "writable": true,
543
567
  "pda": {
544
568
  "seeds": [
545
569
  {
546
570
  "kind": "const",
547
- "value": [122, 116, 111, 107, 101, 110]
571
+ "value": [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103]
548
572
  }
549
573
  ]
550
574
  }
@@ -602,6 +626,39 @@
602
626
  }
603
627
  ]
604
628
  },
629
+ {
630
+ "name": "update_ztoken_config",
631
+ "discriminator": [171, 103, 122, 120, 219, 73, 113, 252],
632
+ "accounts": [
633
+ {
634
+ "name": "admin",
635
+ "writable": true,
636
+ "signer": true
637
+ },
638
+ {
639
+ "name": "ztoken_config",
640
+ "writable": true,
641
+ "pda": {
642
+ "seeds": [
643
+ {
644
+ "kind": "const",
645
+ "value": [122, 116, 111, 107, 101, 110, 95, 99, 111, 110, 102, 105, 103]
646
+ }
647
+ ]
648
+ }
649
+ }
650
+ ],
651
+ "args": [
652
+ {
653
+ "name": "params",
654
+ "type": {
655
+ "defined": {
656
+ "name": "UpdateZtokenConfigParams"
657
+ }
658
+ }
659
+ }
660
+ ]
661
+ },
605
662
  {
606
663
  "name": "whitelist_tokens",
607
664
  "discriminator": [27, 206, 128, 157, 199, 65, 149, 189],
@@ -1077,7 +1134,7 @@
1077
1134
  "type": "pubkey"
1078
1135
  },
1079
1136
  {
1080
- "name": "destination",
1137
+ "name": "minted_to",
1081
1138
  "type": "pubkey"
1082
1139
  },
1083
1140
  {
@@ -1461,6 +1518,26 @@
1461
1518
  ]
1462
1519
  }
1463
1520
  },
1521
+ {
1522
+ "name": "UpdateZtokenConfigParams",
1523
+ "type": {
1524
+ "kind": "struct",
1525
+ "fields": [
1526
+ {
1527
+ "name": "fee",
1528
+ "type": "u32"
1529
+ },
1530
+ {
1531
+ "name": "min_amount",
1532
+ "type": "u64"
1533
+ },
1534
+ {
1535
+ "name": "fee_vault",
1536
+ "type": "pubkey"
1537
+ }
1538
+ ]
1539
+ }
1540
+ },
1464
1541
  {
1465
1542
  "name": "WhitelistTokensParams",
1466
1543
  "type": {
@@ -1512,9 +1589,19 @@
1512
1589
  ],
1513
1590
  "constants": [
1514
1591
  {
1515
- "name": "SEED",
1592
+ "name": "STREAM_CONFIG",
1593
+ "type": "string",
1594
+ "value": "\"config\""
1595
+ },
1596
+ {
1597
+ "name": "ZTOKEN_CONFIG",
1598
+ "type": "string",
1599
+ "value": "\"ztoken_config\""
1600
+ },
1601
+ {
1602
+ "name": "ZTOKEN_MINTER",
1516
1603
  "type": "string",
1517
- "value": "\"anchor\""
1604
+ "value": "\"ztoken_minter\""
1518
1605
  }
1519
1606
  ]
1520
1607
  }
package/dist/pda.js CHANGED
@@ -7,9 +7,9 @@ exports.deriveMintAuthoritPda = deriveMintAuthoritPda;
7
7
  const anchor_1 = require("@coral-xyz/anchor");
8
8
  const web3_js_1 = require("@solana/web3.js");
9
9
  const SEEDS = {
10
- STREAM_CONFIG: [99, 111, 110, 102, 105, 103],
11
- ZTOKEN_CONFIG: [122, 116, 111, 107, 101, 110],
12
- MINT_AUTHORITY: [122, 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114],
10
+ STREAM_CONFIG: anchor_1.utils.bytes.utf8.encode("config"),
11
+ ZTOKEN_CONFIG: anchor_1.utils.bytes.utf8.encode("ztoken_config"),
12
+ MINT_AUTHORITY: anchor_1.utils.bytes.utf8.encode("ztoken_minter"),
13
13
  };
14
14
  function deriveStreamConfigPda(programId) {
15
15
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.STREAM_CONFIG)], (0, anchor_1.translateAddress)(programId));
@@ -12,9 +12,11 @@ export declare class ZTokenService {
12
12
  get connection(): Connection;
13
13
  private _createPayload;
14
14
  getInitZTOkenConfigInstruction(admin: PublicKey, feeVault: PublicKey, feeBps: number, minAmount: anchor.BN): Promise<anchor.web3.TransactionInstruction>;
15
- getMintTokenInstruction(admin: PublicKey, destination: PublicKey, mint: PublicKey, amount: anchor.BN, hash: number[]): Promise<anchor.web3.TransactionInstruction>;
16
- getBurnTokenInstruction(mint: PublicKey, source: PublicKey, sourceAta: PublicKey, amount: anchor.BN, receiver: string): Promise<anchor.web3.TransactionInstruction>;
15
+ getMintZTokenInstruction(admin: PublicKey, destination: PublicKey, mint: PublicKey, amount: anchor.BN, hash: number[]): Promise<anchor.web3.TransactionInstruction>;
16
+ getBurnZTokenInstruction(mint: PublicKey, source: PublicKey, sourceAta: PublicKey, amount: anchor.BN, receiver: string): Promise<anchor.web3.TransactionInstruction>;
17
17
  getSetMintableTokensInstruction(admin: PublicKey, tokens: PublicKey[]): Promise<anchor.web3.TransactionInstruction>;
18
+ getUpdateZTokenConfigInstruction(admin: PublicKey, feeVault: PublicKey, feeBps: number, minAmount: anchor.BN): Promise<anchor.web3.TransactionInstruction>;
19
+ getEmergencyPauseInstruction(admin: PublicKey): Promise<anchor.web3.TransactionInstruction>;
18
20
  createToken(params: {
19
21
  admin: anchor.Address;
20
22
  tokenInfo: {
@@ -31,19 +33,28 @@ export declare class ZTokenService {
31
33
  minAmount: Numeric;
32
34
  feePercent: number;
33
35
  }): Promise<TransactionPayload>;
34
- mintToken(params: {
36
+ mintZToken(params: {
35
37
  admin: anchor.Address;
36
38
  destination: anchor.Address;
37
39
  mint: anchor.Address;
38
40
  amount: Numeric;
39
41
  hash: number[] | Buffer | Uint8Array;
40
42
  }): Promise<TransactionPayload>;
41
- burnToken(params: {
43
+ burnZToken(params: {
42
44
  mint: anchor.Address;
43
45
  source: anchor.Address;
44
46
  receiver: string;
45
47
  amount: Numeric;
46
48
  }): Promise<TransactionPayload>;
49
+ updateZTOkenConfig(params: {
50
+ admin: anchor.Address;
51
+ feeVault: anchor.Address;
52
+ minAmount: Numeric;
53
+ feePercent: number;
54
+ }): Promise<TransactionPayload>;
55
+ emergencyPause(params: {
56
+ admin: anchor.Address;
57
+ }): Promise<TransactionPayload>;
47
58
  getZTokenConfigInfo(): Promise<{
48
59
  fee: number;
49
60
  admin: anchor.web3.PublicKey;
@@ -102,7 +102,7 @@ class ZTokenService {
102
102
  })
103
103
  .instruction();
104
104
  }
105
- async getMintTokenInstruction(admin, destination, mint, amount, hash) {
105
+ async getMintZTokenInstruction(admin, destination, mint, amount, hash) {
106
106
  return this.program.methods
107
107
  .mintZtoken({
108
108
  amount,
@@ -115,7 +115,7 @@ class ZTokenService {
115
115
  })
116
116
  .instruction();
117
117
  }
118
- async getBurnTokenInstruction(mint, source, sourceAta, amount, receiver) {
118
+ async getBurnZTokenInstruction(mint, source, sourceAta, amount, receiver) {
119
119
  return this.program.methods
120
120
  .burnZtoken({
121
121
  amount,
@@ -138,6 +138,26 @@ class ZTokenService {
138
138
  })
139
139
  .instruction();
140
140
  }
141
+ async getUpdateZTokenConfigInstruction(admin, feeVault, feeBps, minAmount) {
142
+ return this.program.methods
143
+ .updateZtokenConfig({
144
+ fee: feeBps,
145
+ feeVault,
146
+ minAmount,
147
+ })
148
+ .accounts({
149
+ admin,
150
+ })
151
+ .instruction();
152
+ }
153
+ async getEmergencyPauseInstruction(admin) {
154
+ return this.program.methods
155
+ .emergencyPause()
156
+ .accounts({
157
+ admin,
158
+ })
159
+ .instruction();
160
+ }
141
161
  async createToken(params) {
142
162
  const { tokenInfo } = params;
143
163
  const lamports = await (0, spl_token_1.getMinimumBalanceForRentExemptMint)(this.connection);
@@ -218,7 +238,7 @@ class ZTokenService {
218
238
  const ix = await this.getInitZTOkenConfigInstruction(admin, feeVault, feeBps, minAmount);
219
239
  return this._createPayload(admin, [ix]);
220
240
  }
221
- async mintToken(params) {
241
+ async mintZToken(params) {
222
242
  const [config] = (0, pda_1.deriveZTokenConfigPda)(this.programId);
223
243
  const configAccount = await this.program.account.ztoken.fetch(config);
224
244
  const admin = anchor.translateAddress(params.admin);
@@ -228,23 +248,34 @@ class ZTokenService {
228
248
  (0, assert_1.default)(params.hash.length == 32, "Invalid hash provided. Required 32 byte hash buffer");
229
249
  const mintDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, mint);
230
250
  const amount = new anchor.BN((0, bignumber_js_1.BigNumber)(params.amount).times(solana_common_1.TEN_BIGNUM.pow(mintDecimals)).toFixed());
231
- const ix = await this.getMintTokenInstruction(admin, destination, mint, amount, Array.from(params.hash));
251
+ const ix = await this.getMintZTokenInstruction(admin, destination, mint, amount, Array.from(params.hash));
232
252
  return this._createPayload(admin, [ix]);
233
253
  }
234
- async burnToken(params) {
254
+ async burnZToken(params) {
235
255
  const mint = anchor.translateAddress(params.mint);
236
256
  const source = anchor.translateAddress(params.source);
237
257
  const sourceAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, source, true);
238
258
  const mintDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, mint);
239
259
  const amount = new anchor.BN((0, bignumber_js_1.BigNumber)(params.amount).times(solana_common_1.TEN_BIGNUM.pow(mintDecimals)).toFixed(0));
240
- const ix = await this.getBurnTokenInstruction(mint, source, sourceAta, amount, params.receiver);
260
+ const ix = await this.getBurnZTokenInstruction(mint, source, sourceAta, amount, params.receiver);
241
261
  return this._createPayload(source, [ix]);
242
262
  }
263
+ async updateZTOkenConfig(params) {
264
+ const admin = anchor.translateAddress(params.admin);
265
+ const feeVault = anchor.translateAddress(params.feeVault);
266
+ const feeBps = Number((0, core_utils_1.percentToBps)(params.feePercent));
267
+ const minAmount = new anchor.BN(params.minAmount);
268
+ const ix = await this.getUpdateZTokenConfigInstruction(admin, feeVault, feeBps, minAmount);
269
+ return this._createPayload(admin, [ix]);
270
+ }
271
+ async emergencyPause(params) {
272
+ const admin = anchor.translateAddress(params.admin);
273
+ const ix = await this.getEmergencyPauseInstruction(admin);
274
+ return this._createPayload(admin, [ix]);
275
+ }
243
276
  async getZTokenConfigInfo() {
244
277
  const [config] = (0, pda_1.deriveZTokenConfigPda)(this.programId);
245
- console.log("config:", config.toString());
246
278
  const configAccount = await this.program.account.ztoken.fetch(config);
247
- console.log("config account", configAccount);
248
279
  return {
249
280
  fee: Number((0, core_utils_1.bpsToPercent)(configAccount.fee)),
250
281
  admin: configAccount.admin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/zebec-stream-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "This is an SDK for interacting with ZEBEC Stream Program in solana",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",