-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
97cd232
commit 81b0f8a
Showing
8 changed files
with
112 additions
and
10 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,6 +1,4 @@ | ||
# Use this as docker-compose.override.yml if you use Linux | ||
version: '3.7' | ||
|
||
services: | ||
php: | ||
volumes: | ||
|
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,6 +1,4 @@ | ||
# Use this as docker-compose.override.yml if you use Mac | ||
version: '3.7' | ||
|
||
services: | ||
php: | ||
volumes: | ||
|
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,5 +1,3 @@ | ||
version: '3.7' | ||
|
||
services: | ||
php: | ||
build: | ||
|
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,33 @@ | ||
<?php | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Codedungeon\PHPCliColors\Color; | ||
use Hardcastle\XRPL_PHP\Core\Stablecoin; | ||
use Hardcastle\XRPL_PHP\Client\JsonRpcClient; | ||
|
||
print_r(PHP_EOL . Color::GREEN); | ||
print_r("┌───────────────────────┐" . PHP_EOL); | ||
print_r("│ RLUSD example │" . PHP_EOL); | ||
print_r("└───────────────────────┘" . PHP_EOL); | ||
print_r(PHP_EOL . Color::RESET); | ||
|
||
const NETWORK = 'testnet'; | ||
|
||
$client = new JsonRpcClient(NETWORK); | ||
|
||
print_r(Color::YELLOW . "Funding wallet, please wait..." . PHP_EOL); | ||
$wallet = $client->fundWallet(); | ||
print_r(Color::GREEN . "Created wallet - address: " . Color::WHITE . "{$wallet->getAddress()} " . Color::GREEN . "seed: " . Color::WHITE . "{$wallet->getSeed()}" . PHP_EOL); | ||
|
||
|
||
print_r(Color::YELLOW . "Creating RLUSD trust line, please wait..." . PHP_EOL); | ||
$trustSetTx = [ | ||
"TransactionType" => "TrustSet", | ||
"Account" => $wallet->getAddress(), | ||
"LimitAmount" => Stablecoin::getRLUSDAmount(NETWORK, '10000') | ||
]; | ||
$trustSetPreparedTx = $client->autofill($trustSetTx); | ||
$signedTx = $wallet->sign($trustSetPreparedTx); | ||
$trustSetResponse = $client->submitAndWait($signedTx['tx_blob']); | ||
print_r(Color::GREEN . "Trust line created! TxHash: " . Color::WHITE . "{$trustSetResponse->getResult()['hash']}" . PHP_EOL); |
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
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,46 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* XRPL-PHP | ||
* | ||
* Copyright (c) Alexander Busse | Hardcastle Technologies | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Hardcastle\XRPL_PHP\Core; | ||
|
||
use Exception; | ||
|
||
class Stablecoin { | ||
private const RLUSD = [ | ||
'mainnet' => [ | ||
'issuer' => 'rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De', | ||
'currency' => 'USD', | ||
], | ||
'testnet' => [ | ||
'issuer' => 'rQhWct2fv4Vc4KRjRgMrxa8xPN9Zx9iLKV', | ||
'currency' => 'USD', | ||
], | ||
]; | ||
|
||
public static function getRLUSD(string $network): array | ||
{ | ||
if (isset(self::RLUSD[$network])) { | ||
return self::RLUSD[$network]; | ||
} | ||
|
||
throw new Exception('RLUSD not available for network: ' . $network); | ||
} | ||
|
||
public static function getRLUSDAmount(string $network, string $value): array | ||
{ | ||
$rlusd = self::getRLUSD($network); | ||
|
||
return [ | ||
'currency' => $rlusd['currency'], | ||
'issuer' => $rlusd['issuer'], | ||
'value' => $value, | ||
]; | ||
} | ||
} |