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
a7b9f2e7
Unverified
Commit
a7b9f2e7
authored
Dec 08, 2021
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add CrossChainMessenger test scaffold and CrossChainERC20Pair API
parent
6b3a455a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
85 deletions
+157
-85
cross-chain-erc20-pair.ts
packages/sdk/src/interfaces/cross-chain-erc20-pair.ts
+111
-0
cross-chain-messenger.ts
packages/sdk/src/interfaces/cross-chain-messenger.ts
+0
-85
index.ts
packages/sdk/src/interfaces/index.ts
+1
-0
cross-chain-messenger.spec.ts
packages/sdk/test/cross-chain-messenger.spec.ts
+45
-0
No files found.
packages/sdk/src/interfaces/cross-chain-erc20-pair.ts
0 → 100644
View file @
a7b9f2e7
import
{
Overrides
,
Contract
}
from
'
ethers
'
import
{
TransactionRequest
,
TransactionResponse
,
}
from
'
@ethersproject/abstract-provider
'
import
{
NumberLike
,
L1ToL2Overrides
}
from
'
./types
'
import
{
ICrossChainMessenger
}
from
'
./cross-chain-messenger
'
/**
* Represents an L1<>L2 ERC20 token pair.
*/
export
interface
ICrossChainERC20Pair
{
/**
* Messenger that will be used to carry out cross-chain iteractions.
*/
messenger
:
ICrossChainMessenger
/**
* Ethers Contract object connected to the L1 token.
*/
l1Token
:
Contract
/**
* Ethers Contract object connected to the L2 token.
*/
l2Token
:
Contract
/**
* Deposits some tokens into the L2 chain.
*
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the deposit transaction.
*/
deposit
(
amount
:
NumberLike
,
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
/**
* Withdraws some tokens back to the L1 chain.
*
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the withdraw transaction.
*/
withdraw
(
amount
:
NumberLike
,
overrides
?:
Overrides
):
Promise
<
TransactionResponse
>
/**
* Object that holds the functions that generate transactions to be signed by the user.
* Follows the pattern used by ethers.js.
*/
populateTransaction
:
{
/**
* Generates a transaction for depositing some tokens into the L2 chain.
*
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
deposit
(
amount
:
NumberLike
,
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
/**
* Generates a transaction for withdrawing some tokens back to the L1 chain.
*
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdraw
(
amount
:
NumberLike
,
overrides
?:
Overrides
):
Promise
<
TransactionRequest
>
}
/**
* Object that holds the functions that estimates the gas required for a given transaction.
* Follows the pattern used by ethers.js.
*/
estimateGas
:
{
/**
* Estimates gas required to deposit some tokens into the L2 chain.
*
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
deposit
(
amount
:
NumberLike
,
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
/**
* Estimates gas required to withdraw some tokens back to the L1 chain.
*
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdraw
(
amount
:
NumberLike
,
overrides
?:
Overrides
):
Promise
<
TransactionRequest
>
}
}
packages/sdk/src/interfaces/cross-chain-messenger.ts
View file @
a7b9f2e7
...
@@ -5,7 +5,6 @@ import {
...
@@ -5,7 +5,6 @@ import {
}
from
'
@ethersproject/abstract-provider
'
}
from
'
@ethersproject/abstract-provider
'
import
{
import
{
MessageLike
,
MessageLike
,
AddressLike
,
NumberLike
,
NumberLike
,
CrossChainMessageRequest
,
CrossChainMessageRequest
,
L1ToL2Overrides
,
L1ToL2Overrides
,
...
@@ -67,20 +66,6 @@ export interface ICrossChainMessenger {
...
@@ -67,20 +66,6 @@ export interface ICrossChainMessenger {
overrides
?:
Overrides
overrides
?:
Overrides
):
Promise
<
TransactionResponse
>
):
Promise
<
TransactionResponse
>
/**
* Deposits some tokens into the L2 chain.
*
* @param token Address of the token to deposit.
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the deposit transaction.
*/
depositTokens
(
token
:
AddressLike
,
amount
:
NumberLike
,
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
/**
/**
* Deposits some ETH into the L2 chain.
* Deposits some ETH into the L2 chain.
*
*
...
@@ -93,20 +78,6 @@ export interface ICrossChainMessenger {
...
@@ -93,20 +78,6 @@ export interface ICrossChainMessenger {
overrides
?:
L1ToL2Overrides
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
):
Promise
<
TransactionResponse
>
/**
* Withdraws some tokens back to the L1 chain.
*
* @param token Address of the token to withdraw.
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the withdraw transaction.
*/
withdrawTokens
(
token
:
AddressLike
,
amount
:
NumberLike
,
overrides
?:
Overrides
):
Promise
<
TransactionResponse
>
/**
/**
* Withdraws some ETH back to the L1 chain.
* Withdraws some ETH back to the L1 chain.
*
*
...
@@ -166,20 +137,6 @@ export interface ICrossChainMessenger {
...
@@ -166,20 +137,6 @@ export interface ICrossChainMessenger {
overrides
?:
Overrides
overrides
?:
Overrides
):
Promise
<
TransactionRequest
>
):
Promise
<
TransactionRequest
>
/**
* Generates a transaction for depositing some tokens into the L2 chain.
*
* @param token Address of the token to deposit.
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
depositTokens
(
token
:
AddressLike
,
amount
:
NumberLike
,
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
/**
/**
* Generates a transaction for depositing some ETH into the L2 chain.
* Generates a transaction for depositing some ETH into the L2 chain.
*
*
...
@@ -192,20 +149,6 @@ export interface ICrossChainMessenger {
...
@@ -192,20 +149,6 @@ export interface ICrossChainMessenger {
overrides
?:
L1ToL2Overrides
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionRequest
>
):
Promise
<
TransactionRequest
>
/**
* Generates a transaction for withdrawing some tokens back to the L1 chain.
*
* @param token Address of the token to withdraw.
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdrawTokens
(
token
:
AddressLike
,
amount
:
NumberLike
,
overrides
?:
Overrides
):
Promise
<
TransactionRequest
>
/**
/**
* Generates a transaction for withdrawing some ETH back to the L1 chain.
* Generates a transaction for withdrawing some ETH back to the L1 chain.
*
*
...
@@ -262,20 +205,6 @@ export interface ICrossChainMessenger {
...
@@ -262,20 +205,6 @@ export interface ICrossChainMessenger {
overrides
?:
Overrides
overrides
?:
Overrides
):
Promise
<
TransactionRequest
>
):
Promise
<
TransactionRequest
>
/**
* Estimates gas required to deposit some tokens into the L2 chain.
*
* @param token Address of the token to deposit.
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
depositTokens
(
token
:
AddressLike
,
amount
:
NumberLike
,
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionResponse
>
/**
/**
* Estimates gas required to deposit some ETH into the L2 chain.
* Estimates gas required to deposit some ETH into the L2 chain.
*
*
...
@@ -288,20 +217,6 @@ export interface ICrossChainMessenger {
...
@@ -288,20 +217,6 @@ export interface ICrossChainMessenger {
overrides
?:
L1ToL2Overrides
overrides
?:
L1ToL2Overrides
):
Promise
<
TransactionRequest
>
):
Promise
<
TransactionRequest
>
/**
* Estimates gas required to withdraw some tokens back to the L1 chain.
*
* @param token Address of the token to withdraw.
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdrawTokens
(
token
:
AddressLike
,
amount
:
NumberLike
,
overrides
?:
Overrides
):
Promise
<
TransactionRequest
>
/**
/**
* Estimates gas required to withdraw some ETH back to the L1 chain.
* Estimates gas required to withdraw some ETH back to the L1 chain.
*
*
...
...
packages/sdk/src/interfaces/index.ts
View file @
a7b9f2e7
export
*
from
'
./cross-chain-erc20-pair
'
export
*
from
'
./cross-chain-messenger
'
export
*
from
'
./cross-chain-messenger
'
export
*
from
'
./cross-chain-provider
'
export
*
from
'
./cross-chain-provider
'
export
*
from
'
./l2-provider
'
export
*
from
'
./l2-provider
'
...
...
packages/sdk/test/cross-chain-messenger.spec.ts
0 → 100644
View file @
a7b9f2e7
/* eslint-disable @typescript-eslint/no-empty-function */
import
'
./setup
'
describe
(
'
CrossChainMessenger
'
,
()
=>
{
describe
(
'
sendMessage
'
,
()
=>
{
describe
(
'
when no l2GasLimit is provided
'
,
()
=>
{
it
(
'
should send a message with an estimated l2GasLimit
'
,
()
=>
{})
})
describe
(
'
when an l2GasLimit is provided
'
,
()
=>
{
it
(
'
should send a message with the provided l2GasLimit
'
,
()
=>
{})
})
})
describe
(
'
resendMessage
'
,
()
=>
{
describe
(
'
when the message being resent exists
'
,
()
=>
{
it
(
'
should resend the message with the new gas limit
'
,
()
=>
{})
})
describe
(
'
when the message being resent does not exist
'
,
()
=>
{
it
(
'
should throw an error
'
,
()
=>
{})
})
})
describe
(
'
finalizeMessage
'
,
()
=>
{
describe
(
'
when the message being finalized exists
'
,
()
=>
{
describe
(
'
when the message is ready to be finalized
'
,
()
=>
{
it
(
'
should finalize the message
'
,
()
=>
{})
})
describe
(
'
when the message is not ready to be finalized
'
,
()
=>
{
it
(
'
should throw an error
'
,
()
=>
{})
})
// TODO: is this the behavior we want?
describe
(
'
when the message has already been finalized
'
,
()
=>
{
it
(
'
should throw an error
'
,
()
=>
{})
})
})
describe
(
'
when the message being finalized does not exist
'
,
()
=>
{
it
(
'
should throw an error
'
,
()
=>
{})
})
})
})
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