@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.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
|
|
|
@@ -2850,7 +2850,7 @@ class Transaction {
|
|
|
2850
2850
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2851
2851
|
}
|
|
2852
2852
|
|
|
2853
|
-
this.signatures[index].signature = Buffer
|
|
2853
|
+
this.signatures[index].signature = Buffer.from(signature);
|
|
2854
2854
|
}
|
|
2855
2855
|
/**
|
|
2856
2856
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2916,15 +2916,15 @@ class Transaction {
|
|
|
2916
2916
|
const signatureCount = [];
|
|
2917
2917
|
encodeLength(signatureCount, signatures.length);
|
|
2918
2918
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2919
|
-
const wireTransaction = Buffer
|
|
2919
|
+
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2920
2920
|
assert(signatures.length < 256);
|
|
2921
|
-
Buffer
|
|
2921
|
+
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2922
2922
|
signatures.forEach(({
|
|
2923
2923
|
signature
|
|
2924
2924
|
}, index) => {
|
|
2925
2925
|
if (signature !== null) {
|
|
2926
2926
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2927
|
-
Buffer
|
|
2927
|
+
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2928
2928
|
}
|
|
2929
2929
|
});
|
|
2930
2930
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2975,7 +2975,7 @@ class Transaction {
|
|
|
2975
2975
|
for (let i = 0; i < signatureCount; i++) {
|
|
2976
2976
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2977
2977
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2978
|
-
signatures.push(bs58.encode(Buffer
|
|
2978
|
+
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2979
2979
|
}
|
|
2980
2980
|
|
|
2981
2981
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3064,99 +3064,13 @@ function sleep(ms) {
|
|
|
3064
3064
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3065
3065
|
}
|
|
3066
3066
|
|
|
3067
|
-
const encodeDecode = (layout) => {
|
|
3068
|
-
const decode = layout.decode.bind(layout);
|
|
3069
|
-
const encode = layout.encode.bind(layout);
|
|
3070
|
-
return { decode, encode };
|
|
3071
|
-
};
|
|
3072
|
-
|
|
3073
|
-
var browser = {};
|
|
3074
|
-
|
|
3075
|
-
Object.defineProperty(browser, "__esModule", { value: true });
|
|
3076
|
-
/**
|
|
3077
|
-
* Convert a little-endian buffer into a BigInt.
|
|
3078
|
-
* @param buf The little-endian buffer to convert
|
|
3079
|
-
* @returns A BigInt with the little-endian representation of buf.
|
|
3080
|
-
*/
|
|
3081
|
-
function toBigIntLE(buf) {
|
|
3082
|
-
{
|
|
3083
|
-
const reversed = Buffer.from(buf);
|
|
3084
|
-
reversed.reverse();
|
|
3085
|
-
const hex = reversed.toString('hex');
|
|
3086
|
-
if (hex.length === 0) {
|
|
3087
|
-
return BigInt(0);
|
|
3088
|
-
}
|
|
3089
|
-
return BigInt(`0x${hex}`);
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
var toBigIntLE_1 = browser.toBigIntLE = toBigIntLE;
|
|
3093
|
-
/**
|
|
3094
|
-
* Convert a big-endian buffer into a BigInt
|
|
3095
|
-
* @param buf The big-endian buffer to convert.
|
|
3096
|
-
* @returns A BigInt with the big-endian representation of buf.
|
|
3097
|
-
*/
|
|
3098
|
-
function toBigIntBE(buf) {
|
|
3099
|
-
{
|
|
3100
|
-
const hex = buf.toString('hex');
|
|
3101
|
-
if (hex.length === 0) {
|
|
3102
|
-
return BigInt(0);
|
|
3103
|
-
}
|
|
3104
|
-
return BigInt(`0x${hex}`);
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
browser.toBigIntBE = toBigIntBE;
|
|
3108
|
-
/**
|
|
3109
|
-
* Convert a BigInt to a little-endian buffer.
|
|
3110
|
-
* @param num The BigInt to convert.
|
|
3111
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3112
|
-
* @returns A little-endian buffer representation of num.
|
|
3113
|
-
*/
|
|
3114
|
-
function toBufferLE(num, width) {
|
|
3115
|
-
{
|
|
3116
|
-
const hex = num.toString(16);
|
|
3117
|
-
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3118
|
-
buffer.reverse();
|
|
3119
|
-
return buffer;
|
|
3120
|
-
}
|
|
3121
|
-
}
|
|
3122
|
-
var toBufferLE_1 = browser.toBufferLE = toBufferLE;
|
|
3123
|
-
/**
|
|
3124
|
-
* Convert a BigInt to a big-endian buffer.
|
|
3125
|
-
* @param num The BigInt to convert.
|
|
3126
|
-
* @param width The number of bytes that the resulting buffer should be.
|
|
3127
|
-
* @returns A big-endian buffer representation of num.
|
|
3128
|
-
*/
|
|
3129
|
-
function toBufferBE(num, width) {
|
|
3130
|
-
{
|
|
3131
|
-
const hex = num.toString(16);
|
|
3132
|
-
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
browser.toBufferBE = toBufferBE;
|
|
3136
|
-
|
|
3137
|
-
const bigInt = (length) => (property) => {
|
|
3138
|
-
const layout = blob(length, property);
|
|
3139
|
-
const { encode, decode } = encodeDecode(layout);
|
|
3140
|
-
const bigIntLayout = layout;
|
|
3141
|
-
bigIntLayout.decode = (buffer, offset) => {
|
|
3142
|
-
const src = decode(buffer, offset);
|
|
3143
|
-
return toBigIntLE_1(Buffer.from(src));
|
|
3144
|
-
};
|
|
3145
|
-
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
3146
|
-
const src = toBufferLE_1(bigInt, length);
|
|
3147
|
-
return encode(src, buffer, offset);
|
|
3148
|
-
};
|
|
3149
|
-
return bigIntLayout;
|
|
3150
|
-
};
|
|
3151
|
-
const u64 = bigInt(8);
|
|
3152
|
-
|
|
3153
3067
|
/**
|
|
3154
3068
|
* Populate a buffer of instruction data using an InstructionType
|
|
3155
3069
|
* @internal
|
|
3156
3070
|
*/
|
|
3157
3071
|
function encodeData(type, fields) {
|
|
3158
3072
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3159
|
-
const data = Buffer
|
|
3073
|
+
const data = Buffer.alloc(allocLength);
|
|
3160
3074
|
const layoutFields = Object.assign({
|
|
3161
3075
|
instruction: type.index
|
|
3162
3076
|
}, fields);
|
|
@@ -4056,7 +3970,7 @@ class Loader {
|
|
|
4056
3970
|
|
|
4057
3971
|
while (array.length > 0) {
|
|
4058
3972
|
const bytes = array.slice(0, chunkSize);
|
|
4059
|
-
const data = Buffer
|
|
3973
|
+
const data = Buffer.alloc(chunkSize + 16);
|
|
4060
3974
|
dataLayout.encode({
|
|
4061
3975
|
instruction: 0,
|
|
4062
3976
|
// Load instruction
|
|
@@ -4091,7 +4005,7 @@ class Loader {
|
|
|
4091
4005
|
|
|
4092
4006
|
{
|
|
4093
4007
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4094
|
-
const data = Buffer
|
|
4008
|
+
const data = Buffer.alloc(dataLayout.span);
|
|
4095
4009
|
dataLayout.encode({
|
|
4096
4010
|
instruction: 1 // Finalize instruction
|
|
4097
4011
|
|
|
@@ -5079,7 +4993,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
5079
4993
|
|
|
5080
4994
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
5081
4995
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
5082
|
-
const BufferFromRawAccountData = coerce(instance(Buffer
|
|
4996
|
+
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
5083
4997
|
/**
|
|
5084
4998
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
5085
4999
|
* @internal
|
|
@@ -5502,7 +5416,7 @@ const KeyedAccountInfoResult = type({
|
|
|
5502
5416
|
pubkey: PublicKeyFromString,
|
|
5503
5417
|
account: AccountInfoResult
|
|
5504
5418
|
});
|
|
5505
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer
|
|
5419
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5506
5420
|
if (Array.isArray(value)) {
|
|
5507
5421
|
return create(value, BufferFromRawAccountData);
|
|
5508
5422
|
} else {
|
|
@@ -8431,7 +8345,7 @@ class Connection {
|
|
|
8431
8345
|
|
|
8432
8346
|
try {
|
|
8433
8347
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
8434
|
-
} catch {// Already removed.
|
|
8348
|
+
} catch (_err) {// Already removed.
|
|
8435
8349
|
}
|
|
8436
8350
|
}
|
|
8437
8351
|
},
|
|
@@ -8473,7 +8387,7 @@ class Connection {
|
|
|
8473
8387
|
|
|
8474
8388
|
try {
|
|
8475
8389
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
8476
|
-
} catch {// Already removed.
|
|
8390
|
+
} catch (_err) {// Already removed.
|
|
8477
8391
|
}
|
|
8478
8392
|
},
|
|
8479
8393
|
method: 'signatureSubscribe',
|
|
@@ -8660,7 +8574,7 @@ class Ed25519Program {
|
|
|
8660
8574
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8661
8575
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8662
8576
|
const numSignatures = 1;
|
|
8663
|
-
const instructionData = Buffer
|
|
8577
|
+
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8664
8578
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8665
8579
|
: instructionIndex;
|
|
8666
8580
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -9531,7 +9445,7 @@ class Secp256k1Program {
|
|
|
9531
9445
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
9532
9446
|
|
|
9533
9447
|
try {
|
|
9534
|
-
return Buffer
|
|
9448
|
+
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9535
9449
|
} catch (error) {
|
|
9536
9450
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
9537
9451
|
}
|
|
@@ -9576,9 +9490,9 @@ class Secp256k1Program {
|
|
|
9576
9490
|
|
|
9577
9491
|
if (typeof rawAddress === 'string') {
|
|
9578
9492
|
if (rawAddress.startsWith('0x')) {
|
|
9579
|
-
ethAddress = Buffer
|
|
9493
|
+
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9580
9494
|
} else {
|
|
9581
|
-
ethAddress = Buffer
|
|
9495
|
+
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9582
9496
|
}
|
|
9583
9497
|
} else {
|
|
9584
9498
|
ethAddress = rawAddress;
|
|
@@ -9590,7 +9504,7 @@ class Secp256k1Program {
|
|
|
9590
9504
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9591
9505
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9592
9506
|
const numSignatures = 1;
|
|
9593
|
-
const instructionData = Buffer
|
|
9507
|
+
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9594
9508
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9595
9509
|
numSignatures,
|
|
9596
9510
|
signatureOffset,
|
|
@@ -9629,7 +9543,7 @@ class Secp256k1Program {
|
|
|
9629
9543
|
const privateKey = toBuffer(pkey);
|
|
9630
9544
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9631
9545
|
|
|
9632
|
-
const messageHash = Buffer
|
|
9546
|
+
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9633
9547
|
const {
|
|
9634
9548
|
signature,
|
|
9635
9549
|
recid: recoveryId
|
|
@@ -9714,7 +9628,7 @@ class ValidatorInfo {
|
|
|
9714
9628
|
|
|
9715
9629
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9716
9630
|
if (configKeys[1].isSigner) {
|
|
9717
|
-
const rawInfo = rustString().decode(Buffer
|
|
9631
|
+
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9718
9632
|
const info = JSON.parse(rawInfo);
|
|
9719
9633
|
assert$7(info, InfoString);
|
|
9720
9634
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|