Skip to content

Instantly share code, notes, and snippets.

View SuperCipher's full-sized avatar
💭
GMT+7 08:00 - 22:00

Napat SuperCipher

💭
GMT+7 08:00 - 22:00
  • BiggestFan Production
  • Thailand
View GitHub Profile
function createPromises(onFunctions) {
return onFunctions.map(onFunction => {
return new Promise((resolve, reject) => {
try {
onFunction(resolve)
} catch (e) {
reject(new Error(`Error in function ${onFunction.name}: ${e}`))
}
})
})
@SuperCipher
SuperCipher / type compatibility table.txt
Created December 19, 2022 02:55
type compatibility table
https://github.com/microsoft/TypeScript/issues/26262#issuecomment-431406596
@SuperCipher
SuperCipher / toNonZeroInteger
Created May 3, 2022 09:21
function to create a set of non zero interger number useful for sanitize input
toNonZeroInteger :: Int -> Int
toNonZeroInteger 0 = 1
toNonZeroInteger x = if x < 0
then (-x) + 1
else x + 1
@SuperCipher
SuperCipher / Main.purs
Created May 2, 2022 17:29
4 different way to update record in purescript
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
type Person = Age (name :: String)
type Age a =
@SuperCipher
SuperCipher / gist:be50793e1b6cd9dabb52ac27099c2d1e
Created April 26, 2022 11:37
get all container name and ip
https://stackoverflow.com/a/63023383/3422861
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}} %tab% {{.Name}}' $(docker ps -aq
) | sed 's#%tab%#\t#g' | sed 's#/##g' | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
@SuperCipher
SuperCipher / gist:d338653374381dbf620954b5502bc590
Last active April 5, 2022 10:05
deploy NFT integrate test
{"chain_id": 80001, "node_rpc": "https://polygon-mumbai.infura.io/v3/529aa367cbba407a98c67577f8b986a0", "Wallets": {"seller": {"address": "0xe00BCef53DD14AE43963cfdd824e78c1858Ea3a8", "private": "76d4921b8eebb1ab031a0296427262e12aef3989132e9cd77d1f4272350bb06f"}}, "erc721": {"SILVER": {"address": "0xaF27c6628135833e3bf094478829D498746A93D4", "tx": "0xf76689b73ce659068dd8f954093184c8440b6249ccee9d023547e1bcbb0a6a4e", "block_number": 25809044, "block_hash": "0xb84b2281f2af8ce1aebb51f6b57314fa085938a7d33ead6d1c8e918c2cde2f17", "name": "Silver box", "symbol": "SILVER", "total_supply": 0, "max_supply": 50000, "abi": [{"anonymous": false, "inputs": [{"indexed": true, "name": "sender", "type": "address"}, {"indexed": true, "name": "receiver", "type": "address"}, {"indexed": true, "name": "tokenId", "type": "uint256"}], "name": "Transfer", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "name": "owner", "type": "address"}, {"indexed": true, "name": "approved", "type": "address"}, {"indexed": true,
@SuperCipher
SuperCipher / gist:38f584b25b211465bbb72e3409013435
Last active April 5, 2022 09:38
exchange 0.0.2 integrate test
{"chain_id": 80001, "node_rpc": "https://polygon-mumbai.infura.io/v3/529aa367cbba407a98c67577f8b986a0", "Wallets": {"exchange": {"address": "0x7A51BA6C12AF5010FE596Ad5496823C1d96E7DD9"}, "seller": {"address": "0xe00BCef53DD14AE43963cfdd824e78c1858Ea3a8"}}, "exchange_contract": {"abi": [{"inputs": [], "name": "apiVersion", "outputs": [{"name": "", "type": "string"}], "stateMutability": "pure", "type": "function"}, {"inputs": [{"name": "_contract_owner", "type": "address"}, {"name": "_platform_signing_account", "type": "address"}, {"name": "_seller_eoa", "type": "address"}], "outputs": [], "stateMutability": "nonpayable", "type": "constructor", "name": "constructor"}, {"inputs": [{"name": "_platform_signature", "type": "bytes"}, {"name": "_buyer_address", "type": "address"}, {"components": [{"name": "seller_eoa", "type": "address"}, {"name": "sale_currency", "type": "address"}, {"name": "erc721_addresses", "type": "(address,uint256,uint256)[3]"}, {"name": "collection_start_time", "type": "uint256"}, {"name": "c
{"chain_id": 80001, "node_rpc": "https://polygon-mumbai.infura.io/v3/529aa367cbba407a98c67577f8b986a0", "Wallets": {"exchange": {"address": "0x94Ac3ed3b60C3262EFD35498D98b39402B317912", "private": "a9c2d97ebaee358471cc487b1d7af7ce12256789f47af3d17fc1fb598031ee4e"}, "seller": {"address": "0xe00BCef53DD14AE43963cfdd824e78c1858Ea3a8", "private": "76d4921b8eebb1ab031a0296427262e12aef3989132e9cd77d1f4272350bb06f"}, "erc20_owner": {"address": "0x7A51BA6C12AF5010FE596Ad5496823C1d96E7DD9", "private": "6ee576c44b0c9aecdcdcdbb5260fc3dde3403f67b1083253d4d902540ad32335"}}, "erc20": {"address": "0x32B00de4829aAD186e0eD0DC9c0f0c5520285A69", "tx": "0x898d7980d3104b2bd7b99815a5fd6aa86ad189e7c8f6ad6bc43e146568d734a9", "block_number": 25712224, "block_hash": "0x479b260da79ee939d52806a424e9fad589e220b264175d5c81a5b54d39854d34", "total_supply": 10000, "decimals": 18, "name": "Ampleia Coin", "symbol": "A14", "abi": [{"anonymous": false, "inputs": [{"indexed": true, "name": "sender", "type": "address"}, {"indexed": true, "name": "
E brownie.exceptions.VirtualMachineError: revert: dev: invalid _signature
E Trace step 619, program counter 4422:
E File "contracts/exchange_presale.vy", line 204, in exchange_presale.checkSellerSignature:
E v: uint256 = convert(slice(_signature, 64, 1), uint256)
E assert ecrecover(digest, v, r, s) == _sellers_signing_account # dev: invalid _signature
E return digest
tests/test_exchange_presale.py:309: VirtualMachineError
@SuperCipher
SuperCipher / gist:8095fde9d52ac8d13d38eb0364558006
Created March 21, 2022 16:13
signing recursive data structure EIP-712
def sign_seller_signature():
def sign_seller_signature(
contract,
sellers_signing_account: Account, # NOTE: Must be a eth_key account, not Brownie
seller_address,
seller_erc20_address,
seller_info,
):
name = "Ampleia"
version = contract.apiVersion()