@rabby-wallet/rabby-bridge 0.0.13-alpha.1 → 0.0.13
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/README.md +1 -159
- package/dist/chains.d.ts +2 -1
- package/dist/chains.js +2 -0
- package/dist/data.d.ts +3 -0
- package/dist/data.js +3 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.js +0 -3
- package/dist/quote.d.ts +4 -26
- package/dist/quote.js +67 -200
- package/package.json +3 -13
- package/dist/calldata/abi.d.ts +0 -29
- package/dist/calldata/abi.js +0 -160
- package/dist/calldata/across/deposit.d.ts +0 -2
- package/dist/calldata/across/deposit.js +0 -36
- package/dist/calldata/across/depositNative.d.ts +0 -2
- package/dist/calldata/across/depositNative.js +0 -45
- package/dist/calldata/across/depositNow.d.ts +0 -2
- package/dist/calldata/across/depositNow.js +0 -35
- package/dist/calldata/across/depositV3.d.ts +0 -2
- package/dist/calldata/across/depositV3.js +0 -35
- package/dist/calldata/across/depositV3Now.d.ts +0 -2
- package/dist/calldata/across/depositV3Now.js +0 -34
- package/dist/calldata/across/index.d.ts +0 -4
- package/dist/calldata/across/index.js +0 -31
- package/dist/calldata/across/swapAndBridge.d.ts +0 -2
- package/dist/calldata/across/swapAndBridge.js +0 -70
- package/dist/calldata/across/validate.d.ts +0 -3
- package/dist/calldata/across/validate.js +0 -34
- package/dist/calldata/chains.d.ts +0 -2
- package/dist/calldata/chains.js +0 -35
- package/dist/calldata/destination.d.ts +0 -6
- package/dist/calldata/destination.js +0 -211
- package/dist/calldata/destinationSwap.d.ts +0 -14
- package/dist/calldata/destinationSwap.js +0 -80
- package/dist/calldata/diagnostics.d.ts +0 -4
- package/dist/calldata/diagnostics.js +0 -18
- package/dist/calldata/expect.d.ts +0 -27
- package/dist/calldata/expect.js +0 -158
- package/dist/calldata/hex.d.ts +0 -6
- package/dist/calldata/hex.js +0 -46
- package/dist/calldata/index.d.ts +0 -20
- package/dist/calldata/index.js +0 -88
- package/dist/calldata/lifi/across/acrossV4Erc20Min.d.ts +0 -2
- package/dist/calldata/lifi/across/acrossV4Erc20Min.js +0 -26
- package/dist/calldata/lifi/across/acrossV4NativeMin.d.ts +0 -2
- package/dist/calldata/lifi/across/acrossV4NativeMin.js +0 -22
- package/dist/calldata/lifi/across/index.d.ts +0 -6
- package/dist/calldata/lifi/across/index.js +0 -19
- package/dist/calldata/lifi/allbridge/index.d.ts +0 -3
- package/dist/calldata/lifi/allbridge/index.js +0 -26
- package/dist/calldata/lifi/celer/index.d.ts +0 -4
- package/dist/calldata/lifi/celer/index.js +0 -10
- package/dist/calldata/lifi/centrifuge/index.d.ts +0 -3
- package/dist/calldata/lifi/centrifuge/index.js +0 -22
- package/dist/calldata/lifi/destination.d.ts +0 -5
- package/dist/calldata/lifi/destination.js +0 -40
- package/dist/calldata/lifi/frax/index.d.ts +0 -4
- package/dist/calldata/lifi/frax/index.js +0 -29
- package/dist/calldata/lifi/garden/index.d.ts +0 -3
- package/dist/calldata/lifi/garden/index.js +0 -22
- package/dist/calldata/lifi/gaszip/index.d.ts +0 -6
- package/dist/calldata/lifi/gaszip/index.js +0 -15
- package/dist/calldata/lifi/index.d.ts +0 -4
- package/dist/calldata/lifi/index.js +0 -62
- package/dist/calldata/lifi/intents/index.d.ts +0 -4
- package/dist/calldata/lifi/intents/index.js +0 -10
- package/dist/calldata/lifi/layerswap/index.d.ts +0 -4
- package/dist/calldata/lifi/layerswap/index.js +0 -10
- package/dist/calldata/lifi/m0/index.d.ts +0 -3
- package/dist/calldata/lifi/m0/index.js +0 -33
- package/dist/calldata/lifi/mayan/index.d.ts +0 -4
- package/dist/calldata/lifi/mayan/index.js +0 -10
- package/dist/calldata/lifi/method.d.ts +0 -6
- package/dist/calldata/lifi/method.js +0 -16
- package/dist/calldata/lifi/native/index.d.ts +0 -4
- package/dist/calldata/lifi/native/index.js +0 -80
- package/dist/calldata/lifi/params.d.ts +0 -28
- package/dist/calldata/lifi/params.js +0 -347
- package/dist/calldata/lifi/paxos/index.d.ts +0 -4
- package/dist/calldata/lifi/paxos/index.js +0 -10
- package/dist/calldata/lifi/polymer/index.d.ts +0 -4
- package/dist/calldata/lifi/polymer/index.js +0 -10
- package/dist/calldata/lifi/relay/index.d.ts +0 -6
- package/dist/calldata/lifi/relay/index.js +0 -15
- package/dist/calldata/lifi/shape.d.ts +0 -4
- package/dist/calldata/lifi/shape.js +0 -31
- package/dist/calldata/lifi/squid/index.d.ts +0 -6
- package/dist/calldata/lifi/squid/index.js +0 -15
- package/dist/calldata/lifi/stargate/index.d.ts +0 -5
- package/dist/calldata/lifi/stargate/index.js +0 -15
- package/dist/calldata/lifi/swap/index.d.ts +0 -5
- package/dist/calldata/lifi/swap/index.js +0 -18
- package/dist/calldata/lifi/swap/swapMethod.d.ts +0 -2
- package/dist/calldata/lifi/swap/swapMethod.js +0 -40
- package/dist/calldata/lifi/swapData.d.ts +0 -5
- package/dist/calldata/lifi/swapData.js +0 -33
- package/dist/calldata/match.d.ts +0 -3
- package/dist/calldata/match.js +0 -21
- package/dist/calldata/mayan/destination.d.ts +0 -2
- package/dist/calldata/mayan/destination.js +0 -13
- package/dist/calldata/mayan/fastMctpBridge.d.ts +0 -3
- package/dist/calldata/mayan/fastMctpBridge.js +0 -48
- package/dist/calldata/mayan/fastMctpCreateOrder.d.ts +0 -3
- package/dist/calldata/mayan/fastMctpCreateOrder.js +0 -39
- package/dist/calldata/mayan/forward.d.ts +0 -8
- package/dist/calldata/mayan/forward.js +0 -35
- package/dist/calldata/mayan/forwardERC20.d.ts +0 -2
- package/dist/calldata/mayan/forwardERC20.js +0 -19
- package/dist/calldata/mayan/forwardEth.d.ts +0 -2
- package/dist/calldata/mayan/forwardEth.js +0 -16
- package/dist/calldata/mayan/index.d.ts +0 -4
- package/dist/calldata/mayan/index.js +0 -21
- package/dist/calldata/mayan/mctp.d.ts +0 -5
- package/dist/calldata/mayan/mctp.js +0 -41
- package/dist/calldata/mayan/readProtocol.d.ts +0 -2
- package/dist/calldata/mayan/readProtocol.js +0 -29
- package/dist/calldata/mayan/swapAndForwardERC20.d.ts +0 -2
- package/dist/calldata/mayan/swapAndForwardERC20.js +0 -24
- package/dist/calldata/mayan/swapAndForwardEth.d.ts +0 -2
- package/dist/calldata/mayan/swapAndForwardEth.js +0 -23
- package/dist/calldata/mayan/swiftCreateOrder.d.ts +0 -3
- package/dist/calldata/mayan/swiftCreateOrder.js +0 -49
- package/dist/calldata/mayan/validate.d.ts +0 -3
- package/dist/calldata/mayan/validate.js +0 -20
- package/dist/calldata/protocols.d.ts +0 -9
- package/dist/calldata/protocols.js +0 -57
- package/dist/calldata/relay/calls.d.ts +0 -13
- package/dist/calldata/relay/calls.js +0 -54
- package/dist/calldata/relay/depositErc20.d.ts +0 -2
- package/dist/calldata/relay/depositErc20.js +0 -22
- package/dist/calldata/relay/depositErc20Allowance.d.ts +0 -2
- package/dist/calldata/relay/depositErc20Allowance.js +0 -20
- package/dist/calldata/relay/depositNative.d.ts +0 -2
- package/dist/calldata/relay/depositNative.js +0 -20
- package/dist/calldata/relay/index.d.ts +0 -4
- package/dist/calldata/relay/index.js +0 -42
- package/dist/calldata/relay/multicall.d.ts +0 -2
- package/dist/calldata/relay/multicall.js +0 -15
- package/dist/calldata/relay/permit2TransferAndMulticall.d.ts +0 -2
- package/dist/calldata/relay/permit2TransferAndMulticall.js +0 -42
- package/dist/calldata/relay/permit3009TransferAndMulticall.d.ts +0 -2
- package/dist/calldata/relay/permit3009TransferAndMulticall.js +0 -41
- package/dist/calldata/relay/permit3009TransferAndMulticallSigned.d.ts +0 -2
- package/dist/calldata/relay/permit3009TransferAndMulticallSigned.js +0 -40
- package/dist/calldata/relay/permitTransferAndMulticall.d.ts +0 -2
- package/dist/calldata/relay/permitTransferAndMulticall.js +0 -34
- package/dist/calldata/relay/permitTransferAndMulticallLegacy.d.ts +0 -2
- package/dist/calldata/relay/permitTransferAndMulticallLegacy.js +0 -35
- package/dist/calldata/relay/transferAndMulticall.d.ts +0 -2
- package/dist/calldata/relay/transferAndMulticall.js +0 -26
- package/dist/calldata/relay/validate.d.ts +0 -3
- package/dist/calldata/relay/validate.js +0 -18
- package/dist/calldata/resolve.d.ts +0 -2
- package/dist/calldata/resolve.js +0 -28
- package/dist/calldata/socket/bridge.d.ts +0 -2
- package/dist/calldata/socket/bridge.js +0 -28
- package/dist/calldata/socket/exec.d.ts +0 -2
- package/dist/calldata/socket/exec.js +0 -71
- package/dist/calldata/socket/index.d.ts +0 -4
- package/dist/calldata/socket/index.js +0 -13
- package/dist/calldata/socket/params.d.ts +0 -5
- package/dist/calldata/socket/params.js +0 -14
- package/dist/calldata/socket/protocols/ccip.d.ts +0 -2
- package/dist/calldata/socket/protocols/ccip.js +0 -32
- package/dist/calldata/socket/protocols/cctp.d.ts +0 -2
- package/dist/calldata/socket/protocols/cctp.js +0 -24
- package/dist/calldata/socket/protocols/eco.d.ts +0 -2
- package/dist/calldata/socket/protocols/eco.js +0 -20
- package/dist/calldata/socket/protocols/index.d.ts +0 -3
- package/dist/calldata/socket/protocols/index.js +0 -86
- package/dist/calldata/socket/protocols/native.d.ts +0 -2
- package/dist/calldata/socket/protocols/native.js +0 -70
- package/dist/calldata/socket/protocols/oft.d.ts +0 -2
- package/dist/calldata/socket/protocols/oft.js +0 -33
- package/dist/calldata/socket/protocols/swapsXYZ.d.ts +0 -2
- package/dist/calldata/socket/protocols/swapsXYZ.js +0 -62
- package/dist/calldata/socket/swapAndBridge.d.ts +0 -2
- package/dist/calldata/socket/swapAndBridge.js +0 -41
- package/dist/calldata/socket/validate.d.ts +0 -3
- package/dist/calldata/socket/validate.js +0 -24
- package/dist/calldata/types.d.ts +0 -82
- package/dist/calldata/types.js +0 -20
- package/dist/errors/constants.d.ts +0 -891
- package/dist/errors/constants.js +0 -898
- package/dist/errors/index.d.ts +0 -66
- package/dist/errors/index.js +0 -53
- package/dist/errors/sanitize.d.ts +0 -3
- package/dist/errors/sanitize.js +0 -74
- package/dist/providers/data.d.ts +0 -23
- package/dist/providers/data.js +0 -116
- package/dist/providers/errors.d.ts +0 -7
- package/dist/providers/errors.js +0 -10
- package/dist/providers/layerswap.d.ts +0 -9
- package/dist/providers/layerswap.js +0 -95
- package/dist/providers/relay.d.ts +0 -59
- package/dist/providers/relay.js +0 -185
- package/dist/providers/socket.d.ts +0 -5
- package/dist/providers/socket.js +0 -57
package/README.md
CHANGED
|
@@ -5,166 +5,8 @@ Minimal bridge SDK for Rabby:
|
|
|
5
5
|
- enumerates supported bridge aggregators and chains
|
|
6
6
|
- maintains per-chain spender/router allowlists
|
|
7
7
|
- validates backend bridge quotes before returning them
|
|
8
|
-
-
|
|
9
|
-
- keeps chain-state-dependent output fields explicitly unverified, without RPC requests
|
|
10
|
-
- performs local validation only; no direct-provider HTTP requests or RPC reads
|
|
11
|
-
|
|
12
|
-
See [calldata parsing](src/calldata/README.md) for supported paths, integration and verification boundaries.
|
|
13
|
-
See [offline provider evidence](src/providers/README.md) for retained historical fixtures and verification limits.
|
|
8
|
+
- does not implement calldata decoding
|
|
14
9
|
|
|
15
10
|
## Test
|
|
16
11
|
|
|
17
12
|
Run `yarn test` to build the package and execute the Jest suite.
|
|
18
|
-
|
|
19
|
-
See [reachable route discovery](tests/fixtures/route-discovery-20261104/README.md) for the latest parsing changes, fixture coverage and remaining verification limits.
|
|
20
|
-
|
|
21
|
-
## Validation rollout
|
|
22
|
-
|
|
23
|
-
The first rollout enforces Router/Spender allowlists and observes local calldata
|
|
24
|
-
validation. No provider API or RPC requests are made. `buildTx` and
|
|
25
|
-
`getQuoteListWithTx` keep the original backend transaction when source, destination
|
|
26
|
-
or receiver checks fail or cannot be completed; `onError` receives those observations.
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
const quotes = await getQuoteListWithTx(aggregatorId, {
|
|
30
|
-
...params,
|
|
31
|
-
onError: (report) => reportToBusiness(report),
|
|
32
|
-
}, api);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
- Quotes and transactions come from the existing backend flow, including Relay
|
|
36
|
-
and Socket, in both modes. The SDK no longer accepts `providerClient` or exposes
|
|
37
|
-
a direct-provider client/fetch adapter.
|
|
38
|
-
- Router/Spender mismatches, unsupported source chains/aggregators,
|
|
39
|
-
missing required slippage, missing backend results and backend request failures
|
|
40
|
-
keep their original blocking behavior.
|
|
41
|
-
- Source token, source amount, supplied sender/chain and protocol structure are
|
|
42
|
-
checked locally. Missing source fields and mismatches are reported.
|
|
43
|
-
- Socket quote IDs (including CCTP), RFQ outer/vault IDs and Relay multicall
|
|
44
|
-
request IDs are compared locally when a selected quote provides a matching
|
|
45
|
-
identifier. Mismatches are reported without blocking or changing field flags;
|
|
46
|
-
missing/unrecognized keys are skipped. See the [binding limits](src/calldata/README.md).
|
|
47
|
-
- Known destination tokens, minimum amounts and chains are compared. Unknown
|
|
48
|
-
destination paths remain unverified and are reported with available method,
|
|
49
|
-
selector and nested-call diagnostics.
|
|
50
|
-
- Locally derivable final receivers are compared. External order data is skipped
|
|
51
|
-
without a provider request; a skipped receiver is never counted as verified.
|
|
52
|
-
- Parse failures, known mismatches and unexpected missing fields are reported with
|
|
53
|
-
`blocking: false`, including when `lite` is omitted or false.
|
|
54
|
-
- Relay and Socket RFQ/CCTP external destination fields are skipped rather than
|
|
55
|
-
fetched. LayerSwap uses its local receiver; no background order lookup runs.
|
|
56
|
-
Skipping an external receiver does not claim order-hash or provider verification.
|
|
57
|
-
- Known unresolved output token/minimum fields and Relay/Socket external
|
|
58
|
-
receiver/chain fields stay in `unverifiedFields` without producing reports.
|
|
59
|
-
Missing source fields, unknown receivers/paths and a missing expected amount
|
|
60
|
-
for a locally available minimum use `BRIDGE_UNVERIFIED_BRIDGE_FIELDS`.
|
|
61
|
-
Actual mismatches retain their existing error codes. Repeated failures are not
|
|
62
|
-
deduplicated, sampled or rate-limited by the SDK.
|
|
63
|
-
|
|
64
|
-
`validateBridgeQuote` also accepts `{ lite, onError }` as its fourth argument;
|
|
65
|
-
`validateBridgeTx` accepts it after the optional expectation as its sixth argument.
|
|
66
|
-
`lite` retains its legacy missing-spender behavior; it no longer selects strict
|
|
67
|
-
calldata enforcement and never skips a missing Router allowlist.
|
|
68
|
-
|
|
69
|
-
`validateBridgeTx` now returns `BridgeValidationResult` instead of `true`:
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
const result = validateBridgeTx(aggregatorId, chainId, bridgeId, tx, expectation);
|
|
73
|
-
// result.pass === result.routerPass
|
|
74
|
-
// result.fromPass / result.toPass / result.receiverPass
|
|
75
|
-
// result.unverifiedFields / result.errors
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
The three field flags are true only when all required local comparisons for that
|
|
79
|
-
group succeeded. False means a failure or an incomplete check; `errors` and
|
|
80
|
-
`unverifiedFields` distinguish them. Known skipped fields can leave `errors` empty
|
|
81
|
-
while a field flag is false. Without an expectation, field flags are false.
|
|
82
|
-
They do not contribute to `pass` in this rollout. Router rejection still throws
|
|
83
|
-
`InvalidBridgeContractError`; its sanitized detail carries `pass: false`,
|
|
84
|
-
`routerPass: false` and `blocking: true`.
|
|
85
|
-
|
|
86
|
-
Raw decode/calldata-check results retain `ok: false` on failure. Observation
|
|
87
|
-
details include all five pass flags, path diagnostics, `lite` and `blocking: false`.
|
|
88
|
-
These are failure-event/path counts, not distinct user counts or a denominator for
|
|
89
|
-
all successful transactions. See error reporting below for failures that still throw.
|
|
90
|
-
|
|
91
|
-
## Error reporting
|
|
92
|
-
|
|
93
|
-
All stable error codes, stages and messages are defined in
|
|
94
|
-
[`BRIDGE_ERRORS`](src/errors/constants.ts). Codes are explicit constants; callers
|
|
95
|
-
must not classify errors by matching message text. Existing error classes and
|
|
96
|
-
legacy `reason` fields remain available.
|
|
97
|
-
|
|
98
|
-
- `decodeBridgeCalldataResult(aggregatorId, tx)` returns a detailed success/failure
|
|
99
|
-
result. The existing `decodeBridgeCalldata` still returns `null` on failure.
|
|
100
|
-
- `validateBridgeCalldata` returns `errors`, plus `error_code` and `stage` on failure.
|
|
101
|
-
Independent intent mismatches are collected together; decoding or dependent
|
|
102
|
-
protocol operations stop at their first failure.
|
|
103
|
-
- Thrown SDK errors extend `BridgeError`. Use `error.toJSON()` for a report.
|
|
104
|
-
- `onError` receives failures filtered from `getQuote` / `getQuoteListWithTx`,
|
|
105
|
-
plus local validation failures and unexpected missing fields from transaction checks.
|
|
106
|
-
Directly thrown errors are handled by the caller, avoiding duplicate reporting.
|
|
107
|
-
Reporting callback failures do not affect validation or quote filtering.
|
|
108
|
-
|
|
109
|
-
```ts
|
|
110
|
-
import { BridgeError, getQuoteListWithTx } from '@rabby-wallet/rabby-bridge';
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const quotes = await getQuoteListWithTx(aggregatorId, {
|
|
114
|
-
...params,
|
|
115
|
-
onError: (report) => reportToBusiness(report),
|
|
116
|
-
}, api);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (error instanceof BridgeError) reportToBusiness(error.toJSON());
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
A report contains a primary `error_code` / `stage` and an `errors` list. The primary
|
|
124
|
-
code is the first failure; inspect the list for every collected failure. Each detail
|
|
125
|
-
contains its fixed message and available context: aggregator, chain, bridge,
|
|
126
|
-
provider, operation, method, selector, nested protocol selector, missing fields or
|
|
127
|
-
HTTP status. SDK reports omit wallet addresses, amounts, raw calldata, response
|
|
128
|
-
bodies and arbitrary transport exception messages. Existing Error messages are
|
|
129
|
-
retained for compatibility; prefer `toJSON()` for reporting.
|
|
130
|
-
|
|
131
|
-
Stages distinguish input checks, contract allowlists, ABI decoding, protocol
|
|
132
|
-
structure, intent comparison, provider requests, provider responses, transaction
|
|
133
|
-
binding and completeness. Unexpected uncategorized failures use `BRIDGE_UNKNOWN`.
|
|
134
|
-
Deferred chain-state output fields remain in `unverifiedFields` without producing
|
|
135
|
-
reports merely because a known local limitation prevents verification.
|
|
136
|
-
|
|
137
|
-
### Privacy-safe diagnostics
|
|
138
|
-
|
|
139
|
-
Use `toBridgeErrorReport(resultOrError)` to convert a calldata check,
|
|
140
|
-
transaction validation result, detailed decode result or exception into a report.
|
|
141
|
-
A transaction with `pass: true` can still produce an observation report when its
|
|
142
|
-
`errors` are nonempty. Results without reportable failures return `undefined`,
|
|
143
|
-
including known skipped destination fields.
|
|
144
|
-
The `onError` callback and `BridgeError.toJSON()` use the same
|
|
145
|
-
runtime allowlist. Do not upload the entire check, exception, parsed transaction,
|
|
146
|
-
request parameters or quote response.
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
const check = validateBridgeTx(aggregatorId, chainId, bridgeId, tx, expectation);
|
|
150
|
-
const report = toBridgeErrorReport(check);
|
|
151
|
-
if (report) reportToBusiness(report);
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Reports can retain recognized aggregator/bridge/method labels, source/destination
|
|
155
|
-
chains, outer/router/protocol selectors, call-data format and byte lengths, ABI
|
|
156
|
-
failure offsets, bounded destination-call selectors/counts, unsupported command
|
|
157
|
-
bytes/counts, static request categories and HTTP status. Nested diagnostics are
|
|
158
|
-
collected where the parser knows the call layout; arbitrary payload bytes are not
|
|
159
|
-
scanned for possible selectors. Destination selector lists are deduplicated and
|
|
160
|
-
limited to 16 entries.
|
|
161
|
-
|
|
162
|
-
Unknown labels become `unknown` or are omitted. Messages and stages are restored
|
|
163
|
-
from the error-code catalogue, even if an error was modified after construction.
|
|
164
|
-
Arbitrary properties are dropped, including wallet/receiver/refund addresses,
|
|
165
|
-
token addresses, amounts, balances, approvals, transaction/order/quote/request IDs,
|
|
166
|
-
signatures, full calldata, URL/query/header/body contents, raw exception messages
|
|
167
|
-
and stack traces. Contract addresses and hashes are not reported either.
|
|
168
|
-
|
|
169
|
-
These reports identify unsupported function families and failure stages. They
|
|
170
|
-
intentionally cannot reconstruct or identify the original user's transaction.
|
package/dist/chains.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CHAINS_ENUM as DBK_CHAINS_ENUM } from '@debank/common';
|
|
2
2
|
export declare const CHAINS_ENUM: typeof DBK_CHAINS_ENUM;
|
|
3
|
-
export declare const EXTRA_CHAINS: readonly ["XDC", "UNI", "RONIN", "XLAYER", "MONAD", "SONIC", "LENS", "WORLD", "STABLE", "HYPER", "LISK", "SEI", "GRAVITY", "SONEIUM", "SWELL", "ABS", "MORPH", "TEMPO", "MEGAETH", "PLASMA", "APE", "HEMI", "SOPHON", "INK", "BOB", "BERA", "PLUME", "TAIKO", "KATANA", "STORY", "CYBER", "ZIRCUIT", "HOOD", "ARC"];
|
|
3
|
+
export declare const EXTRA_CHAINS: readonly ["XDC", "UNI", "RONIN", "XLAYER", "MONAD", "SONIC", "LENS", "WORLD", "STABLE", "HYPER", "LISK", "SEI", "GRAVITY", "SONEIUM", "SWELL", "ABS", "MORPH", "TEMPO", "MEGAETH", "PLASMA", "APE", "HEMI", "SOPHON", "INK", "BOB", "BERA", "PLUME", "TAIKO", "KATANA", "STORY", "CYBER", "ZIRCUIT", "HOOD", "ARC", "ELYSIUM"];
|
|
4
4
|
export type ExtraChainEnum = (typeof EXTRA_CHAINS)[number];
|
|
5
5
|
export type ChainEnum = DBK_CHAINS_ENUM | ExtraChainEnum;
|
|
6
6
|
export declare const SERVER_ID_TO_CHAIN_ENUM: {
|
|
@@ -62,6 +62,7 @@ export declare const SERVER_ID_TO_CHAIN_ENUM: {
|
|
|
62
62
|
readonly zircuit: ChainEnum;
|
|
63
63
|
readonly hood: ChainEnum;
|
|
64
64
|
readonly arc: ChainEnum;
|
|
65
|
+
readonly elysium: ChainEnum;
|
|
65
66
|
readonly zora: DBK_CHAINS_ENUM.ZORA;
|
|
66
67
|
};
|
|
67
68
|
export declare const CHAIN_ENUM_TO_SERVER_ID: Record<ChainEnum, string>;
|
package/dist/chains.js
CHANGED
|
@@ -35,6 +35,7 @@ export const EXTRA_CHAINS = [
|
|
|
35
35
|
'ZIRCUIT',
|
|
36
36
|
'HOOD',
|
|
37
37
|
'ARC',
|
|
38
|
+
'ELYSIUM',
|
|
38
39
|
];
|
|
39
40
|
export const SERVER_ID_TO_CHAIN_ENUM = {
|
|
40
41
|
eth: CHAINS_ENUM.ETH,
|
|
@@ -95,6 +96,7 @@ export const SERVER_ID_TO_CHAIN_ENUM = {
|
|
|
95
96
|
zircuit: 'ZIRCUIT',
|
|
96
97
|
hood: 'HOOD',
|
|
97
98
|
arc: 'ARC',
|
|
99
|
+
elysium: 'ELYSIUM',
|
|
98
100
|
zora: CHAINS_ENUM.ZORA,
|
|
99
101
|
};
|
|
100
102
|
export const CHAIN_ENUM_TO_SERVER_ID = Object.fromEntries(Object.entries(SERVER_ID_TO_CHAIN_ENUM).map(([serverId, chainEnum]) => [
|
package/dist/data.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare const EXTRA_CHAINS: {
|
|
|
35
35
|
readonly ZIRCUIT: ChainEnum;
|
|
36
36
|
readonly HOOD: ChainEnum;
|
|
37
37
|
readonly ARC: ChainEnum;
|
|
38
|
+
readonly ELYSIUM: ChainEnum;
|
|
38
39
|
};
|
|
39
40
|
export declare const BRIDGE_SUPPORT_CHAINS_DATA: {
|
|
40
41
|
readonly near_intents: [import("@debank/common").CHAINS_ENUM.ETH, import("@debank/common").CHAINS_ENUM.ARBITRUM, import("@debank/common").CHAINS_ENUM.BASE, import("@debank/common").CHAINS_ENUM.BSC, import("@debank/common").CHAINS_ENUM.POLYGON, import("@debank/common").CHAINS_ENUM.OP, import("@debank/common").CHAINS_ENUM.AVAX, import("@debank/common").CHAINS_ENUM.GNOSIS, import("@debank/common").CHAINS_ENUM.SCRL, ChainEnum, ChainEnum];
|
|
@@ -175,6 +176,7 @@ export declare const BRIDGE_SPENDER_WHITELIST_DATA: {
|
|
|
175
176
|
readonly [EXTRA_CHAINS.PLASMA]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
176
177
|
readonly [EXTRA_CHAINS.HOOD]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
177
178
|
readonly [EXTRA_CHAINS.ARC]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
179
|
+
readonly [EXTRA_CHAINS.ELYSIUM]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
178
180
|
readonly ETH: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
179
181
|
readonly OP: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
180
182
|
readonly CRO: "0x59916da825d2d2ec1bf878d71c88826f6633ecca";
|
|
@@ -398,6 +400,7 @@ export declare const BRIDGE_ROUTER_WHITELIST_DATA: {
|
|
|
398
400
|
readonly [EXTRA_CHAINS.PLASMA]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
399
401
|
readonly [EXTRA_CHAINS.HOOD]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
400
402
|
readonly [EXTRA_CHAINS.ARC]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
403
|
+
readonly [EXTRA_CHAINS.ELYSIUM]: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
401
404
|
readonly ETH: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
402
405
|
readonly OP: "0x4cd00e387622c35bddb9b4c962c136462338bc31";
|
|
403
406
|
readonly CRO: "0x59916da825d2d2ec1bf878d71c88826f6633ecca";
|
package/dist/data.js
CHANGED
|
@@ -44,6 +44,7 @@ const EXTRA_CHAINS = {
|
|
|
44
44
|
ZIRCUIT: 'ZIRCUIT',
|
|
45
45
|
HOOD: 'HOOD',
|
|
46
46
|
ARC: 'ARC',
|
|
47
|
+
ELYSIUM: 'ELYSIUM',
|
|
47
48
|
};
|
|
48
49
|
const SOCKET_V3_ALLOWANCE_HOLDER = '0x50c4e75a512f2a14a7b304787adf79c4531a5909';
|
|
49
50
|
const SOCKET_V3_CONTRACTS = {
|
|
@@ -218,6 +219,7 @@ export const BRIDGE_SPENDER_WHITELIST_DATA = {
|
|
|
218
219
|
[EXTRA_CHAINS.PLASMA]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
219
220
|
[EXTRA_CHAINS.HOOD]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
220
221
|
[EXTRA_CHAINS.ARC]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
222
|
+
[EXTRA_CHAINS.ELYSIUM]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
221
223
|
},
|
|
222
224
|
stargate: {
|
|
223
225
|
[CHAINS_ENUM.BASE]: '0x8eca03175fd5ac62fb6f4ecbb9a95d13dcdcb4f8',
|
|
@@ -439,6 +441,7 @@ export const BRIDGE_ROUTER_WHITELIST_DATA = {
|
|
|
439
441
|
[EXTRA_CHAINS.PLASMA]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
440
442
|
[EXTRA_CHAINS.HOOD]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
441
443
|
[EXTRA_CHAINS.ARC]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
444
|
+
[EXTRA_CHAINS.ELYSIUM]: '0x4cd00e387622c35bddb9b4c962c136462338bc31',
|
|
442
445
|
},
|
|
443
446
|
stargate: {
|
|
444
447
|
[CHAINS_ENUM.BASE]: '0x7e07a9148e9149e430c6412b79a675028595ff1f',
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export { BRIDGE_AGGREGATORS, BRIDGE_ENUM } from './consts.js';
|
|
2
2
|
export type { BridgeAggregatorId } from './consts.js';
|
|
3
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
|
-
export { CALLDATA_AGGREGATORS, InvalidBridgeCalldataError, decodeBridgeCalldata, decodeBridgeCalldataResult, hasBridgeCalldata, validateBridgeCalldata, } from './calldata/index.js';
|
|
5
|
-
export type { BridgeCalldataTx, BridgeTokenReference, BridgeAmountReference, BridgeCallExpectation, BridgeCheck, DecodeHit, ParsedBridgeCall, } from './calldata/index.js';
|
|
6
4
|
export { InvalidBridgeContractError, buildBridgeQuoteTx, buildTx, getQuote, getQuoteList, getQuoteListWithTx, validateBridgeQuote, validateBridgeTx, } from './quote.js';
|
|
7
|
-
export type { BridgeApi, BridgeBuildTxParams, BridgeQuote, BridgeQuoteListItem, BridgeQuoteListParams,
|
|
8
|
-
export { InvalidBridgeProviderError } from './providers/errors.js';
|
|
9
|
-
export { BRIDGE_ERRORS, BridgeError, toBridgeErrorReport } from './errors/index.js';
|
|
10
|
-
export type { BridgeErrorCode, BridgeErrorStage, BridgeErrorDefinition, BridgeErrorContext, BridgeErrorDetail, BridgeErrorReport, BridgeErrorReporter } from './errors/index.js';
|
|
5
|
+
export type { BridgeApi, BridgeBuildTxParams, BridgeQuote, BridgeQuoteListItem, BridgeQuoteListParams, BridgeTx, } from './quote.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { BRIDGE_AGGREGATORS, BRIDGE_ENUM } from './consts.js';
|
|
2
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
|
-
export { CALLDATA_AGGREGATORS, InvalidBridgeCalldataError, decodeBridgeCalldata, decodeBridgeCalldataResult, hasBridgeCalldata, validateBridgeCalldata, } from './calldata/index.js';
|
|
4
3
|
export { InvalidBridgeContractError, buildBridgeQuoteTx, buildTx, getQuote, getQuoteList, getQuoteListWithTx, validateBridgeQuote, validateBridgeTx, } from './quote.js';
|
|
5
|
-
export { InvalidBridgeProviderError } from './providers/errors.js';
|
|
6
|
-
export { BRIDGE_ERRORS, BridgeError, toBridgeErrorReport } from './errors/index.js';
|
package/dist/quote.d.ts
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import type { BridgeErrorReporter } from './errors/index.js';
|
|
2
|
-
import { BridgeError } from './errors/index.js';
|
|
3
1
|
import type { OpenApiService } from '@rabby-wallet/rabby-api';
|
|
4
|
-
import type { BridgeCallExpectation } from './calldata/expect.js';
|
|
5
|
-
import type { BridgeCheck } from './calldata/types.js';
|
|
6
2
|
import type { BridgeAggregatorId } from './consts.js';
|
|
7
|
-
export interface
|
|
8
|
-
/** Retains the legacy missing-spender rollout behavior. Calldata checks are always observation-only. */
|
|
9
|
-
lite?: boolean;
|
|
10
|
-
/** Receives filtered failures and non-blocking local validation observations. */
|
|
11
|
-
onError?: BridgeErrorReporter;
|
|
12
|
-
}
|
|
13
|
-
export type BridgeValidationResult = {
|
|
14
|
-
/** First rollout: only the router decides whether a transaction passes. */
|
|
15
|
-
pass: boolean;
|
|
16
|
-
routerPass: boolean;
|
|
17
|
-
fromPass: boolean;
|
|
18
|
-
toPass: boolean;
|
|
19
|
-
receiverPass: boolean;
|
|
20
|
-
unverifiedFields: string[];
|
|
21
|
-
errors: BridgeCheck['errors'];
|
|
22
|
-
};
|
|
23
|
-
export interface BridgeQuoteListParams extends BridgeValidationOptions {
|
|
3
|
+
export interface BridgeQuoteListParams {
|
|
24
4
|
userAddress: string;
|
|
25
5
|
fromChainId: string;
|
|
26
6
|
fromTokenId: string;
|
|
@@ -33,14 +13,12 @@ export interface BridgeQuoteListParams extends BridgeValidationOptions {
|
|
|
33
13
|
export interface BridgeBuildTxParams extends BridgeQuoteListParams {
|
|
34
14
|
bridgeId: string;
|
|
35
15
|
quoteKey?: string | Record<string, unknown>;
|
|
36
|
-
/** Quoted output in raw units, before applying slippage. */
|
|
37
|
-
toTokenRawAmount?: string;
|
|
38
16
|
}
|
|
39
17
|
export type BridgeApi = Pick<OpenApiService, 'getBridgeQuoteListV2' | 'getBridgeQuoteV2' | 'buildBridgeTx' | 'getBridgeQuoteTxV2'>;
|
|
40
18
|
export type BridgeQuote = Awaited<ReturnType<BridgeApi['getBridgeQuoteTxV2']>>;
|
|
41
19
|
export type BridgeTx = Awaited<ReturnType<BridgeApi['buildBridgeTx']>> | NonNullable<BridgeQuote['tx']>;
|
|
42
20
|
export type BridgeQuoteListItem = Awaited<ReturnType<BridgeApi['getBridgeQuoteV2']>>[number];
|
|
43
|
-
export declare class InvalidBridgeContractError extends
|
|
21
|
+
export declare class InvalidBridgeContractError extends Error {
|
|
44
22
|
readonly kind: 'spender' | 'router';
|
|
45
23
|
readonly aggregatorId: BridgeAggregatorId;
|
|
46
24
|
readonly chainId: string;
|
|
@@ -49,8 +27,8 @@ export declare class InvalidBridgeContractError extends BridgeError {
|
|
|
49
27
|
readonly bridgeId?: string | undefined;
|
|
50
28
|
constructor(kind: 'spender' | 'router', aggregatorId: BridgeAggregatorId, chainId: string, expected: string, received: string, bridgeId?: string | undefined);
|
|
51
29
|
}
|
|
52
|
-
export declare const validateBridgeQuote: (aggregatorId: BridgeAggregatorId, fromChainId: string, quote: BridgeQuoteListItem
|
|
53
|
-
export declare const validateBridgeTx: (aggregatorId: BridgeAggregatorId, fromChainId: string, bridgeId: string, tx: BridgeTx
|
|
30
|
+
export declare const validateBridgeQuote: (aggregatorId: BridgeAggregatorId, fromChainId: string, quote: BridgeQuoteListItem) => boolean;
|
|
31
|
+
export declare const validateBridgeTx: (aggregatorId: BridgeAggregatorId, fromChainId: string, bridgeId: string, tx: BridgeTx) => boolean;
|
|
54
32
|
export declare const getQuote: (aggregatorId: string, params: BridgeQuoteListParams, api: BridgeApi) => Promise<BridgeQuoteListItem[]>;
|
|
55
33
|
export declare const buildTx: (aggregatorId: string, params: BridgeBuildTxParams, api: BridgeApi) => Promise<BridgeTx>;
|
|
56
34
|
export declare const getQuoteListWithTx: (aggregatorId: string, params: BridgeQuoteListParams, api: BridgeApi) => Promise<Array<BridgeQuoteListItem & {
|