Skip to content

Commit

Permalink
Refactored MeshWrapper.AddOrders to use jsutil
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Feb 5, 2020
1 parent eaf0ed6 commit e81d52b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion browser/conversion-tests/conversion_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ WebAssembly.instantiateStreaming(fetch('conversion_test.wasm'), go.importObject)
testValidationResults(validationResults);

// Execute the Typescript --> Go tests
// tslint:disable:no-object-literal-type-assertion
const ethereumRPCURL = 'http://localhost:8545';

// Set up a Web3 Provider that uses the RPC endpoint
// tslint:disable:no-object-literal-type-assertion
const provider = new Web3ProviderEngine();
provider.addProvider(new RPCSubprovider(ethereumRPCURL));
provider.start();
Expand Down
5 changes: 1 addition & 4 deletions browser/go/mesh-browser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,8 @@ func (cw *MeshWrapper) Start() error {
// core.App.AddOrders, converts the result into basic JavaScript types (string,
// int, etc.) and returns it.
func (cw *MeshWrapper) AddOrders(rawOrders js.Value, pinned bool) (js.Value, error) {
// HACK(albrow): There is a more effecient way to do this, but for now,
// just use JSON to convert to the Go type.
encodedOrders := js.Global().Get("JSON").Call("stringify", rawOrders).String()
var rawMessages []*json.RawMessage
if err := json.Unmarshal([]byte(encodedOrders), &rawMessages); err != nil {
if err := jsutil.InefficientlyConvertFromJS(rawOrders, &rawMessages); err != nil {
return js.Undefined(), err
}
results, err := cw.app.AddOrders(cw.ctx, rawMessages, pinned)
Expand Down

0 comments on commit e81d52b

Please sign in to comment.