Skip to content

Instantly share code, notes, and snippets.

View Rizary's full-sized avatar

Andika Demas Riyandi Rizary

View GitHub Profile
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8;
import "./AdminControlled.sol";
import "./INearBridge.sol";
import "./NearDecoder.sol";
import "./Ed25519.sol";
/// Rizary: it is part of NearBridge interface and deployed on ethereum
///
pragma solidity >= 0.5.0 <0.7.0;
import "@aztec/protocol/contracts/ERC1724/ZkAssetMintable.sol";
import "@aztec/protocol/contracts/libs/NoteUtils.sol";
import "@aztec/protocol/contracts/interfaces/IZkAsset.sol";
import "./LoanUtilities.sol";
// Loan is inherit from ZkAssetMintable.sol from AZTEC protocol.
// each Loan contract represent a loan in the network.
contract Loan is ZkAssetMintable {
// Andika: this is the recursive proof system
@proofSystem
class RollupProof extends ProofWithInput<RollupStateTransition> {
// Andika: first, it has to process the deposit from L1
@branch static processDeposit(
pending: MerkleStack<RollupDeposit>, // deposit queue
accountDb: AccountDb // L2 account
): RollupProof {
let before = new RollupState(pending.commitment, accountDb.commitment()); // current L2 state
let deposit = pending.pop(); // get deposit from queue
@Rizary
Rizary / deposit.sol
Created March 28, 2022 23:26
RollupNC review
// Deposits ETH or ERC20 tokens onto L2
function deposit(
uint[2] memory pubkey,
uint amount,
uint tokenType
) public payable {
if ( tokenType == 0 ) {
// reserved the token type if sender is same as coordinator
require(
msg.sender == coordinator,
pub async fn run_core(
connection_pool: ConnectionPool,
config: &ZkSyncConfig,
eth_gateway: EthereumGateway,
) -> anyhow::Result<Vec<JoinHandle<()>>> {
let (proposed_blocks_sender, proposed_blocks_receiver) =
mpsc::channel(DEFAULT_CHANNEL_CAPACITY);
let (state_keeper_req_sender, state_keeper_req_receiver) =
mpsc::channel(DEFAULT_CHANNEL_CAPACITY);
let (eth_watch_req_sender, eth_watch_req_receiver) = mpsc::channel(DEFAULT_CHANNEL_CAPACITY);
@Rizary
Rizary / wallet_test.go
Created August 26, 2021 10:37
Test wasm wallet
package wasm_test
import (
// "fmt"
// "math"
"encoding/json"
"syscall/js"
"testing"
"net/http"
fn visit_while(&mut self, condition: &JasmExpression, body: &Block) -> () {
// // we count the length of instruction sequence before adding condition.
// let curr_seq_len = self.function_builder.get_mut().func_body().instrs().len();
// self.visit(condition);
// // TODO: Find the easiest way to split the wasm sequences.
// //
pub fn run_fmt(toml_content: &Root, cwd: PathBuf) -> anyhow::Result<()> {
let commands = toml_content
.formatters
.values()
.map(|c| c.command.clone().unwrap_or("".into()));
let args = toml_content.formatters.values().map(|c| {
let arg = match c.args.clone() {
Some(vstr) => vstr,
None => Vec::new(),
{
"name": "rust",
"version": "0.1.0",
"description": "frontend wasm in rust",
"license": "MIT",
"private": true,
"scripts": {
"todo_watch": "yarn run todo_clean && rollup -c rollup.dev.js --watch",
"todo_clean": "rimraf ./devhtml/js",
},
@Rizary
Rizary / dockertosmth.rs
Last active September 18, 2020 12:46
trying to create an async function in Rust
async fn docker_json_to_smth(arg: (Docker, &ContainerSummary)) -> () {
let (docker, csummary) = arg;
let container = docker
.inspect_container(
csummary.id.as_ref().unwrap(),
None::<InspectContainerOptions>,
)
.await
.unwrap();