dop-wallet-v6 1.3.2 โ 1.3.32
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/.eslintrc.js +5 -0
- package/dist/services/dop/crypto/react-native-crypto-provider.js +4 -2
- package/dist/services/dop/crypto/react-native-crypto-provider.js.map +1 -1
- package/dist/services/dop/wallets/wallets.js +12 -17
- package/dist/services/dop/wallets/wallets.js.map +1 -1
- package/dist/services/transactions/tx-encrypt-relayer.d.ts +6 -0
- package/dist/services/transactions/tx-encrypt-relayer.js +80 -0
- package/dist/services/transactions/tx-encrypt-relayer.js.map +1 -0
- package/package.json +6 -1
- package/dist/__tests__/index.test.d.ts +0 -1
- package/dist/__tests__/index.test.js +0 -13
- package/dist/__tests__/index.test.js.map +0 -1
- package/dist/services/artifacts/__tests__/artifact-downloader.test.d.ts +0 -1
- package/dist/services/artifacts/__tests__/artifact-downloader.test.js +0 -70
- package/dist/services/artifacts/__tests__/artifact-downloader.test.js.map +0 -1
- package/dist/services/dop/__tests__/integration.test.d.ts +0 -1
- package/dist/services/dop/__tests__/integration.test.js +0 -378
- package/dist/services/dop/__tests__/integration.test.js.map +0 -1
- package/dist/services/dop/core/__tests__/engine.test.d.ts +0 -1
- package/dist/services/dop/core/__tests__/engine.test.js +0 -30
- package/dist/services/dop/core/__tests__/engine.test.js.map +0 -1
- package/dist/services/dop/core/__tests__/providers.test.d.ts +0 -1
- package/dist/services/dop/core/__tests__/providers.test.js +0 -69
- package/dist/services/dop/core/__tests__/providers.test.js.map +0 -1
- package/dist/services/dop/dop-txids/__tests__/dop-txid-sync-graph-v2.test.d.ts +0 -1
- package/dist/services/dop/dop-txids/__tests__/dop-txid-sync-graph-v2.test.js +0 -168
- package/dist/services/dop/dop-txids/__tests__/dop-txid-sync-graph-v2.test.js.map +0 -1
- package/dist/services/dop/history/__tests__/transaction-history.test.d.ts +0 -0
- package/dist/services/dop/history/__tests__/transaction-history.test.js +0 -2
- package/dist/services/dop/history/__tests__/transaction-history.test.js.map +0 -1
- package/dist/services/dop/profile/__tests__/profile-manager.test.d.ts +0 -1
- package/dist/services/dop/profile/__tests__/profile-manager.test.js +0 -170
- package/dist/services/dop/profile/__tests__/profile-manager.test.js.map +0 -1
- package/dist/services/dop/profile/__tests__/selective-transparency.test.d.ts +0 -1
- package/dist/services/dop/profile/__tests__/selective-transparency.test.js +0 -256
- package/dist/services/dop/profile/__tests__/selective-transparency.test.js.map +0 -1
- package/dist/services/dop/profile/__tests__/storage.test.d.ts +0 -1
- package/dist/services/dop/profile/__tests__/storage.test.js +0 -174
- package/dist/services/dop/profile/__tests__/storage.test.js.map +0 -1
- package/dist/services/dop/quick-sync/V2/__tests__/quick-sync-events-graph-v2.test.d.ts +0 -1
- package/dist/services/dop/quick-sync/V2/__tests__/quick-sync-events-graph-v2.test.js +0 -126
- package/dist/services/dop/quick-sync/V2/__tests__/quick-sync-events-graph-v2.test.js.map +0 -1
- package/dist/services/dop/quick-sync/V3/__tests__/quick-sync-events-graph-v3.test.d.ts +0 -1
- package/dist/services/dop/quick-sync/V3/__tests__/quick-sync-events-graph-v3.test.js +0 -63
- package/dist/services/dop/quick-sync/V3/__tests__/quick-sync-events-graph-v3.test.js.map +0 -1
- package/dist/services/dop/util/__tests__/bytes-util.test.d.ts +0 -1
- package/dist/services/dop/util/__tests__/bytes-util.test.js +0 -23
- package/dist/services/dop/util/__tests__/bytes-util.test.js.map +0 -1
- package/dist/services/dop/util/__tests__/crypto-util.test.d.ts +0 -1
- package/dist/services/dop/util/__tests__/crypto-util.test.js +0 -62
- package/dist/services/dop/util/__tests__/crypto-util.test.js.map +0 -1
- package/dist/services/dop/wallets/__tests__/balances-live.test.d.ts +0 -1
- package/dist/services/dop/wallets/__tests__/balances-live.test.js +0 -58
- package/dist/services/dop/wallets/__tests__/balances-live.test.js.map +0 -1
- package/dist/services/dop/wallets/__tests__/balances-update.test.d.ts +0 -1
- package/dist/services/dop/wallets/__tests__/balances-update.test.js +0 -90
- package/dist/services/dop/wallets/__tests__/balances-update.test.js.map +0 -1
- package/dist/services/dop/wallets/__tests__/balances.test.d.ts +0 -1
- package/dist/services/dop/wallets/__tests__/balances.test.js +0 -59
- package/dist/services/dop/wallets/__tests__/balances.test.js.map +0 -1
- package/dist/services/dop/wallets/__tests__/wallets.test.d.ts +0 -1
- package/dist/services/dop/wallets/__tests__/wallets.test.js +0 -80
- package/dist/services/dop/wallets/__tests__/wallets.test.js.map +0 -1
- package/dist/services/ethers/__tests__/ethers-util.test.d.ts +0 -1
- package/dist/services/ethers/__tests__/ethers-util.test.js +0 -19
- package/dist/services/ethers/__tests__/ethers-util.test.js.map +0 -1
- package/dist/services/transactions/__tests__/json/formatted-relay-adapt-error-logs.json +0 -216
- package/dist/services/transactions/__tests__/proof-cache.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/proof-cache.test.js +0 -128
- package/dist/services/transactions/__tests__/proof-cache.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-cross-contract-calls.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/tx-cross-contract-calls.test.js +0 -385
- package/dist/services/transactions/__tests__/tx-cross-contract-calls.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-decrypt.test.d.ts +0 -0
- package/dist/services/transactions/__tests__/tx-decrypt.test.js +0 -2
- package/dist/services/transactions/__tests__/tx-decrypt.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-encrypt-base-token.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/tx-encrypt-base-token.test.js +0 -101
- package/dist/services/transactions/__tests__/tx-encrypt-base-token.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-encrypt.test.d.ts +0 -0
- package/dist/services/transactions/__tests__/tx-encrypt.test.js +0 -2
- package/dist/services/transactions/__tests__/tx-encrypt.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-gas-details.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/tx-gas-details.test.js +0 -112
- package/dist/services/transactions/__tests__/tx-gas-details.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-notes.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/tx-notes.test.js +0 -193
- package/dist/services/transactions/__tests__/tx-notes.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-proof-transfer-with-data.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/tx-proof-transfer-with-data.test.js +0 -50
- package/dist/services/transactions/__tests__/tx-proof-transfer-with-data.test.js.map +0 -1
- package/dist/services/transactions/__tests__/tx-transfer.test.d.ts +0 -1
- package/dist/services/transactions/__tests__/tx-transfer.test.js +0 -280
- package/dist/services/transactions/__tests__/tx-transfer.test.js.map +0 -1
- package/dist/tests/balances.test.d.ts +0 -1
- package/dist/tests/balances.test.js +0 -419
- package/dist/tests/balances.test.js.map +0 -1
- package/dist/tests/helper.test.d.ts +0 -3
- package/dist/tests/helper.test.js +0 -16
- package/dist/tests/helper.test.js.map +0 -1
- package/dist/tests/mocks.test.d.ts +0 -50
- package/dist/tests/mocks.test.js +0 -202
- package/dist/tests/mocks.test.js.map +0 -1
- package/dist/tests/poi/test-wallet-poi-requester.test.d.ts +0 -10
- package/dist/tests/poi/test-wallet-poi-requester.test.js +0 -15
- package/dist/tests/poi/test-wallet-poi-requester.test.js.map +0 -1
- package/dist/tests/setup.test.d.ts +0 -9
- package/dist/tests/setup.test.js +0 -110
- package/dist/tests/setup.test.js.map +0 -1
- package/dist/tests/stubs/engine-stubs.test.d.ts +0 -7
- package/dist/tests/stubs/engine-stubs.test.js +0 -75
- package/dist/tests/stubs/engine-stubs.test.js.map +0 -1
- package/dist/utils/__tests__/blocked-address.test.d.ts +0 -1
- package/dist/utils/__tests__/blocked-address.test.js +0 -23
- package/dist/utils/__tests__/blocked-address.test.js.map +0 -1
- package/dist/utils/__tests__/logger.test.d.ts +0 -1
- package/dist/utils/__tests__/logger.test.js +0 -28
- package/dist/utils/__tests__/logger.test.js.map +0 -1
- package/dist/utils/__tests__/utils.test.d.ts +0 -1
- package/dist/utils/__tests__/utils.test.js +0 -21
- package/dist/utils/__tests__/utils.test.js.map +0 -1
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
|
-
const chai_1 = __importDefault(require("chai"));
|
|
8
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
|
-
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
|
|
10
|
-
const mocks_test_1 = require("./mocks.test");
|
|
11
|
-
const setup_test_1 = require("./setup.test");
|
|
12
|
-
const wallets_1 = require("../services/dop/wallets/wallets");
|
|
13
|
-
const balance_update_1 = require("../services/dop/wallets/balance-update");
|
|
14
|
-
const dop_sharedmodels_v3_1 = require("dop-sharedmodels-v3");
|
|
15
|
-
const load_provider_1 = require("../services/dop/core/load-provider");
|
|
16
|
-
const engine_1 = require("../services/dop/core/engine");
|
|
17
|
-
chai_1.default.use(chai_as_promised_1.default);
|
|
18
|
-
const { expect } = chai_1.default;
|
|
19
|
-
// ==========================================
|
|
20
|
-
// CONFIGURATION - MODIFY THESE VALUES
|
|
21
|
-
// ==========================================
|
|
22
|
-
// PUT YOUR REAL MNEMONIC HERE
|
|
23
|
-
const YOUR_MNEMONIC = "rough shadow recall crane injury grass valid guilt close latin seed eight";
|
|
24
|
-
// CHOOSE YOUR NETWORK (uncomment one)
|
|
25
|
-
// const NETWORK_NAME: NetworkName = NetworkName.Ethereum; // Ethereum Mainnet
|
|
26
|
-
const NETWORK_NAME = dop_sharedmodels_v3_1.NetworkName.Polygon; // Polygon Mainnet
|
|
27
|
-
// const NETWORK_NAME: NetworkName = NetworkName.Arbitrum; // Arbitrum Mainnet
|
|
28
|
-
// CHOOSE TXID VERSION (V3 is recommended)
|
|
29
|
-
// const TXID_VERSION = TXIDVersion.V3_PoseidonMerkle;
|
|
30
|
-
const TXID_VERSION = dop_sharedmodels_v3_1.TXIDVersion.V2_PoseidonMerkle;
|
|
31
|
-
// SCAN TIMEOUT SETTINGS
|
|
32
|
-
// const MAINNET_SCAN_TIMEOUT_MINUTES = 30; // 30 minutes for mainnet scan
|
|
33
|
-
const SKIP_SCAN_ON_TIMEOUT = true; // If true, continue with balance fetching even if scan times out
|
|
34
|
-
// ==========================================
|
|
35
|
-
// CUSTOM RPC PROVIDER CONFIGURATION
|
|
36
|
-
// ==========================================
|
|
37
|
-
// The test now uses public RPC endpoints by default, but you can customize them below.
|
|
38
|
-
//
|
|
39
|
-
// TO USE YOUR OWN PROVIDERS:
|
|
40
|
-
// 1. Uncomment the custom provider lines in the getProviderConfig() function
|
|
41
|
-
// 2. Replace 'YOUR_*_RPC_URL_HERE' with your actual RPC endpoints
|
|
42
|
-
// 3. Set higher priority (lower number) for your custom providers
|
|
43
|
-
//
|
|
44
|
-
// Where to get RPC URLs:
|
|
45
|
-
// - Infura: https://infura.io/ (format: 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID')
|
|
46
|
-
// - Alchemy: https://alchemy.com/ (format: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY')
|
|
47
|
-
// - QuickNode: https://quicknode.com/ (format: 'https://YOUR_ENDPOINT.quiknode.pro/YOUR_API_KEY/')
|
|
48
|
-
// - Moralis: https://moralis.io/
|
|
49
|
-
// - GetBlock: https://getblock.io/
|
|
50
|
-
// - Your own node
|
|
51
|
-
// ==========================================
|
|
52
|
-
// ==========================================
|
|
53
|
-
// PROVIDER CONFIGURATION
|
|
54
|
-
// ==========================================
|
|
55
|
-
const getProviderConfig = () => {
|
|
56
|
-
// CUSTOM PROVIDER CONFIGURATION
|
|
57
|
-
// Replace the RPC URLs below with your own provider endpoints
|
|
58
|
-
// Example formats:
|
|
59
|
-
// - Infura: 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID'
|
|
60
|
-
// - Alchemy: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY'
|
|
61
|
-
// - QuickNode: 'https://YOUR_ENDPOINT.quiknode.pro/YOUR_API_KEY/'
|
|
62
|
-
// if (NETWORK_NAME === NetworkName.Ethereum) {
|
|
63
|
-
// return {
|
|
64
|
-
// chainId: 1,
|
|
65
|
-
// providers: [
|
|
66
|
-
// // {
|
|
67
|
-
// // provider: 'https://eth.llamarpc.com',
|
|
68
|
-
// // priority: 1,
|
|
69
|
-
// // weight: 2,
|
|
70
|
-
// // },
|
|
71
|
-
// {
|
|
72
|
-
// provider: 'https://ethereum.publicnode.com',
|
|
73
|
-
// priority: 1,
|
|
74
|
-
// weight: 2,
|
|
75
|
-
// },
|
|
76
|
-
// // {
|
|
77
|
-
// // provider: 'https://rpc.ankr.com/eth',
|
|
78
|
-
// // priority: 3,
|
|
79
|
-
// // weight: 1,
|
|
80
|
-
// // },
|
|
81
|
-
// // Add your custom providers here:
|
|
82
|
-
// // {
|
|
83
|
-
// // provider: 'YOUR_ETHEREUM_RPC_URL_HERE',
|
|
84
|
-
// // priority: 1,
|
|
85
|
-
// // weight: 3,
|
|
86
|
-
// // },
|
|
87
|
-
// ],
|
|
88
|
-
// };
|
|
89
|
-
// }
|
|
90
|
-
if (NETWORK_NAME === dop_sharedmodels_v3_1.NetworkName.Polygon) {
|
|
91
|
-
return {
|
|
92
|
-
chainId: 137,
|
|
93
|
-
providers: [
|
|
94
|
-
// {
|
|
95
|
-
// provider: 'https://polygon.llamarpc.com',
|
|
96
|
-
// priority: 1,
|
|
97
|
-
// weight: 2,
|
|
98
|
-
// },
|
|
99
|
-
{
|
|
100
|
-
provider: 'https://polygon.publicnode.com',
|
|
101
|
-
priority: 2,
|
|
102
|
-
weight: 2,
|
|
103
|
-
},
|
|
104
|
-
// {
|
|
105
|
-
// provider: 'https://rpc.ankr.com/polygon',
|
|
106
|
-
// priority: 3,
|
|
107
|
-
// weight: 1,
|
|
108
|
-
// },
|
|
109
|
-
// Add your custom providers here:
|
|
110
|
-
// {
|
|
111
|
-
// provider: 'YOUR_POLYGON_RPC_URL_HERE',
|
|
112
|
-
// priority: 1,
|
|
113
|
-
// weight: 3,
|
|
114
|
-
// },
|
|
115
|
-
],
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
// if (NETWORK_NAME === NetworkName.Arbitrum) {
|
|
119
|
-
// return {
|
|
120
|
-
// chainId: 42161,
|
|
121
|
-
// providers: [
|
|
122
|
-
// {
|
|
123
|
-
// provider: 'https://arbitrum.publicnode.com',
|
|
124
|
-
// priority: 1,
|
|
125
|
-
// weight: 2,
|
|
126
|
-
// },
|
|
127
|
-
// {
|
|
128
|
-
// provider: 'https://rpc.ankr.com/arbitrum',
|
|
129
|
-
// priority: 2,
|
|
130
|
-
// weight: 2,
|
|
131
|
-
// },
|
|
132
|
-
// {
|
|
133
|
-
// provider: 'https://arbitrum.llamarpc.com',
|
|
134
|
-
// priority: 3,
|
|
135
|
-
// weight: 1,
|
|
136
|
-
// },
|
|
137
|
-
// // Add your custom providers here:
|
|
138
|
-
// // {
|
|
139
|
-
// // provider: 'YOUR_ARBITRUM_RPC_URL_HERE',
|
|
140
|
-
// // priority: 1,
|
|
141
|
-
// // weight: 3,
|
|
142
|
-
// // },
|
|
143
|
-
// ],
|
|
144
|
-
// };
|
|
145
|
-
// }
|
|
146
|
-
// Default fallback for any other network
|
|
147
|
-
throw new Error(`No provider configuration available for network: ${String(NETWORK_NAME)}. ` +
|
|
148
|
-
`Please add your custom provider configuration in the getProviderConfig() function.`);
|
|
149
|
-
};
|
|
150
|
-
// ==========================================
|
|
151
|
-
// TEST IMPLEMENTATION
|
|
152
|
-
// ==========================================
|
|
153
|
-
let dopWalletID;
|
|
154
|
-
const balanceUpdatesReceived = [];
|
|
155
|
-
const chain = dop_sharedmodels_v3_1.NETWORK_CONFIG[NETWORK_NAME].chain;
|
|
156
|
-
describe('Real Balance Fetching Test', () => {
|
|
157
|
-
before(async function run() {
|
|
158
|
-
this.timeout(60000); // 1 minute for setup
|
|
159
|
-
console.log('๐ Starting Real Balance Test');
|
|
160
|
-
console.log(`๐ก Network: ${NETWORK_NAME}`);
|
|
161
|
-
console.log(`โ๏ธ Chain ID: ${chain.id}`);
|
|
162
|
-
console.log(`๐ง TXID Version: ${TXID_VERSION}`);
|
|
163
|
-
console.log(`โญ๏ธ Skip on timeout: ${SKIP_SCAN_ON_TIMEOUT ? 'Yes' : 'No'}`);
|
|
164
|
-
console.log('');
|
|
165
|
-
console.log('๐ง Initializing test engine...');
|
|
166
|
-
await (0, setup_test_1.initTestEngine)();
|
|
167
|
-
console.log('๐ Creating DOP wallet from your mnemonic...');
|
|
168
|
-
const dopWalletInfo = await (0, wallets_1.createDopWallet)(mocks_test_1.MOCK_DB_ENCRYPTION_KEY, YOUR_MNEMONIC, undefined);
|
|
169
|
-
if (!(0, dop_sharedmodels_v3_1.isDefined)(dopWalletInfo)) {
|
|
170
|
-
throw new Error('โ Failed to create DOP wallet');
|
|
171
|
-
}
|
|
172
|
-
dopWalletID = dopWalletInfo.id;
|
|
173
|
-
console.log(`โ
Wallet created successfully!`);
|
|
174
|
-
console.log(`๐ Wallet ID: ${dopWalletID}`);
|
|
175
|
-
console.log(`๐ DOP Address: ${dopWalletInfo.dopAddress}`);
|
|
176
|
-
console.log('');
|
|
177
|
-
// const shareableViewingKey = await getWalletShareableViewingKey(dopWalletID);
|
|
178
|
-
// if (!isDefined(shareableViewingKey)) {
|
|
179
|
-
// throw new Error('โ Failed to get shareable viewing key');
|
|
180
|
-
// }
|
|
181
|
-
// // Current block numbers for each chain when the wallet was first created.
|
|
182
|
-
// // If unknown, set to undefined.
|
|
183
|
-
// const creationBlockNumberMap: Optional<MapType<number>> = undefined;
|
|
184
|
-
// const viewOnlyWalletInfo = await createViewOnlyDopWallet(
|
|
185
|
-
// MOCK_DB_ENCRYPTION_KEY,
|
|
186
|
-
// shareableViewingKey,
|
|
187
|
-
// creationBlockNumberMap,
|
|
188
|
-
// );
|
|
189
|
-
// Setup balance update callback with enhanced logging
|
|
190
|
-
(0, balance_update_1.setOnBalanceUpdateCallback)((balancesEvent) => {
|
|
191
|
-
console.log("================================");
|
|
192
|
-
console.log(`๐ฐ Balance Update Received:`);
|
|
193
|
-
console.log(` - ERC20 tokens: ${balancesEvent.erc20Amounts.length}`);
|
|
194
|
-
console.log(` - NFT tokens: ${balancesEvent.nftAmounts.length}`);
|
|
195
|
-
console.log(` - Wallet: ${balancesEvent.dopWalletID}`);
|
|
196
|
-
console.log(` - Chain: ${balancesEvent.chain.type}:${balancesEvent.chain.id}`);
|
|
197
|
-
console.log(` - TXID Version: ${balancesEvent.txidVersion}`);
|
|
198
|
-
console.log(` - Balance Bucket: ${balancesEvent.balanceBucket}`);
|
|
199
|
-
// Log detailed balance information
|
|
200
|
-
if (balancesEvent.erc20Amounts.length > 0) {
|
|
201
|
-
console.log(` - ERC20 Details:`);
|
|
202
|
-
balancesEvent.erc20Amounts.forEach((erc20, index) => {
|
|
203
|
-
console.log(` ${index + 1}. ${erc20.tokenAddress}: ${erc20.amount.toString()}`);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
if (balancesEvent.nftAmounts.length > 0) {
|
|
207
|
-
console.log(` - NFT Details:`);
|
|
208
|
-
balancesEvent.nftAmounts.forEach((nft, index) => {
|
|
209
|
-
console.log(` ${index + 1}. ${nft.nftAddress}#${nft.tokenSubID}: ${nft.amount.toString()}`);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
balanceUpdatesReceived.push(balancesEvent);
|
|
213
|
-
});
|
|
214
|
-
console.log('๐ Loading provider for mainnet...');
|
|
215
|
-
const providerConfig = getProviderConfig();
|
|
216
|
-
const loadRes = await (0, load_provider_1.loadProvider)(providerConfig, NETWORK_NAME, 30000);
|
|
217
|
-
console.log(`โ
Provider loaded for ${NETWORK_NAME}`);
|
|
218
|
-
console.log(`โ
Provider info: ${providerConfig.providers.map(p => p.provider).join(', ')}`);
|
|
219
|
-
console.log('๐ Starting contract history scan...');
|
|
220
|
-
console.log('โณ Starting scan in background (not waiting for completion)...');
|
|
221
|
-
// Start the scan but don't wait for it to complete in the before hook
|
|
222
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
223
|
-
(0, engine_1.getEngine)().scanContractHistory(chain, [dopWalletID]);
|
|
224
|
-
console.log('โ
Setup completed! Tests will run without waiting for full scan.');
|
|
225
|
-
console.log('โ ๏ธ Note: Balance results may be incomplete if scan is still in progress.');
|
|
226
|
-
console.log('');
|
|
227
|
-
});
|
|
228
|
-
after(async () => {
|
|
229
|
-
console.log('๐งน Cleaning up...');
|
|
230
|
-
await (0, setup_test_1.closeTestEngine)();
|
|
231
|
-
console.log('โ
Cleanup completed');
|
|
232
|
-
});
|
|
233
|
-
it('Should try to fetch balances immediately (without waiting for full scan)', async function run() {
|
|
234
|
-
this.timeout(60000); // 1 minute
|
|
235
|
-
console.log('');
|
|
236
|
-
console.log('๐ QUICK BALANCE CHECK (without full scan)');
|
|
237
|
-
console.log('==========================================');
|
|
238
|
-
console.log('โก This test tries to fetch balances immediately');
|
|
239
|
-
console.log('โก without waiting for the full blockchain scan.');
|
|
240
|
-
console.log('โก Results may be incomplete but useful for testing.');
|
|
241
|
-
console.log('');
|
|
242
|
-
// Optional: Try to wait for scans briefly (but don't fail if timeout)
|
|
243
|
-
console.log('โณ Briefly checking if scans have completed...');
|
|
244
|
-
try {
|
|
245
|
-
await Promise.race([
|
|
246
|
-
Promise.all([
|
|
247
|
-
(0, setup_test_1.pollUntilUTXOMerkletreeScanned)(),
|
|
248
|
-
(0, setup_test_1.pollUntilTXIDMerkletreeScanned)(),
|
|
249
|
-
]),
|
|
250
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Quick scan check timeout')), 30000)) // 30 second timeout
|
|
251
|
-
]);
|
|
252
|
-
console.log('โ
Scans completed! Will get full results.');
|
|
253
|
-
}
|
|
254
|
-
catch (error) {
|
|
255
|
-
console.log('โ ๏ธ Scans still in progress, proceeding anyway...');
|
|
256
|
-
}
|
|
257
|
-
// Get wallet instance
|
|
258
|
-
const wallet = (0, wallets_1.fullWalletForID)(dopWalletID);
|
|
259
|
-
expect(wallet).to.not.be.undefined;
|
|
260
|
-
if (wallet == null) {
|
|
261
|
-
throw new Error('โ Wallet not found');
|
|
262
|
-
}
|
|
263
|
-
console.log('๐ Attempting immediate balance fetch...');
|
|
264
|
-
try {
|
|
265
|
-
// Try to get balances even if scan is not complete
|
|
266
|
-
const quickTokenBalances = await wallet.getTokenBalances(TXID_VERSION, chain, false // onlySpendable = false
|
|
267
|
-
);
|
|
268
|
-
const quickERC20Balances = (0, balance_update_1.getSerializedERC20Balances)(quickTokenBalances);
|
|
269
|
-
const quickNFTBalances = (0, balance_update_1.getSerializedNFTBalances)(quickTokenBalances);
|
|
270
|
-
console.log('โ
Quick balance fetch successful!');
|
|
271
|
-
console.log(`๐ Quick Results:`);
|
|
272
|
-
console.log(` - Token addresses found: ${Object.keys(quickTokenBalances).length}`);
|
|
273
|
-
console.log(` - ERC20 balances: ${quickERC20Balances.length}`);
|
|
274
|
-
console.log(` - NFT balances: ${quickNFTBalances.length}`);
|
|
275
|
-
if (quickERC20Balances.length > 0) {
|
|
276
|
-
console.log('๐ฐ Quick ERC20 Balances:');
|
|
277
|
-
quickERC20Balances.forEach((balance, index) => {
|
|
278
|
-
console.log(` ${index + 1}. ${balance.tokenAddress}: ${balance.amount.toString()}`);
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (quickNFTBalances.length > 0) {
|
|
282
|
-
console.log('๐จ Quick NFT Balances:');
|
|
283
|
-
quickNFTBalances.forEach((nft, index) => {
|
|
284
|
-
console.log(` ${index + 1}. ${nft.nftAddress}#${nft.tokenSubID}: ${nft.amount.toString()}`);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
if (quickERC20Balances.length === 0 && quickNFTBalances.length === 0) {
|
|
288
|
-
console.log('โน๏ธ No immediate balances found');
|
|
289
|
-
console.log(' This could mean:');
|
|
290
|
-
console.log(' โข Blockchain scan is still in progress');
|
|
291
|
-
console.log(' โข No DOP transactions exist for this wallet');
|
|
292
|
-
console.log(' โข Wallet only has regular (non-private) transactions');
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
console.log('โ ๏ธ Quick balance fetch failed:');
|
|
297
|
-
console.log(` ${error instanceof Error ? error.message : String(error)}`);
|
|
298
|
-
console.log(' This is normal if the wallet/scan is not ready yet.');
|
|
299
|
-
}
|
|
300
|
-
console.log('โ
Quick balance check completed!');
|
|
301
|
-
console.log('');
|
|
302
|
-
});
|
|
303
|
-
// it('Should fetch real balances from mainnet', async function run() {
|
|
304
|
-
// this.timeout(60_000); // 1 minute
|
|
305
|
-
// console.log('๐ Fetching your real balances...');
|
|
306
|
-
// // Get wallet instance
|
|
307
|
-
// const wallet = fullWalletForID(dopWalletID);
|
|
308
|
-
// expect(wallet).to.not.be.undefined;
|
|
309
|
-
// if (wallet == null) {
|
|
310
|
-
// throw new Error('โ Wallet not found');
|
|
311
|
-
// }
|
|
312
|
-
// console.log('๐ Getting token balances...');
|
|
313
|
-
// // Get all balances (spendable + pending)
|
|
314
|
-
// const allTokenBalances = await wallet.getTokenBalances(
|
|
315
|
-
// TXID_VERSION,
|
|
316
|
-
// chain,
|
|
317
|
-
// false // onlySpendable = false
|
|
318
|
-
// );
|
|
319
|
-
// // Get only spendable balances
|
|
320
|
-
// const spendableTokenBalances = await wallet.getTokenBalances(
|
|
321
|
-
// TXID_VERSION,
|
|
322
|
-
// chain,
|
|
323
|
-
// true // onlySpendable = true
|
|
324
|
-
// );
|
|
325
|
-
// console.log('๐ Raw Balance Results:');
|
|
326
|
-
// console.log(` - Total token addresses: ${Object.keys(allTokenBalances).length}`);
|
|
327
|
-
// console.log(` - Spendable token addresses: ${Object.keys(spendableTokenBalances).length}`);
|
|
328
|
-
// // Serialize balances for easier viewing
|
|
329
|
-
// const allERC20Balances = getSerializedERC20Balances(allTokenBalances);
|
|
330
|
-
// const allNFTBalances = getSerializedNFTBalances(allTokenBalances);
|
|
331
|
-
// const spendableERC20Balances = getSerializedERC20Balances(spendableTokenBalances);
|
|
332
|
-
// const spendableNFTBalances = getSerializedNFTBalances(spendableTokenBalances);
|
|
333
|
-
// console.log('');
|
|
334
|
-
// console.log('๐ฐ BALANCE SUMMARY:');
|
|
335
|
-
// console.log('===================');
|
|
336
|
-
// console.log(`๐ All ERC20 Balances: ${allERC20Balances.length}`);
|
|
337
|
-
// console.log(`๐ All NFT Balances: ${allNFTBalances.length}`);
|
|
338
|
-
// console.log(`๐ Spendable ERC20 Balances: ${spendableERC20Balances.length}`);
|
|
339
|
-
// console.log(`๐จ Spendable NFT Balances: ${spendableNFTBalances.length}`);
|
|
340
|
-
// console.log('');
|
|
341
|
-
// // Display detailed ERC20 balances
|
|
342
|
-
// if (allERC20Balances.length > 0) {
|
|
343
|
-
// console.log('๐ฐ ERC20 TOKEN BALANCES:');
|
|
344
|
-
// console.log('========================');
|
|
345
|
-
// allERC20Balances.forEach((balance: DopERC20Amount, index: number) => {
|
|
346
|
-
// const isSpendable = spendableERC20Balances.some(sb =>
|
|
347
|
-
// sb.tokenAddress === balance.tokenAddress && sb.amount.toString() === balance.amount.toString()
|
|
348
|
-
// );
|
|
349
|
-
// console.log(`${index + 1}. Token: ${balance.tokenAddress}`);
|
|
350
|
-
// console.log(` Amount: ${balance.amount.toString()}`);
|
|
351
|
-
// console.log(` Status: ${isSpendable ? 'โ
Spendable' : 'โณ Pending'}`);
|
|
352
|
-
// console.log('');
|
|
353
|
-
// });
|
|
354
|
-
// }
|
|
355
|
-
// // Display detailed NFT balances
|
|
356
|
-
// if (allNFTBalances.length > 0) {
|
|
357
|
-
// console.log('๐จ NFT TOKEN BALANCES:');
|
|
358
|
-
// console.log('======================');
|
|
359
|
-
// allNFTBalances.forEach((nft: DopNFTAmount, index: number) => {
|
|
360
|
-
// const isSpendable = spendableNFTBalances.some(sn =>
|
|
361
|
-
// sn.nftAddress === nft.nftAddress &&
|
|
362
|
-
// sn.tokenSubID === nft.tokenSubID &&
|
|
363
|
-
// sn.amount.toString() === nft.amount.toString()
|
|
364
|
-
// );
|
|
365
|
-
// console.log(`${index + 1}. NFT Contract: ${nft.nftAddress}`);
|
|
366
|
-
// console.log(` Token ID: ${nft.tokenSubID}`);
|
|
367
|
-
// console.log(` Amount: ${nft.amount.toString()}`);
|
|
368
|
-
// console.log(` Status: ${isSpendable ? 'โ
Spendable' : 'โณ Pending'}`);
|
|
369
|
-
// console.log('');
|
|
370
|
-
// });
|
|
371
|
-
// }
|
|
372
|
-
// if (allERC20Balances.length === 0 && allNFTBalances.length === 0) {
|
|
373
|
-
// console.log('โน๏ธ No DOP balances found for this wallet.');
|
|
374
|
-
// console.log('');
|
|
375
|
-
// console.log('This could mean:');
|
|
376
|
-
// console.log('โข This wallet has never received DOP transactions');
|
|
377
|
-
// console.log('โข This wallet only has regular (non-private) ETH/tokens');
|
|
378
|
-
// console.log('โข The wallet has been used but all balances have been spent');
|
|
379
|
-
// console.log('');
|
|
380
|
-
// console.log('๐ก To test with balances, you need a wallet that has received');
|
|
381
|
-
// console.log(' DOP (private) transactions, not regular Ethereum transactions.');
|
|
382
|
-
// }
|
|
383
|
-
// // Display balance update summary
|
|
384
|
-
// console.log('๐ก BALANCE UPDATE CALLBACKS:');
|
|
385
|
-
// console.log('============================');
|
|
386
|
-
// console.log(`Total updates received: ${balanceUpdatesReceived.length}`);
|
|
387
|
-
// if (balanceUpdatesReceived.length > 0) {
|
|
388
|
-
// balanceUpdatesReceived.forEach((update, index) => {
|
|
389
|
-
// console.log(`Update ${index + 1}:`);
|
|
390
|
-
// console.log(` - Chain: ${update.chain.type}:${update.chain.id}`);
|
|
391
|
-
// console.log(` - ERC20: ${update.erc20Amounts.length}, NFT: ${update.nftAmounts.length}`);
|
|
392
|
-
// console.log(` - Bucket: ${update.balanceBucket}`);
|
|
393
|
-
// });
|
|
394
|
-
// }
|
|
395
|
-
// // Assertions
|
|
396
|
-
// expect(allTokenBalances).to.be.an('object');
|
|
397
|
-
// expect(spendableTokenBalances).to.be.an('object');
|
|
398
|
-
// expect(allERC20Balances).to.be.an('array');
|
|
399
|
-
// expect(allNFTBalances).to.be.an('array');
|
|
400
|
-
// expect(spendableERC20Balances).to.be.an('array');
|
|
401
|
-
// expect(spendableNFTBalances).to.be.an('array');
|
|
402
|
-
// console.log('โ
Real balance fetching test completed successfully!');
|
|
403
|
-
// console.log('');
|
|
404
|
-
// });
|
|
405
|
-
// it('Should test balance refresh functionality', async function run() {
|
|
406
|
-
// this.timeout(60_000); // 1 minute
|
|
407
|
-
// console.log('๐ Testing balance refresh...');
|
|
408
|
-
// const initialUpdateCount = balanceUpdatesReceived.length;
|
|
409
|
-
// // Test refreshBalances function with patched version for Ethereum mainnet
|
|
410
|
-
// await refreshBalances(chain, [dopWalletID]);
|
|
411
|
-
// // Wait for potential updates
|
|
412
|
-
// await new Promise(resolve => setTimeout(resolve, 10000)); // 10 seconds
|
|
413
|
-
// const finalUpdateCount = balanceUpdatesReceived.length;
|
|
414
|
-
// console.log(`๐ Balance updates: ${initialUpdateCount} โ ${finalUpdateCount}`);
|
|
415
|
-
// expect(finalUpdateCount).to.be.greaterThanOrEqual(initialUpdateCount);
|
|
416
|
-
// console.log('โ
Balance refresh test completed!');
|
|
417
|
-
// });
|
|
418
|
-
});
|
|
419
|
-
//# sourceMappingURL=balances.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"balances.test.js","sourceRoot":"","sources":["../../src/tests/balances.test.ts"],"names":[],"mappings":";;;;;AAAA,6DAA6D;AAC7D,gDAAwB;AACxB,6DAA6D;AAC7D,wEAA8C;AAC9C,6CAEsB;AACtB,6CAKsB;AACtB,6DAAwL;AAKxL,2EAIgD;AAChD,6DAU6B;AAC7B,sEAAkE;AAClE,wDAAwD;AAExD,cAAI,CAAC,GAAG,CAAC,0BAAc,CAA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8C;IAC9C,sDAAsD;IACtD,oDAAoD;IAEpD,yEAAyE;IACzE,qBAAqB;IACrB,MAAM;IAEN,yEAAyE;IACzE,sCAAsC;IAEtC,kDAAkD;IAElD,8DAA8D;IAE9D,+EAA+E;IAC/E,iDAAiD;IAEjD,kCAAkC;IAClC,4EAA4E;IAE5E,4DAA4D;IAC5D,oFAAoF;IAEpF,2EAA2E;IAC3E,sDAAsD;IACtD,MAAM;AACR,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport chai from 'chai';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport chaiAsPromised from 'chai-as-promised';\nimport {\n MOCK_DB_ENCRYPTION_KEY,\n} from './mocks.test';\nimport {\n closeTestEngine,\n initTestEngine,\n pollUntilTXIDMerkletreeScanned,\n pollUntilUTXOMerkletreeScanned,\n} from './setup.test';\nimport { createDopWallet, createDopWalletSafe, fullWalletForID, createOrImportDopWallet, createViewOnlyDopWallet, getWalletShareableViewingKey } from '../services/dop/wallets/wallets';\nimport { \n refreshBalances, \n rescanFullUTXOMerkletreesAndWallets \n} from '../services/dop/wallets/balances';\nimport { \n getSerializedERC20Balances, \n getSerializedNFTBalances,\n setOnBalanceUpdateCallback \n} from '../services/dop/wallets/balance-update';\nimport {\n Chain,\n NETWORK_CONFIG,\n NetworkName,\n isDefined,\n TXIDVersion,\n DopBalancesEvent,\n DopERC20Amount,\n DopNFTAmount,\n FallbackProviderJsonConfig,\n} from 'dop-sharedmodels-v3';\nimport { loadProvider } from '../services/dop/core/load-provider';\nimport { getEngine } from '../services/dop/core/engine';\n\nchai.use(chaiAsPromised);\nconst { expect } = chai;\n\n// ==========================================\n// CONFIGURATION - MODIFY THESE VALUES\n// ==========================================\n\n// PUT YOUR REAL MNEMONIC HERE\nconst YOUR_MNEMONIC = \"rough shadow recall crane injury grass valid guilt close latin seed eight\";\n\n// CHOOSE YOUR NETWORK (uncomment one)\n// const NETWORK_NAME: NetworkName = NetworkName.Ethereum; // Ethereum Mainnet\nconst NETWORK_NAME: NetworkName = NetworkName.Polygon; // Polygon Mainnet\n// const NETWORK_NAME: NetworkName = NetworkName.Arbitrum; // Arbitrum Mainnet\n\n// CHOOSE TXID VERSION (V3 is recommended)\n// const TXID_VERSION = TXIDVersion.V3_PoseidonMerkle;\nconst TXID_VERSION = TXIDVersion.V2_PoseidonMerkle;\n\n// SCAN TIMEOUT SETTINGS\n// const MAINNET_SCAN_TIMEOUT_MINUTES = 30; // 30 minutes for mainnet scan\nconst SKIP_SCAN_ON_TIMEOUT = true; // If true, continue with balance fetching even if scan times out\n\n// ==========================================\n// CUSTOM RPC PROVIDER CONFIGURATION\n// ==========================================\n// The test now uses public RPC endpoints by default, but you can customize them below.\n// \n// TO USE YOUR OWN PROVIDERS:\n// 1. Uncomment the custom provider lines in the getProviderConfig() function\n// 2. Replace 'YOUR_*_RPC_URL_HERE' with your actual RPC endpoints\n// 3. Set higher priority (lower number) for your custom providers\n//\n// Where to get RPC URLs:\n// - Infura: https://infura.io/ (format: 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID')\n// - Alchemy: https://alchemy.com/ (format: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY')\n// - QuickNode: https://quicknode.com/ (format: 'https://YOUR_ENDPOINT.quiknode.pro/YOUR_API_KEY/')\n// - Moralis: https://moralis.io/\n// - GetBlock: https://getblock.io/\n// - Your own node\n// ==========================================\n\n// ==========================================\n// PROVIDER CONFIGURATION \n// ==========================================\n\nconst getProviderConfig = (): FallbackProviderJsonConfig => {\n // CUSTOM PROVIDER CONFIGURATION\n // Replace the RPC URLs below with your own provider endpoints\n // Example formats:\n // - Infura: 'https://mainnet.infura.io/v3/YOUR_PROJECT_ID'\n // - Alchemy: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY'\n // - QuickNode: 'https://YOUR_ENDPOINT.quiknode.pro/YOUR_API_KEY/'\n \n // if (NETWORK_NAME === NetworkName.Ethereum) {\n // return {\n // chainId: 1,\n // providers: [\n // // {\n // // provider: 'https://eth.llamarpc.com',\n // // priority: 1,\n // // weight: 2,\n // // },\n // {\n // provider: 'https://ethereum.publicnode.com',\n // priority: 1,\n // weight: 2,\n // },\n // // {\n // // provider: 'https://rpc.ankr.com/eth',\n // // priority: 3,\n // // weight: 1,\n // // },\n // // Add your custom providers here:\n // // {\n // // provider: 'YOUR_ETHEREUM_RPC_URL_HERE',\n // // priority: 1,\n // // weight: 3,\n // // },\n // ],\n // };\n // }\n\n if (NETWORK_NAME === NetworkName.Polygon) {\n return {\n chainId: 137,\n providers: [\n // {\n // provider: 'https://polygon.llamarpc.com',\n // priority: 1,\n // weight: 2,\n // },\n {\n provider: 'https://polygon.publicnode.com',\n priority: 2,\n weight: 2,\n },\n // {\n // provider: 'https://rpc.ankr.com/polygon',\n // priority: 3,\n // weight: 1,\n // },\n // Add your custom providers here:\n // {\n // provider: 'YOUR_POLYGON_RPC_URL_HERE',\n // priority: 1,\n // weight: 3,\n // },\n ],\n };\n }\n\n // if (NETWORK_NAME === NetworkName.Arbitrum) {\n // return {\n // chainId: 42161,\n // providers: [\n // {\n // provider: 'https://arbitrum.publicnode.com',\n // priority: 1,\n // weight: 2,\n // },\n // {\n // provider: 'https://rpc.ankr.com/arbitrum',\n // priority: 2,\n // weight: 2,\n // },\n // {\n // provider: 'https://arbitrum.llamarpc.com',\n // priority: 3,\n // weight: 1,\n // },\n // // Add your custom providers here:\n // // {\n // // provider: 'YOUR_ARBITRUM_RPC_URL_HERE',\n // // priority: 1,\n // // weight: 3,\n // // },\n // ],\n // };\n // }\n\n // Default fallback for any other network\n throw new Error(\n `No provider configuration available for network: ${String(NETWORK_NAME)}. ` +\n `Please add your custom provider configuration in the getProviderConfig() function.`\n );\n};\n\n// ==========================================\n// TEST IMPLEMENTATION\n// ==========================================\n\nlet dopWalletID: string;\nconst balanceUpdatesReceived: DopBalancesEvent[] = [];\nconst chain: Chain = NETWORK_CONFIG[NETWORK_NAME].chain;\n\ndescribe('Real Balance Fetching Test', () => {\n before(async function run() {\n this.timeout(60_000); // 1 minute for setup\n \n console.log('๐ Starting Real Balance Test');\n console.log(`๐ก Network: ${NETWORK_NAME}`);\n console.log(`โ๏ธ Chain ID: ${chain.id}`);\n console.log(`๐ง TXID Version: ${TXID_VERSION}`);\n console.log(`โญ๏ธ Skip on timeout: ${SKIP_SCAN_ON_TIMEOUT ? 'Yes' : 'No'}`);\n console.log('');\n\n console.log('๐ง Initializing test engine...');\n await initTestEngine();\n \n console.log('๐ Creating DOP wallet from your mnemonic...');\n const dopWalletInfo = await createDopWallet(\n MOCK_DB_ENCRYPTION_KEY,\n YOUR_MNEMONIC,\n undefined, // creationBlockNumbers\n );\n \n if (!isDefined(dopWalletInfo)) {\n throw new Error('โ Failed to create DOP wallet');\n }\n \n dopWalletID = dopWalletInfo.id;\n console.log(`โ
Wallet created successfully!`);\n console.log(`๐ Wallet ID: ${dopWalletID}`);\n console.log(`๐ DOP Address: ${dopWalletInfo.dopAddress}`);\n console.log('');\n\n // const shareableViewingKey = await getWalletShareableViewingKey(dopWalletID);\n // if (!isDefined(shareableViewingKey)) {\n // throw new Error('โ Failed to get shareable viewing key');\n // }\n // // Current block numbers for each chain when the wallet was first created.\n // // If unknown, set to undefined.\n // const creationBlockNumberMap: Optional<MapType<number>> = undefined;\n // const viewOnlyWalletInfo = await createViewOnlyDopWallet(\n // MOCK_DB_ENCRYPTION_KEY,\n // shareableViewingKey,\n // creationBlockNumberMap,\n // );\n\n // Setup balance update callback with enhanced logging\n setOnBalanceUpdateCallback((balancesEvent: DopBalancesEvent) => {\n console.log(\"================================\");\n console.log(`๐ฐ Balance Update Received:`);\n console.log(` - ERC20 tokens: ${balancesEvent.erc20Amounts.length}`);\n console.log(` - NFT tokens: ${balancesEvent.nftAmounts.length}`);\n console.log(` - Wallet: ${balancesEvent.dopWalletID}`);\n console.log(` - Chain: ${balancesEvent.chain.type}:${balancesEvent.chain.id}`);\n console.log(` - TXID Version: ${balancesEvent.txidVersion}`);\n console.log(` - Balance Bucket: ${balancesEvent.balanceBucket}`);\n \n // Log detailed balance information\n if (balancesEvent.erc20Amounts.length > 0) {\n console.log(` - ERC20 Details:`);\n balancesEvent.erc20Amounts.forEach((erc20, index) => {\n console.log(` ${index + 1}. ${erc20.tokenAddress}: ${erc20.amount.toString()}`);\n });\n }\n \n if (balancesEvent.nftAmounts.length > 0) {\n console.log(` - NFT Details:`);\n balancesEvent.nftAmounts.forEach((nft, index) => {\n console.log(` ${index + 1}. ${nft.nftAddress}#${nft.tokenSubID}: ${nft.amount.toString()}`);\n });\n }\n \n balanceUpdatesReceived.push(balancesEvent);\n });\n\n console.log('๐ Loading provider for mainnet...');\n const providerConfig = getProviderConfig();\n const loadRes = await loadProvider(\n providerConfig,\n NETWORK_NAME,\n 30_000, // 30 second polling interval for mainnet\n );\n console.log(`โ
Provider loaded for ${NETWORK_NAME}`);\n console.log(`โ
Provider info: ${providerConfig.providers.map(p => p.provider).join(', ')}`);\n\n console.log('๐ Starting contract history scan...');\n console.log('โณ Starting scan in background (not waiting for completion)...');\n \n \n // Start the scan but don't wait for it to complete in the before hook\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n getEngine().scanContractHistory(\n chain,\n [dopWalletID], // walletIdFilter - scan for all wallets\n );\n \n console.log('โ
Setup completed! Tests will run without waiting for full scan.');\n console.log('โ ๏ธ Note: Balance results may be incomplete if scan is still in progress.');\n console.log('');\n \n });\n\n after(async () => {\n console.log('๐งน Cleaning up...');\n await closeTestEngine();\n console.log('โ
Cleanup completed');\n });\n\n it('Should try to fetch balances immediately (without waiting for full scan)', async function run() {\n this.timeout(60_000); // 1 minute\n \n console.log('');\n console.log('๐ QUICK BALANCE CHECK (without full scan)');\n console.log('==========================================');\n console.log('โก This test tries to fetch balances immediately');\n console.log('โก without waiting for the full blockchain scan.');\n console.log('โก Results may be incomplete but useful for testing.');\n console.log('');\n\n // Optional: Try to wait for scans briefly (but don't fail if timeout)\n console.log('โณ Briefly checking if scans have completed...');\n try {\n await Promise.race([\n Promise.all([\n pollUntilUTXOMerkletreeScanned(),\n pollUntilTXIDMerkletreeScanned(),\n ]),\n new Promise((_, reject) => setTimeout(() => reject(new Error('Quick scan check timeout')), 30_000)) // 30 second timeout\n ]);\n console.log('โ
Scans completed! Will get full results.');\n } catch (error) {\n console.log('โ ๏ธ Scans still in progress, proceeding anyway...');\n }\n \n // Get wallet instance\n const wallet = fullWalletForID(dopWalletID);\n expect(wallet).to.not.be.undefined;\n if (wallet == null) {\n throw new Error('โ Wallet not found');\n }\n\n console.log('๐ Attempting immediate balance fetch...');\n \n try {\n // Try to get balances even if scan is not complete\n const quickTokenBalances = await wallet.getTokenBalances(\n TXID_VERSION,\n chain,\n false // onlySpendable = false\n );\n \n const quickERC20Balances = getSerializedERC20Balances(quickTokenBalances);\n const quickNFTBalances = getSerializedNFTBalances(quickTokenBalances);\n\n console.log('โ
Quick balance fetch successful!');\n console.log(`๐ Quick Results:`);\n console.log(` - Token addresses found: ${Object.keys(quickTokenBalances).length}`);\n console.log(` - ERC20 balances: ${quickERC20Balances.length}`);\n console.log(` - NFT balances: ${quickNFTBalances.length}`);\n \n if (quickERC20Balances.length > 0) {\n console.log('๐ฐ Quick ERC20 Balances:');\n quickERC20Balances.forEach((balance: DopERC20Amount, index: number) => {\n console.log(` ${index + 1}. ${balance.tokenAddress}: ${balance.amount.toString()}`);\n });\n }\n \n if (quickNFTBalances.length > 0) {\n console.log('๐จ Quick NFT Balances:');\n quickNFTBalances.forEach((nft: DopNFTAmount, index: number) => {\n console.log(` ${index + 1}. ${nft.nftAddress}#${nft.tokenSubID}: ${nft.amount.toString()}`);\n });\n }\n \n if (quickERC20Balances.length === 0 && quickNFTBalances.length === 0) {\n console.log('โน๏ธ No immediate balances found');\n console.log(' This could mean:');\n console.log(' โข Blockchain scan is still in progress');\n console.log(' โข No DOP transactions exist for this wallet');\n console.log(' โข Wallet only has regular (non-private) transactions');\n }\n \n } catch (error) {\n console.log('โ ๏ธ Quick balance fetch failed:');\n console.log(` ${error instanceof Error ? error.message : String(error)}`);\n console.log(' This is normal if the wallet/scan is not ready yet.');\n }\n \n console.log('โ
Quick balance check completed!');\n console.log('');\n });\n\n // it('Should fetch real balances from mainnet', async function run() {\n // this.timeout(60_000); // 1 minute\n \n // console.log('๐ Fetching your real balances...');\n \n // // Get wallet instance\n // const wallet = fullWalletForID(dopWalletID);\n // expect(wallet).to.not.be.undefined;\n \n // if (wallet == null) {\n // throw new Error('โ Wallet not found');\n // }\n\n // console.log('๐ Getting token balances...');\n \n // // Get all balances (spendable + pending)\n // const allTokenBalances = await wallet.getTokenBalances(\n // TXID_VERSION,\n // chain,\n // false // onlySpendable = false\n // );\n \n // // Get only spendable balances\n // const spendableTokenBalances = await wallet.getTokenBalances(\n // TXID_VERSION,\n // chain,\n // true // onlySpendable = true\n // );\n\n // console.log('๐ Raw Balance Results:');\n // console.log(` - Total token addresses: ${Object.keys(allTokenBalances).length}`);\n // console.log(` - Spendable token addresses: ${Object.keys(spendableTokenBalances).length}`);\n \n // // Serialize balances for easier viewing\n // const allERC20Balances = getSerializedERC20Balances(allTokenBalances);\n // const allNFTBalances = getSerializedNFTBalances(allTokenBalances);\n // const spendableERC20Balances = getSerializedERC20Balances(spendableTokenBalances);\n // const spendableNFTBalances = getSerializedNFTBalances(spendableTokenBalances);\n\n // console.log('');\n // console.log('๐ฐ BALANCE SUMMARY:');\n // console.log('===================');\n // console.log(`๐ All ERC20 Balances: ${allERC20Balances.length}`);\n // console.log(`๐ All NFT Balances: ${allNFTBalances.length}`);\n // console.log(`๐ Spendable ERC20 Balances: ${spendableERC20Balances.length}`);\n // console.log(`๐จ Spendable NFT Balances: ${spendableNFTBalances.length}`);\n // console.log('');\n\n // // Display detailed ERC20 balances\n // if (allERC20Balances.length > 0) {\n // console.log('๐ฐ ERC20 TOKEN BALANCES:');\n // console.log('========================');\n // allERC20Balances.forEach((balance: DopERC20Amount, index: number) => {\n // const isSpendable = spendableERC20Balances.some(sb => \n // sb.tokenAddress === balance.tokenAddress && sb.amount.toString() === balance.amount.toString()\n // );\n // console.log(`${index + 1}. Token: ${balance.tokenAddress}`);\n // console.log(` Amount: ${balance.amount.toString()}`);\n // console.log(` Status: ${isSpendable ? 'โ
Spendable' : 'โณ Pending'}`);\n // console.log('');\n // });\n // }\n\n // // Display detailed NFT balances\n // if (allNFTBalances.length > 0) {\n // console.log('๐จ NFT TOKEN BALANCES:');\n // console.log('======================');\n // allNFTBalances.forEach((nft: DopNFTAmount, index: number) => {\n // const isSpendable = spendableNFTBalances.some(sn => \n // sn.nftAddress === nft.nftAddress && \n // sn.tokenSubID === nft.tokenSubID &&\n // sn.amount.toString() === nft.amount.toString()\n // );\n // console.log(`${index + 1}. NFT Contract: ${nft.nftAddress}`);\n // console.log(` Token ID: ${nft.tokenSubID}`);\n // console.log(` Amount: ${nft.amount.toString()}`);\n // console.log(` Status: ${isSpendable ? 'โ
Spendable' : 'โณ Pending'}`);\n // console.log('');\n // });\n // }\n\n // if (allERC20Balances.length === 0 && allNFTBalances.length === 0) {\n // console.log('โน๏ธ No DOP balances found for this wallet.');\n // console.log('');\n // console.log('This could mean:');\n // console.log('โข This wallet has never received DOP transactions');\n // console.log('โข This wallet only has regular (non-private) ETH/tokens');\n // console.log('โข The wallet has been used but all balances have been spent');\n // console.log('');\n // console.log('๐ก To test with balances, you need a wallet that has received');\n // console.log(' DOP (private) transactions, not regular Ethereum transactions.');\n // }\n\n // // Display balance update summary\n // console.log('๐ก BALANCE UPDATE CALLBACKS:');\n // console.log('============================');\n // console.log(`Total updates received: ${balanceUpdatesReceived.length}`);\n \n // if (balanceUpdatesReceived.length > 0) {\n // balanceUpdatesReceived.forEach((update, index) => {\n // console.log(`Update ${index + 1}:`);\n // console.log(` - Chain: ${update.chain.type}:${update.chain.id}`);\n // console.log(` - ERC20: ${update.erc20Amounts.length}, NFT: ${update.nftAmounts.length}`);\n // console.log(` - Bucket: ${update.balanceBucket}`);\n // });\n // }\n\n // // Assertions\n // expect(allTokenBalances).to.be.an('object');\n // expect(spendableTokenBalances).to.be.an('object');\n // expect(allERC20Balances).to.be.an('array');\n // expect(allNFTBalances).to.be.an('array');\n // expect(spendableERC20Balances).to.be.an('array');\n // expect(spendableNFTBalances).to.be.an('array');\n\n // console.log('โ
Real balance fetching test completed successfully!');\n // console.log('');\n // });\n\n // it('Should test balance refresh functionality', async function run() {\n // this.timeout(60_000); // 1 minute\n \n // console.log('๐ Testing balance refresh...');\n \n // const initialUpdateCount = balanceUpdatesReceived.length;\n \n // // Test refreshBalances function with patched version for Ethereum mainnet\n // await refreshBalances(chain, [dopWalletID]);\n \n // // Wait for potential updates\n // await new Promise(resolve => setTimeout(resolve, 10000)); // 10 seconds\n \n // const finalUpdateCount = balanceUpdatesReceived.length;\n // console.log(`๐ Balance updates: ${initialUpdateCount} โ ${finalUpdateCount}`);\n \n // expect(finalUpdateCount).to.be.greaterThanOrEqual(initialUpdateCount);\n // console.log('โ
Balance refresh test completed!');\n // });\n});\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTestTXIDVersion = exports.isV2Test = void 0;
|
|
4
|
-
const dop_engine_v3_1 = require("dop-engine-v3");
|
|
5
|
-
const isV2Test = () => {
|
|
6
|
-
return process.env.V2_TEST === '1';
|
|
7
|
-
};
|
|
8
|
-
exports.isV2Test = isV2Test;
|
|
9
|
-
const getTestTXIDVersion = () => {
|
|
10
|
-
if ((0, exports.isV2Test)()) {
|
|
11
|
-
return dop_engine_v3_1.TXIDVersion.V2_PoseidonMerkle;
|
|
12
|
-
}
|
|
13
|
-
return dop_engine_v3_1.TXIDVersion.V3_PoseidonMerkle;
|
|
14
|
-
};
|
|
15
|
-
exports.getTestTXIDVersion = getTestTXIDVersion;
|
|
16
|
-
//# sourceMappingURL=helper.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.test.js","sourceRoot":"","sources":["../../src/tests/helper.test.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAErC,MAAM,QAAQ,GAAG,GAAY,EAAE;IACpC,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB;AAEK,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,IAAI,IAAA,gBAAQ,GAAE,EAAE;QACd,OAAO,2BAAW,CAAC,iBAAiB,CAAC;KACtC;IACD,OAAO,2BAAW,CAAC,iBAAiB,CAAC;AACvC,CAAC,CAAC;AALW,QAAA,kBAAkB,sBAK7B","sourcesContent":["import { TXIDVersion } from 'dop-engine-v3';\n\nexport const isV2Test = (): boolean => {\n return process.env.V2_TEST === '1';\n};\n\nexport const getTestTXIDVersion = () => {\n if (isV2Test()) {\n return TXIDVersion.V2_PoseidonMerkle;\n }\n return TXIDVersion.V3_PoseidonMerkle;\n};\n"]}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { FallbackProviderJsonConfig, FeeTokenDetails, DopERC20Amount, DopNFTAmountRecipient, DopNFTAmount, TransactionGasDetails, DopERC20Recipient } from 'dop-sharedmodels-v3';
|
|
2
|
-
import { BalancesUpdatedCallback } from '../services/dop/wallets/balance-update';
|
|
3
|
-
import { CommitmentCiphertextV2, CommitmentCiphertextV3 } from 'dop-engine-v3';
|
|
4
|
-
export declare const MOCK_MNEMONIC = "test test test test test test test test test test test junk";
|
|
5
|
-
export declare const MOCK_MNEMONIC_2 = "pause crystal tornado alcohol genre cement fade large song like bag where";
|
|
6
|
-
export declare const MOCK_DB_ENCRYPTION_KEY = "0101010101010101010101010101010101010101010101010101010101010101";
|
|
7
|
-
export declare const MOCK_MEMO = "A nice little mock memo, and how bout a little more for ya? \uD83E\uDD29";
|
|
8
|
-
export declare const MOCK_DOP_WALLET_ADDRESS = "0zk1q8hxknrs97q8pjxaagwthzc0df99rzmhl2xnlxmgv9akv32sua0kfrv7j6fe3z53llhxknrs97q8pjxaagwthzc0df99rzmhl2xnlxmgv9akv32sua0kg0zpzts";
|
|
9
|
-
export declare const MOCK_ETH_WALLET_ADDRESS = "0x9E9F988356f46744Ee0374A17a5Fa1a3A3cC3777";
|
|
10
|
-
export declare const MOCK_TOKEN_ADDRESS = "0x5FbDB2315678afecb367f032d93F642f64180aa3";
|
|
11
|
-
export declare const MOCK_TOKEN_ADDRESS_2 = "0xe76C6c83af64e4C60245D8C7dE953DF673a7A33D";
|
|
12
|
-
export declare const MOCK_NFT_ADDRESS = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d";
|
|
13
|
-
export declare const TEST_POLYGON_RPC = "https://polygon-rpc.com";
|
|
14
|
-
export declare const TEST_WALLET_SOURCE = "test engine";
|
|
15
|
-
export declare const MOCK_TOKEN_AMOUNTS_TOKEN_1_ONLY: DopERC20Amount[];
|
|
16
|
-
export declare const MOCK_TOKEN_AMOUNTS: DopERC20Amount[];
|
|
17
|
-
export declare const MOCK_ERC20_RECIPIENTS: DopERC20Recipient[];
|
|
18
|
-
export declare const MOCK_NFT_AMOUNTS: DopNFTAmount[];
|
|
19
|
-
export declare const MOCK_COMMITMENTS: string[];
|
|
20
|
-
export declare const MOCK_NULLIFIERS: string[];
|
|
21
|
-
export declare const MOCK_BOUND_PARAMS_V2: {
|
|
22
|
-
commitmentCiphertext: {
|
|
23
|
-
ciphertext: string[];
|
|
24
|
-
blindedSenderViewingKey: string;
|
|
25
|
-
blindedReceiverViewingKey: string;
|
|
26
|
-
memo: string;
|
|
27
|
-
annotationData: string;
|
|
28
|
-
}[];
|
|
29
|
-
};
|
|
30
|
-
export declare const MOCK_BOUND_PARAMS_V3: {
|
|
31
|
-
local: {
|
|
32
|
-
commitmentCiphertext: {
|
|
33
|
-
ciphertext: string;
|
|
34
|
-
blindedSenderViewingKey: string;
|
|
35
|
-
blindedReceiverViewingKey: string;
|
|
36
|
-
}[];
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export declare const MOCK_COMMITMENT_HASH = "0x2b13bccd4974c797df42a89221ed6e19e50c32055058cdcc5a8ea836233e4cab";
|
|
40
|
-
export declare const MOCK_FORMATTED_BROADCASTER_FEE_COMMITMENT_CIPHERTEXT_V2: CommitmentCiphertextV2;
|
|
41
|
-
export declare const MOCK_FORMATTED_BROADCASTER_FEE_COMMITMENT_CIPHERTEXT_V3: CommitmentCiphertextV3;
|
|
42
|
-
export declare const MOCK_NFT_AMOUNT_RECIPIENTS: DopNFTAmountRecipient[];
|
|
43
|
-
export declare const MOCK_NFT_AMOUNT_RECIPIENTS_DECRYPT: DopNFTAmountRecipient[];
|
|
44
|
-
export declare const MOCK_TOKEN_FEE: DopERC20Amount;
|
|
45
|
-
export declare const MOCK_FEE_TOKEN_DETAILS: FeeTokenDetails;
|
|
46
|
-
export declare const MOCK_TRANSACTION_GAS_DETAILS_SERIALIZED_TYPE_2: TransactionGasDetails;
|
|
47
|
-
export declare const MOCK_BALANCES_UPDATE_CALLBACK: BalancesUpdatedCallback;
|
|
48
|
-
export declare const MOCK_FALLBACK_PROVIDER_JSON_CONFIG_POLYGON: FallbackProviderJsonConfig;
|
|
49
|
-
export declare const MOCK_FALLBACK_PROVIDER_JSON_CONFIG_SEPOLIA: FallbackProviderJsonConfig;
|
|
50
|
-
export declare const MOCK_FALLBACK_PROVIDER_JSON_CONFIG_ETHEREUM: FallbackProviderJsonConfig;
|