Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
3fd956f4
Unverified
Commit
3fd956f4
authored
Nov 14, 2023
by
smartcontracts
Committed by
GitHub
Nov 14, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8155 from ethereum-optimism/sc/sdk-bridge-check-bug
fix(sdk): bug in supportsTokenPair
parents
38c102aa
2534eabb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
37 deletions
+38
-37
good-vans-retire.md
.changeset/good-vans-retire.md
+5
-0
standard-bridge.ts
packages/sdk/src/adapters/standard-bridge.ts
+22
-35
cross-chain-messenger.ts
packages/sdk/src/cross-chain-messenger.ts
+11
-2
No files found.
.changeset/good-vans-retire.md
0 → 100644
View file @
3fd956f4
---
'
@eth-optimism/sdk'
:
patch
---
Fixed bug with tokenBridge checks throwing
packages/sdk/src/adapters/standard-bridge.ts
View file @
3fd956f4
...
@@ -156,46 +156,33 @@ export class StandardBridgeAdapter implements IBridgeAdapter {
...
@@ -156,46 +156,33 @@ export class StandardBridgeAdapter implements IBridgeAdapter {
l1Token
:
AddressLike
,
l1Token
:
AddressLike
,
l2Token
:
AddressLike
l2Token
:
AddressLike
):
Promise
<
boolean
>
{
):
Promise
<
boolean
>
{
try
{
const
contract
=
new
Contract
(
const
contract
=
new
Contract
(
toAddress
(
l2Token
),
toAddress
(
l2Token
),
optimismMintableERC20
.
abi
,
optimismMintableERC20
.
abi
,
this
.
messenger
.
l2Provider
this
.
messenger
.
l2Provider
)
)
// Don't support ETH deposits or withdrawals via this bridge.
// Don't support ETH deposits or withdrawals via this bridge.
if
(
if
(
hexStringEquals
(
toAddress
(
l1Token
),
ethers
.
constants
.
AddressZero
)
||
hexStringEquals
(
toAddress
(
l1Token
),
ethers
.
constants
.
AddressZero
)
||
hexStringEquals
(
toAddress
(
l2Token
),
predeploys
.
OVM_ETH
)
hexStringEquals
(
toAddress
(
l2Token
),
predeploys
.
OVM_ETH
)
)
{
)
{
return
false
return
false
}
}
// Make sure the L1 token matches.
const
remoteL1Token
=
await
contract
.
l1Token
()
if
(
!
hexStringEquals
(
remoteL1Token
,
toAddress
(
l1Token
)))
{
// Make sure the L1 token matches.
return
false
const
remoteL1Token
=
await
contract
.
l1Token
()
}
// Make sure the L2 bridge matches.
if
(
!
hexStringEquals
(
remoteL1Token
,
toAddress
(
l1Token
)))
{
const
remoteL2Bridge
=
await
contract
.
l2Bridge
()
return
false
if
(
!
hexStringEquals
(
remoteL2Bridge
,
this
.
l2Bridge
.
address
))
{
}
return
false
}
return
true
// Make sure the L2 bridge matches.
}
catch
(
err
)
{
const
remoteL2Bridge
=
await
contract
.
l2Bridge
()
// If the L2 token is not an L2StandardERC20, it may throw an error. If there's a call
if
(
!
hexStringEquals
(
remoteL2Bridge
,
this
.
l2Bridge
.
address
))
{
// exception then we assume that the token is not supported. Other errors are thrown. Since
// the JSON-RPC API is not well-specified, we need to handle multiple possible error codes.
if
(
!
err
?.
message
?.
toString
().
includes
(
'
CALL_EXCEPTION
'
)
&&
!
err
?.
stack
?.
toString
().
includes
(
'
execution reverted
'
)
)
{
console
.
error
(
'
Unexpected error when checking bridge
'
,
err
)
}
return
false
return
false
}
}
return
true
}
}
public
async
approval
(
public
async
approval
(
...
...
packages/sdk/src/cross-chain-messenger.ts
View file @
3fd956f4
...
@@ -490,8 +490,17 @@ export class CrossChainMessenger {
...
@@ -490,8 +490,17 @@ export class CrossChainMessenger {
):
Promise
<
IBridgeAdapter
>
{
):
Promise
<
IBridgeAdapter
>
{
const
bridges
:
IBridgeAdapter
[]
=
[]
const
bridges
:
IBridgeAdapter
[]
=
[]
for
(
const
bridge
of
Object
.
values
(
this
.
bridges
))
{
for
(
const
bridge
of
Object
.
values
(
this
.
bridges
))
{
if
(
await
bridge
.
supportsTokenPair
(
l1Token
,
l2Token
))
{
try
{
bridges
.
push
(
bridge
)
if
(
await
bridge
.
supportsTokenPair
(
l1Token
,
l2Token
))
{
bridges
.
push
(
bridge
)
}
}
catch
(
err
)
{
if
(
!
err
?.
message
?.
toString
().
includes
(
'
CALL_EXCEPTION
'
)
&&
!
err
?.
stack
?.
toString
().
includes
(
'
execution reverted
'
)
)
{
console
.
error
(
'
Unexpected error when checking bridge
'
,
err
)
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment