@triadxyz/poseidons-protocol 0.3.9 → 0.4.1
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.d.ts +2 -1
- package/dist/game/chest.js +22 -10
- package/dist/game/index.d.ts +5 -4
- package/dist/game/index.js +18 -13
- package/dist/game/wheel.d.ts +6 -5
- package/dist/game/wheel.js +2 -1
- package/dist/types/idl_poseidons_protocol.json +2 -14
- package/dist/types/poseidons_protocol.d.ts +1 -13
- package/package.json +1 -1
package/dist/game/chest.d.ts
CHANGED
|
@@ -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
|
package/dist/game/chest.js
CHANGED
|
@@ -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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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
|
}
|
package/dist/game/index.d.ts
CHANGED
|
@@ -17,10 +17,11 @@ 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({
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
addSpin({ users, refer }: {
|
|
21
|
+
users: {
|
|
22
|
+
user: PublicKey;
|
|
23
|
+
spins: number;
|
|
24
|
+
}[];
|
|
23
25
|
refer: PublicKey;
|
|
24
|
-
newUser: boolean;
|
|
25
26
|
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
26
27
|
}
|
package/dist/game/index.js
CHANGED
|
@@ -30,26 +30,31 @@ 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({
|
|
33
|
+
addSpin({ users, refer }) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const userPDA = (0, pda_1.getUserPDA)(user);
|
|
36
35
|
const ixs = [];
|
|
37
|
-
|
|
36
|
+
for (const user of users) {
|
|
37
|
+
const userPDA = (0, pda_1.getUserPDA)(user.user);
|
|
38
|
+
try {
|
|
39
|
+
yield this.program.account.user.fetch(userPDA, this.rpcOptions.commitment);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
ixs.push(yield this.program.methods
|
|
43
|
+
.createUser(refer)
|
|
44
|
+
.accounts({
|
|
45
|
+
signer: user.user,
|
|
46
|
+
payer: this.rpcOptions.payer
|
|
47
|
+
})
|
|
48
|
+
.instruction());
|
|
49
|
+
}
|
|
38
50
|
ixs.push(yield this.program.methods
|
|
39
|
-
.
|
|
51
|
+
.addSpin(new anchor_1.BN(user.spins))
|
|
40
52
|
.accounts({
|
|
41
|
-
signer:
|
|
42
|
-
|
|
53
|
+
signer: this.program.provider.publicKey,
|
|
54
|
+
user: userPDA
|
|
43
55
|
})
|
|
44
56
|
.instruction());
|
|
45
57
|
}
|
|
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
58
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
54
59
|
});
|
|
55
60
|
}
|
package/dist/game/wheel.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
3
|
import { Program } from '@coral-xyz/anchor';
|
|
3
4
|
import { PoseidonsProtocol } from './../types/poseidons_protocol';
|
|
4
5
|
import { RpcOptions } from './../types';
|
|
@@ -35,7 +36,7 @@ export default class Wheel {
|
|
|
35
36
|
rangeMax: number;
|
|
36
37
|
unit: number;
|
|
37
38
|
}[];
|
|
38
|
-
}): Promise<string | VersionedTransaction>;
|
|
39
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
39
40
|
/**
|
|
40
41
|
* Add a prize to a wheel
|
|
41
42
|
* @param id - The id of the chest
|
|
@@ -45,7 +46,7 @@ export default class Wheel {
|
|
|
45
46
|
addWheelPrize({ id, available }: {
|
|
46
47
|
id: number;
|
|
47
48
|
available: number;
|
|
48
|
-
}): Promise<string | VersionedTransaction>;
|
|
49
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
49
50
|
/**
|
|
50
51
|
* Spin a wheel
|
|
51
52
|
* @param id - The id of the wheel
|
|
@@ -58,12 +59,12 @@ export default class Wheel {
|
|
|
58
59
|
spins: number;
|
|
59
60
|
refer: PublicKey;
|
|
60
61
|
newUser: boolean;
|
|
61
|
-
}): Promise<string | VersionedTransaction>;
|
|
62
|
+
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
62
63
|
/**
|
|
63
64
|
* Close a wheel
|
|
64
65
|
* @param id - The id of the wheel
|
|
65
66
|
* @param isActive - The active status of the wheel
|
|
66
67
|
* @returns The transaction signature or versioned transaction
|
|
67
68
|
*/
|
|
68
|
-
closeWheel(id: number, isActive: boolean): Promise<string | VersionedTransaction>;
|
|
69
|
+
closeWheel(id: number, isActive: boolean): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
69
70
|
}
|
package/dist/game/wheel.js
CHANGED
|
@@ -313,19 +313,7 @@
|
|
|
313
313
|
},
|
|
314
314
|
{
|
|
315
315
|
"name": "wheel",
|
|
316
|
-
"writable": true
|
|
317
|
-
"pda": {
|
|
318
|
-
"seeds": [
|
|
319
|
-
{
|
|
320
|
-
"kind": "const",
|
|
321
|
-
"value": [119, 104, 101, 101, 108]
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
"kind": "arg",
|
|
325
|
-
"path": "args.id"
|
|
326
|
-
}
|
|
327
|
-
]
|
|
328
|
-
}
|
|
316
|
+
"writable": true
|
|
329
317
|
},
|
|
330
318
|
{
|
|
331
319
|
"name": "system_program",
|
|
@@ -809,7 +797,7 @@
|
|
|
809
797
|
},
|
|
810
798
|
{
|
|
811
799
|
"kind": "account",
|
|
812
|
-
"path": "refer
|
|
800
|
+
"path": "user.refer",
|
|
813
801
|
"account": "User"
|
|
814
802
|
}
|
|
815
803
|
]
|
|
@@ -419,18 +419,6 @@ export type PoseidonsProtocol = {
|
|
|
419
419
|
{
|
|
420
420
|
name: 'wheel';
|
|
421
421
|
writable: true;
|
|
422
|
-
pda: {
|
|
423
|
-
seeds: [
|
|
424
|
-
{
|
|
425
|
-
kind: 'const';
|
|
426
|
-
value: [119, 104, 101, 101, 108];
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
kind: 'arg';
|
|
430
|
-
path: 'args.id';
|
|
431
|
-
}
|
|
432
|
-
];
|
|
433
|
-
};
|
|
434
422
|
},
|
|
435
423
|
{
|
|
436
424
|
name: 'systemProgram';
|
|
@@ -1042,7 +1030,7 @@ export type PoseidonsProtocol = {
|
|
|
1042
1030
|
},
|
|
1043
1031
|
{
|
|
1044
1032
|
kind: 'account';
|
|
1045
|
-
path: 'refer
|
|
1033
|
+
path: 'user.refer';
|
|
1046
1034
|
account: 'user';
|
|
1047
1035
|
}
|
|
1048
1036
|
];
|