update deployed voucher list
This commit is contained in:
parent
8abbf2f938
commit
679d92ae4d
47
parse.py
47
parse.py
@ -68,14 +68,14 @@ lexer = lex.lex()
|
|||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# Chain Params
|
# Chain Params
|
||||||
chainId = os.getenv("CHAIN_ID","44787")
|
chainId = os.getenv("CHAIN_ID", "44787")
|
||||||
rpc = os.getenv("RPC","https://alfajores-forno.celo-testnet.org/")
|
rpc = os.getenv("RPC", "https://alfajores-forno.celo-testnet.org/")
|
||||||
gas_cap = os.getenv("GAS_FEE_CAP","35000000000")
|
gas_cap = os.getenv("GAS_FEE_CAP", "35000000000")
|
||||||
|
|
||||||
|
|
||||||
master_private_key = os.getenv("MASTER_PRIVATE_KEY")
|
master_private_key = os.getenv("MASTER_PRIVATE_KEY")
|
||||||
token_index = os.getenv("TOKEN_INDEX","0xD774bc082003eaF8DF74eEcD43AD44F03D488418")
|
token_index = os.getenv("TOKEN_INDEX", "0xD774bc082003eaF8DF74eEcD43AD44F03D488418")
|
||||||
gas_topup = os.getenv("GAS_TOPUP","0.01ether")
|
gas_topup = os.getenv("GAS_TOPUP", "0.01ether")
|
||||||
|
|
||||||
bearer_token = os.getenv("BEARER_TOKEN")
|
bearer_token = os.getenv("BEARER_TOKEN")
|
||||||
|
|
||||||
@ -103,7 +103,12 @@ w3 = Web3(Web3.HTTPProvider(rpc))
|
|||||||
|
|
||||||
class VoucherTransfer:
|
class VoucherTransfer:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, to_address=None, from_address=None, amount=None, token_address=None,decimals = None
|
self,
|
||||||
|
to_address=None,
|
||||||
|
from_address=None,
|
||||||
|
amount=None,
|
||||||
|
token_address=None,
|
||||||
|
decimals=None,
|
||||||
):
|
):
|
||||||
self.to_address = to_address
|
self.to_address = to_address
|
||||||
self.from_address = from_address
|
self.from_address = from_address
|
||||||
@ -111,10 +116,9 @@ class VoucherTransfer:
|
|||||||
self.amount = amount
|
self.amount = amount
|
||||||
self.token_address = token_address
|
self.token_address = token_address
|
||||||
|
|
||||||
|
|
||||||
class VoucherDetail:
|
class VoucherDetail:
|
||||||
def __init__(
|
def __init__(self, name=None, symbol=None, decimals=None, owner=None, address=None):
|
||||||
self, name =None, symbol =None, decimals =None,owner = None,address = None
|
|
||||||
):
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
self.address = address
|
self.address = address
|
||||||
@ -434,7 +438,7 @@ def store_key_in_keystore(keystore_dir, private_key, key_name, address):
|
|||||||
return store_path
|
return store_path
|
||||||
|
|
||||||
|
|
||||||
def load_gas(address,nonce):
|
def load_gas(address, nonce):
|
||||||
command = (
|
command = (
|
||||||
f"cast send {address} "
|
f"cast send {address} "
|
||||||
f"--value {gas_topup} "
|
f"--value {gas_topup} "
|
||||||
@ -478,7 +482,7 @@ def create_custodialaccount():
|
|||||||
|
|
||||||
|
|
||||||
def do_custodial_token_transfer(transfer):
|
def do_custodial_token_transfer(transfer):
|
||||||
#token transfer custodial endpoint
|
# token transfer custodial endpoint
|
||||||
url = "http://localhost:5003/api/v2/token/transfer"
|
url = "http://localhost:5003/api/v2/token/transfer"
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@ -513,7 +517,7 @@ def store_voucher(voucher_detail):
|
|||||||
"voucher_address": voucher_detail.address,
|
"voucher_address": voucher_detail.address,
|
||||||
"owner": voucher_detail.owner,
|
"owner": voucher_detail.owner,
|
||||||
"symbol": voucher_detail.symbol,
|
"symbol": voucher_detail.symbol,
|
||||||
"decimals": voucher_detail.decimals
|
"decimals": voucher_detail.decimals,
|
||||||
}
|
}
|
||||||
vouchers.append(voucher)
|
vouchers.append(voucher)
|
||||||
try:
|
try:
|
||||||
@ -534,8 +538,8 @@ def key_create_handler(cmd):
|
|||||||
store_name = cmd.t
|
store_name = cmd.t
|
||||||
|
|
||||||
keystore_dir = "user_store"
|
keystore_dir = "user_store"
|
||||||
master_address = w3.eth.account.from_key(master_private_key)
|
master_address = w3.eth.account.from_key(master_private_key)
|
||||||
nonce = w3.eth.get_transaction_count(master_address.address,'pending')
|
nonce = w3.eth.get_transaction_count(master_address.address, "pending")
|
||||||
|
|
||||||
if cmd.k is None:
|
if cmd.k is None:
|
||||||
address, private_key = generate_private_key()
|
address, private_key = generate_private_key()
|
||||||
@ -553,8 +557,7 @@ def key_create_handler(cmd):
|
|||||||
private_key = None
|
private_key = None
|
||||||
keystore_dir = "custodialstore"
|
keystore_dir = "custodialstore"
|
||||||
|
|
||||||
|
load_gas(address, nonce)
|
||||||
load_gas(address,nonce)
|
|
||||||
|
|
||||||
store_key_in_keystore(keystore_dir, private_key, key_name, address)
|
store_key_in_keystore(keystore_dir, private_key, key_name, address)
|
||||||
return address
|
return address
|
||||||
@ -571,7 +574,7 @@ def voucher_create_handler(cmd):
|
|||||||
voucher_detail.name = cmd.n
|
voucher_detail.name = cmd.n
|
||||||
voucher_detail.decimals = cmd.v
|
voucher_detail.decimals = cmd.v
|
||||||
|
|
||||||
random_ascii = "".join(random.choices(string.ascii_letters, k=3)).upper()
|
random_ascii = "".join(random.choices(string.ascii_letters, k=4)).upper()
|
||||||
try:
|
try:
|
||||||
with open("vouchers.json", "r") as f:
|
with open("vouchers.json", "r") as f:
|
||||||
existing_vouchers = json.load(f)
|
existing_vouchers = json.load(f)
|
||||||
@ -617,11 +620,11 @@ def voucher_create_handler(cmd):
|
|||||||
|
|
||||||
store_voucher(voucher_detail)
|
store_voucher(voucher_detail)
|
||||||
|
|
||||||
# sleep for 5 second to allow chain to sync
|
# sleep for 5 second to allow chain to sync
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
master_address = w3.eth.account.from_key(master_private_key)
|
master_address = w3.eth.account.from_key(master_private_key)
|
||||||
nonce = w3.eth.get_transaction_count(master_address.address,'pending')
|
nonce = w3.eth.get_transaction_count(master_address.address, "pending")
|
||||||
|
|
||||||
# Command to add the token to the token index
|
# Command to add the token to the token index
|
||||||
add_token_to_index = (
|
add_token_to_index = (
|
||||||
@ -753,8 +756,8 @@ def voucher_transfer_handler(cmd):
|
|||||||
|
|
||||||
def voucher_mint_handler(cmd):
|
def voucher_mint_handler(cmd):
|
||||||
value = cmd.v
|
value = cmd.v
|
||||||
master_address = w3.eth.account.from_key(master_private_key)
|
master_address = w3.eth.account.from_key(master_private_key)
|
||||||
nonce = w3.eth.get_transaction_count(master_address.address,'pending')
|
nonce = w3.eth.get_transaction_count(master_address.address, "pending")
|
||||||
if str(cmd.t).startswith("NameAgent"):
|
if str(cmd.t).startswith("NameAgent"):
|
||||||
key_name = str(cmd.t).split(":")[1]
|
key_name = str(cmd.t).split(":")[1]
|
||||||
custodial_address = find_custodial_address(key_name)
|
custodial_address = find_custodial_address(key_name)
|
||||||
|
@ -1 +1 @@
|
|||||||
[{"voucher_address": "0x0CA60E4b670599466125Ef48FC9d733E2B8927E5", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPFXA", "decimals": 6}, {"voucher_address": "0x4EAbC5070721c9FE18d463Fb75bf6E2A04FbAeE7", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESAWX", "decimals": 6}, {"voucher_address": "0x803EC23bd814b954E938c2cF28356ea0241629D4", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAVJA", "decimals": 6}, {"voucher_address": "0xCe131E4f7fC9f23Ee7768E76a8D14852b3B044aF", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPLV", "decimals": 6}, {"voucher_address": "0xE276Dd85280B962D04F81CCee0eD295a92EC1Fa1", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESPH", "decimals": 6}, {"voucher_address": "0x4AFC95baBA518ec7F6172fDD720645f7a80B4540", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAZV", "decimals": 6}, {"voucher_address": "0xAD8e88D24017aFdf5c32deab6fb6104518b75b05", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPCY", "decimals": 6}, {"voucher_address": "0x4721fE870d23F97Ac0E74980061e922b7180508E", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESSH", "decimals": 6}, {"voucher_address": "0x7f5d2c9E9bFFe2f80D03a3D609Ce82C2c7fA78C2", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAWX", "decimals": 6}, {"voucher_address": "0x49666B0E0FFB6A8316708dE7b0CbB0085aC04a63", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMP", "decimals": 6}, {"voucher_address": "0x66bA02957ae7D8C624e0BE8a7223D0fF942F6608", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MES", "decimals": 6}, {"voucher_address": "0xC3744229442b410fc5CD5D438a8Bc0A749D8E4eC", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIA", "decimals": 6}]
|
[{"voucher_address": "0xa6E7258b375a98af44aECFc30e1B14BFc60913F0", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPNRAR", "decimals": 6}, {"voucher_address": "0xeCb48fcEd893757f7a956E556a215f2E8523b067", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESROLE", "decimals": 6}, {"voucher_address": "0x57B62c8ea79032fF21C95A0CC2b89433259dc8f6", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAPRNF", "decimals": 6}, {"voucher_address": "0x850FD17BeE9C849c4Ed61B3bA4D3c54576641595", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPDHKA", "decimals": 6}, {"voucher_address": "0x03ceb8E85d661626C421094ce7A0AF3a3FEEF8A3", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESPUFA", "decimals": 6}, {"voucher_address": "0x58e3Fa578D42cCd9Af8E8875a37d9C378456C47D", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAFWKG", "decimals": 6}, {"voucher_address": "0x0CA60E4b670599466125Ef48FC9d733E2B8927E5", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPFXA", "decimals": 6}, {"voucher_address": "0x4EAbC5070721c9FE18d463Fb75bf6E2A04FbAeE7", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESAWX", "decimals": 6}, {"voucher_address": "0x803EC23bd814b954E938c2cF28356ea0241629D4", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAVJA", "decimals": 6}, {"voucher_address": "0xCe131E4f7fC9f23Ee7768E76a8D14852b3B044aF", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPLV", "decimals": 6}, {"voucher_address": "0xE276Dd85280B962D04F81CCee0eD295a92EC1Fa1", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESPH", "decimals": 6}, {"voucher_address": "0x4AFC95baBA518ec7F6172fDD720645f7a80B4540", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAZV", "decimals": 6}, {"voucher_address": "0xAD8e88D24017aFdf5c32deab6fb6104518b75b05", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMPCY", "decimals": 6}, {"voucher_address": "0x4721fE870d23F97Ac0E74980061e922b7180508E", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MESSH", "decimals": 6}, {"voucher_address": "0x7f5d2c9E9bFFe2f80D03a3D609Ce82C2c7fA78C2", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIAWX", "decimals": 6}, {"voucher_address": "0x49666B0E0FFB6A8316708dE7b0CbB0085aC04a63", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "KMP", "decimals": 6}, {"voucher_address": "0x66bA02957ae7D8C624e0BE8a7223D0fF942F6608", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MES", "decimals": 6}, {"voucher_address": "0xC3744229442b410fc5CD5D438a8Bc0A749D8E4eC", "owner": "1e1d0c1519479f68d9c8d07352a8e7e7cb9e2c676bce422f84502412cf3954ba", "symbol": "MIA", "decimals": 6}]
|
Loading…
Reference in New Issue
Block a user