diff --git a/ts/tools/.gitignore b/ts/tools/.gitignore deleted file mode 100644 index e3427ccc..00000000 --- a/ts/tools/.gitignore +++ /dev/null @@ -1 +0,0 @@ -airdrop/**/*.json diff --git a/ts/tools/airdrop/generate.sh b/ts/tools/airdrop/generate.sh deleted file mode 100755 index bcc1e00a..00000000 --- a/ts/tools/airdrop/generate.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -ID_FROM=${ID_FROM:-0} -BEAKER=${BEAKER:-"beaker"} -DAEMON=${DAEMON:-"osmosisd"} -MNEMONIC=${SIGNER_MNEMONIC:-"notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius"} - -SIGNER="deployer-test" -beaker key set "$SIGNER" "$MNEMONIC" -y -(echo "y"; echo "$MNEMONIC") | $DAEMON keys add --recover "$SIGNER" - -function check { - if [ -z "$1" ] - then - echo "\$$2 is not defined" - exit 1 - fi -} - -check "$NETWORK" "NETWORK" - -SIGNER_FLAG="--signer-keyring=$SIGNER" - -# generate osmo staker airdrop -yarn start $(($ID_FROM + 0)) ./airdrop/$NETWORK/osmo-staker.json ./airdrop/$NETWORK-out/osmo-staker.json -yarn start $(($ID_FROM + 1)) ./airdrop/$NETWORK/osmo-mission-1.json ./airdrop/$NETWORK-out/osmo-mission-1.json -yarn start $(($ID_FROM + 2)) ./airdrop/$NETWORK/osmo-mission-2.json ./airdrop/$NETWORK-out/osmo-mission-2.json - -# generate ion staker airdrop -yarn start $(($ID_FROM + 3)) ./airdrop/$NETWORK/ion-staker.json ./airdrop/$NETWORK-out/ion-staker.json -yarn start $(($ID_FROM + 4)) ./airdrop/$NETWORK/ion-mission-1.json ./airdrop/$NETWORK-out/ion-mission-1.json -yarn start $(($ID_FROM + 5)) ./airdrop/$NETWORK/ion-mission-2.json ./airdrop/$NETWORK-out/ion-mission-2.json - -# # register airdrops -# beaker wasm execute ibc-airdrop \ -# --raw '{"register": {"merkle_root":"", "denom": "}}' \ -# --network $NETWORK \ -# $SIGNER_FLAG diff --git a/ts/tools/package.json b/ts/tools/package.json deleted file mode 100644 index 783a71e6..00000000 --- a/ts/tools/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@many-things/ibcx-contracts-tools", - "version": "0.0.1", - "description": "Typescript tools for IBCX Contracts", - "author": { - "name": "frostornge " - }, - "license": "MIT OR Apache-2.0", - "scripts": { - "airdrop": "ts-node src/airdrop.ts", - "signer": "ts-node src/signer.ts" - }, - "dependencies": { - "@cosmjs/crypto": "^0.30.1", - "@cosmjs/encoding": "^0.30.1", - "@cosmjs/proto-signing": "^0.30.1", - "@cosmjs/stargate": "^0.30.1", - "@keplr-wallet/crypto": "^0.11.50", - "crypto-js": "^4.1.1", - "merkletreejs": "^0.3.9" - }, - "devDependencies": { - "@types/crypto-js": "^4.1.1", - "@types/node": "^18.15.10", - "@types/prettier": "^2.7.2", - "ts-node": "^10.9.1", - "typescript": "^4.9.4" - } -} diff --git a/ts/tools/src/airdrop.ts b/ts/tools/src/airdrop.ts deleted file mode 100644 index d2e8effb..00000000 --- a/ts/tools/src/airdrop.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { MerkleTree } from "merkletreejs"; -import SHA256 from "crypto-js/sha256"; -import { writeFileSync } from "fs"; -import path from "path"; - -type InputData = [{ address: string; amount: string }] | string[]; - -const [airdropId, inputFile, outputFile] = process.argv.slice(2); - -if (!airdropId || !inputFile || !outputFile) { - console.log("Invalid arguments"); - process.exit(1); -} - -console.log("Input: "); -console.log(` - Airdrop ID : ${airdropId}`); -console.log(` - Input file : ${inputFile}`); -console.log(` - Output file : ${outputFile}`); - -const inputData: InputData = require(path.join(process.cwd(), inputFile)); -const leaves = - inputData[0] instanceof Object - ? (inputData as { address: string; amount: string }[]) - : (inputData as string[]).map((amount) => ({ - address: SHA256(`${Math.random()}`).toString(), - amount, - })); - -const tree = new MerkleTree( - leaves.map(({ address, amount }) => SHA256(`${address}:${amount}`)), - SHA256, - { sort: true } -); - -const root = tree.getHexRoot().replace("0x", ""); - -const proofs = leaves.map(({ address, amount }) => { - const leaf = SHA256(`${address}:${amount}`); - const proof = tree - .getHexProof(leaf.toString()) - .map((v) => v.replace("0x", "")); - - return { - address, - amount, - merkleRoot: root, - merkleProof: proof, - }; -}); - -writeFileSync( - path.join(process.cwd(), outputFile), - JSON.stringify({ airdropId, proofs }, null, 2) -); - -console.log("Done"); diff --git a/ts/tools/src/signer.ts b/ts/tools/src/signer.ts deleted file mode 100644 index af3cdc6f..00000000 --- a/ts/tools/src/signer.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { toBech32 } from "@cosmjs/encoding"; -import { Hash, Mnemonic, PrivKeySecp256k1 } from "@keplr-wallet/crypto"; - -const [, , MNEMONIC, TARGET] = process.argv; - -if (!MNEMONIC) { - throw Error("Please provide a mnemonic phrase"); -} - -if (!TARGET) { - console.log( - "INFO: No target is provided. The address will be used as the target." - ); -} - -async function main() { - const bzToStr = (bz: Uint8Array) => Buffer.from(bz).toString("hex"); - - const privKeyBz = Mnemonic.generateWalletFromMnemonic(MNEMONIC); - const privKey = new PrivKeySecp256k1(privKeyBz); - const pubKey = privKey.getPubKey(); - const addr = toBech32("osmo", pubKey.getAddress()); - - const digest = Hash.sha256(Buffer.from(TARGET || addr)); - const sign = privKey.signDigest32(digest); - - console.log( - JSON.stringify( - { - pubKey: bzToStr(pubKey.toBytes()), - privKey: bzToStr(privKey.toBytes()), - address: addr, - signature: bzToStr(sign), - }, - null, - 2 - ) - ); - - const verified = pubKey.verifyDigest32(digest, sign); - if (!verified) { - throw Error("verification failed"); - } -} - -main().catch(console.error);