@triadxyz/triad-protocol 0.2.6-beta → 0.2.8-beta

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/index.js CHANGED
@@ -36,7 +36,8 @@ class TriadProtocolClient {
36
36
  */
37
37
  this.getUsers = () => __awaiter(this, void 0, void 0, function* () {
38
38
  const response = yield this.program.account.user.all();
39
- return response.map((item) => (0, helpers_1.formatUser)(item));
39
+ console.log(response);
40
+ return response.map((item) => (0, helpers_1.formatUser)(item.account));
40
41
  });
41
42
  /**
42
43
  * Check if user exists
package/dist/stake.js CHANGED
@@ -119,9 +119,11 @@ class Stake {
119
119
  stakeNft({ wallet, stakeVault, items }, options) {
120
120
  return __awaiter(this, void 0, void 0, function* () {
121
121
  let ixs = [];
122
+ const stakeVaultPDA = (0, helpers_1.getStakeVaultAddressSync)(this.program.programId, stakeVault);
122
123
  for (let i = 0; i < items.length; i++) {
123
124
  let item = items[i];
124
125
  const FromAta = (0, helpers_1.getATASync)(wallet, item.mint);
126
+ const toAta = (0, helpers_1.getATASync)(stakeVaultPDA, item.mint);
125
127
  ixs.push(yield this.program.methods
126
128
  .stakeNft({
127
129
  name: item.name,
@@ -130,7 +132,8 @@ class Stake {
130
132
  .accounts({
131
133
  signer: wallet,
132
134
  fromAta: FromAta,
133
- mint: item.mint
135
+ mint: item.mint,
136
+ toAta: toAta
134
137
  })
135
138
  .instruction());
136
139
  }
@@ -162,9 +165,11 @@ class Stake {
162
165
  */
163
166
  stakeToken({ name, wallet, stakeVault, amount }, options) {
164
167
  return __awaiter(this, void 0, void 0, function* () {
168
+ const stakeVaultPDA = (0, helpers_1.getStakeVaultAddressSync)(this.program.programId, stakeVault);
165
169
  const ttriad = new web3_js_1.PublicKey(constants_1.TTRIAD_MINT);
166
170
  const FromAta = (0, helpers_1.getATASync)(wallet, ttriad);
167
171
  const userPDA = (0, helpers_1.getUserAddressSync)(this.program.programId, wallet);
172
+ const toAta = (0, helpers_1.getATASync)(stakeVaultPDA, ttriad);
168
173
  const method = this.program.methods
169
174
  .stakeToken({
170
175
  name,
@@ -175,7 +180,8 @@ class Stake {
175
180
  signer: wallet,
176
181
  fromAta: FromAta,
177
182
  mint: ttriad,
178
- user: userPDA
183
+ user: userPDA,
184
+ toAta: toAta
179
185
  });
180
186
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
181
187
  method.postInstructions([
package/dist/test.js CHANGED
@@ -36,17 +36,40 @@ const updateStakeVaultStatus = () => __awaiter(void 0, void 0, void 0, function*
36
36
  console.log(response);
37
37
  });
38
38
  const getStake = () => __awaiter(void 0, void 0, void 0, function* () {
39
- const response = yield triadProtocol.stake.getStakeByWallet(new web3_js_1.PublicKey('BCTdjdcjMiECGFbF5Ps15yjLRPzy5YZGJNa4VdGRbhjB'), constants_1.STAKE_SEASON);
39
+ // const response = await triadProtocol.stake.getStakeByWallet(
40
+ // new PublicKey('BCTdjdcjMiECGFbF5Ps15yjLRPzy5YZGJNa4VdGRbhjB'),
41
+ // STAKE_SEASON
42
+ // )
40
43
  const stakeVaults = yield triadProtocol.stake.getStakeVaults();
41
- console.log(response);
44
+ // console.log(response)
42
45
  console.log(stakeVaults);
43
46
  });
44
47
  const getUsers = () => __awaiter(void 0, void 0, void 0, function* () {
45
48
  const response = yield triadProtocol.getUsers();
46
49
  console.log(response);
47
50
  });
48
- getUsers();
49
51
  const getReferral = () => __awaiter(void 0, void 0, void 0, function* () {
50
- const response = yield triadProtocol.hasUser(new web3_js_1.PublicKey(''));
52
+ const response = yield triadProtocol.hasUser(new web3_js_1.PublicKey('6MuTdUhc4LDHDW3fiTemyns4NgR99oAWvHM2SwCSTcau'));
53
+ console.log(response);
54
+ });
55
+ const createUser = () => __awaiter(void 0, void 0, void 0, function* () {
56
+ const response = yield triadProtocol.createUser({
57
+ wallet: wallet.publicKey,
58
+ referral: new web3_js_1.PublicKey('5vPF9vByRCUB2pr1oGmJsRPm9WDrH9a2v6iF4pbMiobK'),
59
+ name: 'Builder'
60
+ }, {
61
+ microLamports: 10000
62
+ });
63
+ });
64
+ const stakeToken = () => __awaiter(void 0, void 0, void 0, function* () {
65
+ const response = yield triadProtocol.stake.stakeToken({
66
+ wallet: wallet.publicKey,
67
+ amount: 100,
68
+ name: 'stake-1',
69
+ stakeVault: constants_1.STAKE_SEASON
70
+ }, {
71
+ microLamports: 10000
72
+ });
51
73
  console.log(response);
52
74
  });
75
+ stakeToken();
@@ -21,7 +21,6 @@ export type StakeTokenArgs = {
21
21
  name: string;
22
22
  wallet: PublicKey;
23
23
  stakeVault: string;
24
- mint: PublicKey;
25
24
  amount: number;
26
25
  };
27
26
  export type InitializeStakeArgs = {
@@ -751,92 +751,6 @@ export type TriadProtocol = {
751
751
  {
752
752
  name: 'toAta';
753
753
  writable: true;
754
- pda: {
755
- seeds: [
756
- {
757
- kind: 'account';
758
- path: 'stakeVault';
759
- },
760
- {
761
- kind: 'const';
762
- value: [
763
- 6,
764
- 221,
765
- 246,
766
- 225,
767
- 215,
768
- 101,
769
- 161,
770
- 147,
771
- 217,
772
- 203,
773
- 225,
774
- 70,
775
- 206,
776
- 235,
777
- 121,
778
- 172,
779
- 28,
780
- 180,
781
- 133,
782
- 237,
783
- 95,
784
- 91,
785
- 55,
786
- 145,
787
- 58,
788
- 140,
789
- 245,
790
- 133,
791
- 126,
792
- 255,
793
- 0,
794
- 169
795
- ];
796
- },
797
- {
798
- kind: 'account';
799
- path: 'mint';
800
- }
801
- ];
802
- program: {
803
- kind: 'const';
804
- value: [
805
- 140,
806
- 151,
807
- 37,
808
- 143,
809
- 78,
810
- 36,
811
- 137,
812
- 241,
813
- 187,
814
- 61,
815
- 16,
816
- 41,
817
- 20,
818
- 142,
819
- 13,
820
- 131,
821
- 11,
822
- 90,
823
- 19,
824
- 153,
825
- 218,
826
- 255,
827
- 16,
828
- 132,
829
- 4,
830
- 142,
831
- 123,
832
- 216,
833
- 219,
834
- 233,
835
- 248,
836
- 89
837
- ];
838
- };
839
- };
840
754
  },
841
755
  {
842
756
  name: 'tokenProgram';
@@ -922,92 +836,6 @@ export type TriadProtocol = {
922
836
  {
923
837
  name: 'toAta';
924
838
  writable: true;
925
- pda: {
926
- seeds: [
927
- {
928
- kind: 'account';
929
- path: 'stakeVault';
930
- },
931
- {
932
- kind: 'const';
933
- value: [
934
- 6,
935
- 221,
936
- 246,
937
- 225,
938
- 215,
939
- 101,
940
- 161,
941
- 147,
942
- 217,
943
- 203,
944
- 225,
945
- 70,
946
- 206,
947
- 235,
948
- 121,
949
- 172,
950
- 28,
951
- 180,
952
- 133,
953
- 237,
954
- 95,
955
- 91,
956
- 55,
957
- 145,
958
- 58,
959
- 140,
960
- 245,
961
- 133,
962
- 126,
963
- 255,
964
- 0,
965
- 169
966
- ];
967
- },
968
- {
969
- kind: 'account';
970
- path: 'mint';
971
- }
972
- ];
973
- program: {
974
- kind: 'const';
975
- value: [
976
- 140,
977
- 151,
978
- 37,
979
- 143,
980
- 78,
981
- 36,
982
- 137,
983
- 241,
984
- 187,
985
- 61,
986
- 16,
987
- 41,
988
- 20,
989
- 142,
990
- 13,
991
- 131,
992
- 11,
993
- 90,
994
- 19,
995
- 153,
996
- 218,
997
- 255,
998
- 16,
999
- 132,
1000
- 4,
1001
- 142,
1002
- 123,
1003
- 216,
1004
- 219,
1005
- 233,
1006
- 248,
1007
- 89
1008
- ];
1009
- };
1010
- };
1011
839
  },
1012
840
  {
1013
841
  name: 'tokenProgram';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.2.6-beta",
3
+ "version": "0.2.8-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",