@triadxyz/triad-protocol 1.0.4-beta → 1.0.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/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: ''
|
|
160
|
+
});
|
|
161
|
+
console.log(response);
|
|
162
|
+
});
|
|
163
|
+
claimAllRewards();
|
package/dist/stake.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
2
1
|
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { PublicKey } from '@solana/web3.js';
|
|
4
3
|
import { TriadProtocol } from './types/triad_protocol';
|
|
@@ -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: string;
|
|
100
92
|
}, options?: RpcOptions): Promise<string>;
|
|
101
93
|
/**
|
|
102
94
|
* Update Boost
|
package/dist/stake.js
CHANGED
|
@@ -22,6 +22,7 @@ const base64_js_1 = require("base64-js");
|
|
|
22
22
|
const getRarityRank_1 = __importDefault(require("./utils/getRarityRank"));
|
|
23
23
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
24
24
|
const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
|
|
25
|
+
const convertSecretKeyToKeypair_1 = require("./utils/convertSecretKeyToKeypair");
|
|
25
26
|
class Stake {
|
|
26
27
|
constructor(program, provider) {
|
|
27
28
|
this.stakeVaultName = constants_1.STAKE_VAULT_NAME;
|
|
@@ -224,39 +225,6 @@ class Stake {
|
|
|
224
225
|
}), options);
|
|
225
226
|
});
|
|
226
227
|
}
|
|
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
228
|
/**
|
|
261
229
|
* Claim All Stake Rewards
|
|
262
230
|
* @param wallet - User wallet
|
|
@@ -264,24 +232,29 @@ class Stake {
|
|
|
264
232
|
* @param ranks - Tensor ranks
|
|
265
233
|
*
|
|
266
234
|
*/
|
|
267
|
-
|
|
235
|
+
claimStakeRewards({ wallet, collections, ranks, verifier }, options) {
|
|
268
236
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
-
const stakes = yield this.
|
|
237
|
+
const stakes = yield this.getUserStakes(wallet);
|
|
270
238
|
const ixs = [];
|
|
271
239
|
for (const stake of stakes) {
|
|
272
240
|
const rank = (0, getRarityRank_1.default)(ranks, stake.mint, stake.name);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
wallet,
|
|
278
|
-
nftName: stake.name,
|
|
241
|
+
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
|
|
242
|
+
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, stake.name);
|
|
243
|
+
ixs.push(yield this.program.methods
|
|
244
|
+
.claimStakeRewards({
|
|
279
245
|
collections,
|
|
280
246
|
rank
|
|
281
|
-
})
|
|
282
|
-
|
|
247
|
+
})
|
|
248
|
+
.accounts({
|
|
249
|
+
signer: wallet,
|
|
250
|
+
mint: constants_1.TRD_MINT,
|
|
251
|
+
stake: stakePDA,
|
|
252
|
+
stakeVault: stakeVaultPDA,
|
|
253
|
+
verifier: constants_1.VERIFIER
|
|
254
|
+
})
|
|
255
|
+
.instruction());
|
|
283
256
|
}
|
|
284
|
-
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
257
|
+
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, (0, convertSecretKeyToKeypair_1.convertSecretKeyToKeypair)(verifier));
|
|
285
258
|
});
|
|
286
259
|
}
|
|
287
260
|
/**
|
|
@@ -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
|
});
|