@neo-one/smart-contract-compiler
Version:
NEO•ONE TypeScript smart contract compiler.
43 lines (41 loc) • 1.65 kB
JavaScript
import { GlobalProperty } from '../../constants';
import { Helper } from '../Helper';
export class IsCallerHelper extends Helper {
emit(sb, node, optionsIn) {
const options = sb.pushValueOptions(optionsIn);
sb.emitOp(node, 'DUP');
sb.emitHelper(node, options, sb.helpers.getGlobalProperty({ property: GlobalProperty.CallingScriptHash }));
sb.emitHelper(node, options, sb.helpers.if({
condition: () => {
sb.emitOp(node, 'EQUAL');
},
whenTrue: () => {
sb.emitOp(node, 'DROP');
sb.emitPushBoolean(node, true);
},
whenFalse: () => {
sb.emitOp(node, 'DUP');
sb.emitSysCall(node, 'Neo.Blockchain.GetContract');
sb.emitHelper(node, options, sb.helpers.if({
condition: () => {
sb.emitPushBuffer(node, Buffer.alloc(0, 0));
sb.emitOp(node, 'EQUAL');
},
whenTrue: () => {
sb.emitSysCall(node, 'Neo.Runtime.CheckWitness');
sb.emitHelper(node, options, sb.helpers.invocationIsCaller);
sb.emitOp(node, 'BOOLAND');
},
whenFalse: () => {
sb.emitOp(node, 'DROP');
sb.emitPushBoolean(node, false);
},
}));
},
}));
if (!optionsIn.pushValue) {
sb.emitOp(node, 'DROP');
}
}
}
//# sourceMappingURL=IsCallerHelper.js.map