Compare commits
No commits in common. "d1a4f2ee5d186fc4a7282ea9d6a9d71b6ca947c0" and "a3d149a6593c4e9e422a4ad79097984eaad81cae" have entirely different histories.
d1a4f2ee5d
...
a3d149a659
@ -1,4 +0,0 @@
|
|||||||
PRIVATE_KEY=PRIVATE_KEY=1e1d0c151ajjajajsanakaka54ba
|
|
||||||
CHAIN_ID = 44787
|
|
||||||
RPC = https://alfajores-forno.celo-testnet.org
|
|
||||||
GAS_FEE_CAP = 35000000000
|
|
65
parse.py
65
parse.py
@ -9,7 +9,6 @@ import select
|
|||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
from multiprocessing import Pipe
|
from multiprocessing import Pipe
|
||||||
import subprocess
|
import subprocess
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
logg.setLevel(logging.DEBUG)
|
logg.setLevel(logging.DEBUG)
|
||||||
@ -52,17 +51,6 @@ def t_error(t):
|
|||||||
t.lexer.skip(1)
|
t.lexer.skip(1)
|
||||||
|
|
||||||
lexer = lex.lex()
|
lexer = lex.lex()
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
|
||||||
#Chain params
|
|
||||||
privatekey = os.getenv("PRIVATE_KEY")
|
|
||||||
chainId = os.getenv("CHAIN_ID")
|
|
||||||
rpc = os.getenv("RPC")
|
|
||||||
gasCap = os.getenv("GAS_FEE_CAP")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#data = '''
|
#data = '''
|
||||||
#FOOBAR uf-2etg 0xa3bdefa momo 123
|
#FOOBAR uf-2etg 0xa3bdefa momo 123
|
||||||
@ -312,7 +300,9 @@ class Router:
|
|||||||
def noop_handler(cmd):
|
def noop_handler(cmd):
|
||||||
return str(cmd)
|
return str(cmd)
|
||||||
|
|
||||||
|
#NOTE:
|
||||||
|
#For testing the handlers,am using my hard-coded private key for the cast commands,replace with your actual private key.
|
||||||
|
#I have added random characters to the existing.
|
||||||
def key_create_handler(cmd):
|
def key_create_handler(cmd):
|
||||||
mnemonic = cmd.i.replace('-', ' ')
|
mnemonic = cmd.i.replace('-', ' ')
|
||||||
command = f'cast wallet pk -v "{mnemonic}" 2 | cut -c 16-'
|
command = f'cast wallet pk -v "{mnemonic}" 2 | cut -c 16-'
|
||||||
@ -330,53 +320,46 @@ def key_create_handler(cmd):
|
|||||||
def voucher_create_handler(cmd):
|
def voucher_create_handler(cmd):
|
||||||
name = cmd.n
|
name = cmd.n
|
||||||
symbol = cmd.s
|
symbol = cmd.s
|
||||||
|
command = f'ge-publish --private-key 1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf39S4Ca ' \
|
||||||
command = f'ge-publish --private-key {privatekey} ' \
|
f'--rpc https://alfajores-forno.celo-testnet.org --gas-fee-cap 35000000000 --chainid 44787 ' \
|
||||||
f'--rpc {rpc} --gas-fee-cap {gasCap} --chainid {chainId} ' \
|
f'p erc20 --name "{name}" --symbol "{symbol}"'
|
||||||
f'p erc20 --name "{name}" --symbol "{symbol}"'
|
|
||||||
|
|
||||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||||
if result.returncode != 0:
|
|
||||||
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
|
||||||
output = result.stderr.strip().split("\n")
|
output = result.stderr.strip().split("\n")
|
||||||
contract_address = None
|
contract_address = None
|
||||||
|
|
||||||
for word in output[1].split():
|
for word in output[1].split():
|
||||||
if "contract_address=" in word:
|
if "contract_address=" in word:
|
||||||
contract_address = word.split("=")[1]
|
contract_address = word.split("=")[1]
|
||||||
print("Voucher created with Address:",contract_address)
|
|
||||||
return contract_address
|
return contract_address
|
||||||
|
|
||||||
def voucher_transfer_handler(cmd):
|
def voucher_transfer_handler(cmd):
|
||||||
value = cmd.v # Amount to transfer
|
value = cmd.v
|
||||||
s = "0x" + str(cmd.a).split(":")[1]
|
command = (
|
||||||
to = "0x" + str(cmd.t).split(":")[1]
|
f'cast send --private-key 1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cfsarw54ba '
|
||||||
|
f'--rpc-url https://alfajores-forno.celo-testnet.org/ '
|
||||||
command = (
|
f'0x93bb5f14464A9b7E5D5487DAB12d100417f23323 '
|
||||||
f'cast send --private-key {privatekey} '
|
f'"transfer(address,uint256)" 0x7c9eCcC1de442911954e36e6092DFb10373090a6 {value}'
|
||||||
f'--rpc-url {rpc} '
|
|
||||||
f'{s} '
|
|
||||||
f'"transfer(address,uint256)" {to} {value}'
|
|
||||||
)
|
)
|
||||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||||
if result.returncode != 0:
|
|
||||||
|
if result.returncode != 0:
|
||||||
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
||||||
if result.stderr:
|
if result.stderr:
|
||||||
raise ValueError(f"Command failed with error: {result.stderr}")
|
raise ValueError(f"Command failed with error: {result.stderr}")
|
||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def voucher_mint_handler(cmd):
|
def voucher_mint_handler(cmd):
|
||||||
value = cmd.v
|
value = cmd.v
|
||||||
s = "0x" + str(cmd.a).split(":")[1]
|
|
||||||
to = "0x" + str(cmd.t).split(":")[1]
|
|
||||||
command = (
|
command = (
|
||||||
f'cast send --private-key {privatekey}'
|
f'cast send --private-key 1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf39ASCa '
|
||||||
f'--rpc-url {rpc} '
|
f'--rpc-url https://alfajores-forno.celo-testnet.org/ '
|
||||||
f' {s} '
|
f'0x3feCC87C2c102984865B996de340bb2C6AdCF01E '
|
||||||
f'"mintTo(address,uint256)" {to} {value}'
|
f'"mintTo(address,uint256)" 0xEef7Ad2cCCB317E6898F43eA2B5b1BD1E9C13b1A {value}'
|
||||||
)
|
)
|
||||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
@ -456,8 +439,8 @@ if __name__ == '__main__':
|
|||||||
ifc = None
|
ifc = None
|
||||||
o = Router()
|
o = Router()
|
||||||
o.register(CmdId.KEY_CREATE,key_create_handler)
|
o.register(CmdId.KEY_CREATE,key_create_handler)
|
||||||
o.register(CmdId.VOUCHER_CREATE, voucher_create_handler)
|
|
||||||
o.register(CmdId.VOUCHER_MINT, voucher_mint_handler)
|
o.register(CmdId.VOUCHER_MINT, voucher_mint_handler)
|
||||||
|
o.register(CmdId.VOUCHER_CREATE, voucher_create_handler)
|
||||||
o.register(CmdId.VOUCHER_TRANSFER, voucher_transfer_handler)
|
o.register(CmdId.VOUCHER_TRANSFER, voucher_transfer_handler)
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
KEY_CREATE - lockkey custodialstore
|
|
||||||
VOUCHER_CREATE - stm stopcoin 6
|
|
||||||
VOUCHER_TRANSFER - 0x0d3D8A97f970fbdf7486274b02A8308d8aCcE6a1 5000000 0x74096A72495FE95710C675E78bd4A10f2BfE08BC 0xEef7Ad2cCCB317E6898F43eA2B5b1BD1E9C13b1A
|
|
||||||
VOUCHER_MINT - 0x2e8ce655BEfBee9b29A34fcecb3193462e4d0999 5000000 0x74096a72495fe95710c675e78bd4a10f2bfe08bc
|
|
Loading…
Reference in New Issue
Block a user