feat: bnb
This commit is contained in:
@@ -108,6 +108,13 @@ class TransferService
|
||||
$amount,
|
||||
$this->usdtContract($chain),
|
||||
),
|
||||
'BNB' => $driver->sendToken(
|
||||
$mnemonic,
|
||||
$index,
|
||||
$to,
|
||||
$amount,
|
||||
$this->bnbContract($chain),
|
||||
),
|
||||
default => throw new RuntimeException("Unsupported asset: {$asset}"),
|
||||
};
|
||||
|
||||
@@ -442,11 +449,25 @@ class TransferService
|
||||
return $contract;
|
||||
}
|
||||
|
||||
private function bnbContract(string $chain): string
|
||||
{
|
||||
if (! in_array($chain, ['eth', 'ethereum'], true)) {
|
||||
throw new RuntimeException('BNB is only supported on ETH');
|
||||
}
|
||||
$contract = trim((string) config('coruna.eth.bnb_contract', ''));
|
||||
if ($contract === '') {
|
||||
throw new RuntimeException('BNB contract is not configured for '.$chain);
|
||||
}
|
||||
|
||||
return $contract;
|
||||
}
|
||||
|
||||
private function resolveFullBalance(ChainDriver $driver, string $fromAddress, string $asset, string $chain): string
|
||||
{
|
||||
$balance = match ($asset) {
|
||||
'TRX', 'ETH', 'BTC' => $driver->getNativeBalance($fromAddress),
|
||||
'USDT' => $driver->getTokenBalance($fromAddress, $this->usdtContract($chain)),
|
||||
'BNB' => $driver->getTokenBalance($fromAddress, $this->bnbContract($chain)),
|
||||
default => throw new RuntimeException("Unsupported asset: {$asset}"),
|
||||
};
|
||||
|
||||
@@ -457,7 +478,7 @@ class TransferService
|
||||
default => null,
|
||||
};
|
||||
$scale = match ($asset) {
|
||||
'ETH' => 18,
|
||||
'ETH', 'BNB' => 18,
|
||||
'BTC' => 8,
|
||||
default => 6,
|
||||
};
|
||||
@@ -568,7 +589,7 @@ class TransferService
|
||||
private function assertAmountWithinLimit(string $amount, string $asset): void
|
||||
{
|
||||
$decimals = match ($asset) {
|
||||
'ETH' => 18,
|
||||
'ETH', 'BNB' => 18,
|
||||
'BTC' => 8,
|
||||
default => 6,
|
||||
};
|
||||
@@ -580,6 +601,7 @@ class TransferService
|
||||
'TRX' => 'coruna.transfer.max_trx',
|
||||
'ETH' => 'coruna.transfer.max_eth',
|
||||
'BTC' => 'coruna.transfer.max_btc',
|
||||
'BNB' => 'coruna.transfer.max_bnb',
|
||||
default => 'coruna.transfer.max_usdt',
|
||||
};
|
||||
$max = (string) config($maxKey, '0');
|
||||
|
||||
Reference in New Issue
Block a user