Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialization of Long type #22

Closed
Tracked by #32
pyramation opened this issue Apr 14, 2022 · 4 comments
Closed
Tracked by #32

serialization of Long type #22

pyramation opened this issue Apr 14, 2022 · 4 comments
Labels
⚙️ task A task belongs to an epic

Comments

@pyramation
Copy link
Collaborator

pyramation commented Apr 14, 2022

Seems that we need Long type to serialize to a string to correctly pass through the toAmino/fromAmino inside of stargate.sign

correct

"poolId": "4"

incorrect

"poolId": {
    "low": 4,
    "high": 0,
    "unsigned": false
}

relates to #21

@pyramation
Copy link
Collaborator Author

pyramation commented Apr 14, 2022

idea 1: can we replace the long library, and update it's toObject or toJSON

> a = Long.fromString('1')
Long { low: 1, high: 0, unsigned: false }
> a.toString()
'1'

Looks like Long is inherently a JSON object that we don't need in actual serialization

@pyramation
Copy link
Collaborator Author

Here is the current schema

export interface MsgJoinPool {
  sender: string;
  poolId: Long;
  shareOutAmount: string;
  tokenInMaxs: Coin[];
}

what if instead we did something like this?

export interface MsgJoinPool {
  sender: string;
  poolId: Long | string;
  shareOutAmount: string;
  tokenInMaxs: Coin[];
}

@pyramation
Copy link
Collaborator Author

try this option

-ts_proto_opt=forceLong=string

potentially look at making a plugin for duration

@pyramation
Copy link
Collaborator Author

protobufjs/minimal serialization is identical for strings/Longs

proto.Writer.create().uint32(16).uint64(Long.fromNumber(20))

proto.Writer.create().uint32(16).uint64('20')

@daniel-farina daniel-farina added the ⚙️ task A task belongs to an epic label Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ task A task belongs to an epic
Projects
None yet
Development

No branches or pull requests

2 participants