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
//! # Basic Blockchain functions //! Basic functionality to interact with Catapulta Blockchain. //! It represent via twa main part: transactions //! and getters (**get functions** of some information from Blockchain). //! //! ## Transaction functions //! Main principle of transaction functions is //! that aggregation to pool of transactions. So it will send not immediately. //! The reason is minimize `Gas spent` and reducing Blockchain resources utilization. //! //! When SuperContract will End transactions Flush autromaticaly (it mean it will send //! to Blocchain). //! //! But it possible send transaction pull immediately. //! For that case exist function `flush`. //! When function `flush` invoking then Transactions Pool //! will be send to Blockchain, and then clear. //! //! And again - only **end execution of SuperContract** //! or Flush** can send transactions to Blockchaing. //! Otherwise it will gather to Transactions Pool. use serde::de::DeserializeOwned; use crate::external; use crate::statuses::Error; use crate::statuses::{FunctionResult, Result}; use crate::tools::call::{call_external_func, simple_call_external_func}; use crate::transactions_type::*; /// Flush send immediately Transactions from current /// transactions pool. /// /// Flush should use carefully. If Leader of SuperContract /// execution invoke Flush then SuperContract will be /// paused ann waite /// Signing from other Executors. /// When Flush will send from non-leader it mean fire /// process of signing transactions /// from Leader of SuperContract execution. /// In both case SuperContract will be paused waiting /// event from other Executors. /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// mosaic_definition, /// }; /// use xpx_supercontracts_sdk::transactions_type::MosaicDefinition; /// /// let pub_key = "2C8178EF9ED7A6D30ABDC1E4D30D68B05861112A98B1629FBE2C8D16FDE97A1C".to_string(); /// let params = MosaicDefinition{ /// nonce: 100, /// owner_public_key: pub_key, /// mosaic_props: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = mosaic_definition(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// // Flush current Transactions Pool /// let flush_result = flush(); /// if flush_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn flush() -> FunctionResult { return unsafe { Ok(external::flush()) }; } /// Send to transaction pool **MosaicDefinition transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// mosaic_definition, /// }; /// use xpx_supercontracts_sdk::transactions_type::MosaicDefinition; /// /// let pub_key = "2C8178EF9ED7A6D30ABDC1E4D30D68B05861112A98B1629FBE2C8D16FDE97A1C".to_string(); /// let params = MosaicDefinition{ /// nonce: 100, /// owner_public_key: pub_key, /// mosaic_props: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = mosaic_definition(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn mosaic_definition(params: &MosaicDefinition) -> FunctionResult { simple_call_external_func(params, external::mosaic_definition) } /// Send to transaction pool **AddressAlias transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// address_alias, /// }; /// use xpx_supercontracts_sdk::transactions_type::AddressAlias; /// /// let params = AddressAlias{ /// address: None, /// namespace_id: None, /// action_type: 10, /// }; /// // Add transaction to Transactions Pool /// let tx_result = address_alias(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn address_alias(params: &AddressAlias) -> FunctionResult { simple_call_external_func(params, external::address_alias) } /// Send to transaction pool **MosaicAlias transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// mosaic_alias, /// }; /// use xpx_supercontracts_sdk::transactions_type::MosaicAlias; /// /// let params = MosaicAlias{ /// mosaic_id: None, /// namespace_id: None, /// action_type: 10, /// }; /// // Add transaction to Transactions Pool /// let tx_result = mosaic_alias(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn mosaic_alias(params: &MosaicAlias) -> FunctionResult { simple_call_external_func(params, external::mosaic_alias) } /// Send to transaction pool **AddExchangeOffer transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// add_exchange_offer, /// }; /// use xpx_supercontracts_sdk::transactions_type::AddExchangeOffer; /// /// let params = AddExchangeOffer{ /// add_offers: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = add_exchange_offer(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn add_exchange_offer(params: &AddExchangeOffer) -> FunctionResult { simple_call_external_func(params, external::add_exchange_offer) } /// Send to transaction pool **AddExchangeOffer transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// add_exchange_offer, /// }; /// use xpx_supercontracts_sdk::transactions_type::AddExchangeOffer; /// /// let params = AddExchangeOffer{ /// add_offers: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = add_exchange_offer(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn exchange_offer(params: &ExchangeOffer) -> FunctionResult { simple_call_external_func(params, external::exchange_offer) } /// Send to transaction pool **Transfer transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// transfer, /// }; /// use xpx_supercontracts_sdk::transactions_type::{Transfer, PubKey}; /// /// let pub_key = "2C8178EF9ED7A6D30ABDC1E4D30D68B05861112A98B1629FBE2C8D16FDE97A1C".to_string(); /// let params = Transfer{ /// pub_key: pub_key, /// asset_id: 10, /// amount: 1000, /// }; /// // Add transaction to Transactions Pool /// let tx_result = transfer(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn transfer(params: &Transfer) -> FunctionResult { simple_call_external_func(params, external::transfer) } /// Send to transaction pool **RemoveExchangeOffer transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// remove_exchange_offer, /// }; /// use xpx_supercontracts_sdk::transactions_type::RemoveExchangeOffer; /// /// let params = RemoveExchangeOffer{ /// remove_offers: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = remove_exchange_offer(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn remove_exchange_offer(params: &RemoveExchangeOffer) -> FunctionResult { simple_call_external_func(params, external::remove_exchange_offer) } /// Send to transaction pool **MosaicSupplyChange transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// mosaic_supply_change, /// }; /// use xpx_supercontracts_sdk::transactions_type::MosaicSupplyChange; /// /// let params = MosaicSupplyChange{ /// asset_id: 10, /// supply_type: 20, /// delta: 300, /// }; /// // Add transaction to Transactions Pool /// let tx_result = mosaic_supply_change(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn mosaic_supply_change(params: &MosaicSupplyChange) -> FunctionResult { simple_call_external_func(params, external::mosaic_supply_change) } /// Send to transaction pool **RegisterRootNamespace transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// register_root_namespace, /// }; /// use xpx_supercontracts_sdk::transactions_type::RegisterRootNamespace; /// /// let params = RegisterRootNamespace{ /// namespace_name: String::from("my_name_space"), /// duration: 3000, /// }; /// // Add transaction to Transactions Pool /// let tx_result = register_root_namespace(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn register_root_namespace(params: &RegisterRootNamespace) -> FunctionResult { simple_call_external_func(params, external::register_root_namespace) } /// Send to transaction pool **RegisterRootNamespace transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// register_root_namespace, /// }; /// use xpx_supercontracts_sdk::transactions_type::RegisterRootNamespace; /// /// let params = RegisterRootNamespace{ /// namespace_name: String::from("my_name_space"), /// duration: 3000, /// }; /// // Add transaction to Transactions Pool /// let tx_result = register_root_namespace(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn register_sub_namespace(params: &RegisterSubNamespace) -> FunctionResult { simple_call_external_func(params, external::register_sub_namespace) } /// Send to transaction pool **SecretLock transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// secret_lock, /// }; /// use xpx_supercontracts_sdk::transactions_type::SecretLock; /// /// let params = SecretLock{ /// mosaic: None, /// duration: 3000, /// secret: None, /// recipient: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = secret_lock(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn secret_lock(params: &SecretLock) -> FunctionResult { simple_call_external_func(params, external::secret_lock) } /// Send to transaction pool **SecretProof transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// secret_proof, /// }; /// use xpx_supercontracts_sdk::transactions_type::SecretProof; /// /// let params = SecretProof{ /// hash_type: 10, /// proof: None, /// recipient: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = secret_proof(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn secret_proof(params: &SecretProof) -> FunctionResult { simple_call_external_func(params, external::secret_proof) } /// Send to transaction pool **TransferWithNamespace transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// transfer_with_namespace, /// }; /// use xpx_supercontracts_sdk::transactions_type::TransferWithNamespace; /// /// let params = TransferWithNamespace{ /// recipient: None, /// mosaics: None, /// message: "some message".to_string(), /// }; /// // Add transaction to Transactions Pool /// let tx_result = transfer_with_namespace(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn transfer_with_namespace(params: &TransferWithNamespace) -> FunctionResult { simple_call_external_func(params, external::transfer_with_namespace) } /// Send to transaction pool **ModifyMetadataAddress transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// modify_metadata_address, /// }; /// use xpx_supercontracts_sdk::transactions_type::ModifyMetadataAddress; /// /// let params = ModifyMetadataAddress{ /// address: None, /// modifications: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = modify_metadata_address(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn modify_metadata_address(params: &ModifyMetadataAddress) -> FunctionResult { simple_call_external_func(params, external::modify_metadata_address) } /// Send to transaction pool **ModifyMetadataMosaic transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// modify_metadata_mosaic, /// }; /// use xpx_supercontracts_sdk::transactions_type::ModifyMetadataMosaic; /// /// let params = ModifyMetadataMosaic{ /// mosaic_id: None, /// modifications: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = modify_metadata_mosaic(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn modify_metadata_mosaic(params: &ModifyMetadataMosaic) -> FunctionResult { simple_call_external_func(params, external::modify_metadata_mosaic) } /// Send to transaction pool **ModifyMetadataNamespace transaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// modify_metadata_namespace, /// }; /// use xpx_supercontracts_sdk::transactions_type::ModifyMetadataNamespace; /// /// let params = ModifyMetadataNamespace{ /// namespace_id: Some(10), /// modifications: None, /// }; /// // Add transaction to Transactions Pool /// let tx_result = modify_metadata_namespace(¶ms); /// if tx_result.is_err() { /// // Some error handling /// } /// ``` /// pub fn modify_metadata_namespace(params: &ModifyMetadataNamespace) -> FunctionResult { simple_call_external_func(params, external::modify_metadata_namespace) } /// Get data via **GetAccountExchangeInfo** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// get_account_exchange_info, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetAccountExchangeInfo, UserExchangeInfo}; /// /// let params = GetAccountExchangeInfo{ /// pub_key: None, /// }; /// // Get info data /// let result = get_account_exchange_info(¶ms); /// if result.is_err() { /// // Some error handling /// } /// let info: UserExchangeInfo = result.unwrap(); /// ``` /// pub fn get_account_exchange_info(params: &GetAccountExchangeInfo) -> Result<UserExchangeInfo> { call_external_func(params, external::get_account_exchange_info) } /// Get data via **GetExchangeOfferByAssetId** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// get_exchange_offer_by_asset_id, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetExchangeOfferByAssetId, OfferInfo}; /// /// let params = GetExchangeOfferByAssetId{ /// asset_id: 10, /// offer_type: 20, /// }; /// // Get info data /// let result = get_exchange_offer_by_asset_id(¶ms); /// if result.is_err() { /// // Some error handling /// } /// let info: OfferInfo = result.unwrap(); /// ``` /// pub fn get_exchange_offer_by_asset_id(params: &GetExchangeOfferByAssetId) -> Result<OfferInfo> { call_external_func(params, external::get_exchange_offer_by_asset_id) } /// Get data via **GetMosaicInfo** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// get_mosaic_info, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetMosaicInfo, MosaicInfo}; /// /// let params = GetMosaicInfo{ /// mosaic_id: None, /// }; /// // Get info data /// let result = get_mosaic_info(¶ms); /// if result.is_err() { /// // Some error handling /// } /// let info: Option<MosaicInfo> = result.unwrap(); /// ``` /// pub fn get_mosaic_info(params: &GetMosaicInfo) -> Result<Option<MosaicInfo>> { call_external_func(params, external::get_mosaic_info) } /// Get data via **GetMosaicInfos** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// get_mosaic_infos, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetMosaicInfos, MosaicInfo}; /// /// let params = GetMosaicInfos{ /// msc_ids: None, /// }; /// // Get info data /// let result = get_mosaic_infos(¶ms); /// if result.is_err() { /// // Some error handling /// } /// let info: Option<Vec<MosaicInfo>> = result.unwrap(); /// ``` /// pub fn get_mosaic_infos(params: &GetMosaicInfos) -> Result<Option<Vec<MosaicInfo>>> { call_external_func(params, external::get_mosaic_infos) } /// Get data via **GetMosaicsNames** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// get_mosaics_names, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetMosaicsNames, MosaicName}; /// /// let params = GetMosaicsNames{ /// msc_ids: None, /// }; /// // Get info data /// let result = get_mosaics_names(¶ms); /// if result.is_err() { /// // Some error handling /// } /// let info: Option<Vec<MosaicName>> = result.unwrap(); /// ``` /// pub fn get_mosaics_names(params: &GetMosaicsNames) -> Result<Option<Vec<MosaicName>>> { call_external_func(params, external::get_mosaics_names) } /// Get data via **GetTransaction** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// get_transaction, /// }; /// use xpx_supercontracts_sdk::statuses::Result; /// use xpx_supercontracts_sdk::transactions_type::{GetTransaction, DriveFsTransaction}; /// /// let params = GetTransaction{ /// id: String::from("some_id"), /// }; /// // Get info data /// let tx_result: Result<DriveFsTransaction> = get_transaction(¶ms); /// if tx_result.is_err() { /// // Handle error /// } /// let tx = tx_result.unwrap(); /// ``` /// pub fn get_transaction<T: SignedTransaction + DeserializeOwned>( params: &GetTransaction, ) -> Result<T> { call_external_func(params, external::get_transaction) } /// Get data via **GetTransactionStatus** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// flush, /// get_transaction_status, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetTransactionStatus, TransactionStatus}; /// /// let params = GetTransactionStatus{ /// id: String::from("some_id"), /// }; /// // Get info data /// let result = get_transaction_status(¶ms); /// let info = result.unwrap(); /// ``` /// pub fn get_transaction_status(params: &GetTransactionStatus) -> Result<Option<TransactionStatus>> { call_external_func(params, external::get_transaction_status) } /// Get data via **GetTransactionStatuses** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// get_transaction_statuses, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetTransactionStatuses, TransactionStatus}; /// /// let params = GetTransactionStatuses{ /// ids: vec![], /// }; /// // Get info data /// let result = get_transaction_statuses(¶ms); /// let info: Option<Vec<TransactionStatus>> = result.unwrap(); /// ``` /// pub fn get_transaction_statuses( params: &GetTransactionStatuses, ) -> Result<Option<Vec<TransactionStatus>>> { call_external_func(params, external::get_transaction_statuses) } /// Get data via **GetTransactionEffectiveFee** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// get_transaction_effective_fee, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetTransactionEffectiveFee}; /// /// let params = GetTransactionEffectiveFee{ /// id: String::from("some_id"), /// }; /// // Get info data /// let result = get_transaction_effective_fee(¶ms); /// let info = result.unwrap(); /// ``` /// pub fn get_transaction_effective_fee(params: &GetTransactionEffectiveFee) -> Result<i64> { call_external_func(params, external::get_transaction_effective_fee) } /// Get data via **GetMosaicID** /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// get_mosaic_id, /// }; /// use xpx_supercontracts_sdk::transactions_type::{GetMosaicID}; /// /// let params = GetMosaicID{ /// nonce: 0, /// owner_public_key: String::from("some_id"), /// }; /// // Get info data /// let result = get_mosaic_id(¶ms); /// let info = result.unwrap(); /// ``` /// pub fn get_mosaci_id(params: &GetMosaicID) -> Result<i64> { call_external_func(params, external::get_mosaic_id) } /// Get data current SuperContract data /// /// ## Examples /// ```rust,no_run /// use xpx_supercontracts_sdk::transactions::{ /// get_supercontract, /// }; /// /// // Get SC data /// let result = get_supercontract(); /// let sc = result.unwrap(); /// ``` /// pub fn get_supercontract() -> Result<SuperContract> { let fn_result = unsafe { let fn_result: &mut Vec<u8> = &mut vec![]; let fn_result_len = external::get_supercontract(fn_result.as_mut_ptr()); let fn_data_bytes = fn_result.get_unchecked_mut(0..fn_result_len as usize); fn_data_bytes.to_vec() }; let result = serde_json::from_slice(&fn_result[..]); if result.is_err() { return Err(Error::DeserializeJson); } Ok(result.unwrap()) }