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