Fix generation of signatures from tx confirmations
This commit is contained in:
parent
c79df89e76
commit
88d0453168
|
@ -31,18 +31,27 @@ export const generateSignaturesFromTxConfirmations = (
|
|||
) => {
|
||||
// The constant parts need to be sorted so that the recovered signers are sorted ascending
|
||||
// (natural order) by address (not checksummed).
|
||||
let confirmedAdresses = confirmations.map((conf) => conf.owner.address)
|
||||
const confirmationsMap = confirmations.reduce((map, obj) => {
|
||||
map[obj.owner.address] = obj // eslint-disable-line no-param-reassign
|
||||
return map
|
||||
}, {})
|
||||
|
||||
if (preApprovingOwner) {
|
||||
confirmedAdresses = confirmedAdresses.push(preApprovingOwner)
|
||||
confirmationsMap[preApprovingOwner] = { owner: preApprovingOwner }
|
||||
}
|
||||
|
||||
let sigs = '0x'
|
||||
confirmedAdresses.sort().forEach((addr) => {
|
||||
Object.keys(confirmationsMap).sort().forEach((addr) => {
|
||||
const conf = confirmationsMap[addr]
|
||||
if (conf.signature) {
|
||||
sigs += conf.signature.slice(2)
|
||||
} else {
|
||||
// https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures
|
||||
sigs += `000000000000000000000000${addr.replace(
|
||||
'0x',
|
||||
'',
|
||||
)}000000000000000000000000000000000000000000000000000000000000000001`
|
||||
}
|
||||
})
|
||||
return sigs
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue