@triadxyz/triad-protocol 1.3.5-beta → 1.3.6-beta

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.
package/dist/index.d.ts CHANGED
@@ -82,7 +82,7 @@ export default class TriadProtocolClient {
82
82
  * @param verifier - Verifier keypair
83
83
  * @param options - RPC options
84
84
  */
85
- spinWheel(isSol: boolean, options?: RpcOptions): Promise<any>;
85
+ spinWheel(isSol: boolean, options?: RpcOptions): Promise<number>;
86
86
  /**
87
87
  * Mint Poseidon
88
88
  * @param number - Poseidon number
@@ -90,11 +90,5 @@ export default class TriadProtocolClient {
90
90
  * @param options - RPC options
91
91
  *
92
92
  */
93
- mintPoseidon(items: {
94
- number: number;
95
- attributes: {
96
- key: string;
97
- value: string;
98
- }[];
99
- }[], options?: RpcOptions): Promise<string>;
93
+ mintPoseidon(items: number[], options?: RpcOptions): Promise<string>;
100
94
  }
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const anchor_1 = require("@coral-xyz/anchor");
16
16
  const web3_js_1 = require("@solana/web3.js");
17
+ const base64_js_1 = require("base64-js");
17
18
  const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
18
19
  const trade_1 = __importDefault(require("./trade"));
19
20
  const helpers_1 = require("./utils/helpers");
@@ -228,6 +229,7 @@ class TriadProtocolClient {
228
229
  * @param options - RPC options
229
230
  */
230
231
  spinWheel(isSol, options) {
232
+ var _a, _b, _c;
231
233
  return __awaiter(this, void 0, void 0, function* () {
232
234
  const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId, constants_1.SPIN_NAME);
233
235
  const method = this.program.methods.spinWheel(isSol).accounts({
@@ -236,17 +238,16 @@ class TriadProtocolClient {
236
238
  mint: constants_1.TCMAS_MINT
237
239
  });
238
240
  const tx = yield (0, sendTransactionWithOptions_1.default)(method, options);
239
- const txLogs = yield this.provider.connection.getTransaction(tx, {
241
+ const txResult = (yield this.provider.connection.getTransaction(tx, {
240
242
  commitment: 'confirmed',
241
243
  maxSupportedTransactionVersion: 0
242
- });
243
- const eventLog = txLogs.meta.logMessages.find((log) => log.includes('SpinWheelResult'));
244
- if (!eventLog) {
245
- throw new Error('Spin result not found in transaction logs');
244
+ }));
245
+ const returnData = (_b = (_a = txResult.meta) === null || _a === void 0 ? void 0 : _a.returnData) === null || _b === void 0 ? void 0 : _b.data;
246
+ if (!returnData) {
247
+ throw new Error('No return data found in transaction');
246
248
  }
247
- const prizeType = JSON.parse(eventLog.split('RouletteSpinResult')[1]).data
248
- .prize;
249
- return prizeType;
249
+ let value = (_c = txResult.meta) === null || _c === void 0 ? void 0 : _c.returnData.data[0];
250
+ return new anchor_1.BN((0, base64_js_1.toByteArray)(value), 'le').toNumber();
250
251
  });
251
252
  }
252
253
  /**
@@ -266,7 +267,7 @@ class TriadProtocolClient {
266
267
  ixs.push(yield this.program.methods
267
268
  .mintPoseidon({
268
269
  collectionSymbol: constants_1.POSEIDON_COLLECTION_SYMBOL,
269
- number: new anchor_1.BN(item.number)
270
+ number: new anchor_1.BN(item)
270
271
  })
271
272
  .accounts({
272
273
  signer: this.provider.wallet.publicKey,
@@ -446,11 +446,11 @@ const getSpinPrize = () => __awaiter(void 0, void 0, void 0, function* () {
446
446
  console.log(prizes);
447
447
  });
448
448
  const spinWheel = () => __awaiter(void 0, void 0, void 0, function* () {
449
- const response = yield triadProtocol.spinWheel(false, { skipPreflight: true });
449
+ const response = yield triadProtocol.spinWheel(false, { skipPreflight: false });
450
450
  console.log(response);
451
451
  });
452
452
  spinWheel();
453
453
  const mintPoseidon = () => __awaiter(void 0, void 0, void 0, function* () {
454
- const response = yield triadProtocol.mintPoseidon([]);
454
+ const response = yield triadProtocol.mintPoseidon([1]);
455
455
  console.log(response);
456
456
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.3.5-beta",
3
+ "version": "1.3.6-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",