@fairblock/stabletrust 2.0.5 → 2.0.6
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
|
-
import { ConfidentialTransferClient } from "@fairblock/stabletrust";
|
|
4
|
-
import { ERC20_ABI } from "./constants.js";
|
|
3
|
+
import { ConfidentialTransferClient, ERC20_ABI } from "@fairblock/stabletrust";
|
|
5
4
|
dotenv.config();
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
|
-
import { ConfidentialTransferClient } from "@fairblock/stabletrust";
|
|
4
|
-
import { ERC20_ABI } from "./constants.js";
|
|
3
|
+
import { ConfidentialTransferClient, ERC20_ABI } from "@fairblock/stabletrust";
|
|
5
4
|
dotenv.config();
|
|
6
5
|
const RPC_URL = process.env.RPC_URL || "https://rpc.testnet.stable.xyz";
|
|
7
6
|
const EXPLORER_URL =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fairblock/stabletrust",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
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",
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"src/",
|
|
22
22
|
"pkg/",
|
|
23
23
|
"examples/",
|
|
24
|
-
"README.md"
|
|
25
|
-
"CHANGELOG.md"
|
|
24
|
+
"README.md"
|
|
26
25
|
],
|
|
27
26
|
"repository": {
|
|
28
27
|
"type": "git",
|
|
@@ -840,52 +840,6 @@ export class ConfidentialTransferClient {
|
|
|
840
840
|
);
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
-
/**
|
|
844
|
-
* Wait for pending balance to appear
|
|
845
|
-
*
|
|
846
|
-
* @param {string} address - Account address
|
|
847
|
-
* @param {string} privateKey - Private key for decryption
|
|
848
|
-
* @param {string} tokenAddress - Token address
|
|
849
|
-
* @param {Object} [options] - Options
|
|
850
|
-
* @param {number} [options.maxAttempts=225] - Maximum polling attempts
|
|
851
|
-
* @param {number} [options.intervalMs=400] - Polling interval in milliseconds
|
|
852
|
-
* @returns {Promise<{amount: number, ciphertext: string}>}
|
|
853
|
-
*/
|
|
854
|
-
async _waitForPendingBalance(
|
|
855
|
-
address,
|
|
856
|
-
privateKey,
|
|
857
|
-
tokenAddress,
|
|
858
|
-
options = {},
|
|
859
|
-
) {
|
|
860
|
-
const { maxAttempts = 225, intervalMs = 400 } = options;
|
|
861
|
-
await sleep(1000);
|
|
862
|
-
|
|
863
|
-
try {
|
|
864
|
-
for (let i = 0; i < maxAttempts; i++) {
|
|
865
|
-
const pending = await this._getPendingBalance(
|
|
866
|
-
address,
|
|
867
|
-
privateKey,
|
|
868
|
-
tokenAddress,
|
|
869
|
-
);
|
|
870
|
-
|
|
871
|
-
if (pending.amount > 0n) {
|
|
872
|
-
return pending;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
await sleep(intervalMs);
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
throw new Error(
|
|
879
|
-
`Timeout waiting for pending balance after ${maxAttempts} attempts. The transfer may still be processing.`,
|
|
880
|
-
);
|
|
881
|
-
} catch (error) {
|
|
882
|
-
if (error.message.includes("Timeout waiting for pending balance")) {
|
|
883
|
-
throw error;
|
|
884
|
-
}
|
|
885
|
-
throw new Error(`Failed to wait for pending balance: ${error.message}`);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
|
|
889
843
|
/**
|
|
890
844
|
* Get the current fee amount for confidential transfers
|
|
891
845
|
*
|
package/src/constants.js
CHANGED
|
@@ -24,11 +24,11 @@ export const ERC20_ABI = [
|
|
|
24
24
|
export const TEMPO_FEE_TOKEN_ADDRESS =
|
|
25
25
|
"0x20c0000000000000000000000000000000000000";
|
|
26
26
|
export const STABLETRUST_CONTRACTS_BY_CHAIN_ID = Object.freeze({
|
|
27
|
-
2201: "
|
|
28
|
-
5042002: "
|
|
29
|
-
84532: "
|
|
30
|
-
11155111: "
|
|
31
|
-
421614: "
|
|
27
|
+
2201: "0xe1c1456CAb802312759a8cFc3976f88bf87082cf", //Stable
|
|
28
|
+
5042002: "0x1B4f05f67CC33788Da4C89a7cd0b2f8E0055E605", //Arc
|
|
29
|
+
84532: "0x4a251C9D79faCa20b193630A4ee313af7cBCDD93", //Base
|
|
30
|
+
11155111: "0x7507a13352AFAa79D33E994f86f2f62463ba8DE4", //Ethereum
|
|
31
|
+
421614: "0x5acECCdeb5CbD3C727eCB49F8706Eb80EF2f977F", //Arbitrum
|
|
32
32
|
42431: "0xE559fB936C69c46E216bf61B07C16bF1a6d444aa", //Tempo
|
|
33
33
|
});
|
|
34
34
|
|
package/src/index.d.ts
CHANGED
|
@@ -188,9 +188,7 @@ declare module "@fairblock/stabletrust" {
|
|
|
188
188
|
/**
|
|
189
189
|
* Get on-chain core state for an anonymous account.
|
|
190
190
|
*/
|
|
191
|
-
getAnonymousAccountInfo(
|
|
192
|
-
accountId: number | bigint,
|
|
193
|
-
): Promise<AnonymousAccountInfo>;
|
|
191
|
+
getAnonymousAccountInfo(accountId: string): Promise<AnonymousAccountInfo>;
|
|
194
192
|
|
|
195
193
|
/**
|
|
196
194
|
* Read the current authNonce for an anonymous account.
|
|
@@ -211,7 +209,7 @@ declare module "@fairblock/stabletrust" {
|
|
|
211
209
|
* Use `.available` and `.pending` for individual balances, `.amount` for the total.
|
|
212
210
|
*/
|
|
213
211
|
getBalance(
|
|
214
|
-
accountId:
|
|
212
|
+
accountId: string,
|
|
215
213
|
tokenAddress: string,
|
|
216
214
|
elGamalPrivateKey: string,
|
|
217
215
|
): Promise<AnonymousAccountBalance>;
|
|
@@ -221,7 +219,7 @@ declare module "@fairblock/stabletrust" {
|
|
|
221
219
|
* Use `getBalance` for a simpler numeric summary.
|
|
222
220
|
*/
|
|
223
221
|
getAnonymousBalance(
|
|
224
|
-
accountId:
|
|
222
|
+
accountId: string,
|
|
225
223
|
tokenAddress: string,
|
|
226
224
|
elGamalPrivateKey: string,
|
|
227
225
|
): Promise<AnonymousBalance>;
|
|
@@ -484,7 +482,7 @@ declare module "@fairblock/stabletrust" {
|
|
|
484
482
|
/**
|
|
485
483
|
* Deposit options
|
|
486
484
|
*/
|
|
487
|
-
export interface
|
|
485
|
+
export interface ConfidentialDepositOptions {
|
|
488
486
|
waitForFinalization?: boolean;
|
|
489
487
|
}
|
|
490
488
|
|
|
@@ -560,7 +558,7 @@ declare module "@fairblock/stabletrust" {
|
|
|
560
558
|
wallet: ethers.Wallet | ethers.Signer,
|
|
561
559
|
tokenAddress: string,
|
|
562
560
|
amount: bigint | string | number,
|
|
563
|
-
options?:
|
|
561
|
+
options?: ConfidentialDepositOptions,
|
|
564
562
|
): Promise<ethers.ContractTransactionReceipt>;
|
|
565
563
|
|
|
566
564
|
/**
|
package/examples/constants.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const ERC20_ABI = [
|
|
2
|
-
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
3
|
-
"function allowance(address owner, address spender) external view returns (uint256)",
|
|
4
|
-
"function balanceOf(address account) external view returns (uint256)",
|
|
5
|
-
"function decimals() external view returns (uint8)",
|
|
6
|
-
];
|