@zebec-network/zebec-vault-sdk 5.2.0-dev.1 → 5.2.0

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/providers.js CHANGED
@@ -9,7 +9,9 @@ class ReadonlyProvider {
9
9
  walletAddress;
10
10
  constructor(connection, walletAddress) {
11
11
  this.connection = connection;
12
- this.walletAddress = walletAddress ? (0, anchor_1.translateAddress)(walletAddress) : undefined;
12
+ this.walletAddress = walletAddress
13
+ ? (0, anchor_1.translateAddress)(walletAddress)
14
+ : undefined;
13
15
  }
14
16
  }
15
17
  exports.ReadonlyProvider = ReadonlyProvider;
package/dist/service.js CHANGED
@@ -151,7 +151,9 @@ class ZebecVaultService {
151
151
  .instruction();
152
152
  }
153
153
  async createVault(params) {
154
- const payer = params.payer ? (0, anchor_1.translateAddress)(params.payer) : this.provider.publicKey;
154
+ const payer = params.payer
155
+ ? (0, anchor_1.translateAddress)(params.payer)
156
+ : this.provider.publicKey;
155
157
  if (!payer) {
156
158
  throw new Error("Either provide a payer or use AnchorProvider for provider in the service");
157
159
  }
@@ -161,7 +163,9 @@ class ZebecVaultService {
161
163
  return this._createTransactionPayload(payer, [ix]);
162
164
  }
163
165
  async depositSol(params) {
164
- const depositor = params.depositor ? (0, anchor_1.translateAddress)(params.depositor) : this.provider.publicKey;
166
+ const depositor = params.depositor
167
+ ? (0, anchor_1.translateAddress)(params.depositor)
168
+ : this.provider.publicKey;
165
169
  if (!depositor) {
166
170
  throw new Error("Either provide a depositor or use AnchorProvider for provider in the service");
167
171
  }
@@ -170,7 +174,9 @@ class ZebecVaultService {
170
174
  return this._createTransactionPayload(depositor, [ix]);
171
175
  }
172
176
  async withdrawSol(params) {
173
- const withdrawer = params.withdrawer ? (0, anchor_1.translateAddress)(params.withdrawer) : this.provider.publicKey;
177
+ const withdrawer = params.withdrawer
178
+ ? (0, anchor_1.translateAddress)(params.withdrawer)
179
+ : this.provider.publicKey;
174
180
  if (!withdrawer) {
175
181
  throw new Error("Either provide a withdrawer or use AnchorProvider for provider in the service");
176
182
  }
@@ -179,7 +185,9 @@ class ZebecVaultService {
179
185
  return this._createTransactionPayload(withdrawer, [ix]);
180
186
  }
181
187
  async deposit(params) {
182
- const depositor = params.depositor ? (0, anchor_1.translateAddress)(params.depositor) : this.provider.publicKey;
188
+ const depositor = params.depositor
189
+ ? (0, anchor_1.translateAddress)(params.depositor)
190
+ : this.provider.publicKey;
183
191
  if (!depositor) {
184
192
  throw new Error("Either provide a depositor or use AnchorProvider for provider in the service");
185
193
  }
@@ -238,7 +246,9 @@ class ZebecVaultService {
238
246
  return closeWsolAccountIx;
239
247
  }
240
248
  async withdraw(params) {
241
- const withdrawer = params.withdrawer ? (0, anchor_1.translateAddress)(params.withdrawer) : this.provider.publicKey;
249
+ const withdrawer = params.withdrawer
250
+ ? (0, anchor_1.translateAddress)(params.withdrawer)
251
+ : this.provider.publicKey;
242
252
  if (!withdrawer) {
243
253
  throw new Error("Either provide a withdrawer or use AnchorProvider for provider in the service");
244
254
  }
@@ -264,7 +274,9 @@ class ZebecVaultService {
264
274
  return this._createTransactionPayload(withdrawer, instructions);
265
275
  }
266
276
  async createProposal(params) {
267
- const proposer = params.proposer ? (0, anchor_1.translateAddress)(params.proposer) : this.provider.publicKey;
277
+ const proposer = params.proposer
278
+ ? (0, anchor_1.translateAddress)(params.proposer)
279
+ : this.provider.publicKey;
268
280
  if (!proposer) {
269
281
  throw new Error("Either provide a proposer or use AnchorProvider for provider in the service");
270
282
  }
@@ -278,7 +290,9 @@ class ZebecVaultService {
278
290
  return this._createTransactionPayload(proposer, [ix], [proposalKeypair]);
279
291
  }
280
292
  async appendActions(params) {
281
- const proposer = params.proposer ? (0, anchor_1.translateAddress)(params.proposer) : this.provider.publicKey;
293
+ const proposer = params.proposer
294
+ ? (0, anchor_1.translateAddress)(params.proposer)
295
+ : this.provider.publicKey;
282
296
  if (!proposer) {
283
297
  throw new Error("Either provide a proposer or use AnchorProvider for provider in the service");
284
298
  }
@@ -298,7 +312,9 @@ class ZebecVaultService {
298
312
  return this._createTransactionPayload(proposer, [ix]);
299
313
  }
300
314
  async deleteProposal(params) {
301
- const caller = params.caller ? (0, anchor_1.translateAddress)(params.caller) : this.provider.publicKey;
315
+ const caller = params.caller
316
+ ? (0, anchor_1.translateAddress)(params.caller)
317
+ : this.provider.publicKey;
302
318
  if (!caller) {
303
319
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
304
320
  }
@@ -307,7 +323,9 @@ class ZebecVaultService {
307
323
  return this._createTransactionPayload(caller, [ix]);
308
324
  }
309
325
  async executeProposal(params) {
310
- const caller = params.caller ? (0, anchor_1.translateAddress)(params.caller) : this.provider.publicKey;
326
+ const caller = params.caller
327
+ ? (0, anchor_1.translateAddress)(params.caller)
328
+ : this.provider.publicKey;
311
329
  if (!caller) {
312
330
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
313
331
  }
@@ -347,7 +365,9 @@ class ZebecVaultService {
347
365
  return this._createTransactionPayload(caller, [ix], params.partialSigners, addressLookupTableAccounts);
348
366
  }
349
367
  async executeProposalDirect(params) {
350
- const proposer = params.proposer ? (0, anchor_1.translateAddress)(params.proposer) : this.provider.publicKey;
368
+ const proposer = params.proposer
369
+ ? (0, anchor_1.translateAddress)(params.proposer)
370
+ : this.provider.publicKey;
351
371
  if (!proposer) {
352
372
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
353
373
  }
@@ -586,7 +606,9 @@ class ZebecVaultService {
586
606
  return BigInt(decoded.index.addn(1).toString());
587
607
  }
588
608
  async createSilverCard(params) {
589
- const vaultOwner = params.vaultOwnerAddress ? (0, anchor_1.translateAddress)(params.vaultOwnerAddress) : this.provider.publicKey;
609
+ const vaultOwner = params.vaultOwnerAddress
610
+ ? (0, anchor_1.translateAddress)(params.vaultOwnerAddress)
611
+ : this.provider.publicKey;
590
612
  if (!vaultOwner) {
591
613
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
592
614
  }
@@ -602,7 +624,9 @@ class ZebecVaultService {
602
624
  const revenueVault = cardConfigInfo.revenueVault;
603
625
  const cardVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(usdcMint, cardVault, true);
604
626
  const revenueVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(usdcMint, revenueVault, true);
605
- const parsedAmount = amount.times(solana_common_1.UNITS_PER_USDC).decimalPlaces(0, bignumber_js_1.BigNumber.ROUND_DOWN);
627
+ const parsedAmount = amount
628
+ .times(solana_common_1.UNITS_PER_USDC)
629
+ .decimalPlaces(0, bignumber_js_1.BigNumber.ROUND_DOWN);
606
630
  await this._checkAmountIsWithinProviderRange(cardConfigInfo, parsedAmount);
607
631
  await this._checkAmountIsWithinDailyCardLimit(cardConfigInfo, userPurchaseRecord, parsedAmount);
608
632
  const index = new anchor_1.BN(params.nextCardIndex.toString());
@@ -612,7 +636,9 @@ class ZebecVaultService {
612
636
  currency: params.currency,
613
637
  emailHash: Array.from(params.emailHash),
614
638
  });
615
- const actions = [(0, utils_1.transactionInstructionToPropoalAction)(ix)];
639
+ const actions = [
640
+ (0, utils_1.transactionInstructionToPropoalAction)(ix),
641
+ ];
616
642
  const remainingAccounts = actions.reduce((acc, current) => {
617
643
  const accounts = current.accountSpecs.map((spec) => ({
618
644
  pubkey: spec.pubkey,
@@ -633,7 +659,9 @@ class ZebecVaultService {
633
659
  return this._createTransactionPayload(vaultOwner, [executeProposalDirectIx], [], [lookupTableAccount]);
634
660
  }
635
661
  async loadCarbonCard(params) {
636
- const vaultOwner = params.vaultOwnerAddress ? (0, anchor_1.translateAddress)(params.vaultOwnerAddress) : this.provider.publicKey;
662
+ const vaultOwner = params.vaultOwnerAddress
663
+ ? (0, anchor_1.translateAddress)(params.vaultOwnerAddress)
664
+ : this.provider.publicKey;
637
665
  if (!vaultOwner) {
638
666
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
639
667
  }
@@ -649,7 +677,9 @@ class ZebecVaultService {
649
677
  const revenueVault = cardConfigInfo.revenueVault;
650
678
  const cardVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(usdcMint, cardVault, true);
651
679
  const revenueVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(usdcMint, revenueVault, true);
652
- const parsedAmount = amount.times(solana_common_1.UNITS_PER_USDC).decimalPlaces(0, bignumber_js_1.BigNumber.ROUND_DOWN);
680
+ const parsedAmount = amount
681
+ .times(solana_common_1.UNITS_PER_USDC)
682
+ .decimalPlaces(0, bignumber_js_1.BigNumber.ROUND_DOWN);
653
683
  await this._checkAmountIsWithinProviderRange(cardConfigInfo, parsedAmount);
654
684
  await this._checkAmountIsWithinDailyCardLimit(cardConfigInfo, userPurchaseRecord, parsedAmount);
655
685
  const index = new anchor_1.BN(params.nextCardIndex.toString());
@@ -660,7 +690,9 @@ class ZebecVaultService {
660
690
  emailHash: Array.from(params.emailHash),
661
691
  reloadCardId: params.reloadCardId,
662
692
  });
663
- const actions = [(0, utils_1.transactionInstructionToPropoalAction)(ix)];
693
+ const actions = [
694
+ (0, utils_1.transactionInstructionToPropoalAction)(ix),
695
+ ];
664
696
  const remainingAccounts = actions.reduce((acc, current) => {
665
697
  const accounts = current.accountSpecs.map((spec) => ({
666
698
  pubkey: spec.pubkey,
@@ -727,7 +759,9 @@ class ZebecVaultService {
727
759
  const customTokenFees = await this.getCardCustomTokenFees();
728
760
  const customTokenFee = customTokenFees.find((tf) => tf.tokenAddress === quoteInfo.inputMint);
729
761
  const DEFAULT_SWAP_FEE = 5;
730
- const swapFee = customTokenFee ? (0, bignumber_js_1.BigNumber)(customTokenFee.fee) : (0, bignumber_js_1.BigNumber)(DEFAULT_SWAP_FEE);
762
+ const swapFee = customTokenFee
763
+ ? (0, bignumber_js_1.BigNumber)(customTokenFee.fee)
764
+ : (0, bignumber_js_1.BigNumber)(DEFAULT_SWAP_FEE);
731
765
  const amountAfterFeeDeduction = amount.minus(amount.times(swapFee.div(100)));
732
766
  await this._checkAmountIsWithinProviderRange(cardConfigInfo, amountAfterFeeDeduction);
733
767
  await this._checkAmountIsWithinDailyCardLimit(cardConfigInfo, userPurchaseRecord, amountAfterFeeDeduction);
@@ -752,7 +786,9 @@ class ZebecVaultService {
752
786
  const transaction = web3_js_1.VersionedTransaction.deserialize(swapTransactionBuf);
753
787
  // get address lookup table accounts
754
788
  const addressLookupTableAccounts = await Promise.all(transaction.message.addressTableLookups.map(async (lookup) => {
755
- const data = await this.connection.getAccountInfo(lookup.accountKey).then((res) => {
789
+ const data = await this.connection
790
+ .getAccountInfo(lookup.accountKey)
791
+ .then((res) => {
756
792
  if (!res) {
757
793
  throw new Error(`Lookup table account not found for key: ${(0, anchor_1.translateAddress)(constants_1.CARD_LOOKUP_TABLE_ADDRESS[this.network]).toString()}`);
758
794
  }
@@ -795,7 +831,7 @@ class ZebecVaultService {
795
831
  return this._createTransactionPayload(vaultOwner, otherIxs, [], addressLookupTableAccounts);
796
832
  }
797
833
  async swapAndLoadCarbonCard(params) {
798
- const { vaultOwnerAddress, quoteInfo, emailHash, reloadCardId, wrapAndUnwrapSol } = params;
834
+ const { vaultOwnerAddress, quoteInfo, emailHash, reloadCardId, wrapAndUnwrapSol, } = params;
799
835
  if ("error" in quoteInfo) {
800
836
  throw new Error(quoteInfo.error);
801
837
  }
@@ -824,7 +860,8 @@ class ZebecVaultService {
824
860
  if (!inputMint.equals(solana_common_1.WSOL) || !isSolWrapUnwrapNeeded) {
825
861
  const userInputMintAtaInfo = await this.connection.getAccountInfo(userInputMintAta, this.connection.commitment);
826
862
  if (!userInputMintAtaInfo) {
827
- throw new errors_1.AssociatedTokenAccountDoesNotExistsError("User doesn't have associated token account of input mint: " + inputMint.toString());
863
+ throw new errors_1.AssociatedTokenAccountDoesNotExistsError("User doesn't have associated token account of input mint: " +
864
+ inputMint.toString());
828
865
  }
829
866
  const resAndCtx = await this.connection.getTokenAccountBalance(userInputMintAta, this.connection.commitment);
830
867
  const balance = resAndCtx.value.amount;
@@ -841,7 +878,9 @@ class ZebecVaultService {
841
878
  const customTokenFees = await this.getCardCustomTokenFees();
842
879
  const customTokenFee = customTokenFees.find((tf) => tf.tokenAddress === quoteInfo.inputMint);
843
880
  const DEFAULT_SWAP_FEE = 5;
844
- const swapFee = customTokenFee ? (0, bignumber_js_1.BigNumber)(customTokenFee.fee) : (0, bignumber_js_1.BigNumber)(DEFAULT_SWAP_FEE);
881
+ const swapFee = customTokenFee
882
+ ? (0, bignumber_js_1.BigNumber)(customTokenFee.fee)
883
+ : (0, bignumber_js_1.BigNumber)(DEFAULT_SWAP_FEE);
845
884
  const amountAfterFeeDeduction = amount.minus(amount.times(swapFee.div(100)));
846
885
  await this._checkAmountIsWithinProviderRange(cardConfigInfo, amountAfterFeeDeduction);
847
886
  await this._checkAmountIsWithinDailyCardLimit(cardConfigInfo, userPurchaseRecord, amountAfterFeeDeduction);
@@ -866,7 +905,9 @@ class ZebecVaultService {
866
905
  const transaction = web3_js_1.VersionedTransaction.deserialize(swapTransactionBuf);
867
906
  // get address lookup table accounts
868
907
  const addressLookupTableAccounts = await Promise.all(transaction.message.addressTableLookups.map(async (lookup) => {
869
- const data = await this.connection.getAccountInfo(lookup.accountKey).then((res) => {
908
+ const data = await this.connection
909
+ .getAccountInfo(lookup.accountKey)
910
+ .then((res) => {
870
911
  if (!res) {
871
912
  throw new Error(`Lookup table account not found for key: ${lookup.accountKey.toString()}`);
872
913
  }
@@ -1050,7 +1091,9 @@ class ZebecVaultService {
1050
1091
  const [streamVault] = (0, zebec_stream_sdk_1.deriveStreamVaultPda)(streamMetadata, this.streamProgramId);
1051
1092
  const streamVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, streamVault, true);
1052
1093
  const streamTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, streamToken);
1053
- const amount = (0, bignumber_js_1.BigNumber)(params.amount).times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals)).toFixed(0);
1094
+ const amount = (0, bignumber_js_1.BigNumber)(params.amount)
1095
+ .times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals))
1096
+ .toFixed(0);
1054
1097
  const feeInfo = await (0, zebec_stream_sdk_1.getFeeInfoForStream)(streamToken, amount, streamTokenDecimals, this.network);
1055
1098
  const feeToken = (0, anchor_1.translateAddress)(feeInfo.feeToken.mintAddress);
1056
1099
  const feeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, feeToken);
@@ -1082,7 +1125,9 @@ class ZebecVaultService {
1082
1125
  cliffPercentage,
1083
1126
  duration: new anchor_1.BN(params.duration),
1084
1127
  isPausable: params.isPausable,
1085
- numberOfWithdrawls: autoWithdrawFrequency > 0 ? new anchor_1.BN(Math.floor(params.duration / autoWithdrawFrequency)) : new anchor_1.BN(0),
1128
+ numberOfWithdrawls: autoWithdrawFrequency > 0
1129
+ ? new anchor_1.BN(Math.floor(params.duration / autoWithdrawFrequency))
1130
+ : new anchor_1.BN(0),
1086
1131
  rateUpdatable: params.rateUpdatable,
1087
1132
  startNow: params.startNow,
1088
1133
  startTime: new anchor_1.BN(params.startTime),
@@ -1091,7 +1136,9 @@ class ZebecVaultService {
1091
1136
  transferableBySender: params.transferableBySender,
1092
1137
  });
1093
1138
  const lookupTable = zebec_stream_sdk_1.STREAM_PROGRAM_LOOKUP_TABLE_ADDRESS[this.network];
1094
- const lookupTableData = await this.connection.getAccountInfo((0, anchor_1.translateAddress)(lookupTable)).then((res) => {
1139
+ const lookupTableData = await this.connection
1140
+ .getAccountInfo((0, anchor_1.translateAddress)(lookupTable))
1141
+ .then((res) => {
1095
1142
  if (!res) {
1096
1143
  throw new Error(`Lookup table account not found for key: ${(0, anchor_1.translateAddress)(constants_1.CARD_LOOKUP_TABLE_ADDRESS[this.network]).toString()}`);
1097
1144
  }
@@ -1109,7 +1156,9 @@ class ZebecVaultService {
1109
1156
  const [vault] = (0, pda_1.deriveUserVault)(vaultOwner, this.vaultV1ProgramId);
1110
1157
  const [vaultSigner] = (0, pda_1.deriveVaultSigner)(vault, this.vaultV1ProgramId);
1111
1158
  const lookupTable = zebec_stream_sdk_1.STREAM_PROGRAM_LOOKUP_TABLE_ADDRESS[this.network];
1112
- const lookupTableData = await this.connection.getAccountInfo((0, anchor_1.translateAddress)(lookupTable)).then((res) => {
1159
+ const lookupTableData = await this.connection
1160
+ .getAccountInfo((0, anchor_1.translateAddress)(lookupTable))
1161
+ .then((res) => {
1113
1162
  if (!res) {
1114
1163
  throw new Error(`Lookup table account not found for key: ${(0, anchor_1.translateAddress)(constants_1.CARD_LOOKUP_TABLE_ADDRESS[this.network]).toString()}`);
1115
1164
  }
@@ -1134,7 +1183,9 @@ class ZebecVaultService {
1134
1183
  const [streamVault] = (0, zebec_stream_sdk_1.deriveStreamVaultPda)(streamMetadata, this.streamProgramId);
1135
1184
  const streamVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, streamVault, true);
1136
1185
  const streamTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, streamToken);
1137
- const amount = (0, bignumber_js_1.BigNumber)(info.amount).times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals)).toFixed(0);
1186
+ const amount = (0, bignumber_js_1.BigNumber)(info.amount)
1187
+ .times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals))
1188
+ .toFixed(0);
1138
1189
  const feeInfo = await (0, zebec_stream_sdk_1.getFeeInfoForStream)(streamToken, amount, streamTokenDecimals, this.network);
1139
1190
  const feeToken = (0, anchor_1.translateAddress)(feeInfo.feeToken.mintAddress);
1140
1191
  const feeTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, feeToken);
@@ -1166,7 +1217,9 @@ class ZebecVaultService {
1166
1217
  cliffPercentage,
1167
1218
  duration: new anchor_1.BN(info.duration),
1168
1219
  isPausable: info.isPausable,
1169
- numberOfWithdrawls: autoWithdrawFrequency > 0 ? new anchor_1.BN(Math.floor(info.duration / autoWithdrawFrequency)) : new anchor_1.BN(0),
1220
+ numberOfWithdrawls: autoWithdrawFrequency > 0
1221
+ ? new anchor_1.BN(Math.floor(info.duration / autoWithdrawFrequency))
1222
+ : new anchor_1.BN(0),
1170
1223
  rateUpdatable: info.rateUpdatable,
1171
1224
  startNow: info.startNow,
1172
1225
  startTime: new anchor_1.BN(info.startTime),
@@ -1184,7 +1237,9 @@ class ZebecVaultService {
1184
1237
  return this._createMultiTransactionPayload(vaultOwner, transactionArtifacts);
1185
1238
  }
1186
1239
  async cancelStream(params) {
1187
- const vaultOwner = params.vaultOwner ? (0, anchor_1.translateAddress)(params.vaultOwner) : this.provider.publicKey;
1240
+ const vaultOwner = params.vaultOwner
1241
+ ? (0, anchor_1.translateAddress)(params.vaultOwner)
1242
+ : this.provider.publicKey;
1188
1243
  if (!vaultOwner) {
1189
1244
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
1190
1245
  }
@@ -1211,7 +1266,9 @@ class ZebecVaultService {
1211
1266
  const [streamVault] = (0, zebec_stream_sdk_1.deriveStreamVaultPda)(streamMetadata, this.streamProgramId);
1212
1267
  const streamVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, streamVault, true);
1213
1268
  const ix = await this.getCancelStreamInstruction(feePayer, otherParty, otherPartyAta, vaultSigner, userAta, streamMetadata, streamToken, streamVault, streamVaultAta);
1214
- const actions = [(0, utils_1.transactionInstructionToPropoalAction)(ix)];
1269
+ const actions = [
1270
+ (0, utils_1.transactionInstructionToPropoalAction)(ix),
1271
+ ];
1215
1272
  const remainingAccounts = actions.reduce((acc, current) => {
1216
1273
  const accounts = current.accountSpecs.map((spec) => ({
1217
1274
  pubkey: spec.pubkey,
@@ -1229,7 +1286,9 @@ class ZebecVaultService {
1229
1286
  return this._createTransactionPayload(feePayer, [ixFinal]);
1230
1287
  }
1231
1288
  async pauseResumeStream(params) {
1232
- const vaultOwner = params.vaultOwner ? (0, anchor_1.translateAddress)(params.vaultOwner) : this.provider.publicKey;
1289
+ const vaultOwner = params.vaultOwner
1290
+ ? (0, anchor_1.translateAddress)(params.vaultOwner)
1291
+ : this.provider.publicKey;
1233
1292
  if (!vaultOwner) {
1234
1293
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
1235
1294
  }
@@ -1266,7 +1325,9 @@ class ZebecVaultService {
1266
1325
  return this._createTransactionPayload(vaultOwner, [ixFinal]);
1267
1326
  }
1268
1327
  async changeStreamReceiver(params) {
1269
- const vaultOwner = params.vaultOwner ? (0, anchor_1.translateAddress)(params.vaultOwner) : this.provider.publicKey;
1328
+ const vaultOwner = params.vaultOwner
1329
+ ? (0, anchor_1.translateAddress)(params.vaultOwner)
1330
+ : this.provider.publicKey;
1270
1331
  if (!vaultOwner) {
1271
1332
  throw new Error("Either provide a vaultOwner or use AnchorProvider for provider in the service");
1272
1333
  }
@@ -1275,7 +1336,9 @@ class ZebecVaultService {
1275
1336
  const streamMetadata = (0, anchor_1.translateAddress)(params.streamMetadata);
1276
1337
  const newRecipient = (0, anchor_1.translateAddress)(params.newRecipient);
1277
1338
  const ix = await this.getChangeStreamReceiverInstruction(streamMetadata, newRecipient, vaultSigner);
1278
- const actions = [(0, utils_1.transactionInstructionToPropoalAction)(ix)];
1339
+ const actions = [
1340
+ (0, utils_1.transactionInstructionToPropoalAction)(ix),
1341
+ ];
1279
1342
  const remainingAccounts = actions.reduce((acc, current) => {
1280
1343
  const accounts = current.accountSpecs.map((spec) => ({
1281
1344
  pubkey: spec.pubkey,
@@ -1293,7 +1356,9 @@ class ZebecVaultService {
1293
1356
  return this._createTransactionPayload(vaultOwner, [ixFinal]);
1294
1357
  }
1295
1358
  async withdrawStream(params) {
1296
- const vaultOwner = params.vaultOwner ? (0, anchor_1.translateAddress)(params.vaultOwner) : this.provider.publicKey;
1359
+ const vaultOwner = params.vaultOwner
1360
+ ? (0, anchor_1.translateAddress)(params.vaultOwner)
1361
+ : this.provider.publicKey;
1297
1362
  if (!vaultOwner) {
1298
1363
  throw new Error("Either provide a caller or use AnchorProvider for provider in the service");
1299
1364
  }
@@ -1405,7 +1470,9 @@ class ZebecVaultService {
1405
1470
  .instruction();
1406
1471
  }
1407
1472
  async stake(params) {
1408
- const vaultOwner = params.vaultOwner ? (0, anchor_1.translateAddress)(params.vaultOwner) : this.provider.publicKey;
1473
+ const vaultOwner = params.vaultOwner
1474
+ ? (0, anchor_1.translateAddress)(params.vaultOwner)
1475
+ : this.provider.publicKey;
1409
1476
  if (!vaultOwner) {
1410
1477
  throw new Error("MissingArgument: Please provide either vaultOwner address or publicKey in provider");
1411
1478
  }
@@ -1419,7 +1486,8 @@ class ZebecVaultService {
1419
1486
  }
1420
1487
  const lockPeriods = lockupAccount.stakeInfo.durationMap.map((item) => item.duration.toNumber());
1421
1488
  if (!lockPeriods.includes(params.lockPeriod)) {
1422
- throw new Error("Invalid lockperiod. Available options are: " + lockPeriods.map((l) => l.toString()).concat(", "));
1489
+ throw new Error("Invalid lockperiod. Available options are: " +
1490
+ lockPeriods.map((l) => l.toString()).concat(", "));
1423
1491
  }
1424
1492
  const stakeToken = lockupAccount.stakedToken.tokenAddress;
1425
1493
  const stakeVault = (0, zebec_stake_sdk_1.deriveStakeVaultAddress)(lockup, this.stakeProgramId);
@@ -1459,7 +1527,9 @@ class ZebecVaultService {
1459
1527
  return this._createTransactionPayload(vaultOwner, [ixFinal], [], [lookupTableAccount]);
1460
1528
  }
1461
1529
  async unstake(params) {
1462
- const vaultOwner = params.vaultOwner ? (0, anchor_1.translateAddress)(params.vaultOwner) : this.provider.publicKey;
1530
+ const vaultOwner = params.vaultOwner
1531
+ ? (0, anchor_1.translateAddress)(params.vaultOwner)
1532
+ : this.provider.publicKey;
1463
1533
  if (!vaultOwner) {
1464
1534
  throw new Error("MissingArgument: Please provide either staker address or publicKey in provider");
1465
1535
  }
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "author": "Zebec Network | Ashish Sapkota",
3
- "dependencies": {
4
- "@coral-xyz/anchor": "^0.31.1",
5
- "@solana/spl-token": "^0.4.14",
6
- "@solana/web3.js": "^1.98.2",
7
- "@types/bn.js": "^5.2.0",
8
- "@zebec-network/core-utils": "^1.1.1",
9
- "@zebec-network/solana-common": "^2.3.1",
10
- "@zebec-network/zebec-card-v2-sdk": "^2.5.4",
11
- "@zebec-network/zebec-stake-sdk": "^1.2.2",
12
- "@zebec-network/zebec-stream-sdk": "^3.1.0-dev.1",
13
- "bignumber.js": "^9.3.1",
14
- "buffer": "^6.0.3"
15
- },
16
- "description": "An SDK for zebec vault solana program",
17
- "devDependencies": {
18
- "@types/mocha": "^10.0.10",
19
- "@types/node": "^24.3.1",
20
- "dotenv": "^17.2.2",
21
- "mocha": "^11.7.2",
22
- "prettier": "^3.6.2",
23
- "rimraf": "^6.0.1",
24
- "ts-mocha": "^11.1.0",
25
- "ts-node": "^10.9.2",
26
- "typescript": "^5.9.2"
27
- },
28
- "files": [
29
- "dist",
30
- "assets"
31
- ],
32
- "keywords": [
33
- "solana",
34
- "zebec",
35
- "zebec network",
36
- "vualt",
37
- "zebec vault"
38
- ],
39
- "license": "MIT",
40
- "main": "dist/index.js",
41
- "name": "@zebec-network/zebec-vault-sdk",
42
- "scripts": {
43
- "build": "npm run clean && tsc",
44
- "clean": "rimraf ./dist",
45
- "format": "prettier --write .",
46
- "test": "ts-mocha -p ./tsconfig.json -t 1000000000 test/**/*.test.ts",
47
- "test:single": "ts-mocha -p ./tsconfig.json -t 1000000000"
48
- },
49
- "types": "dist/index.d.ts",
50
- "version": "5.2.0-dev.1"
1
+ {
2
+ "author": "Zebec Network | Ashish Sapkota",
3
+ "dependencies": {
4
+ "@coral-xyz/anchor": "^0.31.1",
5
+ "@solana/spl-token": "^0.4.14",
6
+ "@solana/web3.js": "^1.98.2",
7
+ "@types/bn.js": "^5.2.0",
8
+ "@zebec-network/core-utils": "^1.1.1",
9
+ "@zebec-network/solana-common": "^2.3.1",
10
+ "@zebec-network/zebec-card-v2-sdk": "^2.5.4",
11
+ "@zebec-network/zebec-stake-sdk": "^1.2.2",
12
+ "@zebec-network/zebec-stream-sdk": "^3.1.0",
13
+ "bignumber.js": "^9.3.1",
14
+ "buffer": "^6.0.3"
15
+ },
16
+ "description": "An SDK for zebec vault solana program",
17
+ "devDependencies": {
18
+ "@types/mocha": "^10.0.10",
19
+ "@types/node": "^24.3.1",
20
+ "dotenv": "^17.2.2",
21
+ "mocha": "^11.7.2",
22
+ "prettier": "^3.6.2",
23
+ "rimraf": "^6.0.1",
24
+ "ts-mocha": "^11.1.0",
25
+ "ts-node": "^10.9.2",
26
+ "typescript": "^5.9.2"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "assets"
31
+ ],
32
+ "keywords": [
33
+ "solana",
34
+ "zebec",
35
+ "zebec network",
36
+ "vualt",
37
+ "zebec vault"
38
+ ],
39
+ "license": "MIT",
40
+ "main": "dist/index.js",
41
+ "name": "@zebec-network/zebec-vault-sdk",
42
+ "scripts": {
43
+ "build": "npm run clean && tsc",
44
+ "clean": "rimraf ./dist",
45
+ "format": "npx @biomejs/biome format --write ",
46
+ "test": "ts-mocha -p ./tsconfig.json -t 1000000000 test/**/*.test.ts",
47
+ "test:single": "ts-mocha -p ./tsconfig.json -t 1000000000"
48
+ },
49
+ "types": "dist/index.d.ts",
50
+ "version": "5.2.0"
51
51
  }