@fairblock/stabletrust 1.0.18 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairblock/stabletrust",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
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
@@ -327,7 +327,7 @@ export class ConfidentialTransferClient {
327
327
  tokenAddress,
328
328
  );
329
329
 
330
- if (pendingBalance.amount > 0) {
330
+ if (pendingBalance.amount > 0n) {
331
331
  try {
332
332
  await this._applyPending(wallet, { waitForFinalization: true });
333
333
  } catch (error) {
@@ -381,13 +381,13 @@ export class ConfidentialTransferClient {
381
381
  tokenContract.balanceOf(address),
382
382
  tokenContract.allowance(address, this.config.contractAddress),
383
383
  ]);
384
- if (tokenBalance < depositAmount) {
384
+ if (tokenBalance < BigInt(amount)) {
385
385
  throw new Error(
386
386
  `Insufficient token balance. Required: ${amount}, Available: ${tokenBalance}`,
387
387
  );
388
388
  }
389
389
 
390
- if (allowance < amount) {
390
+ if (allowance < BigInt(amount)) {
391
391
  const approveTx = await tokenContract
392
392
  .connect(wallet)
393
393
  .approve(this.config.contractAddress, ethers.MaxUint256);
@@ -452,7 +452,7 @@ export class ConfidentialTransferClient {
452
452
  if (!tokenAddress || !ethers.isAddress(tokenAddress)) {
453
453
  throw new Error(`Invalid token address: ${tokenAddress}`);
454
454
  }
455
- if (!amount || amount <= 0) {
455
+ if (!amount || BigInt(amount) <= 0n) {
456
456
  throw new Error("Transfer amount must be greater than 0");
457
457
  }
458
458
  const tokenContract = this._getTokenContract(tokenAddress);
@@ -632,7 +632,7 @@ export class ConfidentialTransferClient {
632
632
  if (!tokenAddress || !ethers.isAddress(tokenAddress)) {
633
633
  throw new Error(`Invalid token address: ${tokenAddress}`);
634
634
  }
635
- if (!amount || amount <= 0) {
635
+ if (!amount || BigInt(amount) <= 0n) {
636
636
  throw new Error("Withdrawal amount must be greater than 0");
637
637
  }
638
638
 
@@ -648,7 +648,6 @@ export class ConfidentialTransferClient {
648
648
  }
649
649
 
650
650
  const address = await wallet.getAddress();
651
-
652
651
  // Fetch balance first — only apply pending if available is insufficient
653
652
  let balanceSummary = await this.getConfidentialBalance(
654
653
  address,
@@ -866,7 +865,7 @@ export class ConfidentialTransferClient {
866
865
  tokenAddress,
867
866
  );
868
867
 
869
- if (pending.amount > 0) {
868
+ if (pending.amount > 0n) {
870
869
  return pending;
871
870
  }
872
871
 
package/src/crypto.js CHANGED
@@ -31,7 +31,7 @@ export async function deriveKeys(wallet, config, generateKeypair) {
31
31
  [config.chainId, config.contractAddress, ethers.ZeroAddress, "main"],
32
32
  ),
33
33
  );
34
- const userAddress = wallet.address.toLowerCase();
34
+ const userAddress = (await wallet.getAddress()).toLowerCase();
35
35
  const message = {
36
36
  purpose: "homomorphic-key-derive-v1",
37
37
  user: userAddress,
package/src/utils.js CHANGED
@@ -95,7 +95,7 @@ export async function waitForCondition(
95
95
  */
96
96
  export async function uploadJsonToIpfs(data) {
97
97
  if (!PINATA_JWT) {
98
- throw new Error("REACT_APP_PINATA_JWT is not set");
98
+ throw new Error("PINATA_JWT is not set");
99
99
  }
100
100
 
101
101
  const json = JSON.stringify(data);
@@ -132,7 +132,7 @@ export async function uploadJsonToIpfs(data) {
132
132
  */
133
133
  export async function uploadBytesToIpfs(bytes, name = "proof.bin") {
134
134
  if (!PINATA_JWT) {
135
- throw new Error("REACT_APP_PINATA_JWT is not set");
135
+ throw new Error("PINATA_JWT is not set");
136
136
  }
137
137
 
138
138
  const uint8 = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);