Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
ce515a8635 |
@ -22,6 +22,16 @@ export const getRequiredBlockConfirmations = async (
|
|||||||
web3: Web3 | null = null,
|
web3: Web3 | null = null,
|
||||||
api: string = ''
|
api: string = ''
|
||||||
) => {
|
) => {
|
||||||
|
let blockConfirmations
|
||||||
|
|
||||||
|
try {
|
||||||
|
blockConfirmations = await contract.methods.requiredBlockConfirmations().call()
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
if (blockConfirmations) {
|
||||||
|
return parseInt(blockConfirmations)
|
||||||
|
}
|
||||||
|
|
||||||
const eventsFromSnapshot = snapshotProvider.requiredBlockConfirmationEvents(blockNumber)
|
const eventsFromSnapshot = snapshotProvider.requiredBlockConfirmationEvents(blockNumber)
|
||||||
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
||||||
|
|
||||||
@ -35,16 +45,10 @@ export const getRequiredBlockConfirmations = async (
|
|||||||
|
|
||||||
const events = [...eventsFromSnapshot, ...contractEvents]
|
const events = [...eventsFromSnapshot, ...contractEvents]
|
||||||
|
|
||||||
let blockConfirmations
|
// Use the value from last event before the transaction
|
||||||
if (events.length > 0) {
|
const event = events[events.length - 1]
|
||||||
// Use the value from last event before the transaction
|
blockConfirmations = event.returnValues.requiredBlockConfirmations
|
||||||
const event = events[events.length - 1]
|
|
||||||
blockConfirmations = event.returnValues.requiredBlockConfirmations
|
|
||||||
} else {
|
|
||||||
// This is a special case where RequiredBlockConfirmationChanged was not emitted during initialization in early versions of AMB
|
|
||||||
// of Sokol - Kovan. In this case the current value is used.
|
|
||||||
blockConfirmations = await contract.methods.requiredBlockConfirmations().call()
|
|
||||||
}
|
|
||||||
return parseInt(blockConfirmations)
|
return parseInt(blockConfirmations)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +61,16 @@ export const getRequiredSignatures = async (
|
|||||||
web3: Web3 | null = null,
|
web3: Web3 | null = null,
|
||||||
api: string = ''
|
api: string = ''
|
||||||
) => {
|
) => {
|
||||||
|
let requiredSignatures
|
||||||
|
|
||||||
|
try {
|
||||||
|
requiredSignatures = await contract.methods.requiredSignatures().call()
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
if (requiredSignatures) {
|
||||||
|
return parseInt(requiredSignatures)
|
||||||
|
}
|
||||||
|
|
||||||
if (blockNumber === 'latest') {
|
if (blockNumber === 'latest') {
|
||||||
return contract.methods.requiredSignatures().call()
|
return contract.methods.requiredSignatures().call()
|
||||||
}
|
}
|
||||||
@ -76,7 +90,7 @@ export const getRequiredSignatures = async (
|
|||||||
|
|
||||||
// Use the value form last event before the transaction
|
// Use the value form last event before the transaction
|
||||||
const event = events[events.length - 1]
|
const event = events[events.length - 1]
|
||||||
const { requiredSignatures } = event.returnValues
|
;({ requiredSignatures } = event.returnValues)
|
||||||
return parseInt(requiredSignatures)
|
return parseInt(requiredSignatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +101,13 @@ export const getValidatorList = async (
|
|||||||
web3: Web3 | null = null,
|
web3: Web3 | null = null,
|
||||||
api: string = ''
|
api: string = ''
|
||||||
) => {
|
) => {
|
||||||
if (blockNumber === 'latest') {
|
try {
|
||||||
return contract.methods.validatorList().call()
|
const currentList = await contract.methods.validatorList().call()
|
||||||
}
|
|
||||||
|
if (currentList) {
|
||||||
|
return currentList
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
const addedEventsFromSnapshot = snapshotProvider.validatorAddedEvents(blockNumber)
|
const addedEventsFromSnapshot = snapshotProvider.validatorAddedEvents(blockNumber)
|
||||||
const removedEventsFromSnapshot = snapshotProvider.validatorRemovedEvents(blockNumber)
|
const removedEventsFromSnapshot = snapshotProvider.validatorRemovedEvents(blockNumber)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user