Published
Edited
Mar 25, 2021
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
async function findInfoForAddress (addr) {
const id = await findIdAddress(addr)
const res = await gql`
query {
Height(at: ${inputHeight}) {
Time
Height
ParentStateRoot {
Actors {
At(key:"${id}") {
Balance
Code
Head {
... on MultisigV0State {
StartEpoch
UnlockDuration
InitialBalance
NumApprovalsThreshold
Signers {
All
}
}
... on MultisigV3State {
StartEpoch
UnlockDuration
InitialBalance
NumApprovalsThreshold
Signers {
All
}
}
}
}
}
}
}
}`
const { Code, Balance, Head } = res.data.Height.ParentStateRoot.Actors.At
const Type = codeRegEx.exec(Code)[1]
const multisigState = Type === 'multisig' ? deriveMultisigState(maxHeight, Balance, Head) : {}
return {
Address: addr,
Balance: Balance * 1e-18,
Type,
Signers: Head.Signers?.All.join(' '),
...multisigState }
}
Insert cell
Insert cell
function deriveMultisigState (selectedEpoch, Balance, {InitialBalance, UnlockDuration, StartEpoch} ) {
if (!UnlockDuration){
// no vesting schedule
return { VestingStart: undefined, VestingEnd: undefined, VestedFIL: 0, UnvestedFIL: 0}
}
const VestingStart = heightToDate(StartEpoch)
const VestingEnd = heightToDate(StartEpoch + UnlockDuration)
if (StartEpoch >= selectedEpoch) {
// not started vesting yet
return { VestingStart, VestingEnd, VestedFIL: 0, UnvestedFIL: InitialBalance / 1e18}
} else {
const vestPerEpoch = InitialBalance / UnlockDuration
const vestedEpochs = Math.min(selectedEpoch - StartEpoch, UnlockDuration)
const vestedAttoFil = Math.ceil(vestedEpochs * vestPerEpoch)
const unvestedAttoFil = InitialBalance - vestedAttoFil
return {
VestingStart,
VestingEnd,
VestedFIL: vestedAttoFil / 1e18,
UnvestedFIL: unvestedAttoFil / 1e18,
}
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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