fix: remove spawn
This commit is contained in:
parent
27c2a11635
commit
41865547ee
|
@ -35,7 +35,6 @@ declare module '@solana/web3.js' {
|
||||||
// === src/connection.js ===
|
// === src/connection.js ===
|
||||||
declare export type AccountInfo = {
|
declare export type AccountInfo = {
|
||||||
executable: boolean,
|
executable: boolean,
|
||||||
loader: PublicKey,
|
|
||||||
owner: PublicKey,
|
owner: PublicKey,
|
||||||
tokens: number,
|
tokens: number,
|
||||||
userdata: Buffer,
|
userdata: Buffer,
|
||||||
|
@ -90,7 +89,6 @@ declare module '@solana/web3.js' {
|
||||||
): Transaction;
|
): Transaction;
|
||||||
static move(from: PublicKey, to: PublicKey, amount: number): Transaction;
|
static move(from: PublicKey, to: PublicKey, amount: number): Transaction;
|
||||||
static assign(from: PublicKey, programId: PublicKey): Transaction;
|
static assign(from: PublicKey, programId: PublicKey): Transaction;
|
||||||
static spawn(programId: PublicKey): Transaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === src/transaction.js ===
|
// === src/transaction.js ===
|
||||||
|
|
|
@ -82,7 +82,6 @@ function jsonRpcResult(resultDescription: any) {
|
||||||
*/
|
*/
|
||||||
const AccountInfoResult = struct({
|
const AccountInfoResult = struct({
|
||||||
executable: 'boolean',
|
executable: 'boolean',
|
||||||
loader: 'array',
|
|
||||||
owner: 'array',
|
owner: 'array',
|
||||||
tokens: 'number',
|
tokens: 'number',
|
||||||
userdata: 'array',
|
userdata: 'array',
|
||||||
|
@ -151,12 +150,10 @@ const SendTransactionRpcResult = jsonRpcResult('string');
|
||||||
* @property {number} tokens Number of tokens assigned to the account
|
* @property {number} tokens Number of tokens assigned to the account
|
||||||
* @property {PublicKey} owner Identifier of the program that owns the account
|
* @property {PublicKey} owner Identifier of the program that owns the account
|
||||||
* @property {?Buffer} userdata Optional userdata assigned to 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
|
* @property {boolean} executable `true` if this account's userdata contains a loaded program
|
||||||
*/
|
*/
|
||||||
type AccountInfo = {
|
type AccountInfo = {
|
||||||
executable: boolean,
|
executable: boolean,
|
||||||
loader: PublicKey,
|
|
||||||
owner: PublicKey,
|
owner: PublicKey,
|
||||||
tokens: number,
|
tokens: number,
|
||||||
userdata: Buffer,
|
userdata: Buffer,
|
||||||
|
@ -271,7 +268,6 @@ export class Connection {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
executable: result.executable,
|
executable: result.executable,
|
||||||
loader: new PublicKey(result.loader),
|
|
||||||
owner: new PublicKey(result.owner),
|
owner: new PublicKey(result.owner),
|
||||||
tokens: result.tokens,
|
tokens: result.tokens,
|
||||||
userdata: Buffer.from(result.userdata),
|
userdata: Buffer.from(result.userdata),
|
||||||
|
@ -431,7 +427,6 @@ export class Connection {
|
||||||
async sendRawTransaction(
|
async sendRawTransaction(
|
||||||
rawTransaction: Buffer,
|
rawTransaction: Buffer,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
|
|
||||||
// sendTransaction RPC API requires a u64 length field prepended to the raw
|
// sendTransaction RPC API requires a u64 length field prepended to the raw
|
||||||
// Transaction bytes
|
// Transaction bytes
|
||||||
const rpcTransaction = Buffer.alloc(8 + rawTransaction.length);
|
const rpcTransaction = Buffer.alloc(8 + rawTransaction.length);
|
||||||
|
@ -494,7 +489,6 @@ export class Connection {
|
||||||
|
|
||||||
sub.callback({
|
sub.callback({
|
||||||
executable: result.executable,
|
executable: result.executable,
|
||||||
loader: new PublicKey(result.loader),
|
|
||||||
owner: new PublicKey(result.owner),
|
owner: new PublicKey(result.owner),
|
||||||
tokens: result.tokens,
|
tokens: result.tokens,
|
||||||
userdata: Buffer.from(result.userdata),
|
userdata: Buffer.from(result.userdata),
|
||||||
|
|
|
@ -4,7 +4,6 @@ import * as BufferLayout from 'buffer-layout';
|
||||||
|
|
||||||
import {Account} from './account';
|
import {Account} from './account';
|
||||||
import {PublicKey} from './publickey';
|
import {PublicKey} from './publickey';
|
||||||
import {SystemProgram} from './system-program';
|
|
||||||
import {Transaction} from './transaction';
|
import {Transaction} from './transaction';
|
||||||
import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
|
import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
|
||||||
import type {Connection} from './connection';
|
import type {Connection} from './connection';
|
||||||
|
@ -115,14 +114,11 @@ export class Loader {
|
||||||
userdata,
|
userdata,
|
||||||
);
|
);
|
||||||
|
|
||||||
const transaction = new Transaction();
|
const transaction = new Transaction().add({
|
||||||
|
|
||||||
transaction.add({
|
|
||||||
keys: [program.publicKey],
|
keys: [program.publicKey],
|
||||||
programId: this.programId,
|
programId: this.programId,
|
||||||
userdata,
|
userdata,
|
||||||
});
|
});
|
||||||
transaction.add(SystemProgram.spawn(program.publicKey));
|
|
||||||
await sendAndConfirmTransaction(this.connection, transaction, program);
|
await sendAndConfirmTransaction(this.connection, transaction, program);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,27 +103,4 @@ export class SystemProgram {
|
||||||
userdata,
|
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,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,40 +234,6 @@ test('request airdrop', async () => {
|
||||||
tokens: 42,
|
tokens: 42,
|
||||||
userdata: [],
|
userdata: [],
|
||||||
executable: false,
|
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,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -141,40 +141,6 @@ test('create new token', async () => {
|
||||||
84,
|
84,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
0,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
0,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
0,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
0,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
0,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
0,
|
||||||
],
|
],
|
||||||
executable: false,
|
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,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue