Skip to content

Commit

Permalink
Merge pull request #17 from AlgoRealm/develop
Browse files Browse the repository at this point in the history
Add test deployment guideline
  • Loading branch information
cusma authored Jan 2, 2023
2 parents 0349fd9 + af7d342 commit bff6263
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: 3.10.8

- name: Set up Poetry
uses: abatilo/actions-poetry@v2.1.6
uses: abatilo/actions-poetry@v2.2.0
with:
poetry-version: 1.1.13

Expand Down
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ignoreDeps": [],
"schedule": "before 3am on the first day of the month",
"assignees": ["cusma"],
"baseBranches": ["main"],
"baseBranches": ["develop"],
"separateMajorMinor": true,
"rebaseStalePrs": true,
"lockFileMaintenance": {
Expand Down
92 changes: 92 additions & 0 deletions src/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# AlgoRealm Depoloyment

The following procedure describe the AlgoRealm depoloyment process, which could
be useful in case of testing purposes. The deployment process consists in 4
steps: three for the artifacts creation and one for the artifacts binding.

### 1. AlgoRealm Test ASAs

#### Crown of Test

Creates the *Crown of Test* ASA with:

- Name: `Crown of Test`
- Unit Name: `CROWN`
- Total: `1`
- Decimals: `0`
- `manager` and the `clawback` addresses active;

Get the `TEST_CROWN_ID`.

#### Sceptre of Test

Creates the *Sceptre of Test* ASA with:

- Name: `Sceptre of Test`
- Unit Name: `SCEPTRE`
- Total: `1`
- Decimals: `0`
- `manager` and the `clawback` addresses active;

Get the `TEST_SCEPTRE_ID`.

### 2. AlgoRealm Test App

Depoloy the *AlgoRealm Test App* with:

- Approval Program: `algorealm_approval.teal` (compiling TEAL to AVM bytecode);
- Clear Program: `algorealm_clear.teal` (compiling TEAL to AVM bytecode);
- Global Ints: `2`;
- Global Bytes: `3`;
- Local Ints: `0`;
- Local Bytes: `0`;

Get the `TEST_ALGOREALM_APP_ID`.

### 3. AlgoRealm Test Law

Replace the `TMPL_` parameters in the `tmpl_algorealm_law.teal` Smart Signature
with the `TEST_` IDs obtained in the previous steps, specifically:

1. The `TEST_ALGOREALM_APP_ID` here:

```teal
// To the AlgoRealm App
gtxn 0 ApplicationID
int TMPL_ALGOREALM_APP_ID
```

2. The `TEST_CROWN_ID` and the `TEST_SCEPTRE_ID` here:

```teal
// Either of the Crown of Entropy
gtxn 2 XferAsset
int TMPL_CROWN_ASA_ID
==
// Or of the Sceptre of Proof
gtxn 2 XferAsset
int TMPL_SCEPTRE_ASA_ID
```

Save the updated TEAL source code as `algorealm_test_law.teal` and then compile
it to obtain the public key `TEST_ALGOREALM_ADDR` associated to the Smart
Signature.

Fund the `TEST_ALGOREALM_ADDR` with some ALGOs.

## 4. Bindings

Once all the artifacts are ready:

- `TEST_CROWN_ID`;
- `TEST_SCEPTRE_ID`;
- `TEST_ALGOREALM_APP_ID`;
- `TEST_ALGOREALM_ADDR`;

They must be **binded** as follows:

1. As a `manager`, set `TEST_ALGOREALM_ADDR` as `clawback` address of `TEST_CROWN_ID`;
2. As a `manager`, set `TEST_ALGOREALM_ADDR` as `clawback` address of `TEST_SCEPTRE_ID`;
3. Call the `TEST_ALGOREALM_APP_ID` passing the `TEST_ALGOREALM_ADDR` as first argument of the AppCall.

A new testing instance of AlgoRealm is now succesfully depolyed!
75 changes: 75 additions & 0 deletions src/contracts/tmpl_algorealm_law.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// AlgoRealm Law
#pragma version 2

// Must be a Group of 3 txns
global GroupSize
int 3
==

// First txn must be an AppCall
gtxn 0 TypeEnum
int appl
==
// To the AlgoRealm App
gtxn 0 ApplicationID
int TMPL_ALGOREALM_APP_ID
==
&&
&&

// Second txn must be a Payment donation
gtxn 1 TypeEnum
int pay
==
// From the AlgoRealm App caller
gtxn 1 Sender
gtxn 0 Sender
==
&&
// To the Rewards Pool
gtxn 1 Receiver
addr 737777777777777777777777777777777777777777777777777UFEJ2CI
==
&&
&&

// Third txn must be the NFT AssetTransfer
gtxn 2 TypeEnum
int axfer
==
// To the AlgoRealm donor
gtxn 2 AssetReceiver
gtxn 1 Sender
==
&&
// Either of the Crown of Entropy
gtxn 2 XferAsset
int TMPL_CROWN_ASA_ID
==
// Or of the Sceptre of Proof
gtxn 2 XferAsset
int TMPL_SCEPTRE_ASA_ID
==
||
&&
// The transfer is of a unique NFT
gtxn 2 AssetAmount
int 1
==
&&
// Paying at most 1000 microAlgos as txn fee
gtxn 2 Fee
int 1000
<=
&&
// With no AssetCloseTo
gtxn 2 AssetCloseTo
global ZeroAddress
==
&&
// With no RekeyTo
gtxn 2 RekeyTo
global ZeroAddress
==
&&
&&

0 comments on commit bff6263

Please sign in to comment.