This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Voting { | |
using SafeMath for uint256; | |
enum VoteStatus { | |
NONE, ACCEPT, REJECT | |
} | |
enum VotingResult { | |
NONE, ACCEPT, REJECT, NOT_APPLIED | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract ERC777WithHistory is ERC777 { | |
struct BalanceSnapshot { | |
uint256 timestamp; | |
uint256 balance; | |
} | |
/** | |
* @dev Each account has a history of how it's balance changed over time | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |