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
8708ef22
Commit
8708ef22
authored
Jun 17, 2021
by
elenadimitrova
Committed by
Elena Gesheva
Jun 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Factory contract for creating standard ERC20 tokens
compliant with the standard bridge
parent
21e47e1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
0 deletions
+100
-0
OVM_L2StandardTokenFactory.sol
...ethereum/OVM/bridge/tokens/OVM_L2StandardTokenFactory.sol
+41
-0
L2StandardERC20.sol
...timistic-ethereum/libraries/standards/L2StandardERC20.sol
+1
-0
OVM_L2StandardTokenFactory.spec.ts
...acts/OVM/bridge/assets/OVM_L2StandardTokenFactory.spec.ts
+58
-0
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L2StandardTokenFactory.sol
0 → 100644
View file @
8708ef22
// SPDX-License-Identifier: MIT
pragma solidity >0.5.0 <0.8.0;
pragma experimental ABIEncoderV2;
/* Contract Imports */
import { L2StandardERC20 } from "../../../libraries/standards/L2StandardERC20.sol";
import { Lib_PredeployAddresses } from "../../../libraries/constants/Lib_PredeployAddresses.sol";
/**
* @title OVM_L2StandardTokenFactory
* @dev Factory contract for creating standard L2 token representations of L1 ERC20s
* compatible with and working on the standard bridge.
* Compiler used: optimistic-solc
* Runtime target: OVM
*/
contract OVM_L2StandardTokenFactory {
event StandardL2TokenCreated(address indexed _l1Token, address indexed _l2Token);
/**
* @dev Creates an instance of the standard ERC20 token on L2.
* @param _l1Token Address of the corresponding L1 token.
* @param _name ERC20 name.
* @param _symbol ERC20 symbol.
*/
function createStandardL2Token(
address _l1Token,
string memory _name,
string memory _symbol
)
external
{
L2StandardERC20 l2Token = new L2StandardERC20(
Lib_PredeployAddresses.L2_STANDARD_BRIDGE,
_l1Token,
_name,
_symbol);
emit StandardL2TokenCreated(_l1Token, address(l2Token));
}
}
packages/contracts/contracts/optimistic-ethereum/libraries/standards/L2StandardERC20.sol
View file @
8708ef22
...
...
@@ -10,6 +10,7 @@ contract L2StandardERC20 is IL2StandardERC20, ERC20 {
address public l2Bridge;
/**
* @param _l2Bridge Address of the L2 standard bridge.
* @param _l1Token Address of the corresponding L1 token.
* @param _name ERC20 name.
* @param _symbol ERC20 symbol.
...
...
packages/contracts/test/contracts/OVM/bridge/assets/OVM_L2StandardTokenFactory.spec.ts
0 → 100644
View file @
8708ef22
import
{
expect
}
from
'
../../../../setup
'
/* External Imports */
import
{
ethers
}
from
'
hardhat
'
import
{
Signer
,
ContractFactory
,
Contract
}
from
'
ethers
'
import
{
smoddit
}
from
'
@eth-optimism/smock
'
import
{
getContractInterface
}
from
'
@eth-optimism/contracts
'
/* Internal Imports */
import
{
NON_NULL_BYTES32
,
NON_ZERO_ADDRESS
}
from
'
../../../../helpers
'
import
{
predeploys
}
from
'
../../../../../src
'
describe
(
'
OVM_L2StandardTokenFactory
'
,
()
=>
{
let
signer
:
Signer
let
Factory__L1ERC20
:
ContractFactory
let
L1ERC20
:
Contract
let
OVM_L2StandardTokenFactory
:
Contract
before
(
async
()
=>
{
;[
signer
]
=
await
ethers
.
getSigners
()
// deploy an ERC20 contract on L1
Factory__L1ERC20
=
await
smoddit
(
'
@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20
'
)
L1ERC20
=
await
Factory__L1ERC20
.
deploy
(
'
L1ERC20
'
,
'
ERC
'
)
OVM_L2StandardTokenFactory
=
await
(
await
ethers
.
getContractFactory
(
'
OVM_L2StandardTokenFactory
'
)
).
deploy
()
})
describe
(
'
Standard token factory
'
,
()
=>
{
it
(
'
should be able to create a standard token
'
,
async
()
=>
{
const
tx
=
await
OVM_L2StandardTokenFactory
.
createStandardL2Token
(
L1ERC20
.
address
,
'
L2ERC20
'
,
'
ERC
'
)
const
receipt
=
await
tx
.
wait
()
const
[
tokenCreatedEvent
]
=
receipt
.
events
// Expect there to be an event emmited for the standard token creation
expect
(
tokenCreatedEvent
.
event
).
to
.
be
.
eq
(
'
StandardL2TokenCreated
'
)
// Get the L2 token address from the emmited event and check it was created correctly
const
l2TokenAddress
=
tokenCreatedEvent
.
args
.
_l2Token
const
l2Token
=
new
Contract
(
l2TokenAddress
,
getContractInterface
(
'
L2StandardERC20
'
),
signer
)
expect
(
await
l2Token
.
l2Bridge
()).
to
.
equal
(
predeploys
.
OVM_L2StandardBridge
)
expect
(
await
l2Token
.
l1Token
()).
to
.
equal
(
L1ERC20
.
address
)
expect
(
await
l2Token
.
name
()).
to
.
equal
(
'
L2ERC20
'
)
expect
(
await
l2Token
.
symbol
()).
to
.
equal
(
'
ERC
'
)
})
})
})
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