Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
Focusing

Wietse Wind WietseWind

⌨️
Focusing
View GitHub Profile
@WietseWind
WietseWind / index.mjs
Last active Jul 4, 2022
Fun with Generator Functions. First backfill XRPL Ledgers, then keep up with current Ledgers closing, fall back to backfilling if needed to sync gaps.
View index.mjs
import { XrplClient } from 'xrpl-client'
const config = { backfillLedgers: 20, lastLedger: null }
const client = new XrplClient(['wss://xrplcluster.com'])
await client.ready()
config.lastLedger = client.getState().ledger.last - config.backfillLedgers
function getLedgerTransactions(ledger_index) {
return client.send({ command: 'ledger', transactions: true, expand: true, ledger_index })
@WietseWind
WietseWind / user-profile-script.js
Last active Jun 20, 2022
Xumm OAuth2 Sign In for Auth0, based on Developer Question: https://xumm.readme.io/discuss/62af82ada6faf1007c0e89f3
View user-profile-script.js
function(accessToken, ctx, callback) {
const url = "https://oauth2.xumm.app/userinfo";
request.get(
{ url, headers: { 'Authorization': 'Bearer ' + accessToken, } },
(err, resp, body) => {
if (err) {
return callback(err);
}
if (resp.statusCode !== 200) {
@WietseWind
WietseWind / pkce-implicit.html
Created May 26, 2022
Example OAuth2 client side (vanillaJS) example with Implicit PKCE flow
View pkce-implicit.html
<html>
<title>OAuth Authorization Code + PKCE in Vanilla JS</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!-- Credits: https://github.com/aaronpk/pkce-vanilla-js/blob/master/index.html -->
<script>
// Configure your application and authorization server details
var config = {
client_id: "<The Xumm App API key (public)>",
@WietseWind
WietseWind / build.sh
Created Apr 14, 2022
Hooks AssemblyScript V2
View build.sh
#!/bin/bash
rm ./module.wasm
rm ./module.wat
node assemblyscript/bin/asc \
-O3 \
--noAssert \
--runtime minimal \
--textFile ./module.wat \
View starter.c
/**
* This hook just accepts any transaction coming through it
*/
#include "hookapi.h"
int64_t cbak(int64_t reserved) {
return 0;
}
int64_t hook(int64_t reserved ) {
View blacklist.c
#include "hookapi.h"
/*
Blacklist signing keys ((( you should change these )))
r.deriveKeypair('sEd7CGWXiFPazNncZJsxD11h1sHJCtm')
{
privateKey: 'ED55D3A139AF8F069FE93BB943FE3A46BAF70EA61E0DD02192D4A532D8E87627F0',
publicKey: 'EDDC6D9E28CA0FE2D475FC021D226881666EA106FBD2222C8C2110368A49C9513C'
}
the public key is encoded below, you should change this
*/
View notary.c
/**
* Notary.c - An example hook for collecting signatures for multi-sign transactions without blocking sequence number
* on the account.
*
* Author: Richard Holland
* Date: 11 Feb 2021
*
**/
#include <stdint.h>
View carbon.c
#include <stdint.h>
#include "hookapi.h"
int64_t cbak(int64_t reserved)
{
return 0;
}
int64_t hook(int64_t reserved ) {
View peggy.c
/**
* Peggy.c - An oracle based stable coin hook
*
* Author: Richard Holland
* Date: 1 Mar 2021
*
**/
#include <stdint.h>
#include "hookapi.h"
@WietseWind
WietseWind / index.js
Created Feb 4, 2022
Secret Numbers to Family Seed
View index.js
const {Account} = require('xrpl-secret-numbers')
const secret = '399150 474506 009147 088773 XXXXXX XXXXXX XXXXXX XXXXXX'
const account = new Account(secret)
console.log(account.getFamilySeed())