@fairblock/stabletrust 1.0.10 → 1.0.12

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.
@@ -168,6 +168,17 @@ async function main() {
168
168
  const withdrawRes = await trackPerformance("WITHDRAW_TOKENS", () =>
169
169
  client.withdraw(recipient, TOKEN_ADDRESS, withdrawAmount),
170
170
  );
171
+ let recipientConfidentialBalanceBeforeWithdraw =
172
+ await client.getConfidentialBalance(
173
+ recipient.address,
174
+ recipientKeys.privateKey,
175
+ TOKEN_ADDRESS,
176
+ );
177
+
178
+ console.log(
179
+ "Recipient Confidential Balance (Pre-Withdraw):",
180
+ ethers.formatUnits(recipientConfidentialBalanceBeforeWithdraw.amount, 2),
181
+ );
171
182
  const withdrawHash = withdrawRes.result.hash;
172
183
  console.log(`Transaction Hash: ${withdrawHash}`);
173
184
  console.log(`View Transaction: ${EXPLORER_URL}${withdrawHash}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairblock/stabletrust",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "SDK for confidential transfers using homomorphic encryption and zero-knowledge proofs",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/client.js CHANGED
@@ -155,11 +155,11 @@ export class ConfidentialTransferClient {
155
155
  * @param {ethers.Wallet|ethers.Signer} wallet - The wallet to create account for
156
156
  * @param {Object} [options] - Options
157
157
  * @param {boolean} [options.waitForFinalization=true] - Wait for account finalization
158
- * @param {number} [options.maxAttempts=30] - Max attempts to wait for finalization
158
+ * @param {number} [options.maxAttempts=225] - Max attempts to wait for finalization
159
159
  * @returns {Promise<{publicKey: string, privateKey: string}>} The derived keys
160
160
  */
161
161
  async ensureAccount(wallet, options = {}) {
162
- const { waitForFinalization = true, maxAttempts = 30 } = options;
162
+ const { waitForFinalization = true, maxAttempts = 225 } = options;
163
163
 
164
164
  try {
165
165
  const address = await wallet.getAddress();
@@ -183,7 +183,7 @@ export class ConfidentialTransferClient {
183
183
  if (waitForFinalization) {
184
184
  let attempts = 0;
185
185
  while (!accountInfo.finalized && attempts < maxAttempts) {
186
- await sleep(2000);
186
+ await sleep(400);
187
187
  accountInfo = await this.getAccountInfo(address);
188
188
  attempts++;
189
189
  }
@@ -880,11 +880,8 @@ export class ConfidentialTransferClient {
880
880
  * @private
881
881
  */
882
882
  async _waitForGlobalState(address, actionLabel) {
883
- // Initial cooldown to allow the relayer/indexer to pick up the transaction
884
- await sleep(10000);
885
-
886
883
  let attempts = 0;
887
- const maxAttempts = 60;
884
+ const maxAttempts = 450; // 450 * 200ms = 90 seconds max wait
888
885
 
889
886
  while (attempts < maxAttempts) {
890
887
  try {
@@ -899,7 +896,7 @@ export class ConfidentialTransferClient {
899
896
  );
900
897
  }
901
898
 
902
- await sleep(3000);
899
+ await sleep(200);
903
900
  attempts++;
904
901
  }
905
902
 
@@ -915,8 +912,8 @@ export class ConfidentialTransferClient {
915
912
  * @param {string} privateKey - Private key for decryption
916
913
  * @param {string} tokenAddress - Token address
917
914
  * @param {Object} [options] - Options
918
- * @param {number} [options.maxAttempts=60] - Maximum polling attempts
919
- * @param {number} [options.intervalMs=3000] - Polling interval in milliseconds
915
+ * @param {number} [options.maxAttempts=225] - Maximum polling attempts
916
+ * @param {number} [options.intervalMs=400] - Polling interval in milliseconds
920
917
  * @returns {Promise<{amount: number, ciphertext: string}>}
921
918
  */
922
919
  async _waitForPendingBalance(
@@ -925,7 +922,7 @@ export class ConfidentialTransferClient {
925
922
  tokenAddress,
926
923
  options = {},
927
924
  ) {
928
- const { maxAttempts = 60, intervalMs = 3000 } = options;
925
+ const { maxAttempts = 225, intervalMs = 400 } = options;
929
926
 
930
927
  try {
931
928
  for (let i = 0; i < maxAttempts; i++) {