fix: ensure signatures are ordered correctly (#12165)

This commit is contained in:
Justin Starry
2020-09-13 09:30:51 +08:00
committed by GitHub
parent 555252f435
commit 4bb6c2fffb
4 changed files with 196 additions and 69 deletions

View File

@@ -83,6 +83,16 @@ export class Message {
);
}
findSignerIndex(signer: PublicKey): number {
const index = this.accountKeys.findIndex(accountKey => {
return accountKey.equals(signer);
});
if (index < 0) {
throw new Error(`unknown signer: ${signer.toString()}`);
}
return index;
}
serialize(): Buffer {
const numKeys = this.accountKeys.length;