ergoplatform / sigma-rust

Rust implementation of ErgoTree interpreter and wallet-related features
Creative Commons Zero v1.0 Universal
69 stars 48 forks source link

iOS bindings ErgoBoxes.get uses DataInputPtr #576

Open thedlop opened 2 years ago

thedlop commented 2 years ago

Curious why a DataInputPtr is being used instead of an ErgoBoxPtr: https://github.com/ergoplatform/sigma-rust/blob/develop/bindings/ergo-lib-ios/Sources/ErgoLib/ErgoBox.swift#L514 when the C header has this as the method signature:

struct ReturnOption ergo_lib_ergo_boxes_get(ConstErgoBoxesPtr collection_ptr,                                                                                  
                                            uintptr_t index,
                                            ErgoBoxPtr *element_ptr_out);
kettlebell commented 2 years ago

That's a typo I made. There's probably other instances where it's wrong too. But it actually doesn't affect the runtime since the proper FFI functions are called with the args in the right spots. It's interesting that Swift can't catch the type error.

Of course a sweep should be made to correct these.

thedlop commented 2 years ago

I figured Swift would complain about this but I guess a pointer is a pointer. Thanks for the clarification! I can keep posting instances of this here. I saw another in ErgoBoxCandidates.

https://github.com/ergoplatform/sigma-rust/blob/develop/bindings/ergo-lib-ios/Sources/ErgoLib/ErgoBox.swift#L445

thedlop commented 2 years ago

Var name should not be boxIdPtr https://github.com/ergoplatform/sigma-rust/blob/develop/bindings/ergo-lib-ios/Sources/ErgoLib/Contract.swift#L39