@triadxyz/poseidons-protocol 0.1.0 → 0.1.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,6 +1,8 @@
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 } from '../types';
4
+ import { PoseidonVault, Poseidon, Chest, User } 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
+ export declare const formatUser: (account: IdlAccounts<PoseidonsProtocol>['user'], address: PublicKey) => User;
8
+ export declare const formatChest: (account: IdlAccounts<PoseidonsProtocol>['chest'], address: PublicKey) => Chest;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatPoseidon = exports.formatPoseidonVault = void 0;
3
+ exports.formatChest = exports.formatUser = exports.formatPoseidon = exports.formatPoseidonVault = void 0;
4
4
  const formatPoseidonVault = (account, address) => {
5
5
  return {
6
6
  address: address.toString(),
@@ -25,3 +25,37 @@ const formatPoseidon = (account, address) => {
25
25
  };
26
26
  };
27
27
  exports.formatPoseidon = formatPoseidon;
28
+ const formatUser = (account, address) => {
29
+ return {
30
+ address: address.toString(),
31
+ authority: account.authority.toString(),
32
+ refer: account.refer.toString(),
33
+ createdAt: account.createdAt.toNumber()
34
+ };
35
+ };
36
+ exports.formatUser = formatUser;
37
+ const formatChest = (account, address) => {
38
+ return {
39
+ address: address.toString(),
40
+ authority: account.authority.toString(),
41
+ id: account.id.toNumber(),
42
+ amount: account.amount.toNumber(),
43
+ coins: account.coins.toNumber(),
44
+ timer: account.timer.toNumber(),
45
+ price: account.price.toNumber(),
46
+ isFinished: account.isFinished,
47
+ lastUser: account.lastUser.toString(),
48
+ grandWinner: {
49
+ authority: account.grandWinner.authority.toString(),
50
+ amount: account.grandWinner.amount.toNumber()
51
+ },
52
+ top10: account.top10.map((top10) => ({
53
+ authority: top10.authority.toString(),
54
+ amount: top10.amount.toNumber()
55
+ })),
56
+ isPaid: account.isPaid,
57
+ createdAt: account.createdAt.toNumber(),
58
+ finishedAt: account.finishedAt.toNumber()
59
+ };
60
+ };
61
+ exports.formatChest = formatChest;
@@ -2,3 +2,5 @@ import { PublicKey } from '@solana/web3.js';
2
2
  export declare const getTokenATA: (address: PublicKey, Mint: PublicKey, program?: PublicKey) => PublicKey;
3
3
  export declare const getPoseidonVaultPDA: () => PublicKey;
4
4
  export declare const getPoseidonPDA: (mint: PublicKey) => PublicKey;
5
+ export declare const getUserPDA: (authority: PublicKey) => PublicKey;
6
+ export declare const getChestPDA: (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.getPoseidonPDA = exports.getPoseidonVaultPDA = exports.getTokenATA = void 0;
3
+ 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");
@@ -16,3 +16,11 @@ const getPoseidonPDA = (mint) => {
16
16
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('poseidon'), mint.toBytes()], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
17
17
  };
18
18
  exports.getPoseidonPDA = getPoseidonPDA;
19
+ const getUserPDA = (authority) => {
20
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('user'), authority.toBytes()], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
21
+ };
22
+ exports.getUserPDA = getUserPDA;
23
+ const getChestPDA = (id) => {
24
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('chest'), Buffer.from(id.toString())], constants_1.POSEIDON_VAULT_PROGRAM_ID)[0];
25
+ };
26
+ exports.getChestPDA = getChestPDA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/poseidons-protocol",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",