@silentswap/react 0.0.43 → 0.0.44
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,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { ensureChain, waitForTransactionConfirmation, NI_CHAIN_ID_AVALANCHE, S0X_ADDR_USDC_AVALANCHE, X_MAX_IMPACT_PERCENT, getRelayStatus, getDebridgeStatus, fetchDebridgeOrder, fetchRelayQuote, createPhonyDepositCalldata, isSolanaAsset, parseSolanaCaip19, isSolanaNativeToken, isSplToken, N_RELAY_CHAIN_ID_SOLANA, SB58_ADDR_SOL_PROGRAM_SYSTEM, getChainById, } from '@silentswap/sdk';
|
|
2
|
+
import { encodeFunctionData, erc20Abi, getAddress } from 'viem';
|
|
3
|
+
import { ensureChain, waitForTransactionConfirmation, createPublicClientWithRpc, NI_CHAIN_ID_AVALANCHE, S0X_ADDR_USDC_AVALANCHE, X_MAX_IMPACT_PERCENT, getRelayStatus, getDebridgeStatus, fetchDebridgeOrder, fetchRelayQuote, createPhonyDepositCalldata, isSolanaAsset, parseSolanaCaip19, isSolanaNativeToken, isSplToken, N_RELAY_CHAIN_ID_SOLANA, SB58_ADDR_SOL_PROGRAM_SYSTEM, getChainById, } from '@silentswap/sdk';
|
|
4
4
|
import { createSolanaTransactionExecutor, convertRelaySolanaStepToTransaction } from './solana-transaction.js';
|
|
5
5
|
const S0X_ADDR_EVM_ZERO = '0x0000000000000000000000000000000000000000';
|
|
6
6
|
const XG_UINT256_MAX = (1n << 256n) - 1n;
|
|
@@ -28,14 +28,8 @@ async function ensureChainAndCreateClient(chainId, walletClient, connector) {
|
|
|
28
28
|
const wallet = await ensureChain(chainId, walletClient, connector);
|
|
29
29
|
// Use wallet's chain if available, otherwise look up chain by ID
|
|
30
30
|
const chain = wallet.chain || getChainById(chainId);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
// Create public client - viem has complex union types that TypeScript struggles with
|
|
35
|
-
const publicClient = createPublicClient({
|
|
36
|
-
chain,
|
|
37
|
-
transport: http(),
|
|
38
|
-
});
|
|
31
|
+
// Create public client with RPC fallback configuration
|
|
32
|
+
const publicClient = createPublicClientWithRpc(chainId, chain);
|
|
39
33
|
return { wallet, publicClient };
|
|
40
34
|
}
|
|
41
35
|
/**
|
package/dist/hooks/useSwap.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AssetInfo } from '@silentswap/sdk';
|
|
2
2
|
export declare const X_RANGE_SLIDER_MIN_GAP = 0.01;
|
|
3
|
-
export declare const OUTPUT_LIMIT =
|
|
3
|
+
export declare const OUTPUT_LIMIT = 10;
|
|
4
4
|
export declare const DEFAULT_SOURCE_ASSET = "eip155:1/slip44:60";
|
|
5
5
|
export declare const DEFAULT_DEST_ASSET = "eip155:1/erc20:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599";
|
|
6
6
|
export declare const DEFAULT_OUTPUT_ASSET = "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
package/dist/hooks/useSwap.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getAssetByCaip19 } from '@silentswap/sdk';
|
|
|
4
4
|
const DEFAULT_SLIPPAGE = 1;
|
|
5
5
|
// Constants matching Svelte app
|
|
6
6
|
export const X_RANGE_SLIDER_MIN_GAP = 0.01;
|
|
7
|
-
export const OUTPUT_LIMIT =
|
|
7
|
+
export const OUTPUT_LIMIT = 10;
|
|
8
8
|
// Default assets
|
|
9
9
|
export const DEFAULT_SOURCE_ASSET = 'eip155:1/slip44:60'; // ETH on Ethereum
|
|
10
10
|
export const DEFAULT_DEST_ASSET = 'eip155:1/erc20:0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'; // WBTC on Ethereum
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { executeRelayBridge, executeDebridgeBridge, getBridgeStatus, createTransactionExecutor, createChainSwitcher, ensureChain, waitForTransactionConfirmation, parseTransactionRequestForViem, getChainById, } from '@silentswap/sdk';
|
|
2
|
+
import { erc20Abi } from 'viem';
|
|
3
|
+
import { executeRelayBridge, executeDebridgeBridge, getBridgeStatus, createTransactionExecutor, createChainSwitcher, ensureChain, waitForTransactionConfirmation, parseTransactionRequestForViem, createPublicClientWithRpc, getChainById, } from '@silentswap/sdk';
|
|
4
4
|
import { createSolanaTransactionExecutor } from './silent/solana-transaction.js';
|
|
5
5
|
/**
|
|
6
6
|
* React hook for executing transactions
|
|
@@ -204,16 +204,10 @@ export function useTransaction({ walletClient, connector, solanaConnector, solan
|
|
|
204
204
|
const chainId = transactionParams.chainId ?? 1;
|
|
205
205
|
// Ensure correct chain
|
|
206
206
|
const wallet = await ensureChain(chainId, walletClient, connector);
|
|
207
|
-
// Create public client
|
|
207
|
+
// Create public client with RPC fallback configuration
|
|
208
208
|
// Use wallet's chain if available, otherwise look up chain by ID
|
|
209
209
|
const chain = wallet.chain || getChainById(chainId);
|
|
210
|
-
|
|
211
|
-
throw new Error(`Unsupported chain ID: ${chainId}. Please ensure the chain is supported.`);
|
|
212
|
-
}
|
|
213
|
-
const publicClient = createPublicClient({
|
|
214
|
-
chain,
|
|
215
|
-
transport: http(),
|
|
216
|
-
});
|
|
210
|
+
const publicClient = createPublicClientWithRpc(chainId, chain);
|
|
217
211
|
setCurrentStep('Sending transaction');
|
|
218
212
|
onStatus?.('Sending transaction');
|
|
219
213
|
// Execute transaction
|
|
@@ -269,16 +263,10 @@ export function useTransaction({ walletClient, connector, solanaConnector, solan
|
|
|
269
263
|
try {
|
|
270
264
|
// Switch to source chain for approval
|
|
271
265
|
const wallet = await ensureChain(chainId, walletClient, connector);
|
|
272
|
-
//
|
|
266
|
+
// Create public client with RPC fallback configuration
|
|
273
267
|
// Use wallet's chain if available, otherwise look up chain by ID
|
|
274
268
|
const chain = wallet.chain || getChainById(chainId);
|
|
275
|
-
|
|
276
|
-
throw new Error(`Unsupported chain ID: ${chainId}. Please ensure the chain is supported.`);
|
|
277
|
-
}
|
|
278
|
-
const publicClient = createPublicClient({
|
|
279
|
-
chain,
|
|
280
|
-
transport: http(),
|
|
281
|
-
});
|
|
269
|
+
const publicClient = createPublicClientWithRpc(chainId, chain);
|
|
282
270
|
const currentAllowance = (await publicClient.readContract({
|
|
283
271
|
address: tokenAddress,
|
|
284
272
|
abi: erc20Abi,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silentswap/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.44",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ensdomains/ensjs": "^4.2.0",
|
|
26
|
-
"@silentswap/sdk": "0.0.
|
|
27
|
-
"@silentswap/ui-kit": "0.0.
|
|
26
|
+
"@silentswap/sdk": "0.0.44",
|
|
27
|
+
"@silentswap/ui-kit": "0.0.44",
|
|
28
28
|
"@solana/codecs-strings": "^5.1.0",
|
|
29
29
|
"@solana/kit": "^5.1.0",
|
|
30
30
|
"@solana/rpc": "^5.1.0",
|