fix: remove spawn

This commit is contained in:
Michael Vines 2019-02-14 22:04:13 -08:00
parent 27c2a11635
commit 41865547ee
6 changed files with 1 additions and 308 deletions

View File

@ -35,7 +35,6 @@ declare module '@solana/web3.js' {
// === src/connection.js ===
declare export type AccountInfo = {
executable: boolean,
loader: PublicKey,
owner: PublicKey,
tokens: number,
userdata: Buffer,
@ -90,7 +89,6 @@ declare module '@solana/web3.js' {
): Transaction;
static move(from: PublicKey, to: PublicKey, amount: number): Transaction;
static assign(from: PublicKey, programId: PublicKey): Transaction;
static spawn(programId: PublicKey): Transaction;
}
// === src/transaction.js ===

View File

@ -82,7 +82,6 @@ function jsonRpcResult(resultDescription: any) {
*/
const AccountInfoResult = struct({
executable: 'boolean',
loader: 'array',
owner: 'array',
tokens: 'number',
userdata: 'array',
@ -151,12 +150,10 @@ const SendTransactionRpcResult = jsonRpcResult('string');
* @property {number} tokens Number of tokens assigned to the account
* @property {PublicKey} owner Identifier of the program that owns the account
* @property {?Buffer} userdata Optional userdata assigned to the account
* @property {PublicKey} loader Identifier of the loader for this account
* @property {boolean} executable `true` if this account's userdata contains a loaded program
*/
type AccountInfo = {
executable: boolean,
loader: PublicKey,
owner: PublicKey,
tokens: number,
userdata: Buffer,
@ -271,7 +268,6 @@ export class Connection {
return {
executable: result.executable,
loader: new PublicKey(result.loader),
owner: new PublicKey(result.owner),
tokens: result.tokens,
userdata: Buffer.from(result.userdata),
@ -431,7 +427,6 @@ export class Connection {
async sendRawTransaction(
rawTransaction: Buffer,
): Promise<TransactionSignature> {
// sendTransaction RPC API requires a u64 length field prepended to the raw
// Transaction bytes
const rpcTransaction = Buffer.alloc(8 + rawTransaction.length);
@ -494,7 +489,6 @@ export class Connection {
sub.callback({
executable: result.executable,
loader: new PublicKey(result.loader),
owner: new PublicKey(result.owner),
tokens: result.tokens,
userdata: Buffer.from(result.userdata),

View File

@ -4,7 +4,6 @@ import * as BufferLayout from 'buffer-layout';
import {Account} from './account';
import {PublicKey} from './publickey';
import {SystemProgram} from './system-program';
import {Transaction} from './transaction';
import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
import type {Connection} from './connection';
@ -115,14 +114,11 @@ export class Loader {
userdata,
);
const transaction = new Transaction();
transaction.add({
const transaction = new Transaction().add({
keys: [program.publicKey],
programId: this.programId,
userdata,
});
transaction.add(SystemProgram.spawn(program.publicKey));
await sendAndConfirmTransaction(this.connection, transaction, program);
}
}

View File

@ -103,27 +103,4 @@ 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().add({
keys: [programId],
programId: SystemProgram.programId,
userdata,
});
}
}

View File

@ -234,40 +234,6 @@ test('request airdrop', async () => {
tokens: 42,
userdata: [],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);

View File

@ -141,40 +141,6 @@ test('create new token', async () => {
84,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);
@ -246,40 +212,6 @@ test('create new token', async () => {
0,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);
@ -340,40 +272,6 @@ test('create new token account', async () => {
0,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);
@ -434,40 +332,6 @@ test('transfer', async () => {
0,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);
@ -508,40 +372,6 @@ test('transfer', async () => {
0,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);
@ -625,40 +455,6 @@ test('approve/revoke', async () => {
0,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);
@ -722,40 +518,6 @@ test('approve/revoke', async () => {
0,
],
executable: false,
loader: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
},
},
]);