Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(asset-manager): create asset manager library #19

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jdvlio
Copy link
Contributor

@jdvlio jdvlio commented May 6, 2022

Overview

A library for managing assets on the Algorand blockchain. This PR is intended to partially address issue #13

Task breakdown

  • Algorand blockchain integration:
    • Transaction signing
    • Transaction broadcasting
    • Asset creation
  • Test suite:
    • Integration test for DRT creation via the AlgoExplorer API
    • Set up mocking for unit tests

Todo

  • Fix the unit test
  • Add validation checks for conformance with Algorand API restrictions

Implementation

DRT encoding

DRTs are encoded as JSON objects in the note field of the initial asset configuration transaction that instantiated them as a new ASA on the Algorand blockchain. The structure of this object is outlined in the following table:

Field name Type Description
binary byte array base64 A cryptographic hash of the binary WASM executable.
binary_url string A URL pointing to the WASM binary.
data_package byte array base64 A cryptographic hash of the data package referenced by this DRT.
data_url string A URL pointing to the relevant data package.

Public API

A DrtConfig struct facilitates the creation of new DRTs on the Algorand blockchain. This struct is obtained via a DrtConfigBuilder struct by calling the build method. New DRTs are deployed as Algorand Standard Assets upon calling the asynchronous deploy method on the DrtConfig struct.

PiDelport and others added 3 commits April 28, 2022 11:36
* feat(ntc-vault-cli): initial layout

* style(ntc-vault-cli): add rustfmt.toml

* feat(ntc-vault-cli): add clap-based CLI skeleton

* feat(ntc-vault-cli): flesh out structure, implement identity subcommand

* refactor(ntc-vault-cli): separate code into two crates: core, cli

* refactor(ntc-vault-cli): move rand-using code from core to cli

* test(ntc-vault-cli): generate_secure_seed smoke test

* feat(ntc-vault-cli): data package and JSON Schema work-in-progress

* refactor: move crates into rust-workspace

* docs: add comment about using "cargo +nightly fmt"

* docs: add ARCHITECTURE.md

* refactor: rename package "ntc-vault-core" → "ntc-data-packages"

* feat(ntc-data-packages): replace anyhow with thiserror

* build(ntc-data-packages): drop jsonschema's default features

We don't need jsonschema's CLI, or the file / HTTP resolving features.

This greatly reduces our dependency tree.

* build: declare rust-version

* docs: add package descriptions

* feat(ntc-data-packages): better validation error messages

* ci(rust-workspace): add check and test workflows for GitHub Actions

* docs: fix rustdoc link issues

* build(rust-workspace): add rust-toolchain.toml, with channel = "stable"

* docs(README): add link to ARCHITECTURE.md

* deps(ntc-vault-cli): update confy revision for store_path fix

Upstream PR:

rust-cli/confy#60

(fix: `store_path` should create missing directories, like `load_path`)

* refactor(ntc-data-packages): move tests to API-based integration tests

Motivation:

https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html

* refactor(ntc-vault-cli): move try_exists to compat module

* refactor(ntc-vault-cli): VaultIdentityConfig: make pub

* deps(ntc-vault-cli): add dev dependencies for CLI tests

* test(ntc-vault-cli): add snapshot-based CLI tests

* deps(ntc-data-packages): add serde

* feat(ntc-data-packages): add Metadata::from_json_bytes

* feat(ntc-vault-cli): add fs_io, with read_metadata

* feat(ntc-vault-cli): implement more of the "data" subcommand

* chore: add todos to keep track of changes that needs to be made to allign with design

* chore(deps): update dependencies and bump jsonschema to 0.16

Co-authored-by: Herman <[email protected]>
* build(rust-sgx-workspace): add workspace for SGX code

* build(ntc-tee-server): add SGX project for the TEE server

* build(ntc-tee-server): bump Rust edition: "2018" → "2021"

* build(ntc-tee-server): better error message for missing Enclave_u library

* ci(rust-sgx-workspace): add check and test workflows for GitHub Actions

* ci: use nested checkout for the multiple repositories to prevent _temp being deleted

* style: fix clippy warnings

* ci: remove --all-targets build arg to fix enclave builds and checks

Co-authored-by: Herman <[email protected]>
@jdvlio jdvlio marked this pull request as draft May 6, 2022 14:40
@jdvlio jdvlio changed the title feat(asset-manager): create asset manager library [WIP] feat(asset-manager): create asset manager library May 6, 2022
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 4 times, most recently from 63300a8 to 739c161 Compare May 12, 2022 05:35
@jdvlio jdvlio requested a review from billguo99 May 12, 2022 06:11
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch from 739c161 to 9066361 Compare May 12, 2022 06:15
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 10 times, most recently from c5466f3 to d11b25b Compare May 19, 2022 05:51
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 6 times, most recently from dfc0c66 to 6fbc42e Compare May 25, 2022 04:23
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 2 times, most recently from 609da07 to c6b8655 Compare May 27, 2022 05:53
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 4 times, most recently from 13232fc to b8b6c7a Compare June 7, 2022 15:06
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 3 times, most recently from 611ac28 to 848a96f Compare June 15, 2022 14:40
@jdvlio jdvlio requested review from billguo99 and IscoRuta98 June 15, 2022 14:49
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 2 times, most recently from 6a26989 to d412f4e Compare June 17, 2022 06:26
@jdvlio jdvlio marked this pull request as ready for review June 17, 2022 06:59
@jdvlio jdvlio changed the title [WIP] feat(asset-manager): create asset manager library feat(asset-manager): create asset manager library Jun 17, 2022
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch from d412f4e to 7c26b0f Compare June 17, 2022 07:46
Create the initial version of the asset manager library.  Functionality
for the creation of DRTs on the Algorand blockchain is implemented.
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 4 times, most recently from 68b22d4 to cec2eaf Compare June 17, 2022 08:01
Use the `ALGORAND_MNEMONIC` environment variable in integration tests.
It holds the secret mnemonic for interacting with the Algorand blockchain.
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch 4 times, most recently from 17fd0b1 to 9a74113 Compare June 17, 2022 10:52
The `dotenv!` macro panics if no file named `.env` is present in the
workspace root.  Use `dotenv::var` function instead.
@jdvlio jdvlio force-pushed the feat-initial-asset-manager branch from 9a74113 to c0e4351 Compare June 17, 2022 11:15
[dependencies]
algonaut = { git = "https://github.com/manuelmauro/algonaut", rev = "30a251e438df9bb7af8b3aafc53bb9945a74c963" }
algonaut_client = { git = "https://github.com/manuelmauro/algonaut", rev = "30a251e438df9bb7af8b3aafc53bb9945a74c963" }
once_cell = "1.12"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you use this dependency (once_cell) in the library?

#[derive(Debug)]
pub struct DrtConfig {
creator: Address,
encoder: AsaNote,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use a different field name for encoder?
To me, the AsaNote is references to the code and data which is essentially the rights of the DRT.

@billguo99
Copy link
Contributor

Tested with my "Bert" algorand account and successfully created DRT through the integration test by supplying mnemonic in .env:

  1. https://testnet.algoexplorer.io/address/FX4RARS3PGUDGXF2OUTKUMTRTOWI3277UGIKINH4KREGHJTHMJFRYBIP2E
  2. https://testnet.algoexplorer.io/asset/96492563

});

let response = drt_config.submit(&mock_algod, &mock_account).await.unwrap();
assert!(matches!(response, TransactionResponse { .. }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool things learnt about unit tests:
Can run the following to output println! statements in test output and specificy --lib to just run the unit tests - https://doc.rust-lang.org/cargo/commands/cargo-test.html

cargo test --lib -- --nocapture

Can also make the assert more specific with but the above is sufficient:

assert_eq!(response.tx_id, "id");

@sonasi sonasi force-pushed the feat-initial-asset-manager branch from c0e4351 to 120708e Compare January 25, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants