Skip to content

Instantly share code, notes, and snippets.

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

RockerOne SuperstrongBE

🏠
Working from home
View GitHub Profile
@SuperstrongBE
SuperstrongBE / proton-tw-dialog-styles.css
Created April 13, 2024 11:33
A gist that showcase XPRNetwork transport/link dialogs styles
html[data-theme="twelvedays"] .proton-link-inner,
html[data-theme="twelvedays"] .wallet-selector-inner,
html[data-theme="twelvedays"] .wallet-selector-connect
{
background-color: #0b211c;
}
html[data-theme="twelvedays"] .proton-link-header,
html[data-theme="twelvedays"] .wallet-selector-title {
@SuperstrongBE
SuperstrongBE / mytest.spec.ts
Last active April 7, 2024 08:14
Abi2ts exemple
// Generating smart contract TS types definition from local abi file with abi2ts
// npx abi2ts betsxpr -f ./target/betxpr.contract.abi > ./tests/interfaces/betxpr.ts
describe("End prediction", () => {
it("Should pick resolvers 4 resolvers (resolverSeeds length + 1) ", async () => {
// {contractName}_actionParams<'{action_name}'> turn a typed action parameters object to an array
const predictionEndParams = betsxpr_actionParams<'gov.endpoll'>({
predictionKey: 0,
resolverSeeds:[0,1,2]
})
@SuperstrongBE
SuperstrongBE / apiService.decorator.ts
Created November 20, 2023 12:52
Research around decorator and api route
import { NextResponse } from "next/server";
import { PostMethodSymbol } from "./http-methods/post";
import { GetMethodSymbol } from "./http-methods/get";
export interface APIService {
GET:()=>void,
POST:()=>void,
}
// How can i fix the return type to avoid type check issue ?
{
"[typescriptreact]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@SuperstrongBE
SuperstrongBE / app.js
Created August 23, 2023 23:31
Attempt to resolve PSR in an expo app
import React, {useState, useEffect} from "react";
import {Api, JsonRpc, JsSignatureProvider} from "@proton/js";
import {SigningRequest} from "@proton/signing-request";
import pako from "pako";
import {Text, View, StyleSheet, Button} from "react-native";
import {BarCodeScanner} from "expo-barcode-scanner";
import * as encodeAndDecodeModule from "fastestsmallesttextencoderdecoder";
const fetch = require("node-fetch"); // ou d'autres alternatives selon l'environnement
const endpoints = ["https://api.protonnz.com"]; // Remplacez par l'URL de votre nœud EOSIO
import { Checksum256,U256,sha256 } from "proton-tsc";
export function u64ArrayToU256(assetIds:u64[]): U256 {
const hash: U256 = new U256()
const sortedAsset: u64[] = (assetIds).sort((a: u64, b: u64) => u32(a - b));
return sortedAsset.reduce((prev: U256, current: u64): U256 => {
return U256.add(prev, U256.fromU64(current));
},new U256())
@SuperstrongBE
SuperstrongBE / ProtonAuthProvider.tsx
Created January 29, 2023 10:05
A proton-web-sdk wrapper for react
"use client"
import React, {
createContext,
useState,
useCallback,
useContext
} from 'react';
import ProtonWebSDK,{ ProtonWebLink, Link,LinkSession } from '@proton/web-sdk';
export interface AuthState {
import { Api, JsonRpc, JsSignatureProvider } from "@proton/js";
// THOSE ENDPOINTS ARE TESTNET
// BE SURE TO TEST THIS SCRIPT WITH A TESTNET ACCOUNT
const EPS = [
"https://testnet.brotonbp.com",
"https://api-protontest.saltant.io",
"https://api.testnet.protongb.com",
"https://testnet-api.protongroup.info",
"https://test.proton.kiwi",
@SuperstrongBE
SuperstrongBE / mnemonic2private.js
Last active November 21, 2022 12:16
EOS/Proton mnemonic to private
const account = require('./account.json');
const hdkey = require('hdkey')
const wif = require('wif')
const ecc = require('eosjs-ecc')
const bip39 = require('bip39')
const eos = require('eosjs')
async function generateKeyPair(mnemonicString){
const { JsonRpc }= require("@eoscafe/light-api");
const rpc = new JsonRpc("proton");
/**
* Fetch token holder counts
* @returns {any}
*/
async getTokenHolders (){
return rpc.get_tokenholder_count('accountName','TOKEN');