1pub use near_openapi_types as types;
401#[allow(unused_imports)]
402use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt};
403#[allow(unused_imports)]
404pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue};
405#[derive(Clone, Debug)]
406#[doc = "Client for NEAR Protocol JSON RPC API\n\nVersion: 1.1.0"]
407pub struct Client {
408 pub(crate) baseurl: String,
409 pub(crate) client: reqwest::Client,
410}
411impl Client {
412 #[doc = r" Create a new client."]
413 #[doc = r""]
414 #[doc = r" `baseurl` is the base URL provided to the internal"]
415 #[doc = r" `reqwest::Client`, and should include a scheme and hostname,"]
416 #[doc = r" as well as port and a path stem if applicable."]
417 pub fn new(baseurl: &str) -> Self {
418 #[cfg(not(target_arch = "wasm32"))]
419 let client = {
420 let dur = std::time::Duration::from_secs(15);
421 reqwest::ClientBuilder::new()
422 .connect_timeout(dur)
423 .timeout(dur)
424 };
425 #[cfg(target_arch = "wasm32")]
426 let client = reqwest::ClientBuilder::new();
427 Self::new_with_client(baseurl, client.build().unwrap())
428 }
429 #[doc = r" Construct a new client with an existing `reqwest::Client`,"]
430 #[doc = r" allowing more control over its configuration."]
431 #[doc = r""]
432 #[doc = r" `baseurl` is the base URL provided to the internal"]
433 #[doc = r" `reqwest::Client`, and should include a scheme and hostname,"]
434 #[doc = r" as well as port and a path stem if applicable."]
435 pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self {
436 Self {
437 baseurl: baseurl.to_string(),
438 client,
439 }
440 }
441}
442impl ClientInfo<()> for Client {
443 fn api_version() -> &'static str {
444 "1.1.0"
445 }
446 fn baseurl(&self) -> &str {
447 self.baseurl.as_str()
448 }
449 fn client(&self) -> &reqwest::Client {
450 &self.client
451 }
452 fn inner(&self) -> &() {
453 &()
454 }
455}
456impl ClientHooks<()> for &Client {}
457#[allow(clippy::all)]
458#[allow(elided_named_lifetimes)]
459impl Client {
460 #[doc = "Returns changes in block for given block height or hash over all transactions for the current type. Includes changes like account_touched, access_key_touched, data_touched, contract_code_touched\n\nSends a `POST` request to `/EXPERIMENTAL_changes`\n\n"]
461 pub async fn experimental_changes<'a>(
462 &'a self,
463 body: &'a types::JsonRpcRequestForExperimentalChanges,
464 ) -> Result<
465 ResponseValue<types::JsonRpcResponseForRpcStateChangesInBlockResponseAndRpcError>,
466 Error<()>,
467 > {
468 let url = format!("{}/", self.baseurl,);
469 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
470 header_map.append(
471 ::reqwest::header::HeaderName::from_static("api-version"),
472 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
473 );
474 #[allow(unused_mut)]
475 let mut request = self
476 .client
477 .post(url)
478 .header(
479 ::reqwest::header::ACCEPT,
480 ::reqwest::header::HeaderValue::from_static("application/json"),
481 )
482 .json(&body)
483 .headers(header_map)
484 .build()?;
485 let info = OperationInfo {
486 operation_id: "experimental_changes",
487 };
488 self.pre(&mut request, &info).await?;
489 let result = self.exec(request, &info).await;
490 self.post(&result, &info).await?;
491 let response = result?;
492 match response.status().as_u16() {
493 200u16 => ResponseValue::from_response(response).await,
494 _ => Err(Error::UnexpectedResponse(response)),
495 }
496 }
497 #[doc = "Returns changes in block for given block height or hash over all transactions for all the types. Includes changes like account_touched, access_key_touched, data_touched, contract_code_touched\n\nSends a `POST` request to `/EXPERIMENTAL_changes_in_block`\n\n"]
498 pub async fn experimental_changes_in_block<'a>(
499 &'a self,
500 body: &'a types::JsonRpcRequestForExperimentalChangesInBlock,
501 ) -> Result<
502 ResponseValue<types::JsonRpcResponseForRpcStateChangesInBlockByTypeResponseAndRpcError>,
503 Error<()>,
504 > {
505 let url = format!("{}/", self.baseurl,);
506 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
507 header_map.append(
508 ::reqwest::header::HeaderName::from_static("api-version"),
509 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
510 );
511 #[allow(unused_mut)]
512 let mut request = self
513 .client
514 .post(url)
515 .header(
516 ::reqwest::header::ACCEPT,
517 ::reqwest::header::HeaderValue::from_static("application/json"),
518 )
519 .json(&body)
520 .headers(header_map)
521 .build()?;
522 let info = OperationInfo {
523 operation_id: "experimental_changes_in_block",
524 };
525 self.pre(&mut request, &info).await?;
526 let result = self.exec(request, &info).await;
527 self.post(&result, &info).await?;
528 let response = result?;
529 match response.status().as_u16() {
530 200u16 => ResponseValue::from_response(response).await,
531 _ => Err(Error::UnexpectedResponse(response)),
532 }
533 }
534 #[doc = "Queries the congestion level of a shard. More info about congestion [here](https://near.github.io/nearcore/architecture/how/receipt-congestion.html?highlight=congestion#receipt-congestion)\n\nSends a `POST` request to `/EXPERIMENTAL_congestion_level`\n\n"]
535 pub async fn experimental_congestion_level<'a>(
536 &'a self,
537 body: &'a types::JsonRpcRequestForExperimentalCongestionLevel,
538 ) -> Result<
539 ResponseValue<types::JsonRpcResponseForRpcCongestionLevelResponseAndRpcError>,
540 Error<()>,
541 > {
542 let url = format!("{}/", self.baseurl,);
543 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
544 header_map.append(
545 ::reqwest::header::HeaderName::from_static("api-version"),
546 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
547 );
548 #[allow(unused_mut)]
549 let mut request = self
550 .client
551 .post(url)
552 .header(
553 ::reqwest::header::ACCEPT,
554 ::reqwest::header::HeaderValue::from_static("application/json"),
555 )
556 .json(&body)
557 .headers(header_map)
558 .build()?;
559 let info = OperationInfo {
560 operation_id: "experimental_congestion_level",
561 };
562 self.pre(&mut request, &info).await?;
563 let result = self.exec(request, &info).await;
564 self.post(&result, &info).await?;
565 let response = result?;
566 match response.status().as_u16() {
567 200u16 => ResponseValue::from_response(response).await,
568 _ => Err(Error::UnexpectedResponse(response)),
569 }
570 }
571 #[doc = "Get initial state and parameters for the genesis block\n\nSends a `POST` request to `/EXPERIMENTAL_genesis_config`\n\n"]
572 pub async fn experimental_genesis_config<'a>(
573 &'a self,
574 body: &'a types::JsonRpcRequestForExperimentalGenesisConfig,
575 ) -> Result<ResponseValue<types::JsonRpcResponseForGenesisConfigAndRpcError>, Error<()>> {
576 let url = format!("{}/", self.baseurl,);
577 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
578 header_map.append(
579 ::reqwest::header::HeaderName::from_static("api-version"),
580 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
581 );
582 #[allow(unused_mut)]
583 let mut request = self
584 .client
585 .post(url)
586 .header(
587 ::reqwest::header::ACCEPT,
588 ::reqwest::header::HeaderValue::from_static("application/json"),
589 )
590 .json(&body)
591 .headers(header_map)
592 .build()?;
593 let info = OperationInfo {
594 operation_id: "experimental_genesis_config",
595 };
596 self.pre(&mut request, &info).await?;
597 let result = self.exec(request, &info).await;
598 self.post(&result, &info).await?;
599 let response = result?;
600 match response.status().as_u16() {
601 200u16 => ResponseValue::from_response(response).await,
602 _ => Err(Error::UnexpectedResponse(response)),
603 }
604 }
605 #[doc = "Returns the proofs for a transaction execution.\n\nSends a `POST` request to `/EXPERIMENTAL_light_client_block_proof`\n\n"]
606 pub async fn experimental_light_client_block_proof<'a>(
607 &'a self,
608 body: &'a types::JsonRpcRequestForExperimentalLightClientBlockProof,
609 ) -> Result<
610 ResponseValue<types::JsonRpcResponseForRpcLightClientBlockProofResponseAndRpcError>,
611 Error<()>,
612 > {
613 let url = format!("{}/", self.baseurl,);
614 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
615 header_map.append(
616 ::reqwest::header::HeaderName::from_static("api-version"),
617 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
618 );
619 #[allow(unused_mut)]
620 let mut request = self
621 .client
622 .post(url)
623 .header(
624 ::reqwest::header::ACCEPT,
625 ::reqwest::header::HeaderValue::from_static("application/json"),
626 )
627 .json(&body)
628 .headers(header_map)
629 .build()?;
630 let info = OperationInfo {
631 operation_id: "experimental_light_client_block_proof",
632 };
633 self.pre(&mut request, &info).await?;
634 let result = self.exec(request, &info).await;
635 self.post(&result, &info).await?;
636 let response = result?;
637 match response.status().as_u16() {
638 200u16 => ResponseValue::from_response(response).await,
639 _ => Err(Error::UnexpectedResponse(response)),
640 }
641 }
642 #[doc = "Returns the proofs for a transaction execution.\n\nSends a `POST` request to `/EXPERIMENTAL_light_client_proof`\n\n"]
643 pub async fn experimental_light_client_proof<'a>(
644 &'a self,
645 body: &'a types::JsonRpcRequestForExperimentalLightClientProof,
646 ) -> Result<
647 ResponseValue<types::JsonRpcResponseForRpcLightClientExecutionProofResponseAndRpcError>,
648 Error<()>,
649 > {
650 let url = format!("{}/", self.baseurl,);
651 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
652 header_map.append(
653 ::reqwest::header::HeaderName::from_static("api-version"),
654 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
655 );
656 #[allow(unused_mut)]
657 let mut request = self
658 .client
659 .post(url)
660 .header(
661 ::reqwest::header::ACCEPT,
662 ::reqwest::header::HeaderValue::from_static("application/json"),
663 )
664 .json(&body)
665 .headers(header_map)
666 .build()?;
667 let info = OperationInfo {
668 operation_id: "experimental_light_client_proof",
669 };
670 self.pre(&mut request, &info).await?;
671 let result = self.exec(request, &info).await;
672 self.post(&result, &info).await?;
673 let response = result?;
674 match response.status().as_u16() {
675 200u16 => ResponseValue::from_response(response).await,
676 _ => Err(Error::UnexpectedResponse(response)),
677 }
678 }
679 #[doc = "Returns the future windows for maintenance in current epoch for the specified account. In the maintenance windows, the node will not be block producer or chunk producer\n\nSends a `POST` request to `/EXPERIMENTAL_maintenance_windows`\n\n"]
680 pub async fn experimental_maintenance_windows<'a>(
681 &'a self,
682 body: &'a types::JsonRpcRequestForExperimentalMaintenanceWindows,
683 ) -> Result<ResponseValue<types::JsonRpcResponseForArrayOfRangeOfUint64AndRpcError>, Error<()>>
684 {
685 let url = format!("{}/", self.baseurl,);
686 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
687 header_map.append(
688 ::reqwest::header::HeaderName::from_static("api-version"),
689 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
690 );
691 #[allow(unused_mut)]
692 let mut request = self
693 .client
694 .post(url)
695 .header(
696 ::reqwest::header::ACCEPT,
697 ::reqwest::header::HeaderValue::from_static("application/json"),
698 )
699 .json(&body)
700 .headers(header_map)
701 .build()?;
702 let info = OperationInfo {
703 operation_id: "experimental_maintenance_windows",
704 };
705 self.pre(&mut request, &info).await?;
706 let result = self.exec(request, &info).await;
707 self.post(&result, &info).await?;
708 let response = result?;
709 match response.status().as_u16() {
710 200u16 => ResponseValue::from_response(response).await,
711 _ => Err(Error::UnexpectedResponse(response)),
712 }
713 }
714 #[doc = "A configuration that defines the protocol-level parameters such as gas/storage costs, limits, feature flags, other settings\n\nSends a `POST` request to `/EXPERIMENTAL_protocol_config`\n\n"]
715 pub async fn experimental_protocol_config<'a>(
716 &'a self,
717 body: &'a types::JsonRpcRequestForExperimentalProtocolConfig,
718 ) -> Result<
719 ResponseValue<types::JsonRpcResponseForRpcProtocolConfigResponseAndRpcError>,
720 Error<()>,
721 > {
722 let url = format!("{}/", self.baseurl,);
723 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
724 header_map.append(
725 ::reqwest::header::HeaderName::from_static("api-version"),
726 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
727 );
728 #[allow(unused_mut)]
729 let mut request = self
730 .client
731 .post(url)
732 .header(
733 ::reqwest::header::ACCEPT,
734 ::reqwest::header::HeaderValue::from_static("application/json"),
735 )
736 .json(&body)
737 .headers(header_map)
738 .build()?;
739 let info = OperationInfo {
740 operation_id: "experimental_protocol_config",
741 };
742 self.pre(&mut request, &info).await?;
743 let result = self.exec(request, &info).await;
744 self.post(&result, &info).await?;
745 let response = result?;
746 match response.status().as_u16() {
747 200u16 => ResponseValue::from_response(response).await,
748 _ => Err(Error::UnexpectedResponse(response)),
749 }
750 }
751 #[doc = "Fetches a receipt by its ID (as is, without a status or execution outcome)\n\nSends a `POST` request to `/EXPERIMENTAL_receipt`\n\n"]
752 pub async fn experimental_receipt<'a>(
753 &'a self,
754 body: &'a types::JsonRpcRequestForExperimentalReceipt,
755 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcReceiptResponseAndRpcError>, Error<()>>
756 {
757 let url = format!("{}/", self.baseurl,);
758 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
759 header_map.append(
760 ::reqwest::header::HeaderName::from_static("api-version"),
761 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
762 );
763 #[allow(unused_mut)]
764 let mut request = self
765 .client
766 .post(url)
767 .header(
768 ::reqwest::header::ACCEPT,
769 ::reqwest::header::HeaderValue::from_static("application/json"),
770 )
771 .json(&body)
772 .headers(header_map)
773 .build()?;
774 let info = OperationInfo {
775 operation_id: "experimental_receipt",
776 };
777 self.pre(&mut request, &info).await?;
778 let result = self.exec(request, &info).await;
779 self.post(&result, &info).await?;
780 let response = result?;
781 match response.status().as_u16() {
782 200u16 => ResponseValue::from_response(response).await,
783 _ => Err(Error::UnexpectedResponse(response)),
784 }
785 }
786 #[doc = "Contains the split storage information. More info on split storage [here](https://near-nodes.io/archival/split-storage-archival)\n\nSends a `POST` request to `/EXPERIMENTAL_split_storage_info`\n\n"]
787 pub async fn experimental_split_storage_info<'a>(
788 &'a self,
789 body: &'a types::JsonRpcRequestForExperimentalSplitStorageInfo,
790 ) -> Result<
791 ResponseValue<types::JsonRpcResponseForRpcSplitStorageInfoResponseAndRpcError>,
792 Error<()>,
793 > {
794 let url = format!("{}/", self.baseurl,);
795 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
796 header_map.append(
797 ::reqwest::header::HeaderName::from_static("api-version"),
798 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
799 );
800 #[allow(unused_mut)]
801 let mut request = self
802 .client
803 .post(url)
804 .header(
805 ::reqwest::header::ACCEPT,
806 ::reqwest::header::HeaderValue::from_static("application/json"),
807 )
808 .json(&body)
809 .headers(header_map)
810 .build()?;
811 let info = OperationInfo {
812 operation_id: "experimental_split_storage_info",
813 };
814 self.pre(&mut request, &info).await?;
815 let result = self.exec(request, &info).await;
816 self.post(&result, &info).await?;
817 let response = result?;
818 match response.status().as_u16() {
819 200u16 => ResponseValue::from_response(response).await,
820 _ => Err(Error::UnexpectedResponse(response)),
821 }
822 }
823 #[doc = "Queries status of a transaction by hash, returning the final transaction result and details of all receipts.\n\nSends a `POST` request to `/EXPERIMENTAL_tx_status`\n\n"]
824 pub async fn experimental_tx_status<'a>(
825 &'a self,
826 body: &'a types::JsonRpcRequestForExperimentalTxStatus,
827 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcTransactionResponseAndRpcError>, Error<()>>
828 {
829 let url = format!("{}/", self.baseurl,);
830 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
831 header_map.append(
832 ::reqwest::header::HeaderName::from_static("api-version"),
833 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
834 );
835 #[allow(unused_mut)]
836 let mut request = self
837 .client
838 .post(url)
839 .header(
840 ::reqwest::header::ACCEPT,
841 ::reqwest::header::HeaderValue::from_static("application/json"),
842 )
843 .json(&body)
844 .headers(header_map)
845 .build()?;
846 let info = OperationInfo {
847 operation_id: "experimental_tx_status",
848 };
849 self.pre(&mut request, &info).await?;
850 let result = self.exec(request, &info).await;
851 self.post(&result, &info).await?;
852 let response = result?;
853 match response.status().as_u16() {
854 200u16 => ResponseValue::from_response(response).await,
855 _ => Err(Error::UnexpectedResponse(response)),
856 }
857 }
858 #[doc = "Returns the current epoch validators ordered in the block producer order with repetition. This endpoint is solely used for bridge currently and is not intended for other external use cases.\n\nSends a `POST` request to `/EXPERIMENTAL_validators_ordered`\n\n"]
859 pub async fn experimental_validators_ordered<'a>(
860 &'a self,
861 body: &'a types::JsonRpcRequestForExperimentalValidatorsOrdered,
862 ) -> Result<
863 ResponseValue<types::JsonRpcResponseForArrayOfValidatorStakeViewAndRpcError>,
864 Error<()>,
865 > {
866 let url = format!("{}/", self.baseurl,);
867 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
868 header_map.append(
869 ::reqwest::header::HeaderName::from_static("api-version"),
870 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
871 );
872 #[allow(unused_mut)]
873 let mut request = self
874 .client
875 .post(url)
876 .header(
877 ::reqwest::header::ACCEPT,
878 ::reqwest::header::HeaderValue::from_static("application/json"),
879 )
880 .json(&body)
881 .headers(header_map)
882 .build()?;
883 let info = OperationInfo {
884 operation_id: "experimental_validators_ordered",
885 };
886 self.pre(&mut request, &info).await?;
887 let result = self.exec(request, &info).await;
888 self.post(&result, &info).await?;
889 let response = result?;
890 match response.status().as_u16() {
891 200u16 => ResponseValue::from_response(response).await,
892 _ => Err(Error::UnexpectedResponse(response)),
893 }
894 }
895 #[doc = "Returns block details for given height or hash\n\nSends a `POST` request to `/block`\n\n"]
896 pub async fn block<'a>(
897 &'a self,
898 body: &'a types::JsonRpcRequestForBlock,
899 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcBlockResponseAndRpcError>, Error<()>>
900 {
901 let url = format!("{}/", self.baseurl,);
902 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
903 header_map.append(
904 ::reqwest::header::HeaderName::from_static("api-version"),
905 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
906 );
907 #[allow(unused_mut)]
908 let mut request = self
909 .client
910 .post(url)
911 .header(
912 ::reqwest::header::ACCEPT,
913 ::reqwest::header::HeaderValue::from_static("application/json"),
914 )
915 .json(&body)
916 .headers(header_map)
917 .build()?;
918 let info = OperationInfo {
919 operation_id: "block",
920 };
921 self.pre(&mut request, &info).await?;
922 let result = self.exec(request, &info).await;
923 self.post(&result, &info).await?;
924 let response = result?;
925 match response.status().as_u16() {
926 200u16 => ResponseValue::from_response(response).await,
927 _ => Err(Error::UnexpectedResponse(response)),
928 }
929 }
930 #[doc = "[Deprecated] Sends a transaction and immediately returns transaction hash. Consider using send_tx instead\n\nSends a `POST` request to `/broadcast_tx_async`\n\n"]
931 pub async fn broadcast_tx_async<'a>(
932 &'a self,
933 body: &'a types::JsonRpcRequestForBroadcastTxAsync,
934 ) -> Result<ResponseValue<types::JsonRpcResponseForCryptoHashAndRpcError>, Error<()>> {
935 let url = format!("{}/", self.baseurl,);
936 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
937 header_map.append(
938 ::reqwest::header::HeaderName::from_static("api-version"),
939 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
940 );
941 #[allow(unused_mut)]
942 let mut request = self
943 .client
944 .post(url)
945 .header(
946 ::reqwest::header::ACCEPT,
947 ::reqwest::header::HeaderValue::from_static("application/json"),
948 )
949 .json(&body)
950 .headers(header_map)
951 .build()?;
952 let info = OperationInfo {
953 operation_id: "broadcast_tx_async",
954 };
955 self.pre(&mut request, &info).await?;
956 let result = self.exec(request, &info).await;
957 self.post(&result, &info).await?;
958 let response = result?;
959 match response.status().as_u16() {
960 200u16 => ResponseValue::from_response(response).await,
961 _ => Err(Error::UnexpectedResponse(response)),
962 }
963 }
964 #[doc = "[Deprecated] Sends a transaction and waits until transaction is fully complete. (Has a 10 second timeout). Consider using send_tx instead\n\nSends a `POST` request to `/broadcast_tx_commit`\n\n"]
965 pub async fn broadcast_tx_commit<'a>(
966 &'a self,
967 body: &'a types::JsonRpcRequestForBroadcastTxCommit,
968 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcTransactionResponseAndRpcError>, Error<()>>
969 {
970 let url = format!("{}/", self.baseurl,);
971 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
972 header_map.append(
973 ::reqwest::header::HeaderName::from_static("api-version"),
974 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
975 );
976 #[allow(unused_mut)]
977 let mut request = self
978 .client
979 .post(url)
980 .header(
981 ::reqwest::header::ACCEPT,
982 ::reqwest::header::HeaderValue::from_static("application/json"),
983 )
984 .json(&body)
985 .headers(header_map)
986 .build()?;
987 let info = OperationInfo {
988 operation_id: "broadcast_tx_commit",
989 };
990 self.pre(&mut request, &info).await?;
991 let result = self.exec(request, &info).await;
992 self.post(&result, &info).await?;
993 let response = result?;
994 match response.status().as_u16() {
995 200u16 => ResponseValue::from_response(response).await,
996 _ => Err(Error::UnexpectedResponse(response)),
997 }
998 }
999 #[doc = "Returns changes in block for given block height or hash over all transactions for the current type. Includes changes like account_touched, access_key_touched, data_touched, contract_code_touched\n\nSends a `POST` request to `/changes`\n\n"]
1000 pub async fn changes<'a>(
1001 &'a self,
1002 body: &'a types::JsonRpcRequestForChanges,
1003 ) -> Result<
1004 ResponseValue<types::JsonRpcResponseForRpcStateChangesInBlockResponseAndRpcError>,
1005 Error<()>,
1006 > {
1007 let url = format!("{}/", self.baseurl,);
1008 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1009 header_map.append(
1010 ::reqwest::header::HeaderName::from_static("api-version"),
1011 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1012 );
1013 #[allow(unused_mut)]
1014 let mut request = self
1015 .client
1016 .post(url)
1017 .header(
1018 ::reqwest::header::ACCEPT,
1019 ::reqwest::header::HeaderValue::from_static("application/json"),
1020 )
1021 .json(&body)
1022 .headers(header_map)
1023 .build()?;
1024 let info = OperationInfo {
1025 operation_id: "changes",
1026 };
1027 self.pre(&mut request, &info).await?;
1028 let result = self.exec(request, &info).await;
1029 self.post(&result, &info).await?;
1030 let response = result?;
1031 match response.status().as_u16() {
1032 200u16 => ResponseValue::from_response(response).await,
1033 _ => Err(Error::UnexpectedResponse(response)),
1034 }
1035 }
1036 #[doc = "Returns details of a specific chunk. You can run a block details query to get a valid chunk hash.\n\nSends a `POST` request to `/chunk`\n\n"]
1037 pub async fn chunk<'a>(
1038 &'a self,
1039 body: &'a types::JsonRpcRequestForChunk,
1040 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcChunkResponseAndRpcError>, Error<()>>
1041 {
1042 let url = format!("{}/", self.baseurl,);
1043 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1044 header_map.append(
1045 ::reqwest::header::HeaderName::from_static("api-version"),
1046 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1047 );
1048 #[allow(unused_mut)]
1049 let mut request = self
1050 .client
1051 .post(url)
1052 .header(
1053 ::reqwest::header::ACCEPT,
1054 ::reqwest::header::HeaderValue::from_static("application/json"),
1055 )
1056 .json(&body)
1057 .headers(header_map)
1058 .build()?;
1059 let info = OperationInfo {
1060 operation_id: "chunk",
1061 };
1062 self.pre(&mut request, &info).await?;
1063 let result = self.exec(request, &info).await;
1064 self.post(&result, &info).await?;
1065 let response = result?;
1066 match response.status().as_u16() {
1067 200u16 => ResponseValue::from_response(response).await,
1068 _ => Err(Error::UnexpectedResponse(response)),
1069 }
1070 }
1071 #[doc = "Queries client node configuration\n\nSends a `POST` request to `/client_config`\n\n"]
1072 pub async fn client_config<'a>(
1073 &'a self,
1074 body: &'a types::JsonRpcRequestForClientConfig,
1075 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcClientConfigResponseAndRpcError>, Error<()>>
1076 {
1077 let url = format!("{}/", self.baseurl,);
1078 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1079 header_map.append(
1080 ::reqwest::header::HeaderName::from_static("api-version"),
1081 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1082 );
1083 #[allow(unused_mut)]
1084 let mut request = self
1085 .client
1086 .post(url)
1087 .header(
1088 ::reqwest::header::ACCEPT,
1089 ::reqwest::header::HeaderValue::from_static("application/json"),
1090 )
1091 .json(&body)
1092 .headers(header_map)
1093 .build()?;
1094 let info = OperationInfo {
1095 operation_id: "client_config",
1096 };
1097 self.pre(&mut request, &info).await?;
1098 let result = self.exec(request, &info).await;
1099 self.post(&result, &info).await?;
1100 let response = result?;
1101 match response.status().as_u16() {
1102 200u16 => ResponseValue::from_response(response).await,
1103 _ => Err(Error::UnexpectedResponse(response)),
1104 }
1105 }
1106 #[doc = "Returns gas price for a specific block_height or block_hash. Using [null] will return the most recent block's gas price.\n\nSends a `POST` request to `/gas_price`\n\n"]
1107 pub async fn gas_price<'a>(
1108 &'a self,
1109 body: &'a types::JsonRpcRequestForGasPrice,
1110 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcGasPriceResponseAndRpcError>, Error<()>>
1111 {
1112 let url = format!("{}/", self.baseurl,);
1113 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1114 header_map.append(
1115 ::reqwest::header::HeaderName::from_static("api-version"),
1116 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1117 );
1118 #[allow(unused_mut)]
1119 let mut request = self
1120 .client
1121 .post(url)
1122 .header(
1123 ::reqwest::header::ACCEPT,
1124 ::reqwest::header::HeaderValue::from_static("application/json"),
1125 )
1126 .json(&body)
1127 .headers(header_map)
1128 .build()?;
1129 let info = OperationInfo {
1130 operation_id: "gas_price",
1131 };
1132 self.pre(&mut request, &info).await?;
1133 let result = self.exec(request, &info).await;
1134 self.post(&result, &info).await?;
1135 let response = result?;
1136 match response.status().as_u16() {
1137 200u16 => ResponseValue::from_response(response).await,
1138 _ => Err(Error::UnexpectedResponse(response)),
1139 }
1140 }
1141 #[doc = "Returns the current health stauts of the RPC node the client connects to.\n\nSends a `POST` request to `/health`\n\n"]
1142 pub async fn health<'a>(
1143 &'a self,
1144 body: &'a types::JsonRpcRequestForHealth,
1145 ) -> Result<
1146 ResponseValue<types::JsonRpcResponseForNullableRpcHealthResponseAndRpcError>,
1147 Error<()>,
1148 > {
1149 let url = format!("{}/", self.baseurl,);
1150 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1151 header_map.append(
1152 ::reqwest::header::HeaderName::from_static("api-version"),
1153 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1154 );
1155 #[allow(unused_mut)]
1156 let mut request = self
1157 .client
1158 .post(url)
1159 .header(
1160 ::reqwest::header::ACCEPT,
1161 ::reqwest::header::HeaderValue::from_static("application/json"),
1162 )
1163 .json(&body)
1164 .headers(header_map)
1165 .build()?;
1166 let info = OperationInfo {
1167 operation_id: "health",
1168 };
1169 self.pre(&mut request, &info).await?;
1170 let result = self.exec(request, &info).await;
1171 self.post(&result, &info).await?;
1172 let response = result?;
1173 match response.status().as_u16() {
1174 200u16 => ResponseValue::from_response(response).await,
1175 _ => Err(Error::UnexpectedResponse(response)),
1176 }
1177 }
1178 #[doc = "Returns the proofs for a transaction execution.\n\nSends a `POST` request to `/light_client_proof`\n\n"]
1179 pub async fn light_client_proof<'a>(
1180 &'a self,
1181 body: &'a types::JsonRpcRequestForLightClientProof,
1182 ) -> Result<
1183 ResponseValue<types::JsonRpcResponseForRpcLightClientExecutionProofResponseAndRpcError>,
1184 Error<()>,
1185 > {
1186 let url = format!("{}/", self.baseurl,);
1187 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1188 header_map.append(
1189 ::reqwest::header::HeaderName::from_static("api-version"),
1190 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1191 );
1192 #[allow(unused_mut)]
1193 let mut request = self
1194 .client
1195 .post(url)
1196 .header(
1197 ::reqwest::header::ACCEPT,
1198 ::reqwest::header::HeaderValue::from_static("application/json"),
1199 )
1200 .json(&body)
1201 .headers(header_map)
1202 .build()?;
1203 let info = OperationInfo {
1204 operation_id: "light_client_proof",
1205 };
1206 self.pre(&mut request, &info).await?;
1207 let result = self.exec(request, &info).await;
1208 self.post(&result, &info).await?;
1209 let response = result?;
1210 match response.status().as_u16() {
1211 200u16 => ResponseValue::from_response(response).await,
1212 _ => Err(Error::UnexpectedResponse(response)),
1213 }
1214 }
1215 #[doc = "Queries the current state of node network connections. This includes information about active peers, transmitted data, known producers, etc.\n\nSends a `POST` request to `/network_info`\n\n"]
1216 pub async fn network_info<'a>(
1217 &'a self,
1218 body: &'a types::JsonRpcRequestForNetworkInfo,
1219 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcNetworkInfoResponseAndRpcError>, Error<()>>
1220 {
1221 let url = format!("{}/", self.baseurl,);
1222 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1223 header_map.append(
1224 ::reqwest::header::HeaderName::from_static("api-version"),
1225 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1226 );
1227 #[allow(unused_mut)]
1228 let mut request = self
1229 .client
1230 .post(url)
1231 .header(
1232 ::reqwest::header::ACCEPT,
1233 ::reqwest::header::HeaderValue::from_static("application/json"),
1234 )
1235 .json(&body)
1236 .headers(header_map)
1237 .build()?;
1238 let info = OperationInfo {
1239 operation_id: "network_info",
1240 };
1241 self.pre(&mut request, &info).await?;
1242 let result = self.exec(request, &info).await;
1243 self.post(&result, &info).await?;
1244 let response = result?;
1245 match response.status().as_u16() {
1246 200u16 => ResponseValue::from_response(response).await,
1247 _ => Err(Error::UnexpectedResponse(response)),
1248 }
1249 }
1250 #[doc = "Returns the next light client block.\n\nSends a `POST` request to `/next_light_client_block`\n\n"]
1251 pub async fn next_light_client_block<'a>(
1252 &'a self,
1253 body: &'a types::JsonRpcRequestForNextLightClientBlock,
1254 ) -> Result<
1255 ResponseValue<types::JsonRpcResponseForRpcLightClientNextBlockResponseAndRpcError>,
1256 Error<()>,
1257 > {
1258 let url = format!("{}/", self.baseurl,);
1259 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1260 header_map.append(
1261 ::reqwest::header::HeaderName::from_static("api-version"),
1262 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1263 );
1264 #[allow(unused_mut)]
1265 let mut request = self
1266 .client
1267 .post(url)
1268 .header(
1269 ::reqwest::header::ACCEPT,
1270 ::reqwest::header::HeaderValue::from_static("application/json"),
1271 )
1272 .json(&body)
1273 .headers(header_map)
1274 .build()?;
1275 let info = OperationInfo {
1276 operation_id: "next_light_client_block",
1277 };
1278 self.pre(&mut request, &info).await?;
1279 let result = self.exec(request, &info).await;
1280 self.post(&result, &info).await?;
1281 let response = result?;
1282 match response.status().as_u16() {
1283 200u16 => ResponseValue::from_response(response).await,
1284 _ => Err(Error::UnexpectedResponse(response)),
1285 }
1286 }
1287 #[doc = "This module allows you to make generic requests to the network.\n\nThe `RpcQueryRequest` struct takes in a [`BlockReference`](https://docs.rs/near-primitives/0.12.0/near_primitives/types/enum.BlockReference.html) and a [`QueryRequest`](https://docs.rs/near-primitives/0.12.0/near_primitives/views/enum.QueryRequest.html).\n\nThe `BlockReference` enum allows you to specify a block by `Finality`, `BlockId` or `SyncCheckpoint`.\n\nThe `QueryRequest` enum provides multiple variaints for performing the following actions:\n - View an account's details\n - View a contract's code\n - View the state of an account\n - View the `AccessKey` of an account\n - View the `AccessKeyList` of an account\n - Call a function in a contract deployed on the network.\n\nSends a `POST` request to `/query`\n\n"]
1288 pub async fn query<'a>(
1289 &'a self,
1290 body: &'a types::JsonRpcRequestForQuery,
1291 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcQueryResponseAndRpcError>, Error<()>>
1292 {
1293 let url = format!("{}/", self.baseurl,);
1294 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1295 header_map.append(
1296 ::reqwest::header::HeaderName::from_static("api-version"),
1297 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1298 );
1299 #[allow(unused_mut)]
1300 let mut request = self
1301 .client
1302 .post(url)
1303 .header(
1304 ::reqwest::header::ACCEPT,
1305 ::reqwest::header::HeaderValue::from_static("application/json"),
1306 )
1307 .json(&body)
1308 .headers(header_map)
1309 .build()?;
1310 let info = OperationInfo {
1311 operation_id: "query",
1312 };
1313 self.pre(&mut request, &info).await?;
1314 let result = self.exec(request, &info).await;
1315 self.post(&result, &info).await?;
1316 let response = result?;
1317 match response.status().as_u16() {
1318 200u16 => ResponseValue::from_response(response).await,
1319 _ => Err(Error::UnexpectedResponse(response)),
1320 }
1321 }
1322 #[doc = "Sends transaction. Returns the guaranteed execution status and the results the blockchain can provide at the moment.\n\nSends a `POST` request to `/send_tx`\n\n"]
1323 pub async fn send_tx<'a>(
1324 &'a self,
1325 body: &'a types::JsonRpcRequestForSendTx,
1326 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcTransactionResponseAndRpcError>, Error<()>>
1327 {
1328 let url = format!("{}/", self.baseurl,);
1329 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1330 header_map.append(
1331 ::reqwest::header::HeaderName::from_static("api-version"),
1332 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1333 );
1334 #[allow(unused_mut)]
1335 let mut request = self
1336 .client
1337 .post(url)
1338 .header(
1339 ::reqwest::header::ACCEPT,
1340 ::reqwest::header::HeaderValue::from_static("application/json"),
1341 )
1342 .json(&body)
1343 .headers(header_map)
1344 .build()?;
1345 let info = OperationInfo {
1346 operation_id: "send_tx",
1347 };
1348 self.pre(&mut request, &info).await?;
1349 let result = self.exec(request, &info).await;
1350 self.post(&result, &info).await?;
1351 let response = result?;
1352 match response.status().as_u16() {
1353 200u16 => ResponseValue::from_response(response).await,
1354 _ => Err(Error::UnexpectedResponse(response)),
1355 }
1356 }
1357 #[doc = "Requests the status of the connected RPC node. This includes information about sync status, nearcore node version, protocol version, the current set of validators, etc.\n\nSends a `POST` request to `/status`\n\n"]
1358 pub async fn status<'a>(
1359 &'a self,
1360 body: &'a types::JsonRpcRequestForStatus,
1361 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcStatusResponseAndRpcError>, Error<()>>
1362 {
1363 let url = format!("{}/", self.baseurl,);
1364 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1365 header_map.append(
1366 ::reqwest::header::HeaderName::from_static("api-version"),
1367 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1368 );
1369 #[allow(unused_mut)]
1370 let mut request = self
1371 .client
1372 .post(url)
1373 .header(
1374 ::reqwest::header::ACCEPT,
1375 ::reqwest::header::HeaderValue::from_static("application/json"),
1376 )
1377 .json(&body)
1378 .headers(header_map)
1379 .build()?;
1380 let info = OperationInfo {
1381 operation_id: "status",
1382 };
1383 self.pre(&mut request, &info).await?;
1384 let result = self.exec(request, &info).await;
1385 self.post(&result, &info).await?;
1386 let response = result?;
1387 match response.status().as_u16() {
1388 200u16 => ResponseValue::from_response(response).await,
1389 _ => Err(Error::UnexpectedResponse(response)),
1390 }
1391 }
1392 #[doc = "Queries status of a transaction by hash and returns the final transaction result.\n\nSends a `POST` request to `/tx`\n\n"]
1393 pub async fn tx<'a>(
1394 &'a self,
1395 body: &'a types::JsonRpcRequestForTx,
1396 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcTransactionResponseAndRpcError>, Error<()>>
1397 {
1398 let url = format!("{}/", self.baseurl,);
1399 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1400 header_map.append(
1401 ::reqwest::header::HeaderName::from_static("api-version"),
1402 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1403 );
1404 #[allow(unused_mut)]
1405 let mut request = self
1406 .client
1407 .post(url)
1408 .header(
1409 ::reqwest::header::ACCEPT,
1410 ::reqwest::header::HeaderValue::from_static("application/json"),
1411 )
1412 .json(&body)
1413 .headers(header_map)
1414 .build()?;
1415 let info = OperationInfo { operation_id: "tx" };
1416 self.pre(&mut request, &info).await?;
1417 let result = self.exec(request, &info).await;
1418 self.post(&result, &info).await?;
1419 let response = result?;
1420 match response.status().as_u16() {
1421 200u16 => ResponseValue::from_response(response).await,
1422 _ => Err(Error::UnexpectedResponse(response)),
1423 }
1424 }
1425 #[doc = "Queries active validators on the network. Returns details and the state of validation on the blockchain.\n\nSends a `POST` request to `/validators`\n\n"]
1426 pub async fn validators<'a>(
1427 &'a self,
1428 body: &'a types::JsonRpcRequestForValidators,
1429 ) -> Result<ResponseValue<types::JsonRpcResponseForRpcValidatorResponseAndRpcError>, Error<()>>
1430 {
1431 let url = format!("{}/", self.baseurl,);
1432 let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
1433 header_map.append(
1434 ::reqwest::header::HeaderName::from_static("api-version"),
1435 ::reqwest::header::HeaderValue::from_static(Self::api_version()),
1436 );
1437 #[allow(unused_mut)]
1438 let mut request = self
1439 .client
1440 .post(url)
1441 .header(
1442 ::reqwest::header::ACCEPT,
1443 ::reqwest::header::HeaderValue::from_static("application/json"),
1444 )
1445 .json(&body)
1446 .headers(header_map)
1447 .build()?;
1448 let info = OperationInfo {
1449 operation_id: "validators",
1450 };
1451 self.pre(&mut request, &info).await?;
1452 let result = self.exec(request, &info).await;
1453 self.post(&result, &info).await?;
1454 let response = result?;
1455 match response.status().as_u16() {
1456 200u16 => ResponseValue::from_response(response).await,
1457 _ => Err(Error::UnexpectedResponse(response)),
1458 }
1459 }
1460}
1461#[doc = r" Items consumers will typically use such as the Client."]
1462pub mod prelude {
1463 #[allow(unused_imports)]
1464 pub use super::Client;
1465}