Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
NDEV-2952 op-resources: renaming "Default" token name to "Native" tok…
…en name
  • Loading branch information
alfiedotwtf committed May 7, 2024
commit 014637948231de55894d94a562de91b733d1deb6
4 changes: 2 additions & 2 deletions proxy-cli/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def _neon_address_info(self, _) -> None:
balance = self._get_neon_balance(neon_acct)
total_balance += balance

print(f'{ address }\t { str(sol_acct.pubkey()) }\t { balance:,.18f} {self._config.default_token_name}')
print(f'{ address }\t { str(sol_acct.pubkey()) }\t { balance:,.18f} {self._config.native_token_name}')

print(f'total_balance\t { total_balance:,.18f} {self._config.default_token_name}')
print(f'total_balance\t { total_balance:,.18f} {self._config.native_token_name}')

def _solana_accounts_info(self, _) -> None:
total_balance = Decimal(0)
Expand Down
12 changes: 6 additions & 6 deletions proxy-cli/neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def init_args_parser(parsers) -> NeonHandler:
n.withdraw_parser.add_argument('amount', type=int, help='withdrawing amount')
n.withdraw_parser.add_argument(
'type', type=str, default='PERCENT', nargs='?',
help=f"type of amount <PERCENT|{n._config.default_token_name}>"
help=f"type of amount <PERCENT|{n._config.native_token_name}>"
)
return n

Expand Down Expand Up @@ -87,7 +87,7 @@ def _send_tx(self, from_addr: NeonAddress, to_addr: Address, amount: int, gas: i
tx_hash = self._proxy.send_raw_transaction(tx_signed.rawTransaction)
amount = self._get_neon_amount(amount)

print(f'send {amount:,.18} {self._config.default_token_name} from {str(from_addr)} to 0x{to_addr.hex()}: {tx_hash.hex()}')
print(f'send {amount:,.18} {self._config.native_token_name} from {str(from_addr)} to 0x{to_addr.hex()}: {tx_hash.hex()}')

def _estimate_tx(self, from_addr: NeonAddress, to_addr: Address) -> int:
tx = self._create_tx(from_addr, to_addr, 1)
Expand Down Expand Up @@ -115,8 +115,8 @@ def _withdraw_neon(self, args) -> None:

amount = args.amount
a_type = args.type.upper()
if a_type not in {'PERCENT', self._config.default_token_name}:
print(f'wrong type of amount type {a_type}, should be PERCENT or {self._config.default_token_name}', file=sys.stderr)
if a_type not in {'PERCENT', self._config.native_token_name}:
print(f'wrong type of amount type {a_type}, should be PERCENT or {self._config.native_token_name}', file=sys.stderr)
return
elif amount <= 0:
print(f'amount {amount} should be more than 0', file=sys.stderr)
Expand All @@ -133,7 +133,7 @@ def _withdraw_neon(self, args) -> None:
for balance in neon_acct_dict.values():
total_balance += balance

if a_type == self._config.default_token_name:
if a_type == self._config.native_token_name:
check_balance = math.ceil(total_balance / 1_000_000_000 / 1_000_000_000)
if check_balance < amount:
print(f'amount {amount} is too big, should be less than {check_balance}', file=sys.stderr)
Expand Down Expand Up @@ -164,4 +164,4 @@ def _withdraw_neon(self, args) -> None:
break

total_amount = self._get_neon_amount(total_amount)
print(f'successfully send {total_amount:,.18} {self._config.default_token_name} to 0x{dest_addr.hex()}')
print(f'successfully send {total_amount:,.18} {self._config.native_token_name} to 0x{dest_addr.hex()}')
6 changes: 3 additions & 3 deletions proxy/common_neon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self):
self._const_gas_price = self._env_num('CONST_GAS_PRICE', -1, min_gas_price, 100_000_000) * (10 ** 9)

# Operator resource settings
self._default_token_name = os.environ.get("DEFAULT_TOKEN_NAME", "NEON")
self._native_token_name = os.environ.get("NATIVE_TOKEN_NAME", "NEON")
self._holder_size = self._env_num('HOLDER_SIZE', 256 * 1024, 1024, 10 * 1024 * 1024)
self._min_op_balance_to_warn = self._env_num('MIN_OPERATOR_BALANCE_TO_WARN', 9_000_000_000, 1)
self._min_op_balance_to_err = self._env_num('MIN_OPERATOR_BALANCE_TO_ERR', 1_000_000_000, 1)
Expand Down Expand Up @@ -323,8 +323,8 @@ def _env_num(
# Base settings

@property
def default_token_name(self) -> str:
return self._default_token_name
def native_token_name(self) -> str:
return self._native_token_name

@property
def solana_url_list(self) -> List[str]:
Expand Down
2 changes: 1 addition & 1 deletion proxy/gas_tank/gas_tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _process_write_holder_ix(self, sol_neon_ix: SolNeonIxReceiptInfo) -> None:

holder = self._neon_holder_dict.get(key.value, None)
if holder is None:
LOG.debug(f'new {self._config.default_token_name} tx {key}: {str(chunk)}')
LOG.debug(f'new {self._config.native_token_name} tx {key}: {str(chunk)}')
holder = NeonIndexedHolderInfo(key)
self._neon_holder_dict[key.value] = holder

Expand Down
2 changes: 1 addition & 1 deletion proxy/indexer/neon_ix_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def __init__(self, state: SolNeonDecoderCtx, config=Config()):
self._config = config

def execute(self) -> bool:
return self._decoding_success(None, f"deposit {self._config._default_token_name}s")
return self._decoding_success(None, f"deposit {self._config.native_token_name}s")


def get_neon_ix_decoder_list() -> List[Type[DummyIxDecoder]]:
Expand Down
6 changes: 3 additions & 3 deletions proxy/mempool/gas_price_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, config: Config, solana: SolInteractor) -> None:
self._is_const_gas_price = True
self._min_gas_price: Optional[int] = None
self._suggested_gas_price: Optional[int] = None
self._neon_price_symbol = f"Crypto.{self._config.default_token_name}/USD"
self._neon_price_symbol = f"Crypto.{self._config.native_token_name}/USD"

def set_price_account(self, sol_price_account: Optional[SolPubKey], neon_price_account: Optional[SolPubKey]):
if (sol_price_account is None) or (neon_price_account is None):
Expand Down Expand Up @@ -95,9 +95,9 @@ def _get_tokens_prices_from_net(self) -> None:
try:
self._neon_price_usd = self._get_token_price(self._neon_price_symbol)
except PythNetworkError as exc:
LOG.debug(f'Failed to retrieve {self._config.default_token_name} price: {str(exc)}')
LOG.debug(f'Failed to retrieve {self._config.native_token_name} price: {str(exc)}')
except BaseException as exc:
LOG.error(f'Failed to retrieve {self._config.default_token_name} price', exc_info=exc)
LOG.error(f'Failed to retrieve {self._config.native_token_name} price', exc_info=exc)

try:
self._sol_price_usd = self._get_token_price(self._sol_price_symbol)
Expand Down
2 changes: 1 addition & 1 deletion proxy/statistic/proxy_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _init_metric_list(self) -> None:
registry=self._registry
)
self._metr_op_neon_balance = Gauge(
'operator_neon_balance', f"Operator Balance in {self._config.default_token_name}s",
'operator_neon_balance', f"Operator Balance in {self._config.native_token_name}s",
registry=self._registry
)
self._metr_key_total = Gauge(
Expand Down
2 changes: 1 addition & 1 deletion proxy/testing/test_gas_tank_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def create_token_account(self, owner: SolPubKey, mint_amount: int):
def create_eth_account(self):
self.acc_num += 1
account = self.proxy.create_account(f'neonlabsorg/proxy-model.py/issues/344/eth_account{self.acc_num}')
print(f"{self.config.default_token_name} account created: {account.address}")
print(f"{self.config.native_token_name} account created: {account.address}")
return account

def build_tx(self, name: str, ix_list) -> SolLegacyTx:
Expand Down