@solana/transactions 2.0.0-experimental.dacecb7 → 2.0.0-experimental.df45965
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 +314 -5
- package/dist/index.browser.cjs +170 -217
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +172 -220
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +643 -649
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +172 -218
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +172 -215
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +172 -220
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +17 -16
- package/dist/types/durable-nonce.d.ts +1 -0
- package/dist/types/durable-nonce.d.ts.map +1 -1
- package/dist/types/serializers/address-table-lookup.d.ts +5 -3
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -1
- package/dist/types/serializers/header.d.ts +4 -2
- package/dist/types/serializers/header.d.ts.map +1 -1
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/instruction.d.ts.map +1 -1
- package/dist/types/serializers/message.d.ts +4 -4
- package/dist/types/serializers/message.d.ts.map +1 -1
- package/dist/types/serializers/transaction-version.d.ts +4 -4
- package/dist/types/serializers/transaction-version.d.ts.map +1 -1
- package/dist/types/serializers/transaction.d.ts +5 -4
- package/dist/types/serializers/transaction.d.ts.map +1 -1
- package/dist/types/signatures.d.ts.map +1 -1
- package/dist/types/wire-transaction.d.ts +1 -1
- package/dist/types/wire-transaction.d.ts.map +1 -1
- package/package.json +11 -7
- package/dist/types/serializers/unimplemented.d.ts +0 -3
- package/dist/types/serializers/unimplemented.d.ts.map +0 -1
|
@@ -9,82 +9,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
13
|
-
var mergeBytes = (bytesArr) => {
|
|
14
|
-
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
15
|
-
const result = new Uint8Array(totalLength);
|
|
16
|
-
let offset = 0;
|
|
17
|
-
bytesArr.forEach((arr) => {
|
|
18
|
-
result.set(arr, offset);
|
|
19
|
-
offset += arr.length;
|
|
20
|
-
});
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
var padBytes = (bytes2, length) => {
|
|
24
|
-
if (bytes2.length >= length)
|
|
25
|
-
return bytes2;
|
|
26
|
-
const paddedBytes = new Uint8Array(length).fill(0);
|
|
27
|
-
paddedBytes.set(bytes2);
|
|
28
|
-
return paddedBytes;
|
|
29
|
-
};
|
|
30
|
-
var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
|
|
31
|
-
|
|
32
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
|
|
33
|
-
var DeserializingEmptyBufferError = class extends Error {
|
|
34
|
-
constructor(serializer) {
|
|
35
|
-
super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
|
|
36
|
-
__publicField(this, "name", "DeserializingEmptyBufferError");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var NotEnoughBytesError = class extends Error {
|
|
40
|
-
constructor(serializer, expected, actual) {
|
|
41
|
-
super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
|
|
42
|
-
__publicField(this, "name", "NotEnoughBytesError");
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var ExpectedFixedSizeSerializerError = class extends Error {
|
|
46
|
-
constructor(message) {
|
|
47
|
-
message ?? (message = "Expected a fixed-size serializer, got a variable-size one.");
|
|
48
|
-
super(message);
|
|
49
|
-
__publicField(this, "name", "ExpectedFixedSizeSerializerError");
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
54
|
-
function fixSerializer(serializer, fixedBytes, description) {
|
|
55
|
-
return {
|
|
56
|
-
description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
|
|
57
|
-
fixedSize: fixedBytes,
|
|
58
|
-
maxSize: fixedBytes,
|
|
59
|
-
serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes),
|
|
60
|
-
deserialize: (buffer, offset = 0) => {
|
|
61
|
-
buffer = buffer.slice(offset, offset + fixedBytes);
|
|
62
|
-
if (buffer.length < fixedBytes) {
|
|
63
|
-
throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
|
|
64
|
-
}
|
|
65
|
-
if (serializer.fixedSize !== null) {
|
|
66
|
-
buffer = fixBytes(buffer, serializer.fixedSize);
|
|
67
|
-
}
|
|
68
|
-
const [value] = serializer.deserialize(buffer, 0);
|
|
69
|
-
return [value, offset + fixedBytes];
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
|
|
75
|
-
function mapSerializer(serializer, unmap, map) {
|
|
76
|
-
return {
|
|
77
|
-
description: serializer.description,
|
|
78
|
-
fixedSize: serializer.fixedSize,
|
|
79
|
-
maxSize: serializer.maxSize,
|
|
80
|
-
serialize: (value) => serializer.serialize(unmap(value)),
|
|
81
|
-
deserialize: (buffer, offset = 0) => {
|
|
82
|
-
const [value, length] = serializer.deserialize(buffer, offset);
|
|
83
|
-
return map ? [map(value, buffer, offset), length] : [value, length];
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
12
|
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
89
13
|
var InvalidBaseStringError = class extends Error {
|
|
90
14
|
constructor(value, base, cause) {
|
|
@@ -132,13 +56,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
132
56
|
deserialize(buffer, offset = 0) {
|
|
133
57
|
if (buffer.length === 0)
|
|
134
58
|
return ["", 0];
|
|
135
|
-
const
|
|
136
|
-
let trailIndex =
|
|
137
|
-
trailIndex = trailIndex === -1 ?
|
|
59
|
+
const bytes = buffer.slice(offset);
|
|
60
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
61
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
138
62
|
const leadingZeroes = alphabet[0].repeat(trailIndex);
|
|
139
|
-
if (trailIndex ===
|
|
63
|
+
if (trailIndex === bytes.length)
|
|
140
64
|
return [leadingZeroes, buffer.length];
|
|
141
|
-
let base10Number =
|
|
65
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
142
66
|
const tailChars = [];
|
|
143
67
|
while (base10Number > 0n) {
|
|
144
68
|
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
|
|
@@ -152,347 +76,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
152
76
|
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
153
77
|
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
154
78
|
|
|
155
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
|
|
156
|
-
var removeNullCharacters = (value) => (
|
|
157
|
-
// eslint-disable-next-line no-control-regex
|
|
158
|
-
value.replace(/\u0000/g, "")
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
|
|
162
|
-
var utf8 = {
|
|
163
|
-
description: "utf8",
|
|
164
|
-
fixedSize: null,
|
|
165
|
-
maxSize: null,
|
|
166
|
-
serialize(value) {
|
|
167
|
-
return new TextEncoder().encode(value);
|
|
168
|
-
},
|
|
169
|
-
deserialize(buffer, offset = 0) {
|
|
170
|
-
const value = new TextDecoder().decode(buffer.slice(offset));
|
|
171
|
-
return [removeNullCharacters(value), buffer.length];
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
|
|
176
|
-
var Endian;
|
|
177
|
-
(function(Endian2) {
|
|
178
|
-
Endian2["Little"] = "le";
|
|
179
|
-
Endian2["Big"] = "be";
|
|
180
|
-
})(Endian || (Endian = {}));
|
|
181
|
-
|
|
182
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
|
|
183
|
-
var NumberOutOfRangeError = class extends RangeError {
|
|
184
|
-
constructor(serializer, min, max, actual) {
|
|
185
|
-
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
|
|
186
|
-
__publicField(this, "name", "NumberOutOfRangeError");
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
|
|
191
|
-
function numberFactory(input) {
|
|
192
|
-
let littleEndian;
|
|
193
|
-
let defaultDescription = input.name;
|
|
194
|
-
if (input.size > 1) {
|
|
195
|
-
littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
|
|
196
|
-
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
description: input.options.description ?? defaultDescription,
|
|
200
|
-
fixedSize: input.size,
|
|
201
|
-
maxSize: input.size,
|
|
202
|
-
serialize(value) {
|
|
203
|
-
if (input.range) {
|
|
204
|
-
assertRange(input.name, input.range[0], input.range[1], value);
|
|
205
|
-
}
|
|
206
|
-
const buffer = new ArrayBuffer(input.size);
|
|
207
|
-
input.set(new DataView(buffer), value, littleEndian);
|
|
208
|
-
return new Uint8Array(buffer);
|
|
209
|
-
},
|
|
210
|
-
deserialize(bytes2, offset = 0) {
|
|
211
|
-
const slice = bytes2.slice(offset, offset + input.size);
|
|
212
|
-
assertEnoughBytes("i8", slice, input.size);
|
|
213
|
-
const view = toDataView(slice);
|
|
214
|
-
return [input.get(view, littleEndian), offset + input.size];
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
var toArrayBuffer = (array2) => array2.buffer.slice(array2.byteOffset, array2.byteLength + array2.byteOffset);
|
|
219
|
-
var toDataView = (array2) => new DataView(toArrayBuffer(array2));
|
|
220
|
-
var assertRange = (serializer, min, max, value) => {
|
|
221
|
-
if (value < min || value > max) {
|
|
222
|
-
throw new NumberOutOfRangeError(serializer, min, max, value);
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
var assertEnoughBytes = (serializer, bytes2, expected) => {
|
|
226
|
-
if (bytes2.length === 0) {
|
|
227
|
-
throw new DeserializingEmptyBufferError(serializer);
|
|
228
|
-
}
|
|
229
|
-
if (bytes2.length < expected) {
|
|
230
|
-
throw new NotEnoughBytesError(serializer, expected, bytes2.length);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
|
|
235
|
-
var u8 = (options = {}) => numberFactory({
|
|
236
|
-
name: "u8",
|
|
237
|
-
size: 1,
|
|
238
|
-
range: [0, Number("0xff")],
|
|
239
|
-
set: (view, value) => view.setUint8(0, Number(value)),
|
|
240
|
-
get: (view) => view.getUint8(0),
|
|
241
|
-
options
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
245
|
-
var u32 = (options = {}) => numberFactory({
|
|
246
|
-
name: "u32",
|
|
247
|
-
size: 4,
|
|
248
|
-
range: [0, Number("0xffffffff")],
|
|
249
|
-
set: (view, value, le) => view.setUint32(0, Number(value), le),
|
|
250
|
-
get: (view, le) => view.getUint32(0, le),
|
|
251
|
-
options
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
255
|
-
var shortU16 = (options = {}) => ({
|
|
256
|
-
description: options.description ?? "shortU16",
|
|
257
|
-
fixedSize: null,
|
|
258
|
-
maxSize: 3,
|
|
259
|
-
serialize: (value) => {
|
|
260
|
-
assertRange("shortU16", 0, 65535, value);
|
|
261
|
-
const bytes2 = [0];
|
|
262
|
-
for (let ii = 0; ; ii += 1) {
|
|
263
|
-
const alignedValue = value >> ii * 7;
|
|
264
|
-
if (alignedValue === 0) {
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
const nextSevenBits = 127 & alignedValue;
|
|
268
|
-
bytes2[ii] = nextSevenBits;
|
|
269
|
-
if (ii > 0) {
|
|
270
|
-
bytes2[ii - 1] |= 128;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return new Uint8Array(bytes2);
|
|
274
|
-
},
|
|
275
|
-
deserialize: (bytes2, offset = 0) => {
|
|
276
|
-
let value = 0;
|
|
277
|
-
let byteCount = 0;
|
|
278
|
-
while (++byteCount) {
|
|
279
|
-
const byteIndex = byteCount - 1;
|
|
280
|
-
const currentByte = bytes2[offset + byteIndex];
|
|
281
|
-
const nextSevenBits = 127 & currentByte;
|
|
282
|
-
value |= nextSevenBits << byteIndex * 7;
|
|
283
|
-
if ((currentByte & 128) === 0) {
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return [value, offset + byteCount];
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
|
|
292
|
-
var InvalidNumberOfItemsError = class extends Error {
|
|
293
|
-
constructor(serializer, expected, actual) {
|
|
294
|
-
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
295
|
-
__publicField(this, "name", "InvalidNumberOfItemsError");
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
var InvalidArrayLikeRemainderSizeError = class extends Error {
|
|
299
|
-
constructor(remainderSize, itemSize) {
|
|
300
|
-
super(`The remainder of the buffer (${remainderSize} bytes) cannot be split into chunks of ${itemSize} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainderSize} modulo ${itemSize} should be equal to zero.`);
|
|
301
|
-
__publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
|
|
305
|
-
constructor(size) {
|
|
306
|
-
super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
|
|
307
|
-
__publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
312
|
-
function sumSerializerSizes(sizes) {
|
|
313
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
317
|
-
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
318
|
-
if (typeof size === "number") {
|
|
319
|
-
return [size, offset];
|
|
320
|
-
}
|
|
321
|
-
if (typeof size === "object") {
|
|
322
|
-
return size.deserialize(bytes2, offset);
|
|
323
|
-
}
|
|
324
|
-
if (size === "remainder") {
|
|
325
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
326
|
-
if (childrenSize === null) {
|
|
327
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
328
|
-
}
|
|
329
|
-
const remainder = bytes2.slice(offset).length;
|
|
330
|
-
if (remainder % childrenSize !== 0) {
|
|
331
|
-
throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
|
|
332
|
-
}
|
|
333
|
-
return [remainder / childrenSize, offset];
|
|
334
|
-
}
|
|
335
|
-
throw new UnrecognizedArrayLikeSerializerSizeError(size);
|
|
336
|
-
}
|
|
337
|
-
function getSizeDescription(size) {
|
|
338
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
339
|
-
}
|
|
340
|
-
function getSizeFromChildren(size, childrenSizes) {
|
|
341
|
-
if (typeof size !== "number")
|
|
342
|
-
return null;
|
|
343
|
-
if (size === 0)
|
|
344
|
-
return 0;
|
|
345
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
346
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
347
|
-
}
|
|
348
|
-
function getSizePrefix(size, realSize) {
|
|
349
|
-
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
353
|
-
function array(item, options = {}) {
|
|
354
|
-
const size = options.size ?? u32();
|
|
355
|
-
if (size === "remainder" && item.fixedSize === null) {
|
|
356
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
357
|
-
}
|
|
358
|
-
return {
|
|
359
|
-
description: options.description ?? `array(${item.description}; ${getSizeDescription(size)})`,
|
|
360
|
-
fixedSize: getSizeFromChildren(size, [item.fixedSize]),
|
|
361
|
-
maxSize: getSizeFromChildren(size, [item.maxSize]),
|
|
362
|
-
serialize: (value) => {
|
|
363
|
-
if (typeof size === "number" && value.length !== size) {
|
|
364
|
-
throw new InvalidNumberOfItemsError("array", size, value.length);
|
|
365
|
-
}
|
|
366
|
-
return mergeBytes([getSizePrefix(size, value.length), ...value.map((v) => item.serialize(v))]);
|
|
367
|
-
},
|
|
368
|
-
deserialize: (bytes2, offset = 0) => {
|
|
369
|
-
if (typeof size === "object" && bytes2.slice(offset).length === 0) {
|
|
370
|
-
return [[], offset];
|
|
371
|
-
}
|
|
372
|
-
const [resolvedSize, newOffset] = getResolvedSize(size, [item.fixedSize], bytes2, offset);
|
|
373
|
-
offset = newOffset;
|
|
374
|
-
const values = [];
|
|
375
|
-
for (let i = 0; i < resolvedSize; i += 1) {
|
|
376
|
-
const [value, newOffset2] = item.deserialize(bytes2, offset);
|
|
377
|
-
values.push(value);
|
|
378
|
-
offset = newOffset2;
|
|
379
|
-
}
|
|
380
|
-
return [values, offset];
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
386
|
-
function bytes(options = {}) {
|
|
387
|
-
const size = options.size ?? "variable";
|
|
388
|
-
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
389
|
-
const byteSerializer = {
|
|
390
|
-
description,
|
|
391
|
-
fixedSize: null,
|
|
392
|
-
maxSize: null,
|
|
393
|
-
serialize: (value) => new Uint8Array(value),
|
|
394
|
-
deserialize: (bytes2, offset = 0) => {
|
|
395
|
-
const slice = bytes2.slice(offset);
|
|
396
|
-
return [slice, offset + slice.length];
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
if (size === "variable") {
|
|
400
|
-
return byteSerializer;
|
|
401
|
-
}
|
|
402
|
-
if (typeof size === "number") {
|
|
403
|
-
return fixSerializer(byteSerializer, size, description);
|
|
404
|
-
}
|
|
405
|
-
return {
|
|
406
|
-
description,
|
|
407
|
-
fixedSize: null,
|
|
408
|
-
maxSize: null,
|
|
409
|
-
serialize: (value) => {
|
|
410
|
-
const contentBytes = byteSerializer.serialize(value);
|
|
411
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
412
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
413
|
-
},
|
|
414
|
-
deserialize: (buffer, offset = 0) => {
|
|
415
|
-
if (buffer.slice(offset).length === 0) {
|
|
416
|
-
throw new DeserializingEmptyBufferError("bytes");
|
|
417
|
-
}
|
|
418
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
419
|
-
const length = Number(lengthBigInt);
|
|
420
|
-
offset = lengthOffset;
|
|
421
|
-
const contentBuffer = buffer.slice(offset, offset + length);
|
|
422
|
-
if (contentBuffer.length < length) {
|
|
423
|
-
throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
|
|
424
|
-
}
|
|
425
|
-
const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
|
|
426
|
-
offset += contentOffset;
|
|
427
|
-
return [value, offset];
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
433
|
-
function string(options = {}) {
|
|
434
|
-
const size = options.size ?? u32();
|
|
435
|
-
const encoding = options.encoding ?? utf8;
|
|
436
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
437
|
-
if (size === "variable") {
|
|
438
|
-
return {
|
|
439
|
-
...encoding,
|
|
440
|
-
description
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
if (typeof size === "number") {
|
|
444
|
-
return fixSerializer(encoding, size, description);
|
|
445
|
-
}
|
|
446
|
-
return {
|
|
447
|
-
description,
|
|
448
|
-
fixedSize: null,
|
|
449
|
-
maxSize: null,
|
|
450
|
-
serialize: (value) => {
|
|
451
|
-
const contentBytes = encoding.serialize(value);
|
|
452
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
453
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
454
|
-
},
|
|
455
|
-
deserialize: (buffer, offset = 0) => {
|
|
456
|
-
if (buffer.slice(offset).length === 0) {
|
|
457
|
-
throw new DeserializingEmptyBufferError("string");
|
|
458
|
-
}
|
|
459
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
460
|
-
const length = Number(lengthBigInt);
|
|
461
|
-
offset = lengthOffset;
|
|
462
|
-
const contentBuffer = buffer.slice(offset, offset + length);
|
|
463
|
-
if (contentBuffer.length < length) {
|
|
464
|
-
throw new NotEnoughBytesError("string", length, contentBuffer.length);
|
|
465
|
-
}
|
|
466
|
-
const [value, contentOffset] = encoding.deserialize(contentBuffer);
|
|
467
|
-
offset += contentOffset;
|
|
468
|
-
return [value, offset];
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
474
|
-
function struct(fields, options = {}) {
|
|
475
|
-
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
476
|
-
return {
|
|
477
|
-
description: options.description ?? `struct(${fieldDescriptions})`,
|
|
478
|
-
fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
|
|
479
|
-
maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
|
|
480
|
-
serialize: (struct2) => {
|
|
481
|
-
const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
|
|
482
|
-
return mergeBytes(fieldBytes);
|
|
483
|
-
},
|
|
484
|
-
deserialize: (bytes2, offset = 0) => {
|
|
485
|
-
const struct2 = {};
|
|
486
|
-
fields.forEach(([key, serializer]) => {
|
|
487
|
-
const [value, newOffset] = serializer.deserialize(bytes2, offset);
|
|
488
|
-
offset = newOffset;
|
|
489
|
-
struct2[key] = value;
|
|
490
|
-
});
|
|
491
|
-
return [struct2, offset];
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
|
|
496
79
|
// src/unsigned-transaction.ts
|
|
497
80
|
function getUnsignedTransaction(transaction) {
|
|
498
81
|
if ("signatures" in transaction) {
|
|
@@ -517,14 +100,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
517
100
|
) {
|
|
518
101
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
519
102
|
}
|
|
520
|
-
const
|
|
521
|
-
const numBytes =
|
|
103
|
+
const bytes = base58.serialize(putativeBlockhash);
|
|
104
|
+
const numBytes = bytes.byteLength;
|
|
522
105
|
if (numBytes !== 32) {
|
|
523
106
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
524
107
|
}
|
|
525
|
-
} catch (
|
|
108
|
+
} catch (e2) {
|
|
526
109
|
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
527
|
-
cause:
|
|
110
|
+
cause: e2
|
|
528
111
|
});
|
|
529
112
|
}
|
|
530
113
|
}
|
|
@@ -665,6 +248,415 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
665
248
|
return out;
|
|
666
249
|
}
|
|
667
250
|
|
|
251
|
+
// ../codecs-core/dist/index.browser.js
|
|
252
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
253
|
+
if (bytes.length - offset <= 0) {
|
|
254
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
|
|
258
|
+
const bytesLength = bytes.length - offset;
|
|
259
|
+
if (bytesLength < expected) {
|
|
260
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
var mergeBytes = (byteArrays) => {
|
|
264
|
+
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
265
|
+
if (nonEmptyByteArrays.length === 0) {
|
|
266
|
+
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
267
|
+
}
|
|
268
|
+
if (nonEmptyByteArrays.length === 1) {
|
|
269
|
+
return nonEmptyByteArrays[0];
|
|
270
|
+
}
|
|
271
|
+
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
272
|
+
const result = new Uint8Array(totalLength);
|
|
273
|
+
let offset = 0;
|
|
274
|
+
nonEmptyByteArrays.forEach((arr) => {
|
|
275
|
+
result.set(arr, offset);
|
|
276
|
+
offset += arr.length;
|
|
277
|
+
});
|
|
278
|
+
return result;
|
|
279
|
+
};
|
|
280
|
+
var padBytes = (bytes, length) => {
|
|
281
|
+
if (bytes.length >= length)
|
|
282
|
+
return bytes;
|
|
283
|
+
const paddedBytes = new Uint8Array(length).fill(0);
|
|
284
|
+
paddedBytes.set(bytes);
|
|
285
|
+
return paddedBytes;
|
|
286
|
+
};
|
|
287
|
+
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
288
|
+
function fixCodecHelper(data, fixedBytes, description) {
|
|
289
|
+
return {
|
|
290
|
+
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
291
|
+
fixedSize: fixedBytes,
|
|
292
|
+
maxSize: fixedBytes
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function fixEncoder(encoder, fixedBytes, description) {
|
|
296
|
+
return {
|
|
297
|
+
...fixCodecHelper(encoder, fixedBytes, description),
|
|
298
|
+
encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function fixDecoder(decoder, fixedBytes, description) {
|
|
302
|
+
return {
|
|
303
|
+
...fixCodecHelper(decoder, fixedBytes, description),
|
|
304
|
+
decode: (bytes, offset = 0) => {
|
|
305
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
306
|
+
if (offset > 0 || bytes.length > fixedBytes) {
|
|
307
|
+
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
308
|
+
}
|
|
309
|
+
if (decoder.fixedSize !== null) {
|
|
310
|
+
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
311
|
+
}
|
|
312
|
+
const [value] = decoder.decode(bytes, 0);
|
|
313
|
+
return [value, offset + fixedBytes];
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function mapEncoder(encoder, unmap) {
|
|
318
|
+
return {
|
|
319
|
+
description: encoder.description,
|
|
320
|
+
encode: (value) => encoder.encode(unmap(value)),
|
|
321
|
+
fixedSize: encoder.fixedSize,
|
|
322
|
+
maxSize: encoder.maxSize
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
327
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
328
|
+
if (value < min || value > max) {
|
|
329
|
+
throw new Error(
|
|
330
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function sharedNumberFactory(input) {
|
|
335
|
+
let littleEndian;
|
|
336
|
+
let defaultDescription = input.name;
|
|
337
|
+
if (input.size > 1) {
|
|
338
|
+
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
339
|
+
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
description: input.options.description ?? defaultDescription,
|
|
343
|
+
fixedSize: input.size,
|
|
344
|
+
littleEndian,
|
|
345
|
+
maxSize: input.size
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function numberEncoderFactory(input) {
|
|
349
|
+
const codecData = sharedNumberFactory(input);
|
|
350
|
+
return {
|
|
351
|
+
description: codecData.description,
|
|
352
|
+
encode(value) {
|
|
353
|
+
if (input.range) {
|
|
354
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
355
|
+
}
|
|
356
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
357
|
+
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
|
|
358
|
+
return new Uint8Array(arrayBuffer);
|
|
359
|
+
},
|
|
360
|
+
fixedSize: codecData.fixedSize,
|
|
361
|
+
maxSize: codecData.maxSize
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function numberDecoderFactory(input) {
|
|
365
|
+
const codecData = sharedNumberFactory(input);
|
|
366
|
+
return {
|
|
367
|
+
decode(bytes, offset = 0) {
|
|
368
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
|
|
369
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
|
|
370
|
+
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
371
|
+
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
372
|
+
},
|
|
373
|
+
description: codecData.description,
|
|
374
|
+
fixedSize: codecData.fixedSize,
|
|
375
|
+
maxSize: codecData.maxSize
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function toArrayBuffer(bytes, offset, length) {
|
|
379
|
+
const bytesOffset = bytes.byteOffset + (offset ?? 0);
|
|
380
|
+
const bytesLength = length ?? bytes.byteLength;
|
|
381
|
+
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
382
|
+
}
|
|
383
|
+
var getShortU16Encoder = (options = {}) => ({
|
|
384
|
+
description: options.description ?? "shortU16",
|
|
385
|
+
encode: (value) => {
|
|
386
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
387
|
+
const bytes = [0];
|
|
388
|
+
for (let ii = 0; ; ii += 1) {
|
|
389
|
+
const alignedValue = value >> ii * 7;
|
|
390
|
+
if (alignedValue === 0) {
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
const nextSevenBits = 127 & alignedValue;
|
|
394
|
+
bytes[ii] = nextSevenBits;
|
|
395
|
+
if (ii > 0) {
|
|
396
|
+
bytes[ii - 1] |= 128;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return new Uint8Array(bytes);
|
|
400
|
+
},
|
|
401
|
+
fixedSize: null,
|
|
402
|
+
maxSize: 3
|
|
403
|
+
});
|
|
404
|
+
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
405
|
+
name: "u32",
|
|
406
|
+
options,
|
|
407
|
+
range: [0, Number("0xffffffff")],
|
|
408
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
409
|
+
size: 4
|
|
410
|
+
});
|
|
411
|
+
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
412
|
+
get: (view, le) => view.getUint32(0, le),
|
|
413
|
+
name: "u32",
|
|
414
|
+
options,
|
|
415
|
+
size: 4
|
|
416
|
+
});
|
|
417
|
+
var getU8Encoder = (options = {}) => numberEncoderFactory({
|
|
418
|
+
name: "u8",
|
|
419
|
+
options,
|
|
420
|
+
range: [0, Number("0xff")],
|
|
421
|
+
set: (view, value) => view.setUint8(0, value),
|
|
422
|
+
size: 1
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
426
|
+
function sumCodecSizes(sizes) {
|
|
427
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
428
|
+
}
|
|
429
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
430
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
431
|
+
}
|
|
432
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
433
|
+
if (typeof size !== "number")
|
|
434
|
+
return null;
|
|
435
|
+
if (size === 0)
|
|
436
|
+
return 0;
|
|
437
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
438
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
439
|
+
}
|
|
440
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
441
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
442
|
+
}
|
|
443
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
444
|
+
if (expected !== actual) {
|
|
445
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function arrayCodecHelper(item, size, description) {
|
|
449
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
450
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
454
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
455
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
function getArrayEncoder(item, options = {}) {
|
|
459
|
+
const size = options.size ?? getU32Encoder();
|
|
460
|
+
return {
|
|
461
|
+
...arrayCodecHelper(item, size, options.description),
|
|
462
|
+
encode: (value) => {
|
|
463
|
+
if (typeof size === "number") {
|
|
464
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
465
|
+
}
|
|
466
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function getBytesEncoder(options = {}) {
|
|
471
|
+
const size = options.size ?? "variable";
|
|
472
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
473
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
474
|
+
const byteEncoder = {
|
|
475
|
+
description,
|
|
476
|
+
encode: (value) => value,
|
|
477
|
+
fixedSize: null,
|
|
478
|
+
maxSize: null
|
|
479
|
+
};
|
|
480
|
+
if (size === "variable") {
|
|
481
|
+
return byteEncoder;
|
|
482
|
+
}
|
|
483
|
+
if (typeof size === "number") {
|
|
484
|
+
return fixEncoder(byteEncoder, size, description);
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
...byteEncoder,
|
|
488
|
+
encode: (value) => {
|
|
489
|
+
const contentBytes = byteEncoder.encode(value);
|
|
490
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
491
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function structCodecHelper(fields, description) {
|
|
496
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
497
|
+
return {
|
|
498
|
+
description: description ?? `struct(${fieldDescriptions})`,
|
|
499
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
500
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function getStructEncoder(fields, options = {}) {
|
|
504
|
+
return {
|
|
505
|
+
...structCodecHelper(fields, options.description),
|
|
506
|
+
encode: (struct) => {
|
|
507
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
508
|
+
return mergeBytes(fieldBytes);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// ../codecs-strings/dist/index.browser.js
|
|
514
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
515
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
516
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
520
|
+
const base = alphabet4.length;
|
|
521
|
+
const baseBigInt = BigInt(base);
|
|
522
|
+
return {
|
|
523
|
+
description: `base${base}`,
|
|
524
|
+
encode(value) {
|
|
525
|
+
assertValidBaseString(alphabet4, value);
|
|
526
|
+
if (value === "")
|
|
527
|
+
return new Uint8Array();
|
|
528
|
+
const chars = [...value];
|
|
529
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
530
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
531
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
532
|
+
if (trailIndex === chars.length)
|
|
533
|
+
return Uint8Array.from(leadingZeroes);
|
|
534
|
+
const tailChars = chars.slice(trailIndex);
|
|
535
|
+
let base10Number = 0n;
|
|
536
|
+
let baseXPower = 1n;
|
|
537
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
538
|
+
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
539
|
+
baseXPower *= baseBigInt;
|
|
540
|
+
}
|
|
541
|
+
const tailBytes = [];
|
|
542
|
+
while (base10Number > 0n) {
|
|
543
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
544
|
+
base10Number /= 256n;
|
|
545
|
+
}
|
|
546
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
547
|
+
},
|
|
548
|
+
fixedSize: null,
|
|
549
|
+
maxSize: null
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
553
|
+
const base = alphabet4.length;
|
|
554
|
+
const baseBigInt = BigInt(base);
|
|
555
|
+
return {
|
|
556
|
+
decode(rawBytes, offset = 0) {
|
|
557
|
+
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
558
|
+
if (bytes.length === 0)
|
|
559
|
+
return ["", 0];
|
|
560
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
561
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
562
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
563
|
+
if (trailIndex === bytes.length)
|
|
564
|
+
return [leadingZeroes, rawBytes.length];
|
|
565
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
566
|
+
const tailChars = [];
|
|
567
|
+
while (base10Number > 0n) {
|
|
568
|
+
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
569
|
+
base10Number /= baseBigInt;
|
|
570
|
+
}
|
|
571
|
+
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
572
|
+
},
|
|
573
|
+
description: `base${base}`,
|
|
574
|
+
fixedSize: null,
|
|
575
|
+
maxSize: null
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
579
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
580
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
581
|
+
var removeNullCharacters = (value) => (
|
|
582
|
+
// eslint-disable-next-line no-control-regex
|
|
583
|
+
value.replace(/\u0000/g, "")
|
|
584
|
+
);
|
|
585
|
+
var e = globalThis.TextDecoder;
|
|
586
|
+
var o = globalThis.TextEncoder;
|
|
587
|
+
var getUtf8Encoder = () => {
|
|
588
|
+
let textEncoder;
|
|
589
|
+
return {
|
|
590
|
+
description: "utf8",
|
|
591
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
592
|
+
fixedSize: null,
|
|
593
|
+
maxSize: null
|
|
594
|
+
};
|
|
595
|
+
};
|
|
596
|
+
var getUtf8Decoder = () => {
|
|
597
|
+
let textDecoder;
|
|
598
|
+
return {
|
|
599
|
+
decode(bytes, offset = 0) {
|
|
600
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
601
|
+
return [removeNullCharacters(value), bytes.length];
|
|
602
|
+
},
|
|
603
|
+
description: "utf8",
|
|
604
|
+
fixedSize: null,
|
|
605
|
+
maxSize: null
|
|
606
|
+
};
|
|
607
|
+
};
|
|
608
|
+
var getStringEncoder = (options = {}) => {
|
|
609
|
+
const size = options.size ?? getU32Encoder();
|
|
610
|
+
const encoding = options.encoding ?? getUtf8Encoder();
|
|
611
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
612
|
+
if (size === "variable") {
|
|
613
|
+
return { ...encoding, description };
|
|
614
|
+
}
|
|
615
|
+
if (typeof size === "number") {
|
|
616
|
+
return fixEncoder(encoding, size, description);
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
description,
|
|
620
|
+
encode: (value) => {
|
|
621
|
+
const contentBytes = encoding.encode(value);
|
|
622
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
623
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
624
|
+
},
|
|
625
|
+
fixedSize: null,
|
|
626
|
+
maxSize: null
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
var getStringDecoder = (options = {}) => {
|
|
630
|
+
const size = options.size ?? getU32Decoder();
|
|
631
|
+
const encoding = options.encoding ?? getUtf8Decoder();
|
|
632
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
633
|
+
if (size === "variable") {
|
|
634
|
+
return { ...encoding, description };
|
|
635
|
+
}
|
|
636
|
+
if (typeof size === "number") {
|
|
637
|
+
return fixDecoder(encoding, size, description);
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
decode: (bytes, offset = 0) => {
|
|
641
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
642
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
643
|
+
const length = Number(lengthBigInt);
|
|
644
|
+
offset = lengthOffset;
|
|
645
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
646
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
647
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
648
|
+
offset += contentOffset;
|
|
649
|
+
return [value, offset];
|
|
650
|
+
},
|
|
651
|
+
description,
|
|
652
|
+
fixedSize: null,
|
|
653
|
+
maxSize: null
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
function getSizeDescription(size) {
|
|
657
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
658
|
+
}
|
|
659
|
+
|
|
668
660
|
// ../assertions/dist/index.browser.js
|
|
669
661
|
function assertIsSecureContext() {
|
|
670
662
|
if (!globalThis.isSecureContext) {
|
|
@@ -685,10 +677,59 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
685
677
|
throw new Error("No signing implementation could be found");
|
|
686
678
|
}
|
|
687
679
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
680
|
+
|
|
681
|
+
// ../addresses/dist/index.browser.js
|
|
682
|
+
var memoizedBase58Encoder;
|
|
683
|
+
var memoizedBase58Decoder;
|
|
684
|
+
function getMemoizedBase58Encoder() {
|
|
685
|
+
if (!memoizedBase58Encoder)
|
|
686
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
687
|
+
return memoizedBase58Encoder;
|
|
688
|
+
}
|
|
689
|
+
function getMemoizedBase58Decoder() {
|
|
690
|
+
if (!memoizedBase58Decoder)
|
|
691
|
+
memoizedBase58Decoder = getBase58Decoder();
|
|
692
|
+
return memoizedBase58Decoder;
|
|
693
|
+
}
|
|
694
|
+
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
695
|
+
try {
|
|
696
|
+
if (
|
|
697
|
+
// Lowest address (32 bytes of zeroes)
|
|
698
|
+
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
699
|
+
putativeBase58EncodedAddress.length > 44
|
|
700
|
+
) {
|
|
701
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
702
|
+
}
|
|
703
|
+
const base58Encoder = getMemoizedBase58Encoder();
|
|
704
|
+
const bytes = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
705
|
+
const numBytes = bytes.byteLength;
|
|
706
|
+
if (numBytes !== 32) {
|
|
707
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
708
|
+
}
|
|
709
|
+
} catch (e2) {
|
|
710
|
+
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
711
|
+
cause: e2
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
function address(putativeBase58EncodedAddress) {
|
|
716
|
+
assertIsAddress(putativeBase58EncodedAddress);
|
|
717
|
+
return putativeBase58EncodedAddress;
|
|
718
|
+
}
|
|
719
|
+
function getAddressEncoder(config) {
|
|
720
|
+
return mapEncoder(
|
|
721
|
+
getStringEncoder({
|
|
722
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
723
|
+
encoding: getMemoizedBase58Encoder(),
|
|
724
|
+
size: 32
|
|
725
|
+
}),
|
|
726
|
+
(putativeAddress) => address(putativeAddress)
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
function getAddressDecoder(config) {
|
|
730
|
+
return getStringDecoder({
|
|
731
|
+
description: config?.description ?? "Base58EncodedAddress",
|
|
732
|
+
encoding: getMemoizedBase58Decoder(),
|
|
692
733
|
size: 32
|
|
693
734
|
});
|
|
694
735
|
}
|
|
@@ -708,13 +749,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
708
749
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
709
750
|
}
|
|
710
751
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
711
|
-
const [base58EncodedAddress] =
|
|
752
|
+
const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
712
753
|
return base58EncodedAddress;
|
|
713
754
|
}
|
|
714
755
|
|
|
715
756
|
// src/accounts.ts
|
|
716
|
-
function upsert(addressMap,
|
|
717
|
-
addressMap[
|
|
757
|
+
function upsert(addressMap, address2, update) {
|
|
758
|
+
addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
|
|
718
759
|
}
|
|
719
760
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
720
761
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -877,8 +918,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
877
918
|
} else {
|
|
878
919
|
return addressComparator(leftAddress, rightAddress);
|
|
879
920
|
}
|
|
880
|
-
}).map(([
|
|
881
|
-
address,
|
|
921
|
+
}).map(([address2, addressMeta]) => ({
|
|
922
|
+
address: address2,
|
|
882
923
|
...addressMeta
|
|
883
924
|
}));
|
|
884
925
|
return orderedAccounts;
|
|
@@ -947,7 +988,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
947
988
|
return instructions.map(({ accounts, data, programAddress }) => {
|
|
948
989
|
return {
|
|
949
990
|
programAddressIndex: accountIndex[programAddress],
|
|
950
|
-
...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[
|
|
991
|
+
...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
|
|
951
992
|
...data ? { data } : null
|
|
952
993
|
};
|
|
953
994
|
});
|
|
@@ -965,7 +1006,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
965
1006
|
function getCompiledStaticAccounts(orderedAccounts) {
|
|
966
1007
|
const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
|
|
967
1008
|
const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
|
|
968
|
-
return orderedStaticAccounts.map(({ address }) =>
|
|
1009
|
+
return orderedStaticAccounts.map(({ address: address2 }) => address2);
|
|
969
1010
|
}
|
|
970
1011
|
|
|
971
1012
|
// src/message.ts
|
|
@@ -1001,144 +1042,102 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1001
1042
|
}
|
|
1002
1043
|
|
|
1003
1044
|
// src/serializers/address-table-lookup.ts
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
)
|
|
1014
|
-
],
|
|
1045
|
+
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
1046
|
+
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
1047
|
+
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
1048
|
+
var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
|
|
1049
|
+
var memoizedAddressTableLookupEncoder;
|
|
1050
|
+
function getAddressTableLookupEncoder() {
|
|
1051
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
1052
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
1015
1053
|
[
|
|
1016
|
-
"
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1054
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
1055
|
+
[
|
|
1056
|
+
"writableIndices",
|
|
1057
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1058
|
+
description: writableIndicesDescription,
|
|
1059
|
+
size: getShortU16Encoder()
|
|
1060
|
+
})
|
|
1061
|
+
],
|
|
1062
|
+
[
|
|
1063
|
+
"readableIndices",
|
|
1064
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1065
|
+
description: readableIndicesDescription,
|
|
1066
|
+
size: getShortU16Encoder()
|
|
1067
|
+
})
|
|
1068
|
+
]
|
|
1023
1069
|
],
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
description: "The indices of the accounts in the lookup table that should be loaded as read-only"
|
|
1029
|
-
} ,
|
|
1030
|
-
size: shortU16()
|
|
1031
|
-
})
|
|
1032
|
-
]
|
|
1033
|
-
],
|
|
1034
|
-
{
|
|
1035
|
-
description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
|
|
1036
|
-
}
|
|
1037
|
-
);
|
|
1070
|
+
{ description: addressTableLookupDescription }
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
return memoizedAddressTableLookupEncoder;
|
|
1038
1074
|
}
|
|
1039
1075
|
|
|
1040
1076
|
// src/serializers/header.ts
|
|
1041
|
-
|
|
1042
|
-
|
|
1077
|
+
var memoizedU8Encoder;
|
|
1078
|
+
function getMemoizedU8Encoder() {
|
|
1079
|
+
if (!memoizedU8Encoder)
|
|
1080
|
+
memoizedU8Encoder = getU8Encoder();
|
|
1081
|
+
return memoizedU8Encoder;
|
|
1082
|
+
}
|
|
1083
|
+
function getMemoizedU8EncoderDescription(description) {
|
|
1084
|
+
const encoder = getMemoizedU8Encoder();
|
|
1085
|
+
return {
|
|
1086
|
+
...encoder,
|
|
1087
|
+
description: description ?? encoder.description
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
1091
|
+
var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ;
|
|
1092
|
+
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
1093
|
+
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1094
|
+
function getMessageHeaderEncoder() {
|
|
1095
|
+
return getStructEncoder(
|
|
1043
1096
|
[
|
|
1044
|
-
[
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
{
|
|
1048
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
|
|
1049
|
-
}
|
|
1050
|
-
)
|
|
1051
|
-
],
|
|
1052
|
-
[
|
|
1053
|
-
"numReadonlySignerAccounts",
|
|
1054
|
-
u8(
|
|
1055
|
-
{
|
|
1056
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
|
|
1057
|
-
}
|
|
1058
|
-
)
|
|
1059
|
-
],
|
|
1060
|
-
[
|
|
1061
|
-
"numReadonlyNonSignerAccounts",
|
|
1062
|
-
u8(
|
|
1063
|
-
{
|
|
1064
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
1065
|
-
}
|
|
1066
|
-
)
|
|
1067
|
-
]
|
|
1097
|
+
["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
|
|
1098
|
+
["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
|
|
1099
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1068
1100
|
],
|
|
1069
1101
|
{
|
|
1070
|
-
description:
|
|
1071
|
-
}
|
|
1102
|
+
description: messageHeaderDescription
|
|
1103
|
+
}
|
|
1072
1104
|
);
|
|
1073
1105
|
}
|
|
1074
1106
|
|
|
1075
1107
|
// src/serializers/instruction.ts
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
)
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
)
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
}
|
|
1105
|
-
]
|
|
1106
|
-
]),
|
|
1107
|
-
(value) => {
|
|
1108
|
-
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1109
|
-
return value;
|
|
1110
|
-
}
|
|
1111
|
-
return {
|
|
1112
|
-
...value,
|
|
1113
|
-
accountIndices: value.accountIndices ?? [],
|
|
1114
|
-
data: value.data ?? new Uint8Array(0)
|
|
1115
|
-
};
|
|
1116
|
-
},
|
|
1117
|
-
(value) => {
|
|
1118
|
-
if (value.accountIndices.length && value.data.byteLength) {
|
|
1119
|
-
return value;
|
|
1108
|
+
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
1109
|
+
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
1110
|
+
var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
|
|
1111
|
+
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
1112
|
+
var memoizedGetInstructionEncoder;
|
|
1113
|
+
function getInstructionEncoder() {
|
|
1114
|
+
if (!memoizedGetInstructionEncoder) {
|
|
1115
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
1116
|
+
getStructEncoder([
|
|
1117
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
1118
|
+
[
|
|
1119
|
+
"accountIndices",
|
|
1120
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
1121
|
+
description: accountIndicesDescription,
|
|
1122
|
+
size: getShortU16Encoder()
|
|
1123
|
+
})
|
|
1124
|
+
],
|
|
1125
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
1126
|
+
]),
|
|
1127
|
+
// Convert an instruction to have all fields defined
|
|
1128
|
+
(instruction) => {
|
|
1129
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1130
|
+
return instruction;
|
|
1131
|
+
}
|
|
1132
|
+
return {
|
|
1133
|
+
...instruction,
|
|
1134
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
1135
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
1136
|
+
};
|
|
1120
1137
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
...accountIndices.length ? { accountIndices } : null,
|
|
1125
|
-
...data.byteLength ? { data } : null
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
// src/serializers/unimplemented.ts
|
|
1132
|
-
function getError(type, name) {
|
|
1133
|
-
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
1134
|
-
return new Error(
|
|
1135
|
-
`No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
|
|
1136
|
-
);
|
|
1137
|
-
}
|
|
1138
|
-
function getUnimplementedDecoder(name) {
|
|
1139
|
-
return () => {
|
|
1140
|
-
throw getError("decoder", name);
|
|
1141
|
-
};
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
return memoizedGetInstructionEncoder;
|
|
1142
1141
|
}
|
|
1143
1142
|
|
|
1144
1143
|
// src/serializers/transaction-version.ts
|
|
@@ -1148,16 +1147,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1148
1147
|
fixedSize: null,
|
|
1149
1148
|
maxSize: 1
|
|
1150
1149
|
};
|
|
1151
|
-
function
|
|
1152
|
-
const firstByte = bytes2[offset];
|
|
1153
|
-
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1154
|
-
return ["legacy", offset];
|
|
1155
|
-
} else {
|
|
1156
|
-
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
1157
|
-
return [version, offset + 1];
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
function serialize(value) {
|
|
1150
|
+
function encode(value) {
|
|
1161
1151
|
if (value === "legacy") {
|
|
1162
1152
|
return new Uint8Array();
|
|
1163
1153
|
}
|
|
@@ -1166,108 +1156,110 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1166
1156
|
}
|
|
1167
1157
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1168
1158
|
}
|
|
1169
|
-
function
|
|
1159
|
+
function getTransactionVersionEncoder() {
|
|
1170
1160
|
return {
|
|
1171
1161
|
...BASE_CONFIG,
|
|
1172
|
-
|
|
1173
|
-
serialize
|
|
1162
|
+
encode
|
|
1174
1163
|
};
|
|
1175
1164
|
}
|
|
1176
1165
|
|
|
1177
1166
|
// src/serializers/message.ts
|
|
1178
|
-
var
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
(value)
|
|
1193
|
-
|
|
1194
|
-
return value;
|
|
1195
|
-
}
|
|
1196
|
-
return {
|
|
1197
|
-
...value,
|
|
1198
|
-
addressTableLookups: value.addressTableLookups ?? []
|
|
1199
|
-
};
|
|
1167
|
+
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
|
|
1168
|
+
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
|
|
1169
|
+
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
|
|
1170
|
+
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
|
|
1171
|
+
function getCompiledMessageLegacyEncoder() {
|
|
1172
|
+
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
1173
|
+
}
|
|
1174
|
+
function getCompiledMessageVersionedEncoder() {
|
|
1175
|
+
return mapEncoder(
|
|
1176
|
+
getStructEncoder([
|
|
1177
|
+
...getPreludeStructEncoderTuple(),
|
|
1178
|
+
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1179
|
+
]),
|
|
1180
|
+
(value) => {
|
|
1181
|
+
if (value.version === "legacy") {
|
|
1182
|
+
return value;
|
|
1200
1183
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1184
|
+
return {
|
|
1185
|
+
...value,
|
|
1186
|
+
addressTableLookups: value.addressTableLookups ?? []
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
);
|
|
1203
1190
|
}
|
|
1204
|
-
function
|
|
1191
|
+
function getPreludeStructEncoderTuple() {
|
|
1205
1192
|
return [
|
|
1206
|
-
["version",
|
|
1207
|
-
["header",
|
|
1193
|
+
["version", getTransactionVersionEncoder()],
|
|
1194
|
+
["header", getMessageHeaderEncoder()],
|
|
1208
1195
|
[
|
|
1209
1196
|
"staticAccounts",
|
|
1210
|
-
|
|
1211
|
-
description:
|
|
1212
|
-
size:
|
|
1197
|
+
getArrayEncoder(getAddressEncoder(), {
|
|
1198
|
+
description: staticAccountsDescription,
|
|
1199
|
+
size: getShortU16Encoder()
|
|
1213
1200
|
})
|
|
1214
1201
|
],
|
|
1215
1202
|
[
|
|
1216
1203
|
"lifetimeToken",
|
|
1217
|
-
|
|
1218
|
-
description:
|
|
1219
|
-
encoding:
|
|
1204
|
+
getStringEncoder({
|
|
1205
|
+
description: lifetimeTokenDescription,
|
|
1206
|
+
encoding: getBase58Encoder(),
|
|
1220
1207
|
size: 32
|
|
1221
1208
|
})
|
|
1222
1209
|
],
|
|
1223
1210
|
[
|
|
1224
1211
|
"instructions",
|
|
1225
|
-
|
|
1226
|
-
description:
|
|
1227
|
-
size:
|
|
1212
|
+
getArrayEncoder(getInstructionEncoder(), {
|
|
1213
|
+
description: instructionsDescription,
|
|
1214
|
+
size: getShortU16Encoder()
|
|
1228
1215
|
})
|
|
1229
1216
|
]
|
|
1230
1217
|
];
|
|
1231
1218
|
}
|
|
1232
|
-
function
|
|
1233
|
-
return
|
|
1234
|
-
|
|
1235
|
-
size:
|
|
1219
|
+
function getAddressTableLookupArrayEncoder() {
|
|
1220
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
1221
|
+
description: addressTableLookupsDescription,
|
|
1222
|
+
size: getShortU16Encoder()
|
|
1236
1223
|
});
|
|
1237
1224
|
}
|
|
1225
|
+
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1238
1226
|
function getCompiledMessageEncoder() {
|
|
1239
1227
|
return {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1228
|
+
description: messageDescription,
|
|
1229
|
+
encode: (compiledMessage) => {
|
|
1230
|
+
if (compiledMessage.version === "legacy") {
|
|
1231
|
+
return getCompiledMessageLegacyEncoder().encode(compiledMessage);
|
|
1232
|
+
} else {
|
|
1233
|
+
return getCompiledMessageVersionedEncoder().encode(compiledMessage);
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
fixedSize: null,
|
|
1237
|
+
maxSize: null
|
|
1243
1238
|
};
|
|
1244
1239
|
}
|
|
1245
1240
|
|
|
1246
1241
|
// src/serializers/transaction.ts
|
|
1247
|
-
var
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
};
|
|
1252
|
-
function serialize3(transaction) {
|
|
1253
|
-
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1254
|
-
return struct([
|
|
1242
|
+
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
1243
|
+
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
1244
|
+
function getCompiledTransactionEncoder() {
|
|
1245
|
+
return getStructEncoder(
|
|
1255
1246
|
[
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1247
|
+
[
|
|
1248
|
+
"signatures",
|
|
1249
|
+
getArrayEncoder(getBytesEncoder({ size: 64 }), {
|
|
1250
|
+
description: signaturesDescription,
|
|
1251
|
+
size: getShortU16Encoder()
|
|
1252
|
+
})
|
|
1253
|
+
],
|
|
1254
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
1261
1255
|
],
|
|
1262
|
-
|
|
1263
|
-
|
|
1256
|
+
{
|
|
1257
|
+
description: transactionDescription
|
|
1258
|
+
}
|
|
1259
|
+
);
|
|
1264
1260
|
}
|
|
1265
1261
|
function getTransactionEncoder() {
|
|
1266
|
-
return
|
|
1267
|
-
...BASE_CONFIG3,
|
|
1268
|
-
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1269
|
-
serialize: serialize3
|
|
1270
|
-
};
|
|
1262
|
+
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
1271
1263
|
}
|
|
1272
1264
|
|
|
1273
1265
|
// ../keys/dist/index.browser.js
|
|
@@ -1287,14 +1279,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1287
1279
|
) {
|
|
1288
1280
|
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1289
1281
|
}
|
|
1290
|
-
const
|
|
1291
|
-
const numBytes =
|
|
1282
|
+
const bytes = base58.serialize(putativeTransactionSignature);
|
|
1283
|
+
const numBytes = bytes.byteLength;
|
|
1292
1284
|
if (numBytes !== 64) {
|
|
1293
1285
|
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1294
1286
|
}
|
|
1295
|
-
} catch (
|
|
1287
|
+
} catch (e2) {
|
|
1296
1288
|
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1297
|
-
cause:
|
|
1289
|
+
cause: e2
|
|
1298
1290
|
});
|
|
1299
1291
|
}
|
|
1300
1292
|
}
|
|
@@ -1306,26 +1298,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1306
1298
|
) {
|
|
1307
1299
|
return false;
|
|
1308
1300
|
}
|
|
1309
|
-
const
|
|
1310
|
-
const numBytes =
|
|
1301
|
+
const bytes = base58.serialize(putativeTransactionSignature);
|
|
1302
|
+
const numBytes = bytes.byteLength;
|
|
1311
1303
|
if (numBytes !== 64) {
|
|
1312
1304
|
return false;
|
|
1313
1305
|
}
|
|
1314
1306
|
return true;
|
|
1315
1307
|
}
|
|
1316
1308
|
async function getCompiledMessageSignature(message, secretKey) {
|
|
1317
|
-
const wireMessageBytes = getCompiledMessageEncoder().
|
|
1309
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(message);
|
|
1318
1310
|
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1319
1311
|
return signature;
|
|
1320
1312
|
}
|
|
1321
1313
|
function getSignatureFromTransaction(transaction) {
|
|
1322
|
-
const
|
|
1323
|
-
if (!
|
|
1314
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
1315
|
+
if (!signatureBytes) {
|
|
1324
1316
|
throw new Error(
|
|
1325
1317
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1326
1318
|
);
|
|
1327
1319
|
}
|
|
1328
|
-
|
|
1320
|
+
const transactionSignature2 = base58.deserialize(signatureBytes)[0];
|
|
1321
|
+
return transactionSignature2;
|
|
1329
1322
|
}
|
|
1330
1323
|
async function signTransaction(keyPairs, transaction) {
|
|
1331
1324
|
const compiledMessage = compileMessage(transaction);
|
|
@@ -1355,7 +1348,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1355
1348
|
|
|
1356
1349
|
// src/wire-transaction.ts
|
|
1357
1350
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1358
|
-
const wireTransactionBytes = getTransactionEncoder().
|
|
1351
|
+
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1359
1352
|
{
|
|
1360
1353
|
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1361
1354
|
}
|
|
@@ -1369,6 +1362,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1369
1362
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1370
1363
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1371
1364
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1365
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1372
1366
|
exports.isTransactionSignature = isTransactionSignature;
|
|
1373
1367
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1374
1368
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|