Skip to content

Commit f796953

Browse files
Merge pull request #571 from HathorNetwork/release
Sync master branch with release
2 parents c99fe36 + a6bb073 commit f796953

File tree

7 files changed

+34
-30
lines changed

7 files changed

+34
-30
lines changed

.github/workflows/apidocs-upload.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,5 @@ jobs:
103103
run: |
104104
if [[ "${{ env.release_status }}" == "isRelease" ]]; then
105105
aws s3 cp index.html s3://${{ secrets.AWS_APIDOCS_BUCKET_NAME_PROD }}
106-
else
107-
aws s3 cp index.html s3://${{ secrets.AWS_APIDOCS_BUCKET_NAME_DEV }}
108106
fi
109107

__tests__/integration/configuration/blueprints/authority.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from hathor.nanocontracts.blueprint import Blueprint
16-
from hathor.nanocontracts.context import Context
17-
from hathor.nanocontracts.exception import NCFail
18-
from hathor.nanocontracts.types import (
15+
from hathor import (
16+
Blueprint,
17+
Context,
1918
NCAction,
2019
NCDepositAction,
2120
NCGrantAuthorityAction,
2221
NCAcquireAuthorityAction,
2322
NCWithdrawalAction,
23+
NCFail,
2424
TokenUid,
25+
export,
2526
public,
2627
)
2728

2829
class TooManyActions(NCFail):
2930
pass
3031

32+
@export
3133
class AuthorityBlueprint(Blueprint):
3234
def _get_action(self, ctx: Context) -> NCAction:
3335
"""Return the only action available; fails otherwise."""
@@ -82,7 +84,4 @@ def melt(self, ctx: Context, token_uid: TokenUid, amount: int) -> None:
8284

8385
@public
8486
def revoke(self, ctx: Context, token_uid: TokenUid, revoke_mint: bool, revoke_melt: bool) -> None:
85-
self.syscall.revoke_authorities(token_uid=token_uid, revoke_mint=revoke_mint, revoke_melt=revoke_melt)
86-
87-
88-
__blueprint__ = AuthorityBlueprint
87+
self.syscall.revoke_authorities(token_uid=token_uid, revoke_mint=revoke_mint, revoke_melt=revoke_melt)

__tests__/integration/configuration/blueprints/bet.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from math import floor
1615
from typing import Optional, TypeAlias
1716

18-
from hathor.nanocontracts.blueprint import Blueprint
19-
from hathor.nanocontracts.context import Context
20-
from hathor.nanocontracts.exception import NCFail
21-
from hathor.nanocontracts.types import (
17+
from hathor import (
2218
Address,
19+
Blueprint,
20+
Context,
2321
NCAction,
2422
NCDepositAction,
2523
NCWithdrawalAction,
24+
NCFail,
2625
SignedData,
2726
Timestamp,
2827
TokenUid,
2928
TxOutputScript,
3029
public,
30+
export,
3131
view,
3232
)
3333

@@ -63,6 +63,7 @@ class InvalidOracleSignature(NCFail):
6363
pass
6464

6565

66+
@export
6667
class Bet(Blueprint):
6768
"""Bet blueprint with final result provided by an oracle.
6869
@@ -117,6 +118,11 @@ def initialize(self, ctx: Context, oracle_script: TxOutputScript, token_uid: Tok
117118
self.final_result = None
118119
self.total = Amount(0)
119120

121+
self.bets_total = {}
122+
self.bets_address = {}
123+
self.address_details = {}
124+
self.withdrawals = {}
125+
120126
@view
121127
def has_result(self) -> bool:
122128
"""Return True if the final result has already been set."""
@@ -154,7 +160,7 @@ def bet(self, ctx: Context, address: Address, score: str) -> None:
154160
assert isinstance(action, NCDepositAction)
155161
self.fail_if_result_is_available()
156162
self.fail_if_invalid_token(action)
157-
if ctx.timestamp > self.date_last_bet:
163+
if ctx.block.timestamp > self.date_last_bet:
158164
raise TooLate(f'cannot place bets after {self.date_last_bet}')
159165
amount = Amount(action.amount)
160166
self.total = Amount(self.total + amount)
@@ -191,7 +197,9 @@ def withdraw(self, ctx: Context) -> None:
191197
assert isinstance(action, NCWithdrawalAction)
192198
self.fail_if_result_is_not_available()
193199
self.fail_if_invalid_token(action)
194-
address = Address(ctx.caller_id)
200+
caller_address = ctx.get_caller_address()
201+
assert caller_address is not None
202+
address = Address(caller_address)
195203
allowed = self.get_max_withdrawal(address)
196204
if action.amount > allowed:
197205
raise InsufficientBalance(f'withdrawal amount is greater than available (max: {allowed})')
@@ -217,7 +225,5 @@ def get_winner_amount(self, address: Address) -> Amount:
217225
if result_total == 0:
218226
return Amount(0)
219227
address_total = self.bets_address.get((self.final_result, address), 0)
220-
percentage = address_total / result_total
221-
return Amount(floor(percentage * self.total))
222-
223-
__blueprint__ = Bet
228+
winner_amount = Amount(address_total * self.total // result_total)
229+
return winner_amount

__tests__/integration/configuration/privnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ CHECKPOINTS: []
3434

3535
ENABLE_NANO_CONTRACTS: enabled
3636
NC_ON_CHAIN_BLUEPRINT_RESTRICTED: false
37+
AVG_TIME_BETWEEN_BLOCKS: 5
3738

3839
extends: mainnet.yml

__tests__/integration/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66

77
fullnode:
88
image:
9-
${HATHOR_LIB_INTEGRATION_TESTS_FULLNODE_IMAGE:-hathornetwork/hathor-core:v0.65.0-alpha.3}
9+
${HATHOR_LIB_INTEGRATION_TESTS_FULLNODE_IMAGE:-hathornetwork/hathor-core:v0.67.0}
1010
command: [
1111
"run_node",
1212
"--listen", "tcp:40404",

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hathor-wallet-headless",
3-
"version": "0.36.0",
3+
"version": "0.36.1",
44
"description": "Hathor Wallet Headless, i.e., without graphical user interface",
55
"main": "index.js",
66
"engines": {
@@ -10,7 +10,7 @@
1010
"dependencies": {
1111
"@dinamonetworks/hsm-dinamo": "4.9.1",
1212
"@hathor/healthcheck-lib": "0.1.0",
13-
"@hathor/wallet-lib": "2.8.2",
13+
"@hathor/wallet-lib": "2.9.0",
1414
"axios": "1.7.7",
1515
"express": "4.18.2",
1616
"express-validator": "6.10.0",

0 commit comments

Comments
 (0)