@solana/web3.js 1.98.0 → 1.98.2
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/README.md +4 -4
- package/lib/index.browser.cjs.js +10 -20
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +8 -18
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +10 -20
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +8 -18
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +213 -88
- 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/lib/index.native.js +10 -20
- package/lib/index.native.js.map +1 -1
- package/package.json +5 -5
- package/src/programs/address-lookup-table/index.ts +5 -2
- package/src/utils/bigint.ts +14 -33
package/lib/index.iife.js
CHANGED
|
@@ -7985,9 +7985,13 @@ var solanaWeb3 = (function (exports) {
|
|
|
7985
7985
|
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
7986
7986
|
var b256 = new Uint8Array(size);
|
|
7987
7987
|
// Process the characters.
|
|
7988
|
-
while (source
|
|
7988
|
+
while (psz < source.length) {
|
|
7989
|
+
// Find code of next character
|
|
7990
|
+
var charCode = source.charCodeAt(psz);
|
|
7991
|
+
// Base map can not be indexed using char code
|
|
7992
|
+
if (charCode > 255) { return }
|
|
7989
7993
|
// Decode character
|
|
7990
|
-
var carry = BASE_MAP[
|
|
7994
|
+
var carry = BASE_MAP[charCode];
|
|
7991
7995
|
// Invalid character
|
|
7992
7996
|
if (carry === 255) { return }
|
|
7993
7997
|
var i = 0;
|
|
@@ -14074,106 +14078,227 @@ var solanaWeb3 = (function (exports) {
|
|
|
14074
14078
|
}
|
|
14075
14079
|
}
|
|
14076
14080
|
|
|
14077
|
-
|
|
14081
|
+
// src/codes.ts
|
|
14082
|
+
var SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY = 8078e3;
|
|
14083
|
+
var SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH = 8078001;
|
|
14084
|
+
var SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH = 8078004;
|
|
14085
|
+
var SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH = 8078005;
|
|
14086
|
+
var SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH = 8078006;
|
|
14087
|
+
var SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = 8078011;
|
|
14078
14088
|
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14089
|
+
// src/context.ts
|
|
14090
|
+
function encodeValue(value) {
|
|
14091
|
+
if (Array.isArray(value)) {
|
|
14092
|
+
const commaSeparatedValues = value.map(encodeValue).join(
|
|
14093
|
+
"%2C%20"
|
|
14094
|
+
/* ", " */
|
|
14095
|
+
);
|
|
14096
|
+
return "%5B" + commaSeparatedValues + /* "]" */
|
|
14097
|
+
"%5D";
|
|
14098
|
+
} else if (typeof value === "bigint") {
|
|
14099
|
+
return `${value}n`;
|
|
14100
|
+
} else {
|
|
14101
|
+
return encodeURIComponent(
|
|
14102
|
+
String(
|
|
14103
|
+
value != null && Object.getPrototypeOf(value) === null ? (
|
|
14104
|
+
// Plain objects with no prototype don't have a `toString` method.
|
|
14105
|
+
// Convert them before stringifying them.
|
|
14106
|
+
{ ...value }
|
|
14107
|
+
) : value
|
|
14108
|
+
)
|
|
14109
|
+
);
|
|
14110
|
+
}
|
|
14111
|
+
}
|
|
14112
|
+
function encodeObjectContextEntry([key, value]) {
|
|
14113
|
+
return `${key}=${encodeValue(value)}`;
|
|
14114
|
+
}
|
|
14115
|
+
function encodeContextObject(context) {
|
|
14116
|
+
const searchParamsString = Object.entries(context).map(encodeObjectContextEntry).join("&");
|
|
14117
|
+
return btoa(searchParamsString);
|
|
14118
|
+
}
|
|
14119
|
+
function getErrorMessage(code, context = {}) {
|
|
14120
|
+
{
|
|
14121
|
+
let decodingAdviceMessage = `Solana error #${code}; Decode this error by running \`npx @solana/errors decode -- ${code}`;
|
|
14122
|
+
if (Object.keys(context).length) {
|
|
14123
|
+
decodingAdviceMessage += ` '${encodeContextObject(context)}'`;
|
|
14124
|
+
}
|
|
14125
|
+
return `${decodingAdviceMessage}\``;
|
|
14126
|
+
}
|
|
14127
|
+
}
|
|
14128
|
+
var SolanaError = class extends Error {
|
|
14129
|
+
/**
|
|
14130
|
+
* Indicates the root cause of this {@link SolanaError}, if any.
|
|
14131
|
+
*
|
|
14132
|
+
* For example, a transaction error might have an instruction error as its root cause. In this
|
|
14133
|
+
* case, you will be able to access the instruction error on the transaction error as `cause`.
|
|
14134
|
+
*/
|
|
14135
|
+
cause = this.cause;
|
|
14136
|
+
/**
|
|
14137
|
+
* Contains context that can assist in understanding or recovering from a {@link SolanaError}.
|
|
14138
|
+
*/
|
|
14139
|
+
context;
|
|
14140
|
+
constructor(...[code, contextAndErrorOptions]) {
|
|
14141
|
+
let context;
|
|
14142
|
+
let errorOptions;
|
|
14143
|
+
if (contextAndErrorOptions) {
|
|
14144
|
+
const { cause, ...contextRest } = contextAndErrorOptions;
|
|
14145
|
+
if (cause) {
|
|
14146
|
+
errorOptions = { cause };
|
|
14147
|
+
}
|
|
14148
|
+
if (Object.keys(contextRest).length > 0) {
|
|
14149
|
+
context = contextRest;
|
|
14150
|
+
}
|
|
14151
|
+
}
|
|
14152
|
+
const message = getErrorMessage(code, context);
|
|
14153
|
+
super(message, errorOptions);
|
|
14154
|
+
this.context = {
|
|
14155
|
+
__code: code,
|
|
14156
|
+
...context
|
|
14157
|
+
};
|
|
14158
|
+
this.name = "SolanaError";
|
|
14159
|
+
}
|
|
14160
|
+
};
|
|
14084
14161
|
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14162
|
+
function getEncodedSize(value, encoder) {
|
|
14163
|
+
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
14164
|
+
}
|
|
14165
|
+
function createEncoder(encoder) {
|
|
14166
|
+
return Object.freeze({
|
|
14167
|
+
...encoder,
|
|
14168
|
+
encode: (value) => {
|
|
14169
|
+
const bytes = new Uint8Array(getEncodedSize(value, encoder));
|
|
14170
|
+
encoder.write(value, bytes, 0);
|
|
14171
|
+
return bytes;
|
|
14172
|
+
}
|
|
14173
|
+
});
|
|
14174
|
+
}
|
|
14175
|
+
function createDecoder(decoder) {
|
|
14176
|
+
return Object.freeze({
|
|
14177
|
+
...decoder,
|
|
14178
|
+
decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
|
|
14179
|
+
});
|
|
14180
|
+
}
|
|
14181
|
+
function isFixedSize(codec) {
|
|
14182
|
+
return "fixedSize" in codec && typeof codec.fixedSize === "number";
|
|
14183
|
+
}
|
|
14184
|
+
function combineCodec(encoder, decoder) {
|
|
14185
|
+
if (isFixedSize(encoder) !== isFixedSize(decoder)) {
|
|
14186
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__ENCODER_DECODER_SIZE_COMPATIBILITY_MISMATCH);
|
|
14187
|
+
}
|
|
14188
|
+
if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
|
|
14189
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__ENCODER_DECODER_FIXED_SIZE_MISMATCH, {
|
|
14190
|
+
decoderFixedSize: decoder.fixedSize,
|
|
14191
|
+
encoderFixedSize: encoder.fixedSize
|
|
14192
|
+
});
|
|
14193
|
+
}
|
|
14194
|
+
if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
|
|
14195
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__ENCODER_DECODER_MAX_SIZE_MISMATCH, {
|
|
14196
|
+
decoderMaxSize: decoder.maxSize,
|
|
14197
|
+
encoderMaxSize: encoder.maxSize
|
|
14198
|
+
});
|
|
14199
|
+
}
|
|
14200
|
+
return {
|
|
14201
|
+
...decoder,
|
|
14202
|
+
...encoder,
|
|
14203
|
+
decode: decoder.decode,
|
|
14204
|
+
encode: encoder.encode,
|
|
14205
|
+
read: decoder.read,
|
|
14206
|
+
write: encoder.write
|
|
14207
|
+
};
|
|
14208
|
+
}
|
|
14209
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
14210
|
+
if (bytes.length - offset <= 0) {
|
|
14211
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__CANNOT_DECODE_EMPTY_BYTE_ARRAY, {
|
|
14212
|
+
codecDescription
|
|
14213
|
+
});
|
|
14214
|
+
}
|
|
14215
|
+
}
|
|
14216
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
|
|
14217
|
+
const bytesLength = bytes.length - offset;
|
|
14218
|
+
if (bytesLength < expected) {
|
|
14219
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_BYTE_LENGTH, {
|
|
14220
|
+
bytesLength,
|
|
14221
|
+
codecDescription,
|
|
14222
|
+
expected
|
|
14223
|
+
});
|
|
14224
|
+
}
|
|
14147
14225
|
}
|
|
14148
14226
|
|
|
14149
|
-
|
|
14227
|
+
// src/assertions.ts
|
|
14228
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
14229
|
+
if (value < min || value > max) {
|
|
14230
|
+
throw new SolanaError(SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE, {
|
|
14231
|
+
codecDescription,
|
|
14232
|
+
max,
|
|
14233
|
+
min,
|
|
14234
|
+
value
|
|
14235
|
+
});
|
|
14236
|
+
}
|
|
14237
|
+
}
|
|
14238
|
+
function isLittleEndian(config) {
|
|
14239
|
+
return config?.endian === 1 /* Big */ ? false : true;
|
|
14240
|
+
}
|
|
14241
|
+
function numberEncoderFactory(input) {
|
|
14242
|
+
return createEncoder({
|
|
14243
|
+
fixedSize: input.size,
|
|
14244
|
+
write(value, bytes, offset) {
|
|
14245
|
+
if (input.range) {
|
|
14246
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
14247
|
+
}
|
|
14248
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
14249
|
+
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
|
|
14250
|
+
bytes.set(new Uint8Array(arrayBuffer), offset);
|
|
14251
|
+
return offset + input.size;
|
|
14252
|
+
}
|
|
14253
|
+
});
|
|
14254
|
+
}
|
|
14255
|
+
function numberDecoderFactory(input) {
|
|
14256
|
+
return createDecoder({
|
|
14257
|
+
fixedSize: input.size,
|
|
14258
|
+
read(bytes, offset = 0) {
|
|
14259
|
+
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
|
|
14260
|
+
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
|
|
14261
|
+
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
14262
|
+
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
|
|
14263
|
+
}
|
|
14264
|
+
});
|
|
14265
|
+
}
|
|
14266
|
+
function toArrayBuffer(bytes, offset, length) {
|
|
14267
|
+
const bytesOffset = bytes.byteOffset + (offset ?? 0);
|
|
14268
|
+
const bytesLength = length ?? bytes.byteLength;
|
|
14269
|
+
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
14270
|
+
}
|
|
14271
|
+
var getU64Encoder = (config = {}) => numberEncoderFactory({
|
|
14272
|
+
config,
|
|
14273
|
+
name: "u64",
|
|
14274
|
+
range: [0n, BigInt("0xffffffffffffffff")],
|
|
14275
|
+
set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),
|
|
14276
|
+
size: 8
|
|
14277
|
+
});
|
|
14278
|
+
var getU64Decoder = (config = {}) => numberDecoderFactory({
|
|
14279
|
+
config,
|
|
14280
|
+
get: (view, le) => view.getBigUint64(0, le),
|
|
14281
|
+
name: "u64",
|
|
14282
|
+
size: 8
|
|
14283
|
+
});
|
|
14284
|
+
var getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));
|
|
14150
14285
|
|
|
14151
|
-
|
|
14286
|
+
function u64(property) {
|
|
14287
|
+
const layout = LayoutExports.blob(8 /* bytes */, property);
|
|
14152
14288
|
const decode = layout.decode.bind(layout);
|
|
14153
14289
|
const encode = layout.encode.bind(layout);
|
|
14154
|
-
return {
|
|
14155
|
-
decode,
|
|
14156
|
-
encode
|
|
14157
|
-
};
|
|
14158
|
-
};
|
|
14159
|
-
const bigInt = length => property => {
|
|
14160
|
-
const layout = LayoutExports.blob(length, property);
|
|
14161
|
-
const {
|
|
14162
|
-
encode,
|
|
14163
|
-
decode
|
|
14164
|
-
} = encodeDecode(layout);
|
|
14165
14290
|
const bigIntLayout = layout;
|
|
14291
|
+
const codec = getU64Codec();
|
|
14166
14292
|
bigIntLayout.decode = (buffer, offset) => {
|
|
14167
14293
|
const src = decode(buffer, offset);
|
|
14168
|
-
return
|
|
14294
|
+
return codec.decode(src);
|
|
14169
14295
|
};
|
|
14170
14296
|
bigIntLayout.encode = (bigInt, buffer, offset) => {
|
|
14171
|
-
const src =
|
|
14297
|
+
const src = codec.encode(bigInt);
|
|
14172
14298
|
return encode(src, buffer, offset);
|
|
14173
14299
|
};
|
|
14174
14300
|
return bigIntLayout;
|
|
14175
|
-
}
|
|
14176
|
-
const u64 = bigInt(8);
|
|
14301
|
+
}
|
|
14177
14302
|
|
|
14178
14303
|
/**
|
|
14179
14304
|
* Create account system transaction params
|
|
@@ -22270,7 +22395,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
22270
22395
|
*/
|
|
22271
22396
|
constructor() {}
|
|
22272
22397
|
static createLookupTable(params) {
|
|
22273
|
-
const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(),
|
|
22398
|
+
const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), getU64Encoder().encode(params.recentSlot)], this.programId);
|
|
22274
22399
|
const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;
|
|
22275
22400
|
const data = encodeData(type, {
|
|
22276
22401
|
recentSlot: BigInt(params.recentSlot),
|