Skip to content

Instantly share code, notes, and snippets.

View dumebi's full-sized avatar
🏠
Working from home

Jude Dike dumebi

🏠
Working from home
View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/math/Math.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import 'hardhat/console.sol';
/**
router.get("/posts/", async (req: express.Request, res: express.Response) => {
try {
let { caddress: contractAddresses, waddress: walletAddresses } = req.query
contractAddresses = contractAddresses ? contractAddresses.toString().split(",") : contractAddresses
walletAddresses = walletAddresses ? walletAddresses.toString().split(",") : walletAddresses
const trimmedContractAddresses = trimArrayInputs(walletAddresses);
const validContractAddresses = getValidEthereumAddresses(
trimmedContractAddresses
);
if (validContractAddresses.length == 0) return res.status(400).json({ data: [], message: "Invalid address inputs" });
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
import "./helpers/Ownable.sol";
import "./libraries/ExchangeStruct.sol";
import "./libraries/ExchangeFunc.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";
/**
* @title GetEquity Exchange contract
/**
* return full email body
* @param {string} partialBody
*/
exports.emailBody = (partialBody) => {
const body = `
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@dumebi
dumebi / connection.js
Created March 28, 2021 21:17
example structure
const mongoose = require('mongoose');
const utils = require("./utils");
const RabbitMQ = require('./rabbitmq')
const subscriber = require('./rabbitmq')
require('dotenv').config();
// Socket config
module.exports = {
mongo() {
mongoose.promise = global.promise;
@dumebi
dumebi / lottery.sol
Created November 1, 2020 21:14
Lottery Contract
pragma solidity ^0.4.0;
contract Casino {
uint private start;
uint private buyPeriod = 1000;
uint private verifyPeriod = 100;
uint private checkPeriod = 100;
@dumebi
dumebi / ERC20.sol
Created August 21, 2020 11:40
Basic ERC20 solidity token
pragma solidity ^0.6.10;
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(string memory name, string memory symbol)
public
ERC20(name, symbol)
{
// Mint 100 tokens to msg.sender
@dumebi
dumebi / messaging provider
Created July 2, 2020 10:39
JS OOP example (messaging provider)
class BaseProvider {
constructor (_name) {
if (
_name == null ||
_name === undefined ||
typeof _name !== 'string'
) {
throw new Error('Class needs to be instantiated with an provider name')
}
this.name = _name
@dumebi
dumebi / update struct
Last active June 15, 2020 07:00
Trying to update a struct
type User struct {
mogo.DocumentModel `bson:",inline" coll:"users"`
Username string `json:"username" binding:"required"`
Email string `idx:"{email},unique" json:"email" binding:"required"`
Password string `json:"password" binding:"required"`
FirstName string `json:"firstname"`
LastName string `json:"lastname"`
// CreatedAt *time.Time
// UpdatedAt *time.Time
Verified *time.Time `json:"_verified"`
type User struct {
mogo.DocumentModel `bson:",inline" coll:"users"`
Username string `json:"username" binding:"required"`
Email string `idx:"{email},unique" json:"email" binding:"required"`
Password string `json:"password" binding:"required"`
FirstName string `json:"firstname"`
LastName string `json:"lastname"`
// CreatedAt *time.Time
// UpdatedAt *time.Time
Verified *time.Time `json:"_verified"`