@triadxyz/poseidons-protocol 0.3.4 → 0.3.6
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/game/chest.js +6 -6
- package/dist/game/index.d.ts +3 -1
- package/dist/game/index.js +16 -8
- package/dist/game/wheel.d.ts +4 -2
- package/dist/game/wheel.js +19 -15
- package/dist/types/idl_poseidons_protocol.json +1 -2
- package/dist/types/poseidons_protocol.d.ts +0 -1
- package/package.json +1 -1
package/dist/game/chest.js
CHANGED
|
@@ -52,7 +52,7 @@ class Chest {
|
|
|
52
52
|
*/
|
|
53
53
|
createChest({ id, price, amount }) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const
|
|
55
|
+
const ixs = [
|
|
56
56
|
yield this.program.methods
|
|
57
57
|
.createChest({
|
|
58
58
|
id: new anchor_1.BN(id),
|
|
@@ -64,7 +64,7 @@ class Chest {
|
|
|
64
64
|
})
|
|
65
65
|
.instruction()
|
|
66
66
|
];
|
|
67
|
-
return (0, sendVersionedTransaction_1.default)(this.program,
|
|
67
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
@@ -76,7 +76,7 @@ class Chest {
|
|
|
76
76
|
*/
|
|
77
77
|
placeChestBid({ id, coins }) {
|
|
78
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const
|
|
79
|
+
const ixs = [
|
|
80
80
|
yield this.program.methods
|
|
81
81
|
.placeChestBid({
|
|
82
82
|
id: new anchor_1.BN(id),
|
|
@@ -88,7 +88,7 @@ class Chest {
|
|
|
88
88
|
})
|
|
89
89
|
.instruction()
|
|
90
90
|
];
|
|
91
|
-
return (0, sendVersionedTransaction_1.default)(this.program,
|
|
91
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -100,7 +100,7 @@ class Chest {
|
|
|
100
100
|
*/
|
|
101
101
|
addChestWinners({ id, grandWinner, top10 }) {
|
|
102
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const
|
|
103
|
+
const ixs = [
|
|
104
104
|
yield this.program.methods
|
|
105
105
|
.addChestWinners({
|
|
106
106
|
id: new anchor_1.BN(id),
|
|
@@ -118,7 +118,7 @@ class Chest {
|
|
|
118
118
|
})
|
|
119
119
|
.instruction()
|
|
120
120
|
];
|
|
121
|
-
return (0, sendVersionedTransaction_1.default)(this.program,
|
|
121
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
}
|
package/dist/game/index.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export default class Game {
|
|
|
17
17
|
* @param spins - The number of spins to add
|
|
18
18
|
* @returns The transaction signature or versioned transaction
|
|
19
19
|
*/
|
|
20
|
-
addSpin({ user, spins }: {
|
|
20
|
+
addSpin({ user, spins, refer, newUser }: {
|
|
21
21
|
user: PublicKey;
|
|
22
22
|
spins: number;
|
|
23
|
+
refer: PublicKey;
|
|
24
|
+
newUser: boolean;
|
|
23
25
|
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
24
26
|
}
|
package/dist/game/index.js
CHANGED
|
@@ -30,19 +30,27 @@ class Game {
|
|
|
30
30
|
* @param spins - The number of spins to add
|
|
31
31
|
* @returns The transaction signature or versioned transaction
|
|
32
32
|
*/
|
|
33
|
-
addSpin({ user, spins }) {
|
|
33
|
+
addSpin({ user, spins, refer, newUser }) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
const userPDA = (0, pda_1.getUserPDA)(user);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const ixs = [];
|
|
37
|
+
if (newUser) {
|
|
38
|
+
ixs.push(yield this.program.methods
|
|
39
|
+
.createUser(refer)
|
|
39
40
|
.accounts({
|
|
40
41
|
signer: this.program.provider.publicKey,
|
|
41
|
-
|
|
42
|
+
payer: this.rpcOptions.payer
|
|
42
43
|
})
|
|
43
|
-
.instruction()
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
.instruction());
|
|
45
|
+
}
|
|
46
|
+
ixs.push(yield this.program.methods
|
|
47
|
+
.addSpin(new anchor_1.BN(spins))
|
|
48
|
+
.accounts({
|
|
49
|
+
signer: this.program.provider.publicKey,
|
|
50
|
+
user: userPDA
|
|
51
|
+
})
|
|
52
|
+
.instruction());
|
|
53
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
56
|
}
|
package/dist/game/wheel.d.ts
CHANGED
|
@@ -53,11 +53,13 @@ export default class Wheel {
|
|
|
53
53
|
* @param spins - The number of spins
|
|
54
54
|
* @returns The transaction signature or versioned transaction
|
|
55
55
|
*/
|
|
56
|
-
spinWheel({ user, id, spins }: {
|
|
56
|
+
spinWheel({ user, id, spins, refer, newUser }: {
|
|
57
57
|
user: PublicKey;
|
|
58
58
|
id: number;
|
|
59
59
|
spins: number;
|
|
60
|
-
|
|
60
|
+
refer: PublicKey;
|
|
61
|
+
newUser: boolean;
|
|
62
|
+
}): Promise<{
|
|
61
63
|
transaction: string;
|
|
62
64
|
prize: number[];
|
|
63
65
|
}>;
|
package/dist/game/wheel.js
CHANGED
|
@@ -52,7 +52,7 @@ class Wheel {
|
|
|
52
52
|
*/
|
|
53
53
|
createWheel({ id, name, prizes }) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const
|
|
55
|
+
const ixs = [
|
|
56
56
|
yield this.program.methods
|
|
57
57
|
.createWheel({
|
|
58
58
|
id,
|
|
@@ -71,7 +71,7 @@ class Wheel {
|
|
|
71
71
|
})
|
|
72
72
|
.instruction()
|
|
73
73
|
];
|
|
74
|
-
return (0, sendVersionedTransaction_1.default)(this.program,
|
|
74
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
@@ -82,7 +82,7 @@ class Wheel {
|
|
|
82
82
|
*/
|
|
83
83
|
addWheelPrize({ id, available }) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const
|
|
85
|
+
const ixs = [
|
|
86
86
|
yield this.program.methods
|
|
87
87
|
.addWheelPrize({
|
|
88
88
|
id,
|
|
@@ -93,7 +93,7 @@ class Wheel {
|
|
|
93
93
|
})
|
|
94
94
|
.instruction()
|
|
95
95
|
];
|
|
96
|
-
return (0, sendVersionedTransaction_1.default)(this.program,
|
|
96
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
@@ -102,14 +102,22 @@ class Wheel {
|
|
|
102
102
|
* @param spins - The number of spins
|
|
103
103
|
* @returns The transaction signature or versioned transaction
|
|
104
104
|
*/
|
|
105
|
-
spinWheel({ user, id, spins }) {
|
|
106
|
-
var _a, _b;
|
|
105
|
+
spinWheel({ user, id, spins, refer, newUser }) {
|
|
107
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
107
|
const userPDA = (0, pda_1.getUserPDA)(user);
|
|
109
108
|
const wheelPDA = (0, pda_1.getWheelPDA)(id);
|
|
110
|
-
const
|
|
109
|
+
const ixs = [];
|
|
110
|
+
if (newUser) {
|
|
111
|
+
ixs.push(yield this.program.methods
|
|
112
|
+
.createUser(refer)
|
|
113
|
+
.accounts({
|
|
114
|
+
signer: this.program.provider.publicKey,
|
|
115
|
+
payer: this.rpcOptions.payer
|
|
116
|
+
})
|
|
117
|
+
.instruction());
|
|
118
|
+
}
|
|
111
119
|
for (let i = 0; i < spins; i++) {
|
|
112
|
-
|
|
120
|
+
ixs.push(yield this.program.methods
|
|
113
121
|
.spinWheel()
|
|
114
122
|
.accounts({
|
|
115
123
|
signer: this.program.provider.publicKey,
|
|
@@ -118,11 +126,7 @@ class Wheel {
|
|
|
118
126
|
})
|
|
119
127
|
.instruction());
|
|
120
128
|
}
|
|
121
|
-
|
|
122
|
-
((_b = (_a = this.rpcOptions) === null || _a === void 0 ? void 0 : _a.payer) === null || _b === void 0 ? void 0 : _b.toBase58())) {
|
|
123
|
-
return (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions);
|
|
124
|
-
}
|
|
125
|
-
const transaction = (yield (0, sendVersionedTransaction_1.default)(this.program, instructions, this.rpcOptions));
|
|
129
|
+
const transaction = (yield (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions));
|
|
126
130
|
const { blockhash, lastValidBlockHeight } = yield this.program.provider.connection.getLatestBlockhash();
|
|
127
131
|
yield this.program.provider.connection.confirmTransaction({
|
|
128
132
|
signature: transaction,
|
|
@@ -143,7 +147,7 @@ class Wheel {
|
|
|
143
147
|
closeWheel(id) {
|
|
144
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
149
|
const wheelPDA = (0, pda_1.getWheelPDA)(id);
|
|
146
|
-
const
|
|
150
|
+
const ixs = [
|
|
147
151
|
yield this.program.methods
|
|
148
152
|
.closeWheel()
|
|
149
153
|
.accounts({
|
|
@@ -152,7 +156,7 @@ class Wheel {
|
|
|
152
156
|
})
|
|
153
157
|
.instruction()
|
|
154
158
|
];
|
|
155
|
-
return (0, sendVersionedTransaction_1.default)(this.program,
|
|
159
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
156
160
|
});
|
|
157
161
|
}
|
|
158
162
|
}
|