Comments (2)
I see two use cases:
-
Developer wants to store complex struct in state and then load it
-
Developer wants to receive complex struct as argument or return it in the result
I think (1) is more important
This should be implemented using a serialization library of some sort as part of the contract SDK
There are 3 main serialization candidates, we can support all 3:
-
JSON - developers understand it and like it, although some fuzziness regarding encoding of types like byte arrays, bigints and so forth. JSON doesn't have a good type schema, it's self descriptive with few types. JSON is also very wasteful and results in much larger state than needed (due to being textual for example).
-
membuffers - it's already a format we use for the Orbs protocol. The difficulty here is where to advertise the schemas. We can use reflection to do encoding/decoding and "understand" the schema from the provided type but this will have a performance penalty. Working without schema will make the API for developers very boilerplaty and hard to read.
-
Ethereum serialization protocol - will be nice to support it just for compatibility anyways. But it does rely on reflection to its performance is so so.
from orbs-contract-sdk.
From a product perspective, what do you say about API like this:
type Person struct {
Name string
Age uint32
}
func someFunc() {
schema := "{Name: string, Age: uint32}"
var p Person
person := serializer.Decode(bytes, &p)
bytes := serializer.Encode(p)
The benefit here is that we have clearer expression of the schema for working across languages.. This is very similar to ABI btw.. so maybe just using Ethereum's approach would be good here and no need to do our own
from orbs-contract-sdk.
Related Issues (20)
- cannot see event when calling a function in read only permission scope (run-query)
- v1 and gamma-cli aren't compatible
- ethereum.CallMethod doesn't work HOT 1
- when overriding a sting in the cli using args, it cannot receive a space
- gamma-cli forces every use of the type bytes to have a checksum encoded hex HOT 1
- bug - when using -arg1 gamma-cli doesn't accpet 0x HOT 1
- bug - when using -arg1 in gamma-cli and making error the error message says argument 0 HOT 1
- using the fake_sdk to test contracts there is some kind of connection between tests
- fake sdk missing fake functions env.GetBlockHeight()
- fake sdk should list the mocks not called in verify mock
- fake sdk should list mocked functions that where not called
- TestGetBlockNumberOnEthereum HOT 1
- Context: context not found error HOT 1
- Consider how we save big.Int to state
- state.ReadBytes() returns emty slice instead of nil
- validations should be done before mutation of state HOT 1
- documentation review: addresses
- documentation review: events
- document cross-contract usage and reccomendations
- missing API documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orbs-contract-sdk.