@solana/web3.js 1.41.4 → 1.41.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.cjs.js +6 -95
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +50 -140
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +9 -112
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +54 -158
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +3 -7
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +3 -3
- package/src/connection.ts +2 -2
- package/src/transaction.ts +4 -6
package/lib/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import nacl from 'tweetnacl';
|
|
2
|
-
import { Buffer
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import bs58 from 'bs58';
|
|
5
5
|
import { serialize, deserialize, deserializeUnchecked } from 'borsh';
|
|
6
6
|
import * as BufferLayout from '@solana/buffer-layout';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
7
|
+
import { u64 } from '@solana/buffer-layout-utils';
|
|
8
|
+
import crossFetch from 'cross-fetch';
|
|
9
9
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
10
10
|
import { Client } from 'rpc-websockets';
|
|
11
11
|
import RpcClient from 'jayson/lib/client/browser';
|
|
@@ -15,12 +15,12 @@ import secp256k1 from 'secp256k1';
|
|
|
15
15
|
import sha3 from 'js-sha3';
|
|
16
16
|
|
|
17
17
|
const toBuffer = arr => {
|
|
18
|
-
if (Buffer
|
|
18
|
+
if (Buffer.isBuffer(arr)) {
|
|
19
19
|
return arr;
|
|
20
20
|
} else if (arr instanceof Uint8Array) {
|
|
21
|
-
return Buffer
|
|
21
|
+
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
22
22
|
} else {
|
|
23
|
-
return Buffer
|
|
23
|
+
return Buffer.from(arr);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -1747,7 +1747,7 @@ class Struct {
|
|
|
1747
1747
|
}
|
|
1748
1748
|
|
|
1749
1749
|
encode() {
|
|
1750
|
-
return Buffer
|
|
1750
|
+
return Buffer.from(serialize(SOLANA_SCHEMA, this));
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
static decode(data) {
|
|
@@ -1864,13 +1864,13 @@ class PublicKey extends Struct {
|
|
|
1864
1864
|
|
|
1865
1865
|
|
|
1866
1866
|
toBuffer() {
|
|
1867
|
-
const b = this._bn.toArrayLike(Buffer
|
|
1867
|
+
const b = this._bn.toArrayLike(Buffer);
|
|
1868
1868
|
|
|
1869
1869
|
if (b.length === 32) {
|
|
1870
1870
|
return b;
|
|
1871
1871
|
}
|
|
1872
1872
|
|
|
1873
|
-
const zeroPad = Buffer
|
|
1873
|
+
const zeroPad = Buffer.alloc(32);
|
|
1874
1874
|
b.copy(zeroPad, 32 - b.length);
|
|
1875
1875
|
return zeroPad;
|
|
1876
1876
|
}
|
|
@@ -1892,9 +1892,9 @@ class PublicKey extends Struct {
|
|
|
1892
1892
|
|
|
1893
1893
|
|
|
1894
1894
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
1895
|
-
const buffer = Buffer
|
|
1895
|
+
const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
|
|
1896
1896
|
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1897
|
-
return new PublicKey(Buffer
|
|
1897
|
+
return new PublicKey(Buffer.from(hash, 'hex'));
|
|
1898
1898
|
}
|
|
1899
1899
|
/**
|
|
1900
1900
|
* Derive a program address from seeds and a program ID.
|
|
@@ -1904,15 +1904,15 @@ class PublicKey extends Struct {
|
|
|
1904
1904
|
|
|
1905
1905
|
|
|
1906
1906
|
static createProgramAddressSync(seeds, programId) {
|
|
1907
|
-
let buffer = Buffer
|
|
1907
|
+
let buffer = Buffer.alloc(0);
|
|
1908
1908
|
seeds.forEach(function (seed) {
|
|
1909
1909
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
1910
1910
|
throw new TypeError(`Max seed length exceeded`);
|
|
1911
1911
|
}
|
|
1912
1912
|
|
|
1913
|
-
buffer = Buffer
|
|
1913
|
+
buffer = Buffer.concat([buffer, toBuffer(seed)]);
|
|
1914
1914
|
});
|
|
1915
|
-
buffer = Buffer
|
|
1915
|
+
buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
|
|
1916
1916
|
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1917
1917
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
1918
1918
|
|
|
@@ -1948,7 +1948,7 @@ class PublicKey extends Struct {
|
|
|
1948
1948
|
|
|
1949
1949
|
while (nonce != 0) {
|
|
1950
1950
|
try {
|
|
1951
|
-
const seedsWithNonce = seeds.concat(Buffer
|
|
1951
|
+
const seedsWithNonce = seeds.concat(Buffer.from([nonce]));
|
|
1952
1952
|
address = this.createProgramAddressSync(seedsWithNonce, programId);
|
|
1953
1953
|
} catch (err) {
|
|
1954
1954
|
if (err instanceof TypeError) {
|
|
@@ -2124,13 +2124,13 @@ const rustString = (property = 'string') => {
|
|
|
2124
2124
|
|
|
2125
2125
|
rslShim.encode = (str, b, offset) => {
|
|
2126
2126
|
const data = {
|
|
2127
|
-
chars: Buffer
|
|
2127
|
+
chars: Buffer.from(str, 'utf8')
|
|
2128
2128
|
};
|
|
2129
2129
|
return _encode(data, b, offset);
|
|
2130
2130
|
};
|
|
2131
2131
|
|
|
2132
2132
|
rslShim.alloc = str => {
|
|
2133
|
-
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer
|
|
2133
|
+
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;
|
|
2134
2134
|
};
|
|
2135
2135
|
|
|
2136
2136
|
return rslShim;
|
|
@@ -2260,16 +2260,16 @@ class Message {
|
|
|
2260
2260
|
encodeLength(dataCount, data.length);
|
|
2261
2261
|
return {
|
|
2262
2262
|
programIdIndex,
|
|
2263
|
-
keyIndicesCount: Buffer
|
|
2263
|
+
keyIndicesCount: Buffer.from(keyIndicesCount),
|
|
2264
2264
|
keyIndices: accounts,
|
|
2265
|
-
dataLength: Buffer
|
|
2265
|
+
dataLength: Buffer.from(dataCount),
|
|
2266
2266
|
data
|
|
2267
2267
|
};
|
|
2268
2268
|
});
|
|
2269
2269
|
let instructionCount = [];
|
|
2270
2270
|
encodeLength(instructionCount, instructions.length);
|
|
2271
|
-
let instructionBuffer = Buffer
|
|
2272
|
-
Buffer
|
|
2271
|
+
let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);
|
|
2272
|
+
Buffer.from(instructionCount).copy(instructionBuffer);
|
|
2273
2273
|
let instructionBufferLength = instructionCount.length;
|
|
2274
2274
|
instructions.forEach(instruction => {
|
|
2275
2275
|
const instructionLayout = BufferLayout.struct([BufferLayout.u8('programIdIndex'), BufferLayout.blob(instruction.keyIndicesCount.length, 'keyIndicesCount'), BufferLayout.seq(BufferLayout.u8('keyIndex'), instruction.keyIndices.length, 'keyIndices'), BufferLayout.blob(instruction.dataLength.length, 'dataLength'), BufferLayout.seq(BufferLayout.u8('userdatum'), instruction.data.length, 'data')]);
|
|
@@ -2279,14 +2279,14 @@ class Message {
|
|
|
2279
2279
|
instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);
|
|
2280
2280
|
const signDataLayout = BufferLayout.struct([BufferLayout.blob(1, 'numRequiredSignatures'), BufferLayout.blob(1, 'numReadonlySignedAccounts'), BufferLayout.blob(1, 'numReadonlyUnsignedAccounts'), BufferLayout.blob(keyCount.length, 'keyCount'), BufferLayout.seq(publicKey('key'), numKeys, 'keys'), publicKey('recentBlockhash')]);
|
|
2281
2281
|
const transaction = {
|
|
2282
|
-
numRequiredSignatures: Buffer
|
|
2283
|
-
numReadonlySignedAccounts: Buffer
|
|
2284
|
-
numReadonlyUnsignedAccounts: Buffer
|
|
2285
|
-
keyCount: Buffer
|
|
2282
|
+
numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),
|
|
2283
|
+
numReadonlySignedAccounts: Buffer.from([this.header.numReadonlySignedAccounts]),
|
|
2284
|
+
numReadonlyUnsignedAccounts: Buffer.from([this.header.numReadonlyUnsignedAccounts]),
|
|
2285
|
+
keyCount: Buffer.from(keyCount),
|
|
2286
2286
|
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
|
2287
2287
|
recentBlockhash: bs58.decode(this.recentBlockhash)
|
|
2288
2288
|
};
|
|
2289
|
-
let signData = Buffer
|
|
2289
|
+
let signData = Buffer.alloc(2048);
|
|
2290
2290
|
const length = signDataLayout.encode(transaction, signData);
|
|
2291
2291
|
instructionBuffer.copy(signData, length);
|
|
2292
2292
|
return signData.slice(0, length + instructionBuffer.length);
|
|
@@ -2308,7 +2308,7 @@ class Message {
|
|
|
2308
2308
|
for (let i = 0; i < accountCount; i++) {
|
|
2309
2309
|
const account = byteArray.slice(0, PUBKEY_LENGTH);
|
|
2310
2310
|
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2311
|
-
accountKeys.push(bs58.encode(Buffer
|
|
2311
|
+
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2312
2312
|
}
|
|
2313
2313
|
|
|
2314
2314
|
const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
|
|
@@ -2323,7 +2323,7 @@ class Message {
|
|
|
2323
2323
|
byteArray = byteArray.slice(accountCount);
|
|
2324
2324
|
const dataLength = decodeLength(byteArray);
|
|
2325
2325
|
const dataSlice = byteArray.slice(0, dataLength);
|
|
2326
|
-
const data = bs58.encode(Buffer
|
|
2326
|
+
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2327
2327
|
byteArray = byteArray.slice(dataLength);
|
|
2328
2328
|
instructions.push({
|
|
2329
2329
|
programIdIndex,
|
|
@@ -2338,7 +2338,7 @@ class Message {
|
|
|
2338
2338
|
numReadonlySignedAccounts,
|
|
2339
2339
|
numReadonlyUnsignedAccounts
|
|
2340
2340
|
},
|
|
2341
|
-
recentBlockhash: bs58.encode(Buffer
|
|
2341
|
+
recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),
|
|
2342
2342
|
accountKeys,
|
|
2343
2343
|
instructions
|
|
2344
2344
|
};
|
|
@@ -2356,7 +2356,7 @@ function assert (condition, message) {
|
|
|
2356
2356
|
/**
|
|
2357
2357
|
* Default (empty) signature
|
|
2358
2358
|
*/
|
|
2359
|
-
const DEFAULT_SIGNATURE = Buffer
|
|
2359
|
+
const DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2360
2360
|
/**
|
|
2361
2361
|
* Account metadata used to define instructions
|
|
2362
2362
|
*/
|
|
@@ -2380,7 +2380,7 @@ class TransactionInstruction {
|
|
|
2380
2380
|
constructor(opts) {
|
|
2381
2381
|
this.keys = void 0;
|
|
2382
2382
|
this.programId = void 0;
|
|
2383
|
-
this.data = Buffer
|
|
2383
|
+
this.data = Buffer.alloc(0);
|
|
2384
2384
|
this.programId = opts.programId;
|
|
2385
2385
|
this.keys = opts.keys;
|
|
2386
2386
|
|
|
@@ -2499,11 +2499,7 @@ class Transaction {
|
|
|
2499
2499
|
|
|
2500
2500
|
|
|
2501
2501
|
compileMessage() {
|
|
2502
|
-
if (this._message) {
|
|
2503
|
-
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
|
2504
|
-
throw new Error('Transaction message mutated after being populated from Message');
|
|
2505
|
-
}
|
|
2506
|
-
|
|
2502
|
+
if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {
|
|
2507
2503
|
return this._message;
|
|
2508
2504
|
}
|
|
2509
2505
|
|
|
@@ -2863,7 +2859,7 @@ class Transaction {
|
|
|
2863
2859
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2864
2860
|
}
|
|
2865
2861
|
|
|
2866
|
-
this.signatures[index].signature = Buffer
|
|
2862
|
+
this.signatures[index].signature = Buffer.from(signature);
|
|
2867
2863
|
}
|
|
2868
2864
|
/**
|
|
2869
2865
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2929,15 +2925,15 @@ class Transaction {
|
|
|
2929
2925
|
const signatureCount = [];
|
|
2930
2926
|
encodeLength(signatureCount, signatures.length);
|
|
2931
2927
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2932
|
-
const wireTransaction = Buffer
|
|
2928
|
+
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2933
2929
|
assert(signatures.length < 256);
|
|
2934
|
-
Buffer
|
|
2930
|
+
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2935
2931
|
signatures.forEach(({
|
|
2936
2932
|
signature
|
|
2937
2933
|
}, index) => {
|
|
2938
2934
|
if (signature !== null) {
|
|
2939
2935
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2940
|
-
Buffer
|
|
2936
|
+
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2941
2937
|
}
|
|
2942
2938
|
});
|
|
2943
2939
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2988,7 +2984,7 @@ class Transaction {
|
|
|
2988
2984
|
for (let i = 0; i < signatureCount; i++) {
|
|
2989
2985
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2990
2986
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2991
|
-
signatures.push(bs58.encode(Buffer
|
|
2987
|
+
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2992
2988
|
}
|
|
2993
2989
|
|
|
2994
2990
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3077,113 +3073,13 @@ function sleep(ms) {
|
|
|
3077
3073
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3078
3074
|
}
|
|
3079
3075
|
|
|
3080
|
-
const encodeDecode = (layout) => {
|
|
3081
|
-
const decode = layout.decode.bind(layout);
|
|
3082
|
-
const encode = layout.encode.bind(layout);
|
|
3083
|
-
return { decode, encode };
|
|
3084
|
-
};
|
|
3085
|
-
|
|
3086
|
-
var node = {};
|
|
3087
|
-
|
|
3088
|
-
Object.defineProperty(node, "__esModule", { value: true });
|
|
3089
|
-
let converter;
|
|
3090
|
-
{
|
|
3091
|
-
try {
|
|
3092
|
-
converter = require('bindings')('bigint_buffer');
|
|
3093
|
-
}
|
|
3094
|
-
catch (e) {
|
|
3095
|
-
console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
|
|
3096
|
-
}
|
|
3097
|
-
}
|
|
3098
|
-
/**
|
|
3099
|
-
* Convert a little-endian buffer into a BigInt.
|
|
3100
|
-
* @param buf The little-endian buffer to convert
|
|
3101
|
-
* @returns A BigInt with the little-endian representation of buf.
|
|
3102
|
-
*/
|
|
3103
|
-
function toBigIntLE(buf) {
|
|
3104
|
-
if (converter === undefined) {
|
|
3105
|
-
const reversed = Buffer.from(buf);
|
|
3106
|
-
reversed.reverse();
|
|
3107
|
-
const hex = reversed.toString('hex');
|
|
3108
|
-
if (hex.length === 0) {
|
|
3109
|
-
return BigInt(0);
|
|
3110
|
-
}
|
|
3111
|
-
return BigInt(`0x${hex}`);
|
|
3112
|
-
}
|
|
3113
|
-
return converter.toBigInt(buf, false);
|
|
3114
|
-
}
|
|
3115
|
-
var toBigIntLE_1 = node.toBigIntLE = toBigIntLE;
|
|
3116
|
-
/**
|
|
3117
|
-
* Convert a big-endian buffer into a BigInt
|
|
3118
|
-
* @param buf The big-endian buffer to convert.
|
|
3119
|
-
* @returns A BigInt with the big-endian representation of buf.
|
|
3120
|
-
*/
|
|
3121
|
-
function toBigIntBE(buf) {
|
|
3122
|
-
if (converter === undefined) {
|
|
3123
|
-
const hex = buf.toString('hex');
|
|
3124
|
-
if (hex.length === 0) {
|
|
3125
|
-
return BigInt(0);
|
|
3126
|
-
}
|
|
3127
|
-
return BigInt(`0x${hex}`);
|
|
3128
|
-
}
|
|
3129
|
-
return converter.toBigInt(buf, true);
|
|
3130
|
-
}
|
|
3131
|
-
node.toBigIntBE = toBigIntBE;
|
|
3132
|
-
/**
|
|
3133
|
-
* Convert a BigInt to a little-endian buffer.
|
|
3134
|
-
* @param num The BigInt to convert.
|
|
3135
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3136
|
-
* @returns A little-endian buffer representation of num.
|
|
3137
|
-
*/
|
|
3138
|
-
function toBufferLE(num, width) {
|
|
3139
|
-
if (converter === undefined) {
|
|
3140
|
-
const hex = num.toString(16);
|
|
3141
|
-
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3142
|
-
buffer.reverse();
|
|
3143
|
-
return buffer;
|
|
3144
|
-
}
|
|
3145
|
-
// Allocation is done here, since it is slower using napi in C
|
|
3146
|
-
return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
|
|
3147
|
-
}
|
|
3148
|
-
var toBufferLE_1 = node.toBufferLE = toBufferLE;
|
|
3149
|
-
/**
|
|
3150
|
-
* Convert a BigInt to a big-endian buffer.
|
|
3151
|
-
* @param num The BigInt to convert.
|
|
3152
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3153
|
-
* @returns A big-endian buffer representation of num.
|
|
3154
|
-
*/
|
|
3155
|
-
function toBufferBE(num, width) {
|
|
3156
|
-
if (converter === undefined) {
|
|
3157
|
-
const hex = num.toString(16);
|
|
3158
|
-
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3159
|
-
}
|
|
3160
|
-
return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
|
|
3161
|
-
}
|
|
3162
|
-
node.toBufferBE = toBufferBE;
|
|
3163
|
-
|
|
3164
|
-
const bigInt = (length) => (property) => {
|
|
3165
|
-
const layout = blob(length, property);
|
|
3166
|
-
const { encode, decode } = encodeDecode(layout);
|
|
3167
|
-
const bigIntLayout = layout;
|
|
3168
|
-
bigIntLayout.decode = (buffer, offset) => {
|
|
3169
|
-
const src = decode(buffer, offset);
|
|
3170
|
-
return toBigIntLE_1(Buffer.from(src));
|
|
3171
|
-
};
|
|
3172
|
-
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3173
|
-
const src = toBufferLE_1(bigInt, length);
|
|
3174
|
-
return encode(src, buffer, offset);
|
|
3175
|
-
};
|
|
3176
|
-
return bigIntLayout;
|
|
3177
|
-
};
|
|
3178
|
-
const u64 = bigInt(8);
|
|
3179
|
-
|
|
3180
3076
|
/**
|
|
3181
3077
|
* Populate a buffer of instruction data using an InstructionType
|
|
3182
3078
|
* @internal
|
|
3183
3079
|
*/
|
|
3184
3080
|
function encodeData(type, fields) {
|
|
3185
3081
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3186
|
-
const data = Buffer
|
|
3082
|
+
const data = Buffer.alloc(allocLength);
|
|
3187
3083
|
const layoutFields = Object.assign({
|
|
3188
3084
|
instruction: type.index
|
|
3189
3085
|
}, fields);
|
|
@@ -4083,7 +3979,7 @@ class Loader {
|
|
|
4083
3979
|
|
|
4084
3980
|
while (array.length > 0) {
|
|
4085
3981
|
const bytes = array.slice(0, chunkSize);
|
|
4086
|
-
const data = Buffer
|
|
3982
|
+
const data = Buffer.alloc(chunkSize + 16);
|
|
4087
3983
|
dataLayout.encode({
|
|
4088
3984
|
instruction: 0,
|
|
4089
3985
|
// Load instruction
|
|
@@ -4118,7 +4014,7 @@ class Loader {
|
|
|
4118
4014
|
|
|
4119
4015
|
{
|
|
4120
4016
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4121
|
-
const data = Buffer
|
|
4017
|
+
const data = Buffer.alloc(dataLayout.span);
|
|
4122
4018
|
dataLayout.encode({
|
|
4123
4019
|
instruction: 1 // Finalize instruction
|
|
4124
4020
|
|
|
@@ -4594,7 +4490,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4594
4490
|
|
|
4595
4491
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4596
4492
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4597
|
-
const BufferFromRawAccountData = coerce(instance(Buffer
|
|
4493
|
+
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
4598
4494
|
/**
|
|
4599
4495
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
4600
4496
|
* @internal
|
|
@@ -4777,7 +4673,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
4777
4673
|
*/
|
|
4778
4674
|
|
|
4779
4675
|
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4780
|
-
const fetch
|
|
4676
|
+
const fetch = customFetch ? customFetch : crossFetch;
|
|
4781
4677
|
let agentManager;
|
|
4782
4678
|
|
|
4783
4679
|
{
|
|
@@ -4795,7 +4691,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4795
4691
|
reject(error);
|
|
4796
4692
|
}
|
|
4797
4693
|
});
|
|
4798
|
-
return await fetch
|
|
4694
|
+
return await fetch(...modifiedFetchArgs);
|
|
4799
4695
|
};
|
|
4800
4696
|
}
|
|
4801
4697
|
|
|
@@ -4819,7 +4715,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4819
4715
|
if (fetchWithMiddleware) {
|
|
4820
4716
|
res = await fetchWithMiddleware(url, options);
|
|
4821
4717
|
} else {
|
|
4822
|
-
res = await fetch
|
|
4718
|
+
res = await fetch(url, options);
|
|
4823
4719
|
}
|
|
4824
4720
|
|
|
4825
4721
|
if (res.status !== 429
|
|
@@ -5023,7 +4919,7 @@ const KeyedAccountInfoResult = type({
|
|
|
5023
4919
|
pubkey: PublicKeyFromString,
|
|
5024
4920
|
account: AccountInfoResult
|
|
5025
4921
|
});
|
|
5026
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer
|
|
4922
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5027
4923
|
if (Array.isArray(value)) {
|
|
5028
4924
|
return create(value, BufferFromRawAccountData);
|
|
5029
4925
|
} else {
|
|
@@ -7952,7 +7848,7 @@ class Connection {
|
|
|
7952
7848
|
|
|
7953
7849
|
try {
|
|
7954
7850
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
7955
|
-
} catch {// Already removed.
|
|
7851
|
+
} catch (_err) {// Already removed.
|
|
7956
7852
|
}
|
|
7957
7853
|
}
|
|
7958
7854
|
},
|
|
@@ -7994,7 +7890,7 @@ class Connection {
|
|
|
7994
7890
|
|
|
7995
7891
|
try {
|
|
7996
7892
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
7997
|
-
} catch {// Already removed.
|
|
7893
|
+
} catch (_err) {// Already removed.
|
|
7998
7894
|
}
|
|
7999
7895
|
},
|
|
8000
7896
|
method: 'signatureSubscribe',
|
|
@@ -8181,7 +8077,7 @@ class Ed25519Program {
|
|
|
8181
8077
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8182
8078
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8183
8079
|
const numSignatures = 1;
|
|
8184
|
-
const instructionData = Buffer
|
|
8080
|
+
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8185
8081
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8186
8082
|
: instructionIndex;
|
|
8187
8083
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -9052,7 +8948,7 @@ class Secp256k1Program {
|
|
|
9052
8948
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
9053
8949
|
|
|
9054
8950
|
try {
|
|
9055
|
-
return Buffer
|
|
8951
|
+
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9056
8952
|
} catch (error) {
|
|
9057
8953
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
9058
8954
|
}
|
|
@@ -9097,9 +8993,9 @@ class Secp256k1Program {
|
|
|
9097
8993
|
|
|
9098
8994
|
if (typeof rawAddress === 'string') {
|
|
9099
8995
|
if (rawAddress.startsWith('0x')) {
|
|
9100
|
-
ethAddress = Buffer
|
|
8996
|
+
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9101
8997
|
} else {
|
|
9102
|
-
ethAddress = Buffer
|
|
8998
|
+
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9103
8999
|
}
|
|
9104
9000
|
} else {
|
|
9105
9001
|
ethAddress = rawAddress;
|
|
@@ -9111,7 +9007,7 @@ class Secp256k1Program {
|
|
|
9111
9007
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9112
9008
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9113
9009
|
const numSignatures = 1;
|
|
9114
|
-
const instructionData = Buffer
|
|
9010
|
+
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9115
9011
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9116
9012
|
numSignatures,
|
|
9117
9013
|
signatureOffset,
|
|
@@ -9150,7 +9046,7 @@ class Secp256k1Program {
|
|
|
9150
9046
|
const privateKey = toBuffer(pkey);
|
|
9151
9047
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9152
9048
|
|
|
9153
|
-
const messageHash = Buffer
|
|
9049
|
+
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9154
9050
|
const {
|
|
9155
9051
|
signature,
|
|
9156
9052
|
recid: recoveryId
|
|
@@ -9235,7 +9131,7 @@ class ValidatorInfo {
|
|
|
9235
9131
|
|
|
9236
9132
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9237
9133
|
if (configKeys[1].isSigner) {
|
|
9238
|
-
const rawInfo = rustString().decode(Buffer
|
|
9134
|
+
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9239
9135
|
const info = JSON.parse(rawInfo);
|
|
9240
9136
|
assert$7(info, InfoString);
|
|
9241
9137
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|