@triadxyz/poseidons-protocol 0.2.1 → 0.2.2

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.
@@ -1,10 +1,24 @@
1
+ /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
1
2
  import { Program } from '@coral-xyz/anchor';
3
+ import { PublicKey } from '@solana/web3.js';
2
4
  import { PoseidonsProtocol } from './../types/poseidons_protocol';
3
5
  import { RpcOptions } from './../types';
4
6
  import Chest from './chest';
7
+ import Wheel from './wheel';
5
8
  export default class Game {
6
9
  private program;
7
10
  private rpcOptions;
8
11
  chest: Chest;
12
+ wheel: Wheel;
9
13
  constructor(program: Program<PoseidonsProtocol>, rpcOptions: RpcOptions);
14
+ /**
15
+ * Add spins to a user
16
+ * @param user - The user to add spins to
17
+ * @param spins - The number of spins to add
18
+ * @returns The transaction signature or versioned transaction
19
+ */
20
+ addSpin({ user, spins }: {
21
+ user: PublicKey;
22
+ spins: number;
23
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
10
24
  }
@@ -1,14 +1,49 @@
1
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
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const anchor_1 = require("@coral-xyz/anchor");
6
16
  const chest_1 = __importDefault(require("./chest"));
17
+ const wheel_1 = __importDefault(require("./wheel"));
18
+ const sendVersionedTransaction_1 = __importDefault(require("../utils/sendVersionedTransaction"));
19
+ const pda_1 = require("../utils/pda");
7
20
  class Game {
8
21
  constructor(program, rpcOptions) {
9
22
  this.program = program;
10
23
  this.rpcOptions = rpcOptions;
11
24
  this.chest = new chest_1.default(this.program, this.rpcOptions);
25
+ this.wheel = new wheel_1.default(this.program, this.rpcOptions);
26
+ }
27
+ /**
28
+ * Add spins to a user
29
+ * @param user - The user to add spins to
30
+ * @param spins - The number of spins to add
31
+ * @returns The transaction signature or versioned transaction
32
+ */
33
+ addSpin({ user, spins }) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const userPDA = (0, pda_1.getUserPDA)(user);
36
+ const instructions = [
37
+ yield this.program.methods
38
+ .addSpin(new anchor_1.BN(spins))
39
+ .accounts({
40
+ signer: this.program.provider.publicKey,
41
+ user: userPDA
42
+ })
43
+ .instruction()
44
+ ];
45
+ return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
46
+ });
12
47
  }
13
48
  }
14
49
  exports.default = Game;
@@ -0,0 +1,61 @@
1
+ /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
2
+ import { PublicKey } from '@solana/web3.js';
3
+ import { Program } from '@coral-xyz/anchor';
4
+ import { PoseidonsProtocol } from './../types/poseidons_protocol';
5
+ import { RpcOptions } from './../types';
6
+ export default class Wheel {
7
+ private program;
8
+ private rpcOptions;
9
+ constructor(program: Program<PoseidonsProtocol>, rpcOptions: RpcOptions);
10
+ /**
11
+ * Get all wheels
12
+ * @returns The chests
13
+ */
14
+ getAllWheel(): Promise<import("./../types").Wheel[]>;
15
+ /**
16
+ * Get a wheel
17
+ * @param id - The id of the wheel
18
+ * @returns The wheel
19
+ */
20
+ getWheel(id: number): Promise<import("./../types").Wheel>;
21
+ /**
22
+ * Create a wheel
23
+ * @param id - The id of the wheel
24
+ * @param name - The name of the wheel
25
+ * @param prizes - The prizes of the wheel
26
+ * @returns The transaction signature or versioned transaction
27
+ */
28
+ createWheel({ id, name, prizes }: {
29
+ id: number;
30
+ name: string;
31
+ prizes: {
32
+ id: number;
33
+ name: string;
34
+ available: number;
35
+ rangeMin: number;
36
+ rangeMax: number;
37
+ unit: number;
38
+ }[];
39
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
40
+ /**
41
+ * Add a prize to a wheel
42
+ * @param id - The id of the chest
43
+ * @param available - The available quantity of the prize
44
+ * @returns The transaction signature or versioned transaction
45
+ */
46
+ addWheelPrize({ id, available }: {
47
+ id: number;
48
+ available: number;
49
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
50
+ /**
51
+ * Spin a wheel
52
+ * @param id - The id of the wheel
53
+ * @param spins - The number of spins
54
+ * @returns The transaction signature or versioned transaction
55
+ */
56
+ spinWheel({ user, id, spins }: {
57
+ user: PublicKey;
58
+ id: number;
59
+ spins: number;
60
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
61
+ }
@@ -0,0 +1,124 @@
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 anchor_1 = require("@coral-xyz/anchor");
16
+ const sendVersionedTransaction_1 = __importDefault(require("./../utils/sendVersionedTransaction"));
17
+ const pda_1 = require("./../utils/pda");
18
+ const helpers_1 = require("./../utils/helpers");
19
+ class Wheel {
20
+ constructor(program, rpcOptions) {
21
+ this.program = program;
22
+ this.rpcOptions = rpcOptions;
23
+ }
24
+ /**
25
+ * Get all wheels
26
+ * @returns The chests
27
+ */
28
+ getAllWheel() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const wheels = yield this.program.account.wheel.all();
31
+ return wheels.map((wheel) => (0, helpers_1.formatWheel)(wheel.account, wheel.publicKey));
32
+ });
33
+ }
34
+ /**
35
+ * Get a wheel
36
+ * @param id - The id of the wheel
37
+ * @returns The wheel
38
+ */
39
+ getWheel(id) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const wheelPDA = (0, pda_1.getWheelPDA)(id);
42
+ const wheel = yield this.program.account.wheel.fetch(wheelPDA, this.rpcOptions.commitment);
43
+ return (0, helpers_1.formatWheel)(wheel, wheelPDA);
44
+ });
45
+ }
46
+ /**
47
+ * Create a wheel
48
+ * @param id - The id of the wheel
49
+ * @param name - The name of the wheel
50
+ * @param prizes - The prizes of the wheel
51
+ * @returns The transaction signature or versioned transaction
52
+ */
53
+ createWheel({ id, name, prizes }) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const instructions = [
56
+ yield this.program.methods
57
+ .createWheel({
58
+ id,
59
+ name,
60
+ prizes: prizes.map((prize) => ({
61
+ id: prize.id,
62
+ name: prize.name,
63
+ available: new anchor_1.BN(prize.available),
64
+ rangeMin: new anchor_1.BN(prize.rangeMin),
65
+ rangeMax: new anchor_1.BN(prize.rangeMax),
66
+ unit: new anchor_1.BN(prize.unit)
67
+ }))
68
+ })
69
+ .accounts({
70
+ signer: this.program.provider.publicKey
71
+ })
72
+ .instruction()
73
+ ];
74
+ return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
75
+ });
76
+ }
77
+ /**
78
+ * Add a prize to a wheel
79
+ * @param id - The id of the chest
80
+ * @param available - The available quantity of the prize
81
+ * @returns The transaction signature or versioned transaction
82
+ */
83
+ addWheelPrize({ id, available }) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const instructions = [
86
+ yield this.program.methods
87
+ .addWheelPrize({
88
+ id,
89
+ available: new anchor_1.BN(available)
90
+ })
91
+ .accounts({
92
+ signer: this.program.provider.publicKey
93
+ })
94
+ .instruction()
95
+ ];
96
+ return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
97
+ });
98
+ }
99
+ /**
100
+ * Spin a wheel
101
+ * @param id - The id of the wheel
102
+ * @param spins - The number of spins
103
+ * @returns The transaction signature or versioned transaction
104
+ */
105
+ spinWheel({ user, id, spins }) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const userPDA = (0, pda_1.getUserPDA)(user);
108
+ const instructions = [
109
+ yield this.program.methods
110
+ .spinWheel({
111
+ id,
112
+ spins: new anchor_1.BN(spins)
113
+ })
114
+ .accounts({
115
+ signer: this.program.provider.publicKey,
116
+ user: userPDA
117
+ })
118
+ .instruction()
119
+ ];
120
+ return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
121
+ });
122
+ }
123
+ }
124
+ exports.default = Wheel;
@@ -272,6 +272,77 @@
272
272
  }
273
273
  ]
274
274
  },
275
+ {
276
+ "name": "add_spin",
277
+ "discriminator": [168, 78, 42, 73, 116, 58, 113, 193],
278
+ "accounts": [
279
+ {
280
+ "name": "signer",
281
+ "writable": true,
282
+ "signer": true
283
+ },
284
+ {
285
+ "name": "squads",
286
+ "writable": true,
287
+ "address": "Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4"
288
+ },
289
+ {
290
+ "name": "user",
291
+ "writable": true
292
+ },
293
+ {
294
+ "name": "system_program",
295
+ "address": "11111111111111111111111111111111"
296
+ }
297
+ ],
298
+ "args": [
299
+ {
300
+ "name": "spins",
301
+ "type": "u64"
302
+ }
303
+ ]
304
+ },
305
+ {
306
+ "name": "add_wheel_prize",
307
+ "discriminator": [171, 239, 227, 40, 5, 150, 213, 239],
308
+ "accounts": [
309
+ {
310
+ "name": "signer",
311
+ "writable": true,
312
+ "signer": true
313
+ },
314
+ {
315
+ "name": "wheel",
316
+ "writable": true,
317
+ "pda": {
318
+ "seeds": [
319
+ {
320
+ "kind": "const",
321
+ "value": [119, 104, 101, 108, 108]
322
+ },
323
+ {
324
+ "kind": "arg",
325
+ "path": "args.id"
326
+ }
327
+ ]
328
+ }
329
+ },
330
+ {
331
+ "name": "system_program",
332
+ "address": "11111111111111111111111111111111"
333
+ }
334
+ ],
335
+ "args": [
336
+ {
337
+ "name": "args",
338
+ "type": {
339
+ "defined": {
340
+ "name": "AddWheelPrizeArgs"
341
+ }
342
+ }
343
+ }
344
+ ]
345
+ },
275
346
  {
276
347
  "name": "burn_nft",
277
348
  "discriminator": [119, 13, 183, 17, 194, 243, 38, 31],
@@ -628,6 +699,47 @@
628
699
  }
629
700
  ]
630
701
  },
702
+ {
703
+ "name": "create_wheel",
704
+ "discriminator": [175, 177, 194, 49, 117, 130, 179, 161],
705
+ "accounts": [
706
+ {
707
+ "name": "signer",
708
+ "writable": true,
709
+ "signer": true
710
+ },
711
+ {
712
+ "name": "wheel",
713
+ "writable": true,
714
+ "pda": {
715
+ "seeds": [
716
+ {
717
+ "kind": "const",
718
+ "value": [119, 104, 101, 108, 108]
719
+ },
720
+ {
721
+ "kind": "arg",
722
+ "path": "args.id"
723
+ }
724
+ ]
725
+ }
726
+ },
727
+ {
728
+ "name": "system_program",
729
+ "address": "11111111111111111111111111111111"
730
+ }
731
+ ],
732
+ "args": [
733
+ {
734
+ "name": "args",
735
+ "type": {
736
+ "defined": {
737
+ "name": "CreateWheelArgs"
738
+ }
739
+ }
740
+ }
741
+ ]
742
+ },
631
743
  {
632
744
  "name": "place_chest_bid",
633
745
  "discriminator": [82, 31, 146, 177, 220, 1, 7, 157],
@@ -750,6 +862,52 @@
750
862
  }
751
863
  }
752
864
  ]
865
+ },
866
+ {
867
+ "name": "spin_wheel",
868
+ "discriminator": [25, 214, 214, 83, 131, 150, 190, 91],
869
+ "accounts": [
870
+ {
871
+ "name": "signer",
872
+ "writable": true,
873
+ "signer": true
874
+ },
875
+ {
876
+ "name": "wheel",
877
+ "writable": true,
878
+ "pda": {
879
+ "seeds": [
880
+ {
881
+ "kind": "const",
882
+ "value": [119, 104, 101, 108, 108]
883
+ },
884
+ {
885
+ "kind": "arg",
886
+ "path": "args.id"
887
+ }
888
+ ]
889
+ }
890
+ },
891
+ {
892
+ "name": "user",
893
+ "writable": true
894
+ },
895
+ {
896
+ "name": "system_program",
897
+ "address": "11111111111111111111111111111111"
898
+ }
899
+ ],
900
+ "args": [
901
+ {
902
+ "name": "args",
903
+ "type": {
904
+ "defined": {
905
+ "name": "SpinWheelArgs"
906
+ }
907
+ }
908
+ }
909
+ ],
910
+ "returns": "u8"
753
911
  }
754
912
  ],
755
913
  "accounts": [
@@ -776,6 +934,10 @@
776
934
  {
777
935
  "name": "User",
778
936
  "discriminator": [159, 117, 95, 227, 239, 151, 58, 236]
937
+ },
938
+ {
939
+ "name": "Wheel",
940
+ "discriminator": [196, 41, 11, 47, 123, 180, 10, 219]
779
941
  }
780
942
  ],
781
943
  "events": [
@@ -783,6 +945,10 @@
783
945
  "name": "BidChestEvent",
784
946
  "discriminator": [162, 64, 11, 176, 231, 173, 217, 89]
785
947
  },
948
+ {
949
+ "name": "BuySpinEvent",
950
+ "discriminator": [253, 97, 83, 130, 75, 128, 156, 7]
951
+ },
786
952
  {
787
953
  "name": "ChestCreatedEvent",
788
954
  "discriminator": [27, 178, 135, 161, 240, 189, 246, 238]
@@ -807,6 +973,10 @@
807
973
  "name": "PoseidonRewardsEvent",
808
974
  "discriminator": [93, 26, 205, 192, 107, 244, 92, 119]
809
975
  },
976
+ {
977
+ "name": "SpinWheelEvent",
978
+ "discriminator": [136, 0, 170, 174, 167, 129, 91, 187]
979
+ },
810
980
  {
811
981
  "name": "UserCreatedEvent",
812
982
  "discriminator": [41, 186, 252, 198, 103, 111, 139, 224]
@@ -842,6 +1012,16 @@
842
1012
  "code": 6005,
843
1013
  "name": "InvalidRefer",
844
1014
  "msg": "Invalid refer"
1015
+ },
1016
+ {
1017
+ "code": 6006,
1018
+ "name": "InsufficientFunds",
1019
+ "msg": "Insufficient funds"
1020
+ },
1021
+ {
1022
+ "code": 6007,
1023
+ "name": "InsufficientSpins",
1024
+ "msg": "Insufficient spins"
845
1025
  }
846
1026
  ],
847
1027
  "types": [
@@ -878,6 +1058,22 @@
878
1058
  ]
879
1059
  }
880
1060
  },
1061
+ {
1062
+ "name": "AddWheelPrizeArgs",
1063
+ "type": {
1064
+ "kind": "struct",
1065
+ "fields": [
1066
+ {
1067
+ "name": "id",
1068
+ "type": "u8"
1069
+ },
1070
+ {
1071
+ "name": "available",
1072
+ "type": "u64"
1073
+ }
1074
+ ]
1075
+ }
1076
+ },
881
1077
  {
882
1078
  "name": "BaseAssetV1",
883
1079
  "type": {
@@ -988,6 +1184,30 @@
988
1184
  ]
989
1185
  }
990
1186
  },
1187
+ {
1188
+ "name": "BuySpinEvent",
1189
+ "type": {
1190
+ "kind": "struct",
1191
+ "fields": [
1192
+ {
1193
+ "name": "user",
1194
+ "type": "pubkey"
1195
+ },
1196
+ {
1197
+ "name": "spins",
1198
+ "type": "u64"
1199
+ },
1200
+ {
1201
+ "name": "fee",
1202
+ "type": "u64"
1203
+ },
1204
+ {
1205
+ "name": "timestamp",
1206
+ "type": "i64"
1207
+ }
1208
+ ]
1209
+ }
1210
+ },
991
1211
  {
992
1212
  "name": "Chest",
993
1213
  "type": {
@@ -1240,6 +1460,35 @@
1240
1460
  ]
1241
1461
  }
1242
1462
  },
1463
+ {
1464
+ "name": "CreateWheelArgs",
1465
+ "type": {
1466
+ "kind": "struct",
1467
+ "fields": [
1468
+ {
1469
+ "name": "id",
1470
+ "type": "u8"
1471
+ },
1472
+ {
1473
+ "name": "name",
1474
+ "type": "string"
1475
+ },
1476
+ {
1477
+ "name": "prizes",
1478
+ "type": {
1479
+ "array": [
1480
+ {
1481
+ "defined": {
1482
+ "name": "Prize"
1483
+ }
1484
+ },
1485
+ 12
1486
+ ]
1487
+ }
1488
+ }
1489
+ ]
1490
+ }
1491
+ },
1243
1492
  {
1244
1493
  "name": "Key",
1245
1494
  "type": {
@@ -1454,6 +1703,74 @@
1454
1703
  ]
1455
1704
  }
1456
1705
  },
1706
+ {
1707
+ "name": "Prize",
1708
+ "type": {
1709
+ "kind": "struct",
1710
+ "fields": [
1711
+ {
1712
+ "name": "id",
1713
+ "type": "u8"
1714
+ },
1715
+ {
1716
+ "name": "name",
1717
+ "type": "string"
1718
+ },
1719
+ {
1720
+ "name": "available",
1721
+ "type": "u64"
1722
+ },
1723
+ {
1724
+ "name": "range_min",
1725
+ "type": "u64"
1726
+ },
1727
+ {
1728
+ "name": "range_max",
1729
+ "type": "u64"
1730
+ },
1731
+ {
1732
+ "name": "unit",
1733
+ "type": "u64"
1734
+ }
1735
+ ]
1736
+ }
1737
+ },
1738
+ {
1739
+ "name": "SpinWheelArgs",
1740
+ "type": {
1741
+ "kind": "struct",
1742
+ "fields": [
1743
+ {
1744
+ "name": "id",
1745
+ "type": "u8"
1746
+ },
1747
+ {
1748
+ "name": "spins",
1749
+ "type": "u64"
1750
+ }
1751
+ ]
1752
+ }
1753
+ },
1754
+ {
1755
+ "name": "SpinWheelEvent",
1756
+ "type": {
1757
+ "kind": "struct",
1758
+ "fields": [
1759
+ {
1760
+ "name": "user",
1761
+ "type": "pubkey"
1762
+ },
1763
+ {
1764
+ "name": "prize_id",
1765
+ "type": "u8"
1766
+ },
1767
+ {
1768
+ "name": "timestamp",
1769
+ "type": "i64"
1770
+ }
1771
+ ]
1772
+ }
1773
+ },
1457
1774
  {
1458
1775
  "name": "UpdateAuthority",
1459
1776
  "type": {
@@ -1498,10 +1815,14 @@
1498
1815
  "name": "coins",
1499
1816
  "type": "u64"
1500
1817
  },
1818
+ {
1819
+ "name": "spins",
1820
+ "type": "u64"
1821
+ },
1501
1822
  {
1502
1823
  "name": "padding",
1503
1824
  "type": {
1504
- "array": ["u8", 56]
1825
+ "array": ["u8", 48]
1505
1826
  }
1506
1827
  }
1507
1828
  ]
@@ -1530,6 +1851,49 @@
1530
1851
  }
1531
1852
  ]
1532
1853
  }
1854
+ },
1855
+ {
1856
+ "name": "Wheel",
1857
+ "type": {
1858
+ "kind": "struct",
1859
+ "fields": [
1860
+ {
1861
+ "name": "bump",
1862
+ "type": "u8"
1863
+ },
1864
+ {
1865
+ "name": "id",
1866
+ "type": "u8"
1867
+ },
1868
+ {
1869
+ "name": "name",
1870
+ "type": "string"
1871
+ },
1872
+ {
1873
+ "name": "count",
1874
+ "type": "u64"
1875
+ },
1876
+ {
1877
+ "name": "prizes",
1878
+ "type": {
1879
+ "array": [
1880
+ {
1881
+ "defined": {
1882
+ "name": "Prize"
1883
+ }
1884
+ },
1885
+ 12
1886
+ ]
1887
+ }
1888
+ },
1889
+ {
1890
+ "name": "padding",
1891
+ "type": {
1892
+ "array": ["u8", 32]
1893
+ }
1894
+ }
1895
+ ]
1896
+ }
1533
1897
  }
1534
1898
  ]
1535
1899
  }
@@ -51,3 +51,18 @@ export type Chest = {
51
51
  createdAt: number;
52
52
  finishedAt: number;
53
53
  };
54
+ export type Wheel = {
55
+ address: string;
56
+ id: number;
57
+ name: string;
58
+ count: number;
59
+ prizes: Prize[];
60
+ };
61
+ export type Prize = {
62
+ id: number;
63
+ name: string;
64
+ available: number;
65
+ rangeMin: number;
66
+ rangeMax: number;
67
+ unit: number;
68
+ };
@@ -377,6 +377,77 @@ export type PoseidonsProtocol = {
377
377
  }
378
378
  ];
379
379
  },
380
+ {
381
+ name: 'addSpin';
382
+ discriminator: [168, 78, 42, 73, 116, 58, 113, 193];
383
+ accounts: [
384
+ {
385
+ name: 'signer';
386
+ writable: true;
387
+ signer: true;
388
+ },
389
+ {
390
+ name: 'squads';
391
+ writable: true;
392
+ address: 'Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4';
393
+ },
394
+ {
395
+ name: 'user';
396
+ writable: true;
397
+ },
398
+ {
399
+ name: 'systemProgram';
400
+ address: '11111111111111111111111111111111';
401
+ }
402
+ ];
403
+ args: [
404
+ {
405
+ name: 'spins';
406
+ type: 'u64';
407
+ }
408
+ ];
409
+ },
410
+ {
411
+ name: 'addWheelPrize';
412
+ discriminator: [171, 239, 227, 40, 5, 150, 213, 239];
413
+ accounts: [
414
+ {
415
+ name: 'signer';
416
+ writable: true;
417
+ signer: true;
418
+ },
419
+ {
420
+ name: 'wheel';
421
+ writable: true;
422
+ pda: {
423
+ seeds: [
424
+ {
425
+ kind: 'const';
426
+ value: [119, 104, 101, 108, 108];
427
+ },
428
+ {
429
+ kind: 'arg';
430
+ path: 'args.id';
431
+ }
432
+ ];
433
+ };
434
+ },
435
+ {
436
+ name: 'systemProgram';
437
+ address: '11111111111111111111111111111111';
438
+ }
439
+ ];
440
+ args: [
441
+ {
442
+ name: 'args';
443
+ type: {
444
+ defined: {
445
+ name: 'addWheelPrizeArgs';
446
+ };
447
+ };
448
+ }
449
+ ];
450
+ },
380
451
  {
381
452
  name: 'burnNft';
382
453
  discriminator: [119, 13, 183, 17, 194, 243, 38, 31];
@@ -861,6 +932,47 @@ export type PoseidonsProtocol = {
861
932
  }
862
933
  ];
863
934
  },
935
+ {
936
+ name: 'createWheel';
937
+ discriminator: [175, 177, 194, 49, 117, 130, 179, 161];
938
+ accounts: [
939
+ {
940
+ name: 'signer';
941
+ writable: true;
942
+ signer: true;
943
+ },
944
+ {
945
+ name: 'wheel';
946
+ writable: true;
947
+ pda: {
948
+ seeds: [
949
+ {
950
+ kind: 'const';
951
+ value: [119, 104, 101, 108, 108];
952
+ },
953
+ {
954
+ kind: 'arg';
955
+ path: 'args.id';
956
+ }
957
+ ];
958
+ };
959
+ },
960
+ {
961
+ name: 'systemProgram';
962
+ address: '11111111111111111111111111111111';
963
+ }
964
+ ];
965
+ args: [
966
+ {
967
+ name: 'args';
968
+ type: {
969
+ defined: {
970
+ name: 'createWheelArgs';
971
+ };
972
+ };
973
+ }
974
+ ];
975
+ },
864
976
  {
865
977
  name: 'placeChestBid';
866
978
  discriminator: [82, 31, 146, 177, 220, 1, 7, 157];
@@ -1041,6 +1153,52 @@ export type PoseidonsProtocol = {
1041
1153
  };
1042
1154
  }
1043
1155
  ];
1156
+ },
1157
+ {
1158
+ name: 'spinWheel';
1159
+ discriminator: [25, 214, 214, 83, 131, 150, 190, 91];
1160
+ accounts: [
1161
+ {
1162
+ name: 'signer';
1163
+ writable: true;
1164
+ signer: true;
1165
+ },
1166
+ {
1167
+ name: 'wheel';
1168
+ writable: true;
1169
+ pda: {
1170
+ seeds: [
1171
+ {
1172
+ kind: 'const';
1173
+ value: [119, 104, 101, 108, 108];
1174
+ },
1175
+ {
1176
+ kind: 'arg';
1177
+ path: 'args.id';
1178
+ }
1179
+ ];
1180
+ };
1181
+ },
1182
+ {
1183
+ name: 'user';
1184
+ writable: true;
1185
+ },
1186
+ {
1187
+ name: 'systemProgram';
1188
+ address: '11111111111111111111111111111111';
1189
+ }
1190
+ ];
1191
+ args: [
1192
+ {
1193
+ name: 'args';
1194
+ type: {
1195
+ defined: {
1196
+ name: 'spinWheelArgs';
1197
+ };
1198
+ };
1199
+ }
1200
+ ];
1201
+ returns: 'u8';
1044
1202
  }
1045
1203
  ];
1046
1204
  accounts: [
@@ -1067,6 +1225,10 @@ export type PoseidonsProtocol = {
1067
1225
  {
1068
1226
  name: 'user';
1069
1227
  discriminator: [159, 117, 95, 227, 239, 151, 58, 236];
1228
+ },
1229
+ {
1230
+ name: 'wheel';
1231
+ discriminator: [196, 41, 11, 47, 123, 180, 10, 219];
1070
1232
  }
1071
1233
  ];
1072
1234
  events: [
@@ -1074,6 +1236,10 @@ export type PoseidonsProtocol = {
1074
1236
  name: 'bidChestEvent';
1075
1237
  discriminator: [162, 64, 11, 176, 231, 173, 217, 89];
1076
1238
  },
1239
+ {
1240
+ name: 'buySpinEvent';
1241
+ discriminator: [253, 97, 83, 130, 75, 128, 156, 7];
1242
+ },
1077
1243
  {
1078
1244
  name: 'chestCreatedEvent';
1079
1245
  discriminator: [27, 178, 135, 161, 240, 189, 246, 238];
@@ -1098,6 +1264,10 @@ export type PoseidonsProtocol = {
1098
1264
  name: 'poseidonRewardsEvent';
1099
1265
  discriminator: [93, 26, 205, 192, 107, 244, 92, 119];
1100
1266
  },
1267
+ {
1268
+ name: 'spinWheelEvent';
1269
+ discriminator: [136, 0, 170, 174, 167, 129, 91, 187];
1270
+ },
1101
1271
  {
1102
1272
  name: 'userCreatedEvent';
1103
1273
  discriminator: [41, 186, 252, 198, 103, 111, 139, 224];
@@ -1133,6 +1303,16 @@ export type PoseidonsProtocol = {
1133
1303
  code: 6005;
1134
1304
  name: 'invalidRefer';
1135
1305
  msg: 'Invalid refer';
1306
+ },
1307
+ {
1308
+ code: 6006;
1309
+ name: 'insufficientFunds';
1310
+ msg: 'Insufficient funds';
1311
+ },
1312
+ {
1313
+ code: 6007;
1314
+ name: 'insufficientSpins';
1315
+ msg: 'Insufficient spins';
1136
1316
  }
1137
1317
  ];
1138
1318
  types: [
@@ -1169,6 +1349,22 @@ export type PoseidonsProtocol = {
1169
1349
  ];
1170
1350
  };
1171
1351
  },
1352
+ {
1353
+ name: 'addWheelPrizeArgs';
1354
+ type: {
1355
+ kind: 'struct';
1356
+ fields: [
1357
+ {
1358
+ name: 'id';
1359
+ type: 'u8';
1360
+ },
1361
+ {
1362
+ name: 'available';
1363
+ type: 'u64';
1364
+ }
1365
+ ];
1366
+ };
1367
+ },
1172
1368
  {
1173
1369
  name: 'baseAssetV1';
1174
1370
  type: {
@@ -1279,6 +1475,30 @@ export type PoseidonsProtocol = {
1279
1475
  ];
1280
1476
  };
1281
1477
  },
1478
+ {
1479
+ name: 'buySpinEvent';
1480
+ type: {
1481
+ kind: 'struct';
1482
+ fields: [
1483
+ {
1484
+ name: 'user';
1485
+ type: 'pubkey';
1486
+ },
1487
+ {
1488
+ name: 'spins';
1489
+ type: 'u64';
1490
+ },
1491
+ {
1492
+ name: 'fee';
1493
+ type: 'u64';
1494
+ },
1495
+ {
1496
+ name: 'timestamp';
1497
+ type: 'i64';
1498
+ }
1499
+ ];
1500
+ };
1501
+ },
1282
1502
  {
1283
1503
  name: 'chest';
1284
1504
  type: {
@@ -1531,6 +1751,35 @@ export type PoseidonsProtocol = {
1531
1751
  ];
1532
1752
  };
1533
1753
  },
1754
+ {
1755
+ name: 'createWheelArgs';
1756
+ type: {
1757
+ kind: 'struct';
1758
+ fields: [
1759
+ {
1760
+ name: 'id';
1761
+ type: 'u8';
1762
+ },
1763
+ {
1764
+ name: 'name';
1765
+ type: 'string';
1766
+ },
1767
+ {
1768
+ name: 'prizes';
1769
+ type: {
1770
+ array: [
1771
+ {
1772
+ defined: {
1773
+ name: 'prize';
1774
+ };
1775
+ },
1776
+ 12
1777
+ ];
1778
+ };
1779
+ }
1780
+ ];
1781
+ };
1782
+ },
1534
1783
  {
1535
1784
  name: 'key';
1536
1785
  type: {
@@ -1745,6 +1994,74 @@ export type PoseidonsProtocol = {
1745
1994
  ];
1746
1995
  };
1747
1996
  },
1997
+ {
1998
+ name: 'prize';
1999
+ type: {
2000
+ kind: 'struct';
2001
+ fields: [
2002
+ {
2003
+ name: 'id';
2004
+ type: 'u8';
2005
+ },
2006
+ {
2007
+ name: 'name';
2008
+ type: 'string';
2009
+ },
2010
+ {
2011
+ name: 'available';
2012
+ type: 'u64';
2013
+ },
2014
+ {
2015
+ name: 'rangeMin';
2016
+ type: 'u64';
2017
+ },
2018
+ {
2019
+ name: 'rangeMax';
2020
+ type: 'u64';
2021
+ },
2022
+ {
2023
+ name: 'unit';
2024
+ type: 'u64';
2025
+ }
2026
+ ];
2027
+ };
2028
+ },
2029
+ {
2030
+ name: 'spinWheelArgs';
2031
+ type: {
2032
+ kind: 'struct';
2033
+ fields: [
2034
+ {
2035
+ name: 'id';
2036
+ type: 'u8';
2037
+ },
2038
+ {
2039
+ name: 'spins';
2040
+ type: 'u64';
2041
+ }
2042
+ ];
2043
+ };
2044
+ },
2045
+ {
2046
+ name: 'spinWheelEvent';
2047
+ type: {
2048
+ kind: 'struct';
2049
+ fields: [
2050
+ {
2051
+ name: 'user';
2052
+ type: 'pubkey';
2053
+ },
2054
+ {
2055
+ name: 'prizeId';
2056
+ type: 'u8';
2057
+ },
2058
+ {
2059
+ name: 'timestamp';
2060
+ type: 'i64';
2061
+ }
2062
+ ];
2063
+ };
2064
+ },
1748
2065
  {
1749
2066
  name: 'updateAuthority';
1750
2067
  type: {
@@ -1789,10 +2106,14 @@ export type PoseidonsProtocol = {
1789
2106
  name: 'coins';
1790
2107
  type: 'u64';
1791
2108
  },
2109
+ {
2110
+ name: 'spins';
2111
+ type: 'u64';
2112
+ },
1792
2113
  {
1793
2114
  name: 'padding';
1794
2115
  type: {
1795
- array: ['u8', 56];
2116
+ array: ['u8', 48];
1796
2117
  };
1797
2118
  }
1798
2119
  ];
@@ -1821,6 +2142,49 @@ export type PoseidonsProtocol = {
1821
2142
  }
1822
2143
  ];
1823
2144
  };
2145
+ },
2146
+ {
2147
+ name: 'wheel';
2148
+ type: {
2149
+ kind: 'struct';
2150
+ fields: [
2151
+ {
2152
+ name: 'bump';
2153
+ type: 'u8';
2154
+ },
2155
+ {
2156
+ name: 'id';
2157
+ type: 'u8';
2158
+ },
2159
+ {
2160
+ name: 'name';
2161
+ type: 'string';
2162
+ },
2163
+ {
2164
+ name: 'count';
2165
+ type: 'u64';
2166
+ },
2167
+ {
2168
+ name: 'prizes';
2169
+ type: {
2170
+ array: [
2171
+ {
2172
+ defined: {
2173
+ name: 'prize';
2174
+ };
2175
+ },
2176
+ 12
2177
+ ];
2178
+ };
2179
+ },
2180
+ {
2181
+ name: 'padding';
2182
+ type: {
2183
+ array: ['u8', 32];
2184
+ };
2185
+ }
2186
+ ];
2187
+ };
1824
2188
  }
1825
2189
  ];
1826
2190
  };
@@ -1,8 +1,9 @@
1
1
  import { IdlAccounts } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { PoseidonsProtocol } from '../types/poseidons_protocol';
4
- import { PoseidonVault, Poseidon, Chest, User } from '../types';
4
+ import { PoseidonVault, Poseidon, Chest, User, Wheel } from '../types';
5
5
  export declare const formatPoseidonVault: (account: IdlAccounts<PoseidonsProtocol>['poseidonVault'], address: PublicKey) => PoseidonVault;
6
6
  export declare const formatPoseidon: (account: IdlAccounts<PoseidonsProtocol>['poseidon'], address: PublicKey) => Poseidon;
7
7
  export declare const formatUser: (account: IdlAccounts<PoseidonsProtocol>['user'], address: PublicKey) => User;
8
8
  export declare const formatChest: (account: IdlAccounts<PoseidonsProtocol>['chest'], address: PublicKey) => Chest;
9
+ export declare const formatWheel: (account: IdlAccounts<PoseidonsProtocol>['wheel'], address: PublicKey) => Wheel;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatChest = exports.formatUser = exports.formatPoseidon = exports.formatPoseidonVault = void 0;
3
+ exports.formatWheel = exports.formatChest = exports.formatUser = exports.formatPoseidon = exports.formatPoseidonVault = void 0;
4
4
  const formatPoseidonVault = (account, address) => {
5
5
  return {
6
6
  address: address.toString(),
@@ -60,3 +60,20 @@ const formatChest = (account, address) => {
60
60
  };
61
61
  };
62
62
  exports.formatChest = formatChest;
63
+ const formatWheel = (account, address) => {
64
+ return {
65
+ address: address.toString(),
66
+ id: account.id,
67
+ name: account.name,
68
+ count: account.count.toNumber(),
69
+ prizes: account.prizes.map((prize) => ({
70
+ id: prize.id,
71
+ name: prize.name,
72
+ available: prize.available.toNumber(),
73
+ rangeMin: prize.rangeMin.toNumber(),
74
+ rangeMax: prize.rangeMax.toNumber(),
75
+ unit: prize.unit.toNumber()
76
+ }))
77
+ };
78
+ };
79
+ exports.formatWheel = formatWheel;
@@ -4,3 +4,4 @@ export declare const getPoseidonVaultPDA: () => PublicKey;
4
4
  export declare const getPoseidonPDA: (mint: PublicKey) => PublicKey;
5
5
  export declare const getUserPDA: (authority: PublicKey) => PublicKey;
6
6
  export declare const getChestPDA: (id: number) => PublicKey;
7
+ export declare const getWheelPDA: (id: number) => PublicKey;
package/dist/utils/pda.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChestPDA = exports.getUserPDA = exports.getPoseidonPDA = exports.getPoseidonVaultPDA = exports.getTokenATA = void 0;
3
+ exports.getWheelPDA = exports.getChestPDA = exports.getUserPDA = exports.getPoseidonPDA = exports.getPoseidonVaultPDA = exports.getTokenATA = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  const constants_1 = require("./constants");
@@ -25,3 +25,7 @@ const getChestPDA = (id) => {
25
25
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('chest'), new anchor_1.BN(id).toArrayLike(Buffer, 'le', 8)], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
26
26
  };
27
27
  exports.getChestPDA = getChestPDA;
28
+ const getWheelPDA = (id) => {
29
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('wheel'), new anchor_1.BN(id).toArrayLike(Buffer, 'le', 8)], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
30
+ };
31
+ exports.getWheelPDA = getWheelPDA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/poseidons-protocol",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",