Skip to content

Commit 74a2862

Browse files
committed
Add issue asset to the endpoints
Fix also an issue for calculating the required fee.
1 parent 70466f6 commit 74a2862

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

docs/assets/issueAsset.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Issue an asset
2+
3+
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".
4+
5+
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.
6+
7+
From an endpoint perspective the are the same:
8+
9+
```php
10+
public function issueAsset(String $name, $description = null, int $amount = 1, int $decimals = 0, int $chain = 0, array $more = [])
11+
```
12+
13+
```php
14+
15+
use \AMBERSIVE\Ardor\Classes\ArdorAccounts;
16+
use \AMBERSIVE\Ardor\Models\ArdorAssets;
17+
18+
...
19+
20+
public function returnAcccountData():ArdorAccount {
21+
22+
$ardor = new ArdorAssets();
23+
$account = $ardor->issueAsset("My Asset", "Test description", 1, 0, 2);
24+
25+
}
26+
```
27+
28+
Sometime it is required to transport more information within an asset. Therefor you can make use of the second param.
29+
If you pass an array it will automatically transform it to json :
30+
31+
```php
32+
33+
...
34+
35+
public function returnAcccountData():ArdorAccount {
36+
37+
$ardor = new ArdorAssets();
38+
$account = $ardor->issueAsset(
39+
"My Asset", [
40+
"msg" => "Test description"
41+
], 1, 0, 2);
42+
43+
}
44+
```
45+
46+
---
47+
Return to the [overview](../overview.md) page for all topics.

src/Classes/ArdorBase.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,23 @@ public function send(String $method, array $body = [], bool $asAdmin = false, $t
184184

185185
$shouldBroadcast = data_get($body, 'broadcasted', true);
186186

187-
$body["broadcasted"] = false;
188-
$body["broadcast"] = false;
187+
$body["broadcasted"] = false;
188+
$body["broadcast"] = false;
189+
$body["calculateFee"] = true;
190+
$body["feeRateNQTPerFXT"] = -1;
189191

190192
$res = new ArdorTransaction($this->send($method, $body, $asAdmin, $type));
191193

192-
$this->setFee($res->transactionJSON->feeNQT != 0 ? $res->transactionJSON->feeNQT : 1000000);
194+
$this->setFee($res->transactionJSON->feeNQT != 0 ? $res->transactionJSON->feeNQT : ($res->minimumFeeFQT * 1));
193195

194196
$body["broadcast"] = $shouldBroadcast;
195197
$body["broadcasted"] = $shouldBroadcast;
196198
$body["feeNQT"] = $this->getFee();
197199

200+
unset($body["feeRateNQTPerFXT"]);
201+
198202
}
199-
else {
203+
else if (data_get($body,'broadcat', false) !== false) {
200204
$body["broadcast"] = true;
201205
$body["broadcasted"] = true;
202206
$body["feeNQT"] = $this->getFee();

src/Tests/Units/Classes/ArdorAssetsTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ public function testArdorAssetsIssuing():void {
2020
$response = new ArdorMockResponse(200, ['accountCurrencies' => []]);
2121

2222
$ardor = new ArdorAssets();
23-
$asset = $ardor
24-
// ->setClient($this->createApiMock([$response]))
25-
->calculateFee()
26-
->issueAsset("${time}", ["test" => true], 1, 0, 2);
23+
$asset = $ardor->calculateFee()->issueAsset("${time}", ["test" => true, "time" => $time], 1, 0, 2);
2724

2825
$this->assertNotNull($asset);
2926
$this->assertTrue($asset instanceof \AMBERSIVE\Ardor\Models\ArdorTransaction);

0 commit comments

Comments
 (0)