Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev to main #88

Merged
merged 63 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4922ce7
feat: initialize mono-repo (#1)
remiroyc Jan 12, 2023
c295c26
Add renovate.json (#2)
renovate[bot] Jan 16, 2023
f510cf0
feat: add all-contributors config (#3)
remiroyc Jan 16, 2023
6034781
doc: add contributing
remiroyc Jan 16, 2023
5baa486
feat(web): initial web import
gershon Jan 16, 2023
9e6f144
doc: update all-contributors configuration
remiroyc Jan 16, 2023
f15a3a8
fix(deps): update dependency eslint-plugin-react to v7.32.0
renovate[bot] Jan 16, 2023
b2aeae1
doc: update all-contributors configuration
remiroyc Jan 16, 2023
84fb00f
chore(deps): update dependency @types/node to v18.11.18
renovate[bot] Jan 16, 2023
5708428
chore(deps): update dependency @types/react-dom to v18.0.10
renovate[bot] Jan 16, 2023
f5262e6
doc: update README
remiroyc Jan 16, 2023
18d01e5
fix(deps): update dependency wagmi to v0.10.10
renovate[bot] Jan 16, 2023
489a282
fix(deps): update dependency alchemy-sdk to v2.3.0
renovate[bot] Jan 16, 2023
451af82
fix(web): typing issues
remiroyc Jan 17, 2023
83a806c
fix: prettier and eslint config
remiroyc Jan 17, 2023
086517b
chore(deps): update dependency prettier to v2.8.3
renovate[bot] Jan 16, 2023
88089cb
fix(deps): update dependency eslint-plugin-react to v7.32.1
renovate[bot] Jan 16, 2023
0ad603d
fix(deps): update dependency eslint to v8
renovate[bot] Jan 17, 2023
9ea176f
chore(deps): update dependency postcss to v8.4.21
renovate[bot] Jan 17, 2023
6321fe3
fix(deps): update dependency styled-components to v6.0.0-beta.9 (#15)
renovate[bot] Jan 28, 2023
f4d2653
fix(deps): update dependency wagmi to v0.10.11
renovate[bot] Jan 18, 2023
33f8b2d
chore(deps): update dependency @types/react to v18.0.27
renovate[bot] Jan 18, 2023
c9dab35
chore: update doc (#20)
remiroyc Jan 24, 2023
8f6043c
fix(deps): update dependency alchemy-sdk to v2.3.1 (#25)
renovate[bot] Jan 24, 2023
b043b52
fix(deps): update dependency connectkit to v1.1.2 (#27)
renovate[bot] Jan 24, 2023
b1bf362
fix(deps): update dependency wagmi to v0.10.14 (#23)
renovate[bot] Jan 24, 2023
84bb9f5
fix(deps): update dependency wagmi to v0.10.15 (#28)
renovate[bot] Jan 24, 2023
e08a6cf
fix(deps): update dependency api to v5.0.7 (#26)
renovate[bot] Jan 24, 2023
9040378
chore: update yarn.lock
remiroyc Jan 24, 2023
16140d4
fix(deps): update dependency wagmi to v0.11.0 (#32)
renovate[bot] Jan 27, 2023
3ff511b
fix(web): catch empty nfts list
remiroyc Jan 28, 2023
53365aa
fix(deps): update dependency alchemy-sdk to v2.4.0 (#30)
renovate[bot] Jan 28, 2023
8346f64
fix(deps): update dependency @headlessui/react to v1.7.8 (#33)
renovate[bot] Jan 28, 2023
394444b
fix(deps): update dependency @heroicons/react to v2.0.14 (#31)
renovate[bot] Jan 28, 2023
0c3b44c
chore(deps): update dependency prettier-plugin-tailwindcss to v0.2.2 …
renovate[bot] Jan 28, 2023
0f70726
fix(web): update abi
remiroyc Jan 30, 2023
bc75c21
feat(contracts): l1_handler
remiroyc Jan 30, 2023
348be1f
fix(deps): update dependency alchemy-sdk to v2.4.1 (#37)
renovate[bot] Jan 30, 2023
827494b
chore(deps): update dependency typescript to v4.9.5 (#36)
renovate[bot] Jan 30, 2023
26a78fa
fix(deps): update dependency eslint-plugin-react to v7.32.2 (#35)
renovate[bot] Jan 30, 2023
5eea8d3
fix(deps): update nextjs monorepo to v13.1.6 (#12)
renovate[bot] Jan 31, 2023
e43dbea
fix(deps): update dependency wagmi to v0.11.1 (#42)
renovate[bot] Jan 31, 2023
25ebb1a
fix(deps): update dependency wagmi to v0.11.2 (#49)
renovate[bot] Jan 31, 2023
8ce4e01
fix(deps): update dependency connectkit to v1.1.3 (#48)
renovate[bot] Jan 31, 2023
bc976ac
fix(deps): update dependency wagmi to v0.11.3 (#51)
renovate[bot] Feb 2, 2023
22676e8
chore(deps): update dependency prettier to v2.8.4 (#59)
renovate[bot] Feb 8, 2023
6d848c3
fix(deps): update dependency wagmi to v0.11.5 (#55)
renovate[bot] Feb 8, 2023
1eb5b08
chore(deps): update dependency lint-staged to v13.1.1 (#58)
renovate[bot] Feb 8, 2023
73ab3c5
chore(deps): update dependency @types/node to v18.13.0 (#56)
renovate[bot] Feb 8, 2023
7d34002
fix(deps): update dependency alchemy-sdk to v2.4.2 (#57)
renovate[bot] Feb 8, 2023
ca684a4
Feature/dev 1326 mono repo setup (#50)
kwiss Feb 8, 2023
8259b99
feat(contracts): deposit NFT from L1 and mint new NFT on L2 (#34)
remiroyc Feb 9, 2023
afb136d
chore: remove useless contracts
remiroyc Feb 9, 2023
10dcce2
fix(web): use proper render condition on nfts state (#77)
gershon Feb 9, 2023
40fd627
chore(deps): update dependency tailwindcss to v3.2.6 (#66)
renovate[bot] Feb 10, 2023
8184bac
fix(deps): update dependency @headlessui/react to v1.7.10 (#53)
renovate[bot] Feb 10, 2023
31376b6
chore(deps): update python docker tag to v3.11 (#68)
renovate[bot] Feb 10, 2023
5b8ec40
chore(deps): update dependency @types/mocha to v10 (#69)
renovate[bot] Feb 10, 2023
6960d80
fix(deps): update dependency @heroicons/react to v2.0.15 (#67)
renovate[bot] Feb 10, 2023
e7d6e1e
fix(deps): update dependency styled-components to v6.0.0-beta.11 (#54)
renovate[bot] Feb 10, 2023
78de56c
chore(deps): update dependency @types/react to v18.0.28 (#81)
renovate[bot] Feb 13, 2023
d60d056
fix(deps): update dependency alchemy-sdk to v2.4.3 (#80)
renovate[bot] Feb 13, 2023
ea7fec4
chore(deps): update dependency lint-staged to v13.1.2 (#82)
renovate[bot] Feb 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"projectName": "starklane",
"projectOwner": "ScreenshotLabs",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": true,
"commitConvention": "angular",
"contributorsPerLine": 7,
"linkToUsage": true,
"contributors": [
{
"login": "remiroyc",
"name": "Rémi",
"avatar_url": "https://avatars.githubusercontent.com/u/11146088?v=4",
"profile": "https://github.com/remiroyc",
"contributions": [
"code"
]
},
{
"login": "kwiss",
"name": "Christophe",
"avatar_url": "https://avatars.githubusercontent.com/u/243668?v=4",
"profile": "https://github.com/kwiss",
"contributions": [
"code",
"design"
]
},
{
"login": "gershon",
"name": "Paul",
"avatar_url": "https://avatars.githubusercontent.com/u/55589?v=4",
"profile": "https://github.com/gershon",
"contributions": [
"code"
]
}
]
}
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PRIVATE_KEY=
ALCHEMY_KEY=
HOSTNAME_L1=
HOSTNAME_L2=
ETHERSCAN_API_KEY=
L2_NETWORK=
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
settings: {
next: {
rootDir: ["apps/*/"],
},
},
};
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/**/node_modules
.pnp
.pnp.js

# testing
coverage

# next.js
.next/
out/
build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo

.env
coverage.json
typechain
typechain-types
cache
artifacts
*.key

starknet-artifacts
33 changes: 33 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
node_modules

#Hardhat files
cache
artifacts

#Python artifacts
.venv*
__pycache__
.pytest_cache

#Starknet plugin
starknet-artifacts

#NPM lock file
package-lock.json

#Environment variables file
.env

#deployment artifacts folder
deployment

# Yarn error file
yarn-error.log

# Apple related file
.DS_Store

#IDEs
.idea

starknet-artifacts/**/*.json
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing

For issues to work on, [see the issues tab](https://github.com/ScreenshotLabs/starklane/issues)

To help you get your feet wet and get you familiar with our contribution process, we have a list of **good first issues** that contain bugs that have a relatively limited scope. This is a great place to get started.
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM python:3.11

ENV HOSTNAME_L1 testnet-l1
ENV HOSTNAME_L2 testnet-l2

RUN apt update -y && apt upgrade -y && apt install curl git libssl-dev libgmp3-dev -y

# Copy folder
COPY . starklane
WORKDIR starklane

# Install Python dependencies
RUN rm -rf .venv && python -m venv .venv
RUN . .venv/bin/activate
RUN python -m pip install --upgrade pip && pip install poetry && poetry install

# Install Node 16
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get install -y nodejs

# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt update -y && \
apt install yarn -y

# Install Node dependencies
RUN yarn

# Build Cairo files
RUN yarn build:l2
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
# starklane
# Starklane

The Starklane NFT Bridge: seamless transfer of NFTs between ETH L1 & Starknet L2. Smart contracts, user-friendly interface, secure & efficient solution. Experience the future of NFT ownership today

[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

##

## ➡️ L1 - L2 Flow

- The L1 gateway sends a message to the L2 gateway

- The L2 bridge contract verifies the presence of the L1 address in the registry structure `_l1_to_l2_addresses`

- If the L2 contract doesn't exist, the Universal Deployer Contract is automatically called to deploy a default ERC-721 contract, resulting in a replica of the L1 contract on L2.

- The bridge contract has the authority to mint a new token on the deployed smart contract.

## ⬅️ L2 - L1 Flow

TBD

## Quickstart

### Install dependencies

`yarn`

### Build all packages

`yarn build`

## Disclaimer

These contracts are only given as an example. They HAVE NOT undergone any audit. They SHOULD NOT be used for any production level application.

## Contributors ✨

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/remiroyc"><img src="https://avatars.githubusercontent.com/u/11146088?v=4?s=100" width="100px;" alt="Rémi"/><br /><sub><b>Rémi</b></sub></a><br /><a href="https://github.com/ScreenshotLabs/starklane/commits?author=remiroyc" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kwiss"><img src="https://avatars.githubusercontent.com/u/243668?v=4?s=100" width="100px;" alt="Christophe"/><br /><sub><b>Christophe</b></sub></a><br /><a href="https://github.com/ScreenshotLabs/starklane/commits?author=kwiss" title="Code">💻</a> <a href="#design-kwiss" title="Design">🎨</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/gershon"><img src="https://avatars.githubusercontent.com/u/55589?v=4?s=100" width="100px;" alt="Paul"/><br /><sub><b>Paul</b></sub></a><br /><a href="https://github.com/ScreenshotLabs/starklane/commits?author=gershon" title="Code">💻</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="7">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
89 changes: 89 additions & 0 deletions apps/blockchain/contracts/ethereum/Bridge.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "./interfaces/IStarknetMessaging.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface NFTContract is IERC721 {
function name() external view returns (string memory);

function symbol() external view returns (string memory);

function tokenURI(uint256 tokenId) external view returns (string memory);
}

contract Bridge is Ownable {
IStarknetMessaging public starknetCore;
uint256 public selector;
uint256 public l2GatewayAddress;

constructor(address starknetCore_) {
require(
starknetCore_ != address(0),
"Gateway/invalid-starknet-core-address"
);
starknetCore = IStarknetMessaging(starknetCore_);
}

function setSelector(uint256 value) external onlyOwner {
selector = value;
}

function setL2GatewayAddress(uint256 value) external onlyOwner {
l2GatewayAddress = value;
}

function strToUint(string memory text) public pure returns (uint256 res) {
bytes32 stringInBytes32 = bytes32(bytes(text));
uint256 strLen = bytes(text).length; // TODO: cannot be above 32
require(strLen <= 32, "String cannot be longer than 32");

uint256 shift = 256 - 8 * strLen;

uint256 stringInUint256;
assembly {
stringInUint256 := shr(shift, stringInBytes32)
}
return stringInUint256;
}

function deposit(
address l1TokenAddress,
uint256 l2OwnerAddress,
uint256 tokenId
) public payable {
NFTContract tokenContract = NFTContract(l1TokenAddress);

// optimistic transfer, should revert if no approved or not owner
tokenContract.transferFrom(msg.sender, address(this), tokenId);

string memory symbol = tokenContract.symbol();
string memory name = tokenContract.name();
string memory tokenUri = tokenContract.tokenURI(tokenId);

uint256[] memory payload = new uint256[](6);

payload[0] = uint256(uint160(l1TokenAddress)); // l1_contract_address
payload[1] = l2OwnerAddress; // to
payload[2] = tokenId;
payload[3] = strToUint(name);
payload[4] = strToUint(symbol);
payload[5] = strToUint(tokenUri);

starknetCore.sendMessageToL2{value: msg.value}(
l2GatewayAddress,
selector,
payload
);
}

// TO REMOVE
function forceWithdraw(address l1_contract_address, uint256 tokenId)
public
onlyOwner
{
IERC721 tokenContract = NFTContract(l1_contract_address);
tokenContract.transferFrom(address(this), msg.sender, tokenId);
}
}
Loading