Skip to content

Commit fbf8b86

Browse files
feat: add core interop resource (#44)
* feat: add core interop resource * fix: aggregate approvals for the same token * fix: formatting * refactor: interop implementation * refactor: remove error helpers * fix: formatting * fix: remove unused constants
1 parent 338f75f commit fbf8b86

File tree

42 files changed

+3975
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3975
-139
lines changed

docs/src/sdk-reference/core/rpc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ type ProofNormalized = {
119119
id: bigint;
120120
batchNumber: bigint;
121121
proof: Hex[];
122+
root: Hex;
122123
};
123124

124125
type ReceiptWithL2ToL1 = {

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"access": "public"
4343
},
4444
"exports": {
45+
"./types/flows/interop": null,
46+
"./core/types/flows/interop": null,
47+
"./core/resources/interop/*": null,
4548
".": {
4649
"types": "./dist/index.d.ts",
4750
"import": "./dist/index.js",

src/adapters/ethers/resources/withdrawals/services/finalization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { IL1NullifierABI } from '../../../../../core/abi.ts';
1515

1616
import { L2_ASSET_ROUTER_ADDRESS, L1_MESSENGER_ADDRESS } from '../../../../../core/constants';
17-
import { findL1MessageSentLog } from '../../../../../core/resources/withdrawals/events';
17+
import { findL1MessageSentLog } from '../../../../../core/utils/events';
1818
import { messengerLogIndex } from '../../../../../core/resources/withdrawals/logs';
1919
import { createErrorHandlers } from '../../../errors/error-ops';
2020
import { classifyReadinessFromRevert } from '../../../errors/revert';

src/adapters/viem/resources/withdrawals/services/finalization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111

1212
import { IL1NullifierABI } from '../../../../../core/abi.ts';
1313
import { L2_ASSET_ROUTER_ADDRESS, L1_MESSENGER_ADDRESS } from '../../../../../core/constants';
14-
import { findL1MessageSentLog } from '../../../../../core/resources/withdrawals/events';
14+
import { findL1MessageSentLog } from '../../../../../core/utils/events';
1515
import { messengerLogIndex } from '../../../../../core/resources/withdrawals/logs';
1616
import { createErrorHandlers } from '../../../errors/error-ops';
1717
import { classifyReadinessFromRevert } from '../../../errors/revert';

src/core/abi.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ export { default as L1NativeTokenVaultABI } from './internal/abis/L1NativeTokenV
88
export { default as L2NativeTokenVaultABI } from './internal/abis/L2NativeTokenVault';
99
export { default as IBaseTokenABI } from './internal/abis/IBaseToken';
1010
export { default as IERC20ABI } from './internal/abis/IERC20';
11+
export { default as IERC7786AttributesABI } from './internal/abis/IERC7786Attributes';
1112
export { default as MailboxABI } from './internal/abis/Mailbox';
13+
export { default as InteropCenterABI } from './internal/abis/InteropCenter';
14+
export { default as IInteropHandlerABI } from './internal/abis/IInteropHandler';
15+
export { default as InteropRootStorageABI } from './internal/abis/InteropRootStorage';
16+
export { default as L2MessageVerificationABI } from './internal/abis/L2MessageVerification';

src/core/constants.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,26 @@ export const L1_MESSENGER_ADDRESS: Address = '0x00000000000000000000000000000000
3131
/** L2 Base Token System contract address. */
3232
export const L2_BASE_TOKEN_ADDRESS: Address = '0x000000000000000000000000000000000000800A';
3333

34+
/** The address of the L2 InteropCenter contract.*/
35+
export const L2_INTEROP_CENTER_ADDRESS: Address = '0x000000000000000000000000000000000001000d';
36+
37+
/** The address of the L2 InteropHandler contract.*/
38+
export const L2_INTEROP_HANDLER_ADDRESS: Address = '0x000000000000000000000000000000000001000e';
39+
40+
/** The address of the L2 InteropRootStorage contract. */
41+
export const L2_INTEROP_ROOT_STORAGE_ADDRESS: Address =
42+
'0x0000000000000000000000000000000000010008';
43+
44+
/** L2 Message Verification contract address. */
45+
export const L2_MESSAGE_VERIFICATION_ADDRESS: Address =
46+
'0x0000000000000000000000000000000000010009';
47+
3448
/** L1 token address (SOPH). */
3549
export const L1_SOPH_TOKEN_ADDRESS: Address = '0xa9544a49d4aEa4c8E074431c89C79fA9592049d8';
3650

51+
/** Prefix byte used by InteropCenter when emitting L2->L1 bundle messages. */
52+
export const BUNDLE_IDENTIFIER: Hex = '0x01';
53+
3754
// -----------------------------------------------------------------------------
3855
// Event topics
3956
// -----------------------------------------------------------------------------

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export * from './utils/addr';
2323
// Core resources (routes, events, logs)
2424
export * from './resources/deposits/route';
2525
export * from './resources/withdrawals/route';
26-
export * from './resources/withdrawals/events';
26+
export * from './utils/events';
2727
export * from './resources/withdrawals/logs';
2828

2929
// Core types (type-only)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const IERC7786AttributesABI = [
2+
{
3+
inputs: [
4+
{
5+
internalType: 'bytes',
6+
name: '_executionAddress',
7+
type: 'bytes',
8+
},
9+
],
10+
name: 'executionAddress',
11+
outputs: [],
12+
stateMutability: 'pure',
13+
type: 'function',
14+
},
15+
{
16+
inputs: [
17+
{
18+
internalType: 'uint256',
19+
name: '_indirectCallMessageValue',
20+
type: 'uint256',
21+
},
22+
],
23+
name: 'indirectCall',
24+
outputs: [],
25+
stateMutability: 'pure',
26+
type: 'function',
27+
},
28+
{
29+
inputs: [
30+
{
31+
internalType: 'uint256',
32+
name: '_interopCallValue',
33+
type: 'uint256',
34+
},
35+
],
36+
name: 'interopCallValue',
37+
outputs: [],
38+
stateMutability: 'pure',
39+
type: 'function',
40+
},
41+
{
42+
inputs: [
43+
{
44+
internalType: 'bytes',
45+
name: '_unbundlerAddress',
46+
type: 'bytes',
47+
},
48+
],
49+
name: 'unbundlerAddress',
50+
outputs: [],
51+
stateMutability: 'pure',
52+
type: 'function',
53+
},
54+
] as const;
55+
56+
export default IERC7786AttributesABI;

0 commit comments

Comments
 (0)