@triadxyz/poseidons-protocol 0.2.8 → 0.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.
@@ -118,10 +118,20 @@ class Wheel {
118
118
  }
119
119
  if (this.program.provider.publicKey.toBase58() !==
120
120
  ((_b = (_a = this.rpcOptions) === null || _a === void 0 ? void 0 : _a.payer) === null || _b === void 0 ? void 0 : _b.toBase58())) {
121
+ console.log('sendVersionedTransaction');
121
122
  return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
122
123
  }
123
124
  const transaction = (yield (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions));
124
- return { transaction, prize: yield (0, helpers_1.getPrize)(this.program, transaction) };
125
+ const { blockhash, lastValidBlockHeight } = yield this.program.provider.connection.getLatestBlockhash();
126
+ yield this.program.provider.connection.confirmTransaction({
127
+ signature: transaction,
128
+ blockhash,
129
+ lastValidBlockHeight
130
+ }, 'finalized');
131
+ return {
132
+ transaction,
133
+ prize: yield (0, helpers_1.getPrize)(this.program, transaction)
134
+ };
125
135
  });
126
136
  }
127
137
  }
@@ -318,7 +318,7 @@
318
318
  "seeds": [
319
319
  {
320
320
  "kind": "const",
321
- "value": [119, 104, 101, 108, 108]
321
+ "value": [119, 104, 101, 101, 108]
322
322
  },
323
323
  {
324
324
  "kind": "arg",
@@ -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],
@@ -715,7 +752,7 @@
715
752
  "seeds": [
716
753
  {
717
754
  "kind": "const",
718
- "value": [119, 104, 101, 108, 108]
755
+ "value": [119, 104, 101, 101, 108]
719
756
  },
720
757
  {
721
758
  "kind": "arg",
@@ -879,7 +916,7 @@
879
916
  "seeds": [
880
917
  {
881
918
  "kind": "const",
882
- "value": [119, 104, 101, 108, 108]
919
+ "value": [119, 104, 101, 101, 108]
883
920
  },
884
921
  {
885
922
  "kind": "arg",
@@ -1018,6 +1055,11 @@
1018
1055
  "code": 6007,
1019
1056
  "name": "InsufficientSpins",
1020
1057
  "msg": "Insufficient spins"
1058
+ },
1059
+ {
1060
+ "code": 6008,
1061
+ "name": "WheelIsNotActive",
1062
+ "msg": "Wheel is not active"
1021
1063
  }
1022
1064
  ],
1023
1065
  "types": [
@@ -1866,10 +1908,14 @@
1866
1908
  ]
1867
1909
  }
1868
1910
  },
1911
+ {
1912
+ "name": "is_active",
1913
+ "type": "bool"
1914
+ },
1869
1915
  {
1870
1916
  "name": "padding",
1871
1917
  "type": {
1872
- "array": ["u8", 32]
1918
+ "array": ["u8", 31]
1873
1919
  }
1874
1920
  }
1875
1921
  ]
@@ -57,6 +57,7 @@ export type Wheel = {
57
57
  id: number;
58
58
  name: string;
59
59
  count: number;
60
+ isActive: boolean;
60
61
  prizes: Prize[];
61
62
  };
62
63
  export type Prize = {
@@ -423,7 +423,7 @@ export type PoseidonsProtocol = {
423
423
  seeds: [
424
424
  {
425
425
  kind: 'const';
426
- value: [119, 104, 101, 108, 108];
426
+ value: [119, 104, 101, 101, 108];
427
427
  },
428
428
  {
429
429
  kind: 'arg';
@@ -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];
@@ -948,7 +985,7 @@ export type PoseidonsProtocol = {
948
985
  seeds: [
949
986
  {
950
987
  kind: 'const';
951
- value: [119, 104, 101, 108, 108];
988
+ value: [119, 104, 101, 101, 108];
952
989
  },
953
990
  {
954
991
  kind: 'arg';
@@ -1170,7 +1207,7 @@ export type PoseidonsProtocol = {
1170
1207
  seeds: [
1171
1208
  {
1172
1209
  kind: 'const';
1173
- value: [119, 104, 101, 108, 108];
1210
+ value: [119, 104, 101, 101, 108];
1174
1211
  },
1175
1212
  {
1176
1213
  kind: 'arg';
@@ -1309,6 +1346,11 @@ export type PoseidonsProtocol = {
1309
1346
  code: 6007;
1310
1347
  name: 'insufficientSpins';
1311
1348
  msg: 'Insufficient spins';
1349
+ },
1350
+ {
1351
+ code: 6008;
1352
+ name: 'wheelIsNotActive';
1353
+ msg: 'Wheel is not active';
1312
1354
  }
1313
1355
  ];
1314
1356
  types: [
@@ -2157,10 +2199,14 @@ export type PoseidonsProtocol = {
2157
2199
  ];
2158
2200
  };
2159
2201
  },
2202
+ {
2203
+ name: 'isActive';
2204
+ type: 'bool';
2205
+ },
2160
2206
  {
2161
2207
  name: 'padding';
2162
2208
  type: {
2163
- array: ['u8', 32];
2209
+ array: ['u8', 31];
2164
2210
  };
2165
2211
  }
2166
2212
  ];
@@ -77,13 +77,14 @@ const formatWheel = (account, address) => {
77
77
  id: account.id,
78
78
  name: account.name,
79
79
  count: account.count.toNumber(),
80
+ isActive: account.isActive,
80
81
  prizes: account.prizes.map((prize) => ({
81
82
  id: prize.id,
82
83
  name: prize.name,
83
84
  available: prize.available.toNumber(),
84
85
  rangeMin: prize.rangeMin.toNumber(),
85
86
  rangeMax: prize.rangeMax.toNumber(),
86
- unit: prize.unit.toNumber()
87
+ unit: prize.unit.toNumber() / Math.pow(10, 6)
87
88
  }))
88
89
  };
89
90
  };
@@ -91,13 +92,15 @@ exports.formatWheel = formatWheel;
91
92
  const getPrize = (program, transaction) => __awaiter(void 0, void 0, void 0, function* () {
92
93
  var _a, _b;
93
94
  const prize = [];
94
- const tx = yield program.provider.connection.getParsedTransaction(transaction);
95
+ const tx = yield program.provider.connection.getParsedTransaction(transaction, {
96
+ maxSupportedTransactionVersion: 0
97
+ });
95
98
  if ((_a = tx === null || tx === void 0 ? void 0 : tx.meta) === null || _a === void 0 ? void 0 : _a.logMessages) {
96
99
  const eventParser = new anchor_1.EventParser(program.programId, new anchor_1.BorshCoder(program.idl));
97
100
  const events = eventParser.parseLogs((_b = tx === null || tx === void 0 ? void 0 : tx.meta) === null || _b === void 0 ? void 0 : _b.logMessages);
98
101
  for (let event of events) {
99
102
  switch (event.name) {
100
- case 'SpinWheelEvent':
103
+ case 'spinWheelEvent':
101
104
  prize.push(event.data.prizeId);
102
105
  break;
103
106
  default:
package/dist/utils/pda.js CHANGED
@@ -26,6 +26,6 @@ const getChestPDA = (id) => {
26
26
  };
27
27
  exports.getChestPDA = getChestPDA;
28
28
  const getWheelPDA = (id) => {
29
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('wheel'), new anchor_1.BN(id).toArrayLike(Buffer, 'le', 8)], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
29
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('wheel'), new anchor_1.BN(id).toArrayLike(Buffer, 'le', 1)], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
30
30
  };
31
31
  exports.getWheelPDA = getWheelPDA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/poseidons-protocol",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",