Order signatures by address

This commit is contained in:
apanizo 2018-10-05 17:33:10 +02:00
parent a20f1a1568
commit 98a402ae75
1 changed files with 7 additions and 3 deletions

View File

@ -1,13 +1,17 @@
// @flow
import { List } from 'immutable'
const generateSignatureFrom = (account: string) =>
`000000000000000000000000${account.replace('0x', '')}000000000000000000000000000000000000000000000000000000000000000001`
export const buildSignaturesFrom = (ownersWhoHasSigned: string[], sender: string) => {
export const buildSignaturesFrom = (ownersWhoHasSigned: List<string>, sender: string) => {
const signatures = ownersWhoHasSigned.push(sender)
const orderedSignatures = signatures.sortBy(signature => signature)
let sigs = '0x'
ownersWhoHasSigned.forEach((owner: string) => {
orderedSignatures.forEach((owner: string) => {
sigs += generateSignatureFrom(owner)
})
sigs += generateSignatureFrom(sender)
return sigs
}