@triadxyz/poseidons-protocol 0.2.9 → 0.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.
@@ -37,10 +37,9 @@ export default class Chest {
37
37
  * @param refer - The refer of the user
38
38
  * @returns The transaction signature or versioned transaction
39
39
  */
40
- placeChestBid({ id, coins, refer }: {
40
+ placeChestBid({ id, coins }: {
41
41
  id: number;
42
42
  coins: number;
43
- refer: PublicKey;
44
43
  }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
45
44
  /**
46
45
  * Add chest winners
@@ -74,7 +74,7 @@ class Chest {
74
74
  * @param refer - The refer of the user
75
75
  * @returns The transaction signature or versioned transaction
76
76
  */
77
- placeChestBid({ id, coins, refer }) {
77
+ placeChestBid({ id, coins }) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
79
  const instructions = [
80
80
  yield this.program.methods
@@ -84,7 +84,6 @@ class Chest {
84
84
  })
85
85
  .accounts({
86
86
  signer: this.program.provider.publicKey,
87
- refer: (0, pda_1.getUserPDA)(refer),
88
87
  user: (0, pda_1.getUserPDA)(this.program.provider.publicKey)
89
88
  })
90
89
  .instruction()
@@ -61,4 +61,10 @@ export default class Wheel {
61
61
  transaction: string;
62
62
  prize: number[];
63
63
  }>;
64
+ /**
65
+ * Close a wheel
66
+ * @param id - The id of the wheel
67
+ * @returns The transaction signature or versioned transaction
68
+ */
69
+ closeWheel(id: number): Promise<string | import("@solana/web3.js").VersionedTransaction>;
64
70
  }
@@ -121,7 +121,34 @@ class Wheel {
121
121
  return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
122
122
  }
123
123
  const transaction = (yield (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions));
124
- return { transaction, prize: yield (0, helpers_1.getPrize)(this.program, transaction) };
124
+ const { blockhash, lastValidBlockHeight } = yield this.program.provider.connection.getLatestBlockhash();
125
+ yield this.program.provider.connection.confirmTransaction({
126
+ signature: transaction,
127
+ blockhash,
128
+ lastValidBlockHeight
129
+ }, 'finalized');
130
+ return {
131
+ transaction,
132
+ prize: yield (0, helpers_1.getPrize)(this.program, transaction)
133
+ };
134
+ });
135
+ }
136
+ /**
137
+ * Close a wheel
138
+ * @param id - The id of the wheel
139
+ * @returns The transaction signature or versioned transaction
140
+ */
141
+ closeWheel(id) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ const instructions = [
144
+ yield this.program.methods
145
+ .closeWheel(id)
146
+ .accounts({
147
+ signer: this.program.provider.publicKey
148
+ })
149
+ .instruction()
150
+ ];
151
+ return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
125
152
  });
126
153
  }
127
154
  }
@@ -542,6 +542,43 @@
542
542
  ],
543
543
  "args": []
544
544
  },
545
+ {
546
+ "name": "close_wheel",
547
+ "discriminator": [75, 225, 55, 245, 208, 36, 25, 90],
548
+ "accounts": [
549
+ {
550
+ "name": "signer",
551
+ "writable": true,
552
+ "signer": true
553
+ },
554
+ {
555
+ "name": "wheel",
556
+ "writable": true,
557
+ "pda": {
558
+ "seeds": [
559
+ {
560
+ "kind": "const",
561
+ "value": [119, 104, 101, 101, 108]
562
+ },
563
+ {
564
+ "kind": "arg",
565
+ "path": "id"
566
+ }
567
+ ]
568
+ }
569
+ },
570
+ {
571
+ "name": "system_program",
572
+ "address": "11111111111111111111111111111111"
573
+ }
574
+ ],
575
+ "args": [
576
+ {
577
+ "name": "id",
578
+ "type": "u8"
579
+ }
580
+ ]
581
+ },
545
582
  {
546
583
  "name": "create_chest",
547
584
  "discriminator": [146, 35, 76, 242, 243, 197, 90, 0],
@@ -776,7 +813,20 @@
776
813
  },
777
814
  {
778
815
  "name": "refer",
779
- "writable": true
816
+ "writable": true,
817
+ "pda": {
818
+ "seeds": [
819
+ {
820
+ "kind": "const",
821
+ "value": [117, 115, 101, 114]
822
+ },
823
+ {
824
+ "kind": "account",
825
+ "path": "refer.authority",
826
+ "account": "User"
827
+ }
828
+ ]
829
+ }
780
830
  },
781
831
  {
782
832
  "name": "mint",
@@ -1018,6 +1068,16 @@
1018
1068
  "code": 6007,
1019
1069
  "name": "InsufficientSpins",
1020
1070
  "msg": "Insufficient spins"
1071
+ },
1072
+ {
1073
+ "code": 6008,
1074
+ "name": "WheelIsNotActive",
1075
+ "msg": "Wheel is not active"
1076
+ },
1077
+ {
1078
+ "code": 6009,
1079
+ "name": "NotAuthorized",
1080
+ "msg": "Not authorized"
1021
1081
  }
1022
1082
  ],
1023
1083
  "types": [
@@ -717,6 +717,43 @@ export type PoseidonsProtocol = {
717
717
  ];
718
718
  args: [];
719
719
  },
720
+ {
721
+ name: 'closeWheel';
722
+ discriminator: [75, 225, 55, 245, 208, 36, 25, 90];
723
+ accounts: [
724
+ {
725
+ name: 'signer';
726
+ writable: true;
727
+ signer: true;
728
+ },
729
+ {
730
+ name: 'wheel';
731
+ writable: true;
732
+ pda: {
733
+ seeds: [
734
+ {
735
+ kind: 'const';
736
+ value: [119, 104, 101, 101, 108];
737
+ },
738
+ {
739
+ kind: 'arg';
740
+ path: 'id';
741
+ }
742
+ ];
743
+ };
744
+ },
745
+ {
746
+ name: 'systemProgram';
747
+ address: '11111111111111111111111111111111';
748
+ }
749
+ ];
750
+ args: [
751
+ {
752
+ name: 'id';
753
+ type: 'u8';
754
+ }
755
+ ];
756
+ },
720
757
  {
721
758
  name: 'createChest';
722
759
  discriminator: [146, 35, 76, 242, 243, 197, 90, 0];
@@ -1010,6 +1047,19 @@ export type PoseidonsProtocol = {
1010
1047
  {
1011
1048
  name: 'refer';
1012
1049
  writable: true;
1050
+ pda: {
1051
+ seeds: [
1052
+ {
1053
+ kind: 'const';
1054
+ value: [117, 115, 101, 114];
1055
+ },
1056
+ {
1057
+ kind: 'account';
1058
+ path: 'refer.authority';
1059
+ account: 'user';
1060
+ }
1061
+ ];
1062
+ };
1013
1063
  },
1014
1064
  {
1015
1065
  name: 'mint';
@@ -1309,6 +1359,16 @@ export type PoseidonsProtocol = {
1309
1359
  code: 6007;
1310
1360
  name: 'insufficientSpins';
1311
1361
  msg: 'Insufficient spins';
1362
+ },
1363
+ {
1364
+ code: 6008;
1365
+ name: 'wheelIsNotActive';
1366
+ msg: 'Wheel is not active';
1367
+ },
1368
+ {
1369
+ code: 6009;
1370
+ name: 'notAuthorized';
1371
+ msg: 'Not authorized';
1312
1372
  }
1313
1373
  ];
1314
1374
  types: [
@@ -92,13 +92,15 @@ exports.formatWheel = formatWheel;
92
92
  const getPrize = (program, transaction) => __awaiter(void 0, void 0, void 0, function* () {
93
93
  var _a, _b;
94
94
  const prize = [];
95
- const tx = yield program.provider.connection.getParsedTransaction(transaction);
95
+ const tx = yield program.provider.connection.getParsedTransaction(transaction, {
96
+ maxSupportedTransactionVersion: 0
97
+ });
96
98
  if ((_a = tx === null || tx === void 0 ? void 0 : tx.meta) === null || _a === void 0 ? void 0 : _a.logMessages) {
97
99
  const eventParser = new anchor_1.EventParser(program.programId, new anchor_1.BorshCoder(program.idl));
98
100
  const events = eventParser.parseLogs((_b = tx === null || tx === void 0 ? void 0 : tx.meta) === null || _b === void 0 ? void 0 : _b.logMessages);
99
101
  for (let event of events) {
100
102
  switch (event.name) {
101
- case 'SpinWheelEvent':
103
+ case 'spinWheelEvent':
102
104
  prize.push(event.data.prizeId);
103
105
  break;
104
106
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/poseidons-protocol",
3
- "version": "0.2.9",
3
+ "version": "0.3.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",