@solana/transactions 2.0.0-experimental.ce179f2 → 2.0.0-experimental.cf6ca9d
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 +344 -134
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +346 -139
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +571 -772
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +346 -139
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +342 -134
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +344 -139
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +20 -17
- package/dist/types/decompile-transaction.d.ts +7 -0
- package/dist/types/durable-nonce.d.ts +2 -3
- package/dist/types/serializers/message.d.ts +4 -4
- package/dist/types/serializers/transaction.d.ts +7 -4
- package/dist/types/signatures.d.ts +1 -0
- package/dist/types/wire-transaction.d.ts +1 -1
- package/package.json +9 -7
- package/dist/types/serializers/unimplemented.d.ts +0 -3
|
@@ -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,337 +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/u32.mjs
|
|
235
|
-
var u32 = (options = {}) => numberFactory({
|
|
236
|
-
name: "u32",
|
|
237
|
-
size: 4,
|
|
238
|
-
range: [0, Number("0xffffffff")],
|
|
239
|
-
set: (view, value, le) => view.setUint32(0, Number(value), le),
|
|
240
|
-
get: (view, le) => view.getUint32(0, le),
|
|
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/shortU16.mjs
|
|
245
|
-
var shortU16 = (options = {}) => ({
|
|
246
|
-
description: options.description ?? "shortU16",
|
|
247
|
-
fixedSize: null,
|
|
248
|
-
maxSize: 3,
|
|
249
|
-
serialize: (value) => {
|
|
250
|
-
assertRange("shortU16", 0, 65535, value);
|
|
251
|
-
const bytes2 = [0];
|
|
252
|
-
for (let ii = 0; ; ii += 1) {
|
|
253
|
-
const alignedValue = value >> ii * 7;
|
|
254
|
-
if (alignedValue === 0) {
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
const nextSevenBits = 127 & alignedValue;
|
|
258
|
-
bytes2[ii] = nextSevenBits;
|
|
259
|
-
if (ii > 0) {
|
|
260
|
-
bytes2[ii - 1] |= 128;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return new Uint8Array(bytes2);
|
|
264
|
-
},
|
|
265
|
-
deserialize: (bytes2, offset = 0) => {
|
|
266
|
-
let value = 0;
|
|
267
|
-
let byteCount = 0;
|
|
268
|
-
while (++byteCount) {
|
|
269
|
-
const byteIndex = byteCount - 1;
|
|
270
|
-
const currentByte = bytes2[offset + byteIndex];
|
|
271
|
-
const nextSevenBits = 127 & currentByte;
|
|
272
|
-
value |= nextSevenBits << byteIndex * 7;
|
|
273
|
-
if ((currentByte & 128) === 0) {
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return [value, offset + byteCount];
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
|
|
282
|
-
var InvalidNumberOfItemsError = class extends Error {
|
|
283
|
-
constructor(serializer, expected, actual) {
|
|
284
|
-
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
285
|
-
__publicField(this, "name", "InvalidNumberOfItemsError");
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
var InvalidArrayLikeRemainderSizeError = class extends Error {
|
|
289
|
-
constructor(remainderSize, itemSize) {
|
|
290
|
-
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.`);
|
|
291
|
-
__publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
|
|
295
|
-
constructor(size) {
|
|
296
|
-
super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
|
|
297
|
-
__publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
302
|
-
function sumSerializerSizes(sizes) {
|
|
303
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
307
|
-
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
308
|
-
if (typeof size === "number") {
|
|
309
|
-
return [size, offset];
|
|
310
|
-
}
|
|
311
|
-
if (typeof size === "object") {
|
|
312
|
-
return size.deserialize(bytes2, offset);
|
|
313
|
-
}
|
|
314
|
-
if (size === "remainder") {
|
|
315
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
316
|
-
if (childrenSize === null) {
|
|
317
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
318
|
-
}
|
|
319
|
-
const remainder = bytes2.slice(offset).length;
|
|
320
|
-
if (remainder % childrenSize !== 0) {
|
|
321
|
-
throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
|
|
322
|
-
}
|
|
323
|
-
return [remainder / childrenSize, offset];
|
|
324
|
-
}
|
|
325
|
-
throw new UnrecognizedArrayLikeSerializerSizeError(size);
|
|
326
|
-
}
|
|
327
|
-
function getSizeDescription(size) {
|
|
328
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
329
|
-
}
|
|
330
|
-
function getSizeFromChildren(size, childrenSizes) {
|
|
331
|
-
if (typeof size !== "number")
|
|
332
|
-
return null;
|
|
333
|
-
if (size === 0)
|
|
334
|
-
return 0;
|
|
335
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
336
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
337
|
-
}
|
|
338
|
-
function getSizePrefix(size, realSize) {
|
|
339
|
-
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
343
|
-
function array(item, options = {}) {
|
|
344
|
-
const size = options.size ?? u32();
|
|
345
|
-
if (size === "remainder" && item.fixedSize === null) {
|
|
346
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
347
|
-
}
|
|
348
|
-
return {
|
|
349
|
-
description: options.description ?? `array(${item.description}; ${getSizeDescription(size)})`,
|
|
350
|
-
fixedSize: getSizeFromChildren(size, [item.fixedSize]),
|
|
351
|
-
maxSize: getSizeFromChildren(size, [item.maxSize]),
|
|
352
|
-
serialize: (value) => {
|
|
353
|
-
if (typeof size === "number" && value.length !== size) {
|
|
354
|
-
throw new InvalidNumberOfItemsError("array", size, value.length);
|
|
355
|
-
}
|
|
356
|
-
return mergeBytes([getSizePrefix(size, value.length), ...value.map((v) => item.serialize(v))]);
|
|
357
|
-
},
|
|
358
|
-
deserialize: (bytes2, offset = 0) => {
|
|
359
|
-
if (typeof size === "object" && bytes2.slice(offset).length === 0) {
|
|
360
|
-
return [[], offset];
|
|
361
|
-
}
|
|
362
|
-
const [resolvedSize, newOffset] = getResolvedSize(size, [item.fixedSize], bytes2, offset);
|
|
363
|
-
offset = newOffset;
|
|
364
|
-
const values = [];
|
|
365
|
-
for (let i = 0; i < resolvedSize; i += 1) {
|
|
366
|
-
const [value, newOffset2] = item.deserialize(bytes2, offset);
|
|
367
|
-
values.push(value);
|
|
368
|
-
offset = newOffset2;
|
|
369
|
-
}
|
|
370
|
-
return [values, offset];
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
376
|
-
function bytes(options = {}) {
|
|
377
|
-
const size = options.size ?? "variable";
|
|
378
|
-
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
379
|
-
const byteSerializer = {
|
|
380
|
-
description,
|
|
381
|
-
fixedSize: null,
|
|
382
|
-
maxSize: null,
|
|
383
|
-
serialize: (value) => new Uint8Array(value),
|
|
384
|
-
deserialize: (bytes2, offset = 0) => {
|
|
385
|
-
const slice = bytes2.slice(offset);
|
|
386
|
-
return [slice, offset + slice.length];
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
if (size === "variable") {
|
|
390
|
-
return byteSerializer;
|
|
391
|
-
}
|
|
392
|
-
if (typeof size === "number") {
|
|
393
|
-
return fixSerializer(byteSerializer, size, description);
|
|
394
|
-
}
|
|
395
|
-
return {
|
|
396
|
-
description,
|
|
397
|
-
fixedSize: null,
|
|
398
|
-
maxSize: null,
|
|
399
|
-
serialize: (value) => {
|
|
400
|
-
const contentBytes = byteSerializer.serialize(value);
|
|
401
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
402
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
403
|
-
},
|
|
404
|
-
deserialize: (buffer, offset = 0) => {
|
|
405
|
-
if (buffer.slice(offset).length === 0) {
|
|
406
|
-
throw new DeserializingEmptyBufferError("bytes");
|
|
407
|
-
}
|
|
408
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
409
|
-
const length = Number(lengthBigInt);
|
|
410
|
-
offset = lengthOffset;
|
|
411
|
-
const contentBuffer = buffer.slice(offset, offset + length);
|
|
412
|
-
if (contentBuffer.length < length) {
|
|
413
|
-
throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
|
|
414
|
-
}
|
|
415
|
-
const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
|
|
416
|
-
offset += contentOffset;
|
|
417
|
-
return [value, offset];
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
423
|
-
function string(options = {}) {
|
|
424
|
-
const size = options.size ?? u32();
|
|
425
|
-
const encoding = options.encoding ?? utf8;
|
|
426
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
427
|
-
if (size === "variable") {
|
|
428
|
-
return {
|
|
429
|
-
...encoding,
|
|
430
|
-
description
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
if (typeof size === "number") {
|
|
434
|
-
return fixSerializer(encoding, size, description);
|
|
435
|
-
}
|
|
436
|
-
return {
|
|
437
|
-
description,
|
|
438
|
-
fixedSize: null,
|
|
439
|
-
maxSize: null,
|
|
440
|
-
serialize: (value) => {
|
|
441
|
-
const contentBytes = encoding.serialize(value);
|
|
442
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
443
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
444
|
-
},
|
|
445
|
-
deserialize: (buffer, offset = 0) => {
|
|
446
|
-
if (buffer.slice(offset).length === 0) {
|
|
447
|
-
throw new DeserializingEmptyBufferError("string");
|
|
448
|
-
}
|
|
449
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
450
|
-
const length = Number(lengthBigInt);
|
|
451
|
-
offset = lengthOffset;
|
|
452
|
-
const contentBuffer = buffer.slice(offset, offset + length);
|
|
453
|
-
if (contentBuffer.length < length) {
|
|
454
|
-
throw new NotEnoughBytesError("string", length, contentBuffer.length);
|
|
455
|
-
}
|
|
456
|
-
const [value, contentOffset] = encoding.deserialize(contentBuffer);
|
|
457
|
-
offset += contentOffset;
|
|
458
|
-
return [value, offset];
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
464
|
-
function struct(fields, options = {}) {
|
|
465
|
-
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
466
|
-
return {
|
|
467
|
-
description: options.description ?? `struct(${fieldDescriptions})`,
|
|
468
|
-
fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
|
|
469
|
-
maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
|
|
470
|
-
serialize: (struct2) => {
|
|
471
|
-
const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
|
|
472
|
-
return mergeBytes(fieldBytes);
|
|
473
|
-
},
|
|
474
|
-
deserialize: (bytes2, offset = 0) => {
|
|
475
|
-
const struct2 = {};
|
|
476
|
-
fields.forEach(([key, serializer]) => {
|
|
477
|
-
const [value, newOffset] = serializer.deserialize(bytes2, offset);
|
|
478
|
-
offset = newOffset;
|
|
479
|
-
struct2[key] = value;
|
|
480
|
-
});
|
|
481
|
-
return [struct2, offset];
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
|
|
486
79
|
// src/unsigned-transaction.ts
|
|
487
80
|
function getUnsignedTransaction(transaction) {
|
|
488
81
|
if ("signatures" in transaction) {
|
|
@@ -507,8 +100,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
507
100
|
) {
|
|
508
101
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
509
102
|
}
|
|
510
|
-
const
|
|
511
|
-
const numBytes =
|
|
103
|
+
const bytes = base58.serialize(putativeBlockhash);
|
|
104
|
+
const numBytes = bytes.byteLength;
|
|
512
105
|
if (numBytes !== 32) {
|
|
513
106
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
514
107
|
}
|
|
@@ -593,7 +186,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
593
186
|
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
594
187
|
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
595
188
|
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
596
|
-
instruction.accounts[2].address != null && instruction.accounts[2].role
|
|
189
|
+
instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
|
|
597
190
|
}
|
|
598
191
|
function isAdvanceNonceAccountInstructionData(data) {
|
|
599
192
|
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
@@ -601,21 +194,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
601
194
|
function isDurableNonceTransaction(transaction) {
|
|
602
195
|
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
603
196
|
}
|
|
197
|
+
function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
|
|
198
|
+
return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
|
|
199
|
+
}
|
|
604
200
|
function setTransactionLifetimeUsingDurableNonce({
|
|
605
201
|
nonce,
|
|
606
202
|
nonceAccountAddress,
|
|
607
203
|
nonceAuthorityAddress
|
|
608
204
|
}, transaction) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
205
|
+
let newInstructions;
|
|
206
|
+
const firstInstruction = transaction.instructions[0];
|
|
207
|
+
if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
208
|
+
if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
|
|
209
|
+
if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
|
|
210
|
+
return transaction;
|
|
211
|
+
} else {
|
|
212
|
+
newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
newInstructions = [
|
|
216
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
217
|
+
...transaction.instructions.slice(1)
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
newInstructions = [
|
|
222
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
223
|
+
...transaction.instructions
|
|
224
|
+
];
|
|
612
225
|
}
|
|
613
226
|
const out = {
|
|
614
227
|
...getUnsignedTransaction(transaction),
|
|
615
|
-
instructions:
|
|
616
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
617
|
-
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
618
|
-
],
|
|
228
|
+
instructions: newInstructions,
|
|
619
229
|
lifetimeConstraint: {
|
|
620
230
|
nonce
|
|
621
231
|
}
|
|
@@ -656,18 +266,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
656
266
|
}
|
|
657
267
|
|
|
658
268
|
// ../codecs-core/dist/index.browser.js
|
|
659
|
-
function assertByteArrayIsNotEmptyForCodec(codecDescription,
|
|
660
|
-
if (
|
|
269
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
270
|
+
if (bytes.length - offset <= 0) {
|
|
661
271
|
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
662
272
|
}
|
|
663
273
|
}
|
|
664
|
-
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected,
|
|
665
|
-
const bytesLength =
|
|
274
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
|
|
275
|
+
const bytesLength = bytes.length - offset;
|
|
666
276
|
if (bytesLength < expected) {
|
|
667
277
|
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
668
278
|
}
|
|
669
279
|
}
|
|
670
|
-
var
|
|
280
|
+
var mergeBytes = (byteArrays) => {
|
|
671
281
|
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
672
282
|
if (nonEmptyByteArrays.length === 0) {
|
|
673
283
|
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
@@ -684,14 +294,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
684
294
|
});
|
|
685
295
|
return result;
|
|
686
296
|
};
|
|
687
|
-
var
|
|
688
|
-
if (
|
|
689
|
-
return
|
|
297
|
+
var padBytes = (bytes, length) => {
|
|
298
|
+
if (bytes.length >= length)
|
|
299
|
+
return bytes;
|
|
690
300
|
const paddedBytes = new Uint8Array(length).fill(0);
|
|
691
|
-
paddedBytes.set(
|
|
301
|
+
paddedBytes.set(bytes);
|
|
692
302
|
return paddedBytes;
|
|
693
303
|
};
|
|
694
|
-
var
|
|
304
|
+
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
695
305
|
function combineCodec(encoder, decoder, description) {
|
|
696
306
|
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
697
307
|
throw new Error(
|
|
@@ -726,21 +336,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
726
336
|
function fixEncoder(encoder, fixedBytes, description) {
|
|
727
337
|
return {
|
|
728
338
|
...fixCodecHelper(encoder, fixedBytes, description),
|
|
729
|
-
encode: (value) =>
|
|
339
|
+
encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
|
|
730
340
|
};
|
|
731
341
|
}
|
|
732
342
|
function fixDecoder(decoder, fixedBytes, description) {
|
|
733
343
|
return {
|
|
734
344
|
...fixCodecHelper(decoder, fixedBytes, description),
|
|
735
|
-
decode: (
|
|
736
|
-
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes,
|
|
737
|
-
if (offset > 0 ||
|
|
738
|
-
|
|
345
|
+
decode: (bytes, offset = 0) => {
|
|
346
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
347
|
+
if (offset > 0 || bytes.length > fixedBytes) {
|
|
348
|
+
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
739
349
|
}
|
|
740
350
|
if (decoder.fixedSize !== null) {
|
|
741
|
-
|
|
351
|
+
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
742
352
|
}
|
|
743
|
-
const [value] = decoder.decode(
|
|
353
|
+
const [value] = decoder.decode(bytes, 0);
|
|
744
354
|
return [value, offset + fixedBytes];
|
|
745
355
|
}
|
|
746
356
|
};
|
|
@@ -755,9 +365,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
755
365
|
}
|
|
756
366
|
function mapDecoder(decoder, map) {
|
|
757
367
|
return {
|
|
758
|
-
decode: (
|
|
759
|
-
const [value, length] = decoder.decode(
|
|
760
|
-
return [map(value,
|
|
368
|
+
decode: (bytes, offset = 0) => {
|
|
369
|
+
const [value, length] = decoder.decode(bytes, offset);
|
|
370
|
+
return [map(value, bytes, offset), length];
|
|
761
371
|
},
|
|
762
372
|
description: decoder.description,
|
|
763
373
|
fixedSize: decoder.fixedSize,
|
|
@@ -806,10 +416,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
806
416
|
function numberDecoderFactory(input) {
|
|
807
417
|
const codecData = sharedNumberFactory(input);
|
|
808
418
|
return {
|
|
809
|
-
decode(
|
|
810
|
-
assertByteArrayIsNotEmptyForCodec(codecData.description,
|
|
811
|
-
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size,
|
|
812
|
-
const view = new DataView(
|
|
419
|
+
decode(bytes, offset = 0) {
|
|
420
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
|
|
421
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
|
|
422
|
+
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
813
423
|
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
814
424
|
},
|
|
815
425
|
description: codecData.description,
|
|
@@ -817,39 +427,39 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
817
427
|
maxSize: codecData.maxSize
|
|
818
428
|
};
|
|
819
429
|
}
|
|
820
|
-
function
|
|
821
|
-
const bytesOffset =
|
|
822
|
-
const bytesLength = length ??
|
|
823
|
-
return
|
|
430
|
+
function toArrayBuffer(bytes, offset, length) {
|
|
431
|
+
const bytesOffset = bytes.byteOffset + (offset ?? 0);
|
|
432
|
+
const bytesLength = length ?? bytes.byteLength;
|
|
433
|
+
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
824
434
|
}
|
|
825
435
|
var getShortU16Encoder = (options = {}) => ({
|
|
826
436
|
description: options.description ?? "shortU16",
|
|
827
437
|
encode: (value) => {
|
|
828
438
|
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
829
|
-
const
|
|
439
|
+
const bytes = [0];
|
|
830
440
|
for (let ii = 0; ; ii += 1) {
|
|
831
441
|
const alignedValue = value >> ii * 7;
|
|
832
442
|
if (alignedValue === 0) {
|
|
833
443
|
break;
|
|
834
444
|
}
|
|
835
445
|
const nextSevenBits = 127 & alignedValue;
|
|
836
|
-
|
|
446
|
+
bytes[ii] = nextSevenBits;
|
|
837
447
|
if (ii > 0) {
|
|
838
|
-
|
|
448
|
+
bytes[ii - 1] |= 128;
|
|
839
449
|
}
|
|
840
450
|
}
|
|
841
|
-
return new Uint8Array(
|
|
451
|
+
return new Uint8Array(bytes);
|
|
842
452
|
},
|
|
843
453
|
fixedSize: null,
|
|
844
454
|
maxSize: 3
|
|
845
455
|
});
|
|
846
456
|
var getShortU16Decoder = (options = {}) => ({
|
|
847
|
-
decode: (
|
|
457
|
+
decode: (bytes, offset = 0) => {
|
|
848
458
|
let value = 0;
|
|
849
459
|
let byteCount = 0;
|
|
850
460
|
while (++byteCount) {
|
|
851
461
|
const byteIndex = byteCount - 1;
|
|
852
|
-
const currentByte =
|
|
462
|
+
const currentByte = bytes[offset + byteIndex];
|
|
853
463
|
const nextSevenBits = 127 & currentByte;
|
|
854
464
|
value |= nextSevenBits << byteIndex * 7;
|
|
855
465
|
if ((currentByte & 128) === 0) {
|
|
@@ -888,7 +498,184 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
888
498
|
options,
|
|
889
499
|
size: 1
|
|
890
500
|
});
|
|
891
|
-
|
|
501
|
+
|
|
502
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
503
|
+
function sumCodecSizes(sizes) {
|
|
504
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
505
|
+
}
|
|
506
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
507
|
+
if (typeof size === "number") {
|
|
508
|
+
return [size, offset];
|
|
509
|
+
}
|
|
510
|
+
if (typeof size === "object") {
|
|
511
|
+
return size.decode(bytes, offset);
|
|
512
|
+
}
|
|
513
|
+
if (size === "remainder") {
|
|
514
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
515
|
+
if (childrenSize === null) {
|
|
516
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
517
|
+
}
|
|
518
|
+
const remainder = bytes.slice(offset).length;
|
|
519
|
+
if (remainder % childrenSize !== 0) {
|
|
520
|
+
throw new Error(
|
|
521
|
+
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
return [remainder / childrenSize, offset];
|
|
525
|
+
}
|
|
526
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
527
|
+
}
|
|
528
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
529
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
530
|
+
}
|
|
531
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
532
|
+
if (typeof size !== "number")
|
|
533
|
+
return null;
|
|
534
|
+
if (size === 0)
|
|
535
|
+
return 0;
|
|
536
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
537
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
538
|
+
}
|
|
539
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
540
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
541
|
+
}
|
|
542
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
543
|
+
if (expected !== actual) {
|
|
544
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
function arrayCodecHelper(item, size, description) {
|
|
548
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
549
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
553
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
554
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function getArrayEncoder(item, options = {}) {
|
|
558
|
+
const size = options.size ?? getU32Encoder();
|
|
559
|
+
return {
|
|
560
|
+
...arrayCodecHelper(item, size, options.description),
|
|
561
|
+
encode: (value) => {
|
|
562
|
+
if (typeof size === "number") {
|
|
563
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
564
|
+
}
|
|
565
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function getArrayDecoder(item, options = {}) {
|
|
570
|
+
const size = options.size ?? getU32Decoder();
|
|
571
|
+
return {
|
|
572
|
+
...arrayCodecHelper(item, size, options.description),
|
|
573
|
+
decode: (bytes, offset = 0) => {
|
|
574
|
+
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
575
|
+
return [[], offset];
|
|
576
|
+
}
|
|
577
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
|
|
578
|
+
offset = newOffset;
|
|
579
|
+
const values = [];
|
|
580
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
581
|
+
const [value, newOffset2] = item.decode(bytes, offset);
|
|
582
|
+
values.push(value);
|
|
583
|
+
offset = newOffset2;
|
|
584
|
+
}
|
|
585
|
+
return [values, offset];
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
function getBytesEncoder(options = {}) {
|
|
590
|
+
const size = options.size ?? "variable";
|
|
591
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
592
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
593
|
+
const byteEncoder = {
|
|
594
|
+
description,
|
|
595
|
+
encode: (value) => value,
|
|
596
|
+
fixedSize: null,
|
|
597
|
+
maxSize: null
|
|
598
|
+
};
|
|
599
|
+
if (size === "variable") {
|
|
600
|
+
return byteEncoder;
|
|
601
|
+
}
|
|
602
|
+
if (typeof size === "number") {
|
|
603
|
+
return fixEncoder(byteEncoder, size, description);
|
|
604
|
+
}
|
|
605
|
+
return {
|
|
606
|
+
...byteEncoder,
|
|
607
|
+
encode: (value) => {
|
|
608
|
+
const contentBytes = byteEncoder.encode(value);
|
|
609
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
610
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function getBytesDecoder(options = {}) {
|
|
615
|
+
const size = options.size ?? "variable";
|
|
616
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
617
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
618
|
+
const byteDecoder = {
|
|
619
|
+
decode: (bytes, offset = 0) => {
|
|
620
|
+
const slice = bytes.slice(offset);
|
|
621
|
+
return [slice, offset + slice.length];
|
|
622
|
+
},
|
|
623
|
+
description,
|
|
624
|
+
fixedSize: null,
|
|
625
|
+
maxSize: null
|
|
626
|
+
};
|
|
627
|
+
if (size === "variable") {
|
|
628
|
+
return byteDecoder;
|
|
629
|
+
}
|
|
630
|
+
if (typeof size === "number") {
|
|
631
|
+
return fixDecoder(byteDecoder, size, description);
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
...byteDecoder,
|
|
635
|
+
decode: (bytes, offset = 0) => {
|
|
636
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
637
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
638
|
+
const length = Number(lengthBigInt);
|
|
639
|
+
offset = lengthOffset;
|
|
640
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
641
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
642
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
643
|
+
offset += contentOffset;
|
|
644
|
+
return [value, offset];
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function structCodecHelper(fields, description) {
|
|
649
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
650
|
+
return {
|
|
651
|
+
description: description ?? `struct(${fieldDescriptions})`,
|
|
652
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
653
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function getStructEncoder(fields, options = {}) {
|
|
657
|
+
return {
|
|
658
|
+
...structCodecHelper(fields, options.description),
|
|
659
|
+
encode: (struct) => {
|
|
660
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
661
|
+
return mergeBytes(fieldBytes);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function getStructDecoder(fields, options = {}) {
|
|
666
|
+
return {
|
|
667
|
+
...structCodecHelper(fields, options.description),
|
|
668
|
+
decode: (bytes, offset = 0) => {
|
|
669
|
+
const struct = {};
|
|
670
|
+
fields.forEach(([key, codec]) => {
|
|
671
|
+
const [value, newOffset] = codec.decode(bytes, offset);
|
|
672
|
+
offset = newOffset;
|
|
673
|
+
struct[key] = value;
|
|
674
|
+
});
|
|
675
|
+
return [struct, offset];
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}
|
|
892
679
|
|
|
893
680
|
// ../codecs-strings/dist/index.browser.js
|
|
894
681
|
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
@@ -934,15 +721,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
934
721
|
const baseBigInt = BigInt(base);
|
|
935
722
|
return {
|
|
936
723
|
decode(rawBytes, offset = 0) {
|
|
937
|
-
const
|
|
938
|
-
if (
|
|
724
|
+
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
725
|
+
if (bytes.length === 0)
|
|
939
726
|
return ["", 0];
|
|
940
|
-
let trailIndex =
|
|
941
|
-
trailIndex = trailIndex === -1 ?
|
|
727
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
728
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
942
729
|
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
943
|
-
if (trailIndex ===
|
|
730
|
+
if (trailIndex === bytes.length)
|
|
944
731
|
return [leadingZeroes, rawBytes.length];
|
|
945
|
-
let base10Number =
|
|
732
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
946
733
|
const tailChars = [];
|
|
947
734
|
while (base10Number > 0n) {
|
|
948
735
|
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
@@ -958,7 +745,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
958
745
|
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
959
746
|
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
960
747
|
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
961
|
-
var
|
|
748
|
+
var removeNullCharacters = (value) => (
|
|
962
749
|
// eslint-disable-next-line no-control-regex
|
|
963
750
|
value.replace(/\u0000/g, "")
|
|
964
751
|
);
|
|
@@ -976,9 +763,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
976
763
|
var getUtf8Decoder = () => {
|
|
977
764
|
let textDecoder;
|
|
978
765
|
return {
|
|
979
|
-
decode(
|
|
980
|
-
const value = (textDecoder || (textDecoder = new e())).decode(
|
|
981
|
-
return [
|
|
766
|
+
decode(bytes, offset = 0) {
|
|
767
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
768
|
+
return [removeNullCharacters(value), bytes.length];
|
|
982
769
|
},
|
|
983
770
|
description: "utf8",
|
|
984
771
|
fixedSize: null,
|
|
@@ -988,7 +775,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
988
775
|
var getStringEncoder = (options = {}) => {
|
|
989
776
|
const size = options.size ?? getU32Encoder();
|
|
990
777
|
const encoding = options.encoding ?? getUtf8Encoder();
|
|
991
|
-
const description = options.description ?? `string(${encoding.description}; ${
|
|
778
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
992
779
|
if (size === "variable") {
|
|
993
780
|
return { ...encoding, description };
|
|
994
781
|
}
|
|
@@ -1000,7 +787,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1000
787
|
encode: (value) => {
|
|
1001
788
|
const contentBytes = encoding.encode(value);
|
|
1002
789
|
const lengthBytes = size.encode(contentBytes.length);
|
|
1003
|
-
return
|
|
790
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
1004
791
|
},
|
|
1005
792
|
fixedSize: null,
|
|
1006
793
|
maxSize: null
|
|
@@ -1009,7 +796,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1009
796
|
var getStringDecoder = (options = {}) => {
|
|
1010
797
|
const size = options.size ?? getU32Decoder();
|
|
1011
798
|
const encoding = options.encoding ?? getUtf8Decoder();
|
|
1012
|
-
const description = options.description ?? `string(${encoding.description}; ${
|
|
799
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
1013
800
|
if (size === "variable") {
|
|
1014
801
|
return { ...encoding, description };
|
|
1015
802
|
}
|
|
@@ -1017,12 +804,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1017
804
|
return fixDecoder(encoding, size, description);
|
|
1018
805
|
}
|
|
1019
806
|
return {
|
|
1020
|
-
decode: (
|
|
1021
|
-
assertByteArrayIsNotEmptyForCodec("string",
|
|
1022
|
-
const [lengthBigInt, lengthOffset] = size.decode(
|
|
807
|
+
decode: (bytes, offset = 0) => {
|
|
808
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
809
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
1023
810
|
const length = Number(lengthBigInt);
|
|
1024
811
|
offset = lengthOffset;
|
|
1025
|
-
const contentBytes =
|
|
812
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
1026
813
|
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
1027
814
|
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
1028
815
|
offset += contentOffset;
|
|
@@ -1033,7 +820,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1033
820
|
maxSize: null
|
|
1034
821
|
};
|
|
1035
822
|
};
|
|
1036
|
-
function
|
|
823
|
+
function getSizeDescription(size) {
|
|
1037
824
|
return typeof size === "object" ? size.description : `${size}`;
|
|
1038
825
|
}
|
|
1039
826
|
|
|
@@ -1081,8 +868,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1081
868
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1082
869
|
}
|
|
1083
870
|
const base58Encoder = getMemoizedBase58Encoder();
|
|
1084
|
-
const
|
|
1085
|
-
const numBytes =
|
|
871
|
+
const bytes = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
872
|
+
const numBytes = bytes.byteLength;
|
|
1086
873
|
if (numBytes !== 32) {
|
|
1087
874
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1088
875
|
}
|
|
@@ -1113,9 +900,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1113
900
|
size: 32
|
|
1114
901
|
});
|
|
1115
902
|
}
|
|
1116
|
-
function getAddressCodec(config) {
|
|
1117
|
-
return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
|
|
1118
|
-
}
|
|
1119
903
|
function getAddressComparator() {
|
|
1120
904
|
return new Intl.Collator("en", {
|
|
1121
905
|
caseFirst: "lower",
|
|
@@ -1424,185 +1208,121 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1424
1208
|
};
|
|
1425
1209
|
}
|
|
1426
1210
|
|
|
1427
|
-
// ../
|
|
1428
|
-
function
|
|
1429
|
-
return
|
|
1211
|
+
// ../functional/dist/index.browser.js
|
|
1212
|
+
function pipe(init, ...fns) {
|
|
1213
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1430
1214
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1215
|
+
|
|
1216
|
+
// src/decompile-transaction.ts
|
|
1217
|
+
function getAccountMetas(message) {
|
|
1218
|
+
const { header } = message;
|
|
1219
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
1220
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
1221
|
+
const accountMetas = [];
|
|
1222
|
+
let accountIndex = 0;
|
|
1223
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
1224
|
+
accountMetas.push({
|
|
1225
|
+
address: message.staticAccounts[accountIndex],
|
|
1226
|
+
role: AccountRole.WRITABLE_SIGNER
|
|
1227
|
+
});
|
|
1228
|
+
accountIndex++;
|
|
1437
1229
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
if (remainder % childrenSize !== 0) {
|
|
1445
|
-
throw new Error(
|
|
1446
|
-
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
|
|
1447
|
-
);
|
|
1448
|
-
}
|
|
1449
|
-
return [remainder / childrenSize, offset];
|
|
1230
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
1231
|
+
accountMetas.push({
|
|
1232
|
+
address: message.staticAccounts[accountIndex],
|
|
1233
|
+
role: AccountRole.READONLY_SIGNER
|
|
1234
|
+
});
|
|
1235
|
+
accountIndex++;
|
|
1450
1236
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
if (typeof size !== "number")
|
|
1458
|
-
return null;
|
|
1459
|
-
if (size === 0)
|
|
1460
|
-
return 0;
|
|
1461
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1462
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
1463
|
-
}
|
|
1464
|
-
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
1465
|
-
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
1466
|
-
}
|
|
1467
|
-
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1468
|
-
if (expected !== actual) {
|
|
1469
|
-
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1237
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
1238
|
+
accountMetas.push({
|
|
1239
|
+
address: message.staticAccounts[accountIndex],
|
|
1240
|
+
role: AccountRole.WRITABLE
|
|
1241
|
+
});
|
|
1242
|
+
accountIndex++;
|
|
1470
1243
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1244
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
1245
|
+
accountMetas.push({
|
|
1246
|
+
address: message.staticAccounts[accountIndex],
|
|
1247
|
+
role: AccountRole.READONLY
|
|
1248
|
+
});
|
|
1249
|
+
accountIndex++;
|
|
1475
1250
|
}
|
|
1476
|
-
return
|
|
1477
|
-
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1478
|
-
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1479
|
-
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1480
|
-
};
|
|
1481
|
-
}
|
|
1482
|
-
function getArrayEncoder(item, options = {}) {
|
|
1483
|
-
const size = options.size ?? getU32Encoder();
|
|
1484
|
-
return {
|
|
1485
|
-
...arrayCodecHelper(item, size, options.description),
|
|
1486
|
-
encode: (value) => {
|
|
1487
|
-
if (typeof size === "number") {
|
|
1488
|
-
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
1489
|
-
}
|
|
1490
|
-
return mergeBytes2([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
1491
|
-
}
|
|
1492
|
-
};
|
|
1493
|
-
}
|
|
1494
|
-
function getArrayDecoder(item, options = {}) {
|
|
1495
|
-
const size = options.size ?? getU32Decoder();
|
|
1496
|
-
return {
|
|
1497
|
-
...arrayCodecHelper(item, size, options.description),
|
|
1498
|
-
decode: (bytes2, offset = 0) => {
|
|
1499
|
-
if (typeof size === "object" && bytes2.slice(offset).length === 0) {
|
|
1500
|
-
return [[], offset];
|
|
1501
|
-
}
|
|
1502
|
-
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes2, offset);
|
|
1503
|
-
offset = newOffset;
|
|
1504
|
-
const values = [];
|
|
1505
|
-
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1506
|
-
const [value, newOffset2] = item.decode(bytes2, offset);
|
|
1507
|
-
values.push(value);
|
|
1508
|
-
offset = newOffset2;
|
|
1509
|
-
}
|
|
1510
|
-
return [values, offset];
|
|
1511
|
-
}
|
|
1512
|
-
};
|
|
1251
|
+
return accountMetas;
|
|
1513
1252
|
}
|
|
1514
|
-
function
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
const byteEncoder = {
|
|
1519
|
-
description,
|
|
1520
|
-
encode: (value) => value,
|
|
1521
|
-
fixedSize: null,
|
|
1522
|
-
maxSize: null
|
|
1523
|
-
};
|
|
1524
|
-
if (size === "variable") {
|
|
1525
|
-
return byteEncoder;
|
|
1526
|
-
}
|
|
1527
|
-
if (typeof size === "number") {
|
|
1528
|
-
return fixEncoder(byteEncoder, size, description);
|
|
1253
|
+
function convertInstruction(instruction, accountMetas) {
|
|
1254
|
+
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
1255
|
+
if (!programAddress) {
|
|
1256
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
1529
1257
|
}
|
|
1258
|
+
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
1259
|
+
const { data } = instruction;
|
|
1530
1260
|
return {
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
const lengthBytes = size.encode(contentBytes.length);
|
|
1535
|
-
return mergeBytes2([lengthBytes, contentBytes]);
|
|
1536
|
-
}
|
|
1261
|
+
programAddress,
|
|
1262
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
1263
|
+
...data && data.length ? { data } : {}
|
|
1537
1264
|
};
|
|
1538
1265
|
}
|
|
1539
|
-
function
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
return fixDecoder(byteDecoder, size, description);
|
|
1266
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
1267
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1268
|
+
return {
|
|
1269
|
+
blockhash: messageLifetimeToken,
|
|
1270
|
+
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
1271
|
+
// U64 MAX
|
|
1272
|
+
};
|
|
1273
|
+
} else {
|
|
1274
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
1275
|
+
assertIsAddress(nonceAccountAddress);
|
|
1276
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
1277
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
1278
|
+
return {
|
|
1279
|
+
nonce: messageLifetimeToken,
|
|
1280
|
+
nonceAccountAddress,
|
|
1281
|
+
nonceAuthorityAddress
|
|
1282
|
+
};
|
|
1557
1283
|
}
|
|
1558
|
-
return {
|
|
1559
|
-
...byteDecoder,
|
|
1560
|
-
decode: (bytes2, offset = 0) => {
|
|
1561
|
-
assertByteArrayIsNotEmptyForCodec("bytes", bytes2, offset);
|
|
1562
|
-
const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
|
|
1563
|
-
const length = Number(lengthBigInt);
|
|
1564
|
-
offset = lengthOffset;
|
|
1565
|
-
const contentBytes = bytes2.slice(offset, offset + length);
|
|
1566
|
-
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1567
|
-
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
1568
|
-
offset += contentOffset;
|
|
1569
|
-
return [value, offset];
|
|
1570
|
-
}
|
|
1571
|
-
};
|
|
1572
|
-
}
|
|
1573
|
-
function structCodecHelper(fields, description) {
|
|
1574
|
-
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
1575
|
-
return {
|
|
1576
|
-
description: description ?? `struct(${fieldDescriptions})`,
|
|
1577
|
-
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
1578
|
-
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1579
|
-
};
|
|
1580
|
-
}
|
|
1581
|
-
function getStructEncoder(fields, options = {}) {
|
|
1582
|
-
return {
|
|
1583
|
-
...structCodecHelper(fields, options.description),
|
|
1584
|
-
encode: (struct2) => {
|
|
1585
|
-
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
|
|
1586
|
-
return mergeBytes2(fieldBytes);
|
|
1587
|
-
}
|
|
1588
|
-
};
|
|
1589
|
-
}
|
|
1590
|
-
function getStructDecoder(fields, options = {}) {
|
|
1591
|
-
return {
|
|
1592
|
-
...structCodecHelper(fields, options.description),
|
|
1593
|
-
decode: (bytes2, offset = 0) => {
|
|
1594
|
-
const struct2 = {};
|
|
1595
|
-
fields.forEach(([key, codec]) => {
|
|
1596
|
-
const [value, newOffset] = codec.decode(bytes2, offset);
|
|
1597
|
-
offset = newOffset;
|
|
1598
|
-
struct2[key] = value;
|
|
1599
|
-
});
|
|
1600
|
-
return [struct2, offset];
|
|
1601
|
-
}
|
|
1602
|
-
};
|
|
1603
1284
|
}
|
|
1604
|
-
function
|
|
1605
|
-
|
|
1285
|
+
function convertSignatures(compiledTransaction) {
|
|
1286
|
+
const {
|
|
1287
|
+
compiledMessage: { staticAccounts },
|
|
1288
|
+
signatures
|
|
1289
|
+
} = compiledTransaction;
|
|
1290
|
+
return signatures.reduce((acc, sig, index) => {
|
|
1291
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
1292
|
+
if (allZeros)
|
|
1293
|
+
return acc;
|
|
1294
|
+
const address2 = staticAccounts[index];
|
|
1295
|
+
return { ...acc, [address2]: sig };
|
|
1296
|
+
}, {});
|
|
1297
|
+
}
|
|
1298
|
+
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
1299
|
+
const { compiledMessage } = compiledTransaction;
|
|
1300
|
+
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
1301
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
1302
|
+
}
|
|
1303
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
1304
|
+
if (!feePayer)
|
|
1305
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
1306
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
1307
|
+
const instructions = compiledMessage.instructions.map(
|
|
1308
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
1309
|
+
);
|
|
1310
|
+
const firstInstruction = instructions[0];
|
|
1311
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
1312
|
+
compiledMessage.lifetimeToken,
|
|
1313
|
+
firstInstruction,
|
|
1314
|
+
lastValidBlockHeight
|
|
1315
|
+
);
|
|
1316
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
1317
|
+
return pipe(
|
|
1318
|
+
createTransaction({ version: compiledMessage.version }),
|
|
1319
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
1320
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
1321
|
+
return appendTransactionInstruction(instruction, acc);
|
|
1322
|
+
}, tx),
|
|
1323
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
1324
|
+
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
1325
|
+
);
|
|
1606
1326
|
}
|
|
1607
1327
|
|
|
1608
1328
|
// src/serializers/address-table-lookup.ts
|
|
@@ -1662,34 +1382,56 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1662
1382
|
}
|
|
1663
1383
|
return memoizedAddressTableLookupDecoder;
|
|
1664
1384
|
}
|
|
1665
|
-
function getAddressTableLookupCodec() {
|
|
1666
|
-
return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
|
|
1667
|
-
}
|
|
1668
1385
|
|
|
1669
1386
|
// src/serializers/header.ts
|
|
1670
|
-
var
|
|
1671
|
-
function
|
|
1672
|
-
if (!
|
|
1673
|
-
|
|
1674
|
-
return
|
|
1675
|
-
}
|
|
1676
|
-
function
|
|
1677
|
-
const
|
|
1387
|
+
var memoizedU8Encoder;
|
|
1388
|
+
function getMemoizedU8Encoder() {
|
|
1389
|
+
if (!memoizedU8Encoder)
|
|
1390
|
+
memoizedU8Encoder = getU8Encoder();
|
|
1391
|
+
return memoizedU8Encoder;
|
|
1392
|
+
}
|
|
1393
|
+
function getMemoizedU8EncoderDescription(description) {
|
|
1394
|
+
const encoder = getMemoizedU8Encoder();
|
|
1395
|
+
return {
|
|
1396
|
+
...encoder,
|
|
1397
|
+
description: description ?? encoder.description
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
var memoizedU8Decoder;
|
|
1401
|
+
function getMemoizedU8Decoder() {
|
|
1402
|
+
if (!memoizedU8Decoder)
|
|
1403
|
+
memoizedU8Decoder = getU8Decoder();
|
|
1404
|
+
return memoizedU8Decoder;
|
|
1405
|
+
}
|
|
1406
|
+
function getMemoizedU8DecoderDescription(description) {
|
|
1407
|
+
const decoder = getMemoizedU8Decoder();
|
|
1678
1408
|
return {
|
|
1679
|
-
...
|
|
1680
|
-
description: description ??
|
|
1409
|
+
...decoder,
|
|
1410
|
+
description: description ?? decoder.description
|
|
1681
1411
|
};
|
|
1682
1412
|
}
|
|
1683
1413
|
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
1684
1414
|
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" ;
|
|
1685
1415
|
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
1686
1416
|
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1687
|
-
function
|
|
1688
|
-
return
|
|
1417
|
+
function getMessageHeaderEncoder() {
|
|
1418
|
+
return getStructEncoder(
|
|
1419
|
+
[
|
|
1420
|
+
["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
|
|
1421
|
+
["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
|
|
1422
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1423
|
+
],
|
|
1424
|
+
{
|
|
1425
|
+
description: messageHeaderDescription
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
function getMessageHeaderDecoder() {
|
|
1430
|
+
return getStructDecoder(
|
|
1689
1431
|
[
|
|
1690
|
-
["numSignerAccounts",
|
|
1691
|
-
["numReadonlySignerAccounts",
|
|
1692
|
-
["numReadonlyNonSignerAccounts",
|
|
1432
|
+
["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
|
|
1433
|
+
["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
|
|
1434
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1693
1435
|
],
|
|
1694
1436
|
{
|
|
1695
1437
|
description: messageHeaderDescription
|
|
@@ -1763,9 +1505,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1763
1505
|
}
|
|
1764
1506
|
return memoizedGetInstructionDecoder;
|
|
1765
1507
|
}
|
|
1766
|
-
function getInstructionCodec() {
|
|
1767
|
-
return combineCodec(getInstructionEncoder(), getInstructionDecoder());
|
|
1768
|
-
}
|
|
1769
1508
|
|
|
1770
1509
|
// src/serializers/transaction-version.ts
|
|
1771
1510
|
var VERSION_FLAG_MASK = 128;
|
|
@@ -1774,8 +1513,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1774
1513
|
fixedSize: null,
|
|
1775
1514
|
maxSize: 1
|
|
1776
1515
|
};
|
|
1777
|
-
function decode(
|
|
1778
|
-
const firstByte =
|
|
1516
|
+
function decode(bytes, offset = 0) {
|
|
1517
|
+
const firstByte = bytes[offset];
|
|
1779
1518
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1780
1519
|
return ["legacy", offset];
|
|
1781
1520
|
} else {
|
|
@@ -1804,126 +1543,181 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1804
1543
|
encode
|
|
1805
1544
|
};
|
|
1806
1545
|
}
|
|
1807
|
-
function getTransactionVersionCodec() {
|
|
1808
|
-
return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
// src/serializers/unimplemented.ts
|
|
1812
|
-
function getError(type, name) {
|
|
1813
|
-
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
1814
|
-
return new Error(
|
|
1815
|
-
`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}`
|
|
1816
|
-
);
|
|
1817
|
-
}
|
|
1818
|
-
function getUnimplementedDecoder(name) {
|
|
1819
|
-
return () => {
|
|
1820
|
-
throw getError("decoder", name);
|
|
1821
|
-
};
|
|
1822
|
-
}
|
|
1823
1546
|
|
|
1824
1547
|
// src/serializers/message.ts
|
|
1825
|
-
var
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
(value)
|
|
1840
|
-
|
|
1841
|
-
return value;
|
|
1842
|
-
}
|
|
1843
|
-
return {
|
|
1844
|
-
...value,
|
|
1845
|
-
addressTableLookups: value.addressTableLookups ?? []
|
|
1846
|
-
};
|
|
1548
|
+
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
|
|
1549
|
+
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
|
|
1550
|
+
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
|
|
1551
|
+
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
|
|
1552
|
+
function getCompiledMessageLegacyEncoder() {
|
|
1553
|
+
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
1554
|
+
}
|
|
1555
|
+
function getCompiledMessageVersionedEncoder() {
|
|
1556
|
+
return mapEncoder(
|
|
1557
|
+
getStructEncoder([
|
|
1558
|
+
...getPreludeStructEncoderTuple(),
|
|
1559
|
+
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1560
|
+
]),
|
|
1561
|
+
(value) => {
|
|
1562
|
+
if (value.version === "legacy") {
|
|
1563
|
+
return value;
|
|
1847
1564
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
deserialize: codec.decode,
|
|
1855
|
-
fixedSize: codec.fixedSize,
|
|
1856
|
-
maxSize: codec.maxSize,
|
|
1857
|
-
serialize: codec.encode
|
|
1858
|
-
};
|
|
1565
|
+
return {
|
|
1566
|
+
...value,
|
|
1567
|
+
addressTableLookups: value.addressTableLookups ?? []
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
);
|
|
1859
1571
|
}
|
|
1860
|
-
function
|
|
1572
|
+
function getPreludeStructEncoderTuple() {
|
|
1861
1573
|
return [
|
|
1862
|
-
["version",
|
|
1863
|
-
["header",
|
|
1574
|
+
["version", getTransactionVersionEncoder()],
|
|
1575
|
+
["header", getMessageHeaderEncoder()],
|
|
1864
1576
|
[
|
|
1865
1577
|
"staticAccounts",
|
|
1866
|
-
|
|
1867
|
-
description:
|
|
1868
|
-
size:
|
|
1578
|
+
getArrayEncoder(getAddressEncoder(), {
|
|
1579
|
+
description: staticAccountsDescription,
|
|
1580
|
+
size: getShortU16Encoder()
|
|
1869
1581
|
})
|
|
1870
1582
|
],
|
|
1871
1583
|
[
|
|
1872
1584
|
"lifetimeToken",
|
|
1873
|
-
|
|
1874
|
-
description:
|
|
1875
|
-
encoding:
|
|
1585
|
+
getStringEncoder({
|
|
1586
|
+
description: lifetimeTokenDescription,
|
|
1587
|
+
encoding: getBase58Encoder(),
|
|
1876
1588
|
size: 32
|
|
1877
1589
|
})
|
|
1878
1590
|
],
|
|
1879
1591
|
[
|
|
1880
1592
|
"instructions",
|
|
1881
|
-
|
|
1882
|
-
description:
|
|
1883
|
-
size:
|
|
1593
|
+
getArrayEncoder(getInstructionEncoder(), {
|
|
1594
|
+
description: instructionsDescription,
|
|
1595
|
+
size: getShortU16Encoder()
|
|
1884
1596
|
})
|
|
1885
1597
|
]
|
|
1886
1598
|
];
|
|
1887
1599
|
}
|
|
1888
|
-
function
|
|
1889
|
-
return
|
|
1890
|
-
|
|
1891
|
-
|
|
1600
|
+
function getPreludeStructDecoderTuple() {
|
|
1601
|
+
return [
|
|
1602
|
+
["version", getTransactionVersionDecoder()],
|
|
1603
|
+
["header", getMessageHeaderDecoder()],
|
|
1604
|
+
[
|
|
1605
|
+
"staticAccounts",
|
|
1606
|
+
getArrayDecoder(getAddressDecoder(), {
|
|
1607
|
+
description: staticAccountsDescription,
|
|
1608
|
+
size: getShortU16Decoder()
|
|
1609
|
+
})
|
|
1610
|
+
],
|
|
1611
|
+
[
|
|
1612
|
+
"lifetimeToken",
|
|
1613
|
+
getStringDecoder({
|
|
1614
|
+
description: lifetimeTokenDescription,
|
|
1615
|
+
encoding: getBase58Decoder(),
|
|
1616
|
+
size: 32
|
|
1617
|
+
})
|
|
1618
|
+
],
|
|
1619
|
+
[
|
|
1620
|
+
"instructions",
|
|
1621
|
+
getArrayDecoder(getInstructionDecoder(), {
|
|
1622
|
+
description: instructionsDescription,
|
|
1623
|
+
size: getShortU16Decoder()
|
|
1624
|
+
})
|
|
1625
|
+
],
|
|
1626
|
+
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
1627
|
+
];
|
|
1628
|
+
}
|
|
1629
|
+
function getAddressTableLookupArrayEncoder() {
|
|
1630
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
1631
|
+
description: addressTableLookupsDescription,
|
|
1632
|
+
size: getShortU16Encoder()
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1635
|
+
function getAddressTableLookupArrayDecoder() {
|
|
1636
|
+
return getArrayDecoder(getAddressTableLookupDecoder(), {
|
|
1637
|
+
description: addressTableLookupsDescription,
|
|
1638
|
+
size: getShortU16Decoder()
|
|
1892
1639
|
});
|
|
1893
1640
|
}
|
|
1641
|
+
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1894
1642
|
function getCompiledMessageEncoder() {
|
|
1895
1643
|
return {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1644
|
+
description: messageDescription,
|
|
1645
|
+
encode: (compiledMessage) => {
|
|
1646
|
+
if (compiledMessage.version === "legacy") {
|
|
1647
|
+
return getCompiledMessageLegacyEncoder().encode(compiledMessage);
|
|
1648
|
+
} else {
|
|
1649
|
+
return getCompiledMessageVersionedEncoder().encode(compiledMessage);
|
|
1650
|
+
}
|
|
1651
|
+
},
|
|
1652
|
+
fixedSize: null,
|
|
1653
|
+
maxSize: null
|
|
1899
1654
|
};
|
|
1900
1655
|
}
|
|
1656
|
+
function getCompiledMessageDecoder() {
|
|
1657
|
+
return mapDecoder(
|
|
1658
|
+
getStructDecoder(getPreludeStructDecoderTuple(), {
|
|
1659
|
+
description: messageDescription
|
|
1660
|
+
}),
|
|
1661
|
+
({ addressTableLookups, ...restOfMessage }) => {
|
|
1662
|
+
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
1663
|
+
return restOfMessage;
|
|
1664
|
+
}
|
|
1665
|
+
return { ...restOfMessage, addressTableLookups };
|
|
1666
|
+
}
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1901
1669
|
|
|
1902
1670
|
// src/serializers/transaction.ts
|
|
1903
|
-
var
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
};
|
|
1908
|
-
function serialize2(transaction) {
|
|
1909
|
-
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1910
|
-
return struct([
|
|
1671
|
+
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
1672
|
+
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
1673
|
+
function getCompiledTransactionEncoder() {
|
|
1674
|
+
return getStructEncoder(
|
|
1911
1675
|
[
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1676
|
+
[
|
|
1677
|
+
"signatures",
|
|
1678
|
+
getArrayEncoder(getBytesEncoder({ size: 64 }), {
|
|
1679
|
+
description: signaturesDescription,
|
|
1680
|
+
size: getShortU16Encoder()
|
|
1681
|
+
})
|
|
1682
|
+
],
|
|
1683
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
1684
|
+
],
|
|
1685
|
+
{
|
|
1686
|
+
description: transactionDescription
|
|
1687
|
+
}
|
|
1688
|
+
);
|
|
1689
|
+
}
|
|
1690
|
+
function getSignatureDecoder() {
|
|
1691
|
+
return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
|
|
1692
|
+
}
|
|
1693
|
+
function getCompiledTransactionDecoder() {
|
|
1694
|
+
return getStructDecoder(
|
|
1695
|
+
[
|
|
1696
|
+
[
|
|
1697
|
+
"signatures",
|
|
1698
|
+
getArrayDecoder(getSignatureDecoder(), {
|
|
1699
|
+
description: signaturesDescription,
|
|
1700
|
+
size: getShortU16Decoder()
|
|
1701
|
+
})
|
|
1702
|
+
],
|
|
1703
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
1917
1704
|
],
|
|
1918
|
-
|
|
1919
|
-
|
|
1705
|
+
{
|
|
1706
|
+
description: transactionDescription
|
|
1707
|
+
}
|
|
1708
|
+
);
|
|
1920
1709
|
}
|
|
1921
1710
|
function getTransactionEncoder() {
|
|
1922
|
-
return
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1711
|
+
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
1712
|
+
}
|
|
1713
|
+
function getTransactionDecoder(lastValidBlockHeight) {
|
|
1714
|
+
return mapDecoder(
|
|
1715
|
+
getCompiledTransactionDecoder(),
|
|
1716
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
function getTransactionCodec(lastValidBlockHeight) {
|
|
1720
|
+
return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
1927
1721
|
}
|
|
1928
1722
|
|
|
1929
1723
|
// ../keys/dist/index.browser.js
|
|
@@ -1943,8 +1737,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1943
1737
|
) {
|
|
1944
1738
|
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1945
1739
|
}
|
|
1946
|
-
const
|
|
1947
|
-
const numBytes =
|
|
1740
|
+
const bytes = base58.serialize(putativeTransactionSignature);
|
|
1741
|
+
const numBytes = bytes.byteLength;
|
|
1948
1742
|
if (numBytes !== 64) {
|
|
1949
1743
|
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1950
1744
|
}
|
|
@@ -1962,18 +1756,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1962
1756
|
) {
|
|
1963
1757
|
return false;
|
|
1964
1758
|
}
|
|
1965
|
-
const
|
|
1966
|
-
const numBytes =
|
|
1759
|
+
const bytes = base58.serialize(putativeTransactionSignature);
|
|
1760
|
+
const numBytes = bytes.byteLength;
|
|
1967
1761
|
if (numBytes !== 64) {
|
|
1968
1762
|
return false;
|
|
1969
1763
|
}
|
|
1970
1764
|
return true;
|
|
1971
1765
|
}
|
|
1972
|
-
async function getCompiledMessageSignature(message, secretKey) {
|
|
1973
|
-
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1974
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1975
|
-
return signature;
|
|
1976
|
-
}
|
|
1977
1766
|
function getSignatureFromTransaction(transaction) {
|
|
1978
1767
|
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
1979
1768
|
if (!signatureBytes) {
|
|
@@ -1987,12 +1776,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1987
1776
|
async function signTransaction(keyPairs, transaction) {
|
|
1988
1777
|
const compiledMessage = compileMessage(transaction);
|
|
1989
1778
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1779
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
1990
1780
|
const publicKeySignaturePairs = await Promise.all(
|
|
1991
1781
|
keyPairs.map(
|
|
1992
|
-
(keyPair) => Promise.all([
|
|
1993
|
-
getAddressFromPublicKey(keyPair.publicKey),
|
|
1994
|
-
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1995
|
-
])
|
|
1782
|
+
(keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
|
|
1996
1783
|
)
|
|
1997
1784
|
);
|
|
1998
1785
|
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
@@ -2009,10 +1796,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2009
1796
|
assertIsTransactionSignature(putativeTransactionSignature);
|
|
2010
1797
|
return putativeTransactionSignature;
|
|
2011
1798
|
}
|
|
1799
|
+
function assertTransactionIsFullySigned(transaction) {
|
|
1800
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);
|
|
1801
|
+
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
1802
|
+
requiredSigners.forEach((address2) => {
|
|
1803
|
+
if (!transaction.signatures[address2]) {
|
|
1804
|
+
throw new Error(`Transaction is missing signature for address \`${address2}\``);
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
2012
1808
|
|
|
2013
1809
|
// src/wire-transaction.ts
|
|
2014
1810
|
function getBase64EncodedWireTransaction(transaction) {
|
|
2015
|
-
const wireTransactionBytes = getTransactionEncoder().
|
|
1811
|
+
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
2016
1812
|
{
|
|
2017
1813
|
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
2018
1814
|
}
|
|
@@ -2022,9 +1818,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
2022
1818
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
2023
1819
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
2024
1820
|
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
1821
|
+
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
2025
1822
|
exports.createTransaction = createTransaction;
|
|
2026
1823
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
2027
1824
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1825
|
+
exports.getTransactionCodec = getTransactionCodec;
|
|
1826
|
+
exports.getTransactionDecoder = getTransactionDecoder;
|
|
2028
1827
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
2029
1828
|
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
2030
1829
|
exports.isTransactionSignature = isTransactionSignature;
|