You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
My first thought is it would be nice to simplify down to something like:
function doThing() {
require(this.inputOutput == 1); //optional, reads more simply/makes sense with below terms
require(this.output.lockingBytecode == this.input.lockingBytecode);
require(this.output.tokenCategory == this.input.tokenCategory);
require(this.output.value == 1000);
require(this.output.tokenAmount == this.input.tokenAmount);
require(this.output.nftCommitment == this.input.nftCommitment);
}
When I look at contracts I'm already assuming the contract is only referring to the individual input being processed against it, and having checks done against other inputs/outputs always requires referring to them directly via tx.input/output[#]. I think the only time I ever use this. is specifying the activeInputIndex, so I feel the above would line up with that still.
Rosco floated the idea that perhaps we could add syntactic sugar for the activeInput:
this.input
(orthis.activeInput
) fortx.inputs[this.activeInputIndex]
which would simplify common syntaxand to potentially do something similar for the corresponding output:
this.correspondingOutput
fortx.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:
whereas before:
The text was updated successfully, but these errors were encountered: