fix: catchup to upstream loader changes

This commit is contained in:
Michael Vines
2018-10-18 14:29:57 -07:00
parent 00fd0fc435
commit 757cf3ec16
4 changed files with 32 additions and 4 deletions

View File

@ -105,4 +105,28 @@ export class SystemProgram {
userdata,
});
}
/**
* Spawn a new program from an account
*/
static spawn(programId: PublicKey): Transaction {
const userdataLayout = BufferLayout.struct([
BufferLayout.u32('instruction'),
]);
const userdata = Buffer.alloc(userdataLayout.span);
userdataLayout.encode(
{
instruction: 3, // Spawn instruction
},
userdata,
);
return new Transaction({
fee: 0,
keys: [programId],
programId: SystemProgram.programId,
userdata,
});
}
}