diff --git a/docs/assets/issueAsset.md b/docs/assets/issueAsset.md new file mode 100644 index 0000000..853c87f --- /dev/null +++ b/docs/assets/issueAsset.md @@ -0,0 +1,47 @@ +# Issue an asset + +One of the most important parts of a blockchain solution is providing a rocksolid interface for token. In terms of the ardor blockchain they are called "assets". + +Currently there are to major types of assets. Singleton and "normal" assets. Normal assets are just the same like singleton assets with one major difference. Singleton assets only exsits once. + +From an endpoint perspective the are the same: + +```php +public function issueAsset(String $name, $description = null, int $amount = 1, int $decimals = 0, int $chain = 0, array $more = []) +``` + +```php + +use \AMBERSIVE\Ardor\Classes\ArdorAccounts; +use \AMBERSIVE\Ardor\Models\ArdorAssets; + +... + +public function returnAcccountData():ArdorAccount { + + $ardor = new ArdorAssets(); + $account = $ardor->issueAsset("My Asset", "Test description", 1, 0, 2); + +} +``` + +Sometime it is required to transport more information within an asset. Therefor you can make use of the second param. +If you pass an array it will automatically transform it to json : + +```php + +... + +public function returnAcccountData():ArdorAccount { + + $ardor = new ArdorAssets(); + $account = $ardor->issueAsset( + "My Asset", [ + "msg" => "Test description" + ], 1, 0, 2); + +} +``` + +--- +Return to the [overview](../overview.md) page for all topics. \ No newline at end of file diff --git a/src/Classes/ArdorBase.php b/src/Classes/ArdorBase.php index a78c556..07a42b5 100644 --- a/src/Classes/ArdorBase.php +++ b/src/Classes/ArdorBase.php @@ -184,19 +184,23 @@ public function send(String $method, array $body = [], bool $asAdmin = false, $t $shouldBroadcast = data_get($body, 'broadcasted', true); - $body["broadcasted"] = false; - $body["broadcast"] = false; + $body["broadcasted"] = false; + $body["broadcast"] = false; + $body["calculateFee"] = true; + $body["feeRateNQTPerFXT"] = -1; $res = new ArdorTransaction($this->send($method, $body, $asAdmin, $type)); - $this->setFee($res->transactionJSON->feeNQT != 0 ? $res->transactionJSON->feeNQT : 1000000); + $this->setFee($res->transactionJSON->feeNQT != 0 ? $res->transactionJSON->feeNQT : ($res->minimumFeeFQT * 1)); $body["broadcast"] = $shouldBroadcast; $body["broadcasted"] = $shouldBroadcast; $body["feeNQT"] = $this->getFee(); + unset($body["feeRateNQTPerFXT"]); + } - else { + else if (data_get($body,'broadcat', false) !== false) { $body["broadcast"] = true; $body["broadcasted"] = true; $body["feeNQT"] = $this->getFee(); diff --git a/src/Tests/Units/Classes/ArdorAssetsTest.php b/src/Tests/Units/Classes/ArdorAssetsTest.php index 6e8acf0..0641c4f 100644 --- a/src/Tests/Units/Classes/ArdorAssetsTest.php +++ b/src/Tests/Units/Classes/ArdorAssetsTest.php @@ -20,10 +20,7 @@ public function testArdorAssetsIssuing():void { $response = new ArdorMockResponse(200, ['accountCurrencies' => []]); $ardor = new ArdorAssets(); - $asset = $ardor - // ->setClient($this->createApiMock([$response])) - ->calculateFee() - ->issueAsset("${time}", ["test" => true], 1, 0, 2); + $asset = $ardor->calculateFee()->issueAsset("${time}", ["test" => true, "time" => $time], 1, 0, 2); $this->assertNotNull($asset); $this->assertTrue($asset instanceof \AMBERSIVE\Ardor\Models\ArdorTransaction);