@pear-protocol/exchanges-sdk 0.9.0 → 0.9.1
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.
|
@@ -59,7 +59,7 @@ async function depositUsdcViaFunxyz(sdk, params, demo) {
|
|
|
59
59
|
if (wallet.chain?.id !== params.chainId) {
|
|
60
60
|
throw new Error(`Switch the wallet to chain ${params.chainId} before depositing.`);
|
|
61
61
|
}
|
|
62
|
-
const knownTxHashes = await readKnownBridgeTxHashes(sdk, params, uda.credits);
|
|
62
|
+
const knownTxHashes = await readKnownBridgeTxHashes(sdk, params, uda.credits, uda.raw.resolved.userId);
|
|
63
63
|
const txHash = await writeUsdcTransfer(wallet, {
|
|
64
64
|
usdcAddress,
|
|
65
65
|
to: uda.evmAddress,
|
|
@@ -74,7 +74,7 @@ async function depositUsdcViaFunxyz(sdk, params, demo) {
|
|
|
74
74
|
state: "bridging",
|
|
75
75
|
txHash
|
|
76
76
|
});
|
|
77
|
-
await followFunxyzSettlement(sdk, params, uda.credits, {
|
|
77
|
+
await followFunxyzSettlement(sdk, params, uda.credits, uda.raw.resolved.userId, {
|
|
78
78
|
depositAddress: uda.evmAddress,
|
|
79
79
|
txHash,
|
|
80
80
|
chainId: params.chainId,
|
|
@@ -163,7 +163,7 @@ function assertFunxyzEnvironment(demo) {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
__name(assertFunxyzEnvironment, "assertFunxyzEnvironment");
|
|
166
|
-
async function followFunxyzSettlement(sdk, params, credits, transfer, knownTxHashes, demo) {
|
|
166
|
+
async function followFunxyzSettlement(sdk, params, credits, bridgeUserId, transfer, knownTxHashes, demo) {
|
|
167
167
|
if (!params.settlement) {
|
|
168
168
|
emitProgress(params.onProgress, params.signal, {
|
|
169
169
|
state: "untracked",
|
|
@@ -173,7 +173,7 @@ async function followFunxyzSettlement(sdk, params, credits, transfer, knownTxHas
|
|
|
173
173
|
}
|
|
174
174
|
switch (credits.account) {
|
|
175
175
|
case "existing": {
|
|
176
|
-
const transaction = await watchFunxyzBridge(sdk, params, transfer, knownTxHashes);
|
|
176
|
+
const transaction = await watchFunxyzBridge(sdk, params, bridgeUserId, transfer, knownTxHashes);
|
|
177
177
|
if (!transaction) {
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
@@ -194,19 +194,21 @@ async function followFunxyzSettlement(sdk, params, credits, transfer, knownTxHas
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
__name(followFunxyzSettlement, "followFunxyzSettlement");
|
|
197
|
-
async function readKnownBridgeTxHashes(sdk, params, credits) {
|
|
197
|
+
async function readKnownBridgeTxHashes(sdk, params, credits, bridgeUserId) {
|
|
198
198
|
if (!params.settlement || credits.account !== "existing") {
|
|
199
199
|
return void 0;
|
|
200
200
|
}
|
|
201
201
|
try {
|
|
202
|
-
const result = await sdk.core.misc.lighter.listUdaDeposits(
|
|
203
|
-
return new Set(result.transactions.
|
|
202
|
+
const result = await sdk.core.misc.lighter.listUdaDeposits(bridgeUserId);
|
|
203
|
+
return new Set(result.transactions.flatMap((transaction) => transaction.txHash === void 0 ? [] : [
|
|
204
|
+
transaction.txHash.toLowerCase()
|
|
205
|
+
]));
|
|
204
206
|
} catch {
|
|
205
207
|
return void 0;
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
__name(readKnownBridgeTxHashes, "readKnownBridgeTxHashes");
|
|
209
|
-
async function watchFunxyzBridge(sdk, params, transfer, knownTxHashes) {
|
|
211
|
+
async function watchFunxyzBridge(sdk, params, bridgeUserId, transfer, knownTxHashes) {
|
|
210
212
|
const signal = params.signal;
|
|
211
213
|
const deadline = Date.now() + SETTLEMENT_WATCH_LIMIT_MS;
|
|
212
214
|
while (!signal?.aborted) {
|
|
@@ -223,7 +225,7 @@ async function watchFunxyzBridge(sdk, params, transfer, knownTxHashes) {
|
|
|
223
225
|
}
|
|
224
226
|
let transactions;
|
|
225
227
|
try {
|
|
226
|
-
const result = await sdk.core.misc.lighter.listUdaDeposits(
|
|
228
|
+
const result = await sdk.core.misc.lighter.listUdaDeposits(bridgeUserId);
|
|
227
229
|
transactions = result.transactions;
|
|
228
230
|
} catch {
|
|
229
231
|
continue;
|
|
@@ -242,14 +244,14 @@ async function watchFunxyzBridge(sdk, params, transfer, knownTxHashes) {
|
|
|
242
244
|
}
|
|
243
245
|
__name(watchFunxyzBridge, "watchFunxyzBridge");
|
|
244
246
|
function findFunxyzTransaction(transactions, transfer, knownTxHashes) {
|
|
245
|
-
const byHash = transactions.find((candidate) => candidate.txHash
|
|
247
|
+
const byHash = transactions.find((candidate) => candidate.txHash?.toLowerCase() === transfer.txHash.toLowerCase());
|
|
246
248
|
if (byHash) {
|
|
247
249
|
return byHash;
|
|
248
250
|
}
|
|
249
251
|
if (!knownTxHashes) {
|
|
250
252
|
return void 0;
|
|
251
253
|
}
|
|
252
|
-
const candidates = transactions.filter((candidate) => candidate.depositAddr.toLowerCase() === transfer.depositAddress.toLowerCase() && !knownTxHashes.has(candidate.txHash.toLowerCase()) && candidate.fromChainId === String(transfer.chainId) && candidate.fromAmountBaseUnit === String(transfer.units));
|
|
254
|
+
const candidates = transactions.filter((candidate) => candidate.txHash !== void 0 && candidate.depositAddr.toLowerCase() === transfer.depositAddress.toLowerCase() && !knownTxHashes.has(candidate.txHash.toLowerCase()) && candidate.fromChainId === String(transfer.chainId) && candidate.fromAmountBaseUnit === String(transfer.units));
|
|
253
255
|
return candidates.length === 1 ? candidates[0] : void 0;
|
|
254
256
|
}
|
|
255
257
|
__name(findFunxyzTransaction, "findFunxyzTransaction");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/exchanges-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Pear Protocol Exchanges SDK",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@pear-protocol/core-sdk": "^1.19.0",
|
|
31
|
-
"@pear-protocol/types": "^1.
|
|
31
|
+
"@pear-protocol/types": "^1.29.0",
|
|
32
32
|
"@pear-protocol/utils": "^0.5.3",
|
|
33
33
|
"bignumber.js": "^11.1.1",
|
|
34
34
|
"partysocket": "^1.0.3",
|