Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
wax
Commits
c1555c45
Commit
c1555c45
authored
3 months ago
by
Krzysztof Mochocki
Committed by
Jakub Ziebinski
3 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
Add transaction factory method
parent
e15228d6
No related branches found
No related tags found
1 merge request
!230
Implementation of the python wax interface
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/wax/_private/base_api.py
+16
-3
16 additions, 3 deletions
python/wax/_private/base_api.py
python/wax/interfaces.py
+16
-1
16 additions, 1 deletion
python/wax/interfaces.py
with
32 additions
and
4 deletions
python/wax/_private/base_api.py
+
16
−
3
View file @
c1555c45
from
__future__
import
annotations
from
__future__
import
annotations
from
datetime
import
datetime
,
timezone
from
datetime
import
datetime
,
timedelta
,
timezone
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
wax._private.core.constants
import
HIVE_PERCENT_PRECISION_DOT_PLACES
,
PUBLIC_KEY_ADDRESS_PREFIX
from
wax._private.core.constants
import
(
DEFAULT_TRANSACTION_EXPIRATION_TIME
,
HIVE_PERCENT_PRECISION_DOT_PLACES
,
PUBLIC_KEY_ADDRESS_PREFIX
,
)
from
wax._private.core.decimal_converter
import
DecimalConverter
from
wax._private.core.decimal_converter
import
DecimalConverter
from
wax._private.core.python_price_converter
import
convert_to_python_price
from
wax._private.core.python_price_converter
import
convert_to_python_price
from
wax._private.models.asset
import
(
from
wax._private.models.asset
import
(
...
@@ -30,6 +34,7 @@ from wax._private.result_tools import (
...
@@ -30,6 +34,7 @@ from wax._private.result_tools import (
to_python_string
,
to_python_string
,
validate_wax_result
,
validate_wax_result
,
)
)
from
wax._private.transaction
import
Transaction
from
wax.cpp_python_bridge
import
(
# type: ignore[attr-defined]
from
wax.cpp_python_bridge
import
(
# type: ignore[attr-defined]
calculate_account_hp
,
calculate_account_hp
,
calculate_current_manabar_value
,
calculate_current_manabar_value
,
...
@@ -47,12 +52,13 @@ from wax.cpp_python_bridge import ( # type: ignore[attr-defined]
...
@@ -47,12 +52,13 @@ from wax.cpp_python_bridge import ( # type: ignore[attr-defined]
suggest_brain_key
,
suggest_brain_key
,
validate_operation
,
validate_operation
,
)
)
from
wax.interfaces
import
ChainConfig
,
IWaxBaseInterface
from
wax.interfaces
import
ChainConfig
,
IWaxBaseInterface
,
TTimestamp
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
decimal
import
Decimal
from
decimal
import
Decimal
from
wax._private.models.basic
import
AccountName
,
ChainId
,
PublicKey
,
SigDigest
,
Signature
from
wax._private.models.basic
import
AccountName
,
ChainId
,
PublicKey
,
SigDigest
,
Signature
from
wax.interfaces
import
ITransaction
class
WaxBaseApi
(
IWaxBaseInterface
):
class
WaxBaseApi
(
IWaxBaseInterface
):
...
@@ -268,3 +274,10 @@ class WaxBaseApi(IWaxBaseInterface):
...
@@ -268,3 +274,10 @@ class WaxBaseApi(IWaxBaseInterface):
return
DecimalConverter
.
convert
(
return
DecimalConverter
.
convert
(
expose_result_as_python_string
(
result
),
precision
=
HIVE_PERCENT_PRECISION_DOT_PLACES
expose_result_as_python_string
(
result
),
precision
=
HIVE_PERCENT_PRECISION_DOT_PLACES
)
)
def
create_transaction_with_tapos
(
self
,
tapos_block_id
:
str
,
expiration
:
TTimestamp
|
None
=
None
)
->
ITransaction
:
expiration
=
expiration
or
DEFAULT_TRANSACTION_EXPIRATION_TIME
if
isinstance
(
expiration
,
datetime
):
expiration
=
expiration
.
replace
(
microsecond
=
0
)
-
datetime
.
now
(
timezone
.
utc
).
replace
(
microsecond
=
0
)
assert
isinstance
(
expiration
,
timedelta
),
"
Expiration has to be timedelta type
"
return
Transaction
(
api
=
self
,
tapos_block_id
=
tapos_block_id
,
expiration_time
=
expiration
)
This diff is collapsed.
Click to expand it.
python/wax/interfaces.py
+
16
−
1
View file @
c1555c45
...
@@ -2,6 +2,7 @@ from __future__ import annotations
...
@@ -2,6 +2,7 @@ from __future__ import annotations
from
abc
import
ABC
,
abstractmethod
from
abc
import
ABC
,
abstractmethod
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
datetime
import
datetime
,
timedelta
from
typing
import
TYPE_CHECKING
,
TypeAlias
from
typing
import
TYPE_CHECKING
,
TypeAlias
from
typing_extensions
import
Self
from
typing_extensions
import
Self
...
@@ -9,7 +10,6 @@ from typing_extensions import Self
...
@@ -9,7 +10,6 @@ from typing_extensions import Self
from
wax.proto.transaction_pb2
import
transaction
as
proto_transaction
from
wax.proto.transaction_pb2
import
transaction
as
proto_transaction
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
datetime
import
datetime
from
decimal
import
Decimal
from
decimal
import
Decimal
from
beekeepy._interface.abc.asynchronous.wallet
import
UnlockedWallet
as
AsyncUnlockedWallet
from
beekeepy._interface.abc.asynchronous.wallet
import
UnlockedWallet
as
AsyncUnlockedWallet
...
@@ -31,6 +31,8 @@ if TYPE_CHECKING:
...
@@ -31,6 +31,8 @@ if TYPE_CHECKING:
ProtoTransaction
:
TypeAlias
=
proto_transaction
ProtoTransaction
:
TypeAlias
=
proto_transaction
JsonTransaction
:
TypeAlias
=
str
JsonTransaction
:
TypeAlias
=
str
TTimestamp
:
TypeAlias
=
datetime
|
timedelta
ChainConfig
:
TypeAlias
=
dict
[
str
,
str
]
ChainConfig
:
TypeAlias
=
dict
[
str
,
str
]
...
@@ -574,3 +576,16 @@ class IWaxBaseInterface(ABC):
...
@@ -574,3 +576,16 @@ class IWaxBaseInterface(ABC):
Raises:
Raises:
WaxValidationFailedError: When passed parameters are wrong.
WaxValidationFailedError: When passed parameters are wrong.
"""
"""
@abstractmethod
def
create_transaction_with_tapos
(
self
,
tapos_block_id
:
str
,
expiration
:
TTimestamp
|
None
=
None
)
->
ITransaction
:
"""
Creates transaction object using basic information from chain.
Args:
tapos_block_id: Block id (mostly head) that transaction should refer to
expiration: time (UTC) till transaction is valid. Default to +1 minute.
Returns:
Transaction object
"""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment