@silentswap/sdk 0.1.45 → 0.1.47
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/bridge.js +1 -1
- package/dist/chain.d.ts +1 -0
- package/dist/chain.js +3 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +3 -0
- package/dist/quote-utils.js +6 -6
- package/package.json +1 -1
package/dist/bridge.js
CHANGED
|
@@ -243,7 +243,7 @@ function mapDebridgeStatus(status) {
|
|
|
243
243
|
* Fetch a relay.link quote with detailed response
|
|
244
244
|
*/
|
|
245
245
|
export async function fetchRelayQuote(params, signal) {
|
|
246
|
-
const response = await fetch('https://api.relay.link/quote', {
|
|
246
|
+
const response = await fetch('https://api.relay.link/quote/v2', {
|
|
247
247
|
method: 'POST',
|
|
248
248
|
headers: {
|
|
249
249
|
'Content-Type': 'application/json',
|
package/dist/chain.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare function createPublicClientWithRpc(chainId: number, chain?: Chain
|
|
|
56
56
|
export declare function waitForTransactionConfirmation(hash: Hex, publicClient: PublicClient, timeoutMs?: number): Promise<{
|
|
57
57
|
status: 'success' | 'failed';
|
|
58
58
|
transactionHash: Hex;
|
|
59
|
+
reason?: 'reverted' | 'timeout' | 'error';
|
|
59
60
|
}>;
|
|
60
61
|
/**
|
|
61
62
|
* Execute a transaction with confirmation waiting
|
package/dist/chain.js
CHANGED
|
@@ -208,6 +208,7 @@ export async function waitForTransactionConfirmation(hash, publicClient, timeout
|
|
|
208
208
|
]);
|
|
209
209
|
return {
|
|
210
210
|
status: receipt.status === 'success' ? 'success' : 'failed',
|
|
211
|
+
reason: receipt.status === 'success' ? undefined : 'reverted',
|
|
211
212
|
transactionHash: hash,
|
|
212
213
|
};
|
|
213
214
|
}
|
|
@@ -220,9 +221,10 @@ export async function waitForTransactionConfirmation(hash, publicClient, timeout
|
|
|
220
221
|
isTimeout,
|
|
221
222
|
});
|
|
222
223
|
// Return failed status instead of throwing to allow callers to handle gracefully
|
|
223
|
-
// Callers can check
|
|
224
|
+
// Callers can check reason to distinguish timeout from on-chain revert
|
|
224
225
|
return {
|
|
225
226
|
status: 'failed',
|
|
227
|
+
reason: isTimeout ? 'timeout' : 'error',
|
|
226
228
|
transactionHash: hash,
|
|
227
229
|
};
|
|
228
230
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare const SB58_ADDR_SOL_PROGRAM_SYSTEM = "111111111111111111111111111
|
|
|
31
31
|
export declare const SB58_ADDR_SOL_RELAY_LINK_RECIPIENT = "CbKGgVKLJFb8bBrf58DnAkdryX6ubewVytn7X957YwNr";
|
|
32
32
|
export declare const SB58_ADDR_SOL_DEAD = "1nc1nerator11111111111111111111111111111111";
|
|
33
33
|
export declare const SBTC_ADDR_BITCOIN_NATIVE = "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8";
|
|
34
|
+
export declare const SBTC_ADDR_BTC_RELAY_LINK_RECIPIENT = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4";
|
|
34
35
|
export declare const N_RELAY_CHAIN_ID_SOLANA = 792703809;
|
|
35
36
|
export declare const N_RELAY_CHAIN_ID_BITCOIN = 8253038;
|
|
36
37
|
export declare const N_RELAY_CHAIN_ID_TRON = 728126428;
|
package/dist/constants.js
CHANGED
|
@@ -56,6 +56,9 @@ export const SB58_ADDR_SOL_DEAD = '1nc1nerator11111111111111111111111111111111';
|
|
|
56
56
|
// Bitcoin constants
|
|
57
57
|
// Bitcoin native token address (BTC) used by relay.link
|
|
58
58
|
export const SBTC_ADDR_BITCOIN_NATIVE = 'bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8';
|
|
59
|
+
// Valid Bitcoin recipient address for relay.link quote estimation (BIP-173 test vector P2WPKH)
|
|
60
|
+
// relay.link rejects the phony zero address (SBTC_ADDR_BITCOIN_NATIVE) as recipient — use this fallback
|
|
61
|
+
export const SBTC_ADDR_BTC_RELAY_LINK_RECIPIENT = 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4';
|
|
59
62
|
// Relay.link chain IDs for non-EVM chains
|
|
60
63
|
export const N_RELAY_CHAIN_ID_SOLANA = 792703809;
|
|
61
64
|
export const N_RELAY_CHAIN_ID_BITCOIN = 8253038;
|
package/dist/quote-utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { fetchRelayQuote, fetchDebridgeOrder, } from './bridge.js';
|
|
3
|
-
import { N_DEBRIDGE_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_BITCOIN, SB58_ADDR_SOL_PROGRAM_SYSTEM, SB58_ADDR_SOL_DEAD, SB58_ADDR_SOL_RELAY_LINK_RECIPIENT, SBTC_ADDR_BITCOIN_NATIVE, DEAD_ADDRESS, } from './constants.js';
|
|
3
|
+
import { N_DEBRIDGE_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_SOLANA, N_RELAY_CHAIN_ID_BITCOIN, SB58_ADDR_SOL_PROGRAM_SYSTEM, SB58_ADDR_SOL_DEAD, SB58_ADDR_SOL_RELAY_LINK_RECIPIENT, SBTC_ADDR_BITCOIN_NATIVE, SBTC_ADDR_BTC_RELAY_LINK_RECIPIENT, DEAD_ADDRESS, } from './constants.js';
|
|
4
4
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
5
5
|
/**
|
|
6
6
|
* Map relay.link chain IDs to deBridge chain IDs
|
|
@@ -434,16 +434,16 @@ forceProvider, tradeType = 'EXACT_INPUT', dstAmount) {
|
|
|
434
434
|
if (isDestBitcoin) {
|
|
435
435
|
// For Bitcoin destinations, relay.link requires:
|
|
436
436
|
// - user to be the source chain address (EVM address if source is EVM)
|
|
437
|
-
// - recipient to be
|
|
438
|
-
//
|
|
437
|
+
// - recipient to be a VALID Bitcoin address (NOT the phony zero address)
|
|
438
|
+
// relay.link returns NO_SWAP_ROUTES_FOUND when recipient is the phony address
|
|
439
439
|
// Set recipient to Bitcoin address
|
|
440
|
-
if (recipientAddress && !recipientAddress.startsWith('0x') && !recipientAddress.startsWith('1111')) {
|
|
440
|
+
if (recipientAddress && !recipientAddress.startsWith('0x') && !recipientAddress.startsWith('1111') && recipientAddress !== SBTC_ADDR_BITCOIN_NATIVE) {
|
|
441
441
|
// Use provided Bitcoin recipient address
|
|
442
442
|
relayParams.recipient = recipientAddress;
|
|
443
443
|
}
|
|
444
444
|
else {
|
|
445
|
-
//
|
|
446
|
-
|
|
445
|
+
// Fallback to a valid Bitcoin address for quote estimation
|
|
446
|
+
relayParams.recipient = SBTC_ADDR_BTC_RELAY_LINK_RECIPIENT;
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
else if (isSrcBitcoin) {
|