-
Notifications
You must be signed in to change notification settings - Fork 6
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
how to import signDeploy etc. into a web page script module? #8
Comments
Short answer is no, but... First you need crypto stuff for signing and hashing, this shouldn't be hard. rnode-grpc-js/src/rnode-sign.js Lines 34 to 41 in a842459
And generated code should be something like this (rnode-grpc-gen/js/CasperMessage_pb.js). proto.casper.DeployDataProto.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getDeployer_asU8();
if (f.length > 0) {
writer.writeBytes(
1,
f
);
}
f = message.getTerm();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
.
.
.
f = message.getValidafterblocknumber();
if (f !== 0) {
writer.writeInt64(
10,
f
);
}
}; |
I wonder if https://jspm.io/ would help... |
In my research
debugging with packed code is no fun. :-/ |
looks like ES6 module support is still on the todo/wish list for grpc-web: grpc/grpc-web#535 |
@dckc I'm not sure if you want to use RNode Web API is not using protobuf for communication. It's used only on one place to create serialized bytes by DeployDataProto specification. I don't have better documentation for Web API then the PR. |
@dckc here is the function to serialize deploy data with protobuf directly without code generation. Protobuf definition specify position. You don't need rnode-grpc-js when you are on the web. // message DeployDataProto {
// bytes deployer = 1; //public key
// string term = 2; //rholang source code to deploy (will be parsed into `Par`)
// int64 timestamp = 3; //millisecond timestamp
// bytes sig = 4; //signature of (hash(term) + timestamp) using private key
// string sigAlgorithm = 5; //name of the algorithm used to sign
// int64 phloPrice = 7; //phlo price
// int64 phloLimit = 8; //phlo limit for the deployment
// int64 validAfterBlockNumber = 10;
// }
import jspb from 'google-protobuf'
const deployDataProtobufSerialize = deployData => {
const { term, timestamp, phloPrice, phloLimit, validAfterBlockNumber } = deployData
// Create binary stream writer
const writer = new jspb.BinaryWriter()
// Serialize fields
writer.writeString(2, term)
writer.writeInt64(3, timestamp)
writer.writeInt64(7, phloPrice)
writer.writeInt64(8, phloLimit)
writer.writeInt64(10, validAfterBlockNumber)
return writer.getResultBuffer()
} |
Thanks! That suggests this issue is out of scope of this repo. I wonder where it belongs. An RChain web SDK repo sure would be nice. |
I'd like to do:
Is this feasible without a bundler?
The text was updated successfully, but these errors were encountered: