Scaffold-Stark / scaffold-stark-2

Open source forkable Starknet dev stack
https://www.scaffoldstark.com
64 stars 87 forks source link

refactor(parser): use starknetjs parsers to encode decode data #334

Closed metalboyrick closed 2 weeks ago

metalboyrick commented 4 weeks ago

Task name here

Fixes #326 Fixes #319

Types of change

Comments (optional)

Have not cleaned up yet, but tested with bulletproof contracts, should work with previous data types

TODO:

metalboyrick commented 4 weeks ago

Can review first, I will leave it as draft for now @jrcarlos2000 @Nadai2010

ngjupeng commented 3 weeks ago

image there's a bug with tuple unsigned integer

ngjupeng commented 3 weeks ago

image ContractAddress is bigint here

metalboyrick commented 2 weeks ago

Since I've written some changes for the Address component, this should resolve issue #319 as well

ngjupeng commented 2 weeks ago

image 0x0x issue from useScaffoldEventHistory on felt type

ngjupeng commented 2 weeks ago

image issue happen in nested enum

Sample nested enum cairo code:

#[derive(Drop, Serde)]
enum SampleEnum {
    enum1: u256,
    enum2: felt252
}

#[derive(Drop, Serde)]
enum SampleNestedEnum {
    enum1: SampleEnum,
    enum2: felt252
}

#[derive(Drop, starknet::Event)]
pub struct EventWithNestedEnum {
    element1: u256,
    element2: SampleNestedEnum,
}

 fn emit_event_with_nested_enum(
          ref self: ContractState, element1: u256, element2: SampleNestedEnum
      ) {
          self.emit(EventWithNestedEnum { element1, element2 });
      }
iossocket commented 2 weeks ago

@ngjupeng hi, #339 had fixed the 0x0x event issue, would you mind to check it ?

ngjupeng commented 2 weeks ago

image

image we need handle this case?

jrcarlos2000 commented 2 weeks ago

image

image we need handle this case?

this used to be handled before @metalboyrick iirc

metalboyrick commented 2 weeks ago

@jrcarlos2000 @ngjupeng used to be, new changes may have override this, will check

ngjupeng commented 2 weeks ago

image 0x is valid input (ignore the gia, it only exist on my local for debug purpose)

ngjupeng commented 2 weeks ago

image u256>

ngjupeng commented 2 weeks ago

image integer type is not working

ngjupeng commented 2 weeks ago

image expect to return as contract format

iossocket commented 2 weeks ago
image

will this be a fix for inputting more than one variant for enum form? @metalboyrick

metalboyrick commented 2 weeks ago

@iossocket yep, enums are supposed to only have one active variant only

metalboyrick commented 2 weeks ago

yeah but that somehow doesnt work

iossocket commented 2 weeks ago
image

does not get this hint?

metalboyrick commented 2 weeks ago

wait now it works

metalboyrick commented 2 weeks ago

@iossocket that is the expected one

metalboyrick commented 2 weeks ago

i tink this breaks down if the enum is nested @iossocket

iossocket commented 2 weeks ago

is it because one form will only have one errorMessage state, other field item may change it as well?

metalboyrick commented 2 weeks ago

yep @iossocket fixed this, cc @ngjupeng

metalboyrick commented 2 weeks ago

expect to return as contract format

@ngjupeng this has been fixed but some output might loook a bit uglier haha

iossocket commented 2 weeks ago

for the signed integer, starknetjs does not support right now. https://github.com/starknet-io/starknet.js/pull/1177

ngjupeng commented 2 weeks ago

expect to return as contract format

@ngjupeng this has been fixed but some output might loook a bit uglier haha

this issue existed in tuple and struct also, but it was fixed on array

metalboyrick commented 2 weeks ago

merging and will record outstanding issues to unblock HH usage