Published
Edited
Jun 24, 2021
Insert cell
Insert cell
Insert cell
Insert cell
await client.version()
Insert cell
chainHead = await client.chainHead()
Insert cell
Insert cell
Insert cell
viewof selectedHeight = html`<input type=range min=${currentHeight - 200} max=${currentHeight} value=${currentHeight - 1}>`
Insert cell
Insert cell
tipSetKey = (await client.chainGetTipSetByHeight(selectedHeight, headTipSet)).Cids
Insert cell
selectedTipSet = client.chainGetTipSet(tipSetKey)
Insert cell
tipSet = [...tipSetKey].map(obj => obj['/']).sort().join(',')

Insert cell
async function* messagesStream() {
if (selectedTipSet.Cids) {
for (let i = 0; i < selectedTipSet.Cids.length; i++) {
const blockCid = selectedTipSet.Cids[i]
const height = selectedTipSet.Height
const miner = selectedTipSet.Blocks[i].Miner
const messages = await client.chainGetBlockMessages(blockCid)
for (const message of messages.BlsMessages) {
yield *yieldMessage(message, 'bls')
}
for (const { Message: message } of messages.SecpkMessages) {
yield *yieldMessage(message, 'secpk')
}

function *yieldMessage (message, signatureType) {
yield {
height,
tipSet,
blockCid: blockCid['/'],
blockMiner: miner,
messageCid: message.CID['/'],
signatureType,
version: message.Version,
to: message.To,
from: message.From,
nonce: message.Nonce,
value: message.Value,
gasLimit: message.GasLimit,
gasFeeCap: message.GasFeeCap,
gasPremium: message.GasPremium,
method: message.Method,
params: message.Params
}
}
}
}
}
Insert cell
messagesStream()
Insert cell
messages = {
const result = []
for await (const message of messagesStream()) {
result.push(message)
}
return result
}
Insert cell
Insert cell
LotusRPC = (await import('@filecoin-shipyard/lotus-client-rpc')).LotusRPC
Insert cell
BrowserProvider = (await import('@filecoin-shipyard/lotus-client-provider-browser')).BrowserProvider
Insert cell
schema = (await import('@filecoin-shipyard/lotus-client-schema')).mainnet.fullNode
Insert cell
Insert cell
Object.keys(schema.methods)
Insert cell
Insert cell
Insert cell
client = {
const provider = new BrowserProvider(endpointUrl)
return new LotusRPC(provider, { schema })
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more