예제 #1
0
    def Storage_GetReadOnlyContext(self, engine: ExecutionEngine):
        hash = UInt160(data=engine.CurrentContext.ScriptHash())
        context = StorageContext(script_hash=hash, read_only=True)

        engine.CurrentContext.EvaluationStack.PushT(StackItem.FromInterface(context))

        return True
예제 #2
0
    def Storage_GetContext(self, engine):

        hash = UInt160(data=engine.CurrentContext.ScriptHash())
        context = StorageContext(script_hash=hash)

        engine.EvaluationStack.PushT(StackItem.FromInterface(context))

        return True
예제 #3
0
    def StorageContext_AsReadOnly(self, engine: ExecutionEngine):
        context = engine.CurrentContext.EvaluationStack.Pop.GetInterface()

        if context is None:
            return False

        if not context.IsReadOnly:
            context = StorageContext(script_hash=context.ScriptHash, read_only=True)

        engine.CurrentContext.EvaluationStack.PushT(StackItem.FromInterface(context))
        return True
예제 #4
0
    def Contract_GetStorageContext(self, engine):

        contract = engine.EvaluationStack.Pop().GetInterface()

        if contract.ScriptHash.ToBytes() in self._contracts_created:

            created = self._contracts_created[contract.ScriptHash.ToBytes()]

            if created == UInt160(data=engine.CurrentContext.ScriptHash()):

                context = StorageContext(script_hash=contract.ScriptHash)
                engine.EvaluationStack.PushT(StackItem.FromInterface(context))

        return True
예제 #5
0
    def Contract_GetStorageContext(self, engine):

        contract = engine.EvaluationStack.Pop().GetInterface('neo.Core.State.ContractState.ContractState')

        self.__log.debug("CONTRACT Get storage context %s " % contract)
        if contract.ScriptHash.ToBytes() in self._contracts_created:
            created = self._contracts_created[contract.ScriptHash.ToBytes()]

            if created == UInt160(data=engine.CurrentContext.ScriptHash()):

                context = StorageContext(script_hash=contract.ScriptHash)
                engine.EvaluationStack.PushT(StackItem.FromInterface(context))
                return True

        return False