@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.browser.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 {
|
|
7
|
+
import { u64 } from '@solana/buffer-layout-utils';
|
|
8
8
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
9
9
|
import { Client } from 'rpc-websockets';
|
|
10
10
|
import RpcClient from 'jayson/lib/client/browser';
|
|
@@ -12,12 +12,12 @@ import secp256k1 from 'secp256k1';
|
|
|
12
12
|
import sha3 from 'js-sha3';
|
|
13
13
|
|
|
14
14
|
const toBuffer = arr => {
|
|
15
|
-
if (Buffer
|
|
15
|
+
if (Buffer.isBuffer(arr)) {
|
|
16
16
|
return arr;
|
|
17
17
|
} else if (arr instanceof Uint8Array) {
|
|
18
|
-
return Buffer
|
|
18
|
+
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
19
19
|
} else {
|
|
20
|
-
return Buffer
|
|
20
|
+
return Buffer.from(arr);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -1738,7 +1738,7 @@ class Struct {
|
|
|
1738
1738
|
}
|
|
1739
1739
|
|
|
1740
1740
|
encode() {
|
|
1741
|
-
return Buffer
|
|
1741
|
+
return Buffer.from(serialize(SOLANA_SCHEMA, this));
|
|
1742
1742
|
}
|
|
1743
1743
|
|
|
1744
1744
|
static decode(data) {
|
|
@@ -1855,13 +1855,13 @@ class PublicKey extends Struct {
|
|
|
1855
1855
|
|
|
1856
1856
|
|
|
1857
1857
|
toBuffer() {
|
|
1858
|
-
const b = this._bn.toArrayLike(Buffer
|
|
1858
|
+
const b = this._bn.toArrayLike(Buffer);
|
|
1859
1859
|
|
|
1860
1860
|
if (b.length === 32) {
|
|
1861
1861
|
return b;
|
|
1862
1862
|
}
|
|
1863
1863
|
|
|
1864
|
-
const zeroPad = Buffer
|
|
1864
|
+
const zeroPad = Buffer.alloc(32);
|
|
1865
1865
|
b.copy(zeroPad, 32 - b.length);
|
|
1866
1866
|
return zeroPad;
|
|
1867
1867
|
}
|
|
@@ -1883,9 +1883,9 @@ class PublicKey extends Struct {
|
|
|
1883
1883
|
|
|
1884
1884
|
|
|
1885
1885
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
1886
|
-
const buffer = Buffer
|
|
1886
|
+
const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
|
|
1887
1887
|
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1888
|
-
return new PublicKey(Buffer
|
|
1888
|
+
return new PublicKey(Buffer.from(hash, 'hex'));
|
|
1889
1889
|
}
|
|
1890
1890
|
/**
|
|
1891
1891
|
* Derive a program address from seeds and a program ID.
|
|
@@ -1895,15 +1895,15 @@ class PublicKey extends Struct {
|
|
|
1895
1895
|
|
|
1896
1896
|
|
|
1897
1897
|
static createProgramAddressSync(seeds, programId) {
|
|
1898
|
-
let buffer = Buffer
|
|
1898
|
+
let buffer = Buffer.alloc(0);
|
|
1899
1899
|
seeds.forEach(function (seed) {
|
|
1900
1900
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
1901
1901
|
throw new TypeError(`Max seed length exceeded`);
|
|
1902
1902
|
}
|
|
1903
1903
|
|
|
1904
|
-
buffer = Buffer
|
|
1904
|
+
buffer = Buffer.concat([buffer, toBuffer(seed)]);
|
|
1905
1905
|
});
|
|
1906
|
-
buffer = Buffer
|
|
1906
|
+
buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
|
|
1907
1907
|
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1908
1908
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
1909
1909
|
|
|
@@ -1939,7 +1939,7 @@ class PublicKey extends Struct {
|
|
|
1939
1939
|
|
|
1940
1940
|
while (nonce != 0) {
|
|
1941
1941
|
try {
|
|
1942
|
-
const seedsWithNonce = seeds.concat(Buffer
|
|
1942
|
+
const seedsWithNonce = seeds.concat(Buffer.from([nonce]));
|
|
1943
1943
|
address = this.createProgramAddressSync(seedsWithNonce, programId);
|
|
1944
1944
|
} catch (err) {
|
|
1945
1945
|
if (err instanceof TypeError) {
|
|
@@ -2115,13 +2115,13 @@ const rustString = (property = 'string') => {
|
|
|
2115
2115
|
|
|
2116
2116
|
rslShim.encode = (str, b, offset) => {
|
|
2117
2117
|
const data = {
|
|
2118
|
-
chars: Buffer
|
|
2118
|
+
chars: Buffer.from(str, 'utf8')
|
|
2119
2119
|
};
|
|
2120
2120
|
return _encode(data, b, offset);
|
|
2121
2121
|
};
|
|
2122
2122
|
|
|
2123
2123
|
rslShim.alloc = str => {
|
|
2124
|
-
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer
|
|
2124
|
+
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;
|
|
2125
2125
|
};
|
|
2126
2126
|
|
|
2127
2127
|
return rslShim;
|
|
@@ -2251,16 +2251,16 @@ class Message {
|
|
|
2251
2251
|
encodeLength(dataCount, data.length);
|
|
2252
2252
|
return {
|
|
2253
2253
|
programIdIndex,
|
|
2254
|
-
keyIndicesCount: Buffer
|
|
2254
|
+
keyIndicesCount: Buffer.from(keyIndicesCount),
|
|
2255
2255
|
keyIndices: accounts,
|
|
2256
|
-
dataLength: Buffer
|
|
2256
|
+
dataLength: Buffer.from(dataCount),
|
|
2257
2257
|
data
|
|
2258
2258
|
};
|
|
2259
2259
|
});
|
|
2260
2260
|
let instructionCount = [];
|
|
2261
2261
|
encodeLength(instructionCount, instructions.length);
|
|
2262
|
-
let instructionBuffer = Buffer
|
|
2263
|
-
Buffer
|
|
2262
|
+
let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);
|
|
2263
|
+
Buffer.from(instructionCount).copy(instructionBuffer);
|
|
2264
2264
|
let instructionBufferLength = instructionCount.length;
|
|
2265
2265
|
instructions.forEach(instruction => {
|
|
2266
2266
|
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')]);
|
|
@@ -2270,14 +2270,14 @@ class Message {
|
|
|
2270
2270
|
instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);
|
|
2271
2271
|
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')]);
|
|
2272
2272
|
const transaction = {
|
|
2273
|
-
numRequiredSignatures: Buffer
|
|
2274
|
-
numReadonlySignedAccounts: Buffer
|
|
2275
|
-
numReadonlyUnsignedAccounts: Buffer
|
|
2276
|
-
keyCount: Buffer
|
|
2273
|
+
numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),
|
|
2274
|
+
numReadonlySignedAccounts: Buffer.from([this.header.numReadonlySignedAccounts]),
|
|
2275
|
+
numReadonlyUnsignedAccounts: Buffer.from([this.header.numReadonlyUnsignedAccounts]),
|
|
2276
|
+
keyCount: Buffer.from(keyCount),
|
|
2277
2277
|
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
|
2278
2278
|
recentBlockhash: bs58.decode(this.recentBlockhash)
|
|
2279
2279
|
};
|
|
2280
|
-
let signData = Buffer
|
|
2280
|
+
let signData = Buffer.alloc(2048);
|
|
2281
2281
|
const length = signDataLayout.encode(transaction, signData);
|
|
2282
2282
|
instructionBuffer.copy(signData, length);
|
|
2283
2283
|
return signData.slice(0, length + instructionBuffer.length);
|
|
@@ -2299,7 +2299,7 @@ class Message {
|
|
|
2299
2299
|
for (let i = 0; i < accountCount; i++) {
|
|
2300
2300
|
const account = byteArray.slice(0, PUBKEY_LENGTH);
|
|
2301
2301
|
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2302
|
-
accountKeys.push(bs58.encode(Buffer
|
|
2302
|
+
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2303
2303
|
}
|
|
2304
2304
|
|
|
2305
2305
|
const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
|
|
@@ -2314,7 +2314,7 @@ class Message {
|
|
|
2314
2314
|
byteArray = byteArray.slice(accountCount);
|
|
2315
2315
|
const dataLength = decodeLength(byteArray);
|
|
2316
2316
|
const dataSlice = byteArray.slice(0, dataLength);
|
|
2317
|
-
const data = bs58.encode(Buffer
|
|
2317
|
+
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2318
2318
|
byteArray = byteArray.slice(dataLength);
|
|
2319
2319
|
instructions.push({
|
|
2320
2320
|
programIdIndex,
|
|
@@ -2329,7 +2329,7 @@ class Message {
|
|
|
2329
2329
|
numReadonlySignedAccounts,
|
|
2330
2330
|
numReadonlyUnsignedAccounts
|
|
2331
2331
|
},
|
|
2332
|
-
recentBlockhash: bs58.encode(Buffer
|
|
2332
|
+
recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),
|
|
2333
2333
|
accountKeys,
|
|
2334
2334
|
instructions
|
|
2335
2335
|
};
|
|
@@ -2347,7 +2347,7 @@ function assert (condition, message) {
|
|
|
2347
2347
|
/**
|
|
2348
2348
|
* Default (empty) signature
|
|
2349
2349
|
*/
|
|
2350
|
-
const DEFAULT_SIGNATURE = Buffer
|
|
2350
|
+
const DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2351
2351
|
/**
|
|
2352
2352
|
* Account metadata used to define instructions
|
|
2353
2353
|
*/
|
|
@@ -2371,7 +2371,7 @@ class TransactionInstruction {
|
|
|
2371
2371
|
constructor(opts) {
|
|
2372
2372
|
this.keys = void 0;
|
|
2373
2373
|
this.programId = void 0;
|
|
2374
|
-
this.data = Buffer
|
|
2374
|
+
this.data = Buffer.alloc(0);
|
|
2375
2375
|
this.programId = opts.programId;
|
|
2376
2376
|
this.keys = opts.keys;
|
|
2377
2377
|
|
|
@@ -2490,11 +2490,7 @@ class Transaction {
|
|
|
2490
2490
|
|
|
2491
2491
|
|
|
2492
2492
|
compileMessage() {
|
|
2493
|
-
if (this._message) {
|
|
2494
|
-
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
|
2495
|
-
throw new Error('Transaction message mutated after being populated from Message');
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2493
|
+
if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {
|
|
2498
2494
|
return this._message;
|
|
2499
2495
|
}
|
|
2500
2496
|
|
|
@@ -2854,7 +2850,7 @@ class Transaction {
|
|
|
2854
2850
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2855
2851
|
}
|
|
2856
2852
|
|
|
2857
|
-
this.signatures[index].signature = Buffer
|
|
2853
|
+
this.signatures[index].signature = Buffer.from(signature);
|
|
2858
2854
|
}
|
|
2859
2855
|
/**
|
|
2860
2856
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2920,15 +2916,15 @@ class Transaction {
|
|
|
2920
2916
|
const signatureCount = [];
|
|
2921
2917
|
encodeLength(signatureCount, signatures.length);
|
|
2922
2918
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2923
|
-
const wireTransaction = Buffer
|
|
2919
|
+
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2924
2920
|
assert(signatures.length < 256);
|
|
2925
|
-
Buffer
|
|
2921
|
+
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2926
2922
|
signatures.forEach(({
|
|
2927
2923
|
signature
|
|
2928
2924
|
}, index) => {
|
|
2929
2925
|
if (signature !== null) {
|
|
2930
2926
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2931
|
-
Buffer
|
|
2927
|
+
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2932
2928
|
}
|
|
2933
2929
|
});
|
|
2934
2930
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2979,7 +2975,7 @@ class Transaction {
|
|
|
2979
2975
|
for (let i = 0; i < signatureCount; i++) {
|
|
2980
2976
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2981
2977
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2982
|
-
signatures.push(bs58.encode(Buffer
|
|
2978
|
+
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2983
2979
|
}
|
|
2984
2980
|
|
|
2985
2981
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3068,99 +3064,13 @@ function sleep(ms) {
|
|
|
3068
3064
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3069
3065
|
}
|
|
3070
3066
|
|
|
3071
|
-
const encodeDecode = (layout) => {
|
|
3072
|
-
const decode = layout.decode.bind(layout);
|
|
3073
|
-
const encode = layout.encode.bind(layout);
|
|
3074
|
-
return { decode, encode };
|
|
3075
|
-
};
|
|
3076
|
-
|
|
3077
|
-
var browser = {};
|
|
3078
|
-
|
|
3079
|
-
Object.defineProperty(browser, "__esModule", { value: true });
|
|
3080
|
-
/**
|
|
3081
|
-
* Convert a little-endian buffer into a BigInt.
|
|
3082
|
-
* @param buf The little-endian buffer to convert
|
|
3083
|
-
* @returns A BigInt with the little-endian representation of buf.
|
|
3084
|
-
*/
|
|
3085
|
-
function toBigIntLE(buf) {
|
|
3086
|
-
{
|
|
3087
|
-
const reversed = Buffer.from(buf);
|
|
3088
|
-
reversed.reverse();
|
|
3089
|
-
const hex = reversed.toString('hex');
|
|
3090
|
-
if (hex.length === 0) {
|
|
3091
|
-
return BigInt(0);
|
|
3092
|
-
}
|
|
3093
|
-
return BigInt(`0x${hex}`);
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
|
-
var toBigIntLE_1 = browser.toBigIntLE = toBigIntLE;
|
|
3097
|
-
/**
|
|
3098
|
-
* Convert a big-endian buffer into a BigInt
|
|
3099
|
-
* @param buf The big-endian buffer to convert.
|
|
3100
|
-
* @returns A BigInt with the big-endian representation of buf.
|
|
3101
|
-
*/
|
|
3102
|
-
function toBigIntBE(buf) {
|
|
3103
|
-
{
|
|
3104
|
-
const hex = buf.toString('hex');
|
|
3105
|
-
if (hex.length === 0) {
|
|
3106
|
-
return BigInt(0);
|
|
3107
|
-
}
|
|
3108
|
-
return BigInt(`0x${hex}`);
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
browser.toBigIntBE = toBigIntBE;
|
|
3112
|
-
/**
|
|
3113
|
-
* Convert a BigInt to a little-endian buffer.
|
|
3114
|
-
* @param num The BigInt to convert.
|
|
3115
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3116
|
-
* @returns A little-endian buffer representation of num.
|
|
3117
|
-
*/
|
|
3118
|
-
function toBufferLE(num, width) {
|
|
3119
|
-
{
|
|
3120
|
-
const hex = num.toString(16);
|
|
3121
|
-
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3122
|
-
buffer.reverse();
|
|
3123
|
-
return buffer;
|
|
3124
|
-
}
|
|
3125
|
-
}
|
|
3126
|
-
var toBufferLE_1 = browser.toBufferLE = toBufferLE;
|
|
3127
|
-
/**
|
|
3128
|
-
* Convert a BigInt to a big-endian buffer.
|
|
3129
|
-
* @param num The BigInt to convert.
|
|
3130
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3131
|
-
* @returns A big-endian buffer representation of num.
|
|
3132
|
-
*/
|
|
3133
|
-
function toBufferBE(num, width) {
|
|
3134
|
-
{
|
|
3135
|
-
const hex = num.toString(16);
|
|
3136
|
-
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
browser.toBufferBE = toBufferBE;
|
|
3140
|
-
|
|
3141
|
-
const bigInt = (length) => (property) => {
|
|
3142
|
-
const layout = blob(length, property);
|
|
3143
|
-
const { encode, decode } = encodeDecode(layout);
|
|
3144
|
-
const bigIntLayout = layout;
|
|
3145
|
-
bigIntLayout.decode = (buffer, offset) => {
|
|
3146
|
-
const src = decode(buffer, offset);
|
|
3147
|
-
return toBigIntLE_1(Buffer.from(src));
|
|
3148
|
-
};
|
|
3149
|
-
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3150
|
-
const src = toBufferLE_1(bigInt, length);
|
|
3151
|
-
return encode(src, buffer, offset);
|
|
3152
|
-
};
|
|
3153
|
-
return bigIntLayout;
|
|
3154
|
-
};
|
|
3155
|
-
const u64 = bigInt(8);
|
|
3156
|
-
|
|
3157
3067
|
/**
|
|
3158
3068
|
* Populate a buffer of instruction data using an InstructionType
|
|
3159
3069
|
* @internal
|
|
3160
3070
|
*/
|
|
3161
3071
|
function encodeData(type, fields) {
|
|
3162
3072
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3163
|
-
const data = Buffer
|
|
3073
|
+
const data = Buffer.alloc(allocLength);
|
|
3164
3074
|
const layoutFields = Object.assign({
|
|
3165
3075
|
instruction: type.index
|
|
3166
3076
|
}, fields);
|
|
@@ -4060,7 +3970,7 @@ class Loader {
|
|
|
4060
3970
|
|
|
4061
3971
|
while (array.length > 0) {
|
|
4062
3972
|
const bytes = array.slice(0, chunkSize);
|
|
4063
|
-
const data = Buffer
|
|
3973
|
+
const data = Buffer.alloc(chunkSize + 16);
|
|
4064
3974
|
dataLayout.encode({
|
|
4065
3975
|
instruction: 0,
|
|
4066
3976
|
// Load instruction
|
|
@@ -4095,7 +4005,7 @@ class Loader {
|
|
|
4095
4005
|
|
|
4096
4006
|
{
|
|
4097
4007
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4098
|
-
const data = Buffer
|
|
4008
|
+
const data = Buffer.alloc(dataLayout.span);
|
|
4099
4009
|
dataLayout.encode({
|
|
4100
4010
|
instruction: 1 // Finalize instruction
|
|
4101
4011
|
|
|
@@ -5083,7 +4993,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
5083
4993
|
|
|
5084
4994
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
5085
4995
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
5086
|
-
const BufferFromRawAccountData = coerce(instance(Buffer
|
|
4996
|
+
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
5087
4997
|
/**
|
|
5088
4998
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
5089
4999
|
* @internal
|
|
@@ -5506,7 +5416,7 @@ const KeyedAccountInfoResult = type({
|
|
|
5506
5416
|
pubkey: PublicKeyFromString,
|
|
5507
5417
|
account: AccountInfoResult
|
|
5508
5418
|
});
|
|
5509
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer
|
|
5419
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5510
5420
|
if (Array.isArray(value)) {
|
|
5511
5421
|
return create(value, BufferFromRawAccountData);
|
|
5512
5422
|
} else {
|
|
@@ -8435,7 +8345,7 @@ class Connection {
|
|
|
8435
8345
|
|
|
8436
8346
|
try {
|
|
8437
8347
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
8438
|
-
} catch {// Already removed.
|
|
8348
|
+
} catch (_err) {// Already removed.
|
|
8439
8349
|
}
|
|
8440
8350
|
}
|
|
8441
8351
|
},
|
|
@@ -8477,7 +8387,7 @@ class Connection {
|
|
|
8477
8387
|
|
|
8478
8388
|
try {
|
|
8479
8389
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
8480
|
-
} catch {// Already removed.
|
|
8390
|
+
} catch (_err) {// Already removed.
|
|
8481
8391
|
}
|
|
8482
8392
|
},
|
|
8483
8393
|
method: 'signatureSubscribe',
|
|
@@ -8664,7 +8574,7 @@ class Ed25519Program {
|
|
|
8664
8574
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8665
8575
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8666
8576
|
const numSignatures = 1;
|
|
8667
|
-
const instructionData = Buffer
|
|
8577
|
+
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8668
8578
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8669
8579
|
: instructionIndex;
|
|
8670
8580
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -9535,7 +9445,7 @@ class Secp256k1Program {
|
|
|
9535
9445
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
9536
9446
|
|
|
9537
9447
|
try {
|
|
9538
|
-
return Buffer
|
|
9448
|
+
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9539
9449
|
} catch (error) {
|
|
9540
9450
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
9541
9451
|
}
|
|
@@ -9580,9 +9490,9 @@ class Secp256k1Program {
|
|
|
9580
9490
|
|
|
9581
9491
|
if (typeof rawAddress === 'string') {
|
|
9582
9492
|
if (rawAddress.startsWith('0x')) {
|
|
9583
|
-
ethAddress = Buffer
|
|
9493
|
+
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9584
9494
|
} else {
|
|
9585
|
-
ethAddress = Buffer
|
|
9495
|
+
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9586
9496
|
}
|
|
9587
9497
|
} else {
|
|
9588
9498
|
ethAddress = rawAddress;
|
|
@@ -9594,7 +9504,7 @@ class Secp256k1Program {
|
|
|
9594
9504
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9595
9505
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9596
9506
|
const numSignatures = 1;
|
|
9597
|
-
const instructionData = Buffer
|
|
9507
|
+
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9598
9508
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9599
9509
|
numSignatures,
|
|
9600
9510
|
signatureOffset,
|
|
@@ -9633,7 +9543,7 @@ class Secp256k1Program {
|
|
|
9633
9543
|
const privateKey = toBuffer(pkey);
|
|
9634
9544
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9635
9545
|
|
|
9636
|
-
const messageHash = Buffer
|
|
9546
|
+
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9637
9547
|
const {
|
|
9638
9548
|
signature,
|
|
9639
9549
|
recid: recoveryId
|
|
@@ -9718,7 +9628,7 @@ class ValidatorInfo {
|
|
|
9718
9628
|
|
|
9719
9629
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9720
9630
|
if (configKeys[1].isSigner) {
|
|
9721
|
-
const rawInfo = rustString().decode(Buffer
|
|
9631
|
+
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9722
9632
|
const info = JSON.parse(rawInfo);
|
|
9723
9633
|
assert$7(info, InfoString);
|
|
9724
9634
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|