Created
June 29, 2023 13:17
-
-
Save dannywillems/2100dd41be3058b93ecdd858933ae4a1 to your computer and use it in GitHub Desktop.
WasmVector<WasmFlatVector<WasmFp>> error when building a constructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This should mimic LookupTable structure | |
#[wasm_bindgen] | |
pub struct WasmPastaFpLookupTable { | |
#[wasm_bindgen(skip)] | |
pub id: i32, | |
#[wasm_bindgen(skip)] | |
pub data: WasmVector<WasmFlatVector<WasmPastaFp>>, | |
} | |
// Converter from WasmPastaFpLookupTable to LookupTable, used by the binding | |
// below. | |
impl From<WasmPastaFpLookupTable> for LookupTable<Fp> { | |
fn from(wasm_lt: WasmPastaFpLookupTable) -> LookupTable<Fp> { | |
LookupTable { | |
id: wasm_lt.id.into(), | |
data: wasm_lt | |
.data | |
.into_iter() | |
.map(|row| row.into_iter().map(Into::into).collect()) | |
.collect(), | |
} | |
} | |
} | |
// JS constructor for js/bindings.js | |
#[wasm_bindgen] | |
impl WasmPastaFpLookupTable { | |
#[wasm_bindgen(constructor)] | |
pub fn new( | |
id: i32, | |
data: WasmVector<WasmFlatVector<WasmPastaFp>> | |
) { | |
WasmPastaFpLookupTable {id, data} | |
} | |
} | |
// Getting the following error: | |
➜ wasm git:(dannywillems/lookup) ✗ cargo build --release --all-features | |
warning: unused manifest key: build | |
warning: unused manifest key: target.wasm32-unknown-unknown.rustflags | |
Compiling plonk_wasm v0.1.0 (/home/soc/codes/o1-labs/mina-develop/src/lib/snarkyjs/src/bindings/kimchi/wasm) | |
error[E0271]: type mismatch resolving `<WasmFlatVector<WasmPastaFp> as FromWasmAbi>::Abi == u32` | |
--> src/pasta_fp_plonk_index.rs:54:1 | |
| | |
54 | #[wasm_bindgen] | |
| ^^^^^^^^^^^^^^^ type mismatch resolving `<WasmFlatVector<WasmPastaFp> as FromWasmAbi>::Abi == u32` | |
| | |
note: expected this to be `WasmSlice` | |
--> src/wasm_flat_vector.rs:110:16 | |
| | |
110 | type Abi = <Vec<u8> as FromWasmAbi>::Abi; | |
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
note: required for `wasm_vector::WasmVector<wasm_flat_vector::WasmFlatVector<WasmPastaFp>>` to implement `FromWasmAbi` | |
--> src/wasm_vector.rs:81:33 | |
| | |
81 | impl<T: FromWasmAbi<Abi = u32>> FromWasmAbi for WasmVector<T> { | |
| --------- ^^^^^^^^^^^ ^^^^^^^^^^^^^ | |
| | | |
| unsatisfied trait bound introduced here | |
= note: this error originates in the attribute macro `wasm_bindgen::prelude::__wasm_bindgen_class_marker` (in Nightly builds, run with -Z macro-backtrace for more info) | |
For more information about this error, try `rustc --explain E0271`. | |
error: could not compile `plonk_wasm` due to previous error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment