Skip to content

Instantly share code, notes, and snippets.

View Mleekko's full-sized avatar

Oleh Koval Mleekko

View GitHub Profile
@Mleekko
Mleekko / out_pk.py
Created April 6, 2024 11:23
Read Private Key from node-keystore.ks
import hashlib
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.serialization import Encoding, PrivateFormat, NoEncryption, pkcs12
from ecdsa import keys
from getpass import getpass
from radix_engine_toolkit import Address, PrivateKey, PublicKey, derive_virtual_account_address_from_public_key, OlympiaNetwork
NETWORK_ID: int = OlympiaNetwork.MAINNET.value
@Mleekko
Mleekko / lib.rs
Created February 14, 2024 20:36
TestRunner snapshot example
/* A proof-of-concept for reusing a TestRunner after long-running init (e.g. deploying the initial packages) to speed up tests. */
//
use std::sync::{Once};
static mut SNAP: Option<TestRunnerSnapshot> = None;
static mut DATA: Option<TestData> = None;
static INIT: Once = Once::new();
/* The data that is set during init and needs to be shared with all the tests */
#[derive(Clone)]
@Mleekko
Mleekko / ManifestBuilder.ts
Last active February 6, 2024 19:35
ManifestBuilder from string
public static async fromString(manifestText: string): Promise<ManifestBuilder> {
const instructions = await RadixEngineToolkit.Instructions.convert(
{
"kind": "String",
"value": manifestText
},
NetworkId.Mainnet,
"Parsed"
);
@Mleekko
Mleekko / Invoke scrypto.rs
Created January 8, 2024 22:04
Invoke method by nodeid from omar
<@754961345123844136> If I understood correctly, then here is an example that does what you've described:
```rs
use scrypto::prelude::*;
#[derive(Clone, Debug, ScryptoSbor)]
pub enum Invocation {
Function {
package_address: PackageAddress,
blueprint_name: String,
@Mleekko
Mleekko / .env
Created August 7, 2023 08:03
Babylon RC2 Aggregator + Gateway
# Used by Docker Compose: https://docs.docker.com/compose/env-file/
#################################
# NETWORK GATEWAY CONFIGURATION #
#################################
# The logical network name which the nodes you connect to must match with
# EG mainnet | stokenet | localnet
@Mleekko
Mleekko / query.sql
Last active July 21, 2022 21:53
Stake added within interval (OciSwap staking challenge)
-- Validators leaderboard
WITH validator_data AS (
SELECT t.validator_id, t.name
FROM public.validator_data_substates t
WHERE name IS NOT NULL
AND down_state_version IS NULL
ORDER BY t.validator_id
),
staked_amounts AS (
SELECT v.name, t.inferred_action_amount / pow(10, 18) as amount
@Mleekko
Mleekko / sign-transaction.go
Created July 10, 2022 06:57
Transaction signing in go
package main
import (
"bytes"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"log"
@Mleekko
Mleekko / query.sql
Created July 4, 2022 17:55
Validators that missed proposals recently
WITH validator_data AS (
SELECT t.validator_id, t.name
FROM public.validator_data_substates t
WHERE name IS NOT NULL
AND down_state_version IS NULL
ORDER BY t.validator_id
)
(SELECT k.epoch, '<- Current Epoch' as validator, Null as proposals_missed, Null as proposals_completed
FROM validator_proposal_records k
@Mleekko
Mleekko / query.sql
Last active June 27, 2022 00:11
Average balances per account
-- Average balances per account
WITH balances AS (
SELECT abh.balance as balance,
abh.account_id
FROM account_resource_balance_history abh
where abh.resource_id = 1 AND abh.to_state_version is null
),
staked_balances AS (
SELECT
account_id,
@Mleekko
Mleekko / KeyManager.java
Created March 30, 2022 23:07
KeyManager - manage multiple signing keys for Radix APIs.
import com.radixdlt.crypto.ECDSASignature;
import com.radixdlt.crypto.ECKeyPair;
import com.radixdlt.crypto.ECPublicKey;
import com.radixdlt.crypto.exception.PrivateKeyException;
import com.radixdlt.crypto.exception.PublicKeyException;
import com.radixdlt.identifiers.REAddr;
import com.radixdlt.networks.Addressing;
import com.radixdlt.networks.Network;
import com.radixdlt.utils.Bytes;
import lombok.extern.slf4j.Slf4j;