diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..73bf21c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +git+https://github.com/ethereum/web3.py.git +instantcli diff --git a/scripts/cidbytes.go b/scripts/cidbytes.go new file mode 100644 index 0000000..f4d0eda --- /dev/null +++ b/scripts/cidbytes.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "github.com/ipfs/go-cid" + "os" +) + +func main() { + if len(os.Args) != 2 { + fmt.Println("Usage: ./cidbytes ") + os.Exit(1) + } + piece_cid := os.Args[1] + pieceCid, _ := cid.Parse(piece_cid) + fmt.Println(pieceCid.Bytes()) +} diff --git a/scripts/cli.py b/scripts/cli.py new file mode 100644 index 0000000..b08826a --- /dev/null +++ b/scripts/cli.py @@ -0,0 +1,11 @@ + +import instantcli +import renew +import json +def printme(result): + print(result) + +instantcli.post_call = printme + +instantcli.load_module( renew) +instantcli.cli() diff --git a/scripts/go.mod b/scripts/go.mod new file mode 100644 index 0000000..38244a7 --- /dev/null +++ b/scripts/go.mod @@ -0,0 +1,19 @@ +module github.com/snissn/ipfs + +go 1.18 + +require github.com/ipfs/go-cid v0.3.2 + +require ( + github.com/klauspost/cpuid/v2 v2.0.4 // indirect + github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect + github.com/minio/sha256-simd v1.0.0 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/multiformats/go-base32 v0.0.3 // indirect + github.com/multiformats/go-base36 v0.1.0 // indirect + github.com/multiformats/go-multibase v0.0.3 // indirect + github.com/multiformats/go-multihash v0.0.15 // indirect + github.com/multiformats/go-varint v0.0.6 // indirect + golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf // indirect + golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect +) diff --git a/scripts/go.sum b/scripts/go.sum new file mode 100644 index 0000000..a34c17e --- /dev/null +++ b/scripts/go.sum @@ -0,0 +1,32 @@ +github.com/ipfs/go-cid v0.3.2 h1:OGgOd+JCFM+y1DjWPmVH+2/4POtpDzwcr7VgnB7mZXc= +github.com/ipfs/go-cid v0.3.2/go.mod h1:gQ8pKqT/sUxGY+tIwy1RPpAojYu7jAyCp5Tz1svoupw= +github.com/klauspost/cpuid/v2 v2.0.4 h1:g0I61F2K2DjRHz1cnxlkNSBIaePVoJIjjnHui8QHbiw= +github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= +github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= +github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= +github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= +github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= +github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= +github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= +github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= +github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk= +github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= +github.com/multiformats/go-multihash v0.0.15 h1:hWOPdrNqDjwHDx82vsYGSDZNyktOJJ2dzZJzFkOV1jM= +github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg= +github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= +github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf h1:B2n+Zi5QeYRDAEodEu72OS36gmTWjgpXr2+cWcBW90o= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY= +golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/scripts/renew.py b/scripts/renew.py new file mode 100644 index 0000000..4cf104b --- /dev/null +++ b/scripts/renew.py @@ -0,0 +1,51 @@ +from web3 import Web3 +import json +import os +import time + +DealClientAddress = "0xcB56EFB85d8035145450D28076C0994114B0BB7a" + +w3 = Web3(Web3.HTTPProvider('https://api.hyperspace.node.glif.io/rpc/v1')) +abi_json = "../out/DealClient.sol/DealClient.json" +try: + abi = json.load(open(abi_json))['abi'] + bytecode = json.load(open(abi_json))['bytecode']['object'] +except Exception: + print("Run forge b to compile abi") + raise + +PA=w3.eth.account.from_key(os.environ['PRIVATE_KEY']) + +def getTxInfo(): + return { 'from': PA.address, + 'nonce': w3.eth.get_transaction_count(PA.address)} + +def sendTx(tx): + tx['maxPriorityFeePerGas'] = max(tx['maxPriorityFeePerGas'], tx['maxFeePerGas']) # intermittently fails otherwise + tx['maxFeePerGas'] = max(tx['maxPriorityFeePerGas'], tx['maxFeePerGas']) # intermittently fails otherwise + tx_create = w3.eth.account.sign_transaction(tx, PA.privateKey) + tx_hash = w3.eth.send_raw_transaction(tx_create.rawTransaction) + return w3.eth.wait_for_transaction_receipt(tx_hash) + + +def deploy(): + DealClient = w3.eth.contract(abi=abi, bytecode=bytecode) + tx_info = getTxInfo() + construct_txn = DealClient.constructor().buildTransaction(tx_info) + tx_receipt = sendTx(construct_txn) + print(f'Contract deployed at address: { tx_receipt.contractAddress }') + + +def getContract(): + ContractFactory = w3.eth.contract(abi=abi) + contract = ContractFactory(DealClientAddress) + return contract + + +def wait(blockNumber): + wait_block_count = 0 + while True: + curBlock = w3.eth.get_block('latest') + if curBlock.number - blockNumber > wait_block_count: + return + time.sleep(1)