@rabby-wallet/rabby-bridge 0.0.11-alpha.0 → 0.0.11-alpha.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.
- package/dist/data.d.ts +5 -0
- package/dist/data.js +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/list.d.ts +1 -0
- package/dist/list.js +9 -4
- package/dist/quote.js +2 -1
- package/package.json +1 -1
package/dist/data.d.ts
CHANGED
|
@@ -481,6 +481,11 @@ export declare const BRIDGE_ROUTER_WHITELIST_DATA: {
|
|
|
481
481
|
readonly BLAST: "0x2d509190ed0172ba588407d4c2df918f955cc6e1";
|
|
482
482
|
};
|
|
483
483
|
};
|
|
484
|
+
export declare const BRIDGE_SPENDER_ALT_WHITELIST_DATA: {
|
|
485
|
+
readonly across: {
|
|
486
|
+
readonly [EXTRA_CHAINS.ARC]: readonly ["0xe791a2669bef779ff7a4a9cf789f8ee2ca20a32c"];
|
|
487
|
+
};
|
|
488
|
+
};
|
|
484
489
|
export declare const BRIDGE_ROUTER_ALT_WHITELIST_DATA: {
|
|
485
490
|
readonly relay: {
|
|
486
491
|
readonly [EXTRA_CHAINS.ARC]: readonly ["0xb92fe925dc43a0ecde6c8b1a2709c170ec4fff4f"];
|
package/dist/data.js
CHANGED
|
@@ -495,6 +495,13 @@ export const BRIDGE_ROUTER_WHITELIST_DATA = {
|
|
|
495
495
|
[EXTRA_CHAINS.ARC]: '0x9b4a302a548c7e313c2b74c461db7b84d3074a84',
|
|
496
496
|
},
|
|
497
497
|
};
|
|
498
|
+
// 仅在指定链生效的额外 spender(approve 目标)。
|
|
499
|
+
export const BRIDGE_SPENDER_ALT_WHITELIST_DATA = {
|
|
500
|
+
across: {
|
|
501
|
+
// arc 专有 SpokePoolPeriphery,swap+bridge 路由的 approve 目标
|
|
502
|
+
[EXTRA_CHAINS.ARC]: ['0xe791a2669bef779ff7a4a9cf789f8ee2ca20a32c'],
|
|
503
|
+
},
|
|
504
|
+
};
|
|
498
505
|
// 仅在指定链生效的额外 router。
|
|
499
506
|
export const BRIDGE_ROUTER_ALT_WHITELIST_DATA = {
|
|
500
507
|
relay: {
|
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, getBridgeAltContracts, getBridgeAltRouters, 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, getBridgeAltRouters, getBridgeAltSpenders, 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, getBridgeAltContracts, getBridgeAltRouters, 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, getBridgeAltRouters, getBridgeAltSpenders, 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,5 +11,6 @@ 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 getBridgeAltSpenders: (aggregatorId: BridgeAggregatorId, chainId: string) => string[];
|
|
14
15
|
export declare const getBridgeAltRouters: (aggregatorId: BridgeAggregatorId, chainId: string) => string[];
|
|
15
16
|
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, BRIDGE_ALT_CONTRACTS_DATA, BRIDGE_ROUTER_ALT_WHITELIST_DATA, } from './data.js';
|
|
3
|
+
import { BRIDGE_SUPPORT_CHAINS_DATA, BRIDGE_ROUTER_WHITELIST_DATA, BRIDGE_SPENDER_WHITELIST_DATA, BRIDGE_ALT_CONTRACTS_DATA, BRIDGE_ROUTER_ALT_WHITELIST_DATA, BRIDGE_SPENDER_ALT_WHITELIST_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,13 +40,18 @@ export const getBridgeRouter = (aggregatorId, chainId) => {
|
|
|
40
40
|
}
|
|
41
41
|
return BRIDGE_ROUTER_WHITELIST[aggregatorId]?.[chainEnum];
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
const getChainAltContracts = (data, aggregatorId, chainId) => {
|
|
44
44
|
const chainEnum = normalizeChainEnum(chainId);
|
|
45
45
|
if (!chainEnum) {
|
|
46
46
|
return [];
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
return [...(data[aggregatorId]?.[chainEnum] || [])];
|
|
49
|
+
};
|
|
50
|
+
export const getBridgeAltSpenders = (aggregatorId, chainId) => {
|
|
51
|
+
return getChainAltContracts(BRIDGE_SPENDER_ALT_WHITELIST_DATA, aggregatorId, chainId);
|
|
52
|
+
};
|
|
53
|
+
export const getBridgeAltRouters = (aggregatorId, chainId) => {
|
|
54
|
+
return getChainAltContracts(BRIDGE_ROUTER_ALT_WHITELIST_DATA, aggregatorId, chainId);
|
|
50
55
|
};
|
|
51
56
|
// 该聚合器的全局合法合约(periphery 等),对其所有链均有效,与逐链白名单并列接受。
|
|
52
57
|
export const getBridgeAltContracts = (aggregatorId) => {
|
package/dist/quote.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BRIDGE_ENUM } from './consts.js';
|
|
2
|
-
import { getBridgeAltContracts, getBridgeAltRouters, getBridgeRouter, getBridgeSpender, isSupportedBridgeAggregator, isSupportedBridgeChain, } from './list.js';
|
|
2
|
+
import { getBridgeAltContracts, getBridgeAltRouters, getBridgeAltSpenders, 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}`);
|
|
@@ -51,6 +51,7 @@ export const validateBridgeQuote = (aggregatorId, fromChainId, quote) => {
|
|
|
51
51
|
const allowedSpenders = [
|
|
52
52
|
expectedSpender,
|
|
53
53
|
...getBridgeAltContracts(aggregatorId),
|
|
54
|
+
...getBridgeAltSpenders(aggregatorId, fromChainId),
|
|
54
55
|
];
|
|
55
56
|
if (!allowedSpenders.some((addr) => isSameAddress(addr, receivedSpender))) {
|
|
56
57
|
throw new InvalidBridgeContractError('spender', aggregatorId, fromChainId, expectedSpender, receivedSpender, quote.bridge_id);
|