@triadxyz/triad-protocol 1.3.2-beta → 1.3.3-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.d.ts +2 -2
- package/dist/index.js +18 -7
- package/dist/local-test.js +42 -1
- package/dist/types/idl_triad_protocol.json +34 -29
- package/dist/types/triad_protocol.d.ts +33 -28
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.js +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -77,10 +77,10 @@ export default class TriadProtocolClient {
|
|
|
77
77
|
*/
|
|
78
78
|
claimSpinToken(amount: number, verifier: Keypair, options?: RpcOptions): Promise<string>;
|
|
79
79
|
/**
|
|
80
|
-
* Spin
|
|
80
|
+
* Spin Wheel
|
|
81
81
|
* @param isSol - Whether to pay with SOL or token
|
|
82
82
|
* @param verifier - Verifier keypair
|
|
83
83
|
* @param options - RPC options
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
spinWheel(isSol: boolean, options?: RpcOptions): Promise<any>;
|
|
86
86
|
}
|
package/dist/index.js
CHANGED
|
@@ -208,34 +208,45 @@ class TriadProtocolClient {
|
|
|
208
208
|
*/
|
|
209
209
|
claimSpinToken(amount, verifier, options) {
|
|
210
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId,
|
|
211
|
+
const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId, constants_1.SPIN_NAME);
|
|
212
212
|
const ix = yield this.program.methods
|
|
213
213
|
.claimSpinToken(new anchor_1.BN(amount))
|
|
214
214
|
.accounts({
|
|
215
215
|
signer: this.provider.wallet.publicKey,
|
|
216
216
|
verifier: verifier.publicKey,
|
|
217
217
|
spin: spinPDA,
|
|
218
|
-
mint:
|
|
218
|
+
mint: constants_1.TCMAS_MINT
|
|
219
219
|
})
|
|
220
220
|
.instruction();
|
|
221
221
|
return (0, sendVersionedTransaction_1.default)(this.provider, [ix], options, undefined, [], verifier);
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
* Spin
|
|
225
|
+
* Spin Wheel
|
|
226
226
|
* @param isSol - Whether to pay with SOL or token
|
|
227
227
|
* @param verifier - Verifier keypair
|
|
228
228
|
* @param options - RPC options
|
|
229
229
|
*/
|
|
230
|
-
|
|
230
|
+
spinWheel(isSol, options) {
|
|
231
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
-
const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId,
|
|
233
|
-
const method = this.program.methods.
|
|
232
|
+
const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId, constants_1.SPIN_NAME);
|
|
233
|
+
const method = this.program.methods.spinWheel(isSol).accounts({
|
|
234
234
|
signer: this.provider.wallet.publicKey,
|
|
235
235
|
spin: spinPDA,
|
|
236
236
|
mint: new web3_js_1.PublicKey('9LGNCsQsoeJK2jBMKNiX8UGJv5NPyBHhouTcQLLqWTt9')
|
|
237
237
|
});
|
|
238
|
-
|
|
238
|
+
const tx = yield (0, sendTransactionWithOptions_1.default)(method, options);
|
|
239
|
+
const txLogs = yield this.provider.connection.getTransaction(tx, {
|
|
240
|
+
commitment: 'confirmed',
|
|
241
|
+
maxSupportedTransactionVersion: 0
|
|
242
|
+
});
|
|
243
|
+
const eventLog = txLogs.meta.logMessages.find((log) => log.includes('RouletteSpinResult'));
|
|
244
|
+
if (!eventLog) {
|
|
245
|
+
throw new Error('Spin result not found in transaction logs');
|
|
246
|
+
}
|
|
247
|
+
const prizeType = JSON.parse(eventLog.split('RouletteSpinResult')[1]).data
|
|
248
|
+
.prize;
|
|
249
|
+
return prizeType;
|
|
239
250
|
});
|
|
240
251
|
}
|
|
241
252
|
}
|
package/dist/local-test.js
CHANGED
|
@@ -19,7 +19,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
19
19
|
const trade_1 = require("./types/trade");
|
|
20
20
|
const spl_token_1 = require("@solana/spl-token");
|
|
21
21
|
const constants_1 = require("./utils/constants");
|
|
22
|
-
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/
|
|
22
|
+
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
|
|
23
23
|
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
|
|
24
24
|
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
25
25
|
const connection = new web3_js_1.Connection('https://mainnet.helius-rpc.com/?api-key=05843ded-2085-4567-aff3-85af84ea71d2');
|
|
@@ -412,3 +412,44 @@ const getMinteds = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
412
412
|
const response = yield triadProtocol.program.account.collection.all();
|
|
413
413
|
console.log(response);
|
|
414
414
|
});
|
|
415
|
+
// let prize_ranges = [
|
|
416
|
+
// (1, 14, PrizeType::Undead), // 0.0014%
|
|
417
|
+
// (15, 114, PrizeType::Ticket), // 0.01%
|
|
418
|
+
// (115, 614, PrizeType::Honeyland), // 0.05%
|
|
419
|
+
// (615, 1614, PrizeType::Trd100), // 0.1%
|
|
420
|
+
// (1615, 6614, PrizeType::Trd50), // 0.5%
|
|
421
|
+
// (6615, 16614, PrizeType::Flip), // 1%
|
|
422
|
+
// (16615, 26614, PrizeType::Pengu), // 1%
|
|
423
|
+
// (26615, 66614, PrizeType::Ore), // 4%
|
|
424
|
+
// (66615, 166614, PrizeType::Lucksea), // 10%
|
|
425
|
+
// (166615, 286614, PrizeType::Trd5), // 12%
|
|
426
|
+
// (286615, 499999, PrizeType::Trident2000), // 21.3385%
|
|
427
|
+
// (500000, 1000000, PrizeType::Trident500), // 50%
|
|
428
|
+
// ];
|
|
429
|
+
const addSpinPrize = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
430
|
+
const response = yield triadProtocol.addSpinPrize({
|
|
431
|
+
rangeMin: 66615,
|
|
432
|
+
rangeMax: 166614,
|
|
433
|
+
prizeType: { lucksea: {} },
|
|
434
|
+
availableQuantity: 2000
|
|
435
|
+
});
|
|
436
|
+
console.log(response);
|
|
437
|
+
});
|
|
438
|
+
const getSpinPrize = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
439
|
+
let response = yield triadProtocol.program.account.spin.fetch(new web3_js_1.PublicKey('EQ6ZJbdT2V8ZYcHRpJx6wBkGWmM1e3mimtPKshTVuw8h'));
|
|
440
|
+
const prizes = response.prizes.map((prize) => ({
|
|
441
|
+
rangeMin: prize.rangeMin.toNumber(),
|
|
442
|
+
rangeMax: prize.rangeMax.toNumber(),
|
|
443
|
+
prizeType: prize.prizeType,
|
|
444
|
+
availableQuantity: prize.availableQuantity.toNumber()
|
|
445
|
+
}));
|
|
446
|
+
console.log(prizes);
|
|
447
|
+
});
|
|
448
|
+
const spinWheel = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
449
|
+
const response = yield triadProtocol.spinWheel(false, {
|
|
450
|
+
skipPreflight: true,
|
|
451
|
+
microLamports: 5000
|
|
452
|
+
});
|
|
453
|
+
console.log(response);
|
|
454
|
+
});
|
|
455
|
+
spinWheel();
|
|
@@ -1313,8 +1313,8 @@
|
|
|
1313
1313
|
]
|
|
1314
1314
|
},
|
|
1315
1315
|
{
|
|
1316
|
-
"name": "
|
|
1317
|
-
"discriminator": [
|
|
1316
|
+
"name": "spin_wheel",
|
|
1317
|
+
"discriminator": [25, 214, 214, 83, 131, 150, 190, 91],
|
|
1318
1318
|
"accounts": [
|
|
1319
1319
|
{
|
|
1320
1320
|
"name": "signer",
|
|
@@ -1408,7 +1408,12 @@
|
|
|
1408
1408
|
"name": "is_sol",
|
|
1409
1409
|
"type": "bool"
|
|
1410
1410
|
}
|
|
1411
|
-
]
|
|
1411
|
+
],
|
|
1412
|
+
"returns": {
|
|
1413
|
+
"defined": {
|
|
1414
|
+
"name": "PrizeType"
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1412
1417
|
},
|
|
1413
1418
|
{
|
|
1414
1419
|
"name": "stake_token",
|
|
@@ -1809,8 +1814,8 @@
|
|
|
1809
1814
|
"discriminator": [222, 51, 180, 226, 165, 188, 203, 54]
|
|
1810
1815
|
},
|
|
1811
1816
|
{
|
|
1812
|
-
"name": "
|
|
1813
|
-
"discriminator": [
|
|
1817
|
+
"name": "SpinWheelResult",
|
|
1818
|
+
"discriminator": [98, 31, 244, 65, 124, 192, 160, 79]
|
|
1814
1819
|
},
|
|
1815
1820
|
{
|
|
1816
1821
|
"name": "StakeRewards",
|
|
@@ -3061,30 +3066,6 @@
|
|
|
3061
3066
|
]
|
|
3062
3067
|
}
|
|
3063
3068
|
},
|
|
3064
|
-
{
|
|
3065
|
-
"name": "RouletteSpinResult",
|
|
3066
|
-
"type": {
|
|
3067
|
-
"kind": "struct",
|
|
3068
|
-
"fields": [
|
|
3069
|
-
{
|
|
3070
|
-
"name": "player",
|
|
3071
|
-
"type": "pubkey"
|
|
3072
|
-
},
|
|
3073
|
-
{
|
|
3074
|
-
"name": "prize",
|
|
3075
|
-
"type": {
|
|
3076
|
-
"defined": {
|
|
3077
|
-
"name": "PrizeType"
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
},
|
|
3081
|
-
{
|
|
3082
|
-
"name": "amount",
|
|
3083
|
-
"type": "u64"
|
|
3084
|
-
}
|
|
3085
|
-
]
|
|
3086
|
-
}
|
|
3087
|
-
},
|
|
3088
3069
|
{
|
|
3089
3070
|
"name": "Spin",
|
|
3090
3071
|
"type": {
|
|
@@ -3124,6 +3105,30 @@
|
|
|
3124
3105
|
]
|
|
3125
3106
|
}
|
|
3126
3107
|
},
|
|
3108
|
+
{
|
|
3109
|
+
"name": "SpinWheelResult",
|
|
3110
|
+
"type": {
|
|
3111
|
+
"kind": "struct",
|
|
3112
|
+
"fields": [
|
|
3113
|
+
{
|
|
3114
|
+
"name": "player",
|
|
3115
|
+
"type": "pubkey"
|
|
3116
|
+
},
|
|
3117
|
+
{
|
|
3118
|
+
"name": "prize",
|
|
3119
|
+
"type": {
|
|
3120
|
+
"defined": {
|
|
3121
|
+
"name": "PrizeType"
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
{
|
|
3126
|
+
"name": "amount",
|
|
3127
|
+
"type": "u64"
|
|
3128
|
+
}
|
|
3129
|
+
]
|
|
3130
|
+
}
|
|
3131
|
+
},
|
|
3127
3132
|
{
|
|
3128
3133
|
"name": "StakeRewards",
|
|
3129
3134
|
"type": {
|
|
@@ -1841,8 +1841,8 @@ export type TriadProtocol = {
|
|
|
1841
1841
|
];
|
|
1842
1842
|
},
|
|
1843
1843
|
{
|
|
1844
|
-
name: '
|
|
1845
|
-
discriminator: [
|
|
1844
|
+
name: 'spinWheel';
|
|
1845
|
+
discriminator: [25, 214, 214, 83, 131, 150, 190, 91];
|
|
1846
1846
|
accounts: [
|
|
1847
1847
|
{
|
|
1848
1848
|
name: 'signer';
|
|
@@ -1995,6 +1995,11 @@ export type TriadProtocol = {
|
|
|
1995
1995
|
type: 'bool';
|
|
1996
1996
|
}
|
|
1997
1997
|
];
|
|
1998
|
+
returns: {
|
|
1999
|
+
defined: {
|
|
2000
|
+
name: 'prizeType';
|
|
2001
|
+
};
|
|
2002
|
+
};
|
|
1998
2003
|
},
|
|
1999
2004
|
{
|
|
2000
2005
|
name: 'stakeToken';
|
|
@@ -2569,8 +2574,8 @@ export type TriadProtocol = {
|
|
|
2569
2574
|
discriminator: [222, 51, 180, 226, 165, 188, 203, 54];
|
|
2570
2575
|
},
|
|
2571
2576
|
{
|
|
2572
|
-
name: '
|
|
2573
|
-
discriminator: [
|
|
2577
|
+
name: 'spinWheelResult';
|
|
2578
|
+
discriminator: [98, 31, 244, 65, 124, 192, 160, 79];
|
|
2574
2579
|
},
|
|
2575
2580
|
{
|
|
2576
2581
|
name: 'stakeRewards';
|
|
@@ -3817,30 +3822,6 @@ export type TriadProtocol = {
|
|
|
3817
3822
|
];
|
|
3818
3823
|
};
|
|
3819
3824
|
},
|
|
3820
|
-
{
|
|
3821
|
-
name: 'rouletteSpinResult';
|
|
3822
|
-
type: {
|
|
3823
|
-
kind: 'struct';
|
|
3824
|
-
fields: [
|
|
3825
|
-
{
|
|
3826
|
-
name: 'player';
|
|
3827
|
-
type: 'pubkey';
|
|
3828
|
-
},
|
|
3829
|
-
{
|
|
3830
|
-
name: 'prize';
|
|
3831
|
-
type: {
|
|
3832
|
-
defined: {
|
|
3833
|
-
name: 'prizeType';
|
|
3834
|
-
};
|
|
3835
|
-
};
|
|
3836
|
-
},
|
|
3837
|
-
{
|
|
3838
|
-
name: 'amount';
|
|
3839
|
-
type: 'u64';
|
|
3840
|
-
}
|
|
3841
|
-
];
|
|
3842
|
-
};
|
|
3843
|
-
},
|
|
3844
3825
|
{
|
|
3845
3826
|
name: 'spin';
|
|
3846
3827
|
type: {
|
|
@@ -3880,6 +3861,30 @@ export type TriadProtocol = {
|
|
|
3880
3861
|
];
|
|
3881
3862
|
};
|
|
3882
3863
|
},
|
|
3864
|
+
{
|
|
3865
|
+
name: 'spinWheelResult';
|
|
3866
|
+
type: {
|
|
3867
|
+
kind: 'struct';
|
|
3868
|
+
fields: [
|
|
3869
|
+
{
|
|
3870
|
+
name: 'player';
|
|
3871
|
+
type: 'pubkey';
|
|
3872
|
+
},
|
|
3873
|
+
{
|
|
3874
|
+
name: 'prize';
|
|
3875
|
+
type: {
|
|
3876
|
+
defined: {
|
|
3877
|
+
name: 'prizeType';
|
|
3878
|
+
};
|
|
3879
|
+
};
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
name: 'amount';
|
|
3883
|
+
type: 'u64';
|
|
3884
|
+
}
|
|
3885
|
+
];
|
|
3886
|
+
};
|
|
3887
|
+
},
|
|
3883
3888
|
{
|
|
3884
3889
|
name: 'stakeRewards';
|
|
3885
3890
|
type: {
|
|
@@ -6,3 +6,5 @@ export declare const TRD_MINT: PublicKey;
|
|
|
6
6
|
export declare const TRIAD_ADMIN: PublicKey;
|
|
7
7
|
export declare const SOL_MINT: PublicKey;
|
|
8
8
|
export declare const TICKET_CORE_COLLECTION: PublicKey;
|
|
9
|
+
export declare const SPIN_NAME = "christmas";
|
|
10
|
+
export declare const TCMAS_MINT: PublicKey;
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
|
|
3
|
+
exports.TCMAS_MINT = exports.SPIN_NAME = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
exports.STAKE_VAULT_NAME = 'Triad Share 1';
|
|
6
6
|
exports.TRD_DECIMALS = 6;
|
|
@@ -9,3 +9,5 @@ exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQ
|
|
|
9
9
|
exports.TRIAD_ADMIN = new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR');
|
|
10
10
|
exports.SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
|
|
11
11
|
exports.TICKET_CORE_COLLECTION = new web3_js_1.PublicKey('BaqopH1VXYUCT6VsojbTibVcd3k5jpGGT6296HFb6fVa');
|
|
12
|
+
exports.SPIN_NAME = 'christmas';
|
|
13
|
+
exports.TCMAS_MINT = new web3_js_1.PublicKey('9LGNCsQsoeJK2jBMKNiX8UGJv5NPyBHhouTcQLLqWTt9');
|