id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2,800 | jsvine/spectra | spectra/grapefruit.py | Color.TriadicScheme | def TriadicScheme(self, angle=120, mode='ryb'):
'''Return two colors forming a triad or a split complementary with this one.
Parameters:
:angle:
The angle between the hues of the created colors.
The default value makes a triad.
:mode:
Select which color wheel to use for the ... | python | def TriadicScheme(self, angle=120, mode='ryb'):
'''Return two colors forming a triad or a split complementary with this one.
Parameters:
:angle:
The angle between the hues of the created colors.
The default value makes a triad.
:mode:
Select which color wheel to use for the ... | [
"def",
"TriadicScheme",
"(",
"self",
",",
"angle",
"=",
"120",
",",
"mode",
"=",
"'ryb'",
")",
":",
"h",
",",
"s",
",",
"l",
"=",
"self",
".",
"__hsl",
"angle",
"=",
"min",
"(",
"angle",
",",
"120",
")",
"/",
"2.0",
"if",
"mode",
"==",
"'ryb'",... | Return two colors forming a triad or a split complementary with this one.
Parameters:
:angle:
The angle between the hues of the created colors.
The default value makes a triad.
:mode:
Select which color wheel to use for the generation (ryb/rgb).
Returns:
A tuple of tw... | [
"Return",
"two",
"colors",
"forming",
"a",
"triad",
"or",
"a",
"split",
"complementary",
"with",
"this",
"one",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1860-L1902 |
2,801 | jsvine/spectra | spectra/core.py | Color.from_html | def from_html(cls, html_string):
"""
Create sRGB color from a web-color name or hexcode.
:param str html_string: Web-color name or hexcode.
:rtype: Color
:returns: A spectra.Color in the sRGB color space.
"""
rgb = GC.NewFromHtml(html_string).rgb
return ... | python | def from_html(cls, html_string):
rgb = GC.NewFromHtml(html_string).rgb
return cls("rgb", *rgb) | [
"def",
"from_html",
"(",
"cls",
",",
"html_string",
")",
":",
"rgb",
"=",
"GC",
".",
"NewFromHtml",
"(",
"html_string",
")",
".",
"rgb",
"return",
"cls",
"(",
"\"rgb\"",
",",
"*",
"rgb",
")"
] | Create sRGB color from a web-color name or hexcode.
:param str html_string: Web-color name or hexcode.
:rtype: Color
:returns: A spectra.Color in the sRGB color space. | [
"Create",
"sRGB",
"color",
"from",
"a",
"web",
"-",
"color",
"name",
"or",
"hexcode",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L33-L43 |
2,802 | jsvine/spectra | spectra/core.py | Color.to | def to(self, space):
"""
Convert color to a different color space.
:param str space: Name of the color space.
:rtype: Color
:returns: A new spectra.Color in the given color space.
"""
if space == self.space: return self
new_color = convert_color(self.col... | python | def to(self, space):
if space == self.space: return self
new_color = convert_color(self.color_object, COLOR_SPACES[space])
return self.__class__(space, *new_color.get_value_tuple()) | [
"def",
"to",
"(",
"self",
",",
"space",
")",
":",
"if",
"space",
"==",
"self",
".",
"space",
":",
"return",
"self",
"new_color",
"=",
"convert_color",
"(",
"self",
".",
"color_object",
",",
"COLOR_SPACES",
"[",
"space",
"]",
")",
"return",
"self",
".",... | Convert color to a different color space.
:param str space: Name of the color space.
:rtype: Color
:returns: A new spectra.Color in the given color space. | [
"Convert",
"color",
"to",
"a",
"different",
"color",
"space",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L45-L56 |
2,803 | jsvine/spectra | spectra/core.py | Color.blend | def blend(self, other, ratio=0.5):
"""
Blend this color with another color in the same color space.
By default, blends the colors half-and-half (ratio: 0.5).
:param Color other: The color to blend.
:param float ratio: How much to blend (0 -> 1).
:rtype: Color
:... | python | def blend(self, other, ratio=0.5):
keep = 1.0 - ratio
if not self.space == other.space:
raise Exception("Colors must belong to the same color space.")
values = tuple(((u * keep) + (v * ratio)
for u, v in zip(self.values, other.values)))
return self.__class__(self.... | [
"def",
"blend",
"(",
"self",
",",
"other",
",",
"ratio",
"=",
"0.5",
")",
":",
"keep",
"=",
"1.0",
"-",
"ratio",
"if",
"not",
"self",
".",
"space",
"==",
"other",
".",
"space",
":",
"raise",
"Exception",
"(",
"\"Colors must belong to the same color space.\... | Blend this color with another color in the same color space.
By default, blends the colors half-and-half (ratio: 0.5).
:param Color other: The color to blend.
:param float ratio: How much to blend (0 -> 1).
:rtype: Color
:returns: A new spectra.Color | [
"Blend",
"this",
"color",
"with",
"another",
"color",
"in",
"the",
"same",
"color",
"space",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L68-L85 |
2,804 | jsvine/spectra | spectra/core.py | Color.brighten | def brighten(self, amount=10):
"""
Brighten this color by `amount` luminance.
Converts this color to the LCH color space, and then
increases the `L` parameter by `amount`.
:param float amount: Amount to increase the luminance.
:rtype: Color
:returns: A new spec... | python | def brighten(self, amount=10):
lch = self.to("lch")
l, c, h = lch.values
new_lch = self.__class__("lch", l + amount, c, h)
return new_lch.to(self.space) | [
"def",
"brighten",
"(",
"self",
",",
"amount",
"=",
"10",
")",
":",
"lch",
"=",
"self",
".",
"to",
"(",
"\"lch\"",
")",
"l",
",",
"c",
",",
"h",
"=",
"lch",
".",
"values",
"new_lch",
"=",
"self",
".",
"__class__",
"(",
"\"lch\"",
",",
"l",
"+",... | Brighten this color by `amount` luminance.
Converts this color to the LCH color space, and then
increases the `L` parameter by `amount`.
:param float amount: Amount to increase the luminance.
:rtype: Color
:returns: A new spectra.Color | [
"Brighten",
"this",
"color",
"by",
"amount",
"luminance",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L87-L102 |
2,805 | jsvine/spectra | spectra/core.py | Scale.colorspace | def colorspace(self, space):
"""
Create a new scale in the given color space.
:param str space: The new color space.
:rtype: Scale
:returns: A new color.Scale object.
"""
new_colors = [ c.to(space) for c in self.colors ]
return self.__class__(new_colors,... | python | def colorspace(self, space):
new_colors = [ c.to(space) for c in self.colors ]
return self.__class__(new_colors, self._domain) | [
"def",
"colorspace",
"(",
"self",
",",
"space",
")",
":",
"new_colors",
"=",
"[",
"c",
".",
"to",
"(",
"space",
")",
"for",
"c",
"in",
"self",
".",
"colors",
"]",
"return",
"self",
".",
"__class__",
"(",
"new_colors",
",",
"self",
".",
"_domain",
"... | Create a new scale in the given color space.
:param str space: The new color space.
:rtype: Scale
:returns: A new color.Scale object. | [
"Create",
"a",
"new",
"scale",
"in",
"the",
"given",
"color",
"space",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L211-L221 |
2,806 | jsvine/spectra | spectra/core.py | Scale.range | def range(self, count):
"""
Create a list of colors evenly spaced along this scale's domain.
:param int count: The number of colors to return.
:rtype: list
:returns: A list of spectra.Color objects.
"""
if count <= 1:
raise ValueError("Range size mus... | python | def range(self, count):
if count <= 1:
raise ValueError("Range size must be greater than 1.")
dom = self._domain
distance = dom[-1] - dom[0]
props = [ self(dom[0] + distance * float(x)/(count-1))
for x in range(count) ]
return props | [
"def",
"range",
"(",
"self",
",",
"count",
")",
":",
"if",
"count",
"<=",
"1",
":",
"raise",
"ValueError",
"(",
"\"Range size must be greater than 1.\"",
")",
"dom",
"=",
"self",
".",
"_domain",
"distance",
"=",
"dom",
"[",
"-",
"1",
"]",
"-",
"dom",
"... | Create a list of colors evenly spaced along this scale's domain.
:param int count: The number of colors to return.
:rtype: list
:returns: A list of spectra.Color objects. | [
"Create",
"a",
"list",
"of",
"colors",
"evenly",
"spaced",
"along",
"this",
"scale",
"s",
"domain",
"."
] | 2269a0ae9b5923154b15bd661fb81179608f7ec2 | https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/core.py#L223-L238 |
2,807 | bcb/jsonrpcclient | jsonrpcclient/response.py | sort_response | def sort_response(response: Dict[str, Any]) -> OrderedDict:
"""
Sort the keys in a JSON-RPC response object.
This has no effect other than making it nicer to read. Useful in Python 3.5 only,
dictionaries are already sorted in newer Python versions.
Example::
>>> json.dumps(sort_response({... | python | def sort_response(response: Dict[str, Any]) -> OrderedDict:
root_order = ["jsonrpc", "result", "error", "id"]
error_order = ["code", "message", "data"]
req = OrderedDict(sorted(response.items(), key=lambda k: root_order.index(k[0])))
if "error" in response:
req["error"] = OrderedDict(
... | [
"def",
"sort_response",
"(",
"response",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"OrderedDict",
":",
"root_order",
"=",
"[",
"\"jsonrpc\"",
",",
"\"result\"",
",",
"\"error\"",
",",
"\"id\"",
"]",
"error_order",
"=",
"[",
"\"code\"",
",",
"\... | Sort the keys in a JSON-RPC response object.
This has no effect other than making it nicer to read. Useful in Python 3.5 only,
dictionaries are already sorted in newer Python versions.
Example::
>>> json.dumps(sort_response({'id': 2, 'result': 5, 'jsonrpc': '2.0'}))
{"jsonrpc": "2.0", "re... | [
"Sort",
"the",
"keys",
"in",
"a",
"JSON",
"-",
"RPC",
"response",
"object",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/response.py#L13-L38 |
2,808 | bcb/jsonrpcclient | jsonrpcclient/config.py | parse_callable | def parse_callable(path: str) -> Iterator:
"""
ConfigParser converter.
Calls the specified object, e.g. Option "id_generators.decimal" returns
`id_generators.decimal()`.
"""
module = path[: path.rindex(".")]
callable_name = path[path.rindex(".") + 1 :]
callable_ = getattr(importlib.impo... | python | def parse_callable(path: str) -> Iterator:
module = path[: path.rindex(".")]
callable_name = path[path.rindex(".") + 1 :]
callable_ = getattr(importlib.import_module(module), callable_name)
return callable_() | [
"def",
"parse_callable",
"(",
"path",
":",
"str",
")",
"->",
"Iterator",
":",
"module",
"=",
"path",
"[",
":",
"path",
".",
"rindex",
"(",
"\".\"",
")",
"]",
"callable_name",
"=",
"path",
"[",
"path",
".",
"rindex",
"(",
"\".\"",
")",
"+",
"1",
":"... | ConfigParser converter.
Calls the specified object, e.g. Option "id_generators.decimal" returns
`id_generators.decimal()`. | [
"ConfigParser",
"converter",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/config.py#L12-L22 |
2,809 | bcb/jsonrpcclient | jsonrpcclient/id_generators.py | random | def random(length: int = 8, chars: str = digits + ascii_lowercase) -> Iterator[str]:
"""
A random string.
Not unique, but has around 1 in a million chance of collision (with the default 8
character length). e.g. 'fubui5e6'
Args:
length: Length of the random string.
chars: The chara... | python | def random(length: int = 8, chars: str = digits + ascii_lowercase) -> Iterator[str]:
while True:
yield "".join([choice(chars) for _ in range(length)]) | [
"def",
"random",
"(",
"length",
":",
"int",
"=",
"8",
",",
"chars",
":",
"str",
"=",
"digits",
"+",
"ascii_lowercase",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"while",
"True",
":",
"yield",
"\"\"",
".",
"join",
"(",
"[",
"choice",
"(",
"chars"... | A random string.
Not unique, but has around 1 in a million chance of collision (with the default 8
character length). e.g. 'fubui5e6'
Args:
length: Length of the random string.
chars: The characters to randomly choose from. | [
"A",
"random",
"string",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/id_generators.py#L40-L52 |
2,810 | bcb/jsonrpcclient | jsonrpcclient/parse.py | get_response | def get_response(response: Dict[str, Any]) -> JSONRPCResponse:
"""
Converts a deserialized response into a JSONRPCResponse object.
The dictionary be either an error or success response, never a notification.
Args:
response: Deserialized response dictionary. We can assume the response is valid
... | python | def get_response(response: Dict[str, Any]) -> JSONRPCResponse:
if "error" in response:
return ErrorResponse(**response)
return SuccessResponse(**response) | [
"def",
"get_response",
"(",
"response",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"JSONRPCResponse",
":",
"if",
"\"error\"",
"in",
"response",
":",
"return",
"ErrorResponse",
"(",
"*",
"*",
"response",
")",
"return",
"SuccessResponse",
"(",
"*",... | Converts a deserialized response into a JSONRPCResponse object.
The dictionary be either an error or success response, never a notification.
Args:
response: Deserialized response dictionary. We can assume the response is valid
JSON-RPC here, since it passed the jsonschema validation. | [
"Converts",
"a",
"deserialized",
"response",
"into",
"a",
"JSONRPCResponse",
"object",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/parse.py#L18-L30 |
2,811 | bcb/jsonrpcclient | jsonrpcclient/parse.py | parse | def parse(
response_text: str, *, batch: bool, validate_against_schema: bool = True
) -> Union[JSONRPCResponse, List[JSONRPCResponse]]:
"""
Parses response text, returning JSONRPCResponse objects.
Args:
response_text: JSON-RPC response string.
batch: If the response_text is an empty str... | python | def parse(
response_text: str, *, batch: bool, validate_against_schema: bool = True
) -> Union[JSONRPCResponse, List[JSONRPCResponse]]:
# If the response is empty, we can't deserialize it; an empty string is valid
# JSON-RPC, but not valid JSON.
if not response_text:
if batch:
# An e... | [
"def",
"parse",
"(",
"response_text",
":",
"str",
",",
"*",
",",
"batch",
":",
"bool",
",",
"validate_against_schema",
":",
"bool",
"=",
"True",
")",
"->",
"Union",
"[",
"JSONRPCResponse",
",",
"List",
"[",
"JSONRPCResponse",
"]",
"]",
":",
"# If the respo... | Parses response text, returning JSONRPCResponse objects.
Args:
response_text: JSON-RPC response string.
batch: If the response_text is an empty string, this determines how to parse.
validate_against_schema: Validate against the json-rpc schema.
Returns:
Either a JSONRPCResponse... | [
"Parses",
"response",
"text",
"returning",
"JSONRPCResponse",
"objects",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/parse.py#L33-L75 |
2,812 | bcb/jsonrpcclient | jsonrpcclient/async_client.py | AsyncClient.send | async def send(
self,
request: Union[str, Dict, List],
trim_log_values: bool = False,
validate_against_schema: bool = True,
**kwargs: Any
) -> Response:
"""
Async version of Client.send.
"""
# We need both the serialized and deserialized versio... | python | async def send(
self,
request: Union[str, Dict, List],
trim_log_values: bool = False,
validate_against_schema: bool = True,
**kwargs: Any
) -> Response:
# We need both the serialized and deserialized version of the request
if isinstance(request, str):
... | [
"async",
"def",
"send",
"(",
"self",
",",
"request",
":",
"Union",
"[",
"str",
",",
"Dict",
",",
"List",
"]",
",",
"trim_log_values",
":",
"bool",
"=",
"False",
",",
"validate_against_schema",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
":",
"... | Async version of Client.send. | [
"Async",
"version",
"of",
"Client",
".",
"send",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/async_client.py#L32-L63 |
2,813 | bcb/jsonrpcclient | jsonrpcclient/__main__.py | main | def main(
context: click.core.Context, method: str, request_type: str, id: Any, send: str
) -> None:
"""
Create a JSON-RPC request.
"""
exit_status = 0
# Extract the jsonrpc arguments
positional = [a for a in context.args if "=" not in a]
named = {a.split("=")[0]: a.split("=")[1] for a i... | python | def main(
context: click.core.Context, method: str, request_type: str, id: Any, send: str
) -> None:
exit_status = 0
# Extract the jsonrpc arguments
positional = [a for a in context.args if "=" not in a]
named = {a.split("=")[0]: a.split("=")[1] for a in context.args if "=" in a}
# Create the re... | [
"def",
"main",
"(",
"context",
":",
"click",
".",
"core",
".",
"Context",
",",
"method",
":",
"str",
",",
"request_type",
":",
"str",
",",
"id",
":",
"Any",
",",
"send",
":",
"str",
")",
"->",
"None",
":",
"exit_status",
"=",
"0",
"# Extract the json... | Create a JSON-RPC request. | [
"Create",
"a",
"JSON",
"-",
"RPC",
"request",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/__main__.py#L40-L68 |
2,814 | bcb/jsonrpcclient | jsonrpcclient/requests.py | sort_request | def sort_request(request: Dict[str, Any]) -> OrderedDict:
"""
Sort a JSON-RPC request dict.
This has no effect other than making the request nicer to read.
>>> json.dumps(sort_request(
... {'id': 2, 'params': [2, 3], 'method': 'add', 'jsonrpc': '2.0'}))
'{"jsonrpc": "2.0", "met... | python | def sort_request(request: Dict[str, Any]) -> OrderedDict:
sort_order = ["jsonrpc", "method", "params", "id"]
return OrderedDict(sorted(request.items(), key=lambda k: sort_order.index(k[0]))) | [
"def",
"sort_request",
"(",
"request",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"OrderedDict",
":",
"sort_order",
"=",
"[",
"\"jsonrpc\"",
",",
"\"method\"",
",",
"\"params\"",
",",
"\"id\"",
"]",
"return",
"OrderedDict",
"(",
"sorted",
"(",
... | Sort a JSON-RPC request dict.
This has no effect other than making the request nicer to read.
>>> json.dumps(sort_request(
... {'id': 2, 'params': [2, 3], 'method': 'add', 'jsonrpc': '2.0'}))
'{"jsonrpc": "2.0", "method": "add", "params": [2, 3], "id": 2}'
Args:
request: J... | [
"Sort",
"a",
"JSON",
"-",
"RPC",
"request",
"dict",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/requests.py#L18-L32 |
2,815 | bcb/jsonrpcclient | jsonrpcclient/client.py | Client.basic_logging | def basic_logging(self) -> None:
"""
Call this on the client object to create log handlers to output request and
response messages.
"""
# Request handler
if len(request_log.handlers) == 0:
request_handler = logging.StreamHandler()
request_handler.s... | python | def basic_logging(self) -> None:
# Request handler
if len(request_log.handlers) == 0:
request_handler = logging.StreamHandler()
request_handler.setFormatter(
logging.Formatter(fmt=self.DEFAULT_REQUEST_LOG_FORMAT)
)
request_log.addHandler(re... | [
"def",
"basic_logging",
"(",
"self",
")",
"->",
"None",
":",
"# Request handler",
"if",
"len",
"(",
"request_log",
".",
"handlers",
")",
"==",
"0",
":",
"request_handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"request_handler",
".",
"setFormatter",
... | Call this on the client object to create log handlers to output request and
response messages. | [
"Call",
"this",
"on",
"the",
"client",
"object",
"to",
"create",
"log",
"handlers",
"to",
"output",
"request",
"and",
"response",
"messages",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/client.py#L57-L77 |
2,816 | bcb/jsonrpcclient | jsonrpcclient/client.py | Client.log_response | def log_response(
self, response: Response, trim_log_values: bool = False, **kwargs: Any
) -> None:
"""
Log a response.
Note this is different to log_request, in that it takes a Response object, not a
string.
Args:
response: The Response object to log. N... | python | def log_response(
self, response: Response, trim_log_values: bool = False, **kwargs: Any
) -> None:
return log_(response.text, response_log, "info", trim=trim_log_values, **kwargs) | [
"def",
"log_response",
"(",
"self",
",",
"response",
":",
"Response",
",",
"trim_log_values",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"return",
"log_",
"(",
"response",
".",
"text",
",",
"response_log",
"... | Log a response.
Note this is different to log_request, in that it takes a Response object, not a
string.
Args:
response: The Response object to log. Note this is different to log_request
which takes a string.
trim_log_values: Log an abbreviated version o... | [
"Log",
"a",
"response",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/client.py#L93-L107 |
2,817 | bcb/jsonrpcclient | jsonrpcclient/client.py | Client.notify | def notify(
self,
method_name: str,
*args: Any,
trim_log_values: Optional[bool] = None,
validate_against_schema: Optional[bool] = None,
**kwargs: Any
) -> Response:
"""
Send a JSON-RPC request, without expecting a response.
Args:
m... | python | def notify(
self,
method_name: str,
*args: Any,
trim_log_values: Optional[bool] = None,
validate_against_schema: Optional[bool] = None,
**kwargs: Any
) -> Response:
return self.send(
Notification(method_name, *args, **kwargs),
trim_log_... | [
"def",
"notify",
"(",
"self",
",",
"method_name",
":",
"str",
",",
"*",
"args",
":",
"Any",
",",
"trim_log_values",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"validate_against_schema",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"*"... | Send a JSON-RPC request, without expecting a response.
Args:
method_name: The remote procedure's method name.
args: Positional arguments passed to the remote procedure.
kwargs: Keyword arguments passed to the remote procedure.
trim_log_values: Abbreviate the log ... | [
"Send",
"a",
"JSON",
"-",
"RPC",
"request",
"without",
"expecting",
"a",
"response",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/client.py#L181-L203 |
2,818 | bcb/jsonrpcclient | jsonrpcclient/client.py | Client.request | def request(
self,
method_name: str,
*args: Any,
trim_log_values: bool = False,
validate_against_schema: bool = True,
id_generator: Optional[Iterator] = None,
**kwargs: Any
) -> Response:
"""
Send a request by passing the method and arguments.
... | python | def request(
self,
method_name: str,
*args: Any,
trim_log_values: bool = False,
validate_against_schema: bool = True,
id_generator: Optional[Iterator] = None,
**kwargs: Any
) -> Response:
return self.send(
Request(method_name, id_generator=... | [
"def",
"request",
"(",
"self",
",",
"method_name",
":",
"str",
",",
"*",
"args",
":",
"Any",
",",
"trim_log_values",
":",
"bool",
"=",
"False",
",",
"validate_against_schema",
":",
"bool",
"=",
"True",
",",
"id_generator",
":",
"Optional",
"[",
"Iterator",... | Send a request by passing the method and arguments.
>>> client.request("cat", name="Yoko")
<Response[1]
Args:
method_name: The remote procedure's method name.
args: Positional arguments passed to the remote procedure.
kwargs: Keyword arguments passed to the ... | [
"Send",
"a",
"request",
"by",
"passing",
"the",
"method",
"and",
"arguments",
"."
] | 5b5abc28d1466d694c80b80c427a5dcb275382bb | https://github.com/bcb/jsonrpcclient/blob/5b5abc28d1466d694c80b80c427a5dcb275382bb/jsonrpcclient/client.py#L206-L233 |
2,819 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.init | def init(self, acct: Account, payer_acct: Account, gas_limit: int, gas_price: int) -> str:
"""
This interface is used to call the TotalSupply method in ope4
that initialize smart contract parameter.
:param acct: an Account class that used to sign the transaction.
:param payer_ac... | python | def init(self, acct: Account, payer_acct: Account, gas_limit: int, gas_price: int) -> str:
func = InvokeFunction('init')
tx_hash = self.__sdk.get_network().send_neo_vm_transaction(self.__hex_contract_address, acct, payer_acct,
gas_limit,... | [
"def",
"init",
"(",
"self",
",",
"acct",
":",
"Account",
",",
"payer_acct",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
"->",
"str",
":",
"func",
"=",
"InvokeFunction",
"(",
"'init'",
")",
"tx_hash",
"=",
"self",
... | This interface is used to call the TotalSupply method in ope4
that initialize smart contract parameter.
:param acct: an Account class that used to sign the transaction.
:param payer_acct: an Account class that used to pay for the transaction.
:param gas_limit: an int value that indicate... | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"TotalSupply",
"method",
"in",
"ope4",
"that",
"initialize",
"smart",
"contract",
"parameter",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L73-L87 |
2,820 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.get_total_supply | def get_total_supply(self) -> int:
"""
This interface is used to call the TotalSupply method in ope4
that return the total supply of the oep4 token.
:return: the total supply of the oep4 token.
"""
func = InvokeFunction('totalSupply')
response = self.__sdk.get_ne... | python | def get_total_supply(self) -> int:
func = InvokeFunction('totalSupply')
response = self.__sdk.get_network().send_neo_vm_transaction_pre_exec(self.__hex_contract_address, None, func)
try:
total_supply = ContractDataParser.to_int(response['Result'])
except SDKException:
... | [
"def",
"get_total_supply",
"(",
"self",
")",
"->",
"int",
":",
"func",
"=",
"InvokeFunction",
"(",
"'totalSupply'",
")",
"response",
"=",
"self",
".",
"__sdk",
".",
"get_network",
"(",
")",
".",
"send_neo_vm_transaction_pre_exec",
"(",
"self",
".",
"__hex_cont... | This interface is used to call the TotalSupply method in ope4
that return the total supply of the oep4 token.
:return: the total supply of the oep4 token. | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"TotalSupply",
"method",
"in",
"ope4",
"that",
"return",
"the",
"total",
"supply",
"of",
"the",
"oep4",
"token",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L89-L102 |
2,821 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.balance_of | def balance_of(self, b58_address: str) -> int:
"""
This interface is used to call the BalanceOf method in ope4
that query the ope4 token balance of the given base58 encode address.
:param b58_address: the base58 encode address.
:return: the oep4 token balance of the base58 encod... | python | def balance_of(self, b58_address: str) -> int:
func = InvokeFunction('balanceOf')
Oep4.__b58_address_check(b58_address)
address = Address.b58decode(b58_address).to_bytes()
func.set_params_value(address)
result = self.__sdk.get_network().send_neo_vm_transaction_pre_exec(self.__hex... | [
"def",
"balance_of",
"(",
"self",
",",
"b58_address",
":",
"str",
")",
"->",
"int",
":",
"func",
"=",
"InvokeFunction",
"(",
"'balanceOf'",
")",
"Oep4",
".",
"__b58_address_check",
"(",
"b58_address",
")",
"address",
"=",
"Address",
".",
"b58decode",
"(",
... | This interface is used to call the BalanceOf method in ope4
that query the ope4 token balance of the given base58 encode address.
:param b58_address: the base58 encode address.
:return: the oep4 token balance of the base58 encode address. | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"BalanceOf",
"method",
"in",
"ope4",
"that",
"query",
"the",
"ope4",
"token",
"balance",
"of",
"the",
"given",
"base58",
"encode",
"address",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L104-L121 |
2,822 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.transfer | def transfer(self, from_acct: Account, b58_to_address: str, value: int, payer_acct: Account, gas_limit: int,
gas_price: int) -> str:
"""
This interface is used to call the Transfer method in ope4
that transfer an amount of tokens from one account to another account.
:pa... | python | def transfer(self, from_acct: Account, b58_to_address: str, value: int, payer_acct: Account, gas_limit: int,
gas_price: int) -> str:
func = InvokeFunction('transfer')
if not isinstance(value, int):
raise SDKException(ErrorCode.param_err('the data type of value should be int.... | [
"def",
"transfer",
"(",
"self",
",",
"from_acct",
":",
"Account",
",",
"b58_to_address",
":",
"str",
",",
"value",
":",
"int",
",",
"payer_acct",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
"->",
"str",
":",
"func",... | This interface is used to call the Transfer method in ope4
that transfer an amount of tokens from one account to another account.
:param from_acct: an Account class that send the oep4 token.
:param b58_to_address: a base58 encode address that receive the oep4 token.
:param value: an int... | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"Transfer",
"method",
"in",
"ope4",
"that",
"transfer",
"an",
"amount",
"of",
"tokens",
"from",
"one",
"account",
"to",
"another",
"account",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L123-L150 |
2,823 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.transfer_multi | def transfer_multi(self, transfer_list: list, payer_acct: Account, signers: list, gas_limit: int, gas_price: int):
"""
This interface is used to call the TransferMulti method in ope4
that allow transfer amount of token from multiple from-account to multiple to-account multiple times.
:p... | python | def transfer_multi(self, transfer_list: list, payer_acct: Account, signers: list, gas_limit: int, gas_price: int):
func = InvokeFunction('transferMulti')
for index, item in enumerate(transfer_list):
Oep4.__b58_address_check(item[0])
Oep4.__b58_address_check(item[1])
i... | [
"def",
"transfer_multi",
"(",
"self",
",",
"transfer_list",
":",
"list",
",",
"payer_acct",
":",
"Account",
",",
"signers",
":",
"list",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
":",
"func",
"=",
"InvokeFunction",
"(",
"'transferMul... | This interface is used to call the TransferMulti method in ope4
that allow transfer amount of token from multiple from-account to multiple to-account multiple times.
:param transfer_list: a parameter list with each item contains three sub-items:
base58 encode transaction sender address,... | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"TransferMulti",
"method",
"in",
"ope4",
"that",
"allow",
"transfer",
"amount",
"of",
"token",
"from",
"multiple",
"from",
"-",
"account",
"to",
"multiple",
"to",
"-",
"account",
"multiple",
"times",
".... | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L175-L218 |
2,824 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.approve | def approve(self, owner_acct: Account, b58_spender_address: str, amount: int, payer_acct: Account, gas_limit: int,
gas_price: int):
"""
This interface is used to call the Approve method in ope4
that allows spender to withdraw a certain amount of oep4 token from owner account mult... | python | def approve(self, owner_acct: Account, b58_spender_address: str, amount: int, payer_acct: Account, gas_limit: int,
gas_price: int):
func = InvokeFunction('approve')
if not isinstance(amount, int):
raise SDKException(ErrorCode.param_err('the data type of amount should be int.'... | [
"def",
"approve",
"(",
"self",
",",
"owner_acct",
":",
"Account",
",",
"b58_spender_address",
":",
"str",
",",
"amount",
":",
"int",
",",
"payer_acct",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
":",
"func",
"=",
"... | This interface is used to call the Approve method in ope4
that allows spender to withdraw a certain amount of oep4 token from owner account multiple times.
If this function is called again, it will overwrite the current allowance with new value.
:param owner_acct: an Account class that indicat... | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"Approve",
"method",
"in",
"ope4",
"that",
"allows",
"spender",
"to",
"withdraw",
"a",
"certain",
"amount",
"of",
"oep4",
"token",
"from",
"owner",
"account",
"multiple",
"times",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L220-L247 |
2,825 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.allowance | def allowance(self, b58_owner_address: str, b58_spender_address: str):
"""
This interface is used to call the Allowance method in ope4
that query the amount of spender still allowed to withdraw from owner account.
:param b58_owner_address: a base58 encode address that represent owner's ... | python | def allowance(self, b58_owner_address: str, b58_spender_address: str):
func = InvokeFunction('allowance')
Oep4.__b58_address_check(b58_owner_address)
owner = Address.b58decode(b58_owner_address).to_bytes()
Oep4.__b58_address_check(b58_spender_address)
spender = Address.b58decode(... | [
"def",
"allowance",
"(",
"self",
",",
"b58_owner_address",
":",
"str",
",",
"b58_spender_address",
":",
"str",
")",
":",
"func",
"=",
"InvokeFunction",
"(",
"'allowance'",
")",
"Oep4",
".",
"__b58_address_check",
"(",
"b58_owner_address",
")",
"owner",
"=",
"A... | This interface is used to call the Allowance method in ope4
that query the amount of spender still allowed to withdraw from owner account.
:param b58_owner_address: a base58 encode address that represent owner's account.
:param b58_spender_address: a base58 encode address that represent spender... | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"Allowance",
"method",
"in",
"ope4",
"that",
"query",
"the",
"amount",
"of",
"spender",
"still",
"allowed",
"to",
"withdraw",
"from",
"owner",
"account",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L249-L269 |
2,826 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/oep4.py | Oep4.transfer_from | def transfer_from(self, spender_acct: Account, b58_from_address: str, b58_to_address: str, value: int,
payer_acct: Account, gas_limit: int, gas_price: int):
"""
This interface is used to call the Allowance method in ope4
that allow spender to withdraw amount of oep4 token f... | python | def transfer_from(self, spender_acct: Account, b58_from_address: str, b58_to_address: str, value: int,
payer_acct: Account, gas_limit: int, gas_price: int):
func = InvokeFunction('transferFrom')
Oep4.__b58_address_check(b58_from_address)
Oep4.__b58_address_check(b58_to_addr... | [
"def",
"transfer_from",
"(",
"self",
",",
"spender_acct",
":",
"Account",
",",
"b58_from_address",
":",
"str",
",",
"b58_to_address",
":",
"str",
",",
"value",
":",
"int",
",",
"payer_acct",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
"... | This interface is used to call the Allowance method in ope4
that allow spender to withdraw amount of oep4 token from from-account to to-account.
:param spender_acct: an Account class that actually spend oep4 token.
:param b58_from_address: an base58 encode address that actually pay oep4 token f... | [
"This",
"interface",
"is",
"used",
"to",
"call",
"the",
"Allowance",
"method",
"in",
"ope4",
"that",
"allow",
"spender",
"to",
"withdraw",
"amount",
"of",
"oep4",
"token",
"from",
"from",
"-",
"account",
"to",
"to",
"-",
"account",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/oep4.py#L271-L314 |
2,827 | ontio/ontology-python-sdk | ontology/wallet/wallet_manager.py | WalletManager.import_identity | def import_identity(self, label: str, encrypted_pri_key: str, pwd: str, salt: str, b58_address: str) -> Identity:
"""
This interface is used to import identity by providing encrypted private key, password, salt and
base58 encode address which should be correspond to the encrypted private key pro... | python | def import_identity(self, label: str, encrypted_pri_key: str, pwd: str, salt: str, b58_address: str) -> Identity:
scrypt_n = Scrypt().n
pri_key = Account.get_gcm_decoded_private_key(encrypted_pri_key, pwd, b58_address, salt, scrypt_n, self.scheme)
info = self.__create_identity(label, pwd, salt, ... | [
"def",
"import_identity",
"(",
"self",
",",
"label",
":",
"str",
",",
"encrypted_pri_key",
":",
"str",
",",
"pwd",
":",
"str",
",",
"salt",
":",
"str",
",",
"b58_address",
":",
"str",
")",
"->",
"Identity",
":",
"scrypt_n",
"=",
"Scrypt",
"(",
")",
"... | This interface is used to import identity by providing encrypted private key, password, salt and
base58 encode address which should be correspond to the encrypted private key provided.
:param label: a label for identity.
:param encrypted_pri_key: an encrypted private key in base64 encoding from... | [
"This",
"interface",
"is",
"used",
"to",
"import",
"identity",
"by",
"providing",
"encrypted",
"private",
"key",
"password",
"salt",
"and",
"base58",
"encode",
"address",
"which",
"should",
"be",
"correspond",
"to",
"the",
"encrypted",
"private",
"key",
"provide... | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet_manager.py#L140-L158 |
2,828 | ontio/ontology-python-sdk | ontology/wallet/wallet_manager.py | WalletManager.create_identity_from_private_key | def create_identity_from_private_key(self, label: str, pwd: str, private_key: str) -> Identity:
"""
This interface is used to create identity based on given label, password and private key.
:param label: a label for identity.
:param pwd: a password which will be used to encrypt and decr... | python | def create_identity_from_private_key(self, label: str, pwd: str, private_key: str) -> Identity:
salt = get_random_hex_str(16)
identity = self.__create_identity(label, pwd, salt, private_key)
return identity | [
"def",
"create_identity_from_private_key",
"(",
"self",
",",
"label",
":",
"str",
",",
"pwd",
":",
"str",
",",
"private_key",
":",
"str",
")",
"->",
"Identity",
":",
"salt",
"=",
"get_random_hex_str",
"(",
"16",
")",
"identity",
"=",
"self",
".",
"__create... | This interface is used to create identity based on given label, password and private key.
:param label: a label for identity.
:param pwd: a password which will be used to encrypt and decrypt the private key.
:param private_key: a private key in the form of string.
:return: if succeed, a... | [
"This",
"interface",
"is",
"used",
"to",
"create",
"identity",
"based",
"on",
"given",
"label",
"password",
"and",
"private",
"key",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet_manager.py#L178-L189 |
2,829 | ontio/ontology-python-sdk | ontology/wallet/wallet_manager.py | WalletManager.create_account | def create_account(self, pwd: str, label: str = '') -> Account:
"""
This interface is used to create account based on given password and label.
:param label: a label for account.
:param pwd: a password which will be used to encrypt and decrypt the private key
:return: if succeed... | python | def create_account(self, pwd: str, label: str = '') -> Account:
pri_key = get_random_hex_str(64)
salt = get_random_hex_str(16)
if len(label) == 0 or label is None:
label = uuid.uuid4().hex[0:8]
acct = self.__create_account(label, pwd, salt, pri_key, True)
return self.... | [
"def",
"create_account",
"(",
"self",
",",
"pwd",
":",
"str",
",",
"label",
":",
"str",
"=",
"''",
")",
"->",
"Account",
":",
"pri_key",
"=",
"get_random_hex_str",
"(",
"64",
")",
"salt",
"=",
"get_random_hex_str",
"(",
"16",
")",
"if",
"len",
"(",
"... | This interface is used to create account based on given password and label.
:param label: a label for account.
:param pwd: a password which will be used to encrypt and decrypt the private key
:return: if succeed, return an data structure which contain the information of a wallet account. | [
"This",
"interface",
"is",
"used",
"to",
"create",
"account",
"based",
"on",
"given",
"password",
"and",
"label",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet_manager.py#L191-L204 |
2,830 | ontio/ontology-python-sdk | ontology/wallet/wallet_manager.py | WalletManager.import_account | def import_account(self, label: str, encrypted_pri_key: str, pwd: str, b58_address: str,
b64_salt: str, n: int = 16384) -> AccountData:
"""
This interface is used to import account by providing account data.
:param label: str, wallet label
:param encrypted_pri_key... | python | def import_account(self, label: str, encrypted_pri_key: str, pwd: str, b58_address: str,
b64_salt: str, n: int = 16384) -> AccountData:
salt = base64.b64decode(b64_salt.encode('ascii')).decode('latin-1')
private_key = Account.get_gcm_decoded_private_key(encrypted_pri_key, pwd, b58... | [
"def",
"import_account",
"(",
"self",
",",
"label",
":",
"str",
",",
"encrypted_pri_key",
":",
"str",
",",
"pwd",
":",
"str",
",",
"b58_address",
":",
"str",
",",
"b64_salt",
":",
"str",
",",
"n",
":",
"int",
"=",
"16384",
")",
"->",
"AccountData",
"... | This interface is used to import account by providing account data.
:param label: str, wallet label
:param encrypted_pri_key: str, an encrypted private key in base64 encoding from
:param pwd: str, a password which is used to encrypt and decrypt the private key
:param b58_address: str, a... | [
"This",
"interface",
"is",
"used",
"to",
"import",
"account",
"by",
"providing",
"account",
"data",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet_manager.py#L289-L312 |
2,831 | ontio/ontology-python-sdk | ontology/wallet/wallet_manager.py | WalletManager.create_account_from_private_key | def create_account_from_private_key(self, password: str, private_key: str, label: str = '') -> AccountData:
"""
This interface is used to create account by providing an encrypted private key and it's decrypt password.
:param label: a label for account.
:param password: a password which ... | python | def create_account_from_private_key(self, password: str, private_key: str, label: str = '') -> AccountData:
salt = get_random_hex_str(16)
if len(label) == 0 or label is None:
label = uuid.uuid4().hex[0:8]
info = self.create_account_info(label, password, salt, private_key)
for... | [
"def",
"create_account_from_private_key",
"(",
"self",
",",
"password",
":",
"str",
",",
"private_key",
":",
"str",
",",
"label",
":",
"str",
"=",
"''",
")",
"->",
"AccountData",
":",
"salt",
"=",
"get_random_hex_str",
"(",
"16",
")",
"if",
"len",
"(",
"... | This interface is used to create account by providing an encrypted private key and it's decrypt password.
:param label: a label for account.
:param password: a password which is used to decrypt the encrypted private key.
:param private_key: a private key in the form of string.
:return: ... | [
"This",
"interface",
"is",
"used",
"to",
"create",
"account",
"by",
"providing",
"an",
"encrypted",
"private",
"key",
"and",
"it",
"s",
"decrypt",
"password",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet_manager.py#L324-L341 |
2,832 | ontio/ontology-python-sdk | ontology/wallet/wallet_manager.py | WalletManager.get_default_account_data | def get_default_account_data(self) -> AccountData:
"""
This interface is used to get the default account in WalletManager.
:return: an AccountData object that contain all the information of a default account.
"""
for acct in self.wallet_in_mem.accounts:
if not isinst... | python | def get_default_account_data(self) -> AccountData:
for acct in self.wallet_in_mem.accounts:
if not isinstance(acct, AccountData):
raise SDKException(ErrorCode.other_error('Invalid account data in memory.'))
if acct.is_default:
return acct
raise SDK... | [
"def",
"get_default_account_data",
"(",
"self",
")",
"->",
"AccountData",
":",
"for",
"acct",
"in",
"self",
".",
"wallet_in_mem",
".",
"accounts",
":",
"if",
"not",
"isinstance",
"(",
"acct",
",",
"AccountData",
")",
":",
"raise",
"SDKException",
"(",
"Error... | This interface is used to get the default account in WalletManager.
:return: an AccountData object that contain all the information of a default account. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"default",
"account",
"in",
"WalletManager",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet_manager.py#L440-L451 |
2,833 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/abi/abi_info.py | AbiInfo.get_function | def get_function(self, name: str) -> AbiFunction or None:
"""
This interface is used to get an AbiFunction object from AbiInfo object by given function name.
:param name: the function name in abi file
:return: if succeed, an AbiFunction will constructed based on given function name
... | python | def get_function(self, name: str) -> AbiFunction or None:
for func in self.functions:
if func['name'] == name:
return AbiFunction(func['name'], func['parameters'], func.get('returntype', ''))
return None | [
"def",
"get_function",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"AbiFunction",
"or",
"None",
":",
"for",
"func",
"in",
"self",
".",
"functions",
":",
"if",
"func",
"[",
"'name'",
"]",
"==",
"name",
":",
"return",
"AbiFunction",
"(",
"func",
"... | This interface is used to get an AbiFunction object from AbiInfo object by given function name.
:param name: the function name in abi file
:return: if succeed, an AbiFunction will constructed based on given function name | [
"This",
"interface",
"is",
"used",
"to",
"get",
"an",
"AbiFunction",
"object",
"from",
"AbiInfo",
"object",
"by",
"given",
"function",
"name",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/abi/abi_info.py#L17-L27 |
2,834 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_version | def get_version(self, is_full: bool = False) -> dict or str:
"""
This interface is used to get the version information of the connected node in current network.
Return:
the version information of the connected node.
"""
payload = self.generate_json_rpc_payload(RpcMet... | python | def get_version(self, is_full: bool = False) -> dict or str:
payload = self.generate_json_rpc_payload(RpcMethod.GET_VERSION)
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_version",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
"or",
"str",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_VERSION",
")",
"response",
"=",
"self",
".",
"__post",
... | This interface is used to get the version information of the connected node in current network.
Return:
the version information of the connected node. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"version",
"information",
"of",
"the",
"connected",
"node",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L152-L163 |
2,835 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_connection_count | def get_connection_count(self, is_full: bool = False) -> int:
"""
This interface is used to get the current number of connections for the node in current network.
Return:
the number of connections.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_NODE_COUNT... | python | def get_connection_count(self, is_full: bool = False) -> int:
payload = self.generate_json_rpc_payload(RpcMethod.GET_NODE_COUNT)
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_connection_count",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"int",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_NODE_COUNT",
")",
"response",
"=",
"self",
".",
"__post",
"(",... | This interface is used to get the current number of connections for the node in current network.
Return:
the number of connections. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"current",
"number",
"of",
"connections",
"for",
"the",
"node",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L165-L176 |
2,836 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_gas_price | def get_gas_price(self, is_full: bool = False) -> int or dict:
"""
This interface is used to get the gas price in current network.
Return:
the value of gas price.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_GAS_PRICE)
response = self.__post(sel... | python | def get_gas_price(self, is_full: bool = False) -> int or dict:
payload = self.generate_json_rpc_payload(RpcMethod.GET_GAS_PRICE)
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result']['gasprice'] | [
"def",
"get_gas_price",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"int",
"or",
"dict",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_GAS_PRICE",
")",
"response",
"=",
"self",
".",
"__pos... | This interface is used to get the gas price in current network.
Return:
the value of gas price. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"gas",
"price",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L178-L189 |
2,837 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_network_id | def get_network_id(self, is_full: bool = False) -> int:
"""
This interface is used to get the network id of current network.
Return:
the network id of current network.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_NETWORK_ID)
response = self.__p... | python | def get_network_id(self, is_full: bool = False) -> int:
payload = self.generate_json_rpc_payload(RpcMethod.GET_NETWORK_ID)
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_network_id",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"int",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_NETWORK_ID",
")",
"response",
"=",
"self",
".",
"__post",
"(",
"se... | This interface is used to get the network id of current network.
Return:
the network id of current network. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"network",
"id",
"of",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L191-L203 |
2,838 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_block_by_height | def get_block_by_height(self, height: int, is_full: bool = False) -> dict:
"""
This interface is used to get the block information by block height in current network.
Return:
the decimal total number of blocks in current network.
"""
payload = self.generate_json_rpc_... | python | def get_block_by_height(self, height: int, is_full: bool = False) -> dict:
payload = self.generate_json_rpc_payload(RpcMethod.GET_BLOCK, [height, 1])
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_block_by_height",
"(",
"self",
",",
"height",
":",
"int",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_BLOCK",
",",
"[",
"height",
",",
... | This interface is used to get the block information by block height in current network.
Return:
the decimal total number of blocks in current network. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"block",
"information",
"by",
"block",
"height",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L219-L230 |
2,839 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_block_count | def get_block_count(self, is_full: bool = False) -> int or dict:
"""
This interface is used to get the decimal block number in current network.
Return:
the decimal total number of blocks in current network.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_B... | python | def get_block_count(self, is_full: bool = False) -> int or dict:
payload = self.generate_json_rpc_payload(RpcMethod.GET_BLOCK_COUNT)
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_block_count",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"int",
"or",
"dict",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_BLOCK_COUNT",
")",
"response",
"=",
"self",
".",
"_... | This interface is used to get the decimal block number in current network.
Return:
the decimal total number of blocks in current network. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"decimal",
"block",
"number",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L232-L243 |
2,840 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_block_height | def get_block_height(self, is_full: bool = False) -> int or dict:
"""
This interface is used to get the decimal block height in current network.
Return:
the decimal total height of blocks in current network.
"""
response = self.get_block_count(is_full=True)
r... | python | def get_block_height(self, is_full: bool = False) -> int or dict:
response = self.get_block_count(is_full=True)
response['result'] -= 1
if is_full:
return response
return response['result'] | [
"def",
"get_block_height",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"int",
"or",
"dict",
":",
"response",
"=",
"self",
".",
"get_block_count",
"(",
"is_full",
"=",
"True",
")",
"response",
"[",
"'result'",
"]",
"-=",
"1",
"if"... | This interface is used to get the decimal block height in current network.
Return:
the decimal total height of blocks in current network. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"decimal",
"block",
"height",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L245-L256 |
2,841 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_current_block_hash | def get_current_block_hash(self, is_full: bool = False) -> str:
"""
This interface is used to get the hexadecimal hash value of the highest block in current network.
Return:
the hexadecimal hash value of the highest block in current network.
"""
payload = self.genera... | python | def get_current_block_hash(self, is_full: bool = False) -> str:
payload = self.generate_json_rpc_payload(RpcMethod.GET_CURRENT_BLOCK_HASH)
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_current_block_hash",
"(",
"self",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_CURRENT_BLOCK_HASH",
")",
"response",
"=",
"self",
".",
"__pos... | This interface is used to get the hexadecimal hash value of the highest block in current network.
Return:
the hexadecimal hash value of the highest block in current network. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"hexadecimal",
"hash",
"value",
"of",
"the",
"highest",
"block",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L272-L283 |
2,842 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_balance | def get_balance(self, b58_address: str, is_full: bool = False) -> dict:
"""
This interface is used to get the account balance of specified base58 encoded address in current network.
:param b58_address: a base58 encoded account address.
:param is_full:
:return: the value of accou... | python | def get_balance(self, b58_address: str, is_full: bool = False) -> dict:
payload = self.generate_json_rpc_payload(RpcMethod.GET_BALANCE, [b58_address, 1])
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_balance",
"(",
"self",
",",
"b58_address",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_BALANCE",
",",
"[",
"b58_address",
"... | This interface is used to get the account balance of specified base58 encoded address in current network.
:param b58_address: a base58 encoded account address.
:param is_full:
:return: the value of account balance in dictionary form. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"account",
"balance",
"of",
"specified",
"base58",
"encoded",
"address",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L299-L311 |
2,843 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_allowance | def get_allowance(self, asset_name: str, from_address: str, to_address: str, is_full: bool = False) -> str:
"""
This interface is used to get the the allowance
from transfer-from account to transfer-to account in current network.
:param asset_name:
:param from_address: a base58 ... | python | def get_allowance(self, asset_name: str, from_address: str, to_address: str, is_full: bool = False) -> str:
payload = self.generate_json_rpc_payload(RpcMethod.GET_ALLOWANCE, [asset_name, from_address, to_address])
response = self.__post(self.__url, payload)
if is_full:
return respons... | [
"def",
"get_allowance",
"(",
"self",
",",
"asset_name",
":",
"str",
",",
"from_address",
":",
"str",
",",
"to_address",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
... | This interface is used to get the the allowance
from transfer-from account to transfer-to account in current network.
:param asset_name:
:param from_address: a base58 encoded account address.
:param to_address: a base58 encoded account address.
:param is_full:
:return: t... | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"the",
"allowance",
"from",
"transfer",
"-",
"from",
"account",
"to",
"transfer",
"-",
"to",
"account",
"in",
"current",
"network",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L320-L335 |
2,844 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_storage | def get_storage(self, hex_contract_address: str, hex_key: str, is_full: bool = False) -> str:
"""
This interface is used to get the corresponding stored value
based on hexadecimal contract address and stored key.
:param hex_contract_address: hexadecimal contract address.
:param ... | python | def get_storage(self, hex_contract_address: str, hex_key: str, is_full: bool = False) -> str:
payload = self.generate_json_rpc_payload(RpcMethod.GET_STORAGE, [hex_contract_address, hex_key, 1])
response = self.__post(self.__url, payload)
if is_full:
return response
return res... | [
"def",
"get_storage",
"(",
"self",
",",
"hex_contract_address",
":",
"str",
",",
"hex_key",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_... | This interface is used to get the corresponding stored value
based on hexadecimal contract address and stored key.
:param hex_contract_address: hexadecimal contract address.
:param hex_key: a hexadecimal stored key.
:param is_full:
:return: the information of contract storage. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"corresponding",
"stored",
"value",
"based",
"on",
"hexadecimal",
"contract",
"address",
"and",
"stored",
"key",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L337-L351 |
2,845 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_transaction_by_tx_hash | def get_transaction_by_tx_hash(self, tx_hash: str, is_full: bool = False) -> dict:
"""
This interface is used to get the corresponding transaction information based on the specified hash value.
:param tx_hash: str, a hexadecimal hash value.
:param is_full:
:return: dict
... | python | def get_transaction_by_tx_hash(self, tx_hash: str, is_full: bool = False) -> dict:
payload = self.generate_json_rpc_payload(RpcMethod.GET_TRANSACTION, [tx_hash, 1])
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_transaction_by_tx_hash",
"(",
"self",
",",
"tx_hash",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_TRANSACTION",
",",
"[",
"tx... | This interface is used to get the corresponding transaction information based on the specified hash value.
:param tx_hash: str, a hexadecimal hash value.
:param is_full:
:return: dict | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"corresponding",
"transaction",
"information",
"based",
"on",
"the",
"specified",
"hash",
"value",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L387-L399 |
2,846 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_smart_contract | def get_smart_contract(self, hex_contract_address: str, is_full: bool = False) -> dict:
"""
This interface is used to get the information of smart contract based on the specified hexadecimal hash value.
:param hex_contract_address: str, a hexadecimal hash value.
:param is_full:
... | python | def get_smart_contract(self, hex_contract_address: str, is_full: bool = False) -> dict:
if not isinstance(hex_contract_address, str):
raise SDKException(ErrorCode.param_err('a hexadecimal contract address is required.'))
if len(hex_contract_address) != 40:
raise SDKException(Erro... | [
"def",
"get_smart_contract",
"(",
"self",
",",
"hex_contract_address",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"if",
"not",
"isinstance",
"(",
"hex_contract_address",
",",
"str",
")",
":",
"raise",
"SDKException",
"(",
... | This interface is used to get the information of smart contract based on the specified hexadecimal hash value.
:param hex_contract_address: str, a hexadecimal hash value.
:param is_full:
:return: the information of smart contract in dictionary form. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"information",
"of",
"smart",
"contract",
"based",
"on",
"the",
"specified",
"hexadecimal",
"hash",
"value",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L401-L417 |
2,847 | ontio/ontology-python-sdk | ontology/network/rpc.py | RpcClient.get_merkle_proof | def get_merkle_proof(self, tx_hash: str, is_full: bool = False) -> dict:
"""
This interface is used to get the corresponding merkle proof based on the specified hexadecimal hash value.
:param tx_hash: an hexadecimal transaction hash value.
:param is_full:
:return: the merkle pro... | python | def get_merkle_proof(self, tx_hash: str, is_full: bool = False) -> dict:
payload = self.generate_json_rpc_payload(RpcMethod.GET_MERKLE_PROOF, [tx_hash, 1])
response = self.__post(self.__url, payload)
if is_full:
return response
return response['result'] | [
"def",
"get_merkle_proof",
"(",
"self",
",",
"tx_hash",
":",
"str",
",",
"is_full",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"payload",
"=",
"self",
".",
"generate_json_rpc_payload",
"(",
"RpcMethod",
".",
"GET_MERKLE_PROOF",
",",
"[",
"tx_hash",
... | This interface is used to get the corresponding merkle proof based on the specified hexadecimal hash value.
:param tx_hash: an hexadecimal transaction hash value.
:param is_full:
:return: the merkle proof in dictionary form. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"corresponding",
"merkle",
"proof",
"based",
"on",
"the",
"specified",
"hexadecimal",
"hash",
"value",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/network/rpc.py#L419-L431 |
2,848 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.parse_ddo | def parse_ddo(ont_id: str, serialized_ddo: str or bytes) -> dict:
"""
This interface is used to deserialize a hexadecimal string into a DDO object in the from of dict.
:param ont_id: the unique ID for identity.
:param serialized_ddo: an serialized description object of ONT ID in form of... | python | def parse_ddo(ont_id: str, serialized_ddo: str or bytes) -> dict:
if len(serialized_ddo) == 0:
return dict()
if isinstance(serialized_ddo, str):
stream = StreamManager.get_stream(bytearray.fromhex(serialized_ddo))
elif isinstance(serialized_ddo, bytes):
stream... | [
"def",
"parse_ddo",
"(",
"ont_id",
":",
"str",
",",
"serialized_ddo",
":",
"str",
"or",
"bytes",
")",
"->",
"dict",
":",
"if",
"len",
"(",
"serialized_ddo",
")",
"==",
"0",
":",
"return",
"dict",
"(",
")",
"if",
"isinstance",
"(",
"serialized_ddo",
","... | This interface is used to deserialize a hexadecimal string into a DDO object in the from of dict.
:param ont_id: the unique ID for identity.
:param serialized_ddo: an serialized description object of ONT ID in form of str or bytes.
:return: a description object of ONT ID in the from of dict. | [
"This",
"interface",
"is",
"used",
"to",
"deserialize",
"a",
"hexadecimal",
"string",
"into",
"a",
"DDO",
"object",
"in",
"the",
"from",
"of",
"dict",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L110-L146 |
2,849 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.get_ddo | def get_ddo(self, ont_id: str) -> dict:
"""
This interface is used to get a DDO object in the from of dict.
:param ont_id: the unique ID for identity.
:return: a description object of ONT ID in the from of dict.
"""
args = dict(ontid=ont_id.encode('utf-8'))
invok... | python | def get_ddo(self, ont_id: str) -> dict:
args = dict(ontid=ont_id.encode('utf-8'))
invoke_code = build_vm.build_native_invoke_code(self.__contract_address, self.__version, 'getDDO', args)
unix_time_now = int(time())
tx = Transaction(0, 0xd1, unix_time_now, 0, 0, None, invoke_code, bytearr... | [
"def",
"get_ddo",
"(",
"self",
",",
"ont_id",
":",
"str",
")",
"->",
"dict",
":",
"args",
"=",
"dict",
"(",
"ontid",
"=",
"ont_id",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"invoke_code",
"=",
"build_vm",
".",
"build_native_invoke_code",
"(",
"self",
"... | This interface is used to get a DDO object in the from of dict.
:param ont_id: the unique ID for identity.
:return: a description object of ONT ID in the from of dict. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"a",
"DDO",
"object",
"in",
"the",
"from",
"of",
"dict",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L171-L184 |
2,850 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.registry_ont_id | def registry_ont_id(self, ont_id: str, ctrl_acct: Account, payer: Account, gas_limit: int, gas_price: int):
"""
This interface is used to send a Transaction object which is used to registry ontid.
:param ont_id: OntId.
:param ctrl_acct: an Account object which indicate who will sign for... | python | def registry_ont_id(self, ont_id: str, ctrl_acct: Account, payer: Account, gas_limit: int, gas_price: int):
if not isinstance(ctrl_acct, Account) or not isinstance(payer, Account):
raise SDKException(ErrorCode.require_acct_params)
b58_payer_address = payer.get_address_base58()
bytes_... | [
"def",
"registry_ont_id",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"ctrl_acct",
":",
"Account",
",",
"payer",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
":",
"if",
"not",
"isinstance",
"(",
"ctrl_acct",
",",
"A... | This interface is used to send a Transaction object which is used to registry ontid.
:param ont_id: OntId.
:param ctrl_acct: an Account object which indicate who will sign for the transaction.
:param payer: an Account object which indicate who will pay for the transaction.
:param gas_li... | [
"This",
"interface",
"is",
"used",
"to",
"send",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"registry",
"ontid",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L187-L205 |
2,851 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.add_attribute | def add_attribute(self, ont_id: str, ctrl_acct: Account, attributes: Attribute, payer: Account, gas_limit: int,
gas_price: int) -> str:
"""
This interface is used to send a Transaction object which is used to add attribute.
:param ont_id: OntId.
:param ctrl_acct: a... | python | def add_attribute(self, ont_id: str, ctrl_acct: Account, attributes: Attribute, payer: Account, gas_limit: int,
gas_price: int) -> str:
if not isinstance(ctrl_acct, Account) or not isinstance(payer, Account):
raise SDKException(ErrorCode.require_acct_params)
pub_key = c... | [
"def",
"add_attribute",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"ctrl_acct",
":",
"Account",
",",
"attributes",
":",
"Attribute",
",",
"payer",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
"->",
"str",
":",
"if"... | This interface is used to send a Transaction object which is used to add attribute.
:param ont_id: OntId.
:param ctrl_acct: an Account object which indicate who will sign for the transaction.
:param attributes: a list of attributes we want to add.
:param payer: an Account object which i... | [
"This",
"interface",
"is",
"used",
"to",
"send",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"add",
"attribute",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L264-L285 |
2,852 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.remove_attribute | def remove_attribute(self, ont_id: str, operator: Account, attrib_key: str, payer: Account, gas_limit: int,
gas_price: int):
"""
This interface is used to send a Transaction object which is used to remove attribute.
:param ont_id: OntId.
:param operator: an Acco... | python | def remove_attribute(self, ont_id: str, operator: Account, attrib_key: str, payer: Account, gas_limit: int,
gas_price: int):
pub_key = operator.get_public_key_bytes()
b58_payer_address = payer.get_address_base58()
tx = self.new_remove_attribute_transaction(ont_id, pub_ke... | [
"def",
"remove_attribute",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"operator",
":",
"Account",
",",
"attrib_key",
":",
"str",
",",
"payer",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
":",
"pub_key",
"=",
"oper... | This interface is used to send a Transaction object which is used to remove attribute.
:param ont_id: OntId.
:param operator: an Account object which indicate who will sign for the transaction.
:param attrib_key: a string which is used to indicate which attribute we want to remove.
:par... | [
"This",
"interface",
"is",
"used",
"to",
"send",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"remove",
"attribute",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L288-L306 |
2,853 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.add_recovery | def add_recovery(self, ont_id: str, ctrl_acct: Account, b58_recovery_address: str, payer: Account, gas_limit: int,
gas_price: int):
"""
This interface is used to send a Transaction object which is used to add the recovery.
:param ont_id: OntId.
:param ctrl_acct: an ... | python | def add_recovery(self, ont_id: str, ctrl_acct: Account, b58_recovery_address: str, payer: Account, gas_limit: int,
gas_price: int):
b58_payer_address = payer.get_address_base58()
pub_key = ctrl_acct.get_public_key_bytes()
tx = self.new_add_recovery_transaction(ont_id, pub_ke... | [
"def",
"add_recovery",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"ctrl_acct",
":",
"Account",
",",
"b58_recovery_address",
":",
"str",
",",
"payer",
":",
"Account",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
":",
"b58_payer_address... | This interface is used to send a Transaction object which is used to add the recovery.
:param ont_id: OntId.
:param ctrl_acct: an Account object which indicate who will sign for the transaction.
:param b58_recovery_address: a base58 encode address which indicate who is the recovery.
:pa... | [
"This",
"interface",
"is",
"used",
"to",
"send",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"add",
"the",
"recovery",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L309-L329 |
2,854 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.new_registry_ont_id_transaction | def new_registry_ont_id_transaction(self, ont_id: str, pub_key: str or bytes, b58_payer_address: str,
gas_limit: int, gas_price: int) -> Transaction:
"""
This interface is used to generate a Transaction object which is used to register ONT ID.
:param ont_... | python | def new_registry_ont_id_transaction(self, ont_id: str, pub_key: str or bytes, b58_payer_address: str,
gas_limit: int, gas_price: int) -> Transaction:
if isinstance(pub_key, str):
bytes_ctrl_pub_key = bytes.fromhex(pub_key)
elif isinstance(pub_key, byte... | [
"def",
"new_registry_ont_id_transaction",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"pub_key",
":",
"str",
"or",
"bytes",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
")",
"->",
"Transaction",
":",
"i... | This interface is used to generate a Transaction object which is used to register ONT ID.
:param ont_id: OntId.
:param pub_key: the hexadecimal public key in the form of string.
:param b58_payer_address: a base58 encode address which indicate who will pay for the transaction.
:param gas... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"register",
"ONT",
"ID",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L386-L406 |
2,855 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.new_revoke_public_key_transaction | def new_revoke_public_key_transaction(self, ont_id: str, bytes_operator: bytes, revoked_pub_key: str or bytes,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to remove public key... | python | def new_revoke_public_key_transaction(self, ont_id: str, bytes_operator: bytes, revoked_pub_key: str or bytes,
b58_payer_address: str, gas_limit: int, gas_price: int):
if isinstance(revoked_pub_key, str):
bytes_revoked_pub_key = bytes.fromhex(revoked_pub_key... | [
"def",
"new_revoke_public_key_transaction",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"bytes_operator",
":",
"bytes",
",",
"revoked_pub_key",
":",
"str",
"or",
"bytes",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":... | This interface is used to generate a Transaction object which is used to remove public key.
:param ont_id: OntId.
:param bytes_operator: operator args in from of bytes.
:param revoked_pub_key: a public key string which will be removed.
:param b58_payer_address: a base58 encode address w... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"remove",
"public",
"key",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L438-L460 |
2,856 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.new_add_attribute_transaction | def new_add_attribute_transaction(self, ont_id: str, pub_key: str or bytes, attributes: Attribute,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to add attribute.
:param on... | python | def new_add_attribute_transaction(self, ont_id: str, pub_key: str or bytes, attributes: Attribute,
b58_payer_address: str, gas_limit: int, gas_price: int):
if isinstance(pub_key, str):
bytes_pub_key = bytes.fromhex(pub_key)
elif isinstance(pub_key, bytes... | [
"def",
"new_add_attribute_transaction",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"pub_key",
":",
"str",
"or",
"bytes",
",",
"attributes",
":",
"Attribute",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
... | This interface is used to generate a Transaction object which is used to add attribute.
:param ont_id: OntId.
:param pub_key: the hexadecimal public key in the form of string.
:param attributes: a list of attributes we want to add.
:param b58_payer_address: a base58 encode address which... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"add",
"attribute",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L463-L488 |
2,857 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.new_remove_attribute_transaction | def new_remove_attribute_transaction(self, ont_id: str, pub_key: str or bytes, attrib_key: str,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to remove attribute.
:param... | python | def new_remove_attribute_transaction(self, ont_id: str, pub_key: str or bytes, attrib_key: str,
b58_payer_address: str, gas_limit: int, gas_price: int):
if isinstance(pub_key, str):
bytes_pub_key = bytes.fromhex(pub_key)
elif isinstance(pub_key, bytes... | [
"def",
"new_remove_attribute_transaction",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"pub_key",
":",
"str",
"or",
"bytes",
",",
"attrib_key",
":",
"str",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int",
"... | This interface is used to generate a Transaction object which is used to remove attribute.
:param ont_id: OntId.
:param pub_key: the hexadecimal public key in the form of string.
:param attrib_key: a string which is used to indicate which attribute we want to remove.
:param b58_payer_ad... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"remove",
"attribute",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L491-L512 |
2,858 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/ontid.py | OntId.new_add_recovery_transaction | def new_add_recovery_transaction(self, ont_id: str, pub_key: str or bytes, b58_recovery_address: str,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to add the recovery.
:par... | python | def new_add_recovery_transaction(self, ont_id: str, pub_key: str or bytes, b58_recovery_address: str,
b58_payer_address: str, gas_limit: int, gas_price: int):
if isinstance(pub_key, str):
bytes_pub_key = bytes.fromhex(pub_key)
elif isinstance(pub_key, byt... | [
"def",
"new_add_recovery_transaction",
"(",
"self",
",",
"ont_id",
":",
"str",
",",
"pub_key",
":",
"str",
"or",
"bytes",
",",
"b58_recovery_address",
":",
"str",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price",
":",
"int... | This interface is used to generate a Transaction object which is used to add the recovery.
:param ont_id: OntId.
:param pub_key: the hexadecimal public key in the form of string.
:param b58_recovery_address: a base58 encode address which indicate who is the recovery.
:param b58_payer_ad... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"which",
"is",
"used",
"to",
"add",
"the",
"recovery",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/ontid.py#L515-L537 |
2,859 | ontio/ontology-python-sdk | ontology/core/transaction.py | Transaction.sign_transaction | def sign_transaction(self, signer: Account):
"""
This interface is used to sign the transaction.
:param signer: an Account object which will sign the transaction.
:return: a Transaction object which has been signed.
"""
tx_hash = self.hash256()
sig_data = signer.... | python | def sign_transaction(self, signer: Account):
tx_hash = self.hash256()
sig_data = signer.generate_signature(tx_hash)
sig = [Sig([signer.get_public_key_bytes()], 1, [sig_data])]
self.sig_list = sig | [
"def",
"sign_transaction",
"(",
"self",
",",
"signer",
":",
"Account",
")",
":",
"tx_hash",
"=",
"self",
".",
"hash256",
"(",
")",
"sig_data",
"=",
"signer",
".",
"generate_signature",
"(",
"tx_hash",
")",
"sig",
"=",
"[",
"Sig",
"(",
"[",
"signer",
".... | This interface is used to sign the transaction.
:param signer: an Account object which will sign the transaction.
:return: a Transaction object which has been signed. | [
"This",
"interface",
"is",
"used",
"to",
"sign",
"the",
"transaction",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/core/transaction.py#L137-L147 |
2,860 | ontio/ontology-python-sdk | ontology/core/transaction.py | Transaction.add_sign_transaction | def add_sign_transaction(self, signer: Account):
"""
This interface is used to add signature into the transaction.
:param signer: an Account object which will sign the transaction.
:return: a Transaction object which has been signed.
"""
if self.sig_list is None or len(s... | python | def add_sign_transaction(self, signer: Account):
if self.sig_list is None or len(self.sig_list) == 0:
self.sig_list = []
elif len(self.sig_list) >= TX_MAX_SIG_SIZE:
raise SDKException(ErrorCode.param_err('the number of transaction signatures should not be over 16'))
tx_ha... | [
"def",
"add_sign_transaction",
"(",
"self",
",",
"signer",
":",
"Account",
")",
":",
"if",
"self",
".",
"sig_list",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"sig_list",
")",
"==",
"0",
":",
"self",
".",
"sig_list",
"=",
"[",
"]",
"elif",
"len",
... | This interface is used to add signature into the transaction.
:param signer: an Account object which will sign the transaction.
:return: a Transaction object which has been signed. | [
"This",
"interface",
"is",
"used",
"to",
"add",
"signature",
"into",
"the",
"transaction",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/core/transaction.py#L149-L163 |
2,861 | ontio/ontology-python-sdk | ontology/core/transaction.py | Transaction.add_multi_sign_transaction | def add_multi_sign_transaction(self, m: int, pub_keys: List[bytes] or List[str], signer: Account):
"""
This interface is used to generate an Transaction object which has multi signature.
:param tx: a Transaction object which will be signed.
:param m: the amount of signer.
:param... | python | def add_multi_sign_transaction(self, m: int, pub_keys: List[bytes] or List[str], signer: Account):
for index, pk in enumerate(pub_keys):
if isinstance(pk, str):
pub_keys[index] = pk.encode('ascii')
pub_keys = ProgramBuilder.sort_public_keys(pub_keys)
tx_hash = self.ha... | [
"def",
"add_multi_sign_transaction",
"(",
"self",
",",
"m",
":",
"int",
",",
"pub_keys",
":",
"List",
"[",
"bytes",
"]",
"or",
"List",
"[",
"str",
"]",
",",
"signer",
":",
"Account",
")",
":",
"for",
"index",
",",
"pk",
"in",
"enumerate",
"(",
"pub_k... | This interface is used to generate an Transaction object which has multi signature.
:param tx: a Transaction object which will be signed.
:param m: the amount of signer.
:param pub_keys: a list of public keys.
:param signer: an Account object which will sign the transaction.
:re... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"an",
"Transaction",
"object",
"which",
"has",
"multi",
"signature",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/core/transaction.py#L165-L195 |
2,862 | ontio/ontology-python-sdk | ontology/account/account.py | Account.export_gcm_encrypted_private_key | def export_gcm_encrypted_private_key(self, password: str, salt: str, n: int = 16384) -> str:
"""
This interface is used to export an AES algorithm encrypted private key with the mode of GCM.
:param password: the secret pass phrase to generate the keys from.
:param salt: A string to use ... | python | def export_gcm_encrypted_private_key(self, password: str, salt: str, n: int = 16384) -> str:
r = 8
p = 8
dk_len = 64
scrypt = Scrypt(n, r, p, dk_len)
derived_key = scrypt.generate_kd(password, salt)
iv = derived_key[0:12]
key = derived_key[32:64]
hdr = sel... | [
"def",
"export_gcm_encrypted_private_key",
"(",
"self",
",",
"password",
":",
"str",
",",
"salt",
":",
"str",
",",
"n",
":",
"int",
"=",
"16384",
")",
"->",
"str",
":",
"r",
"=",
"8",
"p",
"=",
"8",
"dk_len",
"=",
"64",
"scrypt",
"=",
"Scrypt",
"("... | This interface is used to export an AES algorithm encrypted private key with the mode of GCM.
:param password: the secret pass phrase to generate the keys from.
:param salt: A string to use for better protection from dictionary attacks.
This value does not need to be kept secret, ... | [
"This",
"interface",
"is",
"used",
"to",
"export",
"an",
"AES",
"algorithm",
"encrypted",
"private",
"key",
"with",
"the",
"mode",
"of",
"GCM",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/account/account.py#L108-L130 |
2,863 | ontio/ontology-python-sdk | ontology/account/account.py | Account.get_gcm_decoded_private_key | def get_gcm_decoded_private_key(encrypted_key_str: str, password: str, b58_address: str, salt: str, n: int,
scheme: SignatureScheme) -> str:
"""
This interface is used to decrypt an private key which has been encrypted.
:param encrypted_key_str: an gcm encryp... | python | def get_gcm_decoded_private_key(encrypted_key_str: str, password: str, b58_address: str, salt: str, n: int,
scheme: SignatureScheme) -> str:
r = 8
p = 8
dk_len = 64
scrypt = Scrypt(n, r, p, dk_len)
derived_key = scrypt.generate_kd(password, sal... | [
"def",
"get_gcm_decoded_private_key",
"(",
"encrypted_key_str",
":",
"str",
",",
"password",
":",
"str",
",",
"b58_address",
":",
"str",
",",
"salt",
":",
"str",
",",
"n",
":",
"int",
",",
"scheme",
":",
"SignatureScheme",
")",
"->",
"str",
":",
"r",
"="... | This interface is used to decrypt an private key which has been encrypted.
:param encrypted_key_str: an gcm encrypted private key in the form of string.
:param password: the secret pass phrase to generate the keys from.
:param b58_address: a base58 encode address which should be correspond with... | [
"This",
"interface",
"is",
"used",
"to",
"decrypt",
"an",
"private",
"key",
"which",
"has",
"been",
"encrypted",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/account/account.py#L133-L162 |
2,864 | ontio/ontology-python-sdk | ontology/account/account.py | Account.export_wif | def export_wif(self) -> str:
"""
This interface is used to get export ECDSA private key in the form of WIF which
is a way to encoding an ECDSA private key and make it easier to copy.
:return: a WIF encode private key.
"""
data = b''.join([b'\x80', self.__private_key, b'\... | python | def export_wif(self) -> str:
data = b''.join([b'\x80', self.__private_key, b'\01'])
checksum = Digest.hash256(data[0:34])
wif = base58.b58encode(b''.join([data, checksum[0:4]]))
return wif.decode('ascii') | [
"def",
"export_wif",
"(",
"self",
")",
"->",
"str",
":",
"data",
"=",
"b''",
".",
"join",
"(",
"[",
"b'\\x80'",
",",
"self",
".",
"__private_key",
",",
"b'\\01'",
"]",
")",
"checksum",
"=",
"Digest",
".",
"hash256",
"(",
"data",
"[",
"0",
":",
"34"... | This interface is used to get export ECDSA private key in the form of WIF which
is a way to encoding an ECDSA private key and make it easier to copy.
:return: a WIF encode private key. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"export",
"ECDSA",
"private",
"key",
"in",
"the",
"form",
"of",
"WIF",
"which",
"is",
"a",
"way",
"to",
"encoding",
"an",
"ECDSA",
"private",
"key",
"and",
"make",
"it",
"easier",
"to",
"copy",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/account/account.py#L216-L226 |
2,865 | ontio/ontology-python-sdk | ontology/account/account.py | Account.get_private_key_from_wif | def get_private_key_from_wif(wif: str) -> bytes:
"""
This interface is used to decode a WIF encode ECDSA private key.
:param wif: a WIF encode private key.
:return: a ECDSA private key in the form of bytes.
"""
if wif is None or wif is "":
raise Exception("no... | python | def get_private_key_from_wif(wif: str) -> bytes:
if wif is None or wif is "":
raise Exception("none wif")
data = base58.b58decode(wif)
if len(data) != 38 or data[0] != 0x80 or data[33] != 0x01:
raise Exception("wif wrong")
checksum = Digest.hash256(data[0:34])
... | [
"def",
"get_private_key_from_wif",
"(",
"wif",
":",
"str",
")",
"->",
"bytes",
":",
"if",
"wif",
"is",
"None",
"or",
"wif",
"is",
"\"\"",
":",
"raise",
"Exception",
"(",
"\"none wif\"",
")",
"data",
"=",
"base58",
".",
"b58decode",
"(",
"wif",
")",
"if... | This interface is used to decode a WIF encode ECDSA private key.
:param wif: a WIF encode private key.
:return: a ECDSA private key in the form of bytes. | [
"This",
"interface",
"is",
"used",
"to",
"decode",
"a",
"WIF",
"encode",
"ECDSA",
"private",
"key",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/account/account.py#L229-L245 |
2,866 | ontio/ontology-python-sdk | ontology/crypto/kdf.py | pbkdf2 | def pbkdf2(seed: str or bytes, dk_len: int) -> bytes:
"""
Derive one key from a seed.
:param seed: the secret pass phrase to generate the keys from.
:param dk_len: the length in bytes of every derived key.
:return:
"""
key = b''
index = 1
bytes_seed = str_to_bytes(seed)
while le... | python | def pbkdf2(seed: str or bytes, dk_len: int) -> bytes:
key = b''
index = 1
bytes_seed = str_to_bytes(seed)
while len(key) < dk_len:
key += Digest.sha256(b''.join([bytes_seed, index.to_bytes(4, 'big', signed=True)]))
index += 1
return key[:dk_len] | [
"def",
"pbkdf2",
"(",
"seed",
":",
"str",
"or",
"bytes",
",",
"dk_len",
":",
"int",
")",
"->",
"bytes",
":",
"key",
"=",
"b''",
"index",
"=",
"1",
"bytes_seed",
"=",
"str_to_bytes",
"(",
"seed",
")",
"while",
"len",
"(",
"key",
")",
"<",
"dk_len",
... | Derive one key from a seed.
:param seed: the secret pass phrase to generate the keys from.
:param dk_len: the length in bytes of every derived key.
:return: | [
"Derive",
"one",
"key",
"from",
"a",
"seed",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/crypto/kdf.py#L9-L23 |
2,867 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/abi/abi_function.py | AbiFunction.set_params_value | def set_params_value(self, *params):
"""
This interface is used to set parameter value for an function in abi file.
"""
if len(params) != len(self.parameters):
raise Exception("parameter error")
temp = self.parameters
self.parameters = []
for i in rang... | python | def set_params_value(self, *params):
if len(params) != len(self.parameters):
raise Exception("parameter error")
temp = self.parameters
self.parameters = []
for i in range(len(params)):
self.parameters.append(Parameter(temp[i]['name'], temp[i]['type']))
... | [
"def",
"set_params_value",
"(",
"self",
",",
"*",
"params",
")",
":",
"if",
"len",
"(",
"params",
")",
"!=",
"len",
"(",
"self",
".",
"parameters",
")",
":",
"raise",
"Exception",
"(",
"\"parameter error\"",
")",
"temp",
"=",
"self",
".",
"parameters",
... | This interface is used to set parameter value for an function in abi file. | [
"This",
"interface",
"is",
"used",
"to",
"set",
"parameter",
"value",
"for",
"an",
"function",
"in",
"abi",
"file",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/abi/abi_function.py#L12-L22 |
2,868 | ontio/ontology-python-sdk | ontology/smart_contract/neo_contract/abi/abi_function.py | AbiFunction.get_parameter | def get_parameter(self, param_name: str) -> Parameter:
"""
This interface is used to get a Parameter object from an AbiFunction object
which contain given function parameter's name, type and value.
:param param_name: a string used to indicate which parameter we want to get from AbiFunct... | python | def get_parameter(self, param_name: str) -> Parameter:
for p in self.parameters:
if p.name == param_name:
return p
raise SDKException(ErrorCode.param_err('get parameter failed.')) | [
"def",
"get_parameter",
"(",
"self",
",",
"param_name",
":",
"str",
")",
"->",
"Parameter",
":",
"for",
"p",
"in",
"self",
".",
"parameters",
":",
"if",
"p",
".",
"name",
"==",
"param_name",
":",
"return",
"p",
"raise",
"SDKException",
"(",
"ErrorCode",
... | This interface is used to get a Parameter object from an AbiFunction object
which contain given function parameter's name, type and value.
:param param_name: a string used to indicate which parameter we want to get from AbiFunction.
:return: a Parameter object which contain given function param... | [
"This",
"interface",
"is",
"used",
"to",
"get",
"a",
"Parameter",
"object",
"from",
"an",
"AbiFunction",
"object",
"which",
"contain",
"given",
"function",
"parameter",
"s",
"name",
"type",
"and",
"value",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/neo_contract/abi/abi_function.py#L24-L35 |
2,869 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_bytes | def read_bytes(self, length) -> bytes:
"""
Read the specified number of bytes from the stream.
Args:
length (int): number of bytes to read.
Returns:
bytes: `length` number of bytes.
"""
value = self.stream.read(length)
return value | python | def read_bytes(self, length) -> bytes:
value = self.stream.read(length)
return value | [
"def",
"read_bytes",
"(",
"self",
",",
"length",
")",
"->",
"bytes",
":",
"value",
"=",
"self",
".",
"stream",
".",
"read",
"(",
"length",
")",
"return",
"value"
] | Read the specified number of bytes from the stream.
Args:
length (int): number of bytes to read.
Returns:
bytes: `length` number of bytes. | [
"Read",
"the",
"specified",
"number",
"of",
"bytes",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L71-L82 |
2,870 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_float | def read_float(self, little_endian=True):
"""
Read 4 bytes as a float value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
float:
"""
if little_endian:
endian = "<"
else:... | python | def read_float(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack("%sf" % endian, 4) | [
"def",
"read_float",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"\"%sf\"",
"%",
"endian",
",",
"4",
")"
] | Read 4 bytes as a float value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
float: | [
"Read",
"4",
"bytes",
"as",
"a",
"float",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L102-L116 |
2,871 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_double | def read_double(self, little_endian=True):
"""
Read 8 bytes as a double value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
float:
"""
if little_endian:
endian = "<"
els... | python | def read_double(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack("%sd" % endian, 8) | [
"def",
"read_double",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"\"%sd\"",
"%",
"endian",
",",
"8",
")"
] | Read 8 bytes as a double value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
float: | [
"Read",
"8",
"bytes",
"as",
"a",
"double",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L118-L132 |
2,872 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_int8 | def read_int8(self, little_endian=True):
"""
Read 1 byte as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_int8(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sb' % endian) | [
"def",
"read_int8",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sb'",
"%",
"endian",
")"
] | Read 1 byte as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"1",
"byte",
"as",
"a",
"signed",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L134-L148 |
2,873 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_uint8 | def read_uint8(self, little_endian=True):
"""
Read 1 byte as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_uint8(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sB' % endian) | [
"def",
"read_uint8",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sB'",
"%",
"endian",
")"
] | Read 1 byte as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"1",
"byte",
"as",
"an",
"unsigned",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L150-L164 |
2,874 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_int16 | def read_int16(self, little_endian=True):
"""
Read 2 byte as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_int16(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sh' % endian, 2) | [
"def",
"read_int16",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sh'",
"%",
"endian",
",",
"2",
")"
] | Read 2 byte as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"2",
"byte",
"as",
"a",
"signed",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L166-L180 |
2,875 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_uint16 | def read_uint16(self, little_endian=True):
"""
Read 2 byte as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_uint16(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sH' % endian, 2) | [
"def",
"read_uint16",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sH'",
"%",
"endian",
",",
"2",
")"
] | Read 2 byte as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"2",
"byte",
"as",
"an",
"unsigned",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L182-L196 |
2,876 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_int32 | def read_int32(self, little_endian=True):
"""
Read 4 bytes as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_int32(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%si' % endian, 4) | [
"def",
"read_int32",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%si'",
"%",
"endian",
",",
"4",
")"
] | Read 4 bytes as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"4",
"bytes",
"as",
"a",
"signed",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L198-L212 |
2,877 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_uint32 | def read_uint32(self, little_endian=True):
"""
Read 4 bytes as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_uint32(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sI' % endian, 4) | [
"def",
"read_uint32",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sI'",
"%",
"endian",
",",
"4",
")"
] | Read 4 bytes as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"4",
"bytes",
"as",
"an",
"unsigned",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L214-L228 |
2,878 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_int64 | def read_int64(self, little_endian=True):
"""
Read 8 bytes as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_int64(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sq' % endian, 8) | [
"def",
"read_int64",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sq'",
"%",
"endian",
",",
"8",
")"
] | Read 8 bytes as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"8",
"bytes",
"as",
"a",
"signed",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L230-L244 |
2,879 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_uint64 | def read_uint64(self, little_endian=True):
"""
Read 8 bytes as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | def read_uint64(self, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.unpack('%sQ' % endian, 8) | [
"def",
"read_uint64",
"(",
"self",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"unpack",
"(",
"'%sQ'",
"%",
"endian",
",",
"8",
")"
] | Read 8 bytes as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: | [
"Read",
"8",
"bytes",
"as",
"an",
"unsigned",
"integer",
"value",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L246-L260 |
2,880 | ontio/ontology-python-sdk | ontology/io/binary_reader.py | BinaryReader.read_var_bytes | def read_var_bytes(self, max_size=sys.maxsize) -> bytes:
"""
Read a variable length of bytes from the stream.
Args:
max_size (int): (Optional) maximum number of bytes to read.
Returns:
bytes:
"""
length = self.read_var_int(max_size)
retur... | python | def read_var_bytes(self, max_size=sys.maxsize) -> bytes:
length = self.read_var_int(max_size)
return self.read_bytes(length) | [
"def",
"read_var_bytes",
"(",
"self",
",",
"max_size",
"=",
"sys",
".",
"maxsize",
")",
"->",
"bytes",
":",
"length",
"=",
"self",
".",
"read_var_int",
"(",
"max_size",
")",
"return",
"self",
".",
"read_bytes",
"(",
"length",
")"
] | Read a variable length of bytes from the stream.
Args:
max_size (int): (Optional) maximum number of bytes to read.
Returns:
bytes: | [
"Read",
"a",
"variable",
"length",
"of",
"bytes",
"from",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L288-L299 |
2,881 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_byte | def write_byte(self, value):
"""
Write a single byte to the stream.
Args:
value (bytes, str or int): value to write to the stream.
"""
if isinstance(value, bytes):
self.stream.write(value)
elif isinstance(value, str):
self.stream.write... | python | def write_byte(self, value):
if isinstance(value, bytes):
self.stream.write(value)
elif isinstance(value, str):
self.stream.write(value.encode('utf-8'))
elif isinstance(value, int):
self.stream.write(bytes([value])) | [
"def",
"write_byte",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"self",
".",
"stream",
".",
"write",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"self",
".",
"stre... | Write a single byte to the stream.
Args:
value (bytes, str or int): value to write to the stream. | [
"Write",
"a",
"single",
"byte",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L47-L59 |
2,882 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_float | def write_float(self, value, little_endian=True):
"""
Pack the value as a float and write 4 bytes to the stream.
Args:
value (number): the value to write to the stream.
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
i... | python | def write_float(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sf' % endian, value) | [
"def",
"write_float",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sf'",
"%",
"endian",
",",
"val... | Pack the value as a float and write 4 bytes to the stream.
Args:
value (number): the value to write to the stream.
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"a",
"float",
"and",
"write",
"4",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L95-L110 |
2,883 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_double | def write_double(self, value, little_endian=True):
"""
Pack the value as a double and write 8 bytes to the stream.
Args:
value (number): the value to write to the stream.
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
... | python | def write_double(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sd' % endian, value) | [
"def",
"write_double",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sd'",
"%",
"endian",
",",
"va... | Pack the value as a double and write 8 bytes to the stream.
Args:
value (number): the value to write to the stream.
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"a",
"double",
"and",
"write",
"8",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L112-L127 |
2,884 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_int8 | def write_int8(self, value, little_endian=True):
"""
Pack the value as a signed byte and write 1 byte to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | def write_int8(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sb' % endian, value) | [
"def",
"write_int8",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sb'",
"%",
"endian",
",",
"valu... | Pack the value as a signed byte and write 1 byte to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"a",
"signed",
"byte",
"and",
"write",
"1",
"byte",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L129-L144 |
2,885 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_uint8 | def write_uint8(self, value, little_endian=True):
"""
Pack the value as an unsigned byte and write 1 byte to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | def write_uint8(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sB' % endian, value) | [
"def",
"write_uint8",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sB'",
"%",
"endian",
",",
"val... | Pack the value as an unsigned byte and write 1 byte to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"an",
"unsigned",
"byte",
"and",
"write",
"1",
"byte",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L146-L161 |
2,886 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_int16 | def write_int16(self, value, little_endian=True):
"""
Pack the value as a signed integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | def write_int16(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sh' % endian, value) | [
"def",
"write_int16",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sh'",
"%",
"endian",
",",
"val... | Pack the value as a signed integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"a",
"signed",
"integer",
"and",
"write",
"2",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L175-L190 |
2,887 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_uint16 | def write_uint16(self, value, little_endian=True):
"""
Pack the value as an unsigned integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes writte... | python | def write_uint16(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sH' % endian, value) | [
"def",
"write_uint16",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sH'",
"%",
"endian",
",",
"va... | Pack the value as an unsigned integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"an",
"unsigned",
"integer",
"and",
"write",
"2",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L192-L207 |
2,888 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_int32 | def write_int32(self, value, little_endian=True):
"""
Pack the value as a signed integer and write 4 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | def write_int32(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%si' % endian, value) | [
"def",
"write_int32",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%si'",
"%",
"endian",
",",
"val... | Pack the value as a signed integer and write 4 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"a",
"signed",
"integer",
"and",
"write",
"4",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L209-L224 |
2,889 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_uint32 | def write_uint32(self, value, little_endian=True):
"""
Pack the value as an unsigned integer and write 4 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes writte... | python | def write_uint32(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sI' % endian, value) | [
"def",
"write_uint32",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sI'",
"%",
"endian",
",",
"va... | Pack the value as an unsigned integer and write 4 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"an",
"unsigned",
"integer",
"and",
"write",
"4",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L226-L241 |
2,890 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_int64 | def write_int64(self, value, little_endian=True):
"""
Pack the value as a signed integer and write 8 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | def write_int64(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sq' % endian, value) | [
"def",
"write_int64",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sq'",
"%",
"endian",
",",
"val... | Pack the value as a signed integer and write 8 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"a",
"signed",
"integer",
"and",
"write",
"8",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L243-L258 |
2,891 | ontio/ontology-python-sdk | ontology/io/binary_writer.py | BinaryWriter.write_uint64 | def write_uint64(self, value, little_endian=True):
"""
Pack the value as an unsigned integer and write 8 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes writte... | python | def write_uint64(self, value, little_endian=True):
if little_endian:
endian = "<"
else:
endian = ">"
return self.pack('%sQ' % endian, value) | [
"def",
"write_uint64",
"(",
"self",
",",
"value",
",",
"little_endian",
"=",
"True",
")",
":",
"if",
"little_endian",
":",
"endian",
"=",
"\"<\"",
"else",
":",
"endian",
"=",
"\">\"",
"return",
"self",
".",
"pack",
"(",
"'%sQ'",
"%",
"endian",
",",
"va... | Pack the value as an unsigned integer and write 8 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written. | [
"Pack",
"the",
"value",
"as",
"an",
"unsigned",
"integer",
"and",
"write",
"8",
"bytes",
"to",
"the",
"stream",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L260-L275 |
2,892 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.get_asset_address | def get_asset_address(self, asset: str) -> bytes:
"""
This interface is used to get the smart contract address of ONT otr ONG.
:param asset: a string which is used to indicate which asset's contract address we want to get.
:return: the contract address of asset in the form of bytearray.... | python | def get_asset_address(self, asset: str) -> bytes:
if asset.upper() == 'ONT':
return self.__ont_contract
elif asset.upper() == 'ONG':
return self.__ong_contract
else:
raise SDKException(ErrorCode.other_error('asset is not equal to ONT or ONG.')) | [
"def",
"get_asset_address",
"(",
"self",
",",
"asset",
":",
"str",
")",
"->",
"bytes",
":",
"if",
"asset",
".",
"upper",
"(",
")",
"==",
"'ONT'",
":",
"return",
"self",
".",
"__ont_contract",
"elif",
"asset",
".",
"upper",
"(",
")",
"==",
"'ONG'",
":... | This interface is used to get the smart contract address of ONT otr ONG.
:param asset: a string which is used to indicate which asset's contract address we want to get.
:return: the contract address of asset in the form of bytearray. | [
"This",
"interface",
"is",
"used",
"to",
"get",
"the",
"smart",
"contract",
"address",
"of",
"ONT",
"otr",
"ONG",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L22-L34 |
2,893 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.query_balance | def query_balance(self, asset: str, b58_address: str) -> int:
"""
This interface is used to query the account's ONT or ONG balance.
:param asset: a string which is used to indicate which asset we want to check the balance.
:param b58_address: a base58 encode account address.
:re... | python | def query_balance(self, asset: str, b58_address: str) -> int:
raw_address = Address.b58decode(b58_address).to_bytes()
contract_address = self.get_asset_address(asset)
invoke_code = build_native_invoke_code(contract_address, b'\x00', "balanceOf", raw_address)
tx = Transaction(0, 0xd1, int... | [
"def",
"query_balance",
"(",
"self",
",",
"asset",
":",
"str",
",",
"b58_address",
":",
"str",
")",
"->",
"int",
":",
"raw_address",
"=",
"Address",
".",
"b58decode",
"(",
"b58_address",
")",
".",
"to_bytes",
"(",
")",
"contract_address",
"=",
"self",
".... | This interface is used to query the account's ONT or ONG balance.
:param asset: a string which is used to indicate which asset we want to check the balance.
:param b58_address: a base58 encode account address.
:return: account balance. | [
"This",
"interface",
"is",
"used",
"to",
"query",
"the",
"account",
"s",
"ONT",
"or",
"ONG",
"balance",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L36-L53 |
2,894 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.query_unbound_ong | def query_unbound_ong(self, base58_address: str) -> int:
"""
This interface is used to query the amount of account's unbound ong.
:param base58_address: a base58 encode address which indicate which account's unbound ong we want to query.
:return: the amount of unbound ong in the form of... | python | def query_unbound_ong(self, base58_address: str) -> int:
contract_address = self.get_asset_address('ont')
unbound_ong = self.__sdk.rpc.get_allowance("ong", Address(contract_address).b58encode(), base58_address)
return int(unbound_ong) | [
"def",
"query_unbound_ong",
"(",
"self",
",",
"base58_address",
":",
"str",
")",
"->",
"int",
":",
"contract_address",
"=",
"self",
".",
"get_asset_address",
"(",
"'ont'",
")",
"unbound_ong",
"=",
"self",
".",
"__sdk",
".",
"rpc",
".",
"get_allowance",
"(",
... | This interface is used to query the amount of account's unbound ong.
:param base58_address: a base58 encode address which indicate which account's unbound ong we want to query.
:return: the amount of unbound ong in the form of int. | [
"This",
"interface",
"is",
"used",
"to",
"query",
"the",
"amount",
"of",
"account",
"s",
"unbound",
"ong",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L76-L85 |
2,895 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.query_symbol | def query_symbol(self, asset: str) -> str:
"""
This interface is used to query the asset's symbol of ONT or ONG.
:param asset: a string which is used to indicate which asset's symbol we want to get.
:return: asset's symbol in the form of string.
"""
contract_address = se... | python | def query_symbol(self, asset: str) -> str:
contract_address = self.get_asset_address(asset)
method = 'symbol'
invoke_code = build_native_invoke_code(contract_address, b'\x00', method, bytearray())
tx = Transaction(0, 0xd1, int(time()), 0, 0, None, invoke_code, bytearray(), list())
... | [
"def",
"query_symbol",
"(",
"self",
",",
"asset",
":",
"str",
")",
"->",
"str",
":",
"contract_address",
"=",
"self",
".",
"get_asset_address",
"(",
"asset",
")",
"method",
"=",
"'symbol'",
"invoke_code",
"=",
"build_native_invoke_code",
"(",
"contract_address",... | This interface is used to query the asset's symbol of ONT or ONG.
:param asset: a string which is used to indicate which asset's symbol we want to get.
:return: asset's symbol in the form of string. | [
"This",
"interface",
"is",
"used",
"to",
"query",
"the",
"asset",
"s",
"symbol",
"of",
"ONT",
"or",
"ONG",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L103-L116 |
2,896 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.query_decimals | def query_decimals(self, asset: str) -> int:
"""
This interface is used to query the asset's decimals of ONT or ONG.
:param asset: a string which is used to indicate which asset's decimals we want to get
:return: asset's decimals in the form of int
"""
contract_address =... | python | def query_decimals(self, asset: str) -> int:
contract_address = self.get_asset_address(asset)
invoke_code = build_native_invoke_code(contract_address, b'\x00', 'decimals', bytearray())
tx = Transaction(0, 0xd1, int(time()), 0, 0, None, invoke_code, bytearray(), list())
response = self.__... | [
"def",
"query_decimals",
"(",
"self",
",",
"asset",
":",
"str",
")",
"->",
"int",
":",
"contract_address",
"=",
"self",
".",
"get_asset_address",
"(",
"asset",
")",
"invoke_code",
"=",
"build_native_invoke_code",
"(",
"contract_address",
",",
"b'\\x00'",
",",
... | This interface is used to query the asset's decimals of ONT or ONG.
:param asset: a string which is used to indicate which asset's decimals we want to get
:return: asset's decimals in the form of int | [
"This",
"interface",
"is",
"used",
"to",
"query",
"the",
"asset",
"s",
"decimals",
"of",
"ONT",
"or",
"ONG",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L118-L133 |
2,897 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.new_transfer_transaction | def new_transfer_transaction(self, asset: str, b58_from_address: str, b58_to_address: str, amount: int,
b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction:
"""
This interface is used to generate a Transaction object for transfer.
:param asset... | python | def new_transfer_transaction(self, asset: str, b58_from_address: str, b58_to_address: str, amount: int,
b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction:
if not isinstance(b58_from_address, str) or not isinstance(b58_to_address, str) or not isinstance(
... | [
"def",
"new_transfer_transaction",
"(",
"self",
",",
"asset",
":",
"str",
",",
"b58_from_address",
":",
"str",
",",
"b58_to_address",
":",
"str",
",",
"amount",
":",
"int",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price",... | This interface is used to generate a Transaction object for transfer.
:param asset: a string which is used to indicate which asset we want to transfer.
:param b58_from_address: a base58 encode address which indicate where the asset from.
:param b58_to_address: a base58 encode address which indi... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"for",
"transfer",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L135-L166 |
2,898 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.new_approve_transaction | def new_approve_transaction(self, asset: str, b58_send_address: str, b58_recv_address: str, amount: int,
b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction:
"""
This interface is used to generate a Transaction object for approve.
:param asset:... | python | def new_approve_transaction(self, asset: str, b58_send_address: str, b58_recv_address: str, amount: int,
b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction:
if not isinstance(b58_send_address, str) or not isinstance(b58_recv_address, str):
raise SD... | [
"def",
"new_approve_transaction",
"(",
"self",
",",
"asset",
":",
"str",
",",
"b58_send_address",
":",
"str",
",",
"b58_recv_address",
":",
"str",
",",
"amount",
":",
"int",
",",
"b58_payer_address",
":",
"str",
",",
"gas_limit",
":",
"int",
",",
"gas_price"... | This interface is used to generate a Transaction object for approve.
:param asset: a string which is used to indicate which asset we want to approve.
:param b58_send_address: a base58 encode address which indicate where the approve from.
:param b58_recv_address: a base58 encode address which in... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"for",
"approve",
"."
] | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L168-L198 |
2,899 | ontio/ontology-python-sdk | ontology/smart_contract/native_contract/asset.py | Asset.new_transfer_from_transaction | def new_transfer_from_transaction(self, asset: str, b58_send_address: str, b58_from_address: str,
b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int,
gas_price: int) -> Transaction:
"""
This interface is ... | python | def new_transfer_from_transaction(self, asset: str, b58_send_address: str, b58_from_address: str,
b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int,
gas_price: int) -> Transaction:
raw_sender = Address.b58decode... | [
"def",
"new_transfer_from_transaction",
"(",
"self",
",",
"asset",
":",
"str",
",",
"b58_send_address",
":",
"str",
",",
"b58_from_address",
":",
"str",
",",
"b58_recv_address",
":",
"str",
",",
"amount",
":",
"int",
",",
"b58_payer_address",
":",
"str",
",",
... | This interface is used to generate a Transaction object that allow one account to transfer
a amount of ONT or ONG Asset to another account, in the condition of the first account had been approved.
:param asset: a string which is used to indicate which asset we want to transfer.
:param b58_send_... | [
"This",
"interface",
"is",
"used",
"to",
"generate",
"a",
"Transaction",
"object",
"that",
"allow",
"one",
"account",
"to",
"transfer",
"a",
"amount",
"of",
"ONT",
"or",
"ONG",
"Asset",
"to",
"another",
"account",
"in",
"the",
"condition",
"of",
"the",
"fi... | ac88bdda941896c5d2ced08422a9c5179d3f9b19 | https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L200-L224 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.