From 41865547ee2ca647a3e3c1933fc27b2dcc84abde Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 14 Feb 2019 22:04:13 -0800 Subject: [PATCH] fix: remove spawn --- web3.js/module.flow.js | 2 - web3.js/src/connection.js | 6 - web3.js/src/loader.js | 6 +- web3.js/src/system-program.js | 23 --- web3.js/test/connection.test.js | 34 ----- web3.js/test/token-program.test.js | 238 ----------------------------- 6 files changed, 1 insertion(+), 308 deletions(-) diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 968b3fc524..d57c92a758 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -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 === diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index 14b3aba629..aa03a94017 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -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 { - // 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), diff --git a/web3.js/src/loader.js b/web3.js/src/loader.js index 5c93f4388a..9b3706c592 100644 --- a/web3.js/src/loader.js +++ b/web3.js/src/loader.js @@ -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); } } diff --git a/web3.js/src/system-program.js b/web3.js/src/system-program.js index 0e5fa59c85..3c3121ab49 100644 --- a/web3.js/src/system-program.js +++ b/web3.js/src/system-program.js @@ -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, - }); - } } diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.js index b782d8884b..8f5bebb08e 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.js @@ -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, - ], }, }, ]); diff --git a/web3.js/test/token-program.test.js b/web3.js/test/token-program.test.js index bdd9149ba5..77ac7e8be5 100644 --- a/web3.js/test/token-program.test.js +++ b/web3.js/test/token-program.test.js @@ -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, - ], }, }, ]);