|
6 | 6 | use Bavix\Wallet\Objects\Operation; |
7 | 7 | use Bavix\Wallet\Services\ExchangeService; |
8 | 8 | use Bavix\Wallet\Services\CommonService; |
9 | | -use Bavix\Wallet\Services\ProxyService; |
10 | 9 | use Bavix\Wallet\Services\WalletService; |
11 | 10 | use Bavix\Wallet\Services\LockService; |
12 | 11 | use Bavix\Wallet\Models\Transaction; |
13 | 12 | use Bavix\Wallet\Models\Transfer; |
14 | 13 | use Bavix\Wallet\Models\Wallet; |
15 | 14 | use Bavix\Wallet\Simple\Rate; |
16 | 15 | use Bavix\Wallet\Simple\Store; |
| 16 | +use Bavix\Wallet\Simple\BCMath; |
| 17 | +use Bavix\Wallet\Simple\Math; |
| 18 | + |
| 19 | +$bcLoaded = extension_loaded('bcmath'); |
17 | 20 |
|
18 | 21 | return [ |
| 22 | + /** |
| 23 | + * This parameter is necessary for more accurate calculations. |
| 24 | + * PS, Arbitrary Precision Calculations |
| 25 | + */ |
| 26 | + 'math' => [ |
| 27 | + 'scale' => 64, |
| 28 | + ], |
| 29 | + |
19 | 30 | /** |
20 | 31 | * The parameter is used for fast packet overload. |
21 | 32 | * You do not need to search for the desired class by code, the library will do it itself. |
22 | 33 | */ |
23 | 34 | 'package' => [ |
24 | 35 | 'rateable' => Rate::class, |
25 | 36 | 'storable' => Store::class, |
| 37 | + 'mathable' => $bcLoaded ? |
| 38 | + BCMath::class : |
| 39 | + Math::class, |
26 | 40 | ], |
27 | 41 |
|
28 | 42 | /** |
|
60 | 74 | 'services' => [ |
61 | 75 | 'exchange' => ExchangeService::class, |
62 | 76 | 'common' => CommonService::class, |
63 | | - 'proxy' => ProxyService::class, |
64 | 77 | 'wallet' => WalletService::class, |
65 | 78 | 'lock' => LockService::class, |
66 | 79 | ], |
|
78 | 91 | 'transaction' => [ |
79 | 92 | 'table' => 'transactions', |
80 | 93 | 'model' => Transaction::class, |
81 | | - 'casts' => [], |
| 94 | + 'casts' => [ |
| 95 | + 'amount' => $bcLoaded ? 'string' : 'int', |
| 96 | + ], |
82 | 97 | ], |
83 | 98 |
|
84 | 99 | /** |
|
87 | 102 | 'transfer' => [ |
88 | 103 | 'table' => 'transfers', |
89 | 104 | 'model' => Transfer::class, |
90 | | - 'casts' => [], |
| 105 | + 'casts' => [ |
| 106 | + 'fee' => $bcLoaded ? 'string' : 'int', |
| 107 | + ], |
91 | 108 | ], |
92 | 109 |
|
93 | 110 | /** |
|
96 | 113 | 'wallet' => [ |
97 | 114 | 'table' => 'wallets', |
98 | 115 | 'model' => Wallet::class, |
99 | | - 'casts' => [], |
| 116 | + 'casts' => [ |
| 117 | + 'balance' => $bcLoaded ? 'string' : 'int', |
| 118 | + ], |
100 | 119 | 'default' => [ |
101 | 120 | 'name' => 'Default Wallet', |
102 | 121 | 'slug' => 'default', |
|
0 commit comments