@rabby-wallet/rabby-bridge 0.0.13-alpha.0 → 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 -131
- 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 -7
- package/dist/index.js +0 -3
- package/dist/quote.d.ts +4 -18
- package/dist/quote.js +65 -282
- 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 -30
- 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 -148
- package/dist/calldata/diagnostics.d.ts +0 -4
- package/dist/calldata/diagnostics.js +0 -18
- package/dist/calldata/expect.d.ts +0 -25
- package/dist/calldata/expect.js +0 -129
- 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 -85
- 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/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 -60
- 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 -30
- package/dist/calldata/lifi/params.js +0 -370
- 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/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 -43
- 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 -56
- 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 -40
- 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 -81
- 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 -31
- 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 -37
- package/dist/calldata/socket/validate.d.ts +0 -3
- package/dist/calldata/socket/validate.js +0 -21
- package/dist/calldata/types.d.ts +0 -82
- package/dist/calldata/types.js +0 -20
- package/dist/errors/constants.d.ts +0 -876
- package/dist/errors/constants.js +0 -883
- package/dist/errors/index.d.ts +0 -61
- package/dist/errors/index.js +0 -53
- package/dist/errors/sanitize.d.ts +0 -3
- package/dist/errors/sanitize.js +0 -75
- 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/index.d.ts +0 -7
- package/dist/providers/index.js +0 -340
- 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/request.d.ts +0 -23
- package/dist/providers/request.js +0 -69
- package/dist/providers/socket.d.ts +0 -5
- package/dist/providers/socket.js +0 -57
- package/dist/providers/types.d.ts +0 -36
- package/dist/providers/types.js +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { applyAcrossMessage } from '../destination.js';
|
|
2
|
-
import { asBigint, asString, decodeCall } from '../abi.js';
|
|
3
|
-
import { accountFromBytes32 } from '../hex.js';
|
|
4
|
-
const fields = [
|
|
5
|
-
{ name: 'depositor', kind: 'bytes', size: 32 },
|
|
6
|
-
{ name: 'recipient', kind: 'bytes', size: 32 },
|
|
7
|
-
{ name: 'inputToken', kind: 'bytes', size: 32 },
|
|
8
|
-
{ name: 'outputToken', kind: 'bytes', size: 32 },
|
|
9
|
-
{ name: 'inputAmount', kind: 'uint' },
|
|
10
|
-
{ name: 'outputAmount', kind: 'uint' },
|
|
11
|
-
{ name: 'destinationChainId', kind: 'uint' },
|
|
12
|
-
{ name: 'exclusiveRelayer', kind: 'bytes', size: 32 },
|
|
13
|
-
{ name: 'quoteTimestamp', kind: 'uint' },
|
|
14
|
-
{ name: 'fillDeadline', kind: 'uint' },
|
|
15
|
-
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
16
|
-
{ name: 'message', kind: 'bytes' },
|
|
17
|
-
];
|
|
18
|
-
export const deposit = {
|
|
19
|
-
name: 'deposit',
|
|
20
|
-
selector: '0xad5425c6',
|
|
21
|
-
decode(data) {
|
|
22
|
-
const args = decodeCall(fields, data);
|
|
23
|
-
return applyAcrossMessage({
|
|
24
|
-
aggregatorId: 'across',
|
|
25
|
-
method: 'deposit',
|
|
26
|
-
kind: 'bridge',
|
|
27
|
-
depositor: accountFromBytes32(asString(args.depositor)),
|
|
28
|
-
sourceToken: accountFromBytes32(asString(args.inputToken)),
|
|
29
|
-
sourceAmount: asBigint(args.inputAmount),
|
|
30
|
-
destinationChainId: asBigint(args.destinationChainId),
|
|
31
|
-
receiver: accountFromBytes32(asString(args.recipient)),
|
|
32
|
-
outputToken: accountFromBytes32(asString(args.outputToken)),
|
|
33
|
-
minOutputAmount: asBigint(args.outputAmount),
|
|
34
|
-
}, asString(args.message));
|
|
35
|
-
},
|
|
36
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { BRIDGE_ERRORS, BridgeError } from '../../errors/index.js';
|
|
2
|
-
import { applyAcrossMessage } from '../destination.js';
|
|
3
|
-
import { asBigint, asString, decodeCall } from '../abi.js';
|
|
4
|
-
import { accountFromBytes32 } from '../hex.js';
|
|
5
|
-
import { NATIVE_TOKEN } from '../protocols.js';
|
|
6
|
-
const fields = [
|
|
7
|
-
{ name: 'spokePool', kind: 'address' },
|
|
8
|
-
{ name: 'depositor', kind: 'address' },
|
|
9
|
-
{ name: 'recipient', kind: 'bytes', size: 32 },
|
|
10
|
-
{ name: 'inputToken', kind: 'address' },
|
|
11
|
-
{ name: 'inputAmount', kind: 'uint' },
|
|
12
|
-
{ name: 'outputToken', kind: 'bytes', size: 32 },
|
|
13
|
-
{ name: 'outputAmount', kind: 'uint' },
|
|
14
|
-
{ name: 'destinationChainId', kind: 'uint' },
|
|
15
|
-
{ name: 'exclusiveRelayer', kind: 'bytes', size: 32 },
|
|
16
|
-
{ name: 'quoteTimestamp', kind: 'uint' },
|
|
17
|
-
{ name: 'fillDeadline', kind: 'uint' },
|
|
18
|
-
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
19
|
-
{ name: 'message', kind: 'bytes' },
|
|
20
|
-
];
|
|
21
|
-
export const depositNative = {
|
|
22
|
-
name: 'depositNative',
|
|
23
|
-
selector: '0x609ea081',
|
|
24
|
-
decode(data, value) {
|
|
25
|
-
const args = decodeCall(fields, data);
|
|
26
|
-
const inputAmount = asBigint(args.inputAmount);
|
|
27
|
-
if (inputAmount > 0n && value !== inputAmount)
|
|
28
|
-
throw new BridgeError(BRIDGE_ERRORS.ACROSS_NATIVE_VALUE_MISMATCH);
|
|
29
|
-
return applyAcrossMessage({
|
|
30
|
-
aggregatorId: 'across',
|
|
31
|
-
method: 'depositNative',
|
|
32
|
-
kind: 'bridge',
|
|
33
|
-
depositor: asString(args.depositor),
|
|
34
|
-
sourceToken: NATIVE_TOKEN,
|
|
35
|
-
sourceAmount: inputAmount > 0n ? inputAmount : value,
|
|
36
|
-
bridgeToken: asString(args.inputToken),
|
|
37
|
-
bridgeAmount: inputAmount > 0n ? inputAmount : value,
|
|
38
|
-
destinationChainId: asBigint(args.destinationChainId),
|
|
39
|
-
receiver: accountFromBytes32(asString(args.recipient)),
|
|
40
|
-
outputToken: accountFromBytes32(asString(args.outputToken)),
|
|
41
|
-
minOutputAmount: asBigint(args.outputAmount),
|
|
42
|
-
spokePool: asString(args.spokePool),
|
|
43
|
-
}, asString(args.message));
|
|
44
|
-
},
|
|
45
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { applyAcrossMessage } from '../destination.js';
|
|
2
|
-
import { asBigint, asString, decodeCall } from '../abi.js';
|
|
3
|
-
import { accountFromBytes32 } from '../hex.js';
|
|
4
|
-
const fields = [
|
|
5
|
-
{ name: 'depositor', kind: 'bytes', size: 32 },
|
|
6
|
-
{ name: 'recipient', kind: 'bytes', size: 32 },
|
|
7
|
-
{ name: 'inputToken', kind: 'bytes', size: 32 },
|
|
8
|
-
{ name: 'outputToken', kind: 'bytes', size: 32 },
|
|
9
|
-
{ name: 'inputAmount', kind: 'uint' },
|
|
10
|
-
{ name: 'outputAmount', kind: 'uint' },
|
|
11
|
-
{ name: 'destinationChainId', kind: 'uint' },
|
|
12
|
-
{ name: 'exclusiveRelayer', kind: 'bytes', size: 32 },
|
|
13
|
-
{ name: 'fillDeadlineOffset', kind: 'uint' },
|
|
14
|
-
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
15
|
-
{ name: 'message', kind: 'bytes' },
|
|
16
|
-
];
|
|
17
|
-
export const depositNow = {
|
|
18
|
-
name: 'depositNow',
|
|
19
|
-
selector: '0xea86bd46',
|
|
20
|
-
decode(data) {
|
|
21
|
-
const args = decodeCall(fields, data);
|
|
22
|
-
return applyAcrossMessage({
|
|
23
|
-
aggregatorId: 'across',
|
|
24
|
-
method: 'depositNow',
|
|
25
|
-
kind: 'bridge',
|
|
26
|
-
depositor: accountFromBytes32(asString(args.depositor)),
|
|
27
|
-
sourceToken: accountFromBytes32(asString(args.inputToken)),
|
|
28
|
-
sourceAmount: asBigint(args.inputAmount),
|
|
29
|
-
destinationChainId: asBigint(args.destinationChainId),
|
|
30
|
-
receiver: accountFromBytes32(asString(args.recipient)),
|
|
31
|
-
outputToken: accountFromBytes32(asString(args.outputToken)),
|
|
32
|
-
minOutputAmount: asBigint(args.outputAmount),
|
|
33
|
-
}, asString(args.message));
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { applyAcrossMessage } from '../destination.js';
|
|
2
|
-
import { asBigint, asString, decodeCall } from '../abi.js';
|
|
3
|
-
const fields = [
|
|
4
|
-
{ name: 'depositor', kind: 'address' },
|
|
5
|
-
{ name: 'recipient', kind: 'address' },
|
|
6
|
-
{ name: 'inputToken', kind: 'address' },
|
|
7
|
-
{ name: 'outputToken', kind: 'address' },
|
|
8
|
-
{ name: 'inputAmount', kind: 'uint' },
|
|
9
|
-
{ name: 'outputAmount', kind: 'uint' },
|
|
10
|
-
{ name: 'destinationChainId', kind: 'uint' },
|
|
11
|
-
{ name: 'exclusiveRelayer', kind: 'address' },
|
|
12
|
-
{ name: 'quoteTimestamp', kind: 'uint' },
|
|
13
|
-
{ name: 'fillDeadline', kind: 'uint' },
|
|
14
|
-
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
15
|
-
{ name: 'message', kind: 'bytes' },
|
|
16
|
-
];
|
|
17
|
-
export const depositV3 = {
|
|
18
|
-
name: 'depositV3',
|
|
19
|
-
selector: '0x7b939232',
|
|
20
|
-
decode(data) {
|
|
21
|
-
const args = decodeCall(fields, data);
|
|
22
|
-
return applyAcrossMessage({
|
|
23
|
-
aggregatorId: 'across',
|
|
24
|
-
method: 'depositV3',
|
|
25
|
-
kind: 'bridge',
|
|
26
|
-
depositor: asString(args.depositor),
|
|
27
|
-
sourceToken: asString(args.inputToken),
|
|
28
|
-
sourceAmount: asBigint(args.inputAmount),
|
|
29
|
-
destinationChainId: asBigint(args.destinationChainId),
|
|
30
|
-
receiver: asString(args.recipient),
|
|
31
|
-
outputToken: asString(args.outputToken),
|
|
32
|
-
minOutputAmount: asBigint(args.outputAmount),
|
|
33
|
-
}, asString(args.message));
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { applyAcrossMessage } from '../destination.js';
|
|
2
|
-
import { asBigint, asString, decodeCall } from '../abi.js';
|
|
3
|
-
const fields = [
|
|
4
|
-
{ name: 'depositor', kind: 'address' },
|
|
5
|
-
{ name: 'recipient', kind: 'address' },
|
|
6
|
-
{ name: 'inputToken', kind: 'address' },
|
|
7
|
-
{ name: 'outputToken', kind: 'address' },
|
|
8
|
-
{ name: 'inputAmount', kind: 'uint' },
|
|
9
|
-
{ name: 'outputAmount', kind: 'uint' },
|
|
10
|
-
{ name: 'destinationChainId', kind: 'uint' },
|
|
11
|
-
{ name: 'exclusiveRelayer', kind: 'address' },
|
|
12
|
-
{ name: 'fillDeadlineOffset', kind: 'uint' },
|
|
13
|
-
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
14
|
-
{ name: 'message', kind: 'bytes' },
|
|
15
|
-
];
|
|
16
|
-
export const depositV3Now = {
|
|
17
|
-
name: 'depositV3Now',
|
|
18
|
-
selector: '0x7aef642c',
|
|
19
|
-
decode(data) {
|
|
20
|
-
const args = decodeCall(fields, data);
|
|
21
|
-
return applyAcrossMessage({
|
|
22
|
-
aggregatorId: 'across',
|
|
23
|
-
method: 'depositV3Now',
|
|
24
|
-
kind: 'bridge',
|
|
25
|
-
depositor: asString(args.depositor),
|
|
26
|
-
sourceToken: asString(args.inputToken),
|
|
27
|
-
sourceAmount: asBigint(args.inputAmount),
|
|
28
|
-
destinationChainId: asBigint(args.destinationChainId),
|
|
29
|
-
receiver: asString(args.recipient),
|
|
30
|
-
outputToken: asString(args.outputToken),
|
|
31
|
-
minOutputAmount: asBigint(args.outputAmount),
|
|
32
|
-
}, asString(args.message));
|
|
33
|
-
},
|
|
34
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { BridgeCallExpectation } from '../expect.js';
|
|
2
|
-
import type { BridgeCheck, DecodeHit } from '../types.js';
|
|
3
|
-
export declare const decodeAcross: (data: string, value: bigint) => DecodeHit;
|
|
4
|
-
export declare const validateAcross: (data: string, value: bigint, expectation?: BridgeCallExpectation, chainId?: string) => BridgeCheck;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { matchMethod } from '../match.js';
|
|
2
|
-
import { finishCheck } from '../expect.js';
|
|
3
|
-
import { deposit } from './deposit.js';
|
|
4
|
-
import { depositNative } from './depositNative.js';
|
|
5
|
-
import { depositNow } from './depositNow.js';
|
|
6
|
-
import { depositV3 } from './depositV3.js';
|
|
7
|
-
import { depositV3Now } from './depositV3Now.js';
|
|
8
|
-
import { swapAndBridge } from './swapAndBridge.js';
|
|
9
|
-
import { acrossFailure } from './validate.js';
|
|
10
|
-
const METHODS = [
|
|
11
|
-
depositV3,
|
|
12
|
-
deposit,
|
|
13
|
-
depositV3Now,
|
|
14
|
-
depositNow,
|
|
15
|
-
depositNative,
|
|
16
|
-
swapAndBridge,
|
|
17
|
-
];
|
|
18
|
-
export const decodeAcross = (data, value) => matchMethod(METHODS, data, value);
|
|
19
|
-
export const validateAcross = (data, value, expectation, chainId = '') => {
|
|
20
|
-
const hit = decodeAcross(data, value);
|
|
21
|
-
if (!hit.ok) {
|
|
22
|
-
return { ...hit, aggregatorId: 'across' };
|
|
23
|
-
}
|
|
24
|
-
return finishCheck('across', hit.parsed, acrossFailure(hit.parsed, chainId, expectation?.userAddress), expectation, chainId, {
|
|
25
|
-
fromToken: true,
|
|
26
|
-
fromAmount: true,
|
|
27
|
-
toToken: true,
|
|
28
|
-
toAmount: true,
|
|
29
|
-
receiver: true,
|
|
30
|
-
});
|
|
31
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { BRIDGE_ERRORS, BridgeError } from '../../errors/index.js';
|
|
2
|
-
import { applyAcrossMessage } from '../destination.js';
|
|
3
|
-
import { asBigint, asRecord, asString, decodeCall } from '../abi.js';
|
|
4
|
-
import { accountFromBytes32 } from '../hex.js';
|
|
5
|
-
import { NATIVE_TOKEN } from '../protocols.js';
|
|
6
|
-
const swapAndDepositData = {
|
|
7
|
-
name: 'swapAndDepositData',
|
|
8
|
-
kind: 'tuple',
|
|
9
|
-
components: [
|
|
10
|
-
{
|
|
11
|
-
name: 'submissionFees',
|
|
12
|
-
kind: 'tuple',
|
|
13
|
-
components: [
|
|
14
|
-
{ name: 'amount', kind: 'uint' },
|
|
15
|
-
{ name: 'recipient', kind: 'address' },
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'depositData',
|
|
20
|
-
kind: 'tuple',
|
|
21
|
-
components: [
|
|
22
|
-
{ name: 'inputToken', kind: 'address' },
|
|
23
|
-
{ name: 'outputToken', kind: 'bytes', size: 32 },
|
|
24
|
-
{ name: 'outputAmount', kind: 'uint' },
|
|
25
|
-
{ name: 'depositor', kind: 'address' },
|
|
26
|
-
{ name: 'recipient', kind: 'bytes', size: 32 },
|
|
27
|
-
{ name: 'destinationChainId', kind: 'uint' },
|
|
28
|
-
{ name: 'exclusiveRelayer', kind: 'bytes', size: 32 },
|
|
29
|
-
{ name: 'quoteTimestamp', kind: 'uint' },
|
|
30
|
-
{ name: 'fillDeadline', kind: 'uint' },
|
|
31
|
-
{ name: 'exclusivityParameter', kind: 'uint' },
|
|
32
|
-
{ name: 'message', kind: 'bytes' },
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
{ name: 'swapToken', kind: 'address' },
|
|
36
|
-
{ name: 'exchange', kind: 'address' },
|
|
37
|
-
{ name: 'transferType', kind: 'uint' },
|
|
38
|
-
{ name: 'swapTokenAmount', kind: 'uint' },
|
|
39
|
-
{ name: 'minExpectedInputTokenAmount', kind: 'uint' },
|
|
40
|
-
{ name: 'routerCalldata', kind: 'bytes' },
|
|
41
|
-
{ name: 'enableProportionalAdjustment', kind: 'bool' },
|
|
42
|
-
{ name: 'spokePool', kind: 'address' },
|
|
43
|
-
{ name: 'nonce', kind: 'uint' },
|
|
44
|
-
],
|
|
45
|
-
};
|
|
46
|
-
export const swapAndBridge = {
|
|
47
|
-
name: 'swapAndBridge',
|
|
48
|
-
selector: '0x110560ad',
|
|
49
|
-
decode(data, value) {
|
|
50
|
-
const args = asRecord(decodeCall([swapAndDepositData], data).swapAndDepositData);
|
|
51
|
-
const depositData = asRecord(args.depositData);
|
|
52
|
-
const sourceAmount = asBigint(args.swapTokenAmount);
|
|
53
|
-
if (value > 0n && value !== sourceAmount)
|
|
54
|
-
throw new BridgeError(BRIDGE_ERRORS.ACROSS_SWAP_VALUE_MISMATCH);
|
|
55
|
-
return applyAcrossMessage({
|
|
56
|
-
aggregatorId: 'across',
|
|
57
|
-
method: 'swapAndBridge',
|
|
58
|
-
kind: 'bridge',
|
|
59
|
-
depositor: asString(depositData.depositor),
|
|
60
|
-
sourceToken: value > 0n ? NATIVE_TOKEN : asString(args.swapToken),
|
|
61
|
-
sourceAmount,
|
|
62
|
-
destinationChainId: asBigint(depositData.destinationChainId),
|
|
63
|
-
receiver: accountFromBytes32(asString(depositData.recipient)),
|
|
64
|
-
outputToken: accountFromBytes32(asString(depositData.outputToken)),
|
|
65
|
-
minOutputAmount: asBigint(depositData.outputAmount),
|
|
66
|
-
spokePool: asString(args.spokePool),
|
|
67
|
-
innerTarget: asString(args.exchange),
|
|
68
|
-
}, asString(depositData.message));
|
|
69
|
-
},
|
|
70
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { BRIDGE_ERRORS } from '../../errors/index.js';
|
|
2
|
-
import { getBridgeRouter } from '../../list.js';
|
|
3
|
-
import { evmChainId } from '../chains.js';
|
|
4
|
-
import { isZeroWord } from '../hex.js';
|
|
5
|
-
export const acrossFailure = (parsed, chainId, expectedDepositor) => {
|
|
6
|
-
if (expectedDepositor && parsed.depositor?.toLowerCase() !== expectedDepositor.toLowerCase()) {
|
|
7
|
-
return BRIDGE_ERRORS.DEPOSITOR_MISMATCH;
|
|
8
|
-
}
|
|
9
|
-
if (parsed.destinationChainId === undefined || parsed.destinationChainId <= 0n) {
|
|
10
|
-
return BRIDGE_ERRORS.MISSING_DESTINATION_CHAIN;
|
|
11
|
-
}
|
|
12
|
-
if (isZeroWord(parsed.receiver ?? parsed.bridgeReceiver)) {
|
|
13
|
-
return BRIDGE_ERRORS.MISSING_RECEIVER;
|
|
14
|
-
}
|
|
15
|
-
if ((parsed.sourceAmount ?? 0n) <= 0n) {
|
|
16
|
-
return BRIDGE_ERRORS.MISSING_SOURCE_AMOUNT;
|
|
17
|
-
}
|
|
18
|
-
if (!parsed.spokePool) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const spoke = parsed.spokePool.toLowerCase();
|
|
22
|
-
// BSC's configured outer router is a periphery, separate from its canonical SpokePool.
|
|
23
|
-
const expectedSpoke = evmChainId(chainId) === 56n
|
|
24
|
-
? '0x4e8e101924ede233c13e2d8622dc8aed2872d505'
|
|
25
|
-
: getBridgeRouter('across', chainId)?.toLowerCase();
|
|
26
|
-
if (expectedSpoke !== spoke) {
|
|
27
|
-
return BRIDGE_ERRORS.SPOKE_POOL_IS_NOT_IN_THE_ALLOWLIST;
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
};
|
package/dist/calldata/chains.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { CHAIN_ENUM_TO_SERVER_ID, normalizeChainEnum } from '../chains.js';
|
|
2
|
-
const CHAIN_IDS = {
|
|
3
|
-
eth: 1n, op: 10n, flr: 14n, cro: 25n, rsk: 30n, xdc: 50n, bsc: 56n,
|
|
4
|
-
xdai: 100n, fuse: 122n, uni: 130n, matic: 137n, monad: 143n, sonic: 146n,
|
|
5
|
-
manta: 169n, xlayer: 196n, opbnb: 204n, lens: 232n, frax: 252n, era: 324n,
|
|
6
|
-
stable: 988n, hyper: 999n, metis: 1088n, lisk: 1135n, sei: 1329n, story: 1514n,
|
|
7
|
-
gravity: 1625n, soneium: 1868n, swell: 1923n, ron: 2020n, abs: 2741n,
|
|
8
|
-
morph: 2818n, tempo: 4217n, megaeth: 4326n, hood: 4663n, world: 480n,
|
|
9
|
-
mnt: 5000n, arc: 5042n, cyber: 7560n, klay: 8217n, base: 8453n, plasma: 9745n,
|
|
10
|
-
ape: 33139n, mode: 34443n, arb: 42161n, celo: 42220n, hemi: 43111n, avax: 43114n,
|
|
11
|
-
zircuit: 48900n, sophon: 50104n, ink: 57073n, linea: 59144n, bob: 60808n,
|
|
12
|
-
bera: 80094n, blast: 81457n, plume: 98866n, taiko: 167000n, scrl: 534352n,
|
|
13
|
-
katana: 747474n, zora: 7777777n,
|
|
14
|
-
ethereum: 1n, optimism: 10n, gnosis: 100n, polygon: 137n, mantle: 5000n,
|
|
15
|
-
arbitrum: 42161n, avalanche: 43114n, fraxtal: 252n,
|
|
16
|
-
};
|
|
17
|
-
export const evmChainId = (chain) => {
|
|
18
|
-
if (/^\d+$/.test(chain)) {
|
|
19
|
-
const id = BigInt(chain);
|
|
20
|
-
return id > 0n ? id : undefined;
|
|
21
|
-
}
|
|
22
|
-
const chainEnum = normalizeChainEnum(chain);
|
|
23
|
-
return CHAIN_IDS[chainEnum ? CHAIN_ENUM_TO_SERVER_ID[chainEnum] : chain.toLowerCase()];
|
|
24
|
-
};
|
|
25
|
-
export const sourceChainMismatch = (expected, actual) => {
|
|
26
|
-
if (actual === undefined)
|
|
27
|
-
return false;
|
|
28
|
-
try {
|
|
29
|
-
return (typeof actual === 'number' && !Number.isSafeInteger(actual)) ||
|
|
30
|
-
evmChainId(expected) === undefined || BigInt(actual) !== evmChainId(expected);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type AbiParam, type AbiValue } from './abi.js';
|
|
2
|
-
import type { ParsedBridgeCall } from './types.js';
|
|
3
|
-
export declare const destinationCall: AbiParam;
|
|
4
|
-
export declare const readTransfer: (target: string, data: string, value: bigint) => Partial<ParsedBridgeCall> | undefined;
|
|
5
|
-
export declare const readDestinationTransfers: (calls: AbiValue[]) => Partial<ParsedBridgeCall>;
|
|
6
|
-
export declare const applyAcrossMessage: (parsed: ParsedBridgeCall, message: string) => ParsedBridgeCall;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { BRIDGE_ERRORS, BridgeError, asBridgeError } from '../errors/index.js';
|
|
2
|
-
import { asArray, asBigint, asRecord, asString, decodeCall, decodeParameters } from './abi.js';
|
|
3
|
-
import { isZeroWord, readSelector } from './hex.js';
|
|
4
|
-
import { NATIVE_TOKEN, WRAPPED_NATIVE_TOKENS, subtractFees } from './protocols.js';
|
|
5
|
-
import { calldataDiagnostics } from './diagnostics.js';
|
|
6
|
-
export const destinationCall = {
|
|
7
|
-
name: 'call', kind: 'tuple', components: [
|
|
8
|
-
{ name: 'target', kind: 'address' }, { name: 'data', kind: 'bytes' }, { name: 'value', kind: 'uint' },
|
|
9
|
-
],
|
|
10
|
-
};
|
|
11
|
-
export const readTransfer = (target, data, value) => {
|
|
12
|
-
if (data === '0x' && value > 0n)
|
|
13
|
-
return { receiver: target, outputToken: NATIVE_TOKEN, minOutputAmount: value };
|
|
14
|
-
if (readSelector(data) !== '0xa9059cbb')
|
|
15
|
-
return undefined;
|
|
16
|
-
const args = decodeCall([{ name: 'to', kind: 'address' }, { name: 'amount', kind: 'uint' }], data);
|
|
17
|
-
return { receiver: asString(args.to), outputToken: target, minOutputAmount: asBigint(args.amount) };
|
|
18
|
-
};
|
|
19
|
-
export const readDestinationTransfers = (calls) => {
|
|
20
|
-
const diagnostics = { destinationCallCount: calls.length,
|
|
21
|
-
destinationSelectors: [...new Set(calls.map((call) => calldataDiagnostics(asRecord(call).data).selector)
|
|
22
|
-
.filter((selector) => Boolean(selector)))].slice(0, 16) };
|
|
23
|
-
const transfers = calls.map((call) => {
|
|
24
|
-
const c = asRecord(call);
|
|
25
|
-
return readTransfer(asString(c.target), asString(c.data), asBigint(c.value));
|
|
26
|
-
});
|
|
27
|
-
if (!transfers.length || transfers.some((transfer) => !transfer))
|
|
28
|
-
return { diagnostics };
|
|
29
|
-
const first = transfers[0];
|
|
30
|
-
if (!transfers.every((transfer) => transfer !== undefined && transfer.receiver === first.receiver && transfer.outputToken === first.outputToken))
|
|
31
|
-
return { diagnostics };
|
|
32
|
-
return { ...first, diagnostics, minOutputAmount: transfers.reduce((sum, transfer) => sum + (transfer?.minOutputAmount ?? 0n), 0n) };
|
|
33
|
-
};
|
|
34
|
-
const instructions = {
|
|
35
|
-
name: 'instructions', kind: 'tuple', components: [
|
|
36
|
-
{ name: 'calls', kind: 'array', item: { name: 'call', kind: 'tuple', components: [
|
|
37
|
-
{ name: 'target', kind: 'address' }, { name: 'callData', kind: 'bytes' }, { name: 'value', kind: 'uint' },
|
|
38
|
-
] } },
|
|
39
|
-
{ name: 'fallbackRecipient', kind: 'address' },
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
const ACROSS_MESSAGE_HANDLERS = {
|
|
43
|
-
999: '0x5e7840e06faccb6d1c3b5f5e0d1d3d07f2829bba',
|
|
44
|
-
4663: '0xa8ad2e87e2043711d8bec77e8bc3e2683c0ab6bd',
|
|
45
|
-
43114: '0x9610954acdca5ff7905f051a040ce33fe613c60e',
|
|
46
|
-
};
|
|
47
|
-
const readAcrossMessage = (parsed, message) => {
|
|
48
|
-
if (message === '0x') {
|
|
49
|
-
const wrapped = WRAPPED_NATIVE_TOKENS[parsed.destinationChainId?.toString() ?? ''];
|
|
50
|
-
if (parsed.outputToken !== undefined && (wrapped === undefined || parsed.outputToken === wrapped)) {
|
|
51
|
-
parsed.bridgeOutputToken = parsed.outputToken;
|
|
52
|
-
parsed.outputTokenReference = { protocol: 'across-native', token: parsed.outputToken,
|
|
53
|
-
destinationChainId: parsed.destinationChainId, destinationContract: parsed.receiver };
|
|
54
|
-
delete parsed.outputToken;
|
|
55
|
-
}
|
|
56
|
-
return parsed;
|
|
57
|
-
}
|
|
58
|
-
const handler = parsed.receiver;
|
|
59
|
-
parsed.bridgeReceiver = handler;
|
|
60
|
-
parsed.bridgeOutputToken = parsed.outputToken;
|
|
61
|
-
parsed.bridgeOutputAmount = parsed.minOutputAmount;
|
|
62
|
-
parsed.destinationCallData = message;
|
|
63
|
-
parsed.diagnostics = { hasDestinationCall: true, destinationCalldataBytes: calldataDiagnostics(message).calldataBytes };
|
|
64
|
-
delete parsed.receiver;
|
|
65
|
-
delete parsed.outputToken;
|
|
66
|
-
delete parsed.minOutputAmount;
|
|
67
|
-
// Other message handlers can implement arbitrary destination logic.
|
|
68
|
-
const expectedHandler = ACROSS_MESSAGE_HANDLERS[parsed.destinationChainId?.toString() ?? ''] ??
|
|
69
|
-
'0x0f7ae28de1c8532170ad4ee566b5801485c13a0e';
|
|
70
|
-
if (handler !== expectedHandler)
|
|
71
|
-
return parsed;
|
|
72
|
-
const emitter = parsed.destinationChainId === 43114n
|
|
73
|
-
? '0x25b15fc38d6a2c13feddd9cb51f184f7cf0d4c11' : '0xbf75133b48b0a42ab9374027902e83c5e2949034';
|
|
74
|
-
const args = asRecord(decodeParameters([instructions], message).instructions);
|
|
75
|
-
const calls = asArray(args.calls);
|
|
76
|
-
parsed.diagnostics.destinationCallCount = calls.length;
|
|
77
|
-
parsed.diagnostics.destinationSelectors = [...new Set(calls.map((call) => calldataDiagnostics(asRecord(call).callData).selector)
|
|
78
|
-
.filter((selector) => Boolean(selector)))].slice(0, 16);
|
|
79
|
-
const balances = new Map([[parsed.bridgeOutputToken, parsed.bridgeOutputAmount]]);
|
|
80
|
-
const payouts = [];
|
|
81
|
-
for (const raw of calls) {
|
|
82
|
-
const call = asRecord(raw);
|
|
83
|
-
const target = asString(call.target);
|
|
84
|
-
const data = asString(call.callData);
|
|
85
|
-
const value = asBigint(call.value);
|
|
86
|
-
const selector = readSelector(data);
|
|
87
|
-
// emitData is telemetry; its amounts are not an enforced receive floor.
|
|
88
|
-
if (selector === '0xd836083e' && target === emitter && value === 0n)
|
|
89
|
-
continue;
|
|
90
|
-
if (selector === '0xc41e8295' && target === handler) {
|
|
91
|
-
if (value !== 0n)
|
|
92
|
-
return parsed;
|
|
93
|
-
const nested = decodeCall([
|
|
94
|
-
{ name: 'target', kind: 'address' }, { name: 'data', kind: 'bytes' }, { name: 'value', kind: 'uint' },
|
|
95
|
-
{ name: 'replacements', kind: 'array', item: { name: 'replacement', kind: 'tuple', components: [
|
|
96
|
-
{ name: 'token', kind: 'address' }, { name: 'offset', kind: 'uint' },
|
|
97
|
-
] } },
|
|
98
|
-
], data);
|
|
99
|
-
const token = asString(nested.target);
|
|
100
|
-
const replacements = asArray(nested.replacements).map(asRecord);
|
|
101
|
-
const withdrawal = asString(nested.data);
|
|
102
|
-
if (readSelector(withdrawal) !== '0x2e1a7d4d' || replacements.length !== 1 ||
|
|
103
|
-
asBigint(decodeCall([{ name: 'amount', kind: 'uint' }], withdrawal).amount) !== 0n ||
|
|
104
|
-
asBigint(nested.value) !== 0n ||
|
|
105
|
-
asString(replacements[0].token) !== token || asBigint(replacements[0].offset) !== 4n || !balances.has(token) ||
|
|
106
|
-
WRAPPED_NATIVE_TOKENS[parsed.destinationChainId?.toString() ?? ''] !== token)
|
|
107
|
-
return parsed;
|
|
108
|
-
balances.set(NATIVE_TOKEN, (balances.get(NATIVE_TOKEN) ?? 0n) + (balances.get(token) ?? 0n));
|
|
109
|
-
balances.set(token, 0n);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (selector === '0xef8738d3' && target === handler) {
|
|
113
|
-
if (value !== 0n)
|
|
114
|
-
return parsed;
|
|
115
|
-
const drain = decodeCall([{ name: 'token', kind: 'address' }, { name: 'receiver', kind: 'address' }], data);
|
|
116
|
-
const token = asString(drain.token);
|
|
117
|
-
const amount = balances.get(token) ?? 0n;
|
|
118
|
-
if (amount > 0n)
|
|
119
|
-
payouts.push({ outputToken: token, minOutputAmount: amount, receiver: asString(drain.receiver) });
|
|
120
|
-
balances.set(token, 0n);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const transfer = readTransfer(target, data, value);
|
|
124
|
-
if (!transfer || !balances.has(transfer.outputToken))
|
|
125
|
-
return parsed;
|
|
126
|
-
const token = transfer.outputToken;
|
|
127
|
-
balances.set(token, subtractFees(balances.get(token) ?? 0n, transfer.minOutputAmount ?? 0n));
|
|
128
|
-
}
|
|
129
|
-
if (payouts.length === 1) {
|
|
130
|
-
const fallback = asString(args.fallbackRecipient);
|
|
131
|
-
if (!isZeroWord(fallback) && fallback !== payouts[0].receiver) {
|
|
132
|
-
throw new BridgeError(BRIDGE_ERRORS.ACROSS_FALLBACK_RECEIVER_MISMATCH);
|
|
133
|
-
}
|
|
134
|
-
if (!isZeroWord(fallback) && parsed.bridgeOutputToken !== payouts[0].outputToken) {
|
|
135
|
-
throw new BridgeError(BRIDGE_ERRORS.ACROSS_FALLBACK_TOKEN_MISMATCH);
|
|
136
|
-
}
|
|
137
|
-
Object.assign(parsed, payouts[0]);
|
|
138
|
-
}
|
|
139
|
-
return parsed;
|
|
140
|
-
};
|
|
141
|
-
export const applyAcrossMessage = (parsed, message) => {
|
|
142
|
-
try {
|
|
143
|
-
return readAcrossMessage(parsed, message);
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
throw asBridgeError(error, BRIDGE_ERRORS.CALLDATA_DECODE_FAILED, parsed.diagnostics);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { BridgeErrorContext } from '../errors/index.js';
|
|
2
|
-
/** Inspect call structure only. Never retain arguments or scan arbitrary payloads for selectors. */
|
|
3
|
-
export declare const calldataDiagnostics: (data: unknown) => BridgeErrorContext;
|
|
4
|
-
export declare const innerCallDiagnostics: (data: string, layer: "router" | "protocol") => BridgeErrorContext;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Inspect call structure only. Never retain arguments or scan arbitrary payloads for selectors. */
|
|
2
|
-
export const calldataDiagnostics = (data) => {
|
|
3
|
-
if (typeof data !== 'string')
|
|
4
|
-
return { calldataFormat: 'missing' };
|
|
5
|
-
const valid = /^0x(?:[0-9a-f]{2})*$/i.test(data);
|
|
6
|
-
const selector = /^0x[0-9a-f]{8}/i.test(data) ? data.slice(0, 10).toLowerCase() : undefined;
|
|
7
|
-
return {
|
|
8
|
-
selector,
|
|
9
|
-
calldataFormat: valid ? (data.length === 2 ? 'empty' : 'valid') : 'invalid',
|
|
10
|
-
...(valid ? { calldataBytes: (data.length - 2) / 2 } : {}),
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const innerCallDiagnostics = (data, layer) => {
|
|
14
|
-
const { selector, calldataBytes } = calldataDiagnostics(data);
|
|
15
|
-
return layer === 'router'
|
|
16
|
-
? { routerSelector: selector, routerCalldataBytes: calldataBytes }
|
|
17
|
-
: { protocolSelector: selector, protocolCalldataBytes: calldataBytes };
|
|
18
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { BridgeErrorDefinition } from '../errors/index.js';
|
|
2
|
-
import type { BridgeCheck, ParsedBridgeCall } from './types.js';
|
|
3
|
-
export type BridgeCallExpectation = {
|
|
4
|
-
userAddress: string;
|
|
5
|
-
fromTokenId: string;
|
|
6
|
-
fromTokenRawAmount: string;
|
|
7
|
-
toTokenId: string;
|
|
8
|
-
/** 目标链 id。目标币是原生币时,用它识别 `hood` 这类链 id,而不是源链 id。 */
|
|
9
|
-
toChainId?: string;
|
|
10
|
-
toTokenRawAmount?: string;
|
|
11
|
-
/** 小数滑点。0.01 表示 1%。 */
|
|
12
|
-
slippage?: string | number;
|
|
13
|
-
};
|
|
14
|
-
export type CompareMask = {
|
|
15
|
-
fromToken: boolean;
|
|
16
|
-
fromAmount: boolean;
|
|
17
|
-
toToken: boolean;
|
|
18
|
-
toAmount: boolean;
|
|
19
|
-
receiver: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare const knownCompare: (parsed: ParsedBridgeCall) => CompareMask;
|
|
22
|
-
/** Actual source payment may exceed local intent by at most 0.1%; lower payments still reject. */
|
|
23
|
-
export declare const sourceAmountMatches: (actual: bigint | undefined, expected: bigint) => boolean;
|
|
24
|
-
export declare const expectationFailures: (parsed: ParsedBridgeCall, expectation: BridgeCallExpectation, chainId: string, mask: CompareMask) => BridgeErrorDefinition[];
|
|
25
|
-
export declare const finishCheck: (aggregatorId: string, parsed: ParsedBridgeCall, structural: BridgeErrorDefinition | undefined, expectation: BridgeCallExpectation | undefined, chainId: string, mask: CompareMask) => BridgeCheck;
|