Skip to content

Commit

Permalink
https://github.com/neo-project/neo/pull/2333
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje committed Apr 19, 2021
1 parent 6c2dcc3 commit 924c6c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
7 changes: 3 additions & 4 deletions neo3/contracts/native/nameservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class NameState(NFTState):
def __init__(self,
owner: types.UInt160,
name: str,
description: str,
expiration: int,
admin: Optional[types.UInt160] = None):
super(NameState, self).__init__(owner, name, description)
super(NameState, self).__init__(owner, name)
self.expiration = expiration
self.admin = admin if admin else types.UInt160.zero()
self.id = name.encode()
Expand All @@ -44,7 +43,7 @@ def deserialize(self, reader: serialization.BinaryReader) -> None:

@classmethod
def _serializable_init(cls):
return cls(types.UInt160.zero(), "", "", 0, types.UInt160.zero())
return cls(types.UInt160.zero(), "", 0, types.UInt160.zero())


class StringList(list, serialization.ISerializable):
Expand Down Expand Up @@ -144,7 +143,7 @@ def register(self, engine: contracts.ApplicationEngine, name: str, owner: types.
raise ValueError("CheckWitness failed")
engine.add_gas(self.get_price(engine.snapshot))

state = NameState(owner, name, "", (engine.snapshot.persisting_block.timestamp // 1000) + self.ONE_YEAR)
state = NameState(owner, name, (engine.snapshot.persisting_block.timestamp // 1000) + self.ONE_YEAR)
self.mint(engine, state)
engine.snapshot.storages.put(
self.key_expiration + state.expiration.to_bytes(4, 'big') + name.encode(),
Expand Down
12 changes: 4 additions & 8 deletions neo3/contracts/native/nonfungible.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@


class NFTState(IInteroperable, serialization.ISerializable):
def __init__(self, owner: types.UInt160, name: str, description: str):
def __init__(self, owner: types.UInt160, name: str):
self.owner = owner
self.name = name
self.description = description
# I don't understand where this ID is coming from as its abstract in C# and not overridden
# we'll probably figure out once we implement the name service in a later PR
self.id: bytes = b''
Expand All @@ -22,31 +21,28 @@ def from_stack_item(cls, stack_item: vm.StackItem):
owner = types.UInt160(stack_item[0].to_array())
name = stack_item[1].to_array().decode()
description = stack_item[2].to_array().decode()
return cls(owner, name, description)
return cls(owner, name)

def to_stack_item(self, reference_counter: vm.ReferenceCounter) -> vm.StackItem:
return vm.StructStackItem(reference_counter, [
vm.ByteStringStackItem(self.owner.to_array()),
vm.ByteStringStackItem(self.name),
vm.ByteStringStackItem(self.description)
])

def serialize(self, writer: serialization.BinaryWriter) -> None:
writer.write_serializable(self.owner)
writer.write_var_string(self.name)
writer.write_var_string(self.description)

def deserialize(self, reader: serialization.BinaryReader) -> None:
self.owner = reader.read_serializable(types.UInt160)
self.name = reader.read_var_string()
self.description = reader.read_var_string()

def to_json(self) -> dict:
return {"name": self.name, "description": self.description}
return {"name": self.name}

@classmethod
def _serializable_init(cls):
return cls(types.UInt160.zero(), "", "")
return cls(types.UInt160.zero(), "")


class NFTAccountState(FungibleTokenStorageState):
Expand Down

0 comments on commit 924c6c4

Please sign in to comment.