Skip to content

Instantly share code, notes, and snippets.

import { dropsToXrp } from "xrpl";
type IOU = { currency: string; issuer: string };
type Asset = "XRP" | IOU;
type QuoteParams = {
side: "buy" | "sell";
base: Asset; // asset you get on buy / sell on sell
quote: Asset; // asset you pay on buy / receive on sell
mode: "from" | "to"; // which field user typed
/**
* XRPL Service
* Handles XRPL blockchain operations and XUMM API integration
*/
import {
Client,
Wallet,
AccountSet,
Payment,
/**
* A set of functions called "actions" for `xrpl`
*/
import { Client, Wallet } from "xrpl";
import validator from "validator";
import { verify, deriveAddress } from "ripple-keypairs";
export default {
// ========================================
/**
* A set of functions called "actions" for `xrpl`
*/
import { Client, Wallet } from "xrpl";
import validator from "validator";
import { verify, deriveAddress } from "ripple-keypairs";
export default {
// ========================================
@mikekoro
mikekoro / gist:c061b0285eda15d3dbed970908f60686
Last active October 10, 2024 19:05
Get ETH and SX prices from Uniswap v3
const rpcUrl = CHAIN_CONFIGS[1].rpcUrls[0];
const provider = new providers.StaticJsonRpcProvider(rpcUrl, 1);
const UniswapV3Pool = await import('../../config/abi/UniswapV3Pool.json');
const sxUsdcPoolAddress = "0xCb3b931E1e02C26399aCc651bFD9c8c4385EECd0";
const ethUsdcPoolAddress = "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8";
const sxUsdcPoolContract = new Contract(sxUsdcPoolAddress, UniswapV3Pool.abi, provider);
const ethUsdcPoolContract = new Contract(ethUsdcPoolAddress, UniswapV3Pool.abi, provider);
import Web3 from 'web3';
export const getMetamask = (windowObject) => {
if(!windowObject.web3) {
return false
}
return windowObject.web3;
}
@mikekoro
mikekoro / Classes.js
Created August 4, 2020 20:32 — forked from gaearon/Classes.js
Beneath Classes: Prototypes
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
@mikekoro
mikekoro / helloWorld.js
Created August 4, 2020 20:17
Testing some stuff
import axios from 'axios';
/**
* Pull public gists from a Github user by their username
* @param {string} username Github username
*/
export const getGistsByUsername = async (username) => {
try {
let response = await axios({
// useSockets.js
import React, {
useState
} from 'react';
import io from 'socket.io-client';
export default function useSocket() {
const [Socket, setSocket] = useState(null);
const RandomNumberGenerator = () => {
const [number, setNumber] = useState(Math.random());
const regenerate = () => {
setNumber(Math.random());
}
const RandomNumber = () => {
return number;
}
return { regenerate, RandomNumber };