Skip to content

Instantly share code, notes, and snippets.

View WietseWind's full-sized avatar
⌨️
Focusing

Wietse Wind WietseWind

⌨️
Focusing
View GitHub Profile
@WietseWind
WietseWind / firewall-hookscript.ts
Created April 6, 2023 21:15
HookScript (Typescript) Hooks Firewall
class ByteSet {
@lazy
static readonly dataSize: u32 = 32;
constructor(public bytes: ByteArray) {
if (bytes.length != ByteSet.dataSize)
rollback("", pack_error_code(bytes.length));
}
has(n: u8): bool {
@WietseWind
WietseWind / savings-hookscript.ts
Created April 6, 2023 21:14
HookScript (Hooks Typescript) savings
function hook(reserved: i32)
{
etxn_reserve(1)
const savings_account = new HookParam<Account>({
name: "savings_account",
description: 'The account the rounded savings are sent to'
})
const dest_accid = savings_account.get(
new Account(util_accid("rfCarbonVNTuXckX6x2qTMFmFSnm6dEWGX")))
@WietseWind
WietseWind / up.bash
Created March 22, 2023 21:29
Auto run dotnet Docker container & config nginx
#!/bin/bash
cpt=${PWD##*/} # to assign to a variable
cpt=${result:-/} # to correct for the case where PWD=/
cpt=$(printf '%q\n' "${PWD##*/}")
cpt=${cpt,,}
rm -f /etc/nginx/sites-enabled/$cpt
cp /etc/nginx/template/template-vhost /etc/nginx/sites-enabled/$cpt
@WietseWind
WietseWind / index.mjs
Created March 20, 2023 14:49
Async/Sync check accounts for balance & TrustLine balance
import { XrplClient } from 'xrpl-client'
const account = 'rpKJsRsvKXt5JwV2PFRnvfkEH47MEWpVYo'
const client = new XrplClient()
let marker
let pages = 0
let accounts = 0
@WietseWind
WietseWind / test.mjs
Created February 15, 2023 22:44
Xumm WebSocket test
import { Xumm } from 'xumm'
import WebSocket from 'ws'
const xumm = new Xumm('xxxxxx', 'yyyyyy')
const payload = await xumm.payload?.create({ TransactionType: "SignIn" })
console.log(payload.refs.websocket_status)
const ws = new WebSocket(payload.refs.websocket_status)
@WietseWind
WietseWind / javascript.mjs
Created January 30, 2023 11:44
XLS35 Digest Calculator
import sha512 from 'crypto-js/sha512';
const metadata = {
details: {
title: 'Some Title'
}
}
const digest = sha512(
JSON.stringify(metadata).trim()
@WietseWind
WietseWind / xls35schema.ts
Last active January 30, 2023 12:38
XLS35 Schema Proposal
export interface xls35category {
code: string
description: string
}
// EXAMPLES (!)
export const xls35categories: xls35category[] = [
{ code: '0000', description: 'Testing-purpose token' },
{ code: '0001', description: 'Art' },
@WietseWind
WietseWind / index.mjs
Last active January 29, 2023 00:04
Update electric-capital/crypto-ecosystems with up to date XRPL repos
import fetch from 'node-fetch'
const repos = []
const knownRepoCall = await fetch('https://raw.githubusercontent.com/electric-capital/crypto-ecosystems/master/data/ecosystems/x/xrp.toml')
const knownRepoData = await knownRepoCall.text()
for (let page = 1; page < 10; page++) {
const call = await fetch('https://api.github.com/search/repositories?q=xrp+xrpl&order=desc&per_page=1000&page=' + page)
const json = await call.json()
@WietseWind
WietseWind / payment.mermaid
Last active December 11, 2022 23:53
Sequence: Xumm POS Payment
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@WietseWind
WietseWind / banxa-api-signature.mjs
Created September 29, 2022 14:36
Banxa API from NodeJS (signature)
import fetch from 'node-fetch'
import {createHmac} from 'crypto'
const endpoint = 'xxxxxx
const key = 'yyyyyy'
const secret = 'xxxxxxxx'
const banxaCall = async (path, body, method = 'GET') => {
const nonce = Math.round(new Date() / 1000)