@triadxyz/triad-protocol 2.2.2-beta → 2.2.4-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.
@@ -85,4 +85,17 @@ export default class Poseidon {
85
85
  * @param options - RPC options
86
86
  */
87
87
  collectChestToken(id: number, options?: RpcOptions): Promise<string>;
88
+ /**
89
+ * Get Chest
90
+ * @param id - Chest ID
91
+ *
92
+ * @returns Chest
93
+ */
94
+ getChest(id: number): Promise<import("./types/trade").Chest>;
95
+ /**
96
+ * Get Chests
97
+ *
98
+ * @returns Chests
99
+ */
100
+ getChests(): Promise<import("./types/trade").Chest[]>;
88
101
  }
package/dist/poseidon.js CHANGED
@@ -17,6 +17,7 @@ const constants_1 = require("./utils/constants");
17
17
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
18
18
  const poseidon_1 = require("./utils/pda/poseidon");
19
19
  const pda_1 = require("./utils/pda");
20
+ const helpers_1 = require("./utils/helpers");
20
21
  class Poseidon {
21
22
  constructor(program) {
22
23
  this.program = program;
@@ -218,5 +219,29 @@ class Poseidon {
218
219
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
219
220
  });
220
221
  }
222
+ /**
223
+ * Get Chest
224
+ * @param id - Chest ID
225
+ *
226
+ * @returns Chest
227
+ */
228
+ getChest(id) {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ const chestPDA = (0, poseidon_1.getChestPDA)(this.program.programId, id);
231
+ const chest = yield this.program.account.chest.fetch(chestPDA);
232
+ return (0, helpers_1.formatChest)(chest);
233
+ });
234
+ }
235
+ /**
236
+ * Get Chests
237
+ *
238
+ * @returns Chests
239
+ */
240
+ getChests() {
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ const chests = yield this.program.account.chest.all();
243
+ return chests.map((chest) => (0, helpers_1.formatChest)(chest.account));
244
+ });
245
+ }
221
246
  }
222
247
  exports.default = Poseidon;
@@ -2636,6 +2636,10 @@
2636
2636
  {
2637
2637
  "name": "timestamp",
2638
2638
  "type": "i64"
2639
+ },
2640
+ {
2641
+ "name": "version",
2642
+ "type": "u64"
2639
2643
  }
2640
2644
  ]
2641
2645
  }
@@ -2689,10 +2693,14 @@
2689
2693
  "name": "version",
2690
2694
  "type": "u64"
2691
2695
  },
2696
+ {
2697
+ "name": "timestamp",
2698
+ "type": "i64"
2699
+ },
2692
2700
  {
2693
2701
  "name": "padding",
2694
2702
  "type": {
2695
- "array": ["u8", 128]
2703
+ "array": ["u8", 120]
2696
2704
  }
2697
2705
  }
2698
2706
  ]
@@ -56,6 +56,14 @@ export type Order = {
56
56
  authority: string;
57
57
  createdAt: string;
58
58
  };
59
+ export type Chest = {
60
+ id: number;
61
+ prizePool: number;
62
+ timer: number;
63
+ isFinished: boolean;
64
+ lastUser: string;
65
+ version: number;
66
+ };
59
67
  export declare enum WinningDirection {
60
68
  HYPE = "Hype",
61
69
  DRAW = "Draw",
@@ -3647,6 +3647,10 @@ export type TriadProtocol = {
3647
3647
  {
3648
3648
  name: 'timestamp';
3649
3649
  type: 'i64';
3650
+ },
3651
+ {
3652
+ name: 'version';
3653
+ type: 'u64';
3650
3654
  }
3651
3655
  ];
3652
3656
  };
@@ -3700,10 +3704,14 @@ export type TriadProtocol = {
3700
3704
  name: 'version';
3701
3705
  type: 'u64';
3702
3706
  },
3707
+ {
3708
+ name: 'timestamp';
3709
+ type: 'i64';
3710
+ },
3703
3711
  {
3704
3712
  name: 'padding';
3705
3713
  type: {
3706
- array: ['u8', 128];
3714
+ array: ['u8', 120];
3707
3715
  };
3708
3716
  }
3709
3717
  ];
@@ -1,5 +1,5 @@
1
1
  import { Stake, StakeVault } from './../types/stake';
2
- import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade } from '../types/trade';
2
+ import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Chest } from '../types/trade';
3
3
  import { PublicKey } from '@solana/web3.js';
4
4
  import { IdlAccounts } from '@coral-xyz/anchor';
5
5
  import { TriadProtocol } from '../types/triad_protocol';
@@ -10,6 +10,7 @@ export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV2'])
10
10
  export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
11
11
  export declare const formatUserTrade: (account: IdlAccounts<TriadProtocol>['userTrade'], publicKey: PublicKey) => UserTrade;
12
12
  export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['userTrade']['orders'][number], authority?: string) => Order;
13
+ export declare const formatChest: (chest: IdlAccounts<TriadProtocol>['chest']) => Chest;
13
14
  export declare const calculateStakeRewards: (stake: Stake) => number;
14
15
  export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
15
16
  export declare const getOrderDirection: (direction: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatChest = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const trade_1 = require("../types/trade");
5
5
  const constants_1 = require("./constants");
6
6
  const spl_token_1 = require("@solana/spl-token");
@@ -122,6 +122,17 @@ const formatOrder = (order, authority) => {
122
122
  };
123
123
  };
124
124
  exports.formatOrder = formatOrder;
125
+ const formatChest = (chest) => {
126
+ return {
127
+ id: chest.id.toNumber(),
128
+ prizePool: chest.prizePool.toNumber(),
129
+ timer: chest.timer.toNumber(),
130
+ isFinished: chest.isFinished,
131
+ lastUser: chest.lastUser.toString(),
132
+ version: chest.version.toNumber()
133
+ };
134
+ };
135
+ exports.formatChest = formatChest;
125
136
  const calculateStakeRewards = (stake) => {
126
137
  if (stake.withdrawTs !== 0)
127
138
  return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.2.2-beta",
3
+ "version": "2.2.4-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",