Skip to content

Commit

Permalink
add: demo, update: project to release
Browse files Browse the repository at this point in the history
  • Loading branch information
19Nazar committed Sep 6, 2024
1 parent 3b9fe50 commit 2d245c9
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 53 deletions.
Binary file modified documentation/Mintbase Flutterchain integration.pdf
Binary file not shown.
3 changes: 3 additions & 0 deletions lib/flutterchain_lib/network/chains/near_rpc_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class NearRpcClient {
}
},
);
if (res.data["error"] != null) {
throw Exception("Account not exist");
}
if (res.isSuccess) {
final decodedRes = res.data['result']['amount'].toString();
final nearAmount = NearFormatter.yoctoNearToNear(
Expand Down
21 changes: 13 additions & 8 deletions lib/flutterchain_lib/services/chains/near_blockchain_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class NearBlockChainService implements BlockChainService {
final Map<String, dynamic> args = {
"owner_id": ownerId,
"metadata": {
"name": name,
"name": name.toLowerCase(),
"spec": spec,
"symbol": symbol,
"icon": icon,
Expand Down Expand Up @@ -889,6 +889,8 @@ class NearBlockChainService implements BlockChainService {

Future<Map<String, String>> checkMaxPriceBidNFT(
{required String nftContractId, required int tokenId}) async {
String resPriceBid;

final query = """query MyQuery {
nft_offers_aggregate(
where: {nft_contract_id: {_eq: "$nftContractId"}, token_id: {_eq: "$tokenId"}}
Expand All @@ -905,18 +907,18 @@ class NearBlockChainService implements BlockChainService {

Map<String, dynamic> pricesResponse =
response.data["data"]["nft_offers_aggregate"];
if (pricesResponse.isEmpty) {
throw Exception("This token don`t have offer max sum");
if (pricesResponse["aggregate"]["max"]["offer_price"] != null) {
resPriceBid = Decimal.parse(
pricesResponse["aggregate"]["max"]["offer_price"].toString())
.toString();
} else {
resPriceBid = "There have been no interactions with this offerer yet.";
}

final resPriceBid = Decimal.parse(
pricesResponse["aggregate"]["max"]["offer_price"].toString());

final priceBid = await getPriceForBuySimpleListNFT(
nftContractId: nftContractId, tokenId: tokenId);

Map<String, String> responseBid = {
"maxbid": resPriceBid.toString(),
"maxbid": resPriceBid,
"minbid": priceBid.toString()
};

Expand Down Expand Up @@ -1088,6 +1090,9 @@ class NearBlockChainService implements BlockChainService {
};
}
final mediaFile = File(media);
if (!mediaFile.existsSync()) {
throw Exception("Media file does not exist");
}
String mediaUpload = await uploadFileToArweave(file: mediaFile);
mediaUploadURL = baseURL! + mediaUpload;

Expand Down
3 changes: 3 additions & 0 deletions mintbase_example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:networkSecurityConfig="@xml/network_security_config"
android:label="mintbase_example"
Expand All @@ -12,6 +13,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true"

android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions mintbase_example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:mintbase_example/routes/routes.dart';
void main() {
runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
await initFlutterChainLib();
initFlutterChainLib();
final isAuthorized = await checkIfUserAuthorized();

//Catch Errors caught by Flutter
Expand All @@ -38,7 +38,7 @@ class AppWidget extends StatelessWidget {
Modular.setInitialRoute(CoreRoutes.init);
ScreenUtil.init(context);
ScreenUtil.configure(
designSize: const Size(360, 690),
designSize: const Size(375, 812),
minTextAdapt: true,
splitScreenMode: true,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _AddRemoveMintersState extends State<AddRemoveMinters> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
_isAdd = true;
Expand All @@ -93,7 +93,7 @@ class _AddRemoveMintersState extends State<AddRemoveMinters> {
Theme.of(context).colorScheme.primary)),
),
SizedBox(width: 45),
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
_isAdd = false;
Expand Down Expand Up @@ -123,14 +123,22 @@ class _AddRemoveMintersState extends State<AddRemoveMinters> {
} else if (snapshot.hasError) {
return SelectableText('Error: ${snapshot.error}');
} else {
if (_isAdd == true) {
return const Text(
"Minters was add",
style: TextStyle(fontSize: 16),
);
final data = snapshot.data;
if (data == true) {
if (_isAdd == true) {
return const Text(
"Minters was add",
style: TextStyle(fontSize: 16),
);
} else {
return const Text(
"Minters was delete",
style: TextStyle(fontSize: 16),
);
}
} else {
return const Text(
"Minters was delete",
"Function was not successful",
style: TextStyle(fontSize: 16),
);
}
Expand All @@ -145,6 +153,7 @@ class _AddRemoveMintersState extends State<AddRemoveMinters> {
? const Center(
child: Text(
"Data about minters not loaded,\nfor interaction add name collection",
style: TextStyle(fontSize: 16),
softWrap: true),
)
: Flexible(
Expand Down Expand Up @@ -184,7 +193,10 @@ class _AddRemoveMintersState extends State<AddRemoveMinters> {
],
);
} else {
return const Text('You do not have minters');
return const Text(
'You do not have minters',
style: TextStyle(fontSize: 16),
);
}
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class _BuySimpleListNftState extends State<BuySimpleListNft> {
decoration:
const InputDecoration(labelText: 'Input referrer id(optional)'),
),
ElevatedButton(
SizedBox(height: 10),
FilledButton(
onPressed: () async {
setState(() {
isBuy = buySimpleListNft(
Expand Down Expand Up @@ -105,7 +106,7 @@ class _BuySimpleListNftState extends State<BuySimpleListNft> {
"You can check price nft",
style: TextStyle(fontSize: 16),
),
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
price = checkPrice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class _CheckInfoState extends State<CheckInfo> {
}
},
),
ElevatedButton(
FilledButton(
onPressed: () {
setState(() {
listInfo = checkNFTInfo();
Expand Down Expand Up @@ -145,7 +145,7 @@ class _CheckInfoState extends State<CheckInfo> {
}
},
),
ElevatedButton(
FilledButton(
onPressed: () {
setState(() {
listingNFTInfo = checkListingNFT();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _CreateCollectionDialogState extends State<CreateCollectionDialog> {
TextStyle(fontSize: 17, color: Color.fromARGB(255, 245, 79, 1)),
),
const Text(
"On your account must be more then 3.7 Near",
"On your account must be more then 3.7 Near. And name collection characters must be in lower case.",
style: TextStyle(fontSize: 16),
),
TextField(
Expand Down Expand Up @@ -107,7 +107,7 @@ class _CreateCollectionDialogState extends State<CreateCollectionDialog> {
SizedBox(
height: 10,
),
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
responseCollection = deployNFTCollection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class _ListingActivateState extends State<ListingActivate> {
style: TextStyle(
fontSize: 17,
)),
ElevatedButton(
FilledButton(
onPressed: () {
setState(() {
isActivate = storageListingActivate();
});
},
child: const Text('List NFT',
child: const Text('Activate',
style: TextStyle(color: Colors.white, fontSize: 15)),
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class _MintnftState extends State<Mintnft> {
),
Column(
children: [
ElevatedButton(
FilledButton(
onPressed: () => pickFile(controller: pickMediaController),
child: const Text('Pick media File**',
style: TextStyle(color: Colors.white, fontSize: 15)),
Expand All @@ -239,7 +239,7 @@ class _MintnftState extends State<Mintnft> {
SizedBox(height: 10),
Column(
children: [
ElevatedButton(
FilledButton(
onPressed: () => pickFile(controller: pickAnimationController),
child: const Text('Pick animation File',
style: TextStyle(color: Colors.white, fontSize: 15)),
Expand All @@ -257,7 +257,7 @@ class _MintnftState extends State<Mintnft> {
SizedBox(height: 10),
Column(
children: [
ElevatedButton(
FilledButton(
onPressed: () => pickFile(controller: pickDocumentController),
child: Text('Pick document File',
style: TextStyle(color: Colors.white, fontSize: 15)),
Expand Down Expand Up @@ -488,7 +488,7 @@ class _MintnftState extends State<Mintnft> {
],
),
),
ElevatedButton(
FilledButton(
onPressed: () {
Map<String, int>? split_owners;
Map<String, int>? split_between;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class _MultiplyNFTState extends State<MultiplyNFT> {
decoration:
const InputDecoration(labelText: 'Input num to multiply'),
),
ElevatedButton(
SizedBox(height: 10),
FilledButton(
onPressed: () {
setState(() {
isMint = multiplyNFT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class _OffersState extends State<Offers> {
decoration:
const InputDecoration(labelText: 'Time out(hour, option)'),
),
ElevatedButton(
SizedBox(height: 10),
FilledButton(
onPressed: () {
setState(() {
isOffering = offersToRollingAuction(
Expand All @@ -86,7 +87,7 @@ class _OffersState extends State<Offers> {
);
});
},
child: const Text('Rolling NFT',
child: const Text('Make offer NFT',
style: TextStyle(color: Colors.white, fontSize: 15)),
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(
Expand All @@ -112,7 +113,7 @@ class _OffersState extends State<Offers> {
),
SizedBox(height: 10),
Text("Beffor starting you can check max price bid"),
ElevatedButton(
FilledButton(
onPressed: () {
setState(() {
pricesOffers = checkMaxPriceBidNFT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class _RollingAuctionNftState extends State<RollingAuctionNft> {
controller: priceController,
decoration: const InputDecoration(labelText: 'Minimum bid(Near)'),
),
ElevatedButton(
SizedBox(height: 10),
FilledButton(
onPressed: () {
setState(() {
isRolling = rollingAuctionNft(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class _SimpleSaleState extends State<SimpleSale> {
controller: priceController,
decoration: const InputDecoration(labelText: 'Input price'),
),
ElevatedButton(
SizedBox(height: 10),
FilledButton(
onPressed: () {
setState(() {
isList = simpleSaleNFT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class _TransferCollectionDialogState extends State<TransferCollectionDialog> {
});
}),
),
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
responseTransfer = transferNFTCollection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class _TransfetNftState extends State<TransfetNft> {
),
),
SizedBox(height: 10),
ElevatedButton(
FilledButton(
onPressed: () {
final tokenIds = convertToTokenIds(
idNFTControllers: _idNFTControllers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _UnlistDelistNFTState extends State<UnlistDelistNFT> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
response = unlistNFT(
Expand All @@ -87,7 +87,7 @@ class _UnlistDelistNFTState extends State<UnlistDelistNFT> {
Theme.of(context).colorScheme.primary)),
),
SizedBox(width: 45),
ElevatedButton(
FilledButton(
onPressed: () async {
setState(() {
response = delistNFT(
Expand Down
Loading

0 comments on commit 2d245c9

Please sign in to comment.