s/move/transfer in system program to match solana

This commit is contained in:
Tyera Eulberg 2019-04-11 18:20:22 -07:00 committed by Michael Vines
parent 7f02185998
commit c1bbb9b291
6 changed files with 19 additions and 19 deletions

View File

@ -69,7 +69,7 @@ showBalance()
.then(airDrop)
.then(() => {
console.log(`\n== Move 1 lamport to approver1`);
const transaction = solanaWeb3.SystemProgram.move(
const transaction = solanaWeb3.SystemProgram.transfer(
account1.publicKey,
approver1.publicKey,
1,
@ -79,7 +79,7 @@ showBalance()
.then(confirmTransaction)
.then(() => {
console.log(`\n== Move 1 lamport to approver2`);
const transaction = solanaWeb3.SystemProgram.move(
const transaction = solanaWeb3.SystemProgram.transfer(
account1.publicKey,
approver2.publicKey,
1,

View File

@ -102,7 +102,7 @@ declare module '@solana/web3.js' {
space: number,
programId: PublicKey,
): Transaction;
static move(from: PublicKey, to: PublicKey, amount: number): Transaction;
static transfer(from: PublicKey, to: PublicKey, amount: number): Transaction;
static assign(from: PublicKey, programId: PublicKey): Transaction;
}

View File

@ -58,9 +58,9 @@ export class SystemProgram {
}
/**
* Generate a Transaction that moves lamports from one account to another
* Generate a Transaction that transfers lamports from one account to another
*/
static move(from: PublicKey, to: PublicKey, amount: number): Transaction {
static transfer(from: PublicKey, to: PublicKey, amount: number): Transaction {
const dataLayout = BufferLayout.struct([
BufferLayout.u32('instruction'),
BufferLayout.ns64('amount'),

View File

@ -296,7 +296,7 @@ test('transaction', async () => {
},
]);
const transaction = SystemProgram.move(
const transaction = SystemProgram.transfer(
accountFrom.publicKey,
accountTo.publicKey,
10,
@ -390,11 +390,11 @@ test('multi-instruction transaction', async () => {
// 1. Move(accountFrom, accountTo)
// 2. Move(accountTo, accountFrom)
const transaction = SystemProgram.move(
const transaction = SystemProgram.transfer(
accountFrom.publicKey,
accountTo.publicKey,
10,
).add(SystemProgram.move(accountTo.publicKey, accountFrom.publicKey, 10));
).add(SystemProgram.transfer(accountTo.publicKey, accountFrom.publicKey, 10));
const signature = await connection.sendTransaction(
transaction,
accountFrom,

View File

@ -20,12 +20,12 @@ test('createAccount', () => {
// TODO: Validate transaction contents more
});
test('move', () => {
test('transfer', () => {
const from = new Account();
const to = new Account();
let transaction;
transaction = SystemProgram.move(from.publicKey, to.publicKey, 123);
transaction = SystemProgram.transfer(from.publicKey, to.publicKey, 123);
expect(transaction.keys).toHaveLength(2);
expect(transaction.programId).toEqual(SystemProgram.programId);

View File

@ -10,12 +10,12 @@ test('signPartial', () => {
const account1 = new Account();
const account2 = new Account();
const recentBlockhash = account1.publicKey.toBase58(); // Fake recentBlockhash
const move = SystemProgram.move(account1.publicKey, account2.publicKey, 123);
const transfer = SystemProgram.transfer(account1.publicKey, account2.publicKey, 123);
const transaction = new Transaction({recentBlockhash}).add(move);
const transaction = new Transaction({recentBlockhash}).add(transfer);
transaction.sign(account1, account2);
const partialTransaction = new Transaction({recentBlockhash}).add(move);
const partialTransaction = new Transaction({recentBlockhash}).add(transfer);
partialTransaction.signPartial(account1, account2.publicKey);
expect(partialTransaction.signatures[1].signature).toBeNull();
partialTransaction.addSigner(account2);
@ -27,16 +27,16 @@ test('transfer signatures', () => {
const account1 = new Account();
const account2 = new Account();
const recentBlockhash = account1.publicKey.toBase58(); // Fake recentBlockhash
const move1 = SystemProgram.move(account1.publicKey, account2.publicKey, 123);
const move2 = SystemProgram.move(account2.publicKey, account1.publicKey, 123);
const transfer1 = SystemProgram.transfer(account1.publicKey, account2.publicKey, 123);
const transfer2 = SystemProgram.transfer(account2.publicKey, account1.publicKey, 123);
const orgTransaction = new Transaction({recentBlockhash}).add(move1, move2);
const orgTransaction = new Transaction({recentBlockhash}).add(transfer1, transfer2);
orgTransaction.sign(account1, account2);
const newTransaction = new Transaction({
recentBlockhash: orgTransaction.recentBlockhash,
signatures: orgTransaction.signatures,
}).add(move1, move2);
}).add(transfer1, transfer2);
expect(newTransaction).toEqual(orgTransaction);
});
@ -50,8 +50,8 @@ test('parse wire format and serialize', () => {
const recipient = new PublicKey(
'J3dxNj7nDRRqRRXuEMynDG57DkZK4jYRuv3Garmb1i99',
); // Arbitrary known public key
const move = SystemProgram.move(sender.publicKey, recipient, 49);
const expectedTransaction = new Transaction({recentBlockhash}).add(move);
const transfer = SystemProgram.transfer(sender.publicKey, recipient, 49);
const expectedTransaction = new Transaction({recentBlockhash}).add(transfer);
expectedTransaction.sign(sender);
const wireTransaction = Buffer.from([