1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
use reqwest::header::HeaderMap;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::error::Error;
use std::option::Option;

#[derive(Debug, Serialize, Deserialize)]
pub struct Response<T> {
    pub status: Option<String>,
    pub data: Option<T>,
    pub code: Option<u32>,
    pub message: Option<String>,
}

// Completes user signup with email

pub struct LoginWithEmailParam<'a> {
    pub email: &'a str,
    pub code: &'a str,
    pub password: &'a str,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct LoginWithEmailRes {
    pub access_token: Option<String>,
    pub refresh_token: Option<String>,
    pub user: Option<LoginWithEmailUserAttribute>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct LoginWithEmailUserAttribute {
    pub allow_spend: bool,
    pub id: usize,
    pub eth_address: Option<String>,
    pub sol_address: Option<String>,
    pub email: String,
    pub email_verified: bool,
    pub is_subaccount: bool,
    pub username: String,
    pub main_user_id: Option<String>,
    pub wallet: LoginWithEmailWalletAttribute,
    #[serde(rename = "createdAt")]
    pub created_at: String,
    #[serde(rename = "updatedAt")]
    pub updated_at: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct LoginWithEmailWalletAttribute {
    pub eth_address: String,
    pub sol_address: String,
}

#[tokio::main]
pub async fn complete_signup(
    payload: LoginWithEmailParam,
) -> Result<Option<Response<LoginWithEmailRes>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse().unwrap());
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    let mut map = HashMap::new();
    map.insert("code", payload.code.to_string());
    map.insert("email", payload.email.to_string());
    map.insert("password", payload.password.to_string());
    let url: String =
        crate::STAGING_REQUEST_URL.to_string() + &"/v1/auth/complete-signup".to_string();
    let client = reqwest::Client::new();
    let res = client
        .post(url)
        .headers(headers)
        .json(&map)
        .send()
        .await
        .unwrap();
    let p = res.json::<Response<LoginWithEmailRes>>().await?;
    println!("login_with_email_code_response_is_{:?}", p);
    Ok(Some(p))
}

// Registers a user with email.

#[tokio::main]
pub async fn signup_email(
    email: &str,
) -> Result<Option<Response<LoginWithEmailRes>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse().unwrap());
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    let mut map = HashMap::new();
    map.insert("email", email.to_string());
    let url: String = crate::STAGING_REQUEST_URL.to_string() + &"/v1/auth/signup".to_string();
    let client = reqwest::Client::new();
    let res = client
        .post(url)
        .headers(headers)
        .json(&map)
        .send()
        .await
        .unwrap();
    let p = res.json::<Response<LoginWithEmailRes>>().await?;
    println!("login_with_email_code_response_is_{:?}", p);
    Ok(Some(p))
}

// Logs in a user with email and password

pub struct LoginParam<'a> {
    pub email: &'a str,
    pub password: &'a str,
}

#[tokio::main]
pub async fn login(
    payload: LoginParam,
) -> Result<Option<Response<LoginWithEmailRes>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse().unwrap());
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    let mut map = HashMap::new();
    map.insert("email", payload.email.to_string());
    map.insert("password", payload.password.to_string());
    let url: String = crate::STAGING_REQUEST_URL.to_string() + &"/v1/auth/login".to_string();
    let client = reqwest::Client::new();
    let res = client
        .post(url)
        .headers(headers)
        .json(&map)
        .send()
        .await
        .unwrap();
    let p = res.json::<Response<LoginWithEmailRes>>().await?;
    Ok(Some(p))
}

//Logs in a user with Google OAuth
#[tokio::main]
pub async fn login_google(
    identity_provider_token: String,
) -> Result<Option<Response<LoginWithEmailRes>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse().unwrap());
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    let mut map = HashMap::new();
    map.insert(
        "identity_provider_token",
        identity_provider_token.to_string(),
    );
    let url: String = crate::STAGING_REQUEST_URL.to_string() + &"/v1/auth/google".to_string();
    let client = reqwest::Client::new();
    let res = client
        .post(url)
        .headers(headers)
        .json(&map)
        .send()
        .await
        .unwrap();
    let p = res.json::<Response<LoginWithEmailRes>>().await?;
    Ok(Some(p))
}

// GETChecks whether is authenticated or not and returns the user object if true

#[derive(Debug, Serialize, Deserialize)]
pub struct FetchUser {
    pub id: u32,
    pub eth_address: Option<String>,
    pub sol_address: Option<String>,
    pub email: Option<String>,
    pub email_verified: bool,
    pub username: String,
    #[serde(rename = "createdAt")]
    pub created_at: String,
    #[serde(rename = "updatedAt")]
    pub updated_at: String,
    pub wallet: LoginWithEmailWalletAttribute,
}
#[tokio::main]
pub async fn fetch_user() -> Result<Option<Response<FetchUser>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    headers.insert("authorization", crate::get_auth().parse().unwrap());
    let url: String = crate::STAGING_REQUEST_URL.to_string() + &"/v1/auth/me".to_string();
    let client = reqwest::Client::new();
    let res = client.get(url).headers(headers).send().await.unwrap();
    let p = res.json::<Response<FetchUser>>().await?;
    Ok(Some(p))
}

#[derive(Debug, Serialize, Deserialize)]
pub struct WalletTokens {
    pub sol: u32,
    pub tokens: Option<Vec<WalletToken>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct WalletToken {
    pub ata: Option<String>,
    pub mint: Option<String>,
    pub amount: Option<u32>,
    pub decimals: Option<u32>,
}
#[tokio::main]
pub async fn get_tokens() -> Result<Option<Response<WalletToken>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    headers.insert("authorization", crate::get_auth().parse().unwrap());
    let url: String = crate::STAGING_REQUEST_URL.to_string() + &"/v1/wallet/tokens".to_string();
    let client = reqwest::Client::new();
    let res = client.get(url).headers(headers).send().await.unwrap();
    let p = res.json::<Response<WalletToken>>().await?;
    println!("{:?}", p.status);
    Ok(Some(p))
}

//Fetches the wallet transactions for a user

#[derive(Debug, Serialize, Deserialize)]
pub struct Transactions {
    pub count: u32,
    pub next_before: Option<String>,
    pub tokens: Option<Vec<Transaction>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Transaction {
    #[serde(rename = "blockTime")]
    pub block_time: Option<String>,
    pub slot: Option<u32>,
    pub meta: Option<Meta>,
    pub transaction: Option<TransactionItem>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct TransactionItem {
    pub message: Message,
    pub signatures: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Message {
    #[serde(rename = "accountKeys")]
    pub account_keys: Option<Vec<AccountKeysEntity>>,
    #[serde(rename = "addressTableLookups")]
    pub address_table_lookups: Option<String>,
    pub instructions: Option<Vec<ParsedInstructionEntity>>,
    #[serde(rename = "recentBlockhash")]
    pub recent_blockhash: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct AccountKeysEntity {
    pub pubkey: Option<String>,
    pub signer: Option<bool>,
    pub writable: Option<bool>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ParsedInstructionEntity {
    pub accounts: Option<String>,
    pub data: Option<String>,
    #[serde(rename = "programId")]
    pub program_id: Option<String>,
    pub parsed: Option<ParsedInstruction>,
    pub program: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ParsedInstruction {
    pub info: Info,
    pub r#type: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Info {
    pub account: Option<String>,
    pub mint: Option<String>,
    #[serde(rename = "rentSysvar")]
    pub rent_sysvar: Option<String>,
    pub source: Option<String>,
    #[serde(rename = "systemProgram")]
    pub system_program: Option<String>,
    #[serde(rename = "tokenProgram")]
    pub token_program: Option<String>,
    pub wallet: Option<String>,
    pub amount: Option<String>,
    pub authority: Option<String>,
    pub destination: Option<String>,
    pub lamports: Option<u32>,
    #[serde(rename = "tokenAmount")]
    pub token_amount: Option<TokenAmount>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct TokenAmount {
    pub amount: Option<String>,
    pub decimals: Option<u32>,
    #[serde(rename = "uiAmount")]
    pub ui_amount: Option<u32>,
    #[serde(rename = "uiAmountString")]
    pub ui_amount_string: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Meta {
    pub err: Option<Err>,
    pub fee: u32,
    #[serde(rename = "innerInstructions")]
    pub inner_instructions: Option<InnerInstructionsEntity>,
    #[serde(rename = "loadedAddresses")]
    pub loaded_addresses: Option<LoadedAddresses>,
    #[serde(rename = "logMessages")]
    pub log_messages: Option<String>,
    #[serde(rename = "postBalances")]
    pub post_balances: Option<u32>,
    #[serde(rename = "postTokenBalances")]
    pub post_token_balances: Option<PostTokenBalancesEntity>,
    #[serde(rename = "preBalances")]
    pub pre_balances: Option<u32>,
    #[serde(rename = "preTokenBalances")]
    pub pre_token_balances: Option<PreTokenBalancesEntityOrPostTokenBalancesEntity>,
    pub status: Option<Status>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Status {
    #[serde(rename = "Ok")]
    pub ok: Option<String>,
    #[serde(rename = "Err")]
    pub err: Option<InstructionError>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct InstructionError {
    #[serde(rename = "InstructionError")]
    pub instruction_error: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct PreTokenBalancesEntityOrPostTokenBalancesEntity {
    #[serde(rename = "accountIndex")]
    pub account_index: u32,
    pub mint: Option<String>,
    pub owner: Option<String>,
    #[serde(rename = "programId")]
    pub program_id: Option<String>,
    #[serde(rename = "uiTokenAmount")]
    pub ui_token_amount: UiTokenAmountOrTokenAmount,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UiTokenAmountOrTokenAmount {
    pub amount: Option<String>,
    pub decimals: Option<u32>,
    #[serde(rename = "uiAmount")]
    pub ui_amount: Option<u32>,
    #[serde(rename = "uiAmountString")]
    pub ui_amount_string: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LoadedAddresses {
    pub readonly: Option<Vec<String>>,
    pub writable: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct PostTokenBalancesEntity {
    #[serde(rename = "accountIndex")]
    pub account_index: Option<u32>,
    pub mint: Option<String>,
    pub owner: Option<String>,
    #[serde(rename = "programId")]
    pub program_id: Option<String>,
    #[serde(rename = "uiTokenAmount")]
    pub ui_token_amount: UiTokenAmount,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UiTokenAmount {
    pub amount: String,
    pub decimals: u32,
    #[serde(rename = "uiAmount")]
    pub ui_amount: Option<u32>,
    #[serde(rename = "uiAmountString")]
    pub ui_amount_string: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct InnerInstructionsEntity {
    pub index: u32,
    pub instructions: Option<Vec<InstructionsEntity>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct InstructionsEntity {
    pub parsed: Option<Parsed>,
    pub program: Option<String>,
    #[serde(rename = "programId")]
    pub program_id: Option<String>,
    pub accounts: Option<Vec<String>>,
    pub data: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Parsed {
    pub info: ParsedInfo,
    pub r#type: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ParsedInfo {
    pub destination: Option<String>,
    pub lamports: Option<u32>,
    pub source: Option<String>,
    pub account: Option<String>,
    pub mint: Option<String>,
    #[serde(rename = "rentSysvar")]
    pub rent_sysvar: Option<String>,
    #[serde(rename = "systemProgram")]
    pub system_program: Option<String>,
    #[serde(rename = "tokenProgram")]
    pub token_program: Option<String>,
    pub wallet: Option<String>,
    #[serde(rename = "newAccount")]
    pub new_account: Option<String>,
    pub owner: Option<String>,
    pub space: Option<u32>,
    pub amount: Option<String>,
    #[serde(rename = "mintAuthority")]
    pub mint_authority: Option<String>,
    #[serde(rename = "authorityType")]
    pub authority_type: Option<String>,
    #[serde(rename = "multisigAuthority")]
    pub multisig_authority: Option<String>,
    #[serde(rename = "newAuthority")]
    pub new_authority: Option<String>,
    pub signers: Option<Vec<String>>,
    pub decimals: Option<u32>,
    pub authority: Option<String>,
    pub delegate: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Err {
    #[serde(rename = "InstructionError")]
    pub instruction_error: Option<String>,
}
#[tokio::main]
pub async fn get_transactions() -> Result<Option<Response<Transactions>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    headers.insert("authorization", crate::get_auth().parse().unwrap());
    let url: String =
        crate::STAGING_REQUEST_URL.to_string() + &"/v1/wallet/transactions".to_string();
    let client = reqwest::Client::new();
    let res = client.get(url).headers(headers).send().await.unwrap();
    let p = res.json::<Response<Transactions>>().await?;
    println!("{:?}", p.status);
    Ok(Some(p))
}

// GET Fetch single NFT details
#[derive(Debug, Serialize, Deserialize)]
pub struct ISolanaNFT {
    pub name: Option<String>,
    #[serde(rename = "sellerFeeBasisPoints")]
    pub seller_fee_basis_points: Option<u32>,
    #[serde(rename = "updateAuthorityAddress")]
    pub update_authority_address: Option<String>,
    pub description: Option<String>,
    pub image: Option<String>,
    #[serde(rename = "externalUrl")]
    pub external_url: Option<String>,
    pub creators: Option<Vec<Creator>>,
    pub owner: Owner,
    pub attributes: Option<Vec<MetadataAttribute>>,
    pub listings: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Creator {
    pub address: Option<String>,
    pub verified: Option<bool>,
    pub share: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Owner {
    pub address: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MetadataAttribute {
    pub trait_type: Option<String>,
    pub value: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct CreateVerifiedCollectionPayload {
    pub name: Option<String>,
    pub symbol: Option<String>,
    #[serde(rename = "metadataUri")]
    pub metadata_uri: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ICreateVerifiedCollectionPayload {
    pub name: Option<String>,
    pub symbol: Option<String>,
    #[serde(rename = "metadataUri")]
    pub metadata_uri: Option<String>,
    pub url: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct CreateVerifiedSubCollectionPayload {
    pub name: Option<String>,
    pub symbol: Option<String>,
    #[serde(rename = "metadataUri")]
    pub metadata_uri: Option<String>,
    #[serde(rename = "parentCollection")]
    pub parent_collection: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ICreateVerifiedSubCollectionPayload {
    pub name: Option<String>,
    pub symbol: Option<String>,
    #[serde(rename = "metadataUri")]
    pub metadata_uri: Option<String>,
    pub url: Option<String>,
    pub collection_mint: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IMintNFTPayload {
    pub collection_mint: Option<String>,
    pub name: Option<String>,
    pub symbol: Option<String>,
    pub url: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MintNFTPayload {
    #[serde(rename = "metadataUri")]
    pub metadata_uri: Option<String>,
    pub collection: Option<String>,
    pub collection_mint: Option<String>,
    pub name: Option<String>,
    pub symbol: Option<String>,
    pub url: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IListNFTPayload {
    pub mint_address: Option<String>,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ListNFTPayload {
    pub mint_address: Option<String>,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IUpdateListingPayload {
    pub mint_address: Option<String>,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct UpdateListingPayload {
    pub mint_address: Option<String>,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IBuyNFTPayload {
    pub mint_address: String,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct BuyNFTPayload {
    pub mint_address: String,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ICancelNFTPayload {
    pub mint_address: String,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct CancelListingPayload {
    pub mint_address: String,
    pub price: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ITransferNFTPayload {
    pub mint_address: String,
    pub to_wallet_address: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct TransferNFTPayload {
    #[serde(rename = "mintAddress")]
    pub mint_address: Option<String>,
    #[serde(rename = "recipientAddress")]
    pub recipient_address: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct IVerifiedCollection {
    pub mint_address: String,
    pub url: String,
    pub update_authority: String,
    pub creator_address: String,
    pub name: String,
    pub symbol: String,
    pub collection: Option<String>,
    pub signature: String,
    pub status: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct QueryNFTsBase {
    pub limit: u32,
    pub offset: u32,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct QueryNFTsByMintAddressesPayload {
    pub limit: Option<u32>,
    pub offset: Option<u32>,
    #[serde(rename = "mintAddresses")]
    pub mint_addresses: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct QueryNFTsByCreatorsPayload {
    pub limit: Option<u32>,
    pub offset: Option<u32>,
    #[serde(rename = "creatorAddresses")]
    pub creator_addresses: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct QueryNFTsByUpdateAuthoritiesPayload {
    pub limit: Option<u32>,
    pub offset: Option<u32>,
    #[serde(rename = "updateAuthorities")]
    pub update_authorities: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct QueryNFTsByOwnersPayload {
    pub limit: Option<u32>,
    pub offset: Option<u32>,
    pub owners: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SolanaNFTExtended {
    pub name: Option<String>,
    #[serde(rename = "sellerFeeBasisPoints")]
    pub seller_fee_basis_points: Option<u32>,
    #[serde(rename = "updateAuthorityAddress")]
    pub update_authority_address: Option<String>,
    pub description: Option<String>,
    pub image: Option<String>,
    #[serde(rename = "externalUrl")]
    pub external_url: Option<String>,
    pub creators: Option<Vec<Creator>>,
    pub owner: Owner,
    pub attributes: Option<Vec<MetadataAttributes>>,
    pub listings: Option<Vec<SolanaNFTListing>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MetadataAttributes {
    pub trait_type: Option<String>,
    pub value: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SolanaNFTListing {
    pub id: Option<u32>,
    #[serde(rename = "tradeState")]
    pub trade_state: Option<String>,
    pub seller: Option<String>,
    pub metadata: Option<String>,
    #[serde(rename = "purchaseId")]
    pub purchase_id: Option<String>,
    pub price: Option<u32>,
    #[serde(rename = "tokenSize")]
    pub token_size: Option<u32>,
    #[serde(rename = "createdAt")]
    pub created_at: Option<String>,
    #[serde(rename = "canceledAt")]
    pub canceled_at: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SolanaNFTAuctionActivitiesPayload {
    #[serde(rename = "mintAddress")]
    pub mint_address: Option<String>,
    #[serde(rename = "auctionActivities")]
    pub auction_activities: Option<Vec<SolanaNFTAuctionActivity>>,
    #[serde(rename = "tokenTransfers")]
    pub token_transfers: Option<Vec<SolanaNFTTransfersEntity>>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SolanaNFTAuctionActivity {
    pub id: Option<u32>,
    #[serde(rename = "mintAddress")]
    pub mint_address: Option<String>,
    #[serde(rename = "txSignature")]
    pub tx_signature: Option<String>,
    pub amount: Option<u32>,
    #[serde(rename = "receiptType")]
    pub receipt_type: Option<String>,
    #[serde(rename = "tokenPrice")]
    pub token_price: Option<String>,
    #[serde(rename = "blockTimeCreated")]
    pub block_time_created: Option<String>,
    #[serde(rename = "blockTimeCanceled")]
    pub block_time_canceled: Option<String>,
    #[serde(rename = "tradeState")]
    pub trade_state: Option<String>,
    #[serde(rename = "auctionHouseAddress")]
    pub auction_house_address: Option<String>,
    #[serde(rename = "sellerAddress")]
    pub seller_address: Option<String>,
    #[serde(rename = "buyerAddress")]
    pub buyer_address: Option<String>,
    pub metadata: Option<String>,
    #[serde(rename = "blockTime")]
    pub block_time: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct SolanaNFTTransfersEntity {
    pub id: Option<u32>,
    #[serde(rename = "mintAddress")]
    pub mint_address: Option<String>,
    #[serde(rename = "txSignature")]
    pub tx_signature: Option<String>,
    #[serde(rename = "fromWalletAddress")]
    pub from_wallet_address: Option<String>,
    #[serde(rename = "toWalletAddress")]
    pub to_wallet_address: Option<String>,
    pub amount: Option<u32>,
    #[serde(rename = "blockTime")]
    pub block_time: Option<String>,
    pub slot: Option<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ISolanaNFTMintResult {
    pub mint_address: Option<String>,
    pub url: Option<String>,
    pub update_authority: Option<String>,
    pub creator_address: Option<String>,
    pub name: Option<String>,
    pub symbol: Option<String>,
    pub collection: Option<String>,
    pub signature: Option<String>,
    pub status: Option<String>,
}
#[tokio::main]
pub async fn get_nft_details(
    sol_addr: &str,
) -> Result<Option<Response<ISolanaNFT>>, Box<dyn Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("Accept", "application/json".parse().unwrap());
    headers.insert("x-api-key", crate::get_apikey().parse().unwrap());
    headers.insert("authorization", crate::get_auth().parse().unwrap());
    let url: String =
        crate::STAGING_REQUEST_URL.to_string() + &"/v1/solana/nft/".to_string() + sol_addr;
    let client = reqwest::Client::new();
    let res = client.get(url).headers(headers).send().await.unwrap();
    let p = res.json::<Response<ISolanaNFT>>().await?;
    println!("{:?}", p.status);
    Ok(Some(p))
}