bstest001 0.0.8 → 0.0.9
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/dist/deposit.js +4 -3
- package/dist/utils/utils.js +2 -1
- package/dist/withdraw.js +3 -1
- package/package.json +1 -1
- package/src/deposit.ts +5 -4
- package/src/utils/utils.ts +2 -2
- package/src/withdraw.ts +3 -1
package/dist/deposit.js
CHANGED
|
@@ -30,6 +30,7 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
30
30
|
throw new Error(`Deposit amount ${depositAmountInput} ETH exceeds pool limit of ${ethers.utils.formatEther(maxDeposit)} ETH`);
|
|
31
31
|
}
|
|
32
32
|
// post address to /screen_address of indexer to check if it's blacklisted
|
|
33
|
+
logger.info('screening walleting');
|
|
33
34
|
logger.debug(`screening address ${address}`);
|
|
34
35
|
let res = await fetch(INDEXER_URL + '/screen_address', {
|
|
35
36
|
method: 'POST',
|
|
@@ -69,14 +70,13 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
69
70
|
const outputAmount = inputSum.add(depositAmount);
|
|
70
71
|
const outputUtxo = new Utxo({ amount: outputAmount, keypair });
|
|
71
72
|
logger.debug(`Depositing ${depositAmountInput} ETH (new output: ${ethers.utils.formatEther(outputAmount)} ETH)`);
|
|
73
|
+
logger.info('generating ZK proof');
|
|
72
74
|
const { args, extData } = await prepareTransaction({
|
|
73
75
|
inputs,
|
|
74
76
|
outputs: [outputUtxo],
|
|
75
77
|
encryptionKey,
|
|
76
78
|
keyBasePath,
|
|
77
79
|
});
|
|
78
|
-
// Build the transaction (Populate)
|
|
79
|
-
logger.info('Building transaction...');
|
|
80
80
|
const partialTx = await etherPool.populateTransaction.transact(args, extData, {
|
|
81
81
|
value: depositAmount,
|
|
82
82
|
gasLimit: 3000000,
|
|
@@ -98,8 +98,9 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
98
98
|
throw new Error('Failed to fetch network fee data for transaction signing');
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
|
+
logger.info('waiting for user signature');
|
|
101
102
|
let tx = await txSender(unsignedTx);
|
|
102
|
-
logger.info(`
|
|
103
|
+
logger.info(`confirming transaction`);
|
|
103
104
|
logger.debug('veryfying transaction on indexer...', extData.encryptedOutput1);
|
|
104
105
|
let retryTimes = 0;
|
|
105
106
|
let itv = 2;
|
package/dist/utils/utils.js
CHANGED
|
@@ -190,7 +190,8 @@ export async function findUnspentUtxos({ address, etherPool, encryptionKey, keyp
|
|
|
190
190
|
throw new Error(`Failed to fetch encrypted UTXOs: ${res.statusText}`);
|
|
191
191
|
}
|
|
192
192
|
const data = await res.json();
|
|
193
|
-
const { encrypted_outputs, hasMore: more, start: realStart } = data;
|
|
193
|
+
const { encrypted_outputs, hasMore: more, start: realStart, total } = data;
|
|
194
|
+
logger.info(`decrypting utxo ${startIndex}/${total}`);
|
|
194
195
|
if (encrypted_outputs && encrypted_outputs.length > 0) {
|
|
195
196
|
encrypted_outputs.forEach((encryptedOutput, i) => {
|
|
196
197
|
const index = (realStart ?? startIndex) + i;
|
package/dist/withdraw.js
CHANGED
|
@@ -64,6 +64,7 @@ export async function withdraw({ provider: rawProvider, withdrawAmountInput, rec
|
|
|
64
64
|
logger.debug(`Change UTXO: ${ethers.utils.formatEther(changeAmount)} ETH`);
|
|
65
65
|
}
|
|
66
66
|
logger.debug(`\nWithdrawing ${realAriveAmount} ETH to ${recipient}...`);
|
|
67
|
+
logger.info('generating ZK proof');
|
|
67
68
|
const { args, extData } = await prepareTransaction({
|
|
68
69
|
inputs,
|
|
69
70
|
outputs,
|
|
@@ -73,7 +74,7 @@ export async function withdraw({ provider: rawProvider, withdrawAmountInput, rec
|
|
|
73
74
|
encryptionKey,
|
|
74
75
|
keyBasePath,
|
|
75
76
|
});
|
|
76
|
-
logger.info(
|
|
77
|
+
logger.info(`submitting transaction to relayer`);
|
|
77
78
|
const response = await fetch(`${INDEXER_URL}/relayer/withdraw`, {
|
|
78
79
|
method: 'POST',
|
|
79
80
|
headers: {
|
|
@@ -95,6 +96,7 @@ export async function withdraw({ provider: rawProvider, withdrawAmountInput, rec
|
|
|
95
96
|
if (changeAmount.gt(0)) {
|
|
96
97
|
logger.debug(`\nChange UTXO created (${ethers.utils.formatEther(changeAmount)} ETH)`);
|
|
97
98
|
}
|
|
99
|
+
logger.info('confirming transaction');
|
|
98
100
|
let retryTimes = 0;
|
|
99
101
|
let itv = 2;
|
|
100
102
|
// const encryptedOutputStr = Buffer.from(extData.encryptedOutput1).toString('hex')
|
package/package.json
CHANGED
package/src/deposit.ts
CHANGED
|
@@ -46,6 +46,7 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// post address to /screen_address of indexer to check if it's blacklisted
|
|
49
|
+
logger.info('screening walleting')
|
|
49
50
|
logger.debug(`screening address ${address}`)
|
|
50
51
|
let res = await fetch(INDEXER_URL + '/screen_address', {
|
|
51
52
|
method: 'POST',
|
|
@@ -89,6 +90,8 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
89
90
|
|
|
90
91
|
logger.debug(`Depositing ${depositAmountInput} ETH (new output: ${ethers.utils.formatEther(outputAmount)} ETH)`);
|
|
91
92
|
|
|
93
|
+
logger.info('generating ZK proof')
|
|
94
|
+
|
|
92
95
|
const { args, extData } = await prepareTransaction({
|
|
93
96
|
inputs,
|
|
94
97
|
outputs: [outputUtxo],
|
|
@@ -96,9 +99,6 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
96
99
|
keyBasePath,
|
|
97
100
|
});
|
|
98
101
|
|
|
99
|
-
// Build the transaction (Populate)
|
|
100
|
-
logger.info('Building transaction...');
|
|
101
|
-
|
|
102
102
|
const partialTx = await etherPool.populateTransaction.transact(args, extData, {
|
|
103
103
|
value: depositAmount,
|
|
104
104
|
gasLimit: 3000000,
|
|
@@ -120,8 +120,9 @@ export async function deposit({ depositAmountInput, keyBasePath, signature, addr
|
|
|
120
120
|
throw new Error('Failed to fetch network fee data for transaction signing');
|
|
121
121
|
}
|
|
122
122
|
try {
|
|
123
|
+
logger.info('waiting for user signature')
|
|
123
124
|
let tx = await txSender(unsignedTx)
|
|
124
|
-
logger.info(`
|
|
125
|
+
logger.info(`confirming transaction`);
|
|
125
126
|
logger.debug('veryfying transaction on indexer...', extData.encryptedOutput1)
|
|
126
127
|
let retryTimes = 0
|
|
127
128
|
let itv = 2
|
package/src/utils/utils.ts
CHANGED
|
@@ -283,8 +283,8 @@ export async function findUnspentUtxos({
|
|
|
283
283
|
throw new Error(`Failed to fetch encrypted UTXOs: ${res.statusText}`);
|
|
284
284
|
}
|
|
285
285
|
const data = await res.json();
|
|
286
|
-
const { encrypted_outputs, hasMore: more, start: realStart } = data;
|
|
287
|
-
|
|
286
|
+
const { encrypted_outputs, hasMore: more, start: realStart, total } = data;
|
|
287
|
+
logger.info(`decrypting utxo ${startIndex}/${total}`)
|
|
288
288
|
if (encrypted_outputs && encrypted_outputs.length > 0) {
|
|
289
289
|
encrypted_outputs.forEach((encryptedOutput: string, i: number) => {
|
|
290
290
|
const index = (realStart ?? startIndex) + i;
|
package/src/withdraw.ts
CHANGED
|
@@ -88,6 +88,7 @@ export async function withdraw({ provider: rawProvider, withdrawAmountInput, rec
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
logger.debug(`\nWithdrawing ${realAriveAmount} ETH to ${recipient}...`);
|
|
91
|
+
logger.info('generating ZK proof')
|
|
91
92
|
|
|
92
93
|
const { args, extData } = await prepareTransaction({
|
|
93
94
|
inputs,
|
|
@@ -99,7 +100,7 @@ export async function withdraw({ provider: rawProvider, withdrawAmountInput, rec
|
|
|
99
100
|
keyBasePath,
|
|
100
101
|
});
|
|
101
102
|
|
|
102
|
-
logger.info(
|
|
103
|
+
logger.info(`submitting transaction to relayer`);
|
|
103
104
|
const response = await fetch(`${INDEXER_URL}/relayer/withdraw`, {
|
|
104
105
|
method: 'POST',
|
|
105
106
|
headers: {
|
|
@@ -124,6 +125,7 @@ export async function withdraw({ provider: rawProvider, withdrawAmountInput, rec
|
|
|
124
125
|
logger.debug(`\nChange UTXO created (${ethers.utils.formatEther(changeAmount)} ETH)`);
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
logger.info('confirming transaction')
|
|
127
129
|
let retryTimes = 0
|
|
128
130
|
let itv = 2
|
|
129
131
|
// const encryptedOutputStr = Buffer.from(extData.encryptedOutput1).toString('hex')
|