@triadxyz/poseidons-protocol 0.4.0 → 0.4.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.
@@ -37,9 +37,10 @@ export default class Chest {
37
37
  * @param refer - The refer of the user
38
38
  * @returns The transaction signature or versioned transaction
39
39
  */
40
- placeChestBid({ id, coins }: {
40
+ placeChestBid({ id, coins, refer }: {
41
41
  id: number;
42
42
  coins: number;
43
+ refer: PublicKey;
43
44
  }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
44
45
  /**
45
46
  * Add chest winners
@@ -74,20 +74,32 @@ class Chest {
74
74
  * @param refer - The refer of the user
75
75
  * @returns The transaction signature or versioned transaction
76
76
  */
77
- placeChestBid({ id, coins }) {
77
+ placeChestBid({ id, coins, refer }) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
- const ixs = [
80
- yield this.program.methods
81
- .placeChestBid({
82
- id: new anchor_1.BN(id),
83
- coins: new anchor_1.BN(coins)
84
- })
79
+ const ixs = [];
80
+ const userPDA = (0, pda_1.getUserPDA)(this.program.provider.publicKey);
81
+ try {
82
+ yield this.program.account.user.fetch(userPDA, this.rpcOptions.commitment);
83
+ }
84
+ catch (error) {
85
+ ixs.push(yield this.program.methods
86
+ .createUser(refer)
85
87
  .accounts({
86
88
  signer: this.program.provider.publicKey,
87
- user: (0, pda_1.getUserPDA)(this.program.provider.publicKey)
89
+ payer: this.rpcOptions.payer
88
90
  })
89
- .instruction()
90
- ];
91
+ .instruction());
92
+ }
93
+ ixs.push(yield this.program.methods
94
+ .placeChestBid({
95
+ id: new anchor_1.BN(id),
96
+ coins: new anchor_1.BN(coins)
97
+ })
98
+ .accounts({
99
+ signer: this.program.provider.publicKey,
100
+ user: (0, pda_1.getUserPDA)(this.program.provider.publicKey)
101
+ })
102
+ .instruction());
91
103
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
92
104
  });
93
105
  }
@@ -25,9 +25,10 @@ export default class Wheel {
25
25
  * @param prizes - The prizes of the wheel
26
26
  * @returns The transaction signature or versioned transaction
27
27
  */
28
- createWheel({ id, name, prizes }: {
28
+ createWheel({ id, name, cost, prizes }: {
29
29
  id: number;
30
30
  name: string;
31
+ cost: number;
31
32
  prizes: {
32
33
  id: number;
33
34
  name: string;
@@ -50,13 +50,14 @@ class Wheel {
50
50
  * @param prizes - The prizes of the wheel
51
51
  * @returns The transaction signature or versioned transaction
52
52
  */
53
- createWheel({ id, name, prizes }) {
53
+ createWheel({ id, name, cost, prizes }) {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  const ixs = [
56
56
  yield this.program.methods
57
57
  .createWheel({
58
58
  id,
59
59
  name,
60
+ cost: new anchor_1.BN(cost),
60
61
  prizes: prizes.map((prize) => ({
61
62
  id: prize.id,
62
63
  name: prize.name,
@@ -1519,6 +1519,10 @@
1519
1519
  "name": "name",
1520
1520
  "type": "string"
1521
1521
  },
1522
+ {
1523
+ "name": "cost",
1524
+ "type": "u64"
1525
+ },
1522
1526
  {
1523
1527
  "name": "prizes",
1524
1528
  "type": {
@@ -1794,6 +1798,10 @@
1794
1798
  "name": "prize_id",
1795
1799
  "type": "u8"
1796
1800
  },
1801
+ {
1802
+ "name": "wheel_id",
1803
+ "type": "u8"
1804
+ },
1797
1805
  {
1798
1806
  "name": "timestamp",
1799
1807
  "type": "i64"
@@ -1920,6 +1928,10 @@
1920
1928
  "name": "is_active",
1921
1929
  "type": "bool"
1922
1930
  },
1931
+ {
1932
+ "name": "cost",
1933
+ "type": "u64"
1934
+ },
1923
1935
  {
1924
1936
  "name": "padding",
1925
1937
  "type": {
@@ -1810,6 +1810,10 @@ export type PoseidonsProtocol = {
1810
1810
  name: 'name';
1811
1811
  type: 'string';
1812
1812
  },
1813
+ {
1814
+ name: 'cost';
1815
+ type: 'u64';
1816
+ },
1813
1817
  {
1814
1818
  name: 'prizes';
1815
1819
  type: {
@@ -2085,6 +2089,10 @@ export type PoseidonsProtocol = {
2085
2089
  name: 'prizeId';
2086
2090
  type: 'u8';
2087
2091
  },
2092
+ {
2093
+ name: 'wheelId';
2094
+ type: 'u8';
2095
+ },
2088
2096
  {
2089
2097
  name: 'timestamp';
2090
2098
  type: 'i64';
@@ -2211,6 +2219,10 @@ export type PoseidonsProtocol = {
2211
2219
  name: 'isActive';
2212
2220
  type: 'bool';
2213
2221
  },
2222
+ {
2223
+ name: 'cost';
2224
+ type: 'u64';
2225
+ },
2214
2226
  {
2215
2227
  name: 'padding';
2216
2228
  type: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/poseidons-protocol",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",