@triadxyz/triad-protocol 0.4.5-beta → 0.4.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/index.js +7 -2
- package/dist/test.d.ts +1 -0
- package/dist/test.js +103 -0
- package/dist/types/idl_triad_protocol.json +2 -5
- package/dist/types/index.d.ts +2 -2
- package/dist/types/triad_protocol.d.ts +2 -5
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/dist/utils/stake-season-1/rarity.json +8832 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -152,8 +152,8 @@ class TriadProtocolClient {
|
|
|
152
152
|
return this.provider.sendAndConfirm(new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
|
|
153
153
|
instructions: ixs,
|
|
154
154
|
recentBlockhash: blockhash,
|
|
155
|
-
payerKey: payer
|
|
156
|
-
}).compileToV0Message()), [], {
|
|
155
|
+
payerKey: payer.publicKey
|
|
156
|
+
}).compileToV0Message()), [payer], {
|
|
157
157
|
skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
|
|
158
158
|
commitment: 'confirmed'
|
|
159
159
|
});
|
|
@@ -162,6 +162,11 @@ class TriadProtocolClient {
|
|
|
162
162
|
const userPDA = (0, helpers_1.getUserAddressSync)(this.program.programId, user);
|
|
163
163
|
const proofInfoPDA = (0, helpers_1.getProofOreAddressSync)(userPDA);
|
|
164
164
|
const ixs = [];
|
|
165
|
+
ixs.push(new web3_js_1.TransactionInstruction({
|
|
166
|
+
keys: [],
|
|
167
|
+
programId: new web3_js_1.PublicKey(constants_1.NOOP_PROGRAM_ID),
|
|
168
|
+
data: Buffer.from(proofInfoPDA.toBytes())
|
|
169
|
+
}));
|
|
165
170
|
ixs.push(yield this.program.methods
|
|
166
171
|
.mineOre({
|
|
167
172
|
digest,
|
package/dist/test.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/test.js
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
17
|
+
const index_1 = __importDefault(require("./index"));
|
|
18
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
19
|
+
const constants_1 = require("./utils/constants");
|
|
20
|
+
const rarity_json_1 = __importDefault(require("./utils/stake-season-1/rarity.json"));
|
|
21
|
+
const getRarity_1 = require("./utils/getRarity");
|
|
22
|
+
const axios_1 = __importDefault(require("axios"));
|
|
23
|
+
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
|
|
24
|
+
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
|
|
25
|
+
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
26
|
+
const connection = new web3_js_1.Connection(rpc_file.toString(), 'confirmed');
|
|
27
|
+
const wallet = new anchor_1.Wallet(keypair);
|
|
28
|
+
const triadProtocol = new index_1.default(connection, wallet);
|
|
29
|
+
const getStake = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const response = yield triadProtocol.stake.getStakes(constants_1.STAKE_SEASON);
|
|
31
|
+
let available = 0;
|
|
32
|
+
let items = 0;
|
|
33
|
+
for (const stake of response) {
|
|
34
|
+
const getRank = (0, getRarity_1.getRarityRank)(rarity_json_1.default, stake.mint, stake.name);
|
|
35
|
+
try {
|
|
36
|
+
available += yield triadProtocol.stake.getStakeRewards({
|
|
37
|
+
wallet: new web3_js_1.PublicKey(stake.authority),
|
|
38
|
+
nftName: stake.name,
|
|
39
|
+
stakeVault: constants_1.STAKE_SEASON,
|
|
40
|
+
rank: getRank,
|
|
41
|
+
collections: 1
|
|
42
|
+
});
|
|
43
|
+
items += 1;
|
|
44
|
+
console.log(items);
|
|
45
|
+
console.log(available);
|
|
46
|
+
}
|
|
47
|
+
catch (e) { }
|
|
48
|
+
}
|
|
49
|
+
console.log(available);
|
|
50
|
+
console.log(items);
|
|
51
|
+
console.log(response.length);
|
|
52
|
+
});
|
|
53
|
+
const deposit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const response = yield triadProtocol.stake.depositStakeRewards({
|
|
55
|
+
wallet: wallet.publicKey,
|
|
56
|
+
stakeVault: constants_1.STAKE_SEASON,
|
|
57
|
+
mint: new web3_js_1.PublicKey(constants_1.TTRIAD_MINT),
|
|
58
|
+
amount: new anchor_1.BN(192388 * Math.pow(10, 6))
|
|
59
|
+
});
|
|
60
|
+
console.log(response);
|
|
61
|
+
});
|
|
62
|
+
const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
const response = yield triadProtocol.stake.getStakeVaultByName(constants_1.STAKE_SEASON);
|
|
64
|
+
console.log(response);
|
|
65
|
+
});
|
|
66
|
+
const getStakeByWallet = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
const response = yield triadProtocol.stake.getStakeByWallet(new web3_js_1.PublicKey('HjJQdfTHgC3EBX3471w4st8BXbBmtbaMyCAXNgcUb7dq'), constants_1.STAKE_SEASON, 1, rarity_json_1.default);
|
|
68
|
+
console.log(response);
|
|
69
|
+
});
|
|
70
|
+
const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
const response = (yield axios_1.default.get('https://api.triadfi.co/boost'))
|
|
72
|
+
.data;
|
|
73
|
+
const stakes = yield triadProtocol.stake.getStakes(constants_1.STAKE_SEASON);
|
|
74
|
+
const update = [];
|
|
75
|
+
for (const stake of stakes) {
|
|
76
|
+
if (response.includes(stake.mint) && !stake.boost) {
|
|
77
|
+
update.push({ name: stake.name, wallet: stake.authority });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
console.log(update);
|
|
81
|
+
const updateBoostResponse = yield triadProtocol.stake.updateBoost({
|
|
82
|
+
wallet: wallet.publicKey,
|
|
83
|
+
stakeVault: constants_1.STAKE_SEASON,
|
|
84
|
+
nfts: update,
|
|
85
|
+
boost: true
|
|
86
|
+
});
|
|
87
|
+
console.log(updateBoostResponse);
|
|
88
|
+
});
|
|
89
|
+
const mineOre = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const response = yield triadProtocol.mineOre({
|
|
91
|
+
user: wallet.publicKey,
|
|
92
|
+
payer: wallet.publicKey,
|
|
93
|
+
bus: new web3_js_1.PublicKey('BZJ2xppmny6ME3NkAgu2SMZB2mwS5xboX9n6VsSyGYFJ'),
|
|
94
|
+
digest: [
|
|
95
|
+
149, 32, 37, 176, 97, 139, 13, 182, 108, 28, 66, 160, 137, 156, 204, 249
|
|
96
|
+
],
|
|
97
|
+
nonce: [217, 46, 186, 232, 162, 139, 46, 186]
|
|
98
|
+
}, {
|
|
99
|
+
skipPreflight: true,
|
|
100
|
+
microLamports: 10000
|
|
101
|
+
});
|
|
102
|
+
console.log(response);
|
|
103
|
+
});
|
|
@@ -473,11 +473,11 @@
|
|
|
473
473
|
}
|
|
474
474
|
},
|
|
475
475
|
{
|
|
476
|
-
"name": "
|
|
476
|
+
"name": "proof_info",
|
|
477
477
|
"writable": true
|
|
478
478
|
},
|
|
479
479
|
{
|
|
480
|
-
"name": "
|
|
480
|
+
"name": "bus",
|
|
481
481
|
"writable": true
|
|
482
482
|
},
|
|
483
483
|
{
|
|
@@ -1365,9 +1365,6 @@
|
|
|
1365
1365
|
},
|
|
1366
1366
|
{
|
|
1367
1367
|
"name": "MineArgs",
|
|
1368
|
-
"repr": {
|
|
1369
|
-
"kind": "c"
|
|
1370
|
-
},
|
|
1371
1368
|
"type": {
|
|
1372
1369
|
"kind": "struct",
|
|
1373
1370
|
"fields": [
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { Keypair, PublicKey } from '@solana/web3.js';
|
|
2
2
|
export type RpcOptions = {
|
|
3
3
|
skipPreflight?: boolean;
|
|
4
4
|
microLamports?: number;
|
|
@@ -10,7 +10,7 @@ export type CreateUserArgs = {
|
|
|
10
10
|
};
|
|
11
11
|
export type OpenOreArgs = {
|
|
12
12
|
user: PublicKey;
|
|
13
|
-
payer:
|
|
13
|
+
payer: Keypair;
|
|
14
14
|
name: string;
|
|
15
15
|
referralName: string;
|
|
16
16
|
};
|
|
@@ -452,11 +452,11 @@ export type TriadProtocol = {
|
|
|
452
452
|
};
|
|
453
453
|
},
|
|
454
454
|
{
|
|
455
|
-
name: '
|
|
455
|
+
name: 'proofInfo';
|
|
456
456
|
writable: true;
|
|
457
457
|
},
|
|
458
458
|
{
|
|
459
|
-
name: '
|
|
459
|
+
name: 'bus';
|
|
460
460
|
writable: true;
|
|
461
461
|
},
|
|
462
462
|
{
|
|
@@ -1277,9 +1277,6 @@ export type TriadProtocol = {
|
|
|
1277
1277
|
},
|
|
1278
1278
|
{
|
|
1279
1279
|
name: 'mineArgs';
|
|
1280
|
-
repr: {
|
|
1281
|
-
kind: 'c';
|
|
1282
|
-
};
|
|
1283
1280
|
type: {
|
|
1284
1281
|
kind: 'struct';
|
|
1285
1282
|
fields: [
|
|
@@ -7,3 +7,4 @@ export declare const TTRIAD_DECIMALS = 6;
|
|
|
7
7
|
export declare const TTRIAD_MINT = "t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV";
|
|
8
8
|
export declare const TTRIAD_FEE = 2;
|
|
9
9
|
export declare const ORE_PROGRAM_ID = "oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ";
|
|
10
|
+
export declare const NOOP_PROGRAM_ID = "noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW";
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ORE_PROGRAM_ID = exports.TTRIAD_FEE = exports.TTRIAD_MINT = exports.TTRIAD_DECIMALS = exports.STAKE_SEASON = exports.VERIFIER = exports.ADMIN = exports.ATA_PROGRAM_ID = exports.TRIAD_PROTOCOL_PROGRAM_ID = void 0;
|
|
3
|
+
exports.NOOP_PROGRAM_ID = exports.ORE_PROGRAM_ID = exports.TTRIAD_FEE = exports.TTRIAD_MINT = exports.TTRIAD_DECIMALS = exports.STAKE_SEASON = exports.VERIFIER = exports.ADMIN = exports.ATA_PROGRAM_ID = exports.TRIAD_PROTOCOL_PROGRAM_ID = void 0;
|
|
4
4
|
exports.TRIAD_PROTOCOL_PROGRAM_ID = 'TRDwq3BN4mP3m9KsuNUWSN6QDff93VKGSwE95Jbr9Ss';
|
|
5
5
|
exports.ATA_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
6
6
|
exports.ADMIN = '';
|
|
@@ -10,3 +10,4 @@ exports.TTRIAD_DECIMALS = 6;
|
|
|
10
10
|
exports.TTRIAD_MINT = 't3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV';
|
|
11
11
|
exports.TTRIAD_FEE = 2;
|
|
12
12
|
exports.ORE_PROGRAM_ID = 'oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ';
|
|
13
|
+
exports.NOOP_PROGRAM_ID = 'noop8ytexvkpCuqbf6FB89BSuNemHtPRqaNC31GWivW';
|