@triadxyz/triad-protocol 1.0.3-beta → 1.0.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.
package/dist/local-test.js
CHANGED
|
@@ -151,3 +151,13 @@ const resolveQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
151
151
|
const response = yield triadProtocol.trade.resolveQuestion(0);
|
|
152
152
|
console.log(response);
|
|
153
153
|
});
|
|
154
|
+
const claimAllRewards = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
|
+
const response = yield triadProtocol.stake.claimStakeRewards({
|
|
156
|
+
wallet: wallet.publicKey,
|
|
157
|
+
ranks: [],
|
|
158
|
+
collections: 1,
|
|
159
|
+
verifier: keypair
|
|
160
|
+
});
|
|
161
|
+
console.log(response);
|
|
162
|
+
});
|
|
163
|
+
claimAllRewards();
|
package/dist/stake.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
2
1
|
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { Keypair, PublicKey } from '@solana/web3.js';
|
|
4
3
|
import { TriadProtocol } from './types/triad_protocol';
|
|
5
4
|
import { RpcOptions } from './types';
|
|
6
5
|
import { UpdateStakeVaultArgs, StakeNftArgs, RequestWithdrawArgs, WithdrawArgs, Stake as StakeResponse, ClaimStakeRewardsArgs, StakeTokenArgs, UpdateBoostArgs } from './types/stake';
|
|
@@ -74,14 +73,6 @@ export default class Stake {
|
|
|
74
73
|
*
|
|
75
74
|
*/
|
|
76
75
|
withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<any>;
|
|
77
|
-
/**
|
|
78
|
-
* Claim Stake Rewards
|
|
79
|
-
* @param wallet - User wallet
|
|
80
|
-
* @param mint - NFT mint
|
|
81
|
-
* @param nftName - Name of the nft
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
claimStakeRewards({ wallet, nftName, collections, rank }: ClaimStakeRewardsArgs, options?: RpcOptions): Promise<import("@solana/web3.js").Transaction>;
|
|
85
76
|
/**
|
|
86
77
|
* Claim All Stake Rewards
|
|
87
78
|
* @param wallet - User wallet
|
|
@@ -89,7 +80,7 @@ export default class Stake {
|
|
|
89
80
|
* @param ranks - Tensor ranks
|
|
90
81
|
*
|
|
91
82
|
*/
|
|
92
|
-
|
|
83
|
+
claimStakeRewards({ wallet, collections, ranks, verifier }: {
|
|
93
84
|
wallet: PublicKey;
|
|
94
85
|
collections: number;
|
|
95
86
|
ranks: {
|
|
@@ -97,6 +88,7 @@ export default class Stake {
|
|
|
97
88
|
name: string;
|
|
98
89
|
rarityRankHrtt: number;
|
|
99
90
|
}[];
|
|
91
|
+
verifier: Keypair;
|
|
100
92
|
}, options?: RpcOptions): Promise<string>;
|
|
101
93
|
/**
|
|
102
94
|
* Update Boost
|
package/dist/stake.js
CHANGED
|
@@ -224,39 +224,6 @@ class Stake {
|
|
|
224
224
|
}), options);
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Claim Stake Rewards
|
|
229
|
-
* @param wallet - User wallet
|
|
230
|
-
* @param mint - NFT mint
|
|
231
|
-
* @param nftName - Name of the nft
|
|
232
|
-
*
|
|
233
|
-
*/
|
|
234
|
-
claimStakeRewards({ wallet, nftName, collections, rank }, options) {
|
|
235
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
-
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
|
|
237
|
-
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, nftName);
|
|
238
|
-
const method = this.program.methods
|
|
239
|
-
.claimStakeRewards({
|
|
240
|
-
collections,
|
|
241
|
-
rank
|
|
242
|
-
})
|
|
243
|
-
.accounts({
|
|
244
|
-
signer: wallet,
|
|
245
|
-
mint: constants_1.TRD_MINT,
|
|
246
|
-
stake: stakePDA,
|
|
247
|
-
stakeVault: stakeVaultPDA,
|
|
248
|
-
verifier: constants_1.VERIFIER
|
|
249
|
-
});
|
|
250
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
251
|
-
method.postInstructions([
|
|
252
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
253
|
-
microLamports: options.microLamports
|
|
254
|
-
})
|
|
255
|
-
]);
|
|
256
|
-
}
|
|
257
|
-
return method.transaction();
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
227
|
/**
|
|
261
228
|
* Claim All Stake Rewards
|
|
262
229
|
* @param wallet - User wallet
|
|
@@ -264,29 +231,29 @@ class Stake {
|
|
|
264
231
|
* @param ranks - Tensor ranks
|
|
265
232
|
*
|
|
266
233
|
*/
|
|
267
|
-
|
|
234
|
+
claimStakeRewards({ wallet, collections, ranks, verifier }, options) {
|
|
268
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
const stakes = yield this.
|
|
236
|
+
const stakes = yield this.getUserStakes(wallet);
|
|
270
237
|
const ixs = [];
|
|
271
238
|
for (const stake of stakes) {
|
|
272
239
|
const rank = (0, getRarityRank_1.default)(ranks, stake.mint, stake.name);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
wallet,
|
|
278
|
-
nftName: stake.name,
|
|
240
|
+
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
|
|
241
|
+
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, stake.name);
|
|
242
|
+
ixs.push(yield this.program.methods
|
|
243
|
+
.claimStakeRewards({
|
|
279
244
|
collections,
|
|
280
245
|
rank
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
246
|
+
})
|
|
247
|
+
.accounts({
|
|
248
|
+
signer: wallet,
|
|
249
|
+
mint: constants_1.TRD_MINT,
|
|
250
|
+
stake: stakePDA,
|
|
251
|
+
stakeVault: stakeVaultPDA,
|
|
252
|
+
verifier: constants_1.VERIFIER
|
|
253
|
+
})
|
|
254
|
+
.instruction());
|
|
288
255
|
}
|
|
289
|
-
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
256
|
+
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, verifier);
|
|
290
257
|
});
|
|
291
258
|
}
|
|
292
259
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
import { RpcOptions } from '../types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
4
|
+
import { Keypair } from '@solana/web3.js';
|
|
5
|
+
declare const sendVersionedTransaction: (provider: AnchorProvider, ixs: TransactionInstruction[], options?: RpcOptions, payer?: Keypair) => Promise<string>;
|
|
5
6
|
export default sendVersionedTransaction;
|
|
@@ -10,18 +10,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const web3_js_1 = require("@solana/web3.js");
|
|
13
|
-
const sendVersionedTransaction = (provider, ixs, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const sendVersionedTransaction = (provider, ixs, options, payer) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
14
|
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
15
15
|
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
16
16
|
microLamports: options.microLamports
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
19
19
|
const { blockhash } = yield provider.connection.getLatestBlockhash();
|
|
20
|
-
|
|
20
|
+
const tx = new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
21
21
|
instructions: ixs,
|
|
22
22
|
recentBlockhash: blockhash,
|
|
23
23
|
payerKey: provider.publicKey
|
|
24
|
-
}).compileToV0Message())
|
|
24
|
+
}).compileToV0Message());
|
|
25
|
+
if (payer) {
|
|
26
|
+
tx.sign([payer]);
|
|
27
|
+
}
|
|
28
|
+
return provider.sendAndConfirm(tx, payer ? [payer] : [], {
|
|
25
29
|
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
26
30
|
commitment: 'confirmed'
|
|
27
31
|
});
|