Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
- Creates epoch 3.3 and costs-4 in preparation for a hardfork to activate Clarity 4
- Adds support for new Clarity 4 builtins (not activated until epoch 3.3):
- `contract-hash?`
- `current-contract`
- `block-time`
- `to-ascii?`
- Added `contract_cost_limit_percentage` to the miner config file — sets the percentage of a block’s execution cost at which, if a large non-boot contract call would cause a BlockTooBigError, the miner will stop adding further non-boot contract calls and only include STX transfers and boot contract calls for the remainder of the block.
Expand Down
2 changes: 1 addition & 1 deletion clarity/src/vm/analysis/arithmetic_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl ArithmeticOnlyChecker<'_> {
match native_var {
ContractCaller | TxSender | TotalLiquidMicroSTX | BlockHeight | BurnBlockHeight
| Regtest | TxSponsor | Mainnet | ChainId | StacksBlockHeight | TenureHeight
| BlockTime => Err(Error::VariableForbidden(native_var)),
| BlockTime | CurrentContract => Err(Error::VariableForbidden(native_var)),
NativeNone | NativeTrue | NativeFalse => Ok(()),
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions clarity/src/vm/analysis/type_checker/v2_05/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ fn type_reserved_variable(variable_name: &str) -> Result<Option<TypeSignature>,
NativeFalse => TypeSignature::BoolType,
TotalLiquidMicroSTX => TypeSignature::UIntType,
Regtest => TypeSignature::BoolType,
TxSponsor | Mainnet | ChainId | StacksBlockHeight | TenureHeight | BlockTime => {
TxSponsor | Mainnet | ChainId | StacksBlockHeight | TenureHeight | BlockTime | CurrentContract => {
return Err(CheckErrors::Expects(
"tx-sponsor, mainnet, chain-id, stacks-block-height, tenure-height, and block-time should not reach here in 2.05".into(),
"tx-sponsor, mainnet, chain-id, stacks-block-height, tenure-height, block-time, and current-contract should not reach here in 2.05".into(),
)
.into())
}
Expand Down
1 change: 1 addition & 0 deletions clarity/src/vm/analysis/type_checker/v2_1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ fn type_reserved_variable(
Regtest => TypeSignature::BoolType,
Mainnet => TypeSignature::BoolType,
ChainId => TypeSignature::UIntType,
CurrentContract => TypeSignature::PrincipalType,
BlockTime => TypeSignature::UIntType,
};
Ok(Some(var_type))
Expand Down
10 changes: 10 additions & 0 deletions clarity/src/vm/docs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ to the same contract principal.",
example: "(print contract-caller) ;; Will print out a Stacks address of the transaction sender",
};

const CURRENT_CONTRACT_KEYWORD: SimpleKeywordAPI = SimpleKeywordAPI {
name: "current-contract",
snippet: "current-contract",
output_type: "principal",
description: "Returns the principal of the current contract.",
example:
"(print current-contract) ;; Will print out the Stacks address of the current contract",
};

const STACKS_BLOCK_HEIGHT_KEYWORD: SimpleKeywordAPI = SimpleKeywordAPI {
name: "stacks-block-height",
snippet: "stacks-block-height",
Expand Down Expand Up @@ -2690,6 +2699,7 @@ pub fn make_keyword_reference(variable: &NativeVariables) -> Option<KeywordAPI>
NativeVariables::Mainnet => MAINNET_KEYWORD.clone(),
NativeVariables::ChainId => CHAINID_KEYWORD.clone(),
NativeVariables::TxSponsor => TX_SPONSOR_KEYWORD.clone(),
NativeVariables::CurrentContract => CURRENT_CONTRACT_KEYWORD.clone(),
NativeVariables::BlockTime => BLOCK_TIME_KEYWORD.clone(),
};
Some(KeywordAPI {
Expand Down
Loading