@triadxyz/triad-protocol 0.1.3-alpha.3 → 0.1.3-alpha.5

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/stake.d.ts CHANGED
@@ -2,10 +2,30 @@ import { AnchorProvider, Program } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { TriadProtocol } from './types/triad_protocol';
4
4
  import BN from 'bn.js';
5
+ import { RpcOptions } from './types';
5
6
  export default class Stake {
6
7
  program: Program<TriadProtocol>;
7
8
  provider: AnchorProvider;
8
9
  constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
10
+ /**
11
+ * Get all Stake Vaults
12
+ */
13
+ getStakeVaults(): Promise<import("@coral-xyz/anchor").ProgramAccount<{
14
+ bump: number;
15
+ authority: PublicKey;
16
+ initTs: BN;
17
+ endTs: BN;
18
+ amount: BN;
19
+ amountPaid: BN;
20
+ apr: number;
21
+ amountUsers: BN;
22
+ slots: BN;
23
+ isLocked: boolean;
24
+ name: string;
25
+ collection: string;
26
+ usersPaid: PublicKey;
27
+ padding: number[];
28
+ }>[]>;
9
29
  /**
10
30
  * Get all stakes
11
31
  */
@@ -80,6 +100,77 @@ export default class Stake {
80
100
  mint: PublicKey;
81
101
  stakeVault: PublicKey;
82
102
  }>[]>;
103
+ getStakeByWallet(wallet: PublicKey): Promise<import("@coral-xyz/anchor").ProgramAccount<{
104
+ bump: number;
105
+ authority: PublicKey;
106
+ initTs: BN;
107
+ isLocked: boolean;
108
+ withdrawTs: BN;
109
+ name: string;
110
+ collections: (({
111
+ undead?: never;
112
+ alligators?: never;
113
+ pyth?: never;
114
+ } & {
115
+ coleta: Record<string, never>;
116
+ }) | ({
117
+ coleta?: never;
118
+ alligators?: never;
119
+ pyth?: never;
120
+ } & {
121
+ undead: Record<string, never>;
122
+ }) | ({
123
+ coleta?: never;
124
+ undead?: never;
125
+ pyth?: never;
126
+ } & {
127
+ alligators: Record<string, never>;
128
+ }) | ({
129
+ coleta?: never;
130
+ undead?: never;
131
+ alligators?: never;
132
+ } & {
133
+ pyth: Record<string, never>;
134
+ }))[];
135
+ rarity: ({
136
+ uncommon?: never;
137
+ rare?: never;
138
+ epic?: never;
139
+ legendary?: never;
140
+ } & {
141
+ common: Record<string, never>;
142
+ }) | ({
143
+ common?: never;
144
+ rare?: never;
145
+ epic?: never;
146
+ legendary?: never;
147
+ } & {
148
+ uncommon: Record<string, never>;
149
+ }) | ({
150
+ common?: never;
151
+ uncommon?: never;
152
+ epic?: never;
153
+ legendary?: never;
154
+ } & {
155
+ rare: Record<string, never>;
156
+ }) | ({
157
+ common?: never;
158
+ uncommon?: never;
159
+ rare?: never;
160
+ legendary?: never;
161
+ } & {
162
+ epic: Record<string, never>;
163
+ }) | ({
164
+ common?: never;
165
+ uncommon?: never;
166
+ rare?: never;
167
+ epic?: never;
168
+ } & {
169
+ legendary: Record<string, never>;
170
+ });
171
+ mint: PublicKey;
172
+ stakeVault: PublicKey;
173
+ }>[]>;
83
174
  /**
84
175
  * Stake NFT
85
176
  * @param name - NFT name
@@ -110,7 +201,7 @@ export default class Stake {
110
201
  } | {
111
202
  legendary: {};
112
203
  };
113
- }): Promise<string>;
204
+ }, options?: RpcOptions): Promise<string>;
114
205
  /**
115
206
  * Initialize Stake Vault
116
207
  * @param name - The ticker's name
@@ -124,5 +215,5 @@ export default class Stake {
124
215
  amount: BN;
125
216
  slots: BN;
126
217
  collection: string;
127
- }): Promise<string>;
218
+ }, options?: RpcOptions): Promise<string>;
128
219
  }
package/dist/stake.js CHANGED
@@ -9,12 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const web3_js_1 = require("@solana/web3.js");
12
13
  const helpers_1 = require("./utils/helpers");
13
14
  class Stake {
14
15
  constructor(program, provider) {
15
16
  this.provider = provider;
16
17
  this.program = program;
17
18
  }
19
+ /**
20
+ * Get all Stake Vaults
21
+ */
22
+ getStakeVaults() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return this.program.account.stakeVault.all();
25
+ });
26
+ }
18
27
  /**
19
28
  * Get all stakes
20
29
  */
@@ -23,6 +32,12 @@ class Stake {
23
32
  return this.program.account.stake.all();
24
33
  });
25
34
  }
35
+ getStakeByWallet(wallet) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const response = yield this.program.account.stake.all();
38
+ return response.filter((stake) => stake.account.authority.equals(wallet));
39
+ });
40
+ }
26
41
  /**
27
42
  * Stake NFT
28
43
  * @param name - NFT name
@@ -32,9 +47,9 @@ class Stake {
32
47
  * @param rarity - NFT rarity
33
48
  *
34
49
  */
35
- stake({ name, wallet, mint, collections, rarity }) {
50
+ stake({ name, wallet, mint, collections, rarity }, options) {
36
51
  return __awaiter(this, void 0, void 0, function* () {
37
- const stakeVaultName = 'Rev 1';
52
+ const stakeVaultName = 'Triad Share 1';
38
53
  const FromAta = (0, helpers_1.getATASync)(wallet, mint);
39
54
  const StakeVault = (0, helpers_1.getStakeVaultAddressSync)(this.program.programId, stakeVaultName);
40
55
  const ToAta = (0, helpers_1.getATASync)(StakeVault, mint);
@@ -44,7 +59,7 @@ class Stake {
44
59
  items.push({ [key]: {} });
45
60
  }
46
61
  });
47
- return this.program.methods
62
+ const method = this.program.methods
48
63
  .stake({
49
64
  name,
50
65
  collections: items,
@@ -56,10 +71,15 @@ class Stake {
56
71
  fromAta: FromAta,
57
72
  toAta: ToAta,
58
73
  mint: mint
59
- })
60
- .rpc({
61
- skipPreflight: true
62
74
  });
75
+ if (options === null || options === void 0 ? void 0 : options.microLamports) {
76
+ method.postInstructions([
77
+ web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
78
+ microLamports: options.microLamports
79
+ })
80
+ ]);
81
+ }
82
+ return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
63
83
  });
64
84
  }
65
85
  /**
@@ -70,9 +90,9 @@ class Stake {
70
90
  * @param collection - The Collection name
71
91
  *
72
92
  */
73
- initializeStakeVault({ name, amount, slots, collection }) {
93
+ initializeStakeVault({ name, amount, slots, collection }, options) {
74
94
  return __awaiter(this, void 0, void 0, function* () {
75
- return this.program.methods
95
+ const method = this.program.methods
76
96
  .initializeStakeVault({
77
97
  name,
78
98
  amount,
@@ -81,8 +101,15 @@ class Stake {
81
101
  })
82
102
  .accounts({
83
103
  signer: this.provider.wallet.publicKey
84
- })
85
- .rpc();
104
+ });
105
+ if (options === null || options === void 0 ? void 0 : options.microLamports) {
106
+ method.postInstructions([
107
+ web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
108
+ microLamports: options.microLamports
109
+ })
110
+ ]);
111
+ }
112
+ return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
86
113
  });
87
114
  }
88
115
  }
package/dist/test.js CHANGED
@@ -20,7 +20,7 @@ class Test {
20
20
  constructor() {
21
21
  this.file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
22
22
  this.Keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(this.file.toString())));
23
- this.connection = new web3_js_1.Connection('http://127.0.0.1:8899');
23
+ this.connection = new web3_js_1.Connection('https://mainnet.helius-rpc.com/?api-key=3fb2333b-4396-4db0-94c5-663cca63697e');
24
24
  this.wallet = new anchor_1.Wallet(this.Keypair);
25
25
  this.triadProtocol = new index_1.default(this.connection, this.wallet);
26
26
  this.init = () => __awaiter(this, void 0, void 0, function* () { });
@@ -28,8 +28,8 @@ class Test {
28
28
  const reponse = yield this.triadProtocol.stake.initializeStakeVault({
29
29
  name: 'Rev 1',
30
30
  collection: 'Triad',
31
- slots: new anchor_1.BN(1939),
32
- amount: new anchor_1.BN(1000000000)
31
+ slots: new anchor_1.BN(1839),
32
+ amount: new anchor_1.BN(50000000000)
33
33
  });
34
34
  console.log('Initialize Stake Vault:', reponse);
35
35
  });
@@ -47,4 +47,4 @@ class Test {
47
47
  }
48
48
  exports.default = Test;
49
49
  const test = new Test();
50
- test.stakeNFT();
50
+ test.initializeStakeVault();
@@ -705,6 +705,11 @@
705
705
  "code": 6018,
706
706
  "name": "StakeLocked",
707
707
  "msg": "Stake is locked"
708
+ },
709
+ {
710
+ "code": 6019,
711
+ "name": "StakeVaultFull",
712
+ "msg": "Stake Vault Full"
708
713
  }
709
714
  ],
710
715
  "types": [
@@ -0,0 +1,4 @@
1
+ export type RpcOptions = {
2
+ skipPreflight?: boolean;
3
+ microLamports?: number;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -757,6 +757,11 @@ export type TriadProtocol = {
757
757
  code: 6018;
758
758
  name: 'stakeLocked';
759
759
  msg: 'Stake is locked';
760
+ },
761
+ {
762
+ code: 6019;
763
+ name: 'stakeVaultFull';
764
+ msg: 'Stake Vault Full';
760
765
  }
761
766
  ];
762
767
  types: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.1.3-alpha.3",
3
+ "version": "0.1.3-alpha.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",