-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
5,863 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
|
||
--build-arg BASE_IMAGE=python:3.9.13-slim-buster | ||
--build-arg BUILD_DATE=2024-11-05T23:05:25UTC | ||
--build-arg BUILD_DATE=2024-11-25T00:37:29UTC | ||
--build-arg DOCKER_BUILD_OPTION=--no-cache --rm=true | ||
--build-arg ECHO_OPTION= | ||
--build-arg GIT_USER=JINWOO-J | ||
--build-arg IS_MULTI_ARCH=false | ||
--build-arg LOCAL_SERVER=20.20.5.172 | ||
--build-arg LOCAL_SERVER=asweenter-oracle | ||
--build-arg NAME=pawnlib | ||
--build-arg PRIMARY_BRANCH=master | ||
--build-arg REPO_HUB=jinwoo | ||
--build-arg SED_OPTION='' | ||
--build-arg UNAME_S=Darwin | ||
--build-arg VERSION=2.0.72 | ||
--build-arg VERSION=2.0.74 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
import common | ||
from pawnlib.typing.converter import format_size, format_network_traffic | ||
from pawnlib.config import pawn | ||
|
||
class Incrementer: | ||
def __init__(self, start=1000): | ||
self.current = start | ||
|
||
def increment(self): | ||
value = self.current | ||
self.current *= 1000 | ||
return value | ||
|
||
|
||
def print_formated_size(unit="", unit_type="storage"): | ||
increment = Incrementer() | ||
for _ in range(7): | ||
value = increment.increment() | ||
formatted_size = format_size(value, unit=unit, decimal_places=5, unit_type=unit_type) | ||
pawn.console.log(f"{value:>42,} {formatted_size:>20}") | ||
|
||
|
||
def print_formated_network_size(per_second=False): | ||
increment = Incrementer() | ||
for _ in range(7): | ||
value = increment.increment() | ||
formatted_size = format_network_traffic(size=value, per_second=per_second) | ||
pawn.console.log(f"{value:>42,} {formatted_size:>20}") | ||
|
||
|
||
print_formated_size() | ||
print_formated_size(unit="GB") | ||
print_formated_size( unit_type="network") | ||
|
||
|
||
|
||
print_formated_network_size() | ||
print_formated_network_size(per_second=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env python3 | ||
import common | ||
from pawnlib.typing.converter import FlatDict, FlatterDict, flatten, Flattener | ||
from pawnlib.output.color_print import dump, classdump | ||
from pawnlib.config import pawnlib_config as pawn | ||
dict_config = { | ||
"key1": "key1 is value", | ||
"111": "sdsdsd", | ||
"1111": "sdsdsd", | ||
"11111": "sdsdsd", | ||
"11111-1": { | ||
"2222-1": "xcxcxc", | ||
"212222-1": "xcxcxc" | ||
}, | ||
"list": [ | ||
"list1", | ||
"list2", | ||
{"aaaa": "bbbbbbbbbbbbbbbbbbbbbbbb"} | ||
] | ||
} | ||
|
||
res2 = Flattener(dict_config, delimiter=".") | ||
pawn.console.rule("Print as String") | ||
dump(res2) | ||
pawn.console.rule("Print as dict ") | ||
dump(res2.to_dict()) | ||
pawn.console.rule("Print key ") | ||
pawn.console.log(f"Get 11111-1.2222-1 => {res2.get('11111-1.2222-1')}") | ||
|
||
list_config = [ | ||
"list1", | ||
"list2", | ||
{"aaaa": "bbbbbbbbbbbbbbbbbbbbbbbb"} | ||
] | ||
|
||
dump(Flattener(list_config)) | ||
|
||
flatten_dict_test = Flattener(list_config) | ||
|
||
pawn.console.rule("Unflatten ") | ||
dump(flatten_dict_test.unflatten()) | ||
|
||
unflatten_dict = FlatDict(list_config).as_dict() | ||
|
||
rpc_response = { | ||
"jsonrpc": "2.0", | ||
"result": { | ||
"block_hash": "db0e18176318217d246ff10aee570f8d31a430cacf8bca2e0b0a97fc622f103f", | ||
"confirmed_transaction_list": [ | ||
{ | ||
"data": { | ||
"result": { | ||
"coveredByFee": "0x0", | ||
"coveredByOverIssuedICX": "0x0", | ||
"issue": "0x201fdfcf45d9425f" | ||
} | ||
}, | ||
"dataType": "base", | ||
"timestamp": "0x62760444bdf10", | ||
"txHash": "0xc81ff93eb41f0b762a8342ec62c9bc2a4322586a4cd050d23306d73bbf1392ab", | ||
"version": "0x3" | ||
} | ||
], | ||
"height": 8747878, | ||
"merkle_tree_root_hash": "016a2af5fe5001c053a1856f996ad66f6ae1877f547deb645dee909cac689bd9", | ||
"peer_id": "hxf2b4ef450c4f158b4611e234bb57f00ad7a615ef", | ||
"prev_block_hash": "6ae91471d1aea76544e58fe6e222dcc08a73ed90b5a9c679c0a78b08aca2f111", | ||
"signature": "", | ||
"time_stamp": 1732144276430608, | ||
"version": "2.0" | ||
}, | ||
"id": 2848 | ||
} | ||
|
||
flatten_rpc = Flattener(rpc_response) | ||
pawn.console.print(flatten_rpc.get("result.time_stamp")) | ||
pawn.console.print(repr(flatten_rpc)) | ||
|
||
pawn.console.print(flatten_rpc.to_dict()) | ||
|
||
pawn.console.rule("Keep list") | ||
|
||
pawn.console.log(Flattener(rpc_response, keep_lists=True).to_dict()) | ||
|
||
pawn.console.rule("get 'result'") | ||
pawn.console.log(flatten_rpc.get('result')) | ||
|
||
pawn.console.rule("get 'result.prev_block_hash'") | ||
pawn.console.log(flatten_rpc.get('result.prev_block_hash')) | ||
|
||
exit() | ||
|
||
pawn.console.print(flatten_rpc.unflatten()) | ||
pawn.console.print(flatten_rpc.original_value) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
try: | ||
import common | ||
except: | ||
pass | ||
from pawnlib.output.file import NullByteRemover | ||
|
||
|
||
def create_test_file(file_path, size_in_bytes, null_byte_positions): | ||
""" | ||
Create a test file with specified size and null bytes at given positions. | ||
:param file_path: Path to the test file to be created. | ||
:param size_in_bytes: Total size of the file in bytes. | ||
:param null_byte_positions: List of byte positions where null bytes should be inserted. | ||
""" | ||
with open(file_path, 'wb') as f: | ||
for i in range(size_in_bytes): | ||
if i in null_byte_positions: | ||
f.write(b'\x00'*10) # Write a null byte | ||
else: | ||
f.write(b'A') # Write a regular byte (e.g., 'A') | ||
|
||
def main(): | ||
# Create test files | ||
test_files = [ | ||
("test_file1.txt", 1024, [0, 20, 30]), # 1 KB file with null bytes at positions 10, 20, 30 | ||
("test_file2.txt", 2048, [50, 100, 150]), # 2 KB file with null bytes at positions 50, 100, 150 | ||
("test_file3.txt", 512, [5, 15]), # 512 bytes file with null bytes at positions 5, 15 | ||
] | ||
|
||
for file_name, size, null_positions in test_files: | ||
create_test_file(file_name, size, null_positions) | ||
print(f"Created {file_name} with size {size} bytes and null bytes at positions {null_positions}") | ||
|
||
# Now we can use the NullByteRemover class to remove null bytes from these files | ||
remover = NullByteRemover([file_name for file_name, _, _ in test_files]) | ||
remover.remove_null_bytes() | ||
remover.print_report() | ||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import common | ||
from pawnlib.config import pawnlib_config as pawn | ||
from pawnlib.utils.http import jequest, disable_ssl_warnings, icon_rpc_call, IconRpcHelper, NetworkInfo | ||
from pawnlib.utils import icx_signer, http | ||
|
||
disable_ssl_warnings() | ||
# icx_signer.compressed = False | ||
|
||
|
||
def main(): | ||
# private_key = "0x32cf8c963178b1dc15abe5628ce098ce067d7afc8cffa0f27405edd3afa90810" | ||
private_key = "cd405e346fa7b7da8c29fdbb769c76965e1a764c2e2f54337ccd0b35434bafc3" | ||
# pawn.console.log(private_key) | ||
network_info = NetworkInfo(network_name="jw-test", network_api="http://20.20.4.129:9000") | ||
pawn.console.log(network_info) | ||
|
||
wallet = icx_signer.load_wallet_key(private_key) | ||
icon_rpc = IconRpcHelper( | ||
network_info=network_info, | ||
wallet=wallet, | ||
raise_on_failure=True, | ||
tx_method='icx_getTransactionByHash', | ||
) | ||
|
||
pawn.console.log(icon_rpc.claim_iscore()) | ||
pawn.console.log(icon_rpc.unjail()) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.