fix: rename nonce instructions with VerbNoun scheme

This commit is contained in:
Trent Nelson
2020-01-13 15:31:02 -07:00
committed by Michael Vines
parent fc007b02ae
commit cca9c5d922
2 changed files with 12 additions and 12 deletions

View File

@ -67,7 +67,7 @@ export class SystemInstruction extends TransactionInstruction {
if ( if (
this.type == SystemInstructionLayout.Create || this.type == SystemInstructionLayout.Create ||
this.type == SystemInstructionLayout.CreateWithSeed || this.type == SystemInstructionLayout.CreateWithSeed ||
this.type == SystemInstructionLayout.NonceWithdraw || this.type == SystemInstructionLayout.WithdrawNonceAccount ||
this.type == SystemInstructionLayout.Transfer this.type == SystemInstructionLayout.Transfer
) { ) {
return this.keys[0].pubkey; return this.keys[0].pubkey;
@ -83,7 +83,7 @@ export class SystemInstruction extends TransactionInstruction {
if ( if (
this.type == SystemInstructionLayout.Create || this.type == SystemInstructionLayout.Create ||
this.type == SystemInstructionLayout.CreateWithSeed || this.type == SystemInstructionLayout.CreateWithSeed ||
this.type == SystemInstructionLayout.NonceWithdraw || this.type == SystemInstructionLayout.WithdrawNonceAccount ||
this.type == SystemInstructionLayout.Transfer this.type == SystemInstructionLayout.Transfer
) { ) {
return this.keys[1].pubkey; return this.keys[1].pubkey;
@ -100,7 +100,7 @@ export class SystemInstruction extends TransactionInstruction {
if ( if (
this.type == SystemInstructionLayout.Create || this.type == SystemInstructionLayout.Create ||
this.type == SystemInstructionLayout.CreateWithSeed || this.type == SystemInstructionLayout.CreateWithSeed ||
this.type == SystemInstructionLayout.NonceWithdraw || this.type == SystemInstructionLayout.WithdrawNonceAccount ||
this.type == SystemInstructionLayout.Transfer this.type == SystemInstructionLayout.Transfer
) { ) {
return data.lamports; return data.lamports;
@ -147,25 +147,25 @@ const SystemInstructionLayout = Object.freeze({
Layout.publicKey('programId'), Layout.publicKey('programId'),
]), ]),
}, },
NonceAdvance: { AdvanceNonceAccount: {
index: 4, index: 4,
layout: BufferLayout.struct([BufferLayout.u32('instruction')]), layout: BufferLayout.struct([BufferLayout.u32('instruction')]),
}, },
NonceWithdraw: { WithdrawNonceAccount: {
index: 5, index: 5,
layout: BufferLayout.struct([ layout: BufferLayout.struct([
BufferLayout.u32('instruction'), BufferLayout.u32('instruction'),
BufferLayout.ns64('lamports'), BufferLayout.ns64('lamports'),
]), ]),
}, },
NonceInitialize: { InitializeNonceAccount: {
index: 6, index: 6,
layout: BufferLayout.struct([ layout: BufferLayout.struct([
BufferLayout.u32('instruction'), BufferLayout.u32('instruction'),
Layout.publicKey('authorized'), Layout.publicKey('authorized'),
]), ]),
}, },
NonceAuthorize: { AuthorizeNonceAccount: {
index: 7, index: 7,
layout: BufferLayout.struct([ layout: BufferLayout.struct([
BufferLayout.u32('instruction'), BufferLayout.u32('instruction'),
@ -305,7 +305,7 @@ export class SystemProgram {
this.programId, this.programId,
); );
const type = SystemInstructionLayout.NonceInitialize; const type = SystemInstructionLayout.InitializeNonceAccount;
const data = encodeData(type, { const data = encodeData(type, {
authorized: authorizedPubkey.toBuffer(), authorized: authorizedPubkey.toBuffer(),
}); });
@ -332,7 +332,7 @@ export class SystemProgram {
nonceAccount: PublicKey, nonceAccount: PublicKey,
authorizedPubkey: PublicKey, authorizedPubkey: PublicKey,
): TransactionInstruction { ): TransactionInstruction {
const type = SystemInstructionLayout.NonceAdvance; const type = SystemInstructionLayout.AdvanceNonceAccount;
const data = encodeData(type); const data = encodeData(type);
const instructionData = { const instructionData = {
keys: [ keys: [
@ -359,7 +359,7 @@ export class SystemProgram {
to: PublicKey, to: PublicKey,
lamports: number, lamports: number,
): Transaction { ): Transaction {
const type = SystemInstructionLayout.NonceWithdraw; const type = SystemInstructionLayout.WithdrawNonceAccount;
const data = encodeData(type, {lamports}); const data = encodeData(type, {lamports});
return new Transaction().add({ return new Transaction().add({
@ -392,7 +392,7 @@ export class SystemProgram {
authorizedPubkey: PublicKey, authorizedPubkey: PublicKey,
newAuthorized: PublicKey, newAuthorized: PublicKey,
): Transaction { ): Transaction {
const type = SystemInstructionLayout.NonceAuthorize; const type = SystemInstructionLayout.AuthorizeNonceAccount;
const data = encodeData(type, { const data = encodeData(type, {
newAuthorized: newAuthorized.toBuffer(), newAuthorized: newAuthorized.toBuffer(),
}); });

View File

@ -105,7 +105,7 @@ type TransactionCtorFields = {|
* *
* @typedef {Object} NonceInformation * @typedef {Object} NonceInformation
* @property {nonce} The current Nonce blockhash * @property {nonce} The current Nonce blockhash
* @property {nonceInstruction} The NonceAdvance Instruction * @property {nonceInstruction} The AdvanceNonceAccount Instruction
*/ */
type NonceInformation = {| type NonceInformation = {|
nonce: Blockhash, nonce: Blockhash,