codechain-io / codechain-sdk-go Goto Github PK
View Code? Open in Web Editor NEWGo Software Development Kit for CodeChain
Go Software Development Kit for CodeChain
This is reduced version of #40. (could be more reduced)
MintAsset, TransferAsset, Pay transactions are planned to be available in the alpha version.
I'll set the day by day schedule until Monday(11/18).
Currently, some of the Transaction-related objects have two forms, which implement normal type and for marshaling.
codechain-sdk-go/core/transaction/signedTransaction.go
Lines 11 to 17 in 6ad3e76
codechain-sdk-go/core/transaction/signedTransaction.go
Lines 19 to 25 in 6ad3e76
This implementation is from codechain-sdk-js.
But since golang can implement custom marshaling function (link1) (link2), I think duplication of the objects is unnecessary.
It seems to be that go get
propery clones this repository. But repository path in my computer(MacOS) has not preserved some uppercase(CodeChain-io
): /Users/daehyun/go/src/github.com/codechain-io/codechain-rpc-go
Below is command execution logs.
$ go get -u github.com/codechain-io/codechain-rpc-go
go: finding github.com/codechain-io/codechain-rpc-go latest
go get: github.com/codechain-io/[email protected]: parsing go.mod:
module declares its path as: github.com/CodeChain-io/codechain-rpc-go
but was required as: github.com/codechain-io/codechain-rpc-go
My go version: go version go1.13.1 darwin/amd64
core
Asset
AssetScheme
Block
Core
Invoice
Script
SignedTransaction
Text
Transaction
types
transaction - [ ] functions for each transaction type. not listed.
We are importing the whole Go Ethereum code to use the RLP code.
We should import only the RLP code.
Line 3 in 6ad3e76
In September 2019, golang version 1.13 has been released officially.
I think there are no breaking changes. However, they had discontinued the support for previous versions for some architecture.
Currently, if RPC error occurs, the error message just gives
unexpected end of JSON input
Because the error format provided by the rpc server is as follows:
{
code: -32032,
message: 'Not Enough Balance',
data: 'InsufficientBalance { address: Address(~~), balance: ~, cost: ~ }'
}
unexpected end of JSON input
comes from line 75.
(body
has the error message in byte slice)
Lines 64 to 77 in 6ad3e76
The current root directory is too messy.
go files that have rpc
package could be moved to /rpc
directory.
I'll do this after [WIP]'s are done to avoid conflict.
Some package names are too long. (e.g. primitives)
It hurts code readability while importing and using the package that has a long name.
Use alias for long package name like prims
for primitives
go test in root directory of 689f8eb fails with
unexpected end of JSON input
Not sure, I think modularizing rpc have occurred this issue.
So fix the *_test.go files.
When I called chain.GetBlockByNumber(2242299)
to the Corgi network, there are only the initial values for each types in every Transaction
field from the parsed Block
struct. Actual values could be found in Explorer.
Currently http.Client is created every RPC execution.
But golang recommends reusing the http.Client
https://golang.org/pkg/net/http/#Client
Some elements of objects are nullable.
But current implementation has not considered this.
Since golang does not support nullable structs in default,
If the object is nullable, hold pointer value instead of the exact value.
We should check all the structs that are implemented.
Block or Transaction type is sophisticated. We should test them.
There are a lot if interface{}
types in rpc functions.
Implement primitive types and assign thos to interface{}
Some of the tests are more like example codes now.
Create example
directory to the root and move some tests there.
The structure ./example
could be like below
Current implementation uses string
a lot to follow the types of codechain-rpc-js, codechain-primitives-js.
But Golang encourages to use byte slice rather than string for many reasons.
So most of the string
types in this repository should be changed to []byte
Hash
Ecdsa
Bech32
Almost all field names in JSON format are same with the deserialized Go types. So I want to propose to implement custom Marshaller changing PascalCase
to camelCase
Implementors can consult the following : https://gist.github.com/Rican7/39a3dc10c1499384ca91
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.