Skip to content

Instantly share code, notes, and snippets.

View pscott's full-sized avatar
🦀
Ayyyy

pscott

🦀
Ayyyy
View GitHub Profile
@pscott
pscott / foo.cairo
Created May 25, 2022 11:16
IAccount example
%lang starknet
from openzeppelin.account.IAccount import IAccount
from openzeppelin.account.library import AccountCallArray
@external
func foo{syscall_ptr: felt*, range_check_ptr}(target: felt, call_array_len: felt, call_array: AccountCallArray*, calldata_len: felt, calldata: felt*, nonce: felt):
IAccount.__execute__(contract_address=target, call_array_len=call_array_len, call_array=call_array, calldata_len=calldata_len, calldata=calldata, nonce=nonce)
return ()
end
const { expect } = require("chai");
import { StarknetContract} from 'hardhat/types';
import { stark } from 'starknet';
import { starknet, ethers } from 'hardhat';
describe("Tuples and type aliases", function () {
it("Should work with felt", async function () {
const Greeter = await starknet.getContractFactory('./contracts/starknet/test.cairo');
const greeter: StarknetContract = await Greeter.deploy();
@pscott
pscott / with_if.cairo
Created April 25, 2022 17:34
with if registration
%lang starknet
from starkware.cairo.common.alloc import alloc
from starkware.cairo.common.cairo_builtins import HashBuiltin
@storage_var
func _whitelist(address: felt) -> (is_valid: felt):
end
@external

Instructions

  1. Double check your eligibility. If you are not in this list of github IDs, you will not be included in the claim process
  2. Click the Fork button on the top right of this page

Group_1

  1. Edit the newly forked gist
  2. Delete all text
  3. Paste in the the Public ID you generated at https://gov.element.fi/zk/github
@pscott
pscott / lib.ts
Created March 10, 2022 13:57
short string ts library
const SHORT_STR_SIZE = 31;
function shortStrToFelt(str: string): bigint {
let res = "0x";
if (str.length > SHORT_STR_SIZE) {
// String too big
return BigInt(0)
}
@pscott
pscott / generate_apdus.py
Last active July 4, 2021 23:41
Generate setExternalPlugin and provideErc20Info apdus
import struct
import argparse
from binascii import hexlify, unhexlify
DEFAULT_SIGNATURE = "9A9EE708C47D8CE568D272223277FABF7C6EF6EE"
DEFAULT_SIGNATURE1 = "000000013045022100DAD508227E3ABEC13A80691EE03BF64684CD87E1669E53C6B9C21403D742B4640220516824C46E3D424A7A2BA247BB0D1821754874A91C301996AA11C39321E597DB"
DEFAULT_SIGNATURE2 = DEFAULT_SIGNATURE1
parser = argparse.ArgumentParser()

Keybase proof

I hereby claim:

  • I am pscott on github.
  • I am biliklok (https://keybase.io/biliklok) on keybase.
  • I have a public key ASBArWpOM9HK_CdhQ3c7WXRr3xR0IULHlG5yUQqvl91j1wo

To claim this, I am signing this object:

@pscott
pscott / stuff.rs
Last active October 27, 2019 14:54
<3
trait MyTrait<U, T> {
fn signing_func(&self, challenger: &U, history: &[T]) -> Result<usize, &'static str>;
}
impl MyTrait<TypeA, TypeB>
for HistoryInfo<TypeB>
{
fn signing_func(
&self,
challenger: &TypeA,
# THIS IS PSEUDO CODE AND NEEDS REVIEWING
# attest_data the attestation data corresponding to the attestation we're evaluating
# attestation_history is a vector of ValidatorHistoricalAttestation structs
def check_inner_attestations(attest_data, history_before_attest_target):
inner_attestations = []
# creating a list of attestations contained between SOURCE and TARGET of attestation
for prev_attest in history_before_attest_epoch:
if prev_attest.target_epoch < attest_data.target.epoch: