@triadxyz/triad-protocol 1.4.0-beta → 1.4.1-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,5 +82,8 @@ 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<number>;
85
+ spinWheel(args: {
86
+ isSol: boolean;
87
+ prizeType: PrizeType;
88
+ }, options?: RpcOptions): Promise<string>;
86
89
  }
package/dist/index.js CHANGED
@@ -14,7 +14,6 @@ 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");
18
17
  const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
19
18
  const trade_1 = __importDefault(require("./trade"));
20
19
  const helpers_1 = require("./utils/helpers");
@@ -228,26 +227,21 @@ class TriadProtocolClient {
228
227
  * @param verifier - Verifier keypair
229
228
  * @param options - RPC options
230
229
  */
231
- spinWheel(isSol, options) {
232
- var _a, _b, _c;
230
+ spinWheel(args, options) {
233
231
  return __awaiter(this, void 0, void 0, function* () {
234
232
  const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId, constants_1.SPIN_NAME);
235
- const method = this.program.methods.spinWheel(isSol).accounts({
233
+ const method = this.program.methods
234
+ .spinWheel({
235
+ isSol: args.isSol,
236
+ prizeType: args.prizeType
237
+ })
238
+ .accounts({
236
239
  signer: this.provider.wallet.publicKey,
240
+ verifier: constants_1.VERIFIER,
237
241
  spin: spinPDA,
238
242
  mint: constants_1.TCMAS_MINT
239
243
  });
240
- const tx = yield (0, sendTransactionWithOptions_1.default)(method, options);
241
- const txResult = (yield this.provider.connection.getTransaction(tx, {
242
- commitment: 'confirmed',
243
- maxSupportedTransactionVersion: 0
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');
248
- }
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();
244
+ return (0, sendTransactionWithOptions_1.default)(method, options);
251
245
  });
252
246
  }
253
247
  }
@@ -445,3 +445,11 @@ const getSpinPrize = () => __awaiter(void 0, void 0, void 0, function* () {
445
445
  }));
446
446
  console.log(prizes);
447
447
  });
448
+ const spinWheel = () => __awaiter(void 0, void 0, void 0, function* () {
449
+ const response = yield triadProtocol.spinWheel({
450
+ isSol: false,
451
+ prizeType: { none: {} }
452
+ });
453
+ console.log(response);
454
+ });
455
+ spinWheel();
@@ -1239,6 +1239,11 @@
1239
1239
  "writable": true,
1240
1240
  "signer": true
1241
1241
  },
1242
+ {
1243
+ "name": "verifier",
1244
+ "writable": true,
1245
+ "signer": true
1246
+ },
1242
1247
  {
1243
1248
  "name": "tresuary_account",
1244
1249
  "writable": true,
@@ -1323,8 +1328,12 @@
1323
1328
  ],
1324
1329
  "args": [
1325
1330
  {
1326
- "name": "is_sol",
1327
- "type": "bool"
1331
+ "name": "args",
1332
+ "type": {
1333
+ "defined": {
1334
+ "name": "SpinWheelArgs"
1335
+ }
1336
+ }
1328
1337
  }
1329
1338
  ],
1330
1339
  "returns": {
@@ -1711,6 +1720,10 @@
1711
1720
  }
1712
1721
  ],
1713
1722
  "events": [
1723
+ {
1724
+ "name": "ClaimSpinTokenUpdate",
1725
+ "discriminator": [162, 70, 212, 35, 0, 49, 120, 75]
1726
+ },
1714
1727
  {
1715
1728
  "name": "MarketUpdate",
1716
1729
  "discriminator": [170, 101, 124, 32, 249, 253, 251, 96]
@@ -1938,6 +1951,26 @@
1938
1951
  ]
1939
1952
  }
1940
1953
  },
1954
+ {
1955
+ "name": "ClaimSpinTokenUpdate",
1956
+ "type": {
1957
+ "kind": "struct",
1958
+ "fields": [
1959
+ {
1960
+ "name": "player",
1961
+ "type": "pubkey"
1962
+ },
1963
+ {
1964
+ "name": "amount",
1965
+ "type": "u64"
1966
+ },
1967
+ {
1968
+ "name": "timestamp",
1969
+ "type": "i64"
1970
+ }
1971
+ ]
1972
+ }
1973
+ },
1941
1974
  {
1942
1975
  "name": "ClaimStakeRewardsArgs",
1943
1976
  "type": {
@@ -2970,6 +3003,26 @@
2970
3003
  ]
2971
3004
  }
2972
3005
  },
3006
+ {
3007
+ "name": "SpinWheelArgs",
3008
+ "type": {
3009
+ "kind": "struct",
3010
+ "fields": [
3011
+ {
3012
+ "name": "is_sol",
3013
+ "type": "bool"
3014
+ },
3015
+ {
3016
+ "name": "prize_type",
3017
+ "type": {
3018
+ "defined": {
3019
+ "name": "PrizeType"
3020
+ }
3021
+ }
3022
+ }
3023
+ ]
3024
+ }
3025
+ },
2973
3026
  {
2974
3027
  "name": "SpinWheelResult",
2975
3028
  "type": {
@@ -1767,6 +1767,11 @@ export type TriadProtocol = {
1767
1767
  writable: true;
1768
1768
  signer: true;
1769
1769
  },
1770
+ {
1771
+ name: 'verifier';
1772
+ writable: true;
1773
+ signer: true;
1774
+ },
1770
1775
  {
1771
1776
  name: 'tresuaryAccount';
1772
1777
  writable: true;
@@ -1909,8 +1914,12 @@ export type TriadProtocol = {
1909
1914
  ];
1910
1915
  args: [
1911
1916
  {
1912
- name: 'isSol';
1913
- type: 'bool';
1917
+ name: 'args';
1918
+ type: {
1919
+ defined: {
1920
+ name: 'spinWheelArgs';
1921
+ };
1922
+ };
1914
1923
  }
1915
1924
  ];
1916
1925
  returns: {
@@ -2471,6 +2480,10 @@ export type TriadProtocol = {
2471
2480
  }
2472
2481
  ];
2473
2482
  events: [
2483
+ {
2484
+ name: 'claimSpinTokenUpdate';
2485
+ discriminator: [162, 70, 212, 35, 0, 49, 120, 75];
2486
+ },
2474
2487
  {
2475
2488
  name: 'marketUpdate';
2476
2489
  discriminator: [170, 101, 124, 32, 249, 253, 251, 96];
@@ -2698,6 +2711,26 @@ export type TriadProtocol = {
2698
2711
  ];
2699
2712
  };
2700
2713
  },
2714
+ {
2715
+ name: 'claimSpinTokenUpdate';
2716
+ type: {
2717
+ kind: 'struct';
2718
+ fields: [
2719
+ {
2720
+ name: 'player';
2721
+ type: 'pubkey';
2722
+ },
2723
+ {
2724
+ name: 'amount';
2725
+ type: 'u64';
2726
+ },
2727
+ {
2728
+ name: 'timestamp';
2729
+ type: 'i64';
2730
+ }
2731
+ ];
2732
+ };
2733
+ },
2701
2734
  {
2702
2735
  name: 'claimStakeRewardsArgs';
2703
2736
  type: {
@@ -3726,6 +3759,26 @@ export type TriadProtocol = {
3726
3759
  ];
3727
3760
  };
3728
3761
  },
3762
+ {
3763
+ name: 'spinWheelArgs';
3764
+ type: {
3765
+ kind: 'struct';
3766
+ fields: [
3767
+ {
3768
+ name: 'isSol';
3769
+ type: 'bool';
3770
+ },
3771
+ {
3772
+ name: 'prizeType';
3773
+ type: {
3774
+ defined: {
3775
+ name: 'prizeType';
3776
+ };
3777
+ };
3778
+ }
3779
+ ];
3780
+ };
3781
+ },
3729
3782
  {
3730
3783
  name: 'spinWheelResult';
3731
3784
  type: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.4.0-beta",
3
+ "version": "1.4.1-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",