Add a util method to create a provider auction
This commit is contained in:
parent
f1fdc48aaa
commit
2319699c68
@ -24,6 +24,8 @@ import tempfile
|
|||||||
import uuid
|
import uuid
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
AUCTION_KIND_PROVIDER = "provider"
|
||||||
|
TOKEN_DENOM = "alnt"
|
||||||
|
|
||||||
class AttrDict(dict):
|
class AttrDict(dict):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -471,6 +473,57 @@ class LaconicRegistryClient:
|
|||||||
|
|
||||||
return AttrDict(json.loads(logged_cmd(self.log_file, *args)))
|
return AttrDict(json.loads(logged_cmd(self.log_file, *args)))
|
||||||
|
|
||||||
|
def create_auction(self, auction):
|
||||||
|
if auction["kind"] == "provider":
|
||||||
|
args = [
|
||||||
|
"laconic",
|
||||||
|
"-c",
|
||||||
|
self.config_file,
|
||||||
|
"registry",
|
||||||
|
"auction",
|
||||||
|
"create",
|
||||||
|
"--kind",
|
||||||
|
auction["kind"],
|
||||||
|
"--commits-duration",
|
||||||
|
str(auction["commits_duration"]),
|
||||||
|
"--reveals-duration",
|
||||||
|
str(auction["reveals_duration"]),
|
||||||
|
"--denom",
|
||||||
|
auction["denom"],
|
||||||
|
"--commit-fee",
|
||||||
|
str(auction["commit_fee"]),
|
||||||
|
"--reveal-fee",
|
||||||
|
str(auction["reveal_fee"]),
|
||||||
|
"--max-price",
|
||||||
|
str(auction["max_price"]),
|
||||||
|
"--num-providers",
|
||||||
|
str(auction["num_providers"])
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
args = [
|
||||||
|
"laconic",
|
||||||
|
"-c",
|
||||||
|
self.config_file,
|
||||||
|
"registry",
|
||||||
|
"auction",
|
||||||
|
"create",
|
||||||
|
"--kind",
|
||||||
|
auction["kind"],
|
||||||
|
"--commits-duration",
|
||||||
|
str(auction["commits_duration"]),
|
||||||
|
"--reveals-duration",
|
||||||
|
str(auction["reveals_duration"]),
|
||||||
|
"--denom",
|
||||||
|
auction["denom"],
|
||||||
|
"--commit-fee",
|
||||||
|
str(auction["commit_fee"]),
|
||||||
|
"--reveal-fee",
|
||||||
|
str(auction["reveal_fee"]),
|
||||||
|
"--minimum-bid",
|
||||||
|
str(auction["minimum_bid"])
|
||||||
|
]
|
||||||
|
|
||||||
|
return json.loads(logged_cmd(self.log_file, *args))["auctionId"]
|
||||||
|
|
||||||
def file_hash(filename):
|
def file_hash(filename):
|
||||||
return hashlib.sha1(open(filename).read().encode()).hexdigest()
|
return hashlib.sha1(open(filename).read().encode()).hexdigest()
|
||||||
@ -730,3 +783,17 @@ def skip_by_tag(r, include_tags, exclude_tags):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def create_provider_auction(laconic: LaconicRegistryClient, params):
|
||||||
|
auction_params = {
|
||||||
|
"kind": AUCTION_KIND_PROVIDER,
|
||||||
|
"commits_duration": params["commits_duration"],
|
||||||
|
"reveals_duration": params["reveals_duration"],
|
||||||
|
"denom": TOKEN_DENOM,
|
||||||
|
"commit_fee": params["commit_fee"],
|
||||||
|
"reveal_fee": params["reveal_fee"],
|
||||||
|
"max_price": params["max_price"],
|
||||||
|
"num_providers": params["num_providers"],
|
||||||
|
}
|
||||||
|
|
||||||
|
return laconic.create_auction(auction_params)
|
||||||
|
Loading…
Reference in New Issue
Block a user