Skip to content

Instantly share code, notes, and snippets.

View ilamanov's full-sized avatar

Nazar Ilamanov ilamanov

View GitHub Profile
/**
* @title L2StandardBridge
* @dev The L2 Standard bridge is a contract which works together with the L1 Standard bridge to
* enable ETH and ERC20 transitions between L1 and L2.
* This contract acts as a minter for new tokens when it hears about deposits into the L1 Standard
* bridge.
* This contract also acts as a burner of the tokens intended for withdrawal, informing the L1
* bridge to release L1 funds.
*/
contract L2StandardBridge is IL2ERC20Bridge, CrossDomainEnabled {
/**
* @title L1StandardBridge
* @dev The L1 ETH and ERC20 Bridge is a contract which stores deposited L1 funds and standard
* tokens that are in use on L2. It synchronizes a corresponding L2 Bridge, informing it of deposits
* and listening to it for newly finalized withdrawals.
*
*/
contract L1StandardBridge is IL1StandardBridge, CrossDomainEnabled {
function depositETHTo(
address _to,
#[program]
pub mod solana_example {
use super::*;
pub fn publish(ctx: Context<AuthorData>) -> ProgramResult {
let author_account = &mut ctx.accounts.author_account;
author_account.publications += 1;
Ok(())
}
}
contract EthereumExample {
struct Author {
uint256 publications;
uint256 likes;
}
Author public author;
function publish() public {
author.publications += 1;
pragma solidity ^0.5.0;
function tokenURI(uint256 _tokenId) external
view onlyValidTokenId(_tokenId) returns (string memory) {
// if staticIpfsImageLink is present,
// then return "{projectBaseIpfsURI}/{staticIpfsImageLink}"
if (bytes(staticIpfsImageLink[_tokenId]).length > 0) {
return Strings.strConcat(
projects[tokenIdToProjectId[_tokenId]].projectBaseIpfsURI,
pragma solidity ^0.5.0;
function updateProjectName(
uint256 _projectId,
string memory _projectName)
onlyUnlocked(_projectId)
onlyArtistOrWhitelisted(_projectId) public {
projects[_projectId].name = _projectName;
}
pragma solidity ^0.5.0;
//All financial functions are stripped from Project struct for visibility
mapping(uint256 => address) public projectIdToArtistAddress;
mapping(uint256 => string) public projectIdToCurrencySymbol;
mapping(uint256 => address) public projectIdToCurrencyAddress;
mapping(uint256 => uint256) public projectIdToPricePerTokenInWei;
mapping(uint256 => address) public projectIdToAdditionalPayee;
mapping(uint256 => uint256) public projectIdToAdditionalPayeePercentage;
pragma solidity ^0.5.0;
mapping(uint256 => Project) projects;
uint256 public nextProjectId = 3;
function addProject(
string memory _projectName,
address _artistAddress,
pragma solidity ^0.5.0;
struct Project {
string name;
string artist;
string description;
string website;
string license;
bool active;
bool locked;
pragma solidity ^0.5.0;
function totalSupply() public view returns (uint256) {
return _allTokens.length;
}
function tokenByIndex(uint256 index) public view returns (uint256) {
require(index < totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];