Skip to content

Commit

Permalink
Updated deno examples (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
markopoloparadox authored Nov 13, 2023
1 parent 080f35a commit 8fc1696
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions examples/deno/benchmarks/query_app_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ console.log("Waiting for a new block to appear (this might take a while)...")
const currentBlockNumber = (await api.rpc.chain.getHeader()).number.toNumber();
await waitForBlockInclusion(api, currentBlockNumber + 1);


console.log("Submitting Data...")
let nonce = (await api.rpc.system.accountNextIndex(alice.address)).toNumber();
const txs = [];
for (let i = 0; i < txCount; ++i) {
await api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce});
txs.push(api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce}));
nonce += 1;
}
await Promise.all(txs);

console.log("Waiting for txs to be finalized (this might take a while)...")
const targetBlockHash = await waitForBlockFinalization(api, currentBlockNumber + 2);
Expand Down
5 changes: 3 additions & 2 deletions examples/deno/benchmarks/query_block_length.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ console.log("Waiting for a new block to appear (this might take a while)...")
const currentBlockNumber = (await api.rpc.chain.getHeader()).number.toNumber();
await waitForBlockInclusion(api, currentBlockNumber + 1);


console.log("Submitting Data...")
let nonce = (await api.rpc.system.accountNextIndex(alice.address)).toNumber();
const txs = [];
for (let i = 0; i < txCount; ++i) {
await api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce});
txs.push(api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce}));
nonce += 1;
}
await Promise.all(txs);

console.log("Waiting for txs to be finalized (this might take a while)...")
const targetBlockHash = await waitForBlockFinalization(api, currentBlockNumber + 2);
Expand Down
5 changes: 3 additions & 2 deletions examples/deno/benchmarks/query_data_proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ console.log("Waiting for a new block to appear (this might take a while)...")
const currentBlockNumber = (await api.rpc.chain.getHeader()).number.toNumber();
await waitForBlockInclusion(api, currentBlockNumber + 1);


console.log("Submitting Data...")
let nonce = (await api.rpc.system.accountNextIndex(alice.address)).toNumber();
const txs = [];
for (let i = 0; i < txCount; ++i) {
await api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce});
txs.push(api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce}));
nonce += 1;
}
await Promise.all(txs);

console.log("Waiting for txs to be finalized (this might take a while)...")
const targetBlockHash = await waitForBlockFinalization(api, currentBlockNumber + 2);
Expand Down
5 changes: 3 additions & 2 deletions examples/deno/benchmarks/query_proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ console.log("Waiting for a new block to appear (this might take a while)...")
const currentBlockNumber = (await api.rpc.chain.getHeader()).number.toNumber();
await waitForBlockInclusion(api, currentBlockNumber + 1);


console.log("Submitting Data...")
let nonce = (await api.rpc.system.accountNextIndex(alice.address)).toNumber();
const txs = [];
for (let i = 0; i < txCount; ++i) {
await api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce});
txs.push(api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce}));
nonce += 1;
}
await Promise.all(txs);

console.log("Waiting for txs to be finalized (this might take a while)...")
const targetBlockHash = await waitForBlockFinalization(api, currentBlockNumber + 2);
Expand Down
5 changes: 3 additions & 2 deletions examples/deno/benchmarks/query_rows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ console.log("Waiting for a new block to appear (this might take a while)...")
const currentBlockNumber = (await api.rpc.chain.getHeader()).number.toNumber();
await waitForBlockInclusion(api, currentBlockNumber + 1);


console.log("Submitting Data...")
let nonce = (await api.rpc.system.accountNextIndex(alice.address)).toNumber();
const txs = [];
for (let i = 0; i < txCount; ++i) {
await api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce});
txs.push(api.tx.dataAvailability.submitData(data[i].toString()).signAndSend(alice, {nonce: nonce}));
nonce += 1;
}
await Promise.all(txs);

console.log("Waiting for txs to be finalized (this might take a while)...")
const targetBlockHash = await waitForBlockFinalization(api, currentBlockNumber + 2);
Expand Down

0 comments on commit 8fc1696

Please sign in to comment.