@solana/web3.js 1.41.5 → 1.41.8
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 +5 -90
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +49 -135
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +8 -107
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +53 -153
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +2 -2
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +2 -2
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
|
|
|
@@ -2859,7 +2859,7 @@ class Transaction {
|
|
|
2859
2859
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2860
2860
|
}
|
|
2861
2861
|
|
|
2862
|
-
this.signatures[index].signature = Buffer
|
|
2862
|
+
this.signatures[index].signature = Buffer.from(signature);
|
|
2863
2863
|
}
|
|
2864
2864
|
/**
|
|
2865
2865
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2925,15 +2925,15 @@ class Transaction {
|
|
|
2925
2925
|
const signatureCount = [];
|
|
2926
2926
|
encodeLength(signatureCount, signatures.length);
|
|
2927
2927
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2928
|
-
const wireTransaction = Buffer
|
|
2928
|
+
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2929
2929
|
assert(signatures.length < 256);
|
|
2930
|
-
Buffer
|
|
2930
|
+
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2931
2931
|
signatures.forEach(({
|
|
2932
2932
|
signature
|
|
2933
2933
|
}, index) => {
|
|
2934
2934
|
if (signature !== null) {
|
|
2935
2935
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2936
|
-
Buffer
|
|
2936
|
+
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2937
2937
|
}
|
|
2938
2938
|
});
|
|
2939
2939
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2984,7 +2984,7 @@ class Transaction {
|
|
|
2984
2984
|
for (let i = 0; i < signatureCount; i++) {
|
|
2985
2985
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2986
2986
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2987
|
-
signatures.push(bs58.encode(Buffer
|
|
2987
|
+
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2988
2988
|
}
|
|
2989
2989
|
|
|
2990
2990
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3073,113 +3073,13 @@ function sleep(ms) {
|
|
|
3073
3073
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3074
3074
|
}
|
|
3075
3075
|
|
|
3076
|
-
const encodeDecode = (layout) => {
|
|
3077
|
-
const decode = layout.decode.bind(layout);
|
|
3078
|
-
const encode = layout.encode.bind(layout);
|
|
3079
|
-
return { decode, encode };
|
|
3080
|
-
};
|
|
3081
|
-
|
|
3082
|
-
var node = {};
|
|
3083
|
-
|
|
3084
|
-
Object.defineProperty(node, "__esModule", { value: true });
|
|
3085
|
-
let converter;
|
|
3086
|
-
{
|
|
3087
|
-
try {
|
|
3088
|
-
converter = require('bindings')('bigint_buffer');
|
|
3089
|
-
}
|
|
3090
|
-
catch (e) {
|
|
3091
|
-
console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
/**
|
|
3095
|
-
* Convert a little-endian buffer into a BigInt.
|
|
3096
|
-
* @param buf The little-endian buffer to convert
|
|
3097
|
-
* @returns A BigInt with the little-endian representation of buf.
|
|
3098
|
-
*/
|
|
3099
|
-
function toBigIntLE(buf) {
|
|
3100
|
-
if (converter === undefined) {
|
|
3101
|
-
const reversed = Buffer.from(buf);
|
|
3102
|
-
reversed.reverse();
|
|
3103
|
-
const hex = reversed.toString('hex');
|
|
3104
|
-
if (hex.length === 0) {
|
|
3105
|
-
return BigInt(0);
|
|
3106
|
-
}
|
|
3107
|
-
return BigInt(`0x${hex}`);
|
|
3108
|
-
}
|
|
3109
|
-
return converter.toBigInt(buf, false);
|
|
3110
|
-
}
|
|
3111
|
-
var toBigIntLE_1 = node.toBigIntLE = toBigIntLE;
|
|
3112
|
-
/**
|
|
3113
|
-
* Convert a big-endian buffer into a BigInt
|
|
3114
|
-
* @param buf The big-endian buffer to convert.
|
|
3115
|
-
* @returns A BigInt with the big-endian representation of buf.
|
|
3116
|
-
*/
|
|
3117
|
-
function toBigIntBE(buf) {
|
|
3118
|
-
if (converter === undefined) {
|
|
3119
|
-
const hex = buf.toString('hex');
|
|
3120
|
-
if (hex.length === 0) {
|
|
3121
|
-
return BigInt(0);
|
|
3122
|
-
}
|
|
3123
|
-
return BigInt(`0x${hex}`);
|
|
3124
|
-
}
|
|
3125
|
-
return converter.toBigInt(buf, true);
|
|
3126
|
-
}
|
|
3127
|
-
node.toBigIntBE = toBigIntBE;
|
|
3128
|
-
/**
|
|
3129
|
-
* Convert a BigInt to a little-endian buffer.
|
|
3130
|
-
* @param num The BigInt to convert.
|
|
3131
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3132
|
-
* @returns A little-endian buffer representation of num.
|
|
3133
|
-
*/
|
|
3134
|
-
function toBufferLE(num, width) {
|
|
3135
|
-
if (converter === undefined) {
|
|
3136
|
-
const hex = num.toString(16);
|
|
3137
|
-
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3138
|
-
buffer.reverse();
|
|
3139
|
-
return buffer;
|
|
3140
|
-
}
|
|
3141
|
-
// Allocation is done here, since it is slower using napi in C
|
|
3142
|
-
return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
|
|
3143
|
-
}
|
|
3144
|
-
var toBufferLE_1 = node.toBufferLE = toBufferLE;
|
|
3145
|
-
/**
|
|
3146
|
-
* Convert a BigInt to a big-endian buffer.
|
|
3147
|
-
* @param num The BigInt to convert.
|
|
3148
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3149
|
-
* @returns A big-endian buffer representation of num.
|
|
3150
|
-
*/
|
|
3151
|
-
function toBufferBE(num, width) {
|
|
3152
|
-
if (converter === undefined) {
|
|
3153
|
-
const hex = num.toString(16);
|
|
3154
|
-
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3155
|
-
}
|
|
3156
|
-
return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
|
|
3157
|
-
}
|
|
3158
|
-
node.toBufferBE = toBufferBE;
|
|
3159
|
-
|
|
3160
|
-
const bigInt = (length) => (property) => {
|
|
3161
|
-
const layout = blob(length, property);
|
|
3162
|
-
const { encode, decode } = encodeDecode(layout);
|
|
3163
|
-
const bigIntLayout = layout;
|
|
3164
|
-
bigIntLayout.decode = (buffer, offset) => {
|
|
3165
|
-
const src = decode(buffer, offset);
|
|
3166
|
-
return toBigIntLE_1(Buffer.from(src));
|
|
3167
|
-
};
|
|
3168
|
-
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3169
|
-
const src = toBufferLE_1(bigInt, length);
|
|
3170
|
-
return encode(src, buffer, offset);
|
|
3171
|
-
};
|
|
3172
|
-
return bigIntLayout;
|
|
3173
|
-
};
|
|
3174
|
-
const u64 = bigInt(8);
|
|
3175
|
-
|
|
3176
3076
|
/**
|
|
3177
3077
|
* Populate a buffer of instruction data using an InstructionType
|
|
3178
3078
|
* @internal
|
|
3179
3079
|
*/
|
|
3180
3080
|
function encodeData(type, fields) {
|
|
3181
3081
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3182
|
-
const data = Buffer
|
|
3082
|
+
const data = Buffer.alloc(allocLength);
|
|
3183
3083
|
const layoutFields = Object.assign({
|
|
3184
3084
|
instruction: type.index
|
|
3185
3085
|
}, fields);
|
|
@@ -4079,7 +3979,7 @@ class Loader {
|
|
|
4079
3979
|
|
|
4080
3980
|
while (array.length > 0) {
|
|
4081
3981
|
const bytes = array.slice(0, chunkSize);
|
|
4082
|
-
const data = Buffer
|
|
3982
|
+
const data = Buffer.alloc(chunkSize + 16);
|
|
4083
3983
|
dataLayout.encode({
|
|
4084
3984
|
instruction: 0,
|
|
4085
3985
|
// Load instruction
|
|
@@ -4114,7 +4014,7 @@ class Loader {
|
|
|
4114
4014
|
|
|
4115
4015
|
{
|
|
4116
4016
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4117
|
-
const data = Buffer
|
|
4017
|
+
const data = Buffer.alloc(dataLayout.span);
|
|
4118
4018
|
dataLayout.encode({
|
|
4119
4019
|
instruction: 1 // Finalize instruction
|
|
4120
4020
|
|
|
@@ -4590,7 +4490,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4590
4490
|
|
|
4591
4491
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4592
4492
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4593
|
-
const BufferFromRawAccountData = coerce(instance(Buffer
|
|
4493
|
+
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
4594
4494
|
/**
|
|
4595
4495
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
4596
4496
|
* @internal
|
|
@@ -4773,7 +4673,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
4773
4673
|
*/
|
|
4774
4674
|
|
|
4775
4675
|
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4776
|
-
const fetch
|
|
4676
|
+
const fetch = customFetch ? customFetch : crossFetch;
|
|
4777
4677
|
let agentManager;
|
|
4778
4678
|
|
|
4779
4679
|
{
|
|
@@ -4791,7 +4691,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4791
4691
|
reject(error);
|
|
4792
4692
|
}
|
|
4793
4693
|
});
|
|
4794
|
-
return await fetch
|
|
4694
|
+
return await fetch(...modifiedFetchArgs);
|
|
4795
4695
|
};
|
|
4796
4696
|
}
|
|
4797
4697
|
|
|
@@ -4815,7 +4715,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4815
4715
|
if (fetchWithMiddleware) {
|
|
4816
4716
|
res = await fetchWithMiddleware(url, options);
|
|
4817
4717
|
} else {
|
|
4818
|
-
res = await fetch
|
|
4718
|
+
res = await fetch(url, options);
|
|
4819
4719
|
}
|
|
4820
4720
|
|
|
4821
4721
|
if (res.status !== 429
|
|
@@ -5019,7 +4919,7 @@ const KeyedAccountInfoResult = type({
|
|
|
5019
4919
|
pubkey: PublicKeyFromString,
|
|
5020
4920
|
account: AccountInfoResult
|
|
5021
4921
|
});
|
|
5022
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer
|
|
4922
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5023
4923
|
if (Array.isArray(value)) {
|
|
5024
4924
|
return create(value, BufferFromRawAccountData);
|
|
5025
4925
|
} else {
|
|
@@ -7948,7 +7848,7 @@ class Connection {
|
|
|
7948
7848
|
|
|
7949
7849
|
try {
|
|
7950
7850
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
7951
|
-
} catch {// Already removed.
|
|
7851
|
+
} catch (_err) {// Already removed.
|
|
7952
7852
|
}
|
|
7953
7853
|
}
|
|
7954
7854
|
},
|
|
@@ -7990,7 +7890,7 @@ class Connection {
|
|
|
7990
7890
|
|
|
7991
7891
|
try {
|
|
7992
7892
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
7993
|
-
} catch {// Already removed.
|
|
7893
|
+
} catch (_err) {// Already removed.
|
|
7994
7894
|
}
|
|
7995
7895
|
},
|
|
7996
7896
|
method: 'signatureSubscribe',
|
|
@@ -8177,7 +8077,7 @@ class Ed25519Program {
|
|
|
8177
8077
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8178
8078
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8179
8079
|
const numSignatures = 1;
|
|
8180
|
-
const instructionData = Buffer
|
|
8080
|
+
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8181
8081
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8182
8082
|
: instructionIndex;
|
|
8183
8083
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -9048,7 +8948,7 @@ class Secp256k1Program {
|
|
|
9048
8948
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
9049
8949
|
|
|
9050
8950
|
try {
|
|
9051
|
-
return Buffer
|
|
8951
|
+
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9052
8952
|
} catch (error) {
|
|
9053
8953
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
9054
8954
|
}
|
|
@@ -9093,9 +8993,9 @@ class Secp256k1Program {
|
|
|
9093
8993
|
|
|
9094
8994
|
if (typeof rawAddress === 'string') {
|
|
9095
8995
|
if (rawAddress.startsWith('0x')) {
|
|
9096
|
-
ethAddress = Buffer
|
|
8996
|
+
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9097
8997
|
} else {
|
|
9098
|
-
ethAddress = Buffer
|
|
8998
|
+
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9099
8999
|
}
|
|
9100
9000
|
} else {
|
|
9101
9001
|
ethAddress = rawAddress;
|
|
@@ -9107,7 +9007,7 @@ class Secp256k1Program {
|
|
|
9107
9007
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9108
9008
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9109
9009
|
const numSignatures = 1;
|
|
9110
|
-
const instructionData = Buffer
|
|
9010
|
+
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9111
9011
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9112
9012
|
numSignatures,
|
|
9113
9013
|
signatureOffset,
|
|
@@ -9146,7 +9046,7 @@ class Secp256k1Program {
|
|
|
9146
9046
|
const privateKey = toBuffer(pkey);
|
|
9147
9047
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9148
9048
|
|
|
9149
|
-
const messageHash = Buffer
|
|
9049
|
+
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9150
9050
|
const {
|
|
9151
9051
|
signature,
|
|
9152
9052
|
recid: recoveryId
|
|
@@ -9231,7 +9131,7 @@ class ValidatorInfo {
|
|
|
9231
9131
|
|
|
9232
9132
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9233
9133
|
if (configKeys[1].isSigner) {
|
|
9234
|
-
const rawInfo = rustString().decode(Buffer
|
|
9134
|
+
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9235
9135
|
const info = JSON.parse(rawInfo);
|
|
9236
9136
|
assert$7(info, InfoString);
|
|
9237
9137
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|