Skip to content

Commit

Permalink
Merge pull request #2039 from radixdlt/release/cuttlefish
Browse files Browse the repository at this point in the history
Merge Cuttlefish -> Develop
  • Loading branch information
0xOmarA authored Dec 10, 2024
2 parents bbb761d + c619e4b commit 45bd944
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 24 deletions.
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
45 changes: 38 additions & 7 deletions scrypto-install-scripts/install-scrypto-macos.sh
Original file line number Diff line number Diff line change
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"

0 comments on commit 45bd944

Please sign in to comment.