Skip to content

Commit

Permalink
improved validator checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscojoray committed Mar 18, 2024
1 parent 792255a commit 99fe6e2
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 17 deletions.
Binary file removed design/img/collect.png
Binary file not shown.
Binary file removed design/img/moveShip.png
Binary file not shown.
Binary file removed design/img/quit.png
Binary file not shown.
35 changes: 18 additions & 17 deletions design/design.md → mvp-design/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Introduction
This document describes the technical design of the Asteria dApp - the script UTxOs involved, the operations that take place both during the game and in the setup phase, and the necessary validators and minting policies.

There will be a single script UTxO for the `Pot`, several `PelletState` UTxOs and a `ShipState` UTxO for every user. The `Pot` UTxO locks the ada amount paid by each user when creating a ship, and it's position on the board is always assumed to be (0,0). Both `PelletState` and `ShipState` UTxOs have their positions specified in the datum. In order to identify valid game UTxOs, the admin will deposit a special token in the `PelletState` and `Pot` UTxOs when creating them.
There will be a single script UTxO for the `Pot`, several `PelletState` UTxOs and a `ShipState` UTxO for every user. The `Pot` UTxO locks the ada amount paid by each user when creating a ship, and it's position on the board is always assumed to be (0,0). Both `PelletState` and `ShipState` UTxOs have their positions specified in the datum. In order to identify valid game UTxOs, the admin will deposit a special token (the "admin token") in the `PelletState` and `Pot` UTxOs when creating them. This token is also used for parameterizing the pot and fuel validators, so we could have different "versions" of the game, each one with a different admin token.

Each ship will be identified by a `ShipToken`, with a fixed policy id but a token name of their own. This is the token that is minted by the _Ship minting policy_, described in the validators section.

Expand All @@ -19,7 +19,8 @@ Each ship will be identified by a `ShipToken`, with a fixed policy id but a toke
>* pos_x: **Int**
>* pos_y: **Int**
>* fuel: **Int**
>* pilot_token: **ByteArray**
>* pilot_token: **(PolicyId, AssetName)**
>* ship_token_policy: **PolicyId**
>
>#### Value
>* minAda
Expand Down Expand Up @@ -59,7 +60,7 @@ Each ship will be identified by a `ShipToken`, with a fixed policy id but a toke
## Transactions

### Create Pot UTxO:
This transaction creates the unique `Pot` UTxO locking min ada and an admin token.
This transaction creates the unique `Pot` UTxO locking min ada and an admin token. It stores in the datum the ship token policy id for being able to reference it in the validator.

![createPot diagram](img/createPot.png)

Expand Down Expand Up @@ -119,57 +120,57 @@ Pays the min ada locked in the `ShipState` UTxO back to the ship owner and burns

#### *Gather Redeemer (includes gathering amount)*
* ship token is present in some input.
* there is a `ShipState` input with the same x and y datum coordinates as the `PelletState` UTxO.
* the amount specified is not greater than the fuel available in the pellet.
* the amount specified is subtracted from the output `PelletState` fuel datum field, and the other fields remain unchanged.

### ShipState validator:
* Params: admin token, `Pot` validator address and `PelletState` validator address.

#### *MoveShip Redeemer (includes delta_x and delta_y displacements)*
* ship token is present.
* there is a single `ShipState` input.
* there is a single `ShipState` output.
* the `PilotToken` is present in an input.
* the `ShipState` input has enough fuel to move the desired delta.
* the `ShipState` output value doesn't change.
* the pilot_token datum field is not changed.
* the x and y output datum values are updated as the previous ones (input values) plus the corresponding deltas.
* the output fuel datum field equals the input fuel minus the fuel required for the displacement.
* the distance advanced doesn't exceed the `MAX_SHIP_MOVEMENT_PER_TX`.
* the tx is signed by the ship owner.

#### *Gather Redeemer (includes gathering amount)*
* the amount specified plus the fuel before charging does not exceed the ship's capacity.
* there is a single `ShipState` input.
* there is a single `ShipState` output.
* there is a `PelletState` input with the same x and y datum coordinates as the `ShipState` UTxO.
* the amount specified plus the fuel before charging does not exceed the ship's fuel capacity.
* the amount specified is added to the output `ShipState` fuel datum field, and the other fields remain unchanged.
* the `ShipState` output value is the same as the input.

#### *Collect Redeemer*
* there is a single `ShipState` input.
* pilot token is present.
* `ShipState` position is (0,0).
* `Pot` UTxO is input.
* the ada value in the `ShipState` UTxO plus at least 50% of the ada value in the `Pot` UTxO is paid to the ship owner.
* ship token is burnt.

#### *Quit Redeemer*
* there is a single `ShipState` input.
* the `PilotToken` is present in an input.
* no `ShipState` output.
* signed by ship owner.

### Ship minting policy:
* Params: `ShipState` validator address.

#### MINT:

***TX:***
* a single token is minted.
* there is a single `ShipState` output.
* signed by the player joining the game.

***DATUM:***
* the `ShipState` output datum has x and y coordinates such that distance from (0,0) is above the minimum.
* the `ShipState` output datum has x and y coordinates such that distance from (0,0) is above the minimum distance.
* the `ShipState` output datum has the `ship_token_policy` set as the policy id of the minted token.
* the `ShipState` fuel datum field equals some initial value.

***VALUE:***
* the minted token is paid to the `ShipState` validator address.

#### BURN:

***TX:***
* there is a `ShipState` input.
* the `ShipState` input is at coordinates (0,0).
* only one token is burnt.
Binary file added mvp-design/img/collect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mvp-design/img/moveShip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mvp-design/img/quit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 99fe6e2

Please sign in to comment.