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: add new build_clients logic #42

Merged
merged 1 commit into from
Jun 21, 2024
Merged

feat: add new build_clients logic #42

merged 1 commit into from
Jun 21, 2024

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Mar 25, 2024

Fixes #58

At the end of a loam build run, it will now run build_clients logic. This looks for an enviroments.toml file like the kind shown in loambuild/frontend, and automatically gets a frontend to a point where it would be ready to run. For example, running with the environments.toml file shown in the new tests/it/build_clients/contracts.rs file here, you get this output:

$ loam build
   Compiling loam-cli v0.8.0 (/Users/chadoh/code/loam/sdk/crates/loam-cli)
    Finished dev [unoptimized + debuginfo] target(s) in 5.43s
     Running `target/debug/loam build --manifest-path ./crates/loam-cli/tests/fixtures/soroban-init-boilerplate/Cargo.toml`
cargo rustc --manifest-path=crates/loam-cli/tests/fixtures/soroban-init-boilerplate/contracts/auth/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished release [optimized] target(s) in 0.07s
cargo rustc --manifest-path=crates/loam-cli/tests/fixtures/soroban-init-boilerplate/contracts/hello_world/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished release [optimized] target(s) in 0.04s
cargo rustc --manifest-path=crates/loam-cli/tests/fixtures/soroban-init-boilerplate/contracts/increment/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished release [optimized] target(s) in 0.04s
cargo rustc --manifest-path=crates/loam-cli/tests/fixtures/soroban-init-boilerplate/contracts/custom_types/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished release [optimized] target(s) in 0.04s
🌐 using network at http://localhost:8000/rpc
🔐 creating keys for "alice"
📲 installing "hello_world" wasm bytecode on-chain...
    ↳ hash: 97183d1986ce664266ba148e98a472b58064032cb7b57f2e2311ec2311944892
🪞 instantiating "hello_world" smart contract
    ↳ contract_id: CBTZIBW5MHZAXSRJELN22TNP7G7JD4WTN46652T5EAFLFKA6XR3GMJSO
🎭 binding "hello_world" contract

added 3 packages, and audited 47 packages in 621ms

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> tsc

🍽️ importing "hello_world" contract
📲 installing "soroban_auth_contract" wasm bytecode on-chain...
    ↳ hash: 2860c7f557f065d80d2e26e2e49146c6ced5f5b84f106d5c2e1733206eab3cb4
🪞 instantiating "soroban_auth_contract" smart contract
    ↳ contract_id: CA7PQX6T5QLV73PI27IANYYVINWYNKP7ZUEKCPOMDSZFHO5NLOODQYC5
🎭 binding "soroban_auth_contract" contract

added 3 packages, and audited 47 packages in 547ms

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> tsc

🍽️ importing "soroban_auth_contract" contract
📲 installing "soroban_custom_types_contract" wasm bytecode on-chain...
    ↳ hash: 57c7d3125a06aec612ad2f9e89ee44c6095827b9b78d15b16bd4aa94dc8b2341
🪞 instantiating "soroban_custom_types_contract" smart contract
    ↳ contract_id: CDNR257FK3IDXDEQP4ESQC4BPXO2LGSCAWOQ2DMWOYEGMLYA7U7RLKFR
🎭 binding "soroban_custom_types_contract" contract

added 3 packages, and audited 47 packages in 529ms

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> tsc

🍽️ importing "soroban_custom_types_contract" contract
📲 installing "soroban_increment_contract" wasm bytecode on-chain...
    ↳ hash: 7245f2e1717756379749da3c65907534808b44ccbf90d53c9b380ecb27bdaa72
🪞 instantiating "soroban_increment_contract" smart contract
    ↳ contract_id: CBQUBFAXPNXNBU7Q75MVPFUCSMD3T47DBFBISB6MO7UYQCPZK5VICBQL
🎭 binding "soroban_increment_contract" contract

added 3 packages, and audited 47 packages in 552ms

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> [email protected] build
> tsc

🍽️ importing "soroban_increment_contract" contract

(we might want to consider suppressing the stdout output of soroban contract bindings typescript by default)

Still simplistic

This is a good-enough starting point, and I'd like to merge it now so other people can help with some improvements. Right now, this logic is no better than the initialize.js script in soroban-astro-template. Notably, it does not:

@chadoh chadoh force-pushed the feat/build-clients branch 2 times, most recently from b586455 to c300072 Compare March 29, 2024 19:27
@chadoh chadoh changed the title feat: add new build_clients command feat: add new build_clients logic Jun 12, 2024
.cargo/config.toml Outdated Show resolved Hide resolved
@chadoh chadoh marked this pull request as ready for review June 13, 2024 19:41
@chadoh chadoh enabled auto-merge (squash) June 13, 2024 20:01

#[derive(Debug, serde::Deserialize, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct Network {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is defined in the soroban-cli crate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should keep our own definition. Ours is describing the format of the environments.toml file, which already differs slightly from the definition in stellar-cli (name vs network), and which may deviate more in the future. Additionally, the one in stellar-cli does not derive serde::Deserialize, and there's not really a reason for it to do so.

Copy link
Collaborator

@willemneal willemneal left a comment

Choose a reason for hiding this comment

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

Couple of design questions.

crates/loam-cli/src/commands/build/env_toml.rs Outdated Show resolved Hide resolved
crates/loam-cli/src/commands/build/env_toml.rs Outdated Show resolved Hide resolved
crates/loam-cli/src/commands/build/build_clients.rs Outdated Show resolved Hide resolved
crates/loam-cli/src/commands/build/build_clients.rs Outdated Show resolved Hide resolved
crates/loam-cli/src/commands/build/build_clients.rs Outdated Show resolved Hide resolved
crates/loam-cli/src/commands/build/build_clients.rs Outdated Show resolved Hide resolved
crates/loam-cli/src/commands/build/build_clients.rs Outdated Show resolved Hide resolved
always run `build-clients` at the end of `build`. If no
`environments.toml` file is found, it's a no-op.

adds integration tests at `crates/loam-cli/tests`

doesn't do a lot of things, but it works!

notably, it does not:

- check if accounts are already created/funded
- check if contracts are already created/using correct wasm hash
- run `init` commands for contract
- add `--env` argument to `loam build`; can only set this with
  `LOAM_ENV` environment variable
- test non-`"production"` environment settings

Co-authored-by: Willem Wyndham <[email protected]>
@chadoh
Copy link
Contributor Author

chadoh commented Jun 20, 2024

All addressed, thank youuuuuu

@chadoh chadoh merged commit fb2d87f into main Jun 21, 2024
1 check passed
@willemneal willemneal deleted the feat/build-clients branch June 21, 2024 14:20
@loambuild-app loambuild-app bot mentioned this pull request Jun 21, 2024
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.

loam build also builds clients from environments.toml settings
3 participants