@solana/web3.js 1.41.3 → 1.41.6
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 +93 -11
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +140 -57
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +110 -14
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +30 -4
- package/lib/index.esm.js +158 -61
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +12193 -12111
- 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 +4 -3
- package/src/connection.ts +2 -2
- package/src/system-program.ts +39 -10
- package/src/transaction.ts +4 -6
package/lib/index.browser.esm.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import nacl from 'tweetnacl';
|
|
2
|
-
import { Buffer } from 'buffer';
|
|
2
|
+
import { Buffer as Buffer$1 } 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 { blob } from '@solana/buffer-layout';
|
|
7
8
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
8
9
|
import { Client } from 'rpc-websockets';
|
|
9
10
|
import RpcClient from 'jayson/lib/client/browser';
|
|
@@ -11,12 +12,12 @@ import secp256k1 from 'secp256k1';
|
|
|
11
12
|
import sha3 from 'js-sha3';
|
|
12
13
|
|
|
13
14
|
const toBuffer = arr => {
|
|
14
|
-
if (Buffer.isBuffer(arr)) {
|
|
15
|
+
if (Buffer$1.isBuffer(arr)) {
|
|
15
16
|
return arr;
|
|
16
17
|
} else if (arr instanceof Uint8Array) {
|
|
17
|
-
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
18
|
+
return Buffer$1.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
18
19
|
} else {
|
|
19
|
-
return Buffer.from(arr);
|
|
20
|
+
return Buffer$1.from(arr);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
|
|
@@ -1737,7 +1738,7 @@ class Struct {
|
|
|
1737
1738
|
}
|
|
1738
1739
|
|
|
1739
1740
|
encode() {
|
|
1740
|
-
return Buffer.from(serialize(SOLANA_SCHEMA, this));
|
|
1741
|
+
return Buffer$1.from(serialize(SOLANA_SCHEMA, this));
|
|
1741
1742
|
}
|
|
1742
1743
|
|
|
1743
1744
|
static decode(data) {
|
|
@@ -1854,13 +1855,13 @@ class PublicKey extends Struct {
|
|
|
1854
1855
|
|
|
1855
1856
|
|
|
1856
1857
|
toBuffer() {
|
|
1857
|
-
const b = this._bn.toArrayLike(Buffer);
|
|
1858
|
+
const b = this._bn.toArrayLike(Buffer$1);
|
|
1858
1859
|
|
|
1859
1860
|
if (b.length === 32) {
|
|
1860
1861
|
return b;
|
|
1861
1862
|
}
|
|
1862
1863
|
|
|
1863
|
-
const zeroPad = Buffer.alloc(32);
|
|
1864
|
+
const zeroPad = Buffer$1.alloc(32);
|
|
1864
1865
|
b.copy(zeroPad, 32 - b.length);
|
|
1865
1866
|
return zeroPad;
|
|
1866
1867
|
}
|
|
@@ -1882,9 +1883,9 @@ class PublicKey extends Struct {
|
|
|
1882
1883
|
|
|
1883
1884
|
|
|
1884
1885
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
1885
|
-
const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
|
|
1886
|
+
const buffer = Buffer$1.concat([fromPublicKey.toBuffer(), Buffer$1.from(seed), programId.toBuffer()]);
|
|
1886
1887
|
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1887
|
-
return new PublicKey(Buffer.from(hash, 'hex'));
|
|
1888
|
+
return new PublicKey(Buffer$1.from(hash, 'hex'));
|
|
1888
1889
|
}
|
|
1889
1890
|
/**
|
|
1890
1891
|
* Derive a program address from seeds and a program ID.
|
|
@@ -1894,15 +1895,15 @@ class PublicKey extends Struct {
|
|
|
1894
1895
|
|
|
1895
1896
|
|
|
1896
1897
|
static createProgramAddressSync(seeds, programId) {
|
|
1897
|
-
let buffer = Buffer.alloc(0);
|
|
1898
|
+
let buffer = Buffer$1.alloc(0);
|
|
1898
1899
|
seeds.forEach(function (seed) {
|
|
1899
1900
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
1900
1901
|
throw new TypeError(`Max seed length exceeded`);
|
|
1901
1902
|
}
|
|
1902
1903
|
|
|
1903
|
-
buffer = Buffer.concat([buffer, toBuffer(seed)]);
|
|
1904
|
+
buffer = Buffer$1.concat([buffer, toBuffer(seed)]);
|
|
1904
1905
|
});
|
|
1905
|
-
buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
|
|
1906
|
+
buffer = Buffer$1.concat([buffer, programId.toBuffer(), Buffer$1.from('ProgramDerivedAddress')]);
|
|
1906
1907
|
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1907
1908
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
1908
1909
|
|
|
@@ -1938,7 +1939,7 @@ class PublicKey extends Struct {
|
|
|
1938
1939
|
|
|
1939
1940
|
while (nonce != 0) {
|
|
1940
1941
|
try {
|
|
1941
|
-
const seedsWithNonce = seeds.concat(Buffer.from([nonce]));
|
|
1942
|
+
const seedsWithNonce = seeds.concat(Buffer$1.from([nonce]));
|
|
1942
1943
|
address = this.createProgramAddressSync(seedsWithNonce, programId);
|
|
1943
1944
|
} catch (err) {
|
|
1944
1945
|
if (err instanceof TypeError) {
|
|
@@ -2114,13 +2115,13 @@ const rustString = (property = 'string') => {
|
|
|
2114
2115
|
|
|
2115
2116
|
rslShim.encode = (str, b, offset) => {
|
|
2116
2117
|
const data = {
|
|
2117
|
-
chars: Buffer.from(str, 'utf8')
|
|
2118
|
+
chars: Buffer$1.from(str, 'utf8')
|
|
2118
2119
|
};
|
|
2119
2120
|
return _encode(data, b, offset);
|
|
2120
2121
|
};
|
|
2121
2122
|
|
|
2122
2123
|
rslShim.alloc = str => {
|
|
2123
|
-
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;
|
|
2124
|
+
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer$1.from(str, 'utf8').length;
|
|
2124
2125
|
};
|
|
2125
2126
|
|
|
2126
2127
|
return rslShim;
|
|
@@ -2250,16 +2251,16 @@ class Message {
|
|
|
2250
2251
|
encodeLength(dataCount, data.length);
|
|
2251
2252
|
return {
|
|
2252
2253
|
programIdIndex,
|
|
2253
|
-
keyIndicesCount: Buffer.from(keyIndicesCount),
|
|
2254
|
+
keyIndicesCount: Buffer$1.from(keyIndicesCount),
|
|
2254
2255
|
keyIndices: accounts,
|
|
2255
|
-
dataLength: Buffer.from(dataCount),
|
|
2256
|
+
dataLength: Buffer$1.from(dataCount),
|
|
2256
2257
|
data
|
|
2257
2258
|
};
|
|
2258
2259
|
});
|
|
2259
2260
|
let instructionCount = [];
|
|
2260
2261
|
encodeLength(instructionCount, instructions.length);
|
|
2261
|
-
let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);
|
|
2262
|
-
Buffer.from(instructionCount).copy(instructionBuffer);
|
|
2262
|
+
let instructionBuffer = Buffer$1.alloc(PACKET_DATA_SIZE);
|
|
2263
|
+
Buffer$1.from(instructionCount).copy(instructionBuffer);
|
|
2263
2264
|
let instructionBufferLength = instructionCount.length;
|
|
2264
2265
|
instructions.forEach(instruction => {
|
|
2265
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')]);
|
|
@@ -2269,14 +2270,14 @@ class Message {
|
|
|
2269
2270
|
instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);
|
|
2270
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')]);
|
|
2271
2272
|
const transaction = {
|
|
2272
|
-
numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),
|
|
2273
|
-
numReadonlySignedAccounts: Buffer.from([this.header.numReadonlySignedAccounts]),
|
|
2274
|
-
numReadonlyUnsignedAccounts: Buffer.from([this.header.numReadonlyUnsignedAccounts]),
|
|
2275
|
-
keyCount: Buffer.from(keyCount),
|
|
2273
|
+
numRequiredSignatures: Buffer$1.from([this.header.numRequiredSignatures]),
|
|
2274
|
+
numReadonlySignedAccounts: Buffer$1.from([this.header.numReadonlySignedAccounts]),
|
|
2275
|
+
numReadonlyUnsignedAccounts: Buffer$1.from([this.header.numReadonlyUnsignedAccounts]),
|
|
2276
|
+
keyCount: Buffer$1.from(keyCount),
|
|
2276
2277
|
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
|
2277
2278
|
recentBlockhash: bs58.decode(this.recentBlockhash)
|
|
2278
2279
|
};
|
|
2279
|
-
let signData = Buffer.alloc(2048);
|
|
2280
|
+
let signData = Buffer$1.alloc(2048);
|
|
2280
2281
|
const length = signDataLayout.encode(transaction, signData);
|
|
2281
2282
|
instructionBuffer.copy(signData, length);
|
|
2282
2283
|
return signData.slice(0, length + instructionBuffer.length);
|
|
@@ -2298,7 +2299,7 @@ class Message {
|
|
|
2298
2299
|
for (let i = 0; i < accountCount; i++) {
|
|
2299
2300
|
const account = byteArray.slice(0, PUBKEY_LENGTH);
|
|
2300
2301
|
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2301
|
-
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2302
|
+
accountKeys.push(bs58.encode(Buffer$1.from(account)));
|
|
2302
2303
|
}
|
|
2303
2304
|
|
|
2304
2305
|
const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
|
|
@@ -2313,7 +2314,7 @@ class Message {
|
|
|
2313
2314
|
byteArray = byteArray.slice(accountCount);
|
|
2314
2315
|
const dataLength = decodeLength(byteArray);
|
|
2315
2316
|
const dataSlice = byteArray.slice(0, dataLength);
|
|
2316
|
-
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2317
|
+
const data = bs58.encode(Buffer$1.from(dataSlice));
|
|
2317
2318
|
byteArray = byteArray.slice(dataLength);
|
|
2318
2319
|
instructions.push({
|
|
2319
2320
|
programIdIndex,
|
|
@@ -2328,7 +2329,7 @@ class Message {
|
|
|
2328
2329
|
numReadonlySignedAccounts,
|
|
2329
2330
|
numReadonlyUnsignedAccounts
|
|
2330
2331
|
},
|
|
2331
|
-
recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),
|
|
2332
|
+
recentBlockhash: bs58.encode(Buffer$1.from(recentBlockhash)),
|
|
2332
2333
|
accountKeys,
|
|
2333
2334
|
instructions
|
|
2334
2335
|
};
|
|
@@ -2346,7 +2347,7 @@ function assert (condition, message) {
|
|
|
2346
2347
|
/**
|
|
2347
2348
|
* Default (empty) signature
|
|
2348
2349
|
*/
|
|
2349
|
-
const DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2350
|
+
const DEFAULT_SIGNATURE = Buffer$1.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2350
2351
|
/**
|
|
2351
2352
|
* Account metadata used to define instructions
|
|
2352
2353
|
*/
|
|
@@ -2370,7 +2371,7 @@ class TransactionInstruction {
|
|
|
2370
2371
|
constructor(opts) {
|
|
2371
2372
|
this.keys = void 0;
|
|
2372
2373
|
this.programId = void 0;
|
|
2373
|
-
this.data = Buffer.alloc(0);
|
|
2374
|
+
this.data = Buffer$1.alloc(0);
|
|
2374
2375
|
this.programId = opts.programId;
|
|
2375
2376
|
this.keys = opts.keys;
|
|
2376
2377
|
|
|
@@ -2489,11 +2490,7 @@ class Transaction {
|
|
|
2489
2490
|
|
|
2490
2491
|
|
|
2491
2492
|
compileMessage() {
|
|
2492
|
-
if (this._message) {
|
|
2493
|
-
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
|
2494
|
-
throw new Error('Transaction message mutated after being populated from Message');
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2493
|
+
if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {
|
|
2497
2494
|
return this._message;
|
|
2498
2495
|
}
|
|
2499
2496
|
|
|
@@ -2853,7 +2850,7 @@ class Transaction {
|
|
|
2853
2850
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2854
2851
|
}
|
|
2855
2852
|
|
|
2856
|
-
this.signatures[index].signature = Buffer.from(signature);
|
|
2853
|
+
this.signatures[index].signature = Buffer$1.from(signature);
|
|
2857
2854
|
}
|
|
2858
2855
|
/**
|
|
2859
2856
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2919,15 +2916,15 @@ class Transaction {
|
|
|
2919
2916
|
const signatureCount = [];
|
|
2920
2917
|
encodeLength(signatureCount, signatures.length);
|
|
2921
2918
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2922
|
-
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2919
|
+
const wireTransaction = Buffer$1.alloc(transactionLength);
|
|
2923
2920
|
assert(signatures.length < 256);
|
|
2924
|
-
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2921
|
+
Buffer$1.from(signatureCount).copy(wireTransaction, 0);
|
|
2925
2922
|
signatures.forEach(({
|
|
2926
2923
|
signature
|
|
2927
2924
|
}, index) => {
|
|
2928
2925
|
if (signature !== null) {
|
|
2929
2926
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2930
|
-
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2927
|
+
Buffer$1.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2931
2928
|
}
|
|
2932
2929
|
});
|
|
2933
2930
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2978,7 +2975,7 @@ class Transaction {
|
|
|
2978
2975
|
for (let i = 0; i < signatureCount; i++) {
|
|
2979
2976
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2980
2977
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2981
|
-
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2978
|
+
signatures.push(bs58.encode(Buffer$1.from(signature)));
|
|
2982
2979
|
}
|
|
2983
2980
|
|
|
2984
2981
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3067,13 +3064,99 @@ function sleep(ms) {
|
|
|
3067
3064
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3068
3065
|
}
|
|
3069
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
|
+
|
|
3070
3153
|
/**
|
|
3071
3154
|
* Populate a buffer of instruction data using an InstructionType
|
|
3072
3155
|
* @internal
|
|
3073
3156
|
*/
|
|
3074
3157
|
function encodeData(type, fields) {
|
|
3075
3158
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3076
|
-
const data = Buffer.alloc(allocLength);
|
|
3159
|
+
const data = Buffer$1.alloc(allocLength);
|
|
3077
3160
|
const layoutFields = Object.assign({
|
|
3078
3161
|
instruction: type.index
|
|
3079
3162
|
}, fields);
|
|
@@ -3456,7 +3539,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3456
3539
|
},
|
|
3457
3540
|
Transfer: {
|
|
3458
3541
|
index: 2,
|
|
3459
|
-
layout: BufferLayout.struct([BufferLayout.u32('instruction'),
|
|
3542
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports')])
|
|
3460
3543
|
},
|
|
3461
3544
|
CreateWithSeed: {
|
|
3462
3545
|
index: 3,
|
|
@@ -3492,7 +3575,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3492
3575
|
},
|
|
3493
3576
|
TransferWithSeed: {
|
|
3494
3577
|
index: 11,
|
|
3495
|
-
layout: BufferLayout.struct([BufferLayout.u32('instruction'),
|
|
3578
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
3496
3579
|
}
|
|
3497
3580
|
});
|
|
3498
3581
|
/**
|
|
@@ -3545,7 +3628,7 @@ class SystemProgram {
|
|
|
3545
3628
|
if ('basePubkey' in params) {
|
|
3546
3629
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
|
|
3547
3630
|
data = encodeData(type, {
|
|
3548
|
-
lamports: params.lamports,
|
|
3631
|
+
lamports: BigInt(params.lamports),
|
|
3549
3632
|
seed: params.seed,
|
|
3550
3633
|
programId: toBuffer(params.programId.toBuffer())
|
|
3551
3634
|
});
|
|
@@ -3565,7 +3648,7 @@ class SystemProgram {
|
|
|
3565
3648
|
} else {
|
|
3566
3649
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
|
|
3567
3650
|
data = encodeData(type, {
|
|
3568
|
-
lamports: params.lamports
|
|
3651
|
+
lamports: BigInt(params.lamports)
|
|
3569
3652
|
});
|
|
3570
3653
|
keys = [{
|
|
3571
3654
|
pubkey: params.fromPubkey,
|
|
@@ -3973,7 +4056,7 @@ class Loader {
|
|
|
3973
4056
|
|
|
3974
4057
|
while (array.length > 0) {
|
|
3975
4058
|
const bytes = array.slice(0, chunkSize);
|
|
3976
|
-
const data = Buffer.alloc(chunkSize + 16);
|
|
4059
|
+
const data = Buffer$1.alloc(chunkSize + 16);
|
|
3977
4060
|
dataLayout.encode({
|
|
3978
4061
|
instruction: 0,
|
|
3979
4062
|
// Load instruction
|
|
@@ -4008,7 +4091,7 @@ class Loader {
|
|
|
4008
4091
|
|
|
4009
4092
|
{
|
|
4010
4093
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4011
|
-
const data = Buffer.alloc(dataLayout.span);
|
|
4094
|
+
const data = Buffer$1.alloc(dataLayout.span);
|
|
4012
4095
|
dataLayout.encode({
|
|
4013
4096
|
instruction: 1 // Finalize instruction
|
|
4014
4097
|
|
|
@@ -4996,7 +5079,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4996
5079
|
|
|
4997
5080
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4998
5081
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4999
|
-
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
5082
|
+
const BufferFromRawAccountData = coerce(instance(Buffer$1), RawAccountDataResult, value => Buffer$1.from(value[0], 'base64'));
|
|
5000
5083
|
/**
|
|
5001
5084
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
5002
5085
|
* @internal
|
|
@@ -5419,7 +5502,7 @@ const KeyedAccountInfoResult = type({
|
|
|
5419
5502
|
pubkey: PublicKeyFromString,
|
|
5420
5503
|
account: AccountInfoResult
|
|
5421
5504
|
});
|
|
5422
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5505
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer$1), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5423
5506
|
if (Array.isArray(value)) {
|
|
5424
5507
|
return create(value, BufferFromRawAccountData);
|
|
5425
5508
|
} else {
|
|
@@ -8348,7 +8431,7 @@ class Connection {
|
|
|
8348
8431
|
|
|
8349
8432
|
try {
|
|
8350
8433
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
8351
|
-
} catch {// Already removed.
|
|
8434
|
+
} catch (_err) {// Already removed.
|
|
8352
8435
|
}
|
|
8353
8436
|
}
|
|
8354
8437
|
},
|
|
@@ -8390,7 +8473,7 @@ class Connection {
|
|
|
8390
8473
|
|
|
8391
8474
|
try {
|
|
8392
8475
|
this.removeSignatureListener(clientSubscriptionId); // eslint-disable-next-line no-empty
|
|
8393
|
-
} catch {// Already removed.
|
|
8476
|
+
} catch (_err) {// Already removed.
|
|
8394
8477
|
}
|
|
8395
8478
|
},
|
|
8396
8479
|
method: 'signatureSubscribe',
|
|
@@ -8577,7 +8660,7 @@ class Ed25519Program {
|
|
|
8577
8660
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8578
8661
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8579
8662
|
const numSignatures = 1;
|
|
8580
|
-
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8663
|
+
const instructionData = Buffer$1.alloc(messageDataOffset + message.length);
|
|
8581
8664
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8582
8665
|
: instructionIndex;
|
|
8583
8666
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -9448,7 +9531,7 @@ class Secp256k1Program {
|
|
|
9448
9531
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
9449
9532
|
|
|
9450
9533
|
try {
|
|
9451
|
-
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9534
|
+
return Buffer$1.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9452
9535
|
} catch (error) {
|
|
9453
9536
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
9454
9537
|
}
|
|
@@ -9493,9 +9576,9 @@ class Secp256k1Program {
|
|
|
9493
9576
|
|
|
9494
9577
|
if (typeof rawAddress === 'string') {
|
|
9495
9578
|
if (rawAddress.startsWith('0x')) {
|
|
9496
|
-
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9579
|
+
ethAddress = Buffer$1.from(rawAddress.substr(2), 'hex');
|
|
9497
9580
|
} else {
|
|
9498
|
-
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9581
|
+
ethAddress = Buffer$1.from(rawAddress, 'hex');
|
|
9499
9582
|
}
|
|
9500
9583
|
} else {
|
|
9501
9584
|
ethAddress = rawAddress;
|
|
@@ -9507,7 +9590,7 @@ class Secp256k1Program {
|
|
|
9507
9590
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9508
9591
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9509
9592
|
const numSignatures = 1;
|
|
9510
|
-
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9593
|
+
const instructionData = Buffer$1.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9511
9594
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9512
9595
|
numSignatures,
|
|
9513
9596
|
signatureOffset,
|
|
@@ -9546,7 +9629,7 @@ class Secp256k1Program {
|
|
|
9546
9629
|
const privateKey = toBuffer(pkey);
|
|
9547
9630
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9548
9631
|
|
|
9549
|
-
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9632
|
+
const messageHash = Buffer$1.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9550
9633
|
const {
|
|
9551
9634
|
signature,
|
|
9552
9635
|
recid: recoveryId
|
|
@@ -9631,7 +9714,7 @@ class ValidatorInfo {
|
|
|
9631
9714
|
|
|
9632
9715
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9633
9716
|
if (configKeys[1].isSigner) {
|
|
9634
|
-
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9717
|
+
const rawInfo = rustString().decode(Buffer$1.from(byteArray));
|
|
9635
9718
|
const info = JSON.parse(rawInfo);
|
|
9636
9719
|
assert$7(info, InfoString);
|
|
9637
9720
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|