@solana/web3.js 1.41.3 → 1.41.4
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 +90 -4
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +137 -50
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +107 -7
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +30 -4
- package/lib/index.esm.js +155 -54
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +12204 -12118
- 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 +2 -1
- package/src/system-program.ts +39 -10
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
|
|
|
@@ -2853,7 +2854,7 @@ class Transaction {
|
|
|
2853
2854
|
throw new Error(`unknown signer: ${pubkey.toString()}`);
|
|
2854
2855
|
}
|
|
2855
2856
|
|
|
2856
|
-
this.signatures[index].signature = Buffer.from(signature);
|
|
2857
|
+
this.signatures[index].signature = Buffer$1.from(signature);
|
|
2857
2858
|
}
|
|
2858
2859
|
/**
|
|
2859
2860
|
* Verify signatures of a complete, signed Transaction
|
|
@@ -2919,15 +2920,15 @@ class Transaction {
|
|
|
2919
2920
|
const signatureCount = [];
|
|
2920
2921
|
encodeLength(signatureCount, signatures.length);
|
|
2921
2922
|
const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;
|
|
2922
|
-
const wireTransaction = Buffer.alloc(transactionLength);
|
|
2923
|
+
const wireTransaction = Buffer$1.alloc(transactionLength);
|
|
2923
2924
|
assert(signatures.length < 256);
|
|
2924
|
-
Buffer.from(signatureCount).copy(wireTransaction, 0);
|
|
2925
|
+
Buffer$1.from(signatureCount).copy(wireTransaction, 0);
|
|
2925
2926
|
signatures.forEach(({
|
|
2926
2927
|
signature
|
|
2927
2928
|
}, index) => {
|
|
2928
2929
|
if (signature !== null) {
|
|
2929
2930
|
assert(signature.length === 64, `signature has invalid length`);
|
|
2930
|
-
Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2931
|
+
Buffer$1.from(signature).copy(wireTransaction, signatureCount.length + index * 64);
|
|
2931
2932
|
}
|
|
2932
2933
|
});
|
|
2933
2934
|
signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);
|
|
@@ -2978,7 +2979,7 @@ class Transaction {
|
|
|
2978
2979
|
for (let i = 0; i < signatureCount; i++) {
|
|
2979
2980
|
const signature = byteArray.slice(0, SIGNATURE_LENGTH_IN_BYTES);
|
|
2980
2981
|
byteArray = byteArray.slice(SIGNATURE_LENGTH_IN_BYTES);
|
|
2981
|
-
signatures.push(bs58.encode(Buffer.from(signature)));
|
|
2982
|
+
signatures.push(bs58.encode(Buffer$1.from(signature)));
|
|
2982
2983
|
}
|
|
2983
2984
|
|
|
2984
2985
|
return Transaction.populate(Message.from(byteArray), signatures);
|
|
@@ -3067,13 +3068,99 @@ function sleep(ms) {
|
|
|
3067
3068
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3068
3069
|
}
|
|
3069
3070
|
|
|
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
|
+
|
|
3070
3157
|
/**
|
|
3071
3158
|
* Populate a buffer of instruction data using an InstructionType
|
|
3072
3159
|
* @internal
|
|
3073
3160
|
*/
|
|
3074
3161
|
function encodeData(type, fields) {
|
|
3075
3162
|
const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);
|
|
3076
|
-
const data = Buffer.alloc(allocLength);
|
|
3163
|
+
const data = Buffer$1.alloc(allocLength);
|
|
3077
3164
|
const layoutFields = Object.assign({
|
|
3078
3165
|
instruction: type.index
|
|
3079
3166
|
}, fields);
|
|
@@ -3456,7 +3543,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3456
3543
|
},
|
|
3457
3544
|
Transfer: {
|
|
3458
3545
|
index: 2,
|
|
3459
|
-
layout: BufferLayout.struct([BufferLayout.u32('instruction'),
|
|
3546
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports')])
|
|
3460
3547
|
},
|
|
3461
3548
|
CreateWithSeed: {
|
|
3462
3549
|
index: 3,
|
|
@@ -3492,7 +3579,7 @@ const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({
|
|
|
3492
3579
|
},
|
|
3493
3580
|
TransferWithSeed: {
|
|
3494
3581
|
index: 11,
|
|
3495
|
-
layout: BufferLayout.struct([BufferLayout.u32('instruction'),
|
|
3582
|
+
layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])
|
|
3496
3583
|
}
|
|
3497
3584
|
});
|
|
3498
3585
|
/**
|
|
@@ -3545,7 +3632,7 @@ class SystemProgram {
|
|
|
3545
3632
|
if ('basePubkey' in params) {
|
|
3546
3633
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;
|
|
3547
3634
|
data = encodeData(type, {
|
|
3548
|
-
lamports: params.lamports,
|
|
3635
|
+
lamports: BigInt(params.lamports),
|
|
3549
3636
|
seed: params.seed,
|
|
3550
3637
|
programId: toBuffer(params.programId.toBuffer())
|
|
3551
3638
|
});
|
|
@@ -3565,7 +3652,7 @@ class SystemProgram {
|
|
|
3565
3652
|
} else {
|
|
3566
3653
|
const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;
|
|
3567
3654
|
data = encodeData(type, {
|
|
3568
|
-
lamports: params.lamports
|
|
3655
|
+
lamports: BigInt(params.lamports)
|
|
3569
3656
|
});
|
|
3570
3657
|
keys = [{
|
|
3571
3658
|
pubkey: params.fromPubkey,
|
|
@@ -3973,7 +4060,7 @@ class Loader {
|
|
|
3973
4060
|
|
|
3974
4061
|
while (array.length > 0) {
|
|
3975
4062
|
const bytes = array.slice(0, chunkSize);
|
|
3976
|
-
const data = Buffer.alloc(chunkSize + 16);
|
|
4063
|
+
const data = Buffer$1.alloc(chunkSize + 16);
|
|
3977
4064
|
dataLayout.encode({
|
|
3978
4065
|
instruction: 0,
|
|
3979
4066
|
// Load instruction
|
|
@@ -4008,7 +4095,7 @@ class Loader {
|
|
|
4008
4095
|
|
|
4009
4096
|
{
|
|
4010
4097
|
const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);
|
|
4011
|
-
const data = Buffer.alloc(dataLayout.span);
|
|
4098
|
+
const data = Buffer$1.alloc(dataLayout.span);
|
|
4012
4099
|
dataLayout.encode({
|
|
4013
4100
|
instruction: 1 // Finalize instruction
|
|
4014
4101
|
|
|
@@ -4996,7 +5083,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4996
5083
|
|
|
4997
5084
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4998
5085
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4999
|
-
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
5086
|
+
const BufferFromRawAccountData = coerce(instance(Buffer$1), RawAccountDataResult, value => Buffer$1.from(value[0], 'base64'));
|
|
5000
5087
|
/**
|
|
5001
5088
|
* Attempt to use a recent blockhash for up to 30 seconds
|
|
5002
5089
|
* @internal
|
|
@@ -5419,7 +5506,7 @@ const KeyedAccountInfoResult = type({
|
|
|
5419
5506
|
pubkey: PublicKeyFromString,
|
|
5420
5507
|
account: AccountInfoResult
|
|
5421
5508
|
});
|
|
5422
|
-
const ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5509
|
+
const ParsedOrRawAccountData = coerce(union([instance(Buffer$1), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {
|
|
5423
5510
|
if (Array.isArray(value)) {
|
|
5424
5511
|
return create(value, BufferFromRawAccountData);
|
|
5425
5512
|
} else {
|
|
@@ -8577,7 +8664,7 @@ class Ed25519Program {
|
|
|
8577
8664
|
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
8578
8665
|
const messageDataOffset = signatureOffset + signature.length;
|
|
8579
8666
|
const numSignatures = 1;
|
|
8580
|
-
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
8667
|
+
const instructionData = Buffer$1.alloc(messageDataOffset + message.length);
|
|
8581
8668
|
const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.
|
|
8582
8669
|
: instructionIndex;
|
|
8583
8670
|
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
@@ -9448,7 +9535,7 @@ class Secp256k1Program {
|
|
|
9448
9535
|
assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);
|
|
9449
9536
|
|
|
9450
9537
|
try {
|
|
9451
|
-
return Buffer.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9538
|
+
return Buffer$1.from(sha3.keccak_256.update(toBuffer(publicKey)).digest()).slice(-ETHEREUM_ADDRESS_BYTES);
|
|
9452
9539
|
} catch (error) {
|
|
9453
9540
|
throw new Error(`Error constructing Ethereum address: ${error}`);
|
|
9454
9541
|
}
|
|
@@ -9493,9 +9580,9 @@ class Secp256k1Program {
|
|
|
9493
9580
|
|
|
9494
9581
|
if (typeof rawAddress === 'string') {
|
|
9495
9582
|
if (rawAddress.startsWith('0x')) {
|
|
9496
|
-
ethAddress = Buffer.from(rawAddress.substr(2), 'hex');
|
|
9583
|
+
ethAddress = Buffer$1.from(rawAddress.substr(2), 'hex');
|
|
9497
9584
|
} else {
|
|
9498
|
-
ethAddress = Buffer.from(rawAddress, 'hex');
|
|
9585
|
+
ethAddress = Buffer$1.from(rawAddress, 'hex');
|
|
9499
9586
|
}
|
|
9500
9587
|
} else {
|
|
9501
9588
|
ethAddress = rawAddress;
|
|
@@ -9507,7 +9594,7 @@ class Secp256k1Program {
|
|
|
9507
9594
|
const signatureOffset = dataStart + ethAddress.length;
|
|
9508
9595
|
const messageDataOffset = signatureOffset + signature.length + 1;
|
|
9509
9596
|
const numSignatures = 1;
|
|
9510
|
-
const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9597
|
+
const instructionData = Buffer$1.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);
|
|
9511
9598
|
SECP256K1_INSTRUCTION_LAYOUT.encode({
|
|
9512
9599
|
numSignatures,
|
|
9513
9600
|
signatureOffset,
|
|
@@ -9546,7 +9633,7 @@ class Secp256k1Program {
|
|
|
9546
9633
|
const privateKey = toBuffer(pkey);
|
|
9547
9634
|
const publicKey = publicKeyCreate(privateKey, false).slice(1); // throw away leading byte
|
|
9548
9635
|
|
|
9549
|
-
const messageHash = Buffer.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9636
|
+
const messageHash = Buffer$1.from(sha3.keccak_256.update(toBuffer(message)).digest());
|
|
9550
9637
|
const {
|
|
9551
9638
|
signature,
|
|
9552
9639
|
recid: recoveryId
|
|
@@ -9631,7 +9718,7 @@ class ValidatorInfo {
|
|
|
9631
9718
|
|
|
9632
9719
|
if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {
|
|
9633
9720
|
if (configKeys[1].isSigner) {
|
|
9634
|
-
const rawInfo = rustString().decode(Buffer.from(byteArray));
|
|
9721
|
+
const rawInfo = rustString().decode(Buffer$1.from(byteArray));
|
|
9635
9722
|
const info = JSON.parse(rawInfo);
|
|
9636
9723
|
assert$7(info, InfoString);
|
|
9637
9724
|
return new ValidatorInfo(configKeys[1].publicKey, info);
|