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

Merge release/cuttlefish into main #2040

Merged
merged 15 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-scrypto-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
tag: ${{ needs.tags.outputs.tag }}
context: "."
dockerfile: "Dockerfile"
target: "scrypto-builder"
platforms: "linux/amd64"
provenance: "false"
scan_image: true
Expand Down Expand Up @@ -74,8 +75,7 @@ jobs:

- uses: RDXWorks-actions/checkout@main
- name: Pull scrypto-builder docker image
run:
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker pull radixdlt/private-scrypto-builder:${{ needs.tags.outputs.tag }}
run: DOCKER_DEFAULT_PLATFORM=linux/amd64 docker pull radixdlt/private-scrypto-builder:${{ needs.tags.outputs.tag }}
- name: Build scrypto example using scrypto-builder
run: |
cp -r examples/everything test_package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-scrypto-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
tag: ${{ inputs.image-label }}
context: "."
dockerfile: "Dockerfile"
target: "scrypto-builder"
platforms: "linux/amd64"
provenance: "false"
scan_image: true
snyk_target_ref: ${{ github.ref_name }}
enable_dockerhub: true
secrets:
role_to_assume: ${{ secrets.DOCKERHUB_RELEASER_ROLE }}

19 changes: 18 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,24 @@ WORKDIR /app

RUN cargo install --path ./radix-clis

FROM base-image
# This dev-container image can be built with the following command:
# docker build . --target scrypto-dev-container -t scrypto-dev-container
FROM base-image AS scrypto-dev-container
RUN apt install -y curl bash-completion git
# Install improved prompt for better dev experience - https://starship.rs/
RUN curl -sS https://starship.rs/install.sh | sh -s -- -y
RUN echo 'eval "$(starship init bash)"\n . /etc/bash_completion' >> /root/.bashrc

COPY --from=builder /app/target/release/scrypto /usr/local/bin/scrypto
COPY --from=builder /app/target/release/resim /usr/local/bin/resim
COPY --from=builder /app/target/release/rtmc /usr/local/bin/rtmc
COPY --from=builder /app/target/release/rtmd /usr/local/bin/rtmd
COPY --from=builder /app/target/release/scrypto-bindgen /usr/local/bin/scrypto-bindgen
RUN rustup target add wasm32-unknown-unknown
RUN rustup component add rustfmt
RUN rustup component add clippy

FROM base-image AS scrypto-builder
COPY --from=builder /app/target/release/scrypto /usr/local/bin/scrypto
RUN rustup target add wasm32-unknown-unknown
WORKDIR /src
Expand Down
4 changes: 2 additions & 2 deletions examples/everything/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod everything {
Faucet as FiFi {
fn new(
address_reservation: GlobalAddressReservation,
bucket: Bucket
bucket: FungibleBucket
) -> Global<FiFi>;

fn lock_fee(&self, amount: Decimal);
Expand Down Expand Up @@ -96,7 +96,7 @@ mod everything {
faucet.lock_fee(amount);
}

pub fn public_method(&self) -> ResourceManager {
pub fn public_method(&self) -> NonFungibleResourceManager {
ResourceBuilder::new_ruid_non_fungible::<TestNFData>(OwnerRole::None)
.mint_roles(mint_roles! {
minter => rule!(allow_all);
Expand Down
12 changes: 6 additions & 6 deletions examples/hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ use scrypto::prelude::*;
#[blueprint]
mod hello {
struct Hello {
sample_vault: Vault,
sample_vault: FungibleVault,
}

impl Hello {
pub fn instantiate_hello() -> Component {
// stripped
}

pub fn free_token(&mut self) -> Bucket {
pub fn free_token(&mut self) -> FungibleBucket {
// stripped
}
}
Expand All @@ -47,7 +47,7 @@ The way to instantiate a component is through the `instantiate()` method on the

```rust
Self {
sample_vault: Vault::with_bucket(my_bucket),
sample_vault: FungibleVault::with_bucket(my_bucket),
}
.instantiate()
```
Expand All @@ -59,16 +59,16 @@ In Scrypto, assets like tokens, NFTs, and more are not implemented as blueprints
To define a new resource, we use the `ResourceBuilder`, specifying the metadata and initial supply. We can use the `ResourceBuilder` to create a simple fungible-supply token called `HelloToken` like this:

```rust
let my_bucket: Bucket = ResourceBuilder::new_fungible(OwnerRole::None)
let my_bucket: FungibleBucket = ResourceBuilder::new_fungible(OwnerRole::None)
.metadata("name", "HelloToken")
.metadata("symbol", "HT")
.mint_initial_supply(1000);
```

Once created, the 1000 resource-based `HelloToken` tokens are held in transient container `my_bucket`. To permanently store the created resources, we need to put them into a `Vault` like this:
Once created, the 1000 resource-based `HelloToken` tokens are held in transient container `my_bucket`. To permanently store the created resources, we need to put them into a `FungibleVault` like this:

```rust
let vault: Vault = Vault::with_bucket(my_bucket);
let vault = FungibleVault::with_bucket(my_bucket);
```

## How to Play?
Expand Down
8 changes: 4 additions & 4 deletions examples/hello-world/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use scrypto::prelude::*;
mod hello {
struct Hello {
// Define what resources and data will be managed by Hello components
sample_vault: Vault,
sample_vault: FungibleVault,
}

impl Hello {
Expand All @@ -13,7 +13,7 @@ mod hello {
// This is a function, and can be called directly on the blueprint once deployed
pub fn instantiate_hello() -> Global<Hello> {
// Create a new token called "HelloToken," with a fixed supply of 1000, and put that supply into a bucket
let my_bucket: Bucket = ResourceBuilder::new_fungible(OwnerRole::None)
let my_bucket: FungibleBucket = ResourceBuilder::new_fungible(OwnerRole::None)
.divisibility(DIVISIBILITY_MAXIMUM)
.metadata(metadata! {
init {
Expand All @@ -26,15 +26,15 @@ mod hello {

// Instantiate a Hello component, populating its vault with our supply of 1000 HelloToken
Self {
sample_vault: Vault::with_bucket(my_bucket),
sample_vault: FungibleVault::with_bucket(my_bucket),
}
.instantiate()
.prepare_to_globalize(OwnerRole::None)
.globalize()
}

// This is a method, because it needs a reference to self. Methods can only be called on components
pub fn free_token(&mut self) -> Bucket {
pub fn free_token(&mut self) -> FungibleBucket {
info!(
"My balance is: {} HelloToken. Now giving away a token!",
self.sample_vault.amount()
Expand Down
8 changes: 4 additions & 4 deletions radix-clis/assets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use scrypto::prelude::*;
mod hello {
struct Hello {
// Define what resources and data will be managed by Hello components
sample_vault: Vault,
sample_vault: FungibleVault,
}

impl Hello {
Expand All @@ -13,7 +13,7 @@ mod hello {
// This is a function, and can be called directly on the blueprint once deployed
pub fn instantiate_hello() -> Global<Hello> {
// Create a new token called "HelloToken," with a fixed supply of 1000, and put that supply into a bucket
let my_bucket: Bucket = ResourceBuilder::new_fungible(OwnerRole::None)
let my_bucket: FungibleBucket = ResourceBuilder::new_fungible(OwnerRole::None)
.divisibility(DIVISIBILITY_MAXIMUM)
.metadata(metadata! {
init {
Expand All @@ -26,15 +26,15 @@ mod hello {

// Instantiate a Hello component, populating its vault with our supply of 1000 HelloToken
Self {
sample_vault: Vault::with_bucket(my_bucket),
sample_vault: FungibleVault::with_bucket(my_bucket),
}
.instantiate()
.prepare_to_globalize(OwnerRole::None)
.globalize()
}

// This is a method, because it needs a reference to self. Methods can only be called on components
pub fn free_token(&mut self) -> Bucket {
pub fn free_token(&mut self) -> FungibleBucket {
info!(
"My balance is: {} HelloToken. Now giving away a token!",
self.sample_vault.amount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct RuleSet {
pub confirmation_role: AccessRule,
}

#[derive(Debug, Clone, PartialEq, Eq, ScryptoSbor)]
#[derive(Debug, Clone, PartialEq, Eq, ScryptoSbor, ManifestSbor)]
pub struct RecoveryProposal {
/// The set of rules being proposed for the different roles.
pub rule_set: RuleSet,
Expand Down
49 changes: 40 additions & 9 deletions scrypto-install-scripts/install-scrypto-macos.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Print commands and exit on errors
set -ex
# Exit on error
set -e

# Versions to install
LLVM_VERSION=18
Expand Down Expand Up @@ -31,11 +31,6 @@ echo -e "\n${BLUE}Installing Xcode Command Line Tools...${NC}"
xcode-select --install 2>/dev/null || true
check_status "Xcode Command Line Tools installation"

# Install cmake and LLVM
echo -e "\n${BLUE}Installing cmake and LLVM...${NC}"
brew install cmake llvm@$LLVM_VERSION
check_status "cmake and LLVM installation"

# Detect shell and configure appropriate rc file
SHELL_CONFIG=""
if [[ "$SHELL" == */bin/zsh ]]; then
Expand All @@ -47,10 +42,37 @@ else
exit 1
fi

# Check if Homebrew is installed, install if it's not
echo -e "\n${BLUE}Checking for Homebrew...${NC}"
if ! command -v brew &>/dev/null; then
echo -e "${BLUE}Homebrew not found. Installing Homebrew...${NC}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
check_status "Homebrew installation"

# Add Homebrew to PATH
echo -e "\n${BLUE}Configuring Homebrew in $SHELL_CONFIG...${NC}"
if [[ "$(uname -m)" == "arm64" ]]; then
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$SHELL_CONFIG"
eval "$(/opt/homebrew/bin/brew shellenv)"
else
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> "$SHELL_CONFIG"
eval "$(/usr/local/bin/brew shellenv)"
fi
check_status "Homebrew path configuration"
else
echo -e "${GREEN}Homebrew is already installed.${NC}"
fi

# Install cmake and LLVM
echo -e "\n${BLUE}Installing cmake and LLVM...${NC}"
brew install cmake --formula llvm@$LLVM_VERSION
check_status "cmake and LLVM installation"

# Add LLVM to PATH
echo -e "\n${BLUE}Configuring LLVM in $SHELL_CONFIG...${NC}"
if ! grep -q "$(brew --prefix llvm@${LLVM_VERSION})/bin" "$SHELL_CONFIG"; then
echo 'PATH="$(brew --prefix llvm@'$LLVM_VERSION')/bin:$PATH"' >> "$SHELL_CONFIG"
LLVM_PATH_LINE='export PATH="$(brew --prefix llvm@'"$LLVM_VERSION"')/bin:$PATH"'
if ! grep -Fxq "$LLVM_PATH_LINE" "$SHELL_CONFIG"; then
echo "$LLVM_PATH_LINE" >> "$SHELL_CONFIG"
fi
check_status "LLVM path configuration"

Expand All @@ -74,5 +96,14 @@ echo -e "\n${BLUE}Installing Radix Engine Simulator and CLI tools...${NC}"
cargo install --force radix-clis@$RADIX_CLI_VERSION
check_status "Radix tools installation"

# Verify installations
echo -e "\n${BLUE}Verifying installations...${NC}"
echo -e "Versions installed:"
echo -e "LLVM: $(llvm-config --version)"
echo -e "Clang: $(clang --version | head -n 1)"
echo -e "Rust: $(rustc --version)"
echo -e "Cargo: $(cargo --version)"
echo -e "Radix CLI: $(scrypto --version)"

echo -e "\n${GREEN}Installation complete! Please restart your terminal or run:${NC}"
echo -e "source $SHELL_CONFIG"
Loading