@triadxyz/triad-protocol 1.4.2-beta → 1.4.4-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 CHANGED
@@ -318,4 +318,11 @@ export default class TriadProtocolClient {
318
318
  } & {
319
319
  trd10000: Record<string, never>;
320
320
  })>;
321
+ /**
322
+ * Buy Token
323
+ * @param amount - Amount of tokens to buy
324
+ * @param options - RPC options
325
+ *
326
+ */
327
+ buyToken(amount: number, options?: RpcOptions): Promise<string>;
321
328
  }
package/dist/index.js CHANGED
@@ -208,13 +208,14 @@ 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, constants_1.SPIN_NAME);
212
211
  const ix = yield this.program.methods
213
- .claimSpinToken(new anchor_1.BN(amount))
212
+ .claimSpinToken({
213
+ name: constants_1.SPIN_NAME,
214
+ amount: new anchor_1.BN(amount * Math.pow(10, 6))
215
+ })
214
216
  .accounts({
215
217
  signer: this.provider.wallet.publicKey,
216
218
  verifier: verifier.publicKey,
217
- spin: spinPDA,
218
219
  mint: constants_1.TCMAS_MINT
219
220
  })
220
221
  .instruction();
@@ -264,5 +265,20 @@ class TriadProtocolClient {
264
265
  return prize.prizeType;
265
266
  });
266
267
  }
268
+ /**
269
+ * Buy Token
270
+ * @param amount - Amount of tokens to buy
271
+ * @param options - RPC options
272
+ *
273
+ */
274
+ buyToken(amount, options) {
275
+ return __awaiter(this, void 0, void 0, function* () {
276
+ const method = this.program.methods.buyToken(new anchor_1.BN(amount)).accounts({
277
+ signer: this.provider.wallet.publicKey,
278
+ mint: constants_1.TCMAS_MINT
279
+ });
280
+ return (0, sendTransactionWithOptions_1.default)(method, options);
281
+ });
282
+ }
267
283
  }
268
284
  exports.default = TriadProtocolClient;
@@ -413,25 +413,104 @@ const getMinteds = () => __awaiter(void 0, void 0, void 0, function* () {
413
413
  console.log(response);
414
414
  });
415
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%
416
+ // (1, 9, PrizeType::Trd10000), // 0.0014%
417
+ // (10, 15, PrizeType::Undead), // 0.0014%
418
+ // (16, 116, PrizeType::Ticket), // 0.01%
419
+ // (117, 617, PrizeType::Honeyland), // 0.05%
420
+ // (618, 5618, PrizeType::Trd50), // 0.5%
421
+ // (5619, 15619, PrizeType::Flip), // 1%
422
+ // (15620, 25620, PrizeType::Pengu), // 1%
423
+ // (25621, 65621, PrizeType::Ore), // 4%
424
+ // (65622, 165622, PrizeType::Lucksea), // 10%
425
+ // (165623, 285623, PrizeType::Trd5), // 12%
426
+ // (285624, 499999, PrizeType::Trident2000), // 21.3385%
427
427
  // (500000, 1000000, PrizeType::Trident500), // 50%
428
428
  // ];
429
429
  const addSpinPrize = () => __awaiter(void 0, void 0, void 0, function* () {
430
- const response = yield triadProtocol.addSpinPrize({
431
- rangeMin: 26615,
432
- rangeMax: 66614,
433
- prizeType: { ore: {} },
434
- availableQuantity: 500
430
+ const data = [
431
+ {
432
+ rangeMin: 1,
433
+ rangeMax: 9,
434
+ prizeType: { trd10000: {} },
435
+ availableQuantity: 1
436
+ },
437
+ {
438
+ rangeMin: 10,
439
+ rangeMax: 15,
440
+ prizeType: { undead: {} },
441
+ availableQuantity: 1
442
+ },
443
+ {
444
+ rangeMin: 16,
445
+ rangeMax: 116,
446
+ prizeType: { ticket: {} },
447
+ availableQuantity: 2
448
+ },
449
+ {
450
+ rangeMin: 117,
451
+ rangeMax: 617,
452
+ prizeType: { honeyland: {} },
453
+ availableQuantity: 7
454
+ },
455
+ {
456
+ rangeMin: 618,
457
+ rangeMax: 5618,
458
+ prizeType: { trd50: {} },
459
+ availableQuantity: 50
460
+ },
461
+ {
462
+ rangeMin: 5619,
463
+ rangeMax: 15619,
464
+ prizeType: { flip: {} },
465
+ availableQuantity: 30
466
+ },
467
+ {
468
+ rangeMin: 15620,
469
+ rangeMax: 25620,
470
+ prizeType: { pengu: {} },
471
+ availableQuantity: 100
472
+ },
473
+ {
474
+ rangeMin: 25621,
475
+ rangeMax: 65621,
476
+ prizeType: { ore: {} },
477
+ availableQuantity: 500
478
+ },
479
+ {
480
+ rangeMin: 65622,
481
+ rangeMax: 165622,
482
+ prizeType: { lucksea: {} },
483
+ availableQuantity: 2000
484
+ },
485
+ {
486
+ rangeMin: 165623,
487
+ rangeMax: 285623,
488
+ prizeType: { trd5: {} },
489
+ availableQuantity: 1000
490
+ },
491
+ {
492
+ rangeMin: 285624,
493
+ rangeMax: 499999,
494
+ prizeType: { trident2000: {} },
495
+ availableQuantity: 500000
496
+ },
497
+ {
498
+ rangeMin: 500000,
499
+ rangeMax: 1000000,
500
+ prizeType: { trident500: {} },
501
+ availableQuantity: 500000
502
+ }
503
+ ];
504
+ for (const item of data) {
505
+ const response = yield triadProtocol.addSpinPrize(item);
506
+ console.log(response);
507
+ }
508
+ });
509
+ const spinWheel = () => __awaiter(void 0, void 0, void 0, function* () {
510
+ const response = yield triadProtocol.spinWheel({
511
+ isSol: false,
512
+ prizeType: { none: {} },
513
+ verifier: keypair
435
514
  });
436
515
  console.log(response);
437
516
  });
@@ -445,11 +524,4 @@ const getSpinPrize = () => __awaiter(void 0, void 0, void 0, function* () {
445
524
  }));
446
525
  console.log(prizes);
447
526
  });
448
- const spinWheel = () => __awaiter(void 0, void 0, void 0, function* () {
449
- const response = yield triadProtocol.spinWheel({
450
- isSol: false,
451
- prizeType: { none: {} },
452
- verifier: keypair
453
- });
454
- console.log(response);
455
- });
527
+ getSpinPrize();
@@ -145,6 +145,116 @@
145
145
  }
146
146
  ]
147
147
  },
148
+ {
149
+ "name": "buy_token",
150
+ "discriminator": [138, 127, 14, 91, 38, 87, 115, 105],
151
+ "accounts": [
152
+ {
153
+ "name": "signer",
154
+ "writable": true,
155
+ "signer": true
156
+ },
157
+ {
158
+ "name": "spin",
159
+ "writable": true,
160
+ "pda": {
161
+ "seeds": [
162
+ {
163
+ "kind": "const",
164
+ "value": [115, 112, 105, 110]
165
+ },
166
+ {
167
+ "kind": "arg",
168
+ "path": "name"
169
+ }
170
+ ]
171
+ }
172
+ },
173
+ {
174
+ "name": "tresuary_account",
175
+ "writable": true,
176
+ "address": "82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR"
177
+ },
178
+ {
179
+ "name": "mint",
180
+ "writable": true
181
+ },
182
+ {
183
+ "name": "from_ata",
184
+ "writable": true,
185
+ "pda": {
186
+ "seeds": [
187
+ {
188
+ "kind": "account",
189
+ "path": "spin"
190
+ },
191
+ {
192
+ "kind": "account",
193
+ "path": "token_program"
194
+ },
195
+ {
196
+ "kind": "account",
197
+ "path": "mint"
198
+ }
199
+ ],
200
+ "program": {
201
+ "kind": "const",
202
+ "value": [
203
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
204
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
205
+ 219, 233, 248, 89
206
+ ]
207
+ }
208
+ }
209
+ },
210
+ {
211
+ "name": "to_ata",
212
+ "writable": true,
213
+ "pda": {
214
+ "seeds": [
215
+ {
216
+ "kind": "account",
217
+ "path": "signer"
218
+ },
219
+ {
220
+ "kind": "account",
221
+ "path": "token_program"
222
+ },
223
+ {
224
+ "kind": "account",
225
+ "path": "mint"
226
+ }
227
+ ],
228
+ "program": {
229
+ "kind": "const",
230
+ "value": [
231
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
232
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
233
+ 219, 233, 248, 89
234
+ ]
235
+ }
236
+ }
237
+ },
238
+ {
239
+ "name": "token_program",
240
+ "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
241
+ },
242
+ {
243
+ "name": "associated_token_program",
244
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
245
+ },
246
+ {
247
+ "name": "system_program",
248
+ "address": "11111111111111111111111111111111"
249
+ }
250
+ ],
251
+ "args": [
252
+ {
253
+ "name": "amount",
254
+ "type": "u64"
255
+ }
256
+ ]
257
+ },
148
258
  {
149
259
  "name": "claim_spin_token",
150
260
  "discriminator": [253, 217, 186, 91, 131, 36, 163, 235],
@@ -161,7 +271,19 @@
161
271
  },
162
272
  {
163
273
  "name": "spin",
164
- "writable": true
274
+ "writable": true,
275
+ "pda": {
276
+ "seeds": [
277
+ {
278
+ "kind": "const",
279
+ "value": [115, 112, 105, 110]
280
+ },
281
+ {
282
+ "kind": "arg",
283
+ "path": "args.name"
284
+ }
285
+ ]
286
+ }
165
287
  },
166
288
  {
167
289
  "name": "mint",
@@ -238,8 +360,12 @@
238
360
  ],
239
361
  "args": [
240
362
  {
241
- "name": "amount",
242
- "type": "u64"
363
+ "name": "args",
364
+ "type": {
365
+ "defined": {
366
+ "name": "ClaimSpinTokenArgs"
367
+ }
368
+ }
243
369
  }
244
370
  ]
245
371
  },
@@ -1951,6 +2077,22 @@
1951
2077
  ]
1952
2078
  }
1953
2079
  },
2080
+ {
2081
+ "name": "ClaimSpinTokenArgs",
2082
+ "type": {
2083
+ "kind": "struct",
2084
+ "fields": [
2085
+ {
2086
+ "name": "name",
2087
+ "type": "string"
2088
+ },
2089
+ {
2090
+ "name": "amount",
2091
+ "type": "u64"
2092
+ }
2093
+ ]
2094
+ }
2095
+ },
1954
2096
  {
1955
2097
  "name": "ClaimSpinTokenUpdate",
1956
2098
  "type": {
@@ -209,6 +209,174 @@ export type TriadProtocol = {
209
209
  }
210
210
  ];
211
211
  },
212
+ {
213
+ name: 'buyToken';
214
+ discriminator: [138, 127, 14, 91, 38, 87, 115, 105];
215
+ accounts: [
216
+ {
217
+ name: 'signer';
218
+ writable: true;
219
+ signer: true;
220
+ },
221
+ {
222
+ name: 'spin';
223
+ writable: true;
224
+ pda: {
225
+ seeds: [
226
+ {
227
+ kind: 'const';
228
+ value: [115, 112, 105, 110];
229
+ },
230
+ {
231
+ kind: 'arg';
232
+ path: 'name';
233
+ }
234
+ ];
235
+ };
236
+ },
237
+ {
238
+ name: 'tresuaryAccount';
239
+ writable: true;
240
+ address: '82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR';
241
+ },
242
+ {
243
+ name: 'mint';
244
+ writable: true;
245
+ },
246
+ {
247
+ name: 'fromAta';
248
+ writable: true;
249
+ pda: {
250
+ seeds: [
251
+ {
252
+ kind: 'account';
253
+ path: 'spin';
254
+ },
255
+ {
256
+ kind: 'account';
257
+ path: 'tokenProgram';
258
+ },
259
+ {
260
+ kind: 'account';
261
+ path: 'mint';
262
+ }
263
+ ];
264
+ program: {
265
+ kind: 'const';
266
+ value: [
267
+ 140,
268
+ 151,
269
+ 37,
270
+ 143,
271
+ 78,
272
+ 36,
273
+ 137,
274
+ 241,
275
+ 187,
276
+ 61,
277
+ 16,
278
+ 41,
279
+ 20,
280
+ 142,
281
+ 13,
282
+ 131,
283
+ 11,
284
+ 90,
285
+ 19,
286
+ 153,
287
+ 218,
288
+ 255,
289
+ 16,
290
+ 132,
291
+ 4,
292
+ 142,
293
+ 123,
294
+ 216,
295
+ 219,
296
+ 233,
297
+ 248,
298
+ 89
299
+ ];
300
+ };
301
+ };
302
+ },
303
+ {
304
+ name: 'toAta';
305
+ writable: true;
306
+ pda: {
307
+ seeds: [
308
+ {
309
+ kind: 'account';
310
+ path: 'signer';
311
+ },
312
+ {
313
+ kind: 'account';
314
+ path: 'tokenProgram';
315
+ },
316
+ {
317
+ kind: 'account';
318
+ path: 'mint';
319
+ }
320
+ ];
321
+ program: {
322
+ kind: 'const';
323
+ value: [
324
+ 140,
325
+ 151,
326
+ 37,
327
+ 143,
328
+ 78,
329
+ 36,
330
+ 137,
331
+ 241,
332
+ 187,
333
+ 61,
334
+ 16,
335
+ 41,
336
+ 20,
337
+ 142,
338
+ 13,
339
+ 131,
340
+ 11,
341
+ 90,
342
+ 19,
343
+ 153,
344
+ 218,
345
+ 255,
346
+ 16,
347
+ 132,
348
+ 4,
349
+ 142,
350
+ 123,
351
+ 216,
352
+ 219,
353
+ 233,
354
+ 248,
355
+ 89
356
+ ];
357
+ };
358
+ };
359
+ },
360
+ {
361
+ name: 'tokenProgram';
362
+ address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
363
+ },
364
+ {
365
+ name: 'associatedTokenProgram';
366
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
367
+ },
368
+ {
369
+ name: 'systemProgram';
370
+ address: '11111111111111111111111111111111';
371
+ }
372
+ ];
373
+ args: [
374
+ {
375
+ name: 'amount';
376
+ type: 'u64';
377
+ }
378
+ ];
379
+ },
212
380
  {
213
381
  name: 'claimSpinToken';
214
382
  discriminator: [253, 217, 186, 91, 131, 36, 163, 235];
@@ -226,6 +394,18 @@ export type TriadProtocol = {
226
394
  {
227
395
  name: 'spin';
228
396
  writable: true;
397
+ pda: {
398
+ seeds: [
399
+ {
400
+ kind: 'const';
401
+ value: [115, 112, 105, 110];
402
+ },
403
+ {
404
+ kind: 'arg';
405
+ path: 'args.name';
406
+ }
407
+ ];
408
+ };
229
409
  },
230
410
  {
231
411
  name: 'mint';
@@ -360,8 +540,12 @@ export type TriadProtocol = {
360
540
  ];
361
541
  args: [
362
542
  {
363
- name: 'amount';
364
- type: 'u64';
543
+ name: 'args';
544
+ type: {
545
+ defined: {
546
+ name: 'claimSpinTokenArgs';
547
+ };
548
+ };
365
549
  }
366
550
  ];
367
551
  },
@@ -2711,6 +2895,22 @@ export type TriadProtocol = {
2711
2895
  ];
2712
2896
  };
2713
2897
  },
2898
+ {
2899
+ name: 'claimSpinTokenArgs';
2900
+ type: {
2901
+ kind: 'struct';
2902
+ fields: [
2903
+ {
2904
+ name: 'name';
2905
+ type: 'string';
2906
+ },
2907
+ {
2908
+ name: 'amount';
2909
+ type: 'u64';
2910
+ }
2911
+ ];
2912
+ };
2913
+ },
2714
2914
  {
2715
2915
  name: 'claimSpinTokenUpdate';
2716
2916
  type: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.4.2-beta",
3
+ "version": "1.4.4-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",