Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Check if directory path argument is provided
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <directory_path> <curve>"
exit 1
fi
DIR_PATH=$1
CURVE=$2
@katat
katat / snarkjs-prove-and-verify.sh
Last active May 24, 2024 03:03
a convenient shell script to test generating a proof from .r1cs and .wtns files and verifying it via snarkjs
#!/bin/bash
# Check if directory path argument is provided
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <directory_path> <curve>"
exit 1
fi
DIR_PATH=$1
CURVE=$2
@katat
katat / solve_cell_equals.py
Created May 20, 2024 09:13
use z3 smt solver to check if constraint satisfies under certain free var assumptions
from z3 import *
# Create solver instance
s = Solver()
# Define variables
x1 = Real('x1')
x2 = Real('x2')
res = Real('res')
@katat
katat / resume.json
Last active September 5, 2023 04:02
{
"basics": {
"name": "Katat Choi",
"label": "Full Stack Developer",
"email": "kata.choi@gmail.com",
"website": "http://katat.me",
"summary": "I have been practicing remote craftmanship with startups across the globe since 2012, experienced in building products from the ground up. Currently, I am looking for opportunities in which I can gain cryptography knowledge at deeper level while making contributions in the blockchain world.",
"profiles": [
{
"network": "Blog",

GrowFi milestone 2 / second round review

The following files are duplicated. The duplicated code is better to be consolidated for the other parts to reference:

  • test/deploy.js and test/deploy/deploy.js
  • test/deploy/exec.js and test/exec.js
  • test/txBuilder.js and test/tx/txBuilder.js
  • test/cellBuilder.js and test/tx/cellBuilder.js

Besides, I don't see there are updates to the contract scripts based on the feedbacks of the first round.

@katat
katat / review.md
Last active August 11, 2020 06:49
GrowFI milestone 2 review feedback

Milestone 2 review

The web app is integrated with the Synapse wallet in a form of Chrome extension, which in turn interacts with the contracts on CKB chain. It achieved all the key functions, such as creating liquidity pool / add liquidity to existing pool / exit from a liquidity pool / swap between UDTs and CKB. Although the UI is working, but I think it will need some polishments to improve the user experiences to be more intuitive.

The integration tests also demonstrates these key functions on UDTSwap are working as expected. There were some problems in the test setup documentation, but they did provide detailed steps for me to be able to setup my local environment to successfully execute these integration tests. I suggested them to encapsulate these complicated setup steps into a script, which they agreed. After some conversions with the team, they did improve the deployment script to be easy enough to run the integration test.

Overall, I think the UDTSwap works as expected as a prototype. It demons

//update staged balance
for(const settlement of settlements.filter(s => s.isStageable)) {
await settlement.stage(wallet, {gasLimit, gasPrice});
}
//withdraw all staged balance for a currency back to base layer
const stagedBalanceBN = await wallet.getNahmiiStagedBalance(tokenInfo.symbol);
const withdrawMonetaryAmount = nahmii.MonetaryAmount.from(stagedBalanceBN, tokenInfo.currency);
await wallet.withdraw(withdrawMonetaryAmount, {gasLimit, gasPrice});
const settlements = await settlementFactory.calculateRequiredSettlements(wallet.address, stageMonetaryAmount);
for (const settlement of settlements) {
const {hash} = await settlement.start(wallet, {gasLimit, gasPrice});
//wait until the transaction is mined on chain
await provider.getTransactionConfirmation(hash);
}
const {hash} = await settlement.start(wallet, {gasLimit, gasPrice});
const settlements = await settlementFactory.getAllSettlements(wallet.address, tokenInfo.currency);
//settlement.type indicates which type the settlement is.
//settlement.isStageable indicates if the settlement is qualified and ready to be staged (marked as completed)
//settlement.isOngoing indicates if the settlement is still within the challenge period.
//settlement.expirationTime indicates the end time of the challenge period.