drainRaceStatus = {
const faucetAddress = createActorStatus.waitResponse.ReturnDec.IDAddress
if (drainRaceButton) {
const start = Date.now()
console.log('Drain race started')
yield {
invoking: true,
start
}
const balances = await getBalances([faucetAddress])
const faucetBalance = new FilecoinNumber(balances[0].balance, 'attofil')
console.log('Faucet balance:', faucetBalance.toFil())
yield {
invoking: true,
initialFaucetBalance: faucetBalance.toFil(),
start
}
const responsePromises = []
for (const key of keys) {
const message = {
To: faucetAddress,
From: key.address,
Nonce: 0,
Value: new FilecoinNumber(0, 'attofil'),
GasLimit: 1000000000,
GasFeeCap: new FilecoinNumber(0, 'attofil'),
GasPremium: new FilecoinNumber(0, 'attofil'),
Method: 2,
Params: cbor.encode([bigToBytes(faucetBalance)]).toString('base64')
}
const privateKey = key.privateKey
console.log('message', message)
responsePromises.push(filecoin_client.tx.sendMessage(
message,
privateKey,
true,
false
))
}
const responses = await Promise.all(responsePromises)
const waitStart = Date.now()
yield {
waiting: true,
start,
waitStart,
initialFaucetBalance: faucetBalance.toFil(),
responses
}
const promises = []
for (const response of responses) {
promises.push(client.stateWaitMsg(response, 0))
}
const waitResponses = await Promise.all(promises)
const decodedResults = []
for (const waitResponse of waitResponses) {
let decodedResult = null
if (waitResponse.Receipt && waitResponse.Receipt.Return) {
decodedResult = cbor.decodeAll(waitResponse.Receipt.Return, 'base64')
}
decodedResults.push(decodedResult)
}
yield { invoked: true, responses, waitResponses, decodedResults }
}
}