Skip to content

Commit

Permalink
Merge pull request #1 from EXADS/EX-18729
Browse files Browse the repository at this point in the history
EX-18729 - Support POLYGON and BEP20 network aliases by default
  • Loading branch information
fiskolini authored Sep 18, 2023
2 parents 2538d8f + 28e3dad commit a13bb5b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Address/Asset/Usdt.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class Usdt extends AbstractAddress

protected $validators = [
Network::ERC20 => EthValidator::class,
Network::TRC20 => TrxValidator::class,
Network::BEP20 => EthValidator::class,
Network::POLYGON => EthValidator::class,
Network::OMNI => UsdtValidator::class,
Network::TRC20 => TrxValidator::class
];
}
2 changes: 2 additions & 0 deletions src/Address/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Network
{
public const ERC20 = 'ERC20';
public const TRC20 = 'TRC20';
public const BEP20 = 'BEP20';
public const POLYGON = 'POLYGON';
public const ADA = 'ADA';
public const BCH = 'BCH';
public const BTC = 'BTC';
Expand Down
14 changes: 14 additions & 0 deletions tests/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ public function testUsdt()
$this->tryAddresses('USDT', 'OMNI', $this->withCommons([
'1KL6n25utGRYXWyiU1SJkaqrYWYD6FurEo' => true,
'1451oXRTetETBi5sFKLSLuwoL2vNR48x2U' => true,
'3MbYQMMmSkC3AgWkj9FMo5LsPTW1zBTwXL' => true,
'0x9ec7d40d627ec59981446a6e5acb33d51afcaf8a' => true,
'TNGNYjStMYALYbCQBmwTb1rjgutUQtQYHC' => false, // TRC20
'0x25bb155b18958983bb380e738bf676169e7cd531' => false, // BEP20
'0x9ec7d40d627ec59981446a6e5acb33d51afcaf8a' => false,
'bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23'=> ['memo'=> '104067442', 'assertion' => false], // BEP2
]));

Expand All @@ -263,6 +266,15 @@ public function testUsdt()
'1KL6n25utGRYXWyiU1SJkaqrYWYD6FurEo' => false,
'0x5e8306c6f9c46cd48522a2aab5d7cbb1c5f2ede9' => false, // ERC20
]));

$this->tryAddresses('USDT', 'BEP20', $this->withCommons([
'0xdbe82367ce536e685b8e4496e172e26b442dd7c7' => true, // BEP20
]));

$this->tryAddresses('USDT', 'POLYGON', $this->withCommons([
'0xBa3F83aCd6DeFF56b873DBd2b05971002EaD6231' => true, // Polygon
'0x35342fe71e28df1308e5ab74d2c111938aa9f4bf' => true, // Polygon
]));
}

public function testTrx()
Expand Down Expand Up @@ -351,6 +363,7 @@ public function testFactoryNetworkAlias()
'USDT-OMNI' => Network::OMNI,
'USDT-ERC20' => Network::ERC20,
'USDT-TRC20' => Network::TRC20,
'USDT-BEP20' => Network::BEP20
],
'BTC' => [
'SOMETHING-ELSE' => Network::BTC
Expand All @@ -362,6 +375,7 @@ public function testFactoryNetworkAlias()
$this->assertTrue(Validator::isValid('USDT', 'USDT-ERC20', '0x5e8306c6f9c46cd48522a2aab5d7cbb1c5f2ede9'));
$this->assertTrue(Validator::isValid('USDT', 'USDT-TRC20', 'TNGNYjStMYALYbCQBmwTb1rjgutUQtQYHC'));
$this->assertTrue(Validator::isValid('BTC', 'SOMETHING-ELSE', '1LNkDkf4rtKRozGTpPRbPtYJnY2q5N5bFW'));
$this->assertTrue(Validator::isValid('USDT', 'USDT-BEP20', '0xBa3F83aCd6DeFF56b873DBd2b05971002EaD6231'));
}

protected function tryAddresses(string $symbol, string $network, array $addresses): void
Expand Down

0 comments on commit a13bb5b

Please sign in to comment.