proximax-storage / nem2-sdk-go Goto Github PK
View Code? Open in Web Editor NEWOfficial Go SDK for ProximaX/NEM Catapult
License: Apache License 2.0
Official Go SDK for ProximaX/NEM Catapult
License: Apache License 2.0
Creating mosaic now returns an error
Hash: 366E0ABBF745B4BE36ADAA04487A519B5D9584BF677ADBC16F9AF7754426F91B
Error code: Failure_Mosaic_Invalid_Name
Deadline: 2018-11-29 14:13:38.615
Unmashall function of MosaicIds struct is not working
This is first account's transaction statuses handling:
subscribeTransaction, err := ws.Subscribe.ConfirmedAdded(account.Address.Address)
if err != nil {
return nil, err
}
// Below goes code which handles channels and it works.
This part of code goes after with different account, thus different address:
subscribeTransaction, err := b.ws.Subscribe.ConfirmedAdded(acc.Address.Address)
if err != nil {
errCh <-err
return
}
// This part handles channel and it is not working
for {
select {
case status := <-statusSub.Ch: // Returns nothing
if status.Hash.String() == signedTx.Hash.String() {
errCh <-errors.New(status.Status)
break
}
}
I checked through debugger function buildType() and it is not called, while other WS client not from sdk receives message about confirmed transaction
sub1, _ := b.ws.Subscribe.Status("VBRPREMRDLANIF2WT2WRFXNLC5GDFGZYBVFSSAGK")
sub2, _ := b.ws.Subscribe.Status("VDYWAEJF7ZNGEOPAVGMSX6KDAX6PHVRENJVKX2OM")
Sub2 overrides sub1 programmatically, while websocket channel is still sending messages to sdk, which can't handle them
Inside mosaic_model.go file there are functions generation id for Mosaics and Namespaces. Error handling in these functions needs some updated to better understanding when error happens.
@slackve please check buildType()
method and update "signer" and "unconfirmed" cases where json.Unmarshall()
works with values, not pointers
Hello Sir,
I'm currently testing the 'Get AccountInfo for an account' sample code and I'm getting this error.
Sample code:
`package main
import (
"fmt"
"github.com/proximax-storage/nem2-sdk-go/sdk"
"golang.org/x/net/context"
)
const (
// Catapult-api-rest server.
baseUrl = "http://localhost:3000"
// Types of network.
// MainNet: 104
// TestNet: 152
// Mijin: 96
// MijinTest: 144
networkType = sdk.MijinTest
// A valid private key.
publicKeyOne = "E17324EAF403B5FD747055ED3ED97CFD1000AF176FB9294C9424A2814D765A76"
)
// Simple Account API request
func main() {
addressOne, _ := sdk.NewAddressFromPublicKey(publicKeyOne, networkType)
conf, err := sdk.LoadTestnetConfig(baseUrl)
if err != nil {
panic(err)
}
// Use the default http client
client := sdk.NewClient(nil, conf)
// Get AccountInfo for an account.
// Param address - A Address struct.
accountInfo, resp, err := client.Account.GetAccountInfo(context.Background(), addressOne)
if err != nil {
fmt.Printf("Account.GetAccountInfo returned error: %s", err)
return
}
fmt.Printf("Response Status Code == %d\n", resp.StatusCode)
fmt.Printf(accountInfo.String())
}
`
Here's the screenshot: https://imgur.com/z8SuYKN
Thanks alot.
package main
import (
"context"
"fmt"
"github.com/proximax-storage/nem2-sdk-go/sdk"
)
const (
baseUrl = "http://xxxxxx:3000"
networkType = sdk.MijinTest
privateKey = "xxx"
)
// WebSockets make possible receiving notifications when a transaction or event occurs in the blockchain.
// The notification is received in real time without having to poll the API waiting for a reply.
// Simple Blockchain API request
func main() {
// timeout in milliseconds
// 60000 ms = 60 seconds
// 0 = without timeout
ws, err := sdk.NewConnectWs(baseUrl, 60000)
conf, err := sdk.NewConfig(baseUrl, networkType)
if err != nil {
panic(err)
}
// Use the default http client
client := sdk.NewClient(nil, conf)
fmt.Println("websocket negotiated uid:", ws.Uid)
d, _ := ws.Subscribe.Block()
for {
data := <-d.Ch
fmt.Printf("Block received with height: %v \n", data.Height)
getBlockTransactions, resp, err := client.Blockchain.GetBlockTransactions(context.Background(), data.Height)
if err != nil {
fmt.Printf("Blockchain.GetBlockTransactions returned error: %s", err)
return
}
fmt.Printf("Response Status Code == %d\n", resp.StatusCode)
fmt.Printf("%s\n\n", getBlockTransactions)
}
}
More flexible Config creation is needed using different network types
In wsConnect()
, changeURLPort()
is called by default, which forces the port to 3000. It should follow the port set in the BaseURL or have an option to not call it at all.
Also there is no way to change from ws://
to wss://
issue with websocket code not receiving block status updates
`package main
import (
"fmt"
"github.com/proximax-storage/nem2-sdk-go/sdk"
)
const (
baseUrl = "http://bctestnet1.xpxsirius.io:3000"
)
func main() {
// timeout in milliseconds
// 5000 ms = 5 seconds
ws, err := sdk.NewConnectWs(baseUrl, 5000)
if err != nil {
panic(err)
}
fmt.Println("websocket negotiated uid:", ws.Uid)
d, _ := ws.Subscribe.Block()
for {
data := <-d.Ch
fmt.Printf("Block received with height: %v \n", data.Height)
}
}
`
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.