@rabby-wallet/rabby-bridge 0.0.4-beta.0 → 0.0.4-beta.2

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/data.d.ts CHANGED
@@ -221,6 +221,10 @@ export declare const BRIDGE_SPENDER_WHITELIST_DATA: {
221
221
  readonly BLAST: "0x2d509190ed0172ba588407d4c2df918f955cc6e1";
222
222
  };
223
223
  };
224
+ export declare const BRIDGE_ALT_CONTRACTS_DATA: {
225
+ readonly across: readonly ["0x10d8b8daa26d307489803e10477de69c0492b610", "0x5a148a9260c1f670429361c34d40b477280f01a9"];
226
+ readonly relay: readonly ["0x8754bc615047de01228a7527b712806a71a8dc9a", "0xccc88a9d1b4ed6b0eaba998850414b24f1c315be", "0xf6e54bbf91e564fcf0df3ed9f2dd82913e9232c3"];
227
+ };
224
228
  export declare const BRIDGE_ROUTER_WHITELIST_DATA: {
225
229
  readonly lifi: {
226
230
  readonly [EXTRA_CHAINS.XDC]: "0x055d4612ec74ad799c6cb4df72c0ab8dbdbcbafa";
package/dist/data.js CHANGED
@@ -217,6 +217,8 @@ export const BRIDGE_SPENDER_WHITELIST_DATA = {
217
217
  [EXTRA_CHAINS.HYPER]: '0x337685fdab40d39bd02028545a4ffa7d287cc3e2',
218
218
  [EXTRA_CHAINS.MONAD]: '0x337685fdab40d39bd02028545a4ffa7d287cc3e2',
219
219
  },
220
+ // across 逐链 SpokePool/直连合约(depositV3 路由的 approve 目标与 tx.to)。
221
+ // swap+bridge 路由会切到全局 SpokePoolPeriphery,额外合法地址见 BRIDGE_ALT_CONTRACTS_DATA。
220
222
  across: {
221
223
  [CHAINS_ENUM.ETH]: '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5',
222
224
  [CHAINS_ENUM.OP]: '0x6f26bf09b1c792e3228e5467807a900a503c0281',
@@ -241,6 +243,22 @@ export const BRIDGE_SPENDER_WHITELIST_DATA = {
241
243
  [EXTRA_CHAINS.PLASMA]: '0x50039faefebef707cfd94d6d462fe6d10b39207a',
242
244
  },
243
245
  };
246
+ // 部分聚合器除逐链合约外,API 还可能路由到全局合约(同时作为 approve 目标与 tx.to)。
247
+ // 这些地址对该聚合器所有链均合法,校验时与逐链白名单并列接受。对应 DeBankCore 的 *_alt_contracts。
248
+ export const BRIDGE_ALT_CONTRACTS_DATA = {
249
+ across: [
250
+ // SpokePoolPeriphery(swap+bridge 入口),多数链同址
251
+ '0x10d8b8daa26d307489803e10477de69c0492b610',
252
+ // SpokePoolPeriphery(zkSync 系: era / lens)
253
+ '0x5a148a9260c1f670429361c34d40b477280f01a9',
254
+ ],
255
+ relay: [
256
+ // ApprovalProxy v3 全局地址,按 EVM fork 类型区分,与逐链 Depository 同时在用
257
+ '0x8754bc615047de01228a7527b712806a71a8dc9a', // london
258
+ '0xccc88a9d1b4ed6b0eaba998850414b24f1c315be', // cancun
259
+ '0xf6e54bbf91e564fcf0df3ed9f2dd82913e9232c3', // zero / zkevm
260
+ ],
261
+ };
244
262
  export const BRIDGE_ROUTER_WHITELIST_DATA = {
245
263
  lifi: {
246
264
  [CHAINS_ENUM.ETH]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
@@ -401,6 +419,8 @@ export const BRIDGE_ROUTER_WHITELIST_DATA = {
401
419
  [EXTRA_CHAINS.HYPER]: '0x337685fdab40d39bd02028545a4ffa7d287cc3e2',
402
420
  [EXTRA_CHAINS.MONAD]: '0x337685fdab40d39bd02028545a4ffa7d287cc3e2',
403
421
  },
422
+ // across 逐链 SpokePool/直连合约(depositV3 路由的 approve 目标与 tx.to)。
423
+ // swap+bridge 路由会切到全局 SpokePoolPeriphery,额外合法地址见 BRIDGE_ALT_CONTRACTS_DATA。
404
424
  across: {
405
425
  [CHAINS_ENUM.ETH]: '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5',
406
426
  [CHAINS_ENUM.OP]: '0x6f26bf09b1c792e3228e5467807a900a503c0281',
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { BRIDGE_AGGREGATORS, BRIDGE_ENUM } from './consts.js';
2
2
  export type { BridgeAggregatorId } from './consts.js';
3
- export { ALL_SUPPORTED_BRIDGE_CHAINS, BRIDGE_ROUTER_WHITELIST, BRIDGE_SPENDER_WHITELIST, BRIDGE_SUPPORT_CHAINS, CHAINS_ENUM, getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
3
+ export { ALL_SUPPORTED_BRIDGE_CHAINS, BRIDGE_ROUTER_WHITELIST, BRIDGE_SPENDER_WHITELIST, BRIDGE_SUPPORT_CHAINS, CHAINS_ENUM, getBridgeAltContracts, getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
4
4
  export { InvalidBridgeContractError, buildBridgeQuoteTx, buildTx, getQuote, getQuoteList, getQuoteListWithTx, validateBridgeQuote, validateBridgeTx, } from './quote.js';
5
5
  export type { BridgeApi, BridgeBuildTxParams, BridgeQuote, BridgeQuoteListItem, BridgeQuoteListParams, BridgeTx, } from './quote.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { BRIDGE_AGGREGATORS, BRIDGE_ENUM } from './consts.js';
2
- export { ALL_SUPPORTED_BRIDGE_CHAINS, BRIDGE_ROUTER_WHITELIST, BRIDGE_SPENDER_WHITELIST, BRIDGE_SUPPORT_CHAINS, CHAINS_ENUM, getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
2
+ export { ALL_SUPPORTED_BRIDGE_CHAINS, BRIDGE_ROUTER_WHITELIST, BRIDGE_SPENDER_WHITELIST, BRIDGE_SUPPORT_CHAINS, CHAINS_ENUM, getBridgeAltContracts, getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
3
3
  export { InvalidBridgeContractError, buildBridgeQuoteTx, buildTx, getQuote, getQuoteList, getQuoteListWithTx, validateBridgeQuote, validateBridgeTx, } from './quote.js';
package/dist/list.d.ts CHANGED
@@ -11,3 +11,4 @@ export declare const isSupportedBridgeAggregator: (aggregatorId: string) => aggr
11
11
  export declare const isSupportedBridgeChain: (aggregatorId: BridgeAggregatorId, chainId: string) => boolean;
12
12
  export declare const getBridgeSpender: (aggregatorId: BridgeAggregatorId, chainId: string) => string | undefined;
13
13
  export declare const getBridgeRouter: (aggregatorId: BridgeAggregatorId, chainId: string) => string | undefined;
14
+ export declare const getBridgeAltContracts: (aggregatorId: BridgeAggregatorId) => string[];
package/dist/list.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CHAINS_ENUM, normalizeChainEnum } from './chains.js';
2
2
  import { BRIDGE_AGGREGATORS } from './consts.js';
3
- import { BRIDGE_SUPPORT_CHAINS_DATA, BRIDGE_ROUTER_WHITELIST_DATA, BRIDGE_SPENDER_WHITELIST_DATA, } from './data.js';
3
+ import { BRIDGE_SUPPORT_CHAINS_DATA, BRIDGE_ROUTER_WHITELIST_DATA, BRIDGE_SPENDER_WHITELIST_DATA, BRIDGE_ALT_CONTRACTS_DATA, } from './data.js';
4
4
  export { CHAINS_ENUM };
5
5
  export const BRIDGE_SPENDER_WHITELIST = BRIDGE_SPENDER_WHITELIST_DATA;
6
6
  export const BRIDGE_ROUTER_WHITELIST = BRIDGE_ROUTER_WHITELIST_DATA;
@@ -40,3 +40,9 @@ export const getBridgeRouter = (aggregatorId, chainId) => {
40
40
  }
41
41
  return BRIDGE_ROUTER_WHITELIST[aggregatorId]?.[chainEnum];
42
42
  };
43
+ // 该聚合器的全局合法合约(periphery 等),对其所有链均有效,与逐链白名单并列接受。
44
+ export const getBridgeAltContracts = (aggregatorId) => {
45
+ return [
46
+ ...(BRIDGE_ALT_CONTRACTS_DATA[aggregatorId] || []),
47
+ ];
48
+ };
package/dist/quote.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BRIDGE_ENUM } from './consts.js';
2
- import { getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
2
+ import { getBridgeAltContracts, getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
3
3
  export class InvalidBridgeContractError extends Error {
4
4
  constructor(kind, aggregatorId, chainId, expected, received, bridgeId) {
5
5
  super(`Invalid bridge ${kind} for ${aggregatorId} on ${chainId}: expected ${expected}, got ${received}`);
@@ -48,7 +48,11 @@ export const validateBridgeQuote = (aggregatorId, fromChainId, quote) => {
48
48
  if (!expectedSpender || !receivedSpender) {
49
49
  return true;
50
50
  }
51
- if (!isSameAddress(expectedSpender, receivedSpender)) {
51
+ const allowedSpenders = [
52
+ expectedSpender,
53
+ ...getBridgeAltContracts(aggregatorId),
54
+ ];
55
+ if (!allowedSpenders.some((addr) => isSameAddress(addr, receivedSpender))) {
52
56
  throw new InvalidBridgeContractError('spender', aggregatorId, fromChainId, expectedSpender, receivedSpender, quote.bridge_id);
53
57
  }
54
58
  return true;
@@ -61,7 +65,11 @@ export const validateBridgeTx = (aggregatorId, fromChainId, bridgeId, tx) => {
61
65
  if (!expectedRouter) {
62
66
  return true;
63
67
  }
64
- if (!isSameAddress(expectedRouter, tx.to)) {
68
+ const allowedRouters = [
69
+ expectedRouter,
70
+ ...getBridgeAltContracts(aggregatorId),
71
+ ];
72
+ if (!allowedRouters.some((addr) => isSameAddress(addr, tx.to))) {
65
73
  throw new InvalidBridgeContractError('router', aggregatorId, fromChainId, expectedRouter, tx.to, bridgeId);
66
74
  }
67
75
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-bridge",
3
- "version": "0.0.4-beta.0",
3
+ "version": "0.0.4-beta.02",
4
4
  "description": "Bridge quote helpers and contract allowlists for Rabby",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",