@solana/web3.js 1.41.2 → 1.41.5
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 -9
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +139 -56
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +110 -12
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +40 -4
- package/lib/index.esm.js +157 -60
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +12206 -12122
- 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/index.ts +1 -0
- package/src/system-program.ts +39 -10
- package/src/transaction.ts +4 -6
package/lib/index.d.ts
CHANGED
|
@@ -2632,7 +2632,7 @@ declare module '@solana/web3.js' {
|
|
|
2632
2632
|
/** Account that will receive transferred lamports */
|
|
2633
2633
|
toPubkey: PublicKey;
|
|
2634
2634
|
/** Amount of lamports to transfer */
|
|
2635
|
-
lamports: number;
|
|
2635
|
+
lamports: number | bigint;
|
|
2636
2636
|
};
|
|
2637
2637
|
/**
|
|
2638
2638
|
* Assign system transaction params
|
|
@@ -2782,7 +2782,31 @@ declare module '@solana/web3.js' {
|
|
|
2782
2782
|
/** Account that will receive transferred lamports */
|
|
2783
2783
|
toPubkey: PublicKey;
|
|
2784
2784
|
/** Amount of lamports to transfer */
|
|
2785
|
-
lamports: number;
|
|
2785
|
+
lamports: number | bigint;
|
|
2786
|
+
/** Seed to use to derive the funding account address */
|
|
2787
|
+
seed: string;
|
|
2788
|
+
/** Program id to use to derive the funding account address */
|
|
2789
|
+
programId: PublicKey;
|
|
2790
|
+
};
|
|
2791
|
+
/** Decoded transfer system transaction instruction */
|
|
2792
|
+
export type DecodedTransferInstruction = {
|
|
2793
|
+
/** Account that will transfer lamports */
|
|
2794
|
+
fromPubkey: PublicKey;
|
|
2795
|
+
/** Account that will receive transferred lamports */
|
|
2796
|
+
toPubkey: PublicKey;
|
|
2797
|
+
/** Amount of lamports to transfer */
|
|
2798
|
+
lamports: bigint;
|
|
2799
|
+
};
|
|
2800
|
+
/** Decoded transferWithSeed system transaction instruction */
|
|
2801
|
+
export type DecodedTransferWithSeedInstruction = {
|
|
2802
|
+
/** Account that will transfer lamports */
|
|
2803
|
+
fromPubkey: PublicKey;
|
|
2804
|
+
/** Base public key to use to derive the funding account address */
|
|
2805
|
+
basePubkey: PublicKey;
|
|
2806
|
+
/** Account that will receive transferred lamports */
|
|
2807
|
+
toPubkey: PublicKey;
|
|
2808
|
+
/** Amount of lamports to transfer */
|
|
2809
|
+
lamports: bigint;
|
|
2786
2810
|
/** Seed to use to derive the funding account address */
|
|
2787
2811
|
seed: string;
|
|
2788
2812
|
/** Program id to use to derive the funding account address */
|
|
@@ -2807,13 +2831,15 @@ declare module '@solana/web3.js' {
|
|
|
2807
2831
|
/**
|
|
2808
2832
|
* Decode a transfer system instruction and retrieve the instruction params.
|
|
2809
2833
|
*/
|
|
2810
|
-
static decodeTransfer(
|
|
2834
|
+
static decodeTransfer(
|
|
2835
|
+
instruction: TransactionInstruction,
|
|
2836
|
+
): DecodedTransferInstruction;
|
|
2811
2837
|
/**
|
|
2812
2838
|
* Decode a transfer with seed system instruction and retrieve the instruction params.
|
|
2813
2839
|
*/
|
|
2814
2840
|
static decodeTransferWithSeed(
|
|
2815
2841
|
instruction: TransactionInstruction,
|
|
2816
|
-
):
|
|
2842
|
+
): DecodedTransferWithSeedInstruction;
|
|
2817
2843
|
/**
|
|
2818
2844
|
* Decode an allocate system instruction and retrieve the instruction params.
|
|
2819
2845
|
*/
|
|
@@ -3008,6 +3034,16 @@ declare module '@solana/web3.js' {
|
|
|
3008
3034
|
): TransactionInstruction;
|
|
3009
3035
|
}
|
|
3010
3036
|
|
|
3037
|
+
/**
|
|
3038
|
+
* Maximum over-the-wire size of a Transaction
|
|
3039
|
+
*
|
|
3040
|
+
* 1280 is IPv6 minimum MTU
|
|
3041
|
+
* 40 bytes is the size of the IPv6 header
|
|
3042
|
+
* 8 bytes is the size of the fragment header
|
|
3043
|
+
*/
|
|
3044
|
+
export const PACKET_DATA_SIZE: number;
|
|
3045
|
+
export const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
3046
|
+
|
|
3011
3047
|
export const VALIDATOR_INFO_KEY: PublicKey;
|
|
3012
3048
|
/**
|
|
3013
3049
|
* Info used to identity validators.
|
package/lib/index.esm.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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
|
|
7
|
+
import { blob } from '@solana/buffer-layout';
|
|
8
|
+
import fetch from 'cross-fetch';
|
|
8
9
|
import { coerce, instance, string, tuple, literal, unknown, union, type, optional, any, number, array, nullable, create, boolean, record, assert as assert$7 } from 'superstruct';
|
|
9
10
|
import { Client } from 'rpc-websockets';
|
|
10
11
|
import RpcClient from 'jayson/lib/client/browser';
|
|
@@ -14,12 +15,12 @@ import secp256k1 from 'secp256k1';
|
|
|
14
15
|
import sha3 from 'js-sha3';
|
|
15
16
|
|
|
16
17
|
const toBuffer = arr => {
|
|
17
|
-
if (Buffer.isBuffer(arr)) {
|
|
18
|
+
if (Buffer$1.isBuffer(arr)) {
|
|
18
19
|
return arr;
|
|
19
20
|
} else if (arr instanceof Uint8Array) {
|
|
20
|
-
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
21
|
+
return Buffer$1.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
21
22
|
} else {
|
|
22
|
-
return Buffer.from(arr);
|
|
23
|
+
return Buffer$1.from(arr);
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -1746,7 +1747,7 @@ class Struct {
|
|
|
1746
1747
|
}
|
|
1747
1748
|
|
|
1748
1749
|
encode() {
|
|
1749
|
-
return Buffer.from(serialize(SOLANA_SCHEMA, this));
|
|
1750
|
+
return Buffer$1.from(serialize(SOLANA_SCHEMA, this));
|
|
1750
1751
|
}
|
|
1751
1752
|
|
|
1752
1753
|
static decode(data) {
|
|
@@ -1863,13 +1864,13 @@ class PublicKey extends Struct {
|
|
|
1863
1864
|
|
|
1864
1865
|
|
|
1865
1866
|
toBuffer() {
|
|
1866
|
-
const b = this._bn.toArrayLike(Buffer);
|
|
1867
|
+
const b = this._bn.toArrayLike(Buffer$1);
|
|
1867
1868
|
|
|
1868
1869
|
if (b.length === 32) {
|
|
1869
1870
|
return b;
|
|
1870
1871
|
}
|
|
1871
1872
|
|
|
1872
|
-
const zeroPad = Buffer.alloc(32);
|
|
1873
|
+
const zeroPad = Buffer$1.alloc(32);
|
|
1873
1874
|
b.copy(zeroPad, 32 - b.length);
|
|
1874
1875
|
return zeroPad;
|
|
1875
1876
|
}
|
|
@@ -1891,9 +1892,9 @@ class PublicKey extends Struct {
|
|
|
1891
1892
|
|
|
1892
1893
|
|
|
1893
1894
|
static async createWithSeed(fromPublicKey, seed, programId) {
|
|
1894
|
-
const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);
|
|
1895
|
+
const buffer = Buffer$1.concat([fromPublicKey.toBuffer(), Buffer$1.from(seed), programId.toBuffer()]);
|
|
1895
1896
|
const hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1896
|
-
return new PublicKey(Buffer.from(hash, 'hex'));
|
|
1897
|
+
return new PublicKey(Buffer$1.from(hash, 'hex'));
|
|
1897
1898
|
}
|
|
1898
1899
|
/**
|
|
1899
1900
|
* Derive a program address from seeds and a program ID.
|
|
@@ -1903,15 +1904,15 @@ class PublicKey extends Struct {
|
|
|
1903
1904
|
|
|
1904
1905
|
|
|
1905
1906
|
static createProgramAddressSync(seeds, programId) {
|
|
1906
|
-
let buffer = Buffer.alloc(0);
|
|
1907
|
+
let buffer = Buffer$1.alloc(0);
|
|
1907
1908
|
seeds.forEach(function (seed) {
|
|
1908
1909
|
if (seed.length > MAX_SEED_LENGTH) {
|
|
1909
1910
|
throw new TypeError(`Max seed length exceeded`);
|
|
1910
1911
|
}
|
|
1911
1912
|
|
|
1912
|
-
buffer = Buffer.concat([buffer, toBuffer(seed)]);
|
|
1913
|
+
buffer = Buffer$1.concat([buffer, toBuffer(seed)]);
|
|
1913
1914
|
});
|
|
1914
|
-
buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);
|
|
1915
|
+
buffer = Buffer$1.concat([buffer, programId.toBuffer(), Buffer$1.from('ProgramDerivedAddress')]);
|
|
1915
1916
|
let hash = sha256(new Uint8Array(buffer)).slice(2);
|
|
1916
1917
|
let publicKeyBytes = new BN(hash, 16).toArray(undefined, 32);
|
|
1917
1918
|
|
|
@@ -1947,7 +1948,7 @@ class PublicKey extends Struct {
|
|
|
1947
1948
|
|
|
1948
1949
|
while (nonce != 0) {
|
|
1949
1950
|
try {
|
|
1950
|
-
const seedsWithNonce = seeds.concat(Buffer.from([nonce]));
|
|
1951
|
+
const seedsWithNonce = seeds.concat(Buffer$1.from([nonce]));
|
|
1951
1952
|
address = this.createProgramAddressSync(seedsWithNonce, programId);
|
|
1952
1953
|
} catch (err) {
|
|
1953
1954
|
if (err instanceof TypeError) {
|
|
@@ -2123,13 +2124,13 @@ const rustString = (property = 'string') => {
|
|
|
2123
2124
|
|
|
2124
2125
|
rslShim.encode = (str, b, offset) => {
|
|
2125
2126
|
const data = {
|
|
2126
|
-
chars: Buffer.from(str, 'utf8')
|
|
2127
|
+
chars: Buffer$1.from(str, 'utf8')
|
|
2127
2128
|
};
|
|
2128
2129
|
return _encode(data, b, offset);
|
|
2129
2130
|
};
|
|
2130
2131
|
|
|
2131
2132
|
rslShim.alloc = str => {
|
|
2132
|
-
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;
|
|
2133
|
+
return BufferLayout.u32().span + BufferLayout.u32().span + Buffer$1.from(str, 'utf8').length;
|
|
2133
2134
|
};
|
|
2134
2135
|
|
|
2135
2136
|
return rslShim;
|
|
@@ -2259,16 +2260,16 @@ class Message {
|
|
|
2259
2260
|
encodeLength(dataCount, data.length);
|
|
2260
2261
|
return {
|
|
2261
2262
|
programIdIndex,
|
|
2262
|
-
keyIndicesCount: Buffer.from(keyIndicesCount),
|
|
2263
|
+
keyIndicesCount: Buffer$1.from(keyIndicesCount),
|
|
2263
2264
|
keyIndices: accounts,
|
|
2264
|
-
dataLength: Buffer.from(dataCount),
|
|
2265
|
+
dataLength: Buffer$1.from(dataCount),
|
|
2265
2266
|
data
|
|
2266
2267
|
};
|
|
2267
2268
|
});
|
|
2268
2269
|
let instructionCount = [];
|
|
2269
2270
|
encodeLength(instructionCount, instructions.length);
|
|
2270
|
-
let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);
|
|
2271
|
-
Buffer.from(instructionCount).copy(instructionBuffer);
|
|
2271
|
+
let instructionBuffer = Buffer$1.alloc(PACKET_DATA_SIZE);
|
|
2272
|
+
Buffer$1.from(instructionCount).copy(instructionBuffer);
|
|
2272
2273
|
let instructionBufferLength = instructionCount.length;
|
|
2273
2274
|
instructions.forEach(instruction => {
|
|
2274
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')]);
|
|
@@ -2278,14 +2279,14 @@ class Message {
|
|
|
2278
2279
|
instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);
|
|
2279
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')]);
|
|
2280
2281
|
const transaction = {
|
|
2281
|
-
numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),
|
|
2282
|
-
numReadonlySignedAccounts: Buffer.from([this.header.numReadonlySignedAccounts]),
|
|
2283
|
-
numReadonlyUnsignedAccounts: Buffer.from([this.header.numReadonlyUnsignedAccounts]),
|
|
2284
|
-
keyCount: Buffer.from(keyCount),
|
|
2282
|
+
numRequiredSignatures: Buffer$1.from([this.header.numRequiredSignatures]),
|
|
2283
|
+
numReadonlySignedAccounts: Buffer$1.from([this.header.numReadonlySignedAccounts]),
|
|
2284
|
+
numReadonlyUnsignedAccounts: Buffer$1.from([this.header.numReadonlyUnsignedAccounts]),
|
|
2285
|
+
keyCount: Buffer$1.from(keyCount),
|
|
2285
2286
|
keys: this.accountKeys.map(key => toBuffer(key.toBytes())),
|
|
2286
2287
|
recentBlockhash: bs58.decode(this.recentBlockhash)
|
|
2287
2288
|
};
|
|
2288
|
-
let signData = Buffer.alloc(2048);
|
|
2289
|
+
let signData = Buffer$1.alloc(2048);
|
|
2289
2290
|
const length = signDataLayout.encode(transaction, signData);
|
|
2290
2291
|
instructionBuffer.copy(signData, length);
|
|
2291
2292
|
return signData.slice(0, length + instructionBuffer.length);
|
|
@@ -2307,7 +2308,7 @@ class Message {
|
|
|
2307
2308
|
for (let i = 0; i < accountCount; i++) {
|
|
2308
2309
|
const account = byteArray.slice(0, PUBKEY_LENGTH);
|
|
2309
2310
|
byteArray = byteArray.slice(PUBKEY_LENGTH);
|
|
2310
|
-
accountKeys.push(bs58.encode(Buffer.from(account)));
|
|
2311
|
+
accountKeys.push(bs58.encode(Buffer$1.from(account)));
|
|
2311
2312
|
}
|
|
2312
2313
|
|
|
2313
2314
|
const recentBlockhash = byteArray.slice(0, PUBKEY_LENGTH);
|
|
@@ -2322,7 +2323,7 @@ class Message {
|
|
|
2322
2323
|
byteArray = byteArray.slice(accountCount);
|
|
2323
2324
|
const dataLength = decodeLength(byteArray);
|
|
2324
2325
|
const dataSlice = byteArray.slice(0, dataLength);
|
|
2325
|
-
const data = bs58.encode(Buffer.from(dataSlice));
|
|
2326
|
+
const data = bs58.encode(Buffer$1.from(dataSlice));
|
|
2326
2327
|
byteArray = byteArray.slice(dataLength);
|
|
2327
2328
|
instructions.push({
|
|
2328
2329
|
programIdIndex,
|
|
@@ -2337,7 +2338,7 @@ class Message {
|
|
|
2337
2338
|
numReadonlySignedAccounts,
|
|
2338
2339
|
numReadonlyUnsignedAccounts
|
|
2339
2340
|
},
|
|
2340
|
-
recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),
|
|
2341
|
+
recentBlockhash: bs58.encode(Buffer$1.from(recentBlockhash)),
|
|
2341
2342
|
accountKeys,
|
|
2342
2343
|
instructions
|
|
2343
2344
|
};
|
|
@@ -2355,7 +2356,7 @@ function assert (condition, message) {
|
|
|
2355
2356
|
/**
|
|
2356
2357
|
* Default (empty) signature
|
|
2357
2358
|
*/
|
|
2358
|
-
const DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2359
|
+
const DEFAULT_SIGNATURE = Buffer$1.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);
|
|
2359
2360
|
/**
|
|
2360
2361
|
* Account metadata used to define instructions
|
|
2361
2362
|
*/
|
|
@@ -2379,7 +2380,7 @@ class TransactionInstruction {
|
|
|
2379
2380
|
constructor(opts) {
|
|
2380
2381
|
this.keys = void 0;
|
|
2381
2382
|
this.programId = void 0;
|
|
2382
|
-
this.data = Buffer.alloc(0);
|
|
2383
|
+
this.data = Buffer$1.alloc(0);
|
|
2383
2384
|
this.programId = opts.programId;
|
|
2384
2385
|
this.keys = opts.keys;
|
|
2385
2386
|
|
|
@@ -2498,11 +2499,7 @@ class Transaction {
|
|
|
2498
2499
|
|
|
2499
2500
|
|
|
2500
2501
|
compileMessage() {
|
|
2501
|
-
if (this._message) {
|
|
2502
|
-
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
|
2503
|
-
throw new Error('Transaction message mutated after being populated from Message');
|
|
2504
|
-
}
|
|
2505
|
-
|
|
2502
|
+
if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {
|
|
2506
2503
|
return this._message;
|
|
2507
2504
|
}
|
|
2508
2505
|
|
|
@@ -2862,7 +2859,7 @@ class Transaction {
|
|
|
2862
2859
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2863
2860
|
}
|
|
2864
2861
|
|
|
2865
|
-
this.signatures[index].signature = Buffer.from(signature);
|
|
2862
|
+
this.signatures[index].signature = Buffer$1.from(signature);
|
|
2866
2863
|
}
|
|
2867
2864
|
/**
|
|
2868
2865
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2928,15 +2925,15 @@ class Transaction {
|
|
|
2928
2925
|
const signatureCount = [];
|
|
2929
2926
|
encodeLength(signatureCount, signatures.length);
|
|
2930
2927
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2931
|
-
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2928
|
+
const wireTransaction = Buffer$1.alloc(transactionLength);
|
|
2932
2929
|
assert(signatures.length < 256);
|
|
2933
|
-
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2930
|
+
Buffer$1.from(signatureCount).copy(wireTransaction, 0);
|
|
2934
2931
|
signatures.forEach(({
|
|
2935
2932
|
signature
|
|
2936
2933
|
}, index) => {
|
|
2937
2934
|
if (signature !== null) {
|
|
2938
2935
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2939
|
-
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2936
|
+
Buffer$1.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2940
2937
|
}
|
|
2941
2938
|
});
|
|
2942
2939
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2987,7 +2984,7 @@ class Transaction {
|
|
|
2987
2984
|
for (let i = 0; i < signatureCount; i++) {
|
|
2988
2985
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2989
2986
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2990
|
-
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2987
|
+
signatures.push(bs58.encode(Buffer$1.from(signature)));
|
|
2991
2988
|
}
|
|
2992
2989
|
|
|
2993
2990
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3076,13 +3073,113 @@ function sleep(ms) {
|
|
|
3076
3073
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3077
3074
|
}
|
|
3078
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
|
+
|
|
3079
3176
|
/**
|
|
3080
3177
|
* Populate a buffer of instruction data using an InstructionType
|
|
3081
3178
|
* @internal
|
|
3082
3179
|
*/
|
|
3083
3180
|
function encodeData(type, fields) {
|
|
3084
3181
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3085
|
-
const data = Buffer.alloc(allocLength);
|
|
3182
|
+
const data = Buffer$1.alloc(allocLength);
|
|
3086
3183
|
const layoutFields = Object.assign({
|
|
3087
3184
|
instruction: type.index
|
|
3088
3185
|
}, fields);
|
|
@@ -3465,7 +3562,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3465
3562
|
},
|
|
3466
3563
|
Transfer: {
|
|
3467
3564
|
index: 2,
|
|
3468
|
-
layout: BufferLayout.struct([BufferLayout.u32('instruction'),
|
|
3565
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports')])
|
|
3469
3566
|
},
|
|
3470
3567
|
CreateWithSeed: {
|
|
3471
3568
|
index: 3,
|
|
@@ -3501,7 +3598,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3501
3598
|
},
|
|
3502
3599
|
TransferWithSeed: {
|
|
3503
3600
|
index: 11,
|
|
3504
|
-
layout: BufferLayout.struct([BufferLayout.u32('instruction'),
|
|
3601
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
3505
3602
|
}
|
|
3506
3603
|
});
|
|
3507
3604
|
/**
|
|
@@ -3554,7 +3651,7 @@ class SystemProgram {
|
|
|
3554
3651
|
if ('basePubkey' in params) {
|
|
3555
3652
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
|
|
3556
3653
|
data = encodeData(type, {
|
|
3557
|
-
lamports: params.lamports,
|
|
3654
|
+
lamports: BigInt(params.lamports),
|
|
3558
3655
|
seed: params.seed,
|
|
3559
3656
|
programId: toBuffer(params.programId.toBuffer())
|
|
3560
3657
|
});
|
|
@@ -3574,7 +3671,7 @@ class SystemProgram {
|
|
|
3574
3671
|
} else {
|
|
3575
3672
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
|
|
3576
3673
|
data = encodeData(type, {
|
|
3577
|
-
lamports: params.lamports
|
|
3674
|
+
lamports: BigInt(params.lamports)
|
|
3578
3675
|
});
|
|
3579
3676
|
keys = [{
|
|
3580
3677
|
pubkey: params.fromPubkey,
|
|
@@ -3982,7 +4079,7 @@ class Loader {
|
|
|
3982
4079
|
|
|
3983
4080
|
while (array.length > 0) {
|
|
3984
4081
|
const bytes = array.slice(0, chunkSize);
|
|
3985
|
-
const data = Buffer.alloc(chunkSize + 16);
|
|
4082
|
+
const data = Buffer$1.alloc(chunkSize + 16);
|
|
3986
4083
|
dataLayout.encode({
|
|
3987
4084
|
instruction: 0,
|
|
3988
4085
|
// Load instruction
|
|
@@ -4017,7 +4114,7 @@ class Loader {
|
|
|
4017
4114
|
|
|
4018
4115
|
{
|
|
4019
4116
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4020
|
-
const data = Buffer.alloc(dataLayout.span);
|
|
4117
|
+
const data = Buffer$1.alloc(dataLayout.span);
|
|
4021
4118
|
dataLayout.encode({
|
|
4022
4119
|
instruction: 1 // Finalize instruction
|
|
4023
4120
|
|
|
@@ -4493,7 +4590,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4493
4590
|
|
|
4494
4591
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4495
4592
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4496
|
-
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
4593
|
+
const BufferFromRawAccountData = coerce(instance(Buffer$1), RawAccountDataResult, value => Buffer$1.from(value[0], 'base64'));
|
|
4497
4594
|
/**
|
|
4498
4595
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
4499
4596
|
* @internal
|
|
@@ -4676,7 +4773,7 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
4676
4773
|
*/
|
|
4677
4774
|
|
|
4678
4775
|
function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
4679
|
-
const fetch = customFetch ? customFetch :
|
|
4776
|
+
const fetch$1 = customFetch ? customFetch : fetch;
|
|
4680
4777
|
let agentManager;
|
|
4681
4778
|
|
|
4682
4779
|
{
|
|
@@ -4694,7 +4791,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4694
4791
|
reject(error);
|
|
4695
4792
|
}
|
|
4696
4793
|
});
|
|
4697
|
-
return await fetch(...modifiedFetchArgs);
|
|
4794
|
+
return await fetch$1(...modifiedFetchArgs);
|
|
4698
4795
|
};
|
|
4699
4796
|
}
|
|
4700
4797
|
|
|
@@ -4718,7 +4815,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4718
4815
|
if (fetchWithMiddleware) {
|
|
4719
4816
|
res = await fetchWithMiddleware(url, options);
|
|
4720
4817
|
} else {
|
|
4721
|
-
res = await fetch(url, options);
|
|
4818
|
+
res = await fetch$1(url, options);
|
|
4722
4819
|
}
|
|
4723
4820
|
|
|
4724
4821
|
if (res.status !== 429
|
|
@@ -4922,7 +5019,7 @@ const KeyedAccountInfoResult = type({
|
|
|
4922
5019
|
pubkey: PublicKeyFromString,
|
|
4923
5020
|
account: AccountInfoResult
|
|
4924
5021
|
});
|
|
4925
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5022
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer$1), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
4926
5023
|
if (Array.isArray(value)) {
|
|
4927
5024
|
return create(value, BufferFromRawAccountData);
|
|
4928
5025
|
} else {
|
|
@@ -8080,7 +8177,7 @@ class Ed25519Program {
|
|
|
8080
8177
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8081
8178
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8082
8179
|
const numSignatures = 1;
|
|
8083
|
-
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8180
|
+
const instructionData = Buffer$1.alloc(messageDataOffset + message.length);
|
|
8084
8181
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8085
8182
|
: instructionIndex;
|
|
8086
8183
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -8951,7 +9048,7 @@ class Secp256k1Program {
|
|
|
8951
9048
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
8952
9049
|
|
|
8953
9050
|
try {
|
|
8954
|
-
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9051
|
+
return Buffer$1.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
8955
9052
|
} catch (error) {
|
|
8956
9053
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
8957
9054
|
}
|
|
@@ -8996,9 +9093,9 @@ class Secp256k1Program {
|
|
|
8996
9093
|
|
|
8997
9094
|
if (typeof rawAddress === 'string') {
|
|
8998
9095
|
if (rawAddress.startsWith('0x')) {
|
|
8999
|
-
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9096
|
+
ethAddress = Buffer$1.from(rawAddress.substr(2), 'hex');
|
|
9000
9097
|
} else {
|
|
9001
|
-
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9098
|
+
ethAddress = Buffer$1.from(rawAddress, 'hex');
|
|
9002
9099
|
}
|
|
9003
9100
|
} else {
|
|
9004
9101
|
ethAddress = rawAddress;
|
|
@@ -9010,7 +9107,7 @@ class Secp256k1Program {
|
|
|
9010
9107
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9011
9108
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9012
9109
|
const numSignatures = 1;
|
|
9013
|
-
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9110
|
+
const instructionData = Buffer$1.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9014
9111
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9015
9112
|
numSignatures,
|
|
9016
9113
|
signatureOffset,
|
|
@@ -9049,7 +9146,7 @@ class Secp256k1Program {
|
|
|
9049
9146
|
const privateKey = toBuffer(pkey);
|
|
9050
9147
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9051
9148
|
|
|
9052
|
-
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9149
|
+
const messageHash = Buffer$1.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9053
9150
|
const {
|
|
9054
9151
|
signature,
|
|
9055
9152
|
recid: recoveryId
|
|
@@ -9134,7 +9231,7 @@ class ValidatorInfo {
|
|
|
9134
9231
|
|
|
9135
9232
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9136
9233
|
if (configKeys[1].isSigner) {
|
|
9137
|
-
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9234
|
+
const rawInfo = rustString().decode(Buffer$1.from(byteArray));
|
|
9138
9235
|
const info = JSON.parse(rawInfo);
|
|
9139
9236
|
assert$7(info, InfoString);
|
|
9140
9237
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|
|
@@ -9630,5 +9727,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
9630
9727
|
|
|
9631
9728
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
9632
9729
|
|
|
9633
|
-
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
9730
|
+
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
9634
9731
|
//# sourceMappingURL=index.esm.js.map
|