@zebec-network/zebec-stream-sdk 1.1.1 → 1.2.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,24 +22,12 @@ export type ZebecStream = {
22
22
  writable: true;
23
23
  },
24
24
  {
25
- name: "zstreamPda";
25
+ name: "ztokenPda";
26
26
  pda: {
27
27
  seeds: [
28
28
  {
29
29
  kind: "const";
30
- value: [122, 115, 116, 114, 101, 97, 109];
31
- }
32
- ];
33
- };
34
- },
35
- {
36
- name: "streamConfig";
37
- writable: true;
38
- pda: {
39
- seeds: [
40
- {
41
- kind: "const";
42
- value: [99, 111, 110, 102, 105, 103];
30
+ value: [122, 116, 111, 107, 101, 110];
43
31
  }
44
32
  ];
45
33
  };
@@ -63,7 +51,7 @@ export type ZebecStream = {
63
51
  name: "params";
64
52
  type: {
65
53
  defined: {
66
- name: "burnTokenParams";
54
+ name: "burnZtokenParams";
67
55
  };
68
56
  };
69
57
  }
@@ -507,8 +495,8 @@ export type ZebecStream = {
507
495
  ];
508
496
  },
509
497
  {
510
- name: "initZstreamConfig";
511
- discriminator: [206, 234, 255, 200, 252, 197, 23, 63];
498
+ name: "initZtokenConfig";
499
+ discriminator: [208, 17, 124, 131, 67, 225, 25, 51];
512
500
  accounts: [
513
501
  {
514
502
  name: "admin";
@@ -516,13 +504,25 @@ export type ZebecStream = {
516
504
  signer: true;
517
505
  },
518
506
  {
519
- name: "zstreamPda";
507
+ name: "ztokenPda";
520
508
  writable: true;
521
509
  pda: {
522
510
  seeds: [
523
511
  {
524
512
  kind: "const";
525
- value: [122, 115, 116, 114, 101, 97, 109];
513
+ value: [122, 116, 111, 107, 101, 110];
514
+ }
515
+ ];
516
+ };
517
+ },
518
+ {
519
+ name: "mintAuthority";
520
+ writable: true;
521
+ pda: {
522
+ seeds: [
523
+ {
524
+ kind: "const";
525
+ value: [122, 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114];
526
526
  }
527
527
  ];
528
528
  };
@@ -548,7 +548,7 @@ export type ZebecStream = {
548
548
  name: "params";
549
549
  type: {
550
550
  defined: {
551
- name: "initZstreamConfigParams";
551
+ name: "initZtokenConfigParams";
552
552
  };
553
553
  };
554
554
  }
@@ -597,6 +597,7 @@ export type ZebecStream = {
597
597
  accounts: [
598
598
  {
599
599
  name: "admin";
600
+ writable: true;
600
601
  signer: true;
601
602
  },
602
603
  {
@@ -610,18 +611,18 @@ export type ZebecStream = {
610
611
  seeds: [
611
612
  {
612
613
  kind: "const";
613
- value: [122, 115, 116, 114, 101, 97, 109, 95, 109, 105, 110, 116, 101, 114];
614
+ value: [122, 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114];
614
615
  }
615
616
  ];
616
617
  };
617
618
  },
618
619
  {
619
- name: "zstreamPda";
620
+ name: "ztokenPda";
620
621
  pda: {
621
622
  seeds: [
622
623
  {
623
624
  kind: "const";
624
- value: [122, 115, 116, 114, 101, 97, 109];
625
+ value: [122, 116, 111, 107, 101, 110];
625
626
  }
626
627
  ];
627
628
  };
@@ -733,100 +734,6 @@ export type ZebecStream = {
733
734
  };
734
735
  };
735
736
  },
736
- {
737
- name: "feeVault";
738
- writable: true;
739
- },
740
- {
741
- name: "feeCollectorTokenAccount";
742
- writable: true;
743
- pda: {
744
- seeds: [
745
- {
746
- kind: "account";
747
- path: "feeVault";
748
- },
749
- {
750
- kind: "const";
751
- value: [
752
- 6,
753
- 221,
754
- 246,
755
- 225,
756
- 215,
757
- 101,
758
- 161,
759
- 147,
760
- 217,
761
- 203,
762
- 225,
763
- 70,
764
- 206,
765
- 235,
766
- 121,
767
- 172,
768
- 28,
769
- 180,
770
- 133,
771
- 237,
772
- 95,
773
- 91,
774
- 55,
775
- 145,
776
- 58,
777
- 140,
778
- 245,
779
- 133,
780
- 126,
781
- 255,
782
- 0,
783
- 169
784
- ];
785
- },
786
- {
787
- kind: "account";
788
- path: "mint";
789
- }
790
- ];
791
- program: {
792
- kind: "const";
793
- value: [
794
- 140,
795
- 151,
796
- 37,
797
- 143,
798
- 78,
799
- 36,
800
- 137,
801
- 241,
802
- 187,
803
- 61,
804
- 16,
805
- 41,
806
- 20,
807
- 142,
808
- 13,
809
- 131,
810
- 11,
811
- 90,
812
- 19,
813
- 153,
814
- 218,
815
- 255,
816
- 16,
817
- 132,
818
- 4,
819
- 142,
820
- 123,
821
- 216,
822
- 219,
823
- 233,
824
- 248,
825
- 89
826
- ];
827
- };
828
- };
829
- },
830
737
  {
831
738
  name: "tokenProgram";
832
739
  address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
@@ -845,7 +752,7 @@ export type ZebecStream = {
845
752
  name: "params";
846
753
  type: {
847
754
  defined: {
848
- name: "mintTokenPrams";
755
+ name: "mintZtokenPrams";
849
756
  };
850
757
  };
851
758
  }
@@ -867,6 +774,43 @@ export type ZebecStream = {
867
774
  ];
868
775
  args: [];
869
776
  },
777
+ {
778
+ name: "setMintableTokens";
779
+ discriminator: [224, 133, 23, 188, 255, 162, 101, 56];
780
+ accounts: [
781
+ {
782
+ name: "admin";
783
+ writable: true;
784
+ signer: true;
785
+ },
786
+ {
787
+ name: "ztokenPda";
788
+ writable: true;
789
+ pda: {
790
+ seeds: [
791
+ {
792
+ kind: "const";
793
+ value: [122, 116, 111, 107, 101, 110];
794
+ }
795
+ ];
796
+ };
797
+ },
798
+ {
799
+ name: "systemProgram";
800
+ address: "11111111111111111111111111111111";
801
+ }
802
+ ];
803
+ args: [
804
+ {
805
+ name: "params";
806
+ type: {
807
+ defined: {
808
+ name: "setMintableZtokenParams";
809
+ };
810
+ };
811
+ }
812
+ ];
813
+ },
870
814
  {
871
815
  name: "updateConfig";
872
816
  discriminator: [29, 158, 252, 191, 10, 83, 219, 99];
@@ -1111,8 +1055,8 @@ export type ZebecStream = {
1111
1055
  discriminator: [130, 127, 218, 245, 133, 158, 70, 198];
1112
1056
  },
1113
1057
  {
1114
- name: "zstream";
1115
- discriminator: [140, 236, 248, 88, 87, 203, 46, 117];
1058
+ name: "ztoken";
1059
+ discriminator: [152, 188, 138, 213, 141, 52, 107, 138];
1116
1060
  }
1117
1061
  ];
1118
1062
  events: [
@@ -1265,6 +1209,11 @@ export type ZebecStream = {
1265
1209
  code: 6023;
1266
1210
  name: "invalidFeeVault";
1267
1211
  msg: "Invalid fee vault";
1212
+ },
1213
+ {
1214
+ code: 6024;
1215
+ name: "tokenNotAllowed";
1216
+ msg: "Invalid Token";
1268
1217
  }
1269
1218
  ];
1270
1219
  types: [
@@ -1289,7 +1238,7 @@ export type ZebecStream = {
1289
1238
  };
1290
1239
  },
1291
1240
  {
1292
- name: "burnTokenParams";
1241
+ name: "burnZtokenParams";
1293
1242
  type: {
1294
1243
  kind: "struct";
1295
1244
  fields: [
@@ -1383,7 +1332,7 @@ export type ZebecStream = {
1383
1332
  };
1384
1333
  },
1385
1334
  {
1386
- name: "initZstreamConfigParams";
1335
+ name: "initZtokenConfigParams";
1387
1336
  type: {
1388
1337
  kind: "struct";
1389
1338
  fields: [
@@ -1449,7 +1398,7 @@ export type ZebecStream = {
1449
1398
  };
1450
1399
  },
1451
1400
  {
1452
- name: "mintTokenPrams";
1401
+ name: "mintZtokenPrams";
1453
1402
  type: {
1454
1403
  kind: "struct";
1455
1404
  fields: [
@@ -1459,7 +1408,9 @@ export type ZebecStream = {
1459
1408
  },
1460
1409
  {
1461
1410
  name: "hash";
1462
- type: "string";
1411
+ type: {
1412
+ array: ["u8", 32];
1413
+ };
1463
1414
  }
1464
1415
  ];
1465
1416
  };
@@ -1514,6 +1465,20 @@ export type ZebecStream = {
1514
1465
  ];
1515
1466
  };
1516
1467
  },
1468
+ {
1469
+ name: "setMintableZtokenParams";
1470
+ type: {
1471
+ kind: "struct";
1472
+ fields: [
1473
+ {
1474
+ name: "tokens";
1475
+ type: {
1476
+ vec: "pubkey";
1477
+ };
1478
+ }
1479
+ ];
1480
+ };
1481
+ },
1517
1482
  {
1518
1483
  name: "streamCancelEvent";
1519
1484
  type: {
@@ -1817,7 +1782,7 @@ export type ZebecStream = {
1817
1782
  };
1818
1783
  },
1819
1784
  {
1820
- name: "zstream";
1785
+ name: "ztoken";
1821
1786
  type: {
1822
1787
  kind: "struct";
1823
1788
  fields: [
@@ -1840,6 +1805,12 @@ export type ZebecStream = {
1840
1805
  {
1841
1806
  name: "minAmount";
1842
1807
  type: "u64";
1808
+ },
1809
+ {
1810
+ name: "mintableTokens";
1811
+ type: {
1812
+ vec: "pubkey";
1813
+ };
1843
1814
  }
1844
1815
  ];
1845
1816
  };
@@ -16,24 +16,12 @@
16
16
  "writable": true
17
17
  },
18
18
  {
19
- "name": "zstream_pda",
19
+ "name": "ztoken_pda",
20
20
  "pda": {
21
21
  "seeds": [
22
22
  {
23
23
  "kind": "const",
24
- "value": [122, 115, 116, 114, 101, 97, 109]
25
- }
26
- ]
27
- }
28
- },
29
- {
30
- "name": "stream_config",
31
- "writable": true,
32
- "pda": {
33
- "seeds": [
34
- {
35
- "kind": "const",
36
- "value": [99, 111, 110, 102, 105, 103]
24
+ "value": [122, 116, 111, 107, 101, 110]
37
25
  }
38
26
  ]
39
27
  }
@@ -57,7 +45,7 @@
57
45
  "name": "params",
58
46
  "type": {
59
47
  "defined": {
60
- "name": "BurnTokenParams"
48
+ "name": "BurnZtokenParams"
61
49
  }
62
50
  }
63
51
  }
@@ -321,8 +309,8 @@
321
309
  ]
322
310
  },
323
311
  {
324
- "name": "init_zstream_config",
325
- "discriminator": [206, 234, 255, 200, 252, 197, 23, 63],
312
+ "name": "init_ztoken_config",
313
+ "discriminator": [208, 17, 124, 131, 67, 225, 25, 51],
326
314
  "accounts": [
327
315
  {
328
316
  "name": "admin",
@@ -330,13 +318,25 @@
330
318
  "signer": true
331
319
  },
332
320
  {
333
- "name": "zstream_pda",
321
+ "name": "ztoken_pda",
322
+ "writable": true,
323
+ "pda": {
324
+ "seeds": [
325
+ {
326
+ "kind": "const",
327
+ "value": [122, 116, 111, 107, 101, 110]
328
+ }
329
+ ]
330
+ }
331
+ },
332
+ {
333
+ "name": "mint_authority",
334
334
  "writable": true,
335
335
  "pda": {
336
336
  "seeds": [
337
337
  {
338
338
  "kind": "const",
339
- "value": [122, 115, 116, 114, 101, 97, 109]
339
+ "value": [122, 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114]
340
340
  }
341
341
  ]
342
342
  }
@@ -362,7 +362,7 @@
362
362
  "name": "params",
363
363
  "type": {
364
364
  "defined": {
365
- "name": "InitZstreamConfigParams"
365
+ "name": "InitZtokenConfigParams"
366
366
  }
367
367
  }
368
368
  }
@@ -411,6 +411,7 @@
411
411
  "accounts": [
412
412
  {
413
413
  "name": "admin",
414
+ "writable": true,
414
415
  "signer": true
415
416
  },
416
417
  {
@@ -424,18 +425,18 @@
424
425
  "seeds": [
425
426
  {
426
427
  "kind": "const",
427
- "value": [122, 115, 116, 114, 101, 97, 109, 95, 109, 105, 110, 116, 101, 114]
428
+ "value": [122, 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114]
428
429
  }
429
430
  ]
430
431
  }
431
432
  },
432
433
  {
433
- "name": "zstream_pda",
434
+ "name": "ztoken_pda",
434
435
  "pda": {
435
436
  "seeds": [
436
437
  {
437
438
  "kind": "const",
438
- "value": [122, 115, 116, 114, 101, 97, 109]
439
+ "value": [122, 116, 111, 107, 101, 110]
439
440
  }
440
441
  ]
441
442
  }
@@ -487,40 +488,6 @@
487
488
  }
488
489
  }
489
490
  },
490
- {
491
- "name": "fee_vault",
492
- "writable": true
493
- },
494
- {
495
- "name": "fee_collector_token_account",
496
- "writable": true,
497
- "pda": {
498
- "seeds": [
499
- {
500
- "kind": "account",
501
- "path": "fee_vault"
502
- },
503
- {
504
- "kind": "const",
505
- "value": [
506
- 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95,
507
- 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169
508
- ]
509
- },
510
- {
511
- "kind": "account",
512
- "path": "mint"
513
- }
514
- ],
515
- "program": {
516
- "kind": "const",
517
- "value": [
518
- 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16,
519
- 132, 4, 142, 123, 216, 219, 233, 248, 89
520
- ]
521
- }
522
- }
523
- },
524
491
  {
525
492
  "name": "token_program",
526
493
  "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
@@ -539,7 +506,7 @@
539
506
  "name": "params",
540
507
  "type": {
541
508
  "defined": {
542
- "name": "MintTokenPrams"
509
+ "name": "MintZtokenPrams"
543
510
  }
544
511
  }
545
512
  }
@@ -561,6 +528,43 @@
561
528
  ],
562
529
  "args": []
563
530
  },
531
+ {
532
+ "name": "set_mintable_tokens",
533
+ "discriminator": [224, 133, 23, 188, 255, 162, 101, 56],
534
+ "accounts": [
535
+ {
536
+ "name": "admin",
537
+ "writable": true,
538
+ "signer": true
539
+ },
540
+ {
541
+ "name": "ztoken_pda",
542
+ "writable": true,
543
+ "pda": {
544
+ "seeds": [
545
+ {
546
+ "kind": "const",
547
+ "value": [122, 116, 111, 107, 101, 110]
548
+ }
549
+ ]
550
+ }
551
+ },
552
+ {
553
+ "name": "system_program",
554
+ "address": "11111111111111111111111111111111"
555
+ }
556
+ ],
557
+ "args": [
558
+ {
559
+ "name": "params",
560
+ "type": {
561
+ "defined": {
562
+ "name": "SetMintableZtokenParams"
563
+ }
564
+ }
565
+ }
566
+ ]
567
+ },
564
568
  {
565
569
  "name": "update_config",
566
570
  "discriminator": [29, 158, 252, 191, 10, 83, 219, 99],
@@ -745,8 +749,8 @@
745
749
  "discriminator": [130, 127, 218, 245, 133, 158, 70, 198]
746
750
  },
747
751
  {
748
- "name": "Zstream",
749
- "discriminator": [140, 236, 248, 88, 87, 203, 46, 117]
752
+ "name": "Ztoken",
753
+ "discriminator": [152, 188, 138, 213, 141, 52, 107, 138]
750
754
  }
751
755
  ],
752
756
  "events": [
@@ -899,6 +903,11 @@
899
903
  "code": 6023,
900
904
  "name": "InvalidFeeVault",
901
905
  "msg": "Invalid fee vault"
906
+ },
907
+ {
908
+ "code": 6024,
909
+ "name": "TokenNotAllowed",
910
+ "msg": "Invalid Token"
902
911
  }
903
912
  ],
904
913
  "types": [
@@ -923,7 +932,7 @@
923
932
  }
924
933
  },
925
934
  {
926
- "name": "BurnTokenParams",
935
+ "name": "BurnZtokenParams",
927
936
  "type": {
928
937
  "kind": "struct",
929
938
  "fields": [
@@ -1017,7 +1026,7 @@
1017
1026
  }
1018
1027
  },
1019
1028
  {
1020
- "name": "InitZstreamConfigParams",
1029
+ "name": "InitZtokenConfigParams",
1021
1030
  "type": {
1022
1031
  "kind": "struct",
1023
1032
  "fields": [
@@ -1083,7 +1092,7 @@
1083
1092
  }
1084
1093
  },
1085
1094
  {
1086
- "name": "MintTokenPrams",
1095
+ "name": "MintZtokenPrams",
1087
1096
  "type": {
1088
1097
  "kind": "struct",
1089
1098
  "fields": [
@@ -1093,7 +1102,9 @@
1093
1102
  },
1094
1103
  {
1095
1104
  "name": "hash",
1096
- "type": "string"
1105
+ "type": {
1106
+ "array": ["u8", 32]
1107
+ }
1097
1108
  }
1098
1109
  ]
1099
1110
  }
@@ -1148,6 +1159,20 @@
1148
1159
  ]
1149
1160
  }
1150
1161
  },
1162
+ {
1163
+ "name": "SetMintableZtokenParams",
1164
+ "type": {
1165
+ "kind": "struct",
1166
+ "fields": [
1167
+ {
1168
+ "name": "tokens",
1169
+ "type": {
1170
+ "vec": "pubkey"
1171
+ }
1172
+ }
1173
+ ]
1174
+ }
1175
+ },
1151
1176
  {
1152
1177
  "name": "StreamCancelEvent",
1153
1178
  "type": {
@@ -1451,7 +1476,7 @@
1451
1476
  }
1452
1477
  },
1453
1478
  {
1454
- "name": "Zstream",
1479
+ "name": "Ztoken",
1455
1480
  "type": {
1456
1481
  "kind": "struct",
1457
1482
  "fields": [
@@ -1474,6 +1499,12 @@
1474
1499
  {
1475
1500
  "name": "min_amount",
1476
1501
  "type": "u64"
1502
+ },
1503
+ {
1504
+ "name": "mintable_tokens",
1505
+ "type": {
1506
+ "vec": "pubkey"
1507
+ }
1477
1508
  }
1478
1509
  ]
1479
1510
  }
package/dist/pda.d.ts CHANGED
@@ -3,3 +3,4 @@ import { PublicKey } from "@solana/web3.js";
3
3
  export declare function deriveStreamConfigPda(programId: Address): [PublicKey, number];
4
4
  export declare function deriveStreamVaultPda(metatadata: Address, programId: Address): [PublicKey, number];
5
5
  export declare function deriveZTokenConfigPda(programId: Address): [PublicKey, number];
6
+ export declare function deriveMintAuthoritPda(programId: Address): [PublicKey, number];
package/dist/pda.js CHANGED
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deriveStreamConfigPda = deriveStreamConfigPda;
4
4
  exports.deriveStreamVaultPda = deriveStreamVaultPda;
5
5
  exports.deriveZTokenConfigPda = deriveZTokenConfigPda;
6
+ exports.deriveMintAuthoritPda = deriveMintAuthoritPda;
6
7
  const anchor_1 = require("@coral-xyz/anchor");
7
8
  const web3_js_1 = require("@solana/web3.js");
8
9
  const SEEDS = {
9
10
  STREAM_CONFIG: [99, 111, 110, 102, 105, 103],
10
- ZTOKEN_CONFIG: [122, 115, 116, 114, 101, 97, 109],
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],
11
13
  };
12
14
  function deriveStreamConfigPda(programId) {
13
15
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.STREAM_CONFIG)], (0, anchor_1.translateAddress)(programId));
@@ -18,3 +20,6 @@ function deriveStreamVaultPda(metatadata, programId) {
18
20
  function deriveZTokenConfigPda(programId) {
19
21
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.ZTOKEN_CONFIG)], (0, anchor_1.translateAddress)(programId));
20
22
  }
23
+ function deriveMintAuthoritPda(programId) {
24
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(SEEDS.MINT_AUTHORITY)], (0, anchor_1.translateAddress)(programId));
25
+ }
@@ -1,2 +1,2 @@
1
- export * from "./tokenService";
1
+ export * from "./zTokenService";
2
2
  export * from "./streamService";
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./tokenService"), exports);
17
+ __exportStar(require("./zTokenService"), exports);
18
18
  __exportStar(require("./streamService"), exports);
@@ -11,24 +11,20 @@ export declare class ZTokenService {
11
11
  get programId(): PublicKey;
12
12
  get connection(): Connection;
13
13
  private _createPayload;
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>;
17
+ getSetMintableTokensInstruction(admin: PublicKey, tokens: PublicKey[]): Promise<anchor.web3.TransactionInstruction>;
14
18
  createToken(params: {
19
+ admin: anchor.Address;
15
20
  tokenInfo: {
16
21
  tokenName: string;
17
22
  symbol: string;
18
23
  metadataUri: string;
19
- mintAuthority: anchor.Address;
20
- updateAuthority: anchor.Address;
21
24
  decimals: number;
22
25
  mintKeypair?: Keypair;
23
26
  };
24
27
  }): Promise<TransactionPayload>;
25
- changeMintAuthority(params: {
26
- mint: anchor.Address;
27
- currentMintAuthority: anchor.Address;
28
- newMintAuthority: anchor.Address;
29
- }): Promise<TransactionPayload>;
30
- getInitZTOkenConfigInstruction(admin: PublicKey, feeVault: PublicKey, feeBps: number, minAmount: anchor.BN): Promise<anchor.web3.TransactionInstruction>;
31
- getMintTokenInstruction(admin: PublicKey, destination: PublicKey, feeVault: PublicKey, mint: PublicKey, amount: anchor.BN, hash: string): Promise<anchor.web3.TransactionInstruction>;
32
28
  initZTOkenConfig(params: {
33
29
  admin: anchor.Address;
34
30
  feeVault: anchor.Address;
@@ -36,9 +32,24 @@ export declare class ZTokenService {
36
32
  feePercent: number;
37
33
  }): Promise<TransactionPayload>;
38
34
  mintToken(params: {
35
+ admin: anchor.Address;
39
36
  destination: anchor.Address;
40
37
  mint: anchor.Address;
41
38
  amount: Numeric;
42
- hash: string;
39
+ hash: number[] | Buffer | Uint8Array;
40
+ }): Promise<TransactionPayload>;
41
+ burnToken(params: {
42
+ mint: anchor.Address;
43
+ source: anchor.Address;
44
+ receiver: string;
45
+ amount: Numeric;
43
46
  }): Promise<TransactionPayload>;
47
+ getZTokenConfigInfo(): Promise<{
48
+ fee: number;
49
+ admin: anchor.web3.PublicKey;
50
+ emergencyPause: boolean;
51
+ feeVault: anchor.web3.PublicKey;
52
+ minAmount: string;
53
+ minttableTokens: anchor.web3.PublicKey[];
54
+ }>;
44
55
  }
@@ -32,8 +32,13 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
35
38
  Object.defineProperty(exports, "__esModule", { value: true });
36
39
  exports.ZTokenService = void 0;
40
+ const assert_1 = __importDefault(require("assert"));
41
+ const bignumber_js_1 = require("bignumber.js");
37
42
  const anchor = __importStar(require("@coral-xyz/anchor"));
38
43
  const mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");
39
44
  const umi_bundle_defaults_1 = require("@metaplex-foundation/umi-bundle-defaults");
@@ -85,13 +90,63 @@ class ZTokenService {
85
90
  }
86
91
  return new solana_common_1.TransactionPayload(this.connection, errorMap, instructions, payerKey, signers, addressLookupTableAccounts, signTransaction);
87
92
  }
93
+ async getInitZTOkenConfigInstruction(admin, feeVault, feeBps, minAmount) {
94
+ return this.program.methods
95
+ .initZtokenConfig({
96
+ fee: feeBps,
97
+ minAmount,
98
+ })
99
+ .accounts({
100
+ feeVault,
101
+ admin,
102
+ })
103
+ .instruction();
104
+ }
105
+ async getMintTokenInstruction(admin, destination, mint, amount, hash) {
106
+ return this.program.methods
107
+ .mintZtoken({
108
+ amount,
109
+ hash,
110
+ })
111
+ .accounts({
112
+ destination,
113
+ mint,
114
+ admin,
115
+ })
116
+ .instruction();
117
+ }
118
+ async getBurnTokenInstruction(mint, source, sourceAta, amount, receiver) {
119
+ return this.program.methods
120
+ .burnZtoken({
121
+ amount,
122
+ receiver,
123
+ })
124
+ .accounts({
125
+ mint,
126
+ sourceAta,
127
+ source,
128
+ })
129
+ .instruction();
130
+ }
131
+ async getSetMintableTokensInstruction(admin, tokens) {
132
+ return this.program.methods
133
+ .setMintableTokens({
134
+ tokens,
135
+ })
136
+ .accounts({
137
+ admin,
138
+ })
139
+ .instruction();
140
+ }
88
141
  async createToken(params) {
89
142
  const { tokenInfo } = params;
90
143
  const lamports = await (0, spl_token_1.getMinimumBalanceForRentExemptMint)(this.connection);
91
- const mintKeypair = tokenInfo.mintKeypair ? tokenInfo.mintKeypair : web3_js_1.Keypair.generate();
144
+ const mintKeypair = tokenInfo.mintKeypair ?? web3_js_1.Keypair.generate();
92
145
  const mint = mintKeypair.publicKey;
93
- const mintAuthority = anchor.translateAddress(tokenInfo.mintAuthority);
94
- const updateAuthority = anchor.translateAddress(tokenInfo.updateAuthority);
146
+ const admin = anchor.translateAddress(params.admin);
147
+ const mintAuthority = admin;
148
+ const updateAuthority = admin;
149
+ const [newMintAuthority] = (0, pda_1.deriveMintAuthoritPda)(this.programId);
95
150
  const umi = (0, umi_bundle_defaults_1.createUmi)(this.connection.rpcEndpoint);
96
151
  const mplProgramId = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(mpl_token_metadata_1.MPL_TOKEN_METADATA_PROGRAM_ID);
97
152
  const [metadata] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), mplProgramId.toBytes(), mint.toBytes()], mplProgramId);
@@ -138,7 +193,8 @@ class ZTokenService {
138
193
  data: Buffer.from(ix.data),
139
194
  programId: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(ix.programId),
140
195
  };
141
- const createNewTokenIxs = [
196
+ const setMintableTokenIx = await this.getSetMintableTokensInstruction(admin, [mint]);
197
+ const ixs = [
142
198
  web3_js_1.SystemProgram.createAccount({
143
199
  fromPubkey: mintAuthority,
144
200
  newAccountPubkey: mint,
@@ -146,46 +202,13 @@ class ZTokenService {
146
202
  lamports: lamports,
147
203
  programId: spl_token_1.TOKEN_PROGRAM_ID,
148
204
  }),
149
- (0, spl_token_1.createInitializeMintInstruction)(mint, tokenInfo.decimals, mintAuthority, mintAuthority, spl_token_1.TOKEN_PROGRAM_ID),
205
+ (0, spl_token_1.createInitializeMintInstruction)(mint, tokenInfo.decimals, mintAuthority, null, spl_token_1.TOKEN_PROGRAM_ID),
150
206
  createMetadataInstruction,
207
+ (0, spl_token_1.createSetAuthorityInstruction)(mint, mintAuthority, spl_token_1.AuthorityType.MintTokens, // authority type
208
+ newMintAuthority),
209
+ setMintableTokenIx,
151
210
  ];
152
- return this._createPayload(mintAuthority, createNewTokenIxs, [mintKeypair]);
153
- }
154
- async changeMintAuthority(params) {
155
- const mint = anchor.translateAddress(params.mint);
156
- const currentMintAuthority = anchor.translateAddress(params.currentMintAuthority);
157
- const newMintAuthority = anchor.translateAddress(params.newMintAuthority);
158
- let setMintAuthorityIx = (0, spl_token_1.createSetAuthorityInstruction)(mint, // mint account || token account
159
- currentMintAuthority, // current auth
160
- spl_token_1.AuthorityType.MintTokens, // authority type
161
- newMintAuthority);
162
- return this._createPayload(currentMintAuthority, [setMintAuthorityIx]);
163
- }
164
- async getInitZTOkenConfigInstruction(admin, feeVault, feeBps, minAmount) {
165
- return this.program.methods
166
- .initZstreamConfig({
167
- fee: feeBps,
168
- minAmount,
169
- })
170
- .accounts({
171
- feeVault,
172
- admin,
173
- })
174
- .instruction();
175
- }
176
- async getMintTokenInstruction(admin, destination, feeVault, mint, amount, hash) {
177
- return this.program.methods
178
- .mintZtoken({
179
- amount,
180
- hash,
181
- })
182
- .accounts({
183
- destination,
184
- feeVault,
185
- mint,
186
- admin,
187
- })
188
- .instruction();
211
+ return this._createPayload(admin, ixs, [mintKeypair]);
189
212
  }
190
213
  async initZTOkenConfig(params) {
191
214
  const admin = anchor.translateAddress(params.admin);
@@ -197,15 +220,39 @@ class ZTokenService {
197
220
  }
198
221
  async mintToken(params) {
199
222
  const [config] = (0, pda_1.deriveZTokenConfigPda)(this.programId);
200
- const configAccount = await this.program.account.zstream.fetch(config);
201
- const feeVault = configAccount.feeVault;
202
- const admin = configAccount.admin;
223
+ const configAccount = await this.program.account.ztoken.fetch(config);
224
+ const admin = anchor.translateAddress(params.admin);
225
+ (0, assert_1.default)(admin.equals(configAccount.admin), "Invalid admin address");
203
226
  const destination = anchor.translateAddress(params.destination);
204
227
  const mint = anchor.translateAddress(params.mint);
228
+ (0, assert_1.default)(params.hash.length == 32, "Invalid hash provided. Required 32 byte hash buffer");
205
229
  const mintDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, mint);
206
- const amount = new anchor.BN(BigNumber(params.amount).times(solana_common_1.TEN_BIGNUM.pow(mintDecimals)).toFixed());
207
- const ix = await this.getMintTokenInstruction(admin, destination, feeVault, mint, amount, params.hash);
230
+ 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));
208
232
  return this._createPayload(admin, [ix]);
209
233
  }
234
+ async burnToken(params) {
235
+ const mint = anchor.translateAddress(params.mint);
236
+ const source = anchor.translateAddress(params.source);
237
+ const sourceAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, source, true);
238
+ const mintDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, mint);
239
+ 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);
241
+ return this._createPayload(source, [ix]);
242
+ }
243
+ async getZTokenConfigInfo() {
244
+ const [config] = (0, pda_1.deriveZTokenConfigPda)(this.programId);
245
+ console.log("config:", config.toString());
246
+ const configAccount = await this.program.account.ztoken.fetch(config);
247
+ console.log("config account", configAccount);
248
+ return {
249
+ fee: Number((0, core_utils_1.bpsToPercent)(configAccount.fee)),
250
+ admin: configAccount.admin,
251
+ emergencyPause: configAccount.emergencyPause,
252
+ feeVault: configAccount.feeVault,
253
+ minAmount: configAccount.minAmount.toString(),
254
+ minttableTokens: configAccount.mintableTokens,
255
+ };
256
+ }
210
257
  }
211
258
  exports.ZTokenService = ZTokenService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/zebec-stream-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.2.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",
@@ -38,7 +38,7 @@
38
38
  "@solana/spl-token": "^0.4.13",
39
39
  "@solana/web3.js": "^1.98.2",
40
40
  "@types/bn.js": "^5.2.0",
41
- "@zebec-network/core-utils": "^1.0.4",
41
+ "@zebec-network/core-utils": "^1.1.0",
42
42
  "@zebec-network/solana-common": "^1.5.1",
43
43
  "bignumber.js": "^9.3.1"
44
44
  }