Parses and validates the common arguments shared by all three externally-signed methods.
(
program_id: &str,
function_name: &str,
inputs: &Array,
input_types: &Array,
signer: &Address,
tvk: &Field,
)
| 780 | impl ExecutionRequest { |
| 781 | /// Parses and validates the common arguments shared by all three externally-signed methods. |
| 782 | fn parse_common_args( |
| 783 | program_id: &str, |
| 784 | function_name: &str, |
| 785 | inputs: &Array, |
| 786 | input_types: &Array, |
| 787 | signer: &Address, |
| 788 | tvk: &Field, |
| 789 | ) -> Result< |
| 790 | ( |
| 791 | ProgramIDNative, |
| 792 | IdentifierNative, |
| 793 | Vec<ValueNative>, |
| 794 | Vec<ValueTypeNative>, |
| 795 | FieldNative, |
| 796 | FieldNative, |
| 797 | U16Native, |
| 798 | FieldNative, |
| 799 | ), |
| 800 | String, |
| 801 | > { |
| 802 | let program_id = ProgramIDNative::from_str(program_id).map_err(|e| e.to_string())?; |
| 803 | let function_name = IdentifierNative::from_str(function_name).map_err(|e| e.to_string())?; |
| 804 | |
| 805 | let input_types_length = input_types.length(); |
| 806 | let inputs_length = inputs.length(); |
| 807 | if input_types_length != inputs_length { |
| 808 | return Err(format!( |
| 809 | "input_types and inputs must have the same length. Input array length: {inputs_length} - input type array length: {input_types_length}" |
| 810 | )); |
| 811 | } |
| 812 | |
| 813 | let mut inputs_native = Vec::with_capacity(inputs_length as usize); |
| 814 | for (i, input) in inputs.iter().enumerate() { |
| 815 | let input_string = input.as_string().ok_or(format!("Input had invalid string encoding at index {i}"))?; |
| 816 | let input = ValueNative::from_str(&input_string).map_err(|e| e.to_string())?; |
| 817 | inputs_native.push(input); |
| 818 | } |
| 819 | |
| 820 | let mut input_types_native = Vec::with_capacity(inputs_length as usize); |
| 821 | for (i, input_type) in input_types.iter().enumerate() { |
| 822 | let input_type_string = |
| 823 | input_type.as_string().ok_or(format!("Input type had invalid string encoding at index {i}"))?; |
| 824 | let input_type = ValueTypeNative::from_str(&input_type_string).map_err(|e| e.to_string())?; |
| 825 | input_types_native.push(input_type); |
| 826 | } |
| 827 | |
| 828 | let scm = |
| 829 | CurrentNetwork::hash_psd2(&[*signer.to_group().to_x_coordinate(), **tvk]).map_err(|e| e.to_string())?; |
| 830 | let tcm = CurrentNetwork::hash_psd2(&[**tvk]).map_err(|e| e.to_string())?; |
| 831 | |
| 832 | let network_id = U16Native::new(CurrentNetwork::ID); |
| 833 | let function_id = compute_function_id(&network_id, &program_id, &function_name).map_err(|e| e.to_string())?; |
| 834 | |
| 835 | Ok((program_id, function_name, inputs_native, input_types_native, scm, tcm, network_id, function_id)) |
| 836 | } |
| 837 | |
| 838 | /// Computes input IDs using supplied record view keys (consumed in order for record inputs). |
| 839 | fn compute_input_ids_with_record_view_keys( |
nothing calls this directly
no test coverage detected