-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Labels
cashc-compilerRelates to the cashc compilerRelates to the cashc compilerenhancementNew feature or requestNew feature or request
Milestone
Description
Rosco floated the idea that perhaps we could add syntactic sugar for the activeInput:
this.input (or this.activeInput) for tx.inputs[this.activeInputIndex] which would simplify common syntax
and to potentially do something similar for the corresponding output:
this.correspondingOutput for tx.outputs[this.activeInputIndex]
the drawback/danger of the syntax for the output is that it dilutes the meaning of this referring to the active script/input and is only slightly shorter (although no brackets)...
Example
With the new syntactic sugar, self-replicating covenants would then look like this:
require(this.correspondingOutput.lockingBytecode == this.activeInput.lockingBytecode);
require(this.correspondingOutput.tokenCategory == this.activeInput.tokenCategory);
require(this.correspondingOutput.value == 1000);
require(this.correspondingOutput.tokenAmount == this.activeInput.tokenAmount);
require(this.correspondingOutput.nftCommitment == this.activeInput.nftCommitment);whereas before:
require(tx.outputs[this.activeInputIndex].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode);
require(tx.outputs[this.activeInputIndex].tokenCategory == tx.inputs[this.activeInputIndex].tokenCategory);
require(tx.outputs[this.activeInputIndex].value == 1000);
require(tx.outputs[this.activeInputIndex].tokenAmount == tx.inputs[this.activeInputIndex].tokenAmount);
require(tx.outputs[this.activeInputIndex].nftCommitment == tx.inputs[this.activeInputIndex].nftCommitment);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cashc-compilerRelates to the cashc compilerRelates to the cashc compilerenhancementNew feature or requestNew feature or request