Skip to content
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

feat(grpc,node-wasm): add javascript bindings for tx client #510

Merged
merged 60 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
999138b
feat(node-wasm, types)!: Add blob service for wasm
fl0rek Nov 28, 2024
55c5c5b
Merge remote-tracking branch 'upstream/main' into feat/blob_service
fl0rek Nov 28, 2024
a8a1b20
fix wasm ci
fl0rek Nov 29, 2024
8307ddc
new rust, more CI
fl0rek Nov 29, 2024
795e6ac
fix unused
fl0rek Nov 29, 2024
a9d64d6
Merge remote-tracking branch 'upstream/main' into feat/blob_service
fl0rek Nov 29, 2024
4d2494c
increase timeout
fl0rek Nov 29, 2024
bcfefca
better tests, et al
fl0rek Dec 2, 2024
69fb3e0
missed
fl0rek Dec 2, 2024
7dbfe9a
wip
fl0rek Dec 2, 2024
5d5ac5a
fix commitment
fl0rek Dec 3, 2024
e9e1ae0
misc ci
fl0rek Dec 3, 2024
82dc2cb
feat(grpc)!: enable celestia-grpc usage within wasm
zvolin Dec 10, 2024
99b3af1
remove env_or helper
zvolin Dec 10, 2024
e83598d
remove unused import
zvolin Dec 10, 2024
5cebaf8
remove anyhow in tests
zvolin Dec 11, 2024
9c6493c
wip
fl0rek Dec 11, 2024
6a7b71c
PR review, align to current wasm-bindgen
fl0rek Dec 12, 2024
09e4cbb
Merge branch 'main' into feat/blob_service
fl0rek Dec 12, 2024
ab3cff9
Add relevant getters to namespace
fl0rek Dec 13, 2024
5ec36f8
whoops didnt mean to commit that
fl0rek Dec 13, 2024
7079948
add transaction client
zvolin Dec 13, 2024
b04e880
Merge branch 'main' into feat/grpc-wasm-support
zvolin Dec 19, 2024
74e461d
remove sleep from tests
zvolin Dec 19, 2024
3feb07f
remove unused deps
zvolin Dec 19, 2024
66bef5b
rename shares_count to shares_len
zvolin Dec 19, 2024
6b6b820
add debug impls
zvolin Dec 19, 2024
201f091
fix blob shares_len doctest
zvolin Dec 19, 2024
138fec1
match errors in tests
zvolin Dec 20, 2024
47c9f00
wip
zvolin Dec 27, 2024
a8b71db
allow constructing Namespace and Blob in js
zvolin Dec 27, 2024
6a0ead6
add inspectable to Commitment and fix comments
zvolin Dec 27, 2024
c3b685a
revert grpc tests changes
zvolin Dec 27, 2024
c902d9a
Merge branch 'main' into feat/blob_service
zvolin Dec 27, 2024
01c3033
make AppVersion binding a struct
zvolin Dec 30, 2024
662eaa7
take references in blob constructor to not zero out pointers
zvolin Dec 30, 2024
3787a92
take namespace by ref also in request_all_blobs
zvolin Dec 30, 2024
ae01cdc
Merge branch 'feat/blob_service' into feat/grpc-js-bindings
zvolin Dec 30, 2024
e25df05
submitBlobs working from wasm
zvolin Jan 3, 2025
b939926
simplify client creation
zvolin Jan 3, 2025
a9e86bf
submit message
zvolin Jan 3, 2025
1a9d14d
cleanup js and docs
zvolin Jan 7, 2025
db0fd70
fix ts types
zvolin Jan 7, 2025
e1114eb
specify wbg test timeout also in 'tests' job
zvolin Jan 7, 2025
a54016f
cleanups
zvolin Jan 7, 2025
a38c93b
Merge branch 'main' into feat/grpc-js-bindings
zvolin Jan 7, 2025
d220bdd
Merge branch 'main' into feat/grpc-js-bindings
zvolin Jan 14, 2025
992446d
resolve missing conflicts
zvolin Jan 14, 2025
2daba92
remove regex
zvolin Jan 14, 2025
5cf3210
fix public key in typescript account
zvolin Jan 14, 2025
c0fab09
add missing wbg feature on types
zvolin Jan 14, 2025
55077a9
update lockfile
zvolin Jan 14, 2025
9e1783e
add dropped doc
zvolin Jan 14, 2025
d567ff7
move the doc to correct place
zvolin Jan 14, 2025
590bdca
Merge branch 'main' into feat/grpc-js-bindings
zvolin Jan 16, 2025
f4aec41
add missing docs for wbg bindings
zvolin Jan 16, 2025
235868c
florek's grammars
zvolin Jan 21, 2025
432938c
replace rlib with lib to allow cargo more freedom
zvolin Jan 21, 2025
0d62ddf
rename last_gas_price
zvolin Jan 21, 2025
01f7012
Merge branch 'main' into feat/grpc-js-bindings
oblique Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 52 additions & 1 deletion cli/js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
Error.stackTraceLimit = 99; // rust stack traces can get pretty big, increase the default

import { NodeConfig, spawnNode } from "lumina-node";
import { AppVersion, Blob, Namespace, NodeConfig, TxClient, protoEncodeSignDoc, spawnNode } from "lumina-node";
import { secp256k1 } from "@noble/curves/secp256k1";
import { Registry } from "@cosmjs/proto-signing";

// Expose classes on window so they can be used from the console
window.AppVersion = AppVersion;
window.Blob = Blob;
window.Namespace = Namespace;

// cat ci/credentials/bridge-0.address
window.bridge0Address = "celestia1t52q7uqgnjfzdh3wx5m5phvma3umrq8k6tq2p9";

async function createTxClient() {
// cat ci/credentials/bridge-0.plaintext-key
const privKey = "393fdb5def075819de55756b45c9e2c8531a8c78dd6eede483d3440e9457d839";
const pubKey = secp256k1.getPublicKey(privKey);

const signer = (signDoc) => {
const bytes = protoEncodeSignDoc(signDoc);
const sig = secp256k1.sign(bytes, privKey, { prehash: true });
return sig.toCompactRawBytes();
};

const txClient = await new TxClient(
"http://127.0.0.1:18080",
window.bridge0Address,
pubKey,
signer
);
return txClient;
}

async function submitBankMsgSend(address, amount) {
const registry = new Registry();
const sendMsg = {
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
value: {
fromAddress: window.bridge0Address,
toAddress: address,
amount: [{ denom: "utia", amount: amount.toString() }],
},
};
const sendMsgAny = registry.encodeAsAny(sendMsg);
const txInfo = await window.txClient.submitMessage(sendMsgAny);

return txInfo;
}

async function showStats(node) {
if (!node || !await node.isRunning()) {
Expand Down Expand Up @@ -81,6 +127,7 @@ function stopped(document) {

async function main(document, window) {
window.node = await spawnNode();
window.txClient = await createTxClient();

window.events = await window.node.eventsChannel();
window.events.onmessage = (event) => {
Expand Down Expand Up @@ -114,6 +161,10 @@ async function main(document, window) {
await started(document, window);
}
});

// test submitting transfer
const txInfo = await submitBankMsgSend(window.bridge0Address, 10000);
console.log("Submitting bank MsgSend successful", txInfo);
}

await main(document, window);
Loading
Loading