feat: add stake program methods; refactor instruction type handling

This commit is contained in:
Tyera Eulberg
2019-12-23 11:46:49 -07:00
committed by Michael Vines
parent fc77e55920
commit 532b28e96e
16 changed files with 602 additions and 48 deletions

View File

@@ -80,8 +80,16 @@ export class PublicKey {
/**
* Derive a public key from another key, a seed, and a programId.
*/
static createWithSeed(fromPublicKey: PublicKey, seed: string, programId: PublicKey): PublicKey {
const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()])
static createWithSeed(
fromPublicKey: PublicKey,
seed: string,
programId: PublicKey,
): PublicKey {
const buffer = Buffer.concat([
fromPublicKey.toBuffer(),
Buffer.from(seed),
programId.toBuffer(),
]);
const hash = hasha(buffer, {algorithm: 'sha256'});
return new PublicKey('0x' + hash);
}