@triadxyz/poseidons-protocol 0.1.4 → 0.1.7
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
CHANGED
|
@@ -34,11 +34,13 @@ export default class Chest {
|
|
|
34
34
|
* Place a bid on a chest
|
|
35
35
|
* @param id - The id of the chest
|
|
36
36
|
* @param coins - The coins to bid
|
|
37
|
+
* @param refer - The refer of the user
|
|
37
38
|
* @returns The transaction signature or versioned transaction
|
|
38
39
|
*/
|
|
39
|
-
placeChestBid({ id, coins }: {
|
|
40
|
+
placeChestBid({ id, coins, refer }: {
|
|
40
41
|
id: number;
|
|
41
42
|
coins: number;
|
|
43
|
+
refer: PublicKey;
|
|
42
44
|
}): Promise<string | import("@solana/web3.js").VersionedTransaction>;
|
|
43
45
|
/**
|
|
44
46
|
* Add chest winners
|
package/dist/game/chest.js
CHANGED
|
@@ -71,9 +71,10 @@ class Chest {
|
|
|
71
71
|
* Place a bid on a chest
|
|
72
72
|
* @param id - The id of the chest
|
|
73
73
|
* @param coins - The coins to bid
|
|
74
|
+
* @param refer - The refer of the user
|
|
74
75
|
* @returns The transaction signature or versioned transaction
|
|
75
76
|
*/
|
|
76
|
-
placeChestBid({ id, coins }) {
|
|
77
|
+
placeChestBid({ id, coins, refer }) {
|
|
77
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
79
|
const instructions = [
|
|
79
80
|
yield this.program.methods
|
|
@@ -83,6 +84,7 @@ class Chest {
|
|
|
83
84
|
})
|
|
84
85
|
.accounts({
|
|
85
86
|
signer: this.program.provider.publicKey,
|
|
87
|
+
refer: (0, pda_1.getUserPDA)(refer),
|
|
86
88
|
user: (0, pda_1.getUserPDA)(this.program.provider.publicKey)
|
|
87
89
|
})
|
|
88
90
|
.instruction()
|
|
@@ -662,6 +662,10 @@
|
|
|
662
662
|
"name": "user",
|
|
663
663
|
"writable": true
|
|
664
664
|
},
|
|
665
|
+
{
|
|
666
|
+
"name": "refer",
|
|
667
|
+
"writable": true
|
|
668
|
+
},
|
|
665
669
|
{
|
|
666
670
|
"name": "mint",
|
|
667
671
|
"writable": true,
|
|
@@ -825,6 +829,11 @@
|
|
|
825
829
|
"code": 6004,
|
|
826
830
|
"name": "InvalidAmount",
|
|
827
831
|
"msg": "Invalid amount"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
"code": 6005,
|
|
835
|
+
"name": "InvalidRefer",
|
|
836
|
+
"msg": "Invalid refer"
|
|
828
837
|
}
|
|
829
838
|
],
|
|
830
839
|
"types": [
|
|
@@ -895,6 +895,10 @@ export type PoseidonsProtocol = {
|
|
|
895
895
|
name: 'user';
|
|
896
896
|
writable: true;
|
|
897
897
|
},
|
|
898
|
+
{
|
|
899
|
+
name: 'refer';
|
|
900
|
+
writable: true;
|
|
901
|
+
},
|
|
898
902
|
{
|
|
899
903
|
name: 'mint';
|
|
900
904
|
writable: true;
|
|
@@ -1116,6 +1120,11 @@ export type PoseidonsProtocol = {
|
|
|
1116
1120
|
code: 6004;
|
|
1117
1121
|
name: 'invalidAmount';
|
|
1118
1122
|
msg: 'Invalid amount';
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
code: 6005;
|
|
1126
|
+
name: 'invalidRefer';
|
|
1127
|
+
msg: 'Invalid refer';
|
|
1119
1128
|
}
|
|
1120
1129
|
];
|
|
1121
1130
|
types: [
|
package/dist/utils/pda.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.getChestPDA = exports.getUserPDA = exports.getPoseidonPDA = exports.getP
|
|
|
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");
|
|
7
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
7
8
|
const getTokenATA = (address, Mint, program = spl_token_1.TOKEN_2022_PROGRAM_ID) => {
|
|
8
9
|
return web3_js_1.PublicKey.findProgramAddressSync([address.toBytes(), program.toBytes(), Mint.toBytes()], new web3_js_1.PublicKey(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID))[0];
|
|
9
10
|
};
|
|
@@ -21,6 +22,6 @@ const getUserPDA = (authority) => {
|
|
|
21
22
|
};
|
|
22
23
|
exports.getUserPDA = getUserPDA;
|
|
23
24
|
const getChestPDA = (id) => {
|
|
24
|
-
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('chest'),
|
|
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];
|
|
25
26
|
};
|
|
26
27
|
exports.getChestPDA = getChestPDA;
|