@silentswap/react 0.1.0 → 0.1.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.
|
@@ -193,6 +193,11 @@ export function useQuoteCalculation({ address, evmAddress, wallet, depositorAddr
|
|
|
193
193
|
return amountStr;
|
|
194
194
|
});
|
|
195
195
|
const outputs = destinations.map((dest, idx) => {
|
|
196
|
+
// Validate destination asset exists in the asset registry
|
|
197
|
+
// This prevents invalid CAIP-19 identifiers (e.g. erc20 with zero address) from reaching the quote API
|
|
198
|
+
if (!getAssetByCaip19(dest.asset)) {
|
|
199
|
+
throw new Error(`Unknown destination asset: ${dest.asset}. Asset not found in registry.`);
|
|
200
|
+
}
|
|
196
201
|
const isDestSolana = isSolanaAsset(dest.asset);
|
|
197
202
|
const isDestBitcoin = isBitcoinAsset(dest.asset);
|
|
198
203
|
let asset;
|
|
@@ -272,6 +277,14 @@ export function useQuoteCalculation({ address, evmAddress, wallet, depositorAddr
|
|
|
272
277
|
// - Using isEvmNativeToken() would incorrectly try to construct erc20:null
|
|
273
278
|
const isNative = destParsed.isNative;
|
|
274
279
|
const destChainId = destParsed.chainId;
|
|
280
|
+
// Reject ERC-20 tokens with the zero address — the zero address is not a valid
|
|
281
|
+
// ERC-20 contract. Native tokens should use slip44 namespace instead.
|
|
282
|
+
if (!isNative &&
|
|
283
|
+
destParsed.tokenAddress &&
|
|
284
|
+
/^0x0+$/.test(destParsed.tokenAddress)) {
|
|
285
|
+
throw new Error(`Invalid ERC-20 token address for destination ${idx}: zero address is not a valid token. ` +
|
|
286
|
+
`Use slip44 namespace for native tokens (e.g. eip155:${destChainId}/slip44:60).`);
|
|
287
|
+
}
|
|
275
288
|
asset = isNative
|
|
276
289
|
? dest.asset
|
|
277
290
|
: caip19FungibleEvmToken(destChainId, destParsed.tokenAddress);
|
package/dist/hooks/useSwap.js
CHANGED
|
@@ -194,11 +194,17 @@ const useSwapStore = create()(persist((set, get) => ({
|
|
|
194
194
|
return false;
|
|
195
195
|
},
|
|
196
196
|
updateDestinationAsset: (index, asset) => {
|
|
197
|
+
const assetStr = String(asset);
|
|
198
|
+
// Validate that the asset CAIP-19 exists in the registry
|
|
199
|
+
if (!getAssetByCaip19(assetStr)) {
|
|
200
|
+
console.warn(`[useSwap] Ignoring unknown destination asset: ${assetStr}`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
197
203
|
set((state) => {
|
|
198
204
|
return {
|
|
199
205
|
destinations: state.destinations.map((dest, idx) => idx === index
|
|
200
206
|
? {
|
|
201
|
-
asset:
|
|
207
|
+
asset: assetStr,
|
|
202
208
|
contact: String(dest.contact),
|
|
203
209
|
amount: '',
|
|
204
210
|
priceUsd: dest.priceUsd,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silentswap/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@bigmi/core": "^0.6.5",
|
|
26
26
|
"@ensdomains/ensjs": "^4.2.0",
|
|
27
|
-
"@silentswap/sdk": "0.1.
|
|
28
|
-
"@silentswap/ui-kit": "0.1.
|
|
27
|
+
"@silentswap/sdk": "0.1.1",
|
|
28
|
+
"@silentswap/ui-kit": "0.1.1",
|
|
29
29
|
"@solana/codecs-strings": "^5.1.0",
|
|
30
30
|
"@solana/kit": "^5.1.0",
|
|
31
31
|
"@solana/rpc": "^5.1.0",
|