Skip to content

Instantly share code, notes, and snippets.

View franciscoaguirre's full-sized avatar
🦀

Francisco Aguirre franciscoaguirre

🦀
View GitHub Profile
@franciscoaguirre
franciscoaguirre / constants.ts
Last active November 6, 2025 10:43
People Hollar DCA
import { XcmV5Junction, XcmV5Junctions } from "@polkadot-api/descriptors";
// ===== Dev accounts =====
export const ALICE = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
// ===== Parachain IDs =====
export const PEOPLE_PARA_ID = 1004;
export const HYDRATION_PARA_ID = 2034;
export const ASSET_HUB_PARA_ID = 1000;
export const PEOPLE_PALLET_INSTANCE = 53;
@franciscoaguirre
franciscoaguirre / generate-xcm.ts
Last active September 9, 2025 00:19
Interacting with the XCM precompile with Hardhat
import {
passetHub,
XcmV3MultiassetFungibility,
XcmV3WeightLimit,
XcmV5AssetFilter,
XcmV5Instruction,
XcmV5Junction,
XcmV5Junctions,
XcmV5WildAsset,
XcmVersionedXcm,
@franciscoaguirre
franciscoaguirre / papi.ts
Last active June 17, 2025 12:57
XCM Teleport with accurate fees
// `ahp` is the name we gave to `bun papi add`.
import {
ahp,
DispatchRawOrigin,
people,
XcmV3Junction,
XcmV3Junctions,
XcmV3MultiassetFungibility,
XcmV3WeightLimit,
XcmV4AssetAssetFilter,
@franciscoaguirre
franciscoaguirre / CallXcmPrecompile.sol
Created June 13, 2025 16:54
Contract calling XCM precompile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IXcm {
struct Weight {
uint64 refTime;
uint64 proofSize;
}
function xcmExecute(bytes calldata message, Weight calldata weight) external;
function xcmSend(bytes calldata destination, bytes calldata message) external;
@franciscoaguirre
franciscoaguirre / derived_account.rs
Created May 14, 2025 11:33
How to get a utility derived account in FRAME
#[test]
fn whats_the_derived_account_id() {
use sp_runtime::AccountId32;
let account_id = AccountId32::from_ss58check("13YMK2ehDHE4hoxL9L2jq4h8zwMFpo4cZnrR7YwzgxxSH8LR").unwrap();
let result = pallet_utility::Pallet::<Runtime>::derivative_account_id(account_id, 0);
let derived_account_id = result.to_ss58check_with_version(42_u16.into());
dbg!(&derived_account_id);
}
@franciscoaguirre
franciscoaguirre / index.test.ts
Created January 7, 2025 19:02
Polkadot API error with vitest and bun
import { describe, test, expect } from 'vitest';
import { createClient } from 'polkadot-api';
import { getWsProvider } from 'polkadot-api/ws-provider/web';
describe('some context', () => {
const client = createClient(getWsProvider("wss://westend-penpal-rpc.polkadot.io"));
test('some test', () => {
expect(1).toBeGreaterThan(0);
});
@franciscoaguirre
franciscoaguirre / test_service.txt
Last active February 8, 2025 23:03
JAM Test Service
%stack_size = 4096
// Can't test the "designate" host function because
// we'd need 336 * 1023 zeroes here for correct decoding.
%rw_data_size = 12
%rw_data = 00 00 00 00 00 00 00 00 00 00 00 00
// ===== JAM entrypoints =====
jump @is_authorized
fallthrough
fallthrough
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const encoderStates = {
initial: 'streaming',
states: {
streaming: {
on: {
ENCODER_STOPPED: 'paused',
},
},
paused: {
on: {
@franciscoaguirre
franciscoaguirre / .vimrc
Created December 14, 2020 21:48
Vim configuration
" Plugins
call plug#begin('~/.vim/plugged')
Plug 'dense-analysis/ale'
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdtree'
Plug 'tomtom/tcomment_vim'
Plug 'kien/ctrlp.vim'
Plug 'vim-airline/vim-airline'
Plug 'airblade/vim-gitgutter'