Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Changing the structure of the originations object #9

Closed
kalouo opened this issue Aug 16, 2022 · 1 comment · Fixed by #10
Closed

Changing the structure of the originations object #9

kalouo opened this issue Aug 16, 2022 · 1 comment · Fixed by #10
Assignees

Comments

@kalouo
Copy link
Collaborator

kalouo commented Aug 16, 2022

Describe the issue
Changing the structure of the originations object for better discoverability.

Examples
The current originations object is structured as follows:

{
  "chinstrap": {
    "networks": {
      "development": {
        "ce454cb23b49e96cd9190eed128ab4eb5e83bca865b3c3ef1c4ede0124ba5a0a": {
          "orignation_hash": "ooDL2ymhse9ExVpJCV9M1xD54ACPXr7s7DQ2fejXTHz2jXmb94i",
          "address": "KT1VuEMFcjJ1GnhVyg3LdfYbhKH7F7wo2u5B",
          "name": "contract_name",
          "date": "2022-08-16T11:22:48.104119"
        },
      }
    }
  }
}

For better discoverability I propose the following:

{
  "chinstrap": {
    "networks": {
      "development": {
        "<contract_name>": [
          {
            "hash": "ce454cb23b49e96cd9190eed128ab4eb5e83bca865b3c3ef1c4ede0124ba5a0a",
            "orignation_hash": "ooDL2ymhse9ExVpJCV9M1xD54ACPXr7s7DQ2fejXTHz2jXmb94i",
            "address": "KT1VuEMFcjJ1GnhVyg3LdfYbhKH7F7wo2u5B",
            "name": "contract_name",
            "date": "2022-08-16T11:22:48.104119"
          }
        ]
      }
    }
  }
}

At every run of chinstrap originate, the script would check if a contract already exists at the corresponding index of the contract_name array. For example, suppose you want to deploy two instances of nft_contract to the sandbox and have two files in the originations/folder:

  • 1_nft_contract_a.py
  • 2_nft_contract_b.py

The steps would be as follows:

  1. On the first run of chinstrap originate, two instances will be originated and two corresponding objects will be appended to the array under chinstrap.networks.development.nft_contract
  2. On the second run of chinstrap originate, the script detects that contracts already exist at index 0 and 1 of the chinstrap.networks.development.nft_contract, and simply returns the existing deployments.
  3. You add 3_nft_contract_b.py to the originations/ folder and run chinstrap originate. The first two originations are skipped as per the logic above, but the third one is executed because the script detects nothing at index 3 of the nft_contract array.
@kalouo
Copy link
Collaborator Author

kalouo commented Aug 16, 2022

Optionally you could have an --overwrite flag for chinstrap originate. This would redeploy contracts and over-write an existing item at the given index.

This would function like hot reloading – but it might make sense to scope this out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants