solana-web3: add TransferWithSeed implementation (#14570)
* fix: add handling for TransferWithSeed system instruction * chore: add failing Assign/AllocateWithSeed test * fix: broken Allocate/AssignWithSeed methods
This commit is contained in:
17
web3.js/module.d.ts
vendored
17
web3.js/module.d.ts
vendored
@ -891,6 +891,15 @@ declare module '@solana/web3.js' {
|
|||||||
lamports: number;
|
lamports: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TransferWithSeedParams = {
|
||||||
|
fromPubkey: PublicKey;
|
||||||
|
basePubkey: PublicKey;
|
||||||
|
toPubkey: PublicKey;
|
||||||
|
lamports: number;
|
||||||
|
seed: string;
|
||||||
|
programId: PublicKey;
|
||||||
|
};
|
||||||
|
|
||||||
export type CreateNonceAccountParams = {
|
export type CreateNonceAccountParams = {
|
||||||
fromPubkey: PublicKey;
|
fromPubkey: PublicKey;
|
||||||
noncePubkey: PublicKey;
|
noncePubkey: PublicKey;
|
||||||
@ -943,7 +952,9 @@ declare module '@solana/web3.js' {
|
|||||||
static assign(
|
static assign(
|
||||||
params: AssignParams | AssignWithSeedParams,
|
params: AssignParams | AssignWithSeedParams,
|
||||||
): TransactionInstruction;
|
): TransactionInstruction;
|
||||||
static transfer(params: TransferParams): TransactionInstruction;
|
static transfer(
|
||||||
|
params: TransferParams | TransferWithSeedParams,
|
||||||
|
): TransactionInstruction;
|
||||||
static createNonceAccount(
|
static createNonceAccount(
|
||||||
params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams,
|
params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams,
|
||||||
): Transaction;
|
): Transaction;
|
||||||
@ -960,6 +971,7 @@ declare module '@solana/web3.js' {
|
|||||||
| 'Assign'
|
| 'Assign'
|
||||||
| 'AssignWithSeed'
|
| 'AssignWithSeed'
|
||||||
| 'Transfer'
|
| 'Transfer'
|
||||||
|
| 'TransferWithSeed'
|
||||||
| 'AdvanceNonceAccount'
|
| 'AdvanceNonceAccount'
|
||||||
| 'WithdrawNonceAccount'
|
| 'WithdrawNonceAccount'
|
||||||
| 'InitializeNonceAccount'
|
| 'InitializeNonceAccount'
|
||||||
@ -988,6 +1000,9 @@ declare module '@solana/web3.js' {
|
|||||||
instruction: TransactionInstruction,
|
instruction: TransactionInstruction,
|
||||||
): AssignWithSeedParams;
|
): AssignWithSeedParams;
|
||||||
static decodeTransfer(instruction: TransactionInstruction): TransferParams;
|
static decodeTransfer(instruction: TransactionInstruction): TransferParams;
|
||||||
|
static decodeTransferWithSeed(
|
||||||
|
instruction: TransactionInstruction,
|
||||||
|
): TransferWithSeedParams;
|
||||||
static decodeNonceInitialize(
|
static decodeNonceInitialize(
|
||||||
instruction: TransactionInstruction,
|
instruction: TransactionInstruction,
|
||||||
): InitializeNonceParams;
|
): InitializeNonceParams;
|
||||||
|
@ -899,6 +899,15 @@ declare module '@solana/web3.js' {
|
|||||||
lamports: number,
|
lamports: number,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
|
declare export type TransferWithSeedParams = {|
|
||||||
|
fromPubkey: PublicKey,
|
||||||
|
basePubkey: PublicKey,
|
||||||
|
toPubkey: PublicKey,
|
||||||
|
lamports: number,
|
||||||
|
seed: string,
|
||||||
|
programId: PublicKey,
|
||||||
|
|};
|
||||||
|
|
||||||
declare export type CreateNonceAccountParams = {|
|
declare export type CreateNonceAccountParams = {|
|
||||||
fromPubkey: PublicKey,
|
fromPubkey: PublicKey,
|
||||||
noncePubkey: PublicKey,
|
noncePubkey: PublicKey,
|
||||||
@ -951,7 +960,9 @@ declare module '@solana/web3.js' {
|
|||||||
static assign(
|
static assign(
|
||||||
params: AssignParams | AssignWithSeedParams,
|
params: AssignParams | AssignWithSeedParams,
|
||||||
): TransactionInstruction;
|
): TransactionInstruction;
|
||||||
static transfer(params: TransferParams): TransactionInstruction;
|
static transfer(
|
||||||
|
params: TransferParams | TransferWithSeedParams,
|
||||||
|
): TransactionInstruction;
|
||||||
static createNonceAccount(
|
static createNonceAccount(
|
||||||
params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams,
|
params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams,
|
||||||
): Transaction;
|
): Transaction;
|
||||||
@ -968,6 +979,7 @@ declare module '@solana/web3.js' {
|
|||||||
| 'Assign'
|
| 'Assign'
|
||||||
| 'AssignWithSeed'
|
| 'AssignWithSeed'
|
||||||
| 'Transfer'
|
| 'Transfer'
|
||||||
|
| 'TransferWithSeed'
|
||||||
| 'AdvanceNonceAccount'
|
| 'AdvanceNonceAccount'
|
||||||
| 'WithdrawNonceAccount'
|
| 'WithdrawNonceAccount'
|
||||||
| 'InitializeNonceAccount'
|
| 'InitializeNonceAccount'
|
||||||
@ -996,6 +1008,9 @@ declare module '@solana/web3.js' {
|
|||||||
instruction: TransactionInstruction,
|
instruction: TransactionInstruction,
|
||||||
): AssignWithSeedParams;
|
): AssignWithSeedParams;
|
||||||
static decodeTransfer(instruction: TransactionInstruction): TransferParams;
|
static decodeTransfer(instruction: TransactionInstruction): TransferParams;
|
||||||
|
static decodeTransferWithSeed(
|
||||||
|
instruction: TransactionInstruction,
|
||||||
|
): TransferWithSeedParams;
|
||||||
static decodeNonceInitialize(
|
static decodeNonceInitialize(
|
||||||
instruction: TransactionInstruction,
|
instruction: TransactionInstruction,
|
||||||
): InitializeNonceParams;
|
): InitializeNonceParams;
|
||||||
|
@ -198,6 +198,23 @@ export type AssignWithSeedParams = {|
|
|||||||
programId: PublicKey,
|
programId: PublicKey,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfer with seed system transaction params
|
||||||
|
* @typedef {Object} TransferWithSeedParams
|
||||||
|
* @property {PublicKey} accountPubkey
|
||||||
|
* @property {PublicKey} basePubkey
|
||||||
|
* @property {string} seed
|
||||||
|
* @property {PublicKey} programId
|
||||||
|
*/
|
||||||
|
export type TransferWithSeedParams = {|
|
||||||
|
fromPubkey: PublicKey,
|
||||||
|
basePubkey: PublicKey,
|
||||||
|
toPubkey: PublicKey,
|
||||||
|
lamports: number,
|
||||||
|
seed: string,
|
||||||
|
programId: PublicKey,
|
||||||
|
|};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System Instruction class
|
* System Instruction class
|
||||||
*/
|
*/
|
||||||
@ -269,6 +286,30 @@ export class SystemInstruction {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode a transfer with seed system instruction and retrieve the instruction params.
|
||||||
|
*/
|
||||||
|
static decodeTransferWithSeed(
|
||||||
|
instruction: TransactionInstruction,
|
||||||
|
): TransferWithSeedParams {
|
||||||
|
this.checkProgramId(instruction.programId);
|
||||||
|
this.checkKeyLength(instruction.keys, 3);
|
||||||
|
|
||||||
|
const {lamports, seed, programId} = decodeData(
|
||||||
|
SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed,
|
||||||
|
instruction.data,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
fromPubkey: instruction.keys[0].pubkey,
|
||||||
|
basePubkey: instruction.keys[1].pubkey,
|
||||||
|
toPubkey: instruction.keys[2].pubkey,
|
||||||
|
lamports,
|
||||||
|
seed,
|
||||||
|
programId: new PublicKey(programId),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode an allocate system instruction and retrieve the instruction params.
|
* Decode an allocate system instruction and retrieve the instruction params.
|
||||||
*/
|
*/
|
||||||
@ -576,6 +617,15 @@ export const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|||||||
Layout.publicKey('programId'),
|
Layout.publicKey('programId'),
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
|
TransferWithSeed: {
|
||||||
|
index: 11,
|
||||||
|
layout: BufferLayout.struct([
|
||||||
|
BufferLayout.u32('instruction'),
|
||||||
|
BufferLayout.ns64('lamports'),
|
||||||
|
Layout.rustString('seed'),
|
||||||
|
Layout.publicKey('programId'),
|
||||||
|
]),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -613,15 +663,34 @@ export class SystemProgram {
|
|||||||
/**
|
/**
|
||||||
* Generate a transaction instruction that transfers lamports from one account to another
|
* Generate a transaction instruction that transfers lamports from one account to another
|
||||||
*/
|
*/
|
||||||
static transfer(params: TransferParams): TransactionInstruction {
|
static transfer(
|
||||||
|
params: TransferParams | TransferWithSeedParams,
|
||||||
|
): TransactionInstruction {
|
||||||
|
let data;
|
||||||
|
let keys;
|
||||||
|
if (params.basePubkey) {
|
||||||
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
|
||||||
|
data = encodeData(type, {
|
||||||
|
lamports: params.lamports,
|
||||||
|
seed: params.seed,
|
||||||
|
programId: params.programId.toBuffer(),
|
||||||
|
});
|
||||||
|
keys = [
|
||||||
|
{pubkey: params.fromPubkey, isSigner: false, isWritable: true},
|
||||||
|
{pubkey: params.basePubkey, isSigner: true, isWritable: false},
|
||||||
|
{pubkey: params.toPubkey, isSigner: false, isWritable: true},
|
||||||
|
];
|
||||||
|
} else {
|
||||||
const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
|
||||||
const data = encodeData(type, {lamports: params.lamports});
|
data = encodeData(type, {lamports: params.lamports});
|
||||||
|
keys = [
|
||||||
return new TransactionInstruction({
|
|
||||||
keys: [
|
|
||||||
{pubkey: params.fromPubkey, isSigner: true, isWritable: true},
|
{pubkey: params.fromPubkey, isSigner: true, isWritable: true},
|
||||||
{pubkey: params.toPubkey, isSigner: false, isWritable: true},
|
{pubkey: params.toPubkey, isSigner: false, isWritable: true},
|
||||||
],
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TransactionInstruction({
|
||||||
|
keys,
|
||||||
programId: this.programId,
|
programId: this.programId,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
@ -634,6 +703,7 @@ export class SystemProgram {
|
|||||||
params: AssignParams | AssignWithSeedParams,
|
params: AssignParams | AssignWithSeedParams,
|
||||||
): TransactionInstruction {
|
): TransactionInstruction {
|
||||||
let data;
|
let data;
|
||||||
|
let keys;
|
||||||
if (params.basePubkey) {
|
if (params.basePubkey) {
|
||||||
const type = SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed;
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed;
|
||||||
data = encodeData(type, {
|
data = encodeData(type, {
|
||||||
@ -641,13 +711,18 @@ export class SystemProgram {
|
|||||||
seed: params.seed,
|
seed: params.seed,
|
||||||
programId: params.programId.toBuffer(),
|
programId: params.programId.toBuffer(),
|
||||||
});
|
});
|
||||||
|
keys = [
|
||||||
|
{pubkey: params.accountPubkey, isSigner: false, isWritable: true},
|
||||||
|
{pubkey: params.basePubkey, isSigner: true, isWritable: false},
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
const type = SYSTEM_INSTRUCTION_LAYOUTS.Assign;
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Assign;
|
||||||
data = encodeData(type, {programId: params.programId.toBuffer()});
|
data = encodeData(type, {programId: params.programId.toBuffer()});
|
||||||
|
keys = [{pubkey: params.accountPubkey, isSigner: true, isWritable: true}];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TransactionInstruction({
|
return new TransactionInstruction({
|
||||||
keys: [{pubkey: params.accountPubkey, isSigner: true, isWritable: true}],
|
keys,
|
||||||
programId: this.programId,
|
programId: this.programId,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
@ -822,6 +897,7 @@ export class SystemProgram {
|
|||||||
params: AllocateParams | AllocateWithSeedParams,
|
params: AllocateParams | AllocateWithSeedParams,
|
||||||
): TransactionInstruction {
|
): TransactionInstruction {
|
||||||
let data;
|
let data;
|
||||||
|
let keys;
|
||||||
if (params.basePubkey) {
|
if (params.basePubkey) {
|
||||||
const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;
|
||||||
data = encodeData(type, {
|
data = encodeData(type, {
|
||||||
@ -830,15 +906,20 @@ export class SystemProgram {
|
|||||||
space: params.space,
|
space: params.space,
|
||||||
programId: params.programId.toBuffer(),
|
programId: params.programId.toBuffer(),
|
||||||
});
|
});
|
||||||
|
keys = [
|
||||||
|
{pubkey: params.accountPubkey, isSigner: false, isWritable: true},
|
||||||
|
{pubkey: params.basePubkey, isSigner: true, isWritable: false},
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
const type = SYSTEM_INSTRUCTION_LAYOUTS.Allocate;
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Allocate;
|
||||||
data = encodeData(type, {
|
data = encodeData(type, {
|
||||||
space: params.space,
|
space: params.space,
|
||||||
});
|
});
|
||||||
|
keys = [{pubkey: params.accountPubkey, isSigner: true, isWritable: true}];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TransactionInstruction({
|
return new TransactionInstruction({
|
||||||
keys: [{pubkey: params.accountPubkey, isSigner: true, isWritable: true}],
|
keys,
|
||||||
programId: this.programId,
|
programId: this.programId,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import {
|
import {
|
||||||
Account,
|
Account,
|
||||||
Connection,
|
Connection,
|
||||||
|
PublicKey,
|
||||||
StakeProgram,
|
StakeProgram,
|
||||||
SystemInstruction,
|
SystemInstruction,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
@ -52,6 +53,23 @@ test('transfer', () => {
|
|||||||
expect(params).toEqual(SystemInstruction.decodeTransfer(systemInstruction));
|
expect(params).toEqual(SystemInstruction.decodeTransfer(systemInstruction));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('transferWithSeed', () => {
|
||||||
|
const params = {
|
||||||
|
fromPubkey: new Account().publicKey,
|
||||||
|
basePubkey: new Account().publicKey,
|
||||||
|
toPubkey: new Account().publicKey,
|
||||||
|
lamports: 123,
|
||||||
|
seed: '你好',
|
||||||
|
programId: new Account().publicKey,
|
||||||
|
};
|
||||||
|
const transaction = new Transaction().add(SystemProgram.transfer(params));
|
||||||
|
expect(transaction.instructions).toHaveLength(1);
|
||||||
|
const [systemInstruction] = transaction.instructions;
|
||||||
|
expect(params).toEqual(
|
||||||
|
SystemInstruction.decodeTransferWithSeed(systemInstruction),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('allocate', () => {
|
test('allocate', () => {
|
||||||
const params = {
|
const params = {
|
||||||
accountPubkey: new Account().publicKey,
|
accountPubkey: new Account().publicKey,
|
||||||
@ -402,3 +420,154 @@ test('live Nonce actions', async () => {
|
|||||||
);
|
);
|
||||||
expect(withdrawBalance).toEqual(minimumAmount);
|
expect(withdrawBalance).toEqual(minimumAmount);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('live withSeed actions', async () => {
|
||||||
|
if (mockRpcEnabled) {
|
||||||
|
console.log('non-live test skipped');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const connection = new Connection(url, 'singleGossip');
|
||||||
|
const baseAccount = await newAccountWithLamports(
|
||||||
|
connection,
|
||||||
|
2 * LAMPORTS_PER_SOL,
|
||||||
|
);
|
||||||
|
const basePubkey = baseAccount.publicKey;
|
||||||
|
const seed = 'hi there';
|
||||||
|
const programId = new Account().publicKey;
|
||||||
|
const createAccountWithSeedAddress = await PublicKey.createWithSeed(
|
||||||
|
basePubkey,
|
||||||
|
seed,
|
||||||
|
programId,
|
||||||
|
);
|
||||||
|
const space = 0;
|
||||||
|
|
||||||
|
const minimumAmount = await connection.getMinimumBalanceForRentExemption(
|
||||||
|
space,
|
||||||
|
);
|
||||||
|
|
||||||
|
const createAccountWithSeedParams = {
|
||||||
|
fromPubkey: basePubkey,
|
||||||
|
newAccountPubkey: createAccountWithSeedAddress,
|
||||||
|
basePubkey,
|
||||||
|
seed,
|
||||||
|
lamports: minimumAmount,
|
||||||
|
space,
|
||||||
|
programId,
|
||||||
|
};
|
||||||
|
const createAccountWithSeedTransaction = new Transaction().add(
|
||||||
|
SystemProgram.createAccountWithSeed(createAccountWithSeedParams),
|
||||||
|
);
|
||||||
|
await sendAndConfirmTransaction(
|
||||||
|
connection,
|
||||||
|
createAccountWithSeedTransaction,
|
||||||
|
[baseAccount],
|
||||||
|
{commitment: 'singleGossip', preflightCommitment: 'singleGossip'},
|
||||||
|
);
|
||||||
|
const createAccountWithSeedBalance = await connection.getBalance(
|
||||||
|
createAccountWithSeedAddress,
|
||||||
|
);
|
||||||
|
expect(createAccountWithSeedBalance).toEqual(minimumAmount);
|
||||||
|
|
||||||
|
// Transfer to a derived address
|
||||||
|
const programId2 = new Account().publicKey;
|
||||||
|
const transferWithSeedAddress = await PublicKey.createWithSeed(
|
||||||
|
basePubkey,
|
||||||
|
seed,
|
||||||
|
programId2,
|
||||||
|
);
|
||||||
|
await sendAndConfirmTransaction(
|
||||||
|
connection,
|
||||||
|
new Transaction().add(
|
||||||
|
SystemProgram.transfer({
|
||||||
|
fromPubkey: baseAccount.publicKey,
|
||||||
|
toPubkey: transferWithSeedAddress,
|
||||||
|
lamports: 3 * minimumAmount,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
[baseAccount],
|
||||||
|
{commitment: 'singleGossip', preflightCommitment: 'singleGossip'},
|
||||||
|
);
|
||||||
|
let transferWithSeedAddressBalance = await connection.getBalance(
|
||||||
|
transferWithSeedAddress,
|
||||||
|
);
|
||||||
|
expect(transferWithSeedAddressBalance).toEqual(3 * minimumAmount);
|
||||||
|
|
||||||
|
// Test TransferWithSeed
|
||||||
|
const programId3 = new Account();
|
||||||
|
const toPubkey = await PublicKey.createWithSeed(
|
||||||
|
basePubkey,
|
||||||
|
seed,
|
||||||
|
programId3.publicKey,
|
||||||
|
);
|
||||||
|
const transferWithSeedParams = {
|
||||||
|
fromPubkey: transferWithSeedAddress,
|
||||||
|
basePubkey,
|
||||||
|
toPubkey,
|
||||||
|
lamports: 2 * minimumAmount,
|
||||||
|
seed,
|
||||||
|
programId: programId2,
|
||||||
|
};
|
||||||
|
const transferWithSeedTransaction = new Transaction().add(
|
||||||
|
SystemProgram.transfer(transferWithSeedParams),
|
||||||
|
);
|
||||||
|
await sendAndConfirmTransaction(
|
||||||
|
connection,
|
||||||
|
transferWithSeedTransaction,
|
||||||
|
[baseAccount],
|
||||||
|
{commitment: 'singleGossip', preflightCommitment: 'singleGossip'},
|
||||||
|
);
|
||||||
|
const toBalance = await connection.getBalance(toPubkey);
|
||||||
|
expect(toBalance).toEqual(2 * minimumAmount);
|
||||||
|
transferWithSeedAddressBalance = await connection.getBalance(
|
||||||
|
createAccountWithSeedAddress,
|
||||||
|
);
|
||||||
|
expect(transferWithSeedAddressBalance).toEqual(minimumAmount);
|
||||||
|
|
||||||
|
// Test AllocateWithSeed
|
||||||
|
const allocateWithSeedParams = {
|
||||||
|
accountPubkey: toPubkey,
|
||||||
|
basePubkey,
|
||||||
|
seed,
|
||||||
|
space: 10,
|
||||||
|
programId: programId3.publicKey,
|
||||||
|
};
|
||||||
|
const allocateWithSeedTransaction = new Transaction().add(
|
||||||
|
SystemProgram.allocate(allocateWithSeedParams),
|
||||||
|
);
|
||||||
|
await sendAndConfirmTransaction(
|
||||||
|
connection,
|
||||||
|
allocateWithSeedTransaction,
|
||||||
|
[baseAccount],
|
||||||
|
{commitment: 'singleGossip', preflightCommitment: 'singleGossip'},
|
||||||
|
);
|
||||||
|
let account = await connection.getAccountInfo(toPubkey);
|
||||||
|
if (account === null) {
|
||||||
|
expect(account).not.toBeNull();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
expect(account.data).toHaveLength(10);
|
||||||
|
|
||||||
|
// Test AssignWithSeed
|
||||||
|
const assignWithSeedParams = {
|
||||||
|
accountPubkey: toPubkey,
|
||||||
|
basePubkey,
|
||||||
|
seed,
|
||||||
|
programId: programId3.publicKey,
|
||||||
|
};
|
||||||
|
const assignWithSeedTransaction = new Transaction().add(
|
||||||
|
SystemProgram.assign(assignWithSeedParams),
|
||||||
|
);
|
||||||
|
await sendAndConfirmTransaction(
|
||||||
|
connection,
|
||||||
|
assignWithSeedTransaction,
|
||||||
|
[baseAccount],
|
||||||
|
{commitment: 'singleGossip', preflightCommitment: 'singleGossip'},
|
||||||
|
);
|
||||||
|
account = await connection.getAccountInfo(toPubkey);
|
||||||
|
if (account === null) {
|
||||||
|
expect(account).not.toBeNull();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
expect(account.owner).toEqual(programId3.publicKey);
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user