feat: use base64 encoding when sending and simulating transactions (#12950)
This commit is contained in:
@ -2744,11 +2744,12 @@ export class Connection {
|
|||||||
|
|
||||||
const signData = transaction.serializeMessage();
|
const signData = transaction.serializeMessage();
|
||||||
const wireTransaction = transaction._serialize(signData);
|
const wireTransaction = transaction._serialize(signData);
|
||||||
const encodedTransaction = bs58.encode(wireTransaction);
|
const encodedTransaction = wireTransaction.toString('base64');
|
||||||
const args = [encodedTransaction];
|
const config: any = {encoding: 'base64'};
|
||||||
|
const args = [encodedTransaction, config];
|
||||||
|
|
||||||
if (signers) {
|
if (signers) {
|
||||||
args.push({sigVerify: true});
|
config.sigVerify = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsafeRes = await this._rpcRequest('simulateTransaction', args);
|
const unsafeRes = await this._rpcRequest('simulateTransaction', args);
|
||||||
@ -2817,7 +2818,7 @@ export class Connection {
|
|||||||
rawTransaction: Buffer | Uint8Array | Array<number>,
|
rawTransaction: Buffer | Uint8Array | Array<number>,
|
||||||
options: ?SendOptions,
|
options: ?SendOptions,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const encodedTransaction = bs58.encode(toBuffer(rawTransaction));
|
const encodedTransaction = toBuffer(rawTransaction).toString('base64');
|
||||||
const result = await this.sendEncodedTransaction(
|
const result = await this.sendEncodedTransaction(
|
||||||
encodedTransaction,
|
encodedTransaction,
|
||||||
options,
|
options,
|
||||||
@ -2827,13 +2828,14 @@ export class Connection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a transaction that has already been signed, serialized into the
|
* Send a transaction that has already been signed, serialized into the
|
||||||
* wire format, and encoded as a base58 string
|
* wire format, and encoded as a base64 string
|
||||||
*/
|
*/
|
||||||
async sendEncodedTransaction(
|
async sendEncodedTransaction(
|
||||||
encodedTransaction: string,
|
encodedTransaction: string,
|
||||||
options: ?SendOptions,
|
options: ?SendOptions,
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const args = [encodedTransaction];
|
const config: any = {encoding: 'base64'};
|
||||||
|
const args = [encodedTransaction, config];
|
||||||
const skipPreflight = options && options.skipPreflight;
|
const skipPreflight = options && options.skipPreflight;
|
||||||
const preflightCommitment = options && options.preflightCommitment;
|
const preflightCommitment = options && options.preflightCommitment;
|
||||||
|
|
||||||
@ -2844,9 +2846,9 @@ export class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (skipPreflight) {
|
if (skipPreflight) {
|
||||||
args.push({skipPreflight});
|
config.skipPreflight = skipPreflight;
|
||||||
} else if (preflightCommitment) {
|
} else if (preflightCommitment) {
|
||||||
args.push({preflightCommitment});
|
config.preflightCommitment = preflightCommitment;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
||||||
|
Reference in New Issue
Block a user