@fairblock/stabletrust 1.0.19 → 1.0.21

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/README.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The StableTrust SDK by Fairblock provides a robust interface for executing confidential transfers using homomorphic encryption and zero-knowledge proofs. This package enables developers to integrate confidentiality features directly into their applications, allowing for secure token deposits, private transfers, and withdrawals while maintaining the integrity and auditability of the underlying blockchain transactions.
5
+ The Stabletrust SDK by Fairblock provides a robust interface for executing confidential transfers using homomorphic encryption and zero-knowledge proofs. This package enables developers to integrate confidentiality features directly into their applications, allowing for secure token deposits, private transfers, and withdrawals while maintaining the integrity and auditability of the underlying blockchain transactions.
6
6
 
7
7
  For a comprehensive technical understanding of the architecture and cryptographic primitives, please refer to the following documentation:
8
8
 
9
9
  - **Technical Overview**: [Fairblock Confidential Transfers](https://docs.fairblock.network/docs/confidential_transfers/technical_overview)
10
- - **StableTrust Protocol**: [StableTrust Documentation](https://docs.fairblock.network/docs/confidential_transfers/stabletrust)
10
+ - **Stabletrust Protocol**: [Stabletrust Documentation](https://docs.fairblock.network/docs/confidential_transfers/stabletrust)
11
11
  - **Confidential Transactions**: [Transaction Mechanics](https://docs.fairblock.network/docs/confidential_transfers/confidential_transactions)
12
12
 
13
13
  ## Requirements
@@ -57,7 +57,7 @@ Import and initialize the client with your network configuration.
57
57
  import { ConfidentialTransferClient } from "@fairblock/stabletrust";
58
58
  import { ethers } from "ethers";
59
59
 
60
- // Configuration for Base Sepolia (uses SDK default StableTrust contract for chainId 84532)
60
+ // Configuration for Base Sepolia (uses SDK default Stabletrust contract for chainId 84532)
61
61
  const client = new ConfidentialTransferClient(
62
62
  "https://sepolia.base.org",
63
63
  84532,
@@ -69,7 +69,7 @@ If you are using a custom deployment, you can still pass an explicit contract ad
69
69
  ```javascript
70
70
  const customClient = new ConfidentialTransferClient(
71
71
  "https://sepolia.base.org",
72
- "0xYourCustomStableTrustContract",
72
+ "0xYourCustomStabletrustContract",
73
73
  84532,
74
74
  );
75
75
  ```
@@ -146,7 +146,7 @@ Fetches account core information from the contract.
146
146
 
147
147
  #### `ensureAccount(signer, options)`
148
148
 
149
- Initializes or retrieves the cryptographic keys associated with an account. This step is required before performing any confidential operations. Automatically creates the account on-chain if it doesn't exist.
149
+ Initializes or retrieves the cryptographic keys associated with an account. This step is required before performing any confidential operations. Automatically creates the account onchain if it doesn't exist.
150
150
 
151
151
  - **Parameters**:
152
152
  - `signer` (ethers.Signer): The ethers.js signer instance for the user.
@@ -266,7 +266,7 @@ The following are estimated execution times for standard operations within the c
266
266
 
267
267
  ## Security Considerations
268
268
 
269
- When using the StableTrust SDK, follow these best practices to ensure the security of your confidential transactions:
269
+ When using the Stabletrust SDK, follow these best practices to ensure the security of your confidential transactions:
270
270
 
271
271
  1. **Private Key Management**
272
272
  - Never expose or log private keys or seed phrases
@@ -245,7 +245,7 @@ async function runChainFlow(chain, senderPrivateKey, recipientPrivateKey) {
245
245
 
246
246
  const txHash = txRes.result.hash || txRes.result.transactionHash;
247
247
  console.log(
248
- "Status: Confidential Transfer is completed. Transfer amount is hidden on-chain.",
248
+ "Status: Confidential Transfer is completed. Transfer amount is hidden onchain.",
249
249
  );
250
250
  console.log(`Transaction Hash: ${txHash}`);
251
251
  console.log(`View Transaction: ${explorerBaseUrl}${txHash}`);
@@ -28,7 +28,7 @@ async function minimalFlow() {
28
28
  // 3. DEPOSIT: Move public ERC20 into the confidential contract
29
29
  res = await client.confidentialDeposit(sender, TOKEN, amount);
30
30
  console.log("Deposit TX Hash:", EXPLORER_URL + res.hash);
31
- // 4. TRANSFER: Privacy-preserving transfer (On-chain amount is hidden)
31
+ // 4. TRANSFER: Privacy-preserving transfer (onchain amount is hidden)
32
32
  // This moves funds from Sender's 'Available' to Recipient's 'Pending' balance
33
33
  res = await client.confidentialTransfer(
34
34
  sender,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairblock/stabletrust",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
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
@@ -2,7 +2,7 @@ import { ethers } from "ethers";
2
2
  import {
3
3
  CONTRACT_ABI,
4
4
  ERC20_ABI,
5
- getStableTrustContractAddress,
5
+ getStabletrustContractAddress,
6
6
  } from "./constants.js";
7
7
  import { deriveKeys, decryptCiphertext, combineCiphertext } from "./crypto.js";
8
8
  import {
@@ -45,12 +45,12 @@ export class ConfidentialTransferClient {
45
45
 
46
46
  if (typeof contractAddressOrChainId === "number" && chainId === undefined) {
47
47
  resolvedChainId = contractAddressOrChainId;
48
- resolvedContractAddress = getStableTrustContractAddress(resolvedChainId);
48
+ resolvedContractAddress = getStabletrustContractAddress(resolvedChainId);
49
49
  } else {
50
50
  resolvedChainId = chainId;
51
51
  resolvedContractAddress =
52
52
  contractAddressOrChainId ||
53
- getStableTrustContractAddress(resolvedChainId);
53
+ getStabletrustContractAddress(resolvedChainId);
54
54
  }
55
55
 
56
56
  if (!resolvedChainId) {
@@ -61,7 +61,7 @@ export class ConfidentialTransferClient {
61
61
  .map(String)
62
62
  .join(", ");
63
63
  throw new Error(
64
- `contractAddress is required for chainId ${resolvedChainId}. No default StableTrust contract is configured for this chain. Supported chainIds: ${supportedChainIds}`,
64
+ `contractAddress is required for chainId ${resolvedChainId}. No default Stabletrust contract is configured for this chain. Supported chainIds: ${supportedChainIds}`,
65
65
  );
66
66
  }
67
67
  if (!ethers.isAddress(resolvedContractAddress)) {
@@ -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) {
@@ -387,7 +387,7 @@ export class ConfidentialTransferClient {
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
 
@@ -865,7 +865,7 @@ export class ConfidentialTransferClient {
865
865
  tokenAddress,
866
866
  );
867
867
 
868
- if (pending.amount > 0) {
868
+ if (pending.amount > 0n) {
869
869
  return pending;
870
870
  }
871
871
 
package/src/constants.js CHANGED
@@ -33,6 +33,6 @@ export const STABLETRUST_CONTRACTS_BY_CHAIN_ID = Object.freeze({
33
33
  42431: "0xE559fB936C69c46E216bf61B07C16bF1a6d444aa", //Tempo
34
34
  });
35
35
 
36
- export function getStableTrustContractAddress(chainId) {
36
+ export function getStabletrustContractAddress(chainId) {
37
37
  return STABLETRUST_CONTRACTS_BY_CHAIN_ID[Number(chainId)] || null;
38
38
  }
package/src/index.d.ts CHANGED
@@ -10,7 +10,7 @@ declare module "@fairblock/stabletrust" {
10
10
  chainId: number;
11
11
  }
12
12
 
13
- export type StableTrustChainId =
13
+ export type StabletrustChainId =
14
14
  | 1244
15
15
  | 2201
16
16
  | 42431
@@ -82,7 +82,7 @@ declare module "@fairblock/stabletrust" {
82
82
  /**
83
83
  * Create a new ConfidentialTransferClient
84
84
  * @param rpcUrl RPC endpoint URL
85
- * @param chainId Chain ID (uses default StableTrust contract for known networks)
85
+ * @param chainId Chain ID (uses default Stabletrust contract for known networks)
86
86
  */
87
87
  constructor(rpcUrl: string, chainId: number);
88
88
 
@@ -233,12 +233,12 @@ declare module "@fairblock/stabletrust" {
233
233
  export const ERC20_ABI: any[];
234
234
 
235
235
  /**
236
- * StableTrust contract addresses by chain id
236
+ * Stabletrust contract addresses by chain id
237
237
  */
238
238
  export const STABLETRUST_CONTRACTS_BY_CHAIN_ID: Record<number, string>;
239
239
 
240
240
  /**
241
- * Resolve StableTrust contract address by chain id
241
+ * Resolve Stabletrust contract address by chain id
242
242
  */
243
- export function getStableTrustContractAddress(chainId: number): string | null;
243
+ export function getStabletrustContractAddress(chainId: number): string | null;
244
244
  }
package/src/index.js CHANGED
@@ -5,6 +5,6 @@ export {
5
5
  CONTRACT_ABI,
6
6
  ERC20_ABI,
7
7
  STABLETRUST_CONTRACTS_BY_CHAIN_ID,
8
- getStableTrustContractAddress,
8
+ getStabletrustContractAddress,
9
9
  } from "./constants.js";
10
10
  // Note: initializeWasm is now internal - WASM auto-initializes on first client use
package/src/utils.js CHANGED
@@ -56,7 +56,7 @@ export function logTransaction(hash, explorerUrl, isConfidential = false) {
56
56
  console.log(`Transaction submitted: ${explorerUrl}${hash}`);
57
57
  if (isConfidential) {
58
58
  console.log(
59
- `Note: This is a confidential transaction - the amount is not visible on-chain.`,
59
+ `Note: This is a confidential transaction - the amount is not visible onchain.`,
60
60
  );
61
61
  }
62
62
  }