Skip to content

Commit

Permalink
Merge pull request #186 from securesecrets/dev
Browse files Browse the repository at this point in the history
Airdrop Mainnet Release
  • Loading branch information
FloppyDisck authored Feb 22, 2022
2 parents 079a359 + 404d66d commit 7eeaaf2
Show file tree
Hide file tree
Showing 117 changed files with 7,076 additions and 3,865 deletions.
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[submodule "contracts/snip20"]
path = contracts/snip20
url = https://github.com/scrtlabs/snip20-reference-impl.git
branch = master
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ members = [
"contracts/governance",
"contracts/staking",
"contracts/mint",
"contracts/micro_mint",
"contracts/mint_router",
"contracts/treasury",
"contracts/oracle",
"contracts/snip20",
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| [`shade_staking`](./contracts/staking) | [doc](./contracts/staking/README.md) | Snip20 staker |
| [`scrt_staking`](./contracts/scrt_staking) | [doc](./contracts/scrt_staking/README.md) | SCRT staker |
| [`treasury`](./contracts/treasury) | [doc](./contracts/treasury/README.md) | Protocol's asset manager |
| [`mint`](./contracts/micro_mint) | [doc](./contracts/micro_mint/README.md) | Asset burner and minter |
| [`mint`](./contracts/mint) | [doc](./contracts/mint/README.md) | Asset burner and minter |
| [`oracle`](./contracts/oracle) | [doc](./contracts/oracle/README.md) | Asset price querier |
| [`airdrop`](./contracts/airdrop) | [doc](./contracts/airdrop/README.md) | Task based, multichain snip20 airdropper |

Expand Down Expand Up @@ -46,4 +46,4 @@ Each contract contains Rust unit and integration tests embedded within the contr

```sh
cargo unit-test
```
```
111 changes: 0 additions & 111 deletions contractlib/micro_mintlib.py

This file was deleted.

83 changes: 44 additions & 39 deletions contractlib/mintlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,55 @@


class Mint(Contract):
def __init__(self, label, oracle, contract='mint.wasm.gz', admin='a', uploader='a',
backend='test', instantiated_contract=None, code_id=None):
init_msg = json.dumps(
{"oracle": {"address": oracle.address, "code_hash": oracle.code_hash}})
def __init__(self, label, native_asset, oracle, treasury=None,
asset_peg=None,
contract='mint.wasm.gz',
admin='a', uploader='a',
backend='test', instantiated_contract=None, code_id=None):
init_msg = {
"native_asset": {
"address": native_asset.address,
"code_hash": native_asset.code_hash,
},
"oracle": {
"address": oracle.address,
"code_hash": oracle.code_hash
},
}
if treasury:
init_msg['treasury'] = {
'address': treasury.address,
'code_hash': treasury.code_hash,
}

if asset_peg:
init_msg['peg'] = asset_peg

print(json.dumps(init_msg, indent=2))
init_msg = json.dumps(init_msg)

super().__init__(contract, init_msg, label, admin, uploader, backend,
instantiated_contract=instantiated_contract, code_id=code_id)

def migrate(self, label, code_id, code_hash):
"""
Instantiate another mint contract and migrate this contracts info into that one
:param label: Label name of the contract
:param code_id: Code id of the contract
:param code_hash: Code hash
:return: new Mint
"""
msg = json.dumps(
{"migrate": {"label": label, "code_id": code_id, "code_hash": code_hash}})

new_mint = copy.deepcopy(self)
for attribute in self.execute(msg, compute=False)["logs"][0]["events"][0]["attributes"]:
if attribute["key"] == "contract_address":
new_mint.address = attribute["value"]
break
new_mint.code_id = code_id
new_mint.code_hash = code_hash
return new_mint

def update_config(self, owner=None, oracle=None):
def update_config(self, owner=None, native_asset=None, oracle=None):
"""
Updates the minting contract's config
:param owner: New admin
:param silk: Silk contract
:param native_asset: Snip20 to Mint
:param oracle: Oracle contract
:return: Result
"""
raw_msg = {"update_config": {}}
if owner is not None:
raw_msg["update_config"]["owner"] = owner

if native_asset is not None:
contract = {
"address": native_asset.address,
"code_hash": native_asset.code_hash
}
raw_msg["update_config"]["native_asset"] = contract

if oracle is not None:
contract = {
"address": oracle.address,
Expand All @@ -54,25 +65,19 @@ def update_config(self, owner=None, oracle=None):
msg = json.dumps(raw_msg)
return self.execute(msg)

def register_asset(self, snip20, name=None, burnable=None, total_burned=None):
def register_asset(self, snip20, capture=None):
"""
Registers a SNIP20 asset
:param total_burned: Total value burned
:param burnable: If burning is allowed
:param name: The Snip20's ticker
:param snip20: SNIP20 object to add
:param capture: Comission for the SNIP20
:return: Result
"""
raw_msg = {"register_asset": {"contract": {"address": snip20.address, "code_hash": snip20.code_hash}}}
if name is not None:
raw_msg["register_asset"]["name"] = name
if burnable is not None:
raw_msg["register_asset"]["burnable"] = burnable
if total_burned is not None:
raw_msg["register_asset"]["total_burned"] = total_burned
msg = json.dumps(raw_msg)
msg = {"register_asset": {"contract": {"address": snip20.address, "code_hash": snip20.code_hash}}}

return self.execute(msg)
if capture:
msg['register_asset']['capture'] = str(capture)

return self.execute(json.dumps(msg))

def get_supported_assets(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion contractlib/secretlib/secretlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run_command(command):
:param wait: Time to wait for command
:return: Output string
"""
# print('CMD', command)
#print(' '.join(command))
p = Popen(command, stdout=PIPE, stderr=PIPE, text=True)
output, err = p.communicate()
status = p.wait()
Expand Down
2 changes: 2 additions & 0 deletions contractlib/snip20lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def get_balance(self, address, password):
"""
msg = json.dumps(
{"balance": {"key": password, "address": address}})

msg = {"balance": {"key": password, "address": address}}
res = self.query(msg)

return res["balance"]["amount"]
Expand Down
4 changes: 1 addition & 3 deletions contracts/airdrop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ snafu = { version = "0.6.3" }
rs_merkle = { git = "https://github.com/FloppyDisck/rs-merkle", branch = "node_export" }
mockall = "0.10.2"
mockall_double = "0.2.0"

[dev-dependencies]
flexible-permits = {git = "https://github.com/securesecrets/flexible-permits", tag = "v1.0.1"}
query-authentication = {git = "https://github.com/securesecrets/query-authentication", tag = "v1.2.0"}
Loading

0 comments on commit 7eeaaf2

Please sign in to comment.