Skip to content
Open
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
4 changes: 2 additions & 2 deletions hathor/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
GENESIS_TOKEN_UNITS = 1 * (10**9) # 1B
GENESIS_TOKENS = GENESIS_TOKEN_UNITS * (10**DECIMAL_PLACES) # 100B

HATHOR_TOKEN_UID = b'\x00'
HATHOR_TOKEN_UID: bytes = b'\x00'


@unique
Expand Down Expand Up @@ -469,7 +469,7 @@ def GENESIS_TX2_TIMESTAMP(self) -> int:
ENABLE_NANO_CONTRACTS: NanoContractsSetting = NanoContractsSetting.DISABLED

# List of enabled blueprints.
BLUEPRINTS: dict[bytes, 'str'] = {}
BLUEPRINTS: dict[bytes, str] = {}

# The consensus algorithm protocol settings.
CONSENSUS_ALGORITHM: ConsensusSettings = PowSettings()
Expand Down
6 changes: 3 additions & 3 deletions hathor/dag_builder/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Iterator, NamedTuple, TypeVar
from typing import TYPE_CHECKING, Iterator, NamedTuple, Sequence, TypeVar

from hathor.dag_builder.types import DAGNode
from hathor.manager import HathorManager
Expand Down Expand Up @@ -49,9 +49,9 @@ def get_typed_vertex(self, name: str, type_: type[T]) -> T:
assert isinstance(vertex, type_)
return vertex

def get_typed_vertices(self, names: list[str], type_: type[T]) -> list[T]:
def get_typed_vertices(self, names: Sequence[str], type_: type[T]) -> Sequence[T]:
"""Get a list of vertices by name, asserting they are of the provided type."""
return [self.get_typed_vertex(name, type_) for name in names]
return tuple(self.get_typed_vertex(name, type_) for name in names)

def propagate_with(self, manager: HathorManager, *, up_to: str | None = None) -> None:
"""
Expand Down
8 changes: 7 additions & 1 deletion hathor/nanocontracts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from hathor.conf import settings
from hathor.nanocontracts.blueprint import Blueprint
from hathor.nanocontracts.context import Context
from hathor.nanocontracts.contract_accessor import get_contract
from hathor.nanocontracts.exception import NCFail
from hathor.nanocontracts.on_chain_blueprint import OnChainBlueprint
from hathor.nanocontracts.runner import Runner
from hathor.nanocontracts.storage import NCMemoryStorageFactory, NCRocksDBStorageFactory, NCStorageFactory
from hathor.nanocontracts.types import fallback, public, view
from hathor.nanocontracts.types import TokenUid, VertexId, fallback, public, view

# Identifier used in metadata's voided_by when a Nano Contract method fails.
NC_EXECUTION_FAIL_ID: bytes = b'nc-fail'
HATHOR_TOKEN_UID: TokenUid = TokenUid(VertexId(settings.HATHOR_TOKEN_UID))


__all__ = [
'Blueprint',
Expand All @@ -36,4 +40,6 @@
'fallback',
'view',
'NC_EXECUTION_FAIL_ID',
'HATHOR_TOKEN_UID',
'get_contract',
]
6 changes: 5 additions & 1 deletion hathor/nanocontracts/allowed_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
),
'collections': dict(OrderedDict=collections.OrderedDict),
# hathor
'hathor.nanocontracts': dict(Blueprint=nc.Blueprint),
'hathor.nanocontracts': dict(
Blueprint=nc.Blueprint,
HATHOR_TOKEN_UID=nc.HATHOR_TOKEN_UID,
get_contract=nc.contract_accessor.get_contract,
),
'hathor.nanocontracts.blueprint': dict(Blueprint=nc.Blueprint),
'hathor.nanocontracts.context': dict(Context=nc.Context),
'hathor.nanocontracts.exception': dict(NCFail=nc.NCFail),
Expand Down
9 changes: 8 additions & 1 deletion hathor/nanocontracts/blueprint_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ def call_public_method(
**kwargs: Any,
) -> Any:
"""Call a public method of another contract."""
return self.__runner.syscall_call_another_contract_public_method(nc_id, method_name, actions, args, kwargs)
return self.__runner.syscall_call_another_contract_public_method(
nc_id,
method_name,
actions,
args,
kwargs,
forbid_fallback=False,
)

@final
def proxy_call_public_method(
Expand Down
Loading
Loading