@triadxyz/triad-protocol 2.3.3-beta → 2.3.5-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.
@@ -1,8 +1,7 @@
1
1
  import { Program } from '@coral-xyz/anchor';
2
- import { PublicKey } from '@solana/web3.js';
3
2
  import { TriadProtocol } from './types/triad_protocol';
4
- import { RpcOptions, TransferPoseidonArgs } from './types';
5
- import { CreateChestArgs, BidChestArgs, BuyChestTokenArgs } from './types/poseidon';
3
+ import { RpcOptions } from './types';
4
+ import { AddTraderPoseidonArgs, RemoveTraderPoseidonArgs, TransferPoseidonArgs, WithdrawPoseidonArgs } from './types/poseidon';
6
5
  export default class Poseidon {
7
6
  private program;
8
7
  constructor(program: Program<TriadProtocol>);
@@ -23,10 +22,7 @@ export default class Poseidon {
23
22
  *
24
23
  * @param options - RPC options
25
24
  */
26
- withdrawPoseidon({ poseidonAsset, nft }: {
27
- poseidonAsset: PublicKey;
28
- nft: number;
29
- }, options?: RpcOptions): Promise<string>;
25
+ withdrawPoseidon({ poseidonAsset, nft }: WithdrawPoseidonArgs, options?: RpcOptions): Promise<string>;
30
26
  /**
31
27
  * Collect Royalty
32
28
  * @param collection - Collection Symbol
@@ -36,66 +32,18 @@ export default class Poseidon {
36
32
  collectRoyalty(collection: string, options?: RpcOptions): Promise<string>;
37
33
  /**
38
34
  * Add Trader Poseidon
39
- * @param user - User
40
- * @param poseidonAsset - Poseidon Asset
35
+ * @param args.user - User
36
+ * @param args.poseidonAsset - Poseidon Asset
41
37
  *
42
38
  * @param options - RPC options
43
39
  */
44
- addTraderPoseidon({ user, poseidonAsset }: {
45
- user: PublicKey;
46
- poseidonAsset: PublicKey;
47
- }, options?: RpcOptions): Promise<string>;
40
+ addTraderPoseidon({ user, poseidonAsset }: AddTraderPoseidonArgs, options?: RpcOptions): Promise<string>;
48
41
  /**
49
42
  * Remove Trader Poseidon
50
- * @param user - User
51
- *
52
- * @param options - RPC options
53
- */
54
- removeTraderPoseidon({ user, poseidonAsset }: {
55
- user: PublicKey;
56
- poseidonAsset: PublicKey;
57
- }, options?: RpcOptions): Promise<string>;
58
- /**
59
- * Create Chest
60
- * @param args.id - Chest ID
61
- * @param args.initialPrizePool - Initial Prize Pool
62
- *
63
- * @param options - RPC options
64
- */
65
- createChest({ id, initialPrizePool }: CreateChestArgs, options?: RpcOptions): Promise<string>;
66
- /**
67
- * Bid Chest
68
- * @param args.id - Chest ID
69
- * @param args.amount - Amount
70
- *
71
- * @param options - RPC options
72
- */
73
- bidChest(args: BidChestArgs, options?: RpcOptions): Promise<string>;
74
- /**
75
- * Buy Chest Token
76
- * @param args.id - Chest ID
77
- * @param args.amount - Amount
78
- *
79
- * @param options - RPC options
80
- */
81
- buyChestToken(args: BuyChestTokenArgs, options?: RpcOptions): Promise<string>;
82
- /**
83
- * Collect Chest Token
43
+ * @param args.user - User
44
+ * @param args.poseidonAsset - Poseidon Asset
84
45
  *
85
46
  * @param options - RPC options
86
47
  */
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[]>;
48
+ removeTraderPoseidon({ user, poseidonAsset }: RemoveTraderPoseidonArgs, options?: RpcOptions): Promise<string>;
101
49
  }
package/dist/poseidon.js CHANGED
@@ -12,12 +12,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const anchor_1 = require("@coral-xyz/anchor");
16
15
  const constants_1 = require("./utils/constants");
17
16
  const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
18
17
  const poseidon_1 = require("./utils/pda/poseidon");
19
18
  const pda_1 = require("./utils/pda");
20
- const helpers_1 = require("./utils/helpers");
21
19
  class Poseidon {
22
20
  constructor(program) {
23
21
  this.program = program;
@@ -49,7 +47,7 @@ class Poseidon {
49
47
  })
50
48
  .instruction());
51
49
  }
52
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
50
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
53
51
  });
54
52
  }
55
53
  /**
@@ -72,7 +70,7 @@ class Poseidon {
72
70
  corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
73
71
  })
74
72
  .instruction());
75
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
73
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
76
74
  });
77
75
  }
78
76
  /**
@@ -91,13 +89,13 @@ class Poseidon {
91
89
  collection: (0, poseidon_1.getCollectionPDA)(this.program.programId, collection)
92
90
  })
93
91
  .instruction());
94
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
92
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
95
93
  });
96
94
  }
97
95
  /**
98
96
  * Add Trader Poseidon
99
- * @param user - User
100
- * @param poseidonAsset - Poseidon Asset
97
+ * @param args.user - User
98
+ * @param args.poseidonAsset - Poseidon Asset
101
99
  *
102
100
  * @param options - RPC options
103
101
  */
@@ -113,12 +111,13 @@ class Poseidon {
113
111
  poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
114
112
  })
115
113
  .instruction());
116
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
114
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
117
115
  });
118
116
  }
119
117
  /**
120
118
  * Remove Trader Poseidon
121
- * @param user - User
119
+ * @param args.user - User
120
+ * @param args.poseidonAsset - Poseidon Asset
122
121
  *
123
122
  * @param options - RPC options
124
123
  */
@@ -134,113 +133,7 @@ class Poseidon {
134
133
  poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
135
134
  })
136
135
  .instruction());
137
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
138
- });
139
- }
140
- /**
141
- * Create Chest
142
- * @param args.id - Chest ID
143
- * @param args.initialPrizePool - Initial Prize Pool
144
- *
145
- * @param options - RPC options
146
- */
147
- createChest({ id, initialPrizePool }, options) {
148
- return __awaiter(this, void 0, void 0, function* () {
149
- const ixs = [];
150
- ixs.push(yield this.program.methods
151
- .createChest({
152
- id: new anchor_1.BN(id),
153
- initialPrizePool: new anchor_1.BN(initialPrizePool)
154
- })
155
- .accounts({
156
- signer: this.program.provider.publicKey
157
- })
158
- .instruction());
159
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
160
- });
161
- }
162
- /**
163
- * Bid Chest
164
- * @param args.id - Chest ID
165
- * @param args.amount - Amount
166
- *
167
- * @param options - RPC options
168
- */
169
- bidChest(args, options) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- const ixs = [];
172
- ixs.push(yield this.program.methods
173
- .bidChest({
174
- id: new anchor_1.BN(args.id),
175
- amount: new anchor_1.BN(args.amount)
176
- })
177
- .accounts({
178
- signer: this.program.provider.publicKey
179
- })
180
- .instruction());
181
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
182
- });
183
- }
184
- /**
185
- * Buy Chest Token
186
- * @param args.id - Chest ID
187
- * @param args.amount - Amount
188
- *
189
- * @param options - RPC options
190
- */
191
- buyChestToken(args, options) {
192
- return __awaiter(this, void 0, void 0, function* () {
193
- const ixs = [];
194
- ixs.push(yield this.program.methods
195
- .buyChestToken({
196
- id: new anchor_1.BN(args.id),
197
- amount: new anchor_1.BN(args.amount)
198
- })
199
- .accounts({
200
- signer: this.program.provider.publicKey
201
- })
202
- .instruction());
203
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
204
- });
205
- }
206
- /**
207
- * Collect Chest Token
208
- *
209
- * @param options - RPC options
210
- */
211
- collectChestToken(id, options) {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- const ixs = [];
214
- const chestPDA = (0, poseidon_1.getChestPDA)(this.program.programId, id);
215
- ixs.push(yield this.program.methods
216
- .collectChestToken()
217
- .accounts({ signer: this.program.provider.publicKey, chest: chestPDA })
218
- .instruction());
219
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
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));
136
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
244
137
  });
245
138
  }
246
139
  }
package/dist/stake.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Program } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { TriadProtocol } from './types/triad_protocol';
4
4
  import { RpcOptions } from './types';
5
- import { UpdateStakeVaultArgs, RequestWithdrawArgs, WithdrawArgs, Stake as StakeResponse, StakeTokenArgs } from './types/stake';
5
+ import { UpdateStakeVaultArgs, RequestWithdrawArgs, WithdrawArgs, StakeTokenArgs } from './types/stake';
6
6
  export default class Stake {
7
7
  private program;
8
8
  constructor(program: Program<TriadProtocol>);
@@ -15,19 +15,31 @@ export default class Stake {
15
15
  * Get all Stakes
16
16
  *
17
17
  */
18
- getStakes(): Promise<StakeResponse[]>;
18
+ getStakes(): Promise<import("./types/stake").Stake[]>;
19
19
  /**
20
20
  * Get User Stakes By Wallet
21
21
  * @param wallet - User wallet
22
22
  *
23
23
  */
24
- getUserStakes(wallet: PublicKey): Promise<StakeResponse[]>;
24
+ getUserStakes(wallet: PublicKey): Promise<import("./types/stake").Stake[]>;
25
25
  /**
26
26
  * Get Stake By Wallet
27
27
  * @param wallet - User Wallet
28
28
  *
29
29
  */
30
- getStakeByWallet(wallet: PublicKey): Promise<StakeResponse[]>;
30
+ getStakeByWallet(wallet: PublicKey): Promise<{
31
+ available: number;
32
+ name: string;
33
+ stakeVault: string;
34
+ authority: string;
35
+ initTs: number;
36
+ withdrawTs: number;
37
+ mint: string;
38
+ claimedTs: number;
39
+ boost: boolean;
40
+ claimed: number;
41
+ amount: number;
42
+ }[]>;
31
43
  /**
32
44
  * Stake Token
33
45
  * @param args.name - Index for finding the PDA
@@ -68,7 +80,7 @@ export default class Stake {
68
80
  withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<string>;
69
81
  /**
70
82
  * Claim Stake Rewards
71
- * @param args.wallet - User wallet
83
+ * @param wallet - User wallet
72
84
  *
73
85
  * @param options - RPC options
74
86
  *
package/dist/stake.js CHANGED
@@ -61,12 +61,10 @@ class Stake {
61
61
  getStakeByWallet(wallet) {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
63
  const response = yield this.getUserStakes(wallet);
64
- const data = [];
65
- for (const stake of response) {
64
+ return response.map((stake) => {
66
65
  let available = (0, helpers_1.calculateStakeRewards)(stake);
67
- data.push(Object.assign(Object.assign({}, stake), { available }));
68
- }
69
- return data;
66
+ return Object.assign(Object.assign({}, stake), { available });
67
+ });
70
68
  });
71
69
  }
72
70
  /**
@@ -167,7 +165,7 @@ class Stake {
167
165
  }
168
166
  /**
169
167
  * Claim Stake Rewards
170
- * @param args.wallet - User wallet
168
+ * @param wallet - User wallet
171
169
  *
172
170
  * @param options - RPC options
173
171
  *