Skip to content

Instantly share code, notes, and snippets.

View seniorjoinu's full-sized avatar
🎯
Focusing

Alexander Vtyurin seniorjoinu

🎯
Focusing
View GitHub Profile
mod clients;
mod common;
use crate::clients::dip20::Dip20;
use crate::clients::sonic::Sonic;
use crate::clients::xtc::{XTCBurnPayload, XTC};
use crate::common::guards::controller_guard;
use crate::common::types::{Currency, LimitOrder, MarketOrder, Order, OrderDirective, TargetPrice};
use bigdecimal::num_bigint::{BigInt, ToBigInt};
use bigdecimal::num_traits::Pow;
use async_trait::async_trait;
use ic_cdk::api::call::CallResult;
use ic_cdk::call;
use ic_cdk::export::candid::{CandidType, Deserialize, Int, Nat, Principal};
#[derive(CandidType, Deserialize)]
pub struct SonicTokenInfo {
pub id: String,
pub name: String,
pub symbol: String,
use async_trait::async_trait;
use ic_cdk::api::call::CallResult;
use ic_cdk::call;
use ic_cdk::export::candid::{CandidType, Deserialize, Nat, Principal};
#[derive(CandidType, Deserialize)]
pub struct Dip20Metadata {
pub fee: Nat,
pub decimals: u8,
pub owner: Principal,
use async_trait::async_trait;
use ic_cdk::api::call::{call_with_payment, CallResult};
use ic_cdk::call;
use ic_cdk::export::candid::{CandidType, Deserialize, Nat, Principal};
#[derive(CandidType, Deserialize)]
pub struct XTCBurnPayload {
pub canister_id: Principal,
pub amount: u64,
}
// SPDX-License-Identifier: MIT
pragma solidity >0.6.1 <0.7.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract HonestCasino is Ownable {
using SafeMath for uint256;
@seniorjoinu
seniorjoinu / Voting.sol
Last active January 22, 2021 11:11
Voting system for ERC777 with history
contract Voting {
using SafeMath for uint256;
enum VoteStatus {
NONE, ACCEPT, REJECT
}
enum VotingResult {
NONE, ACCEPT, REJECT, NOT_APPLIED
}
@seniorjoinu
seniorjoinu / ERC777WithHistory.sol
Last active April 17, 2021 19:48
ERC777 with history
contract ERC777WithHistory is ERC777 {
struct BalanceSnapshot {
uint256 timestamp;
uint256 balance;
}
/**
* @dev Each account has a history of how it's balance changed over time
*/
@seniorjoinu
seniorjoinu / svg-utils.ts
Created November 9, 2020 23:29
Async SVG to PNG file convert function
// it needs some utilitary canvas to work
export async function transformSvgToPng(canvas: HTMLCanvasElement, svg: File): Promise<File> {
return new Promise((resolve, reject) => {
const ctx = canvas.getContext('2d');
if (!ctx) return reject('Unsupported browser');
const img = new Image;
img.onload = () => {
// this makes result png the same size as the input svg
canvas.width = img.width;