@solana/transactions 2.0.0-experimental.5082935 → 2.0.0-experimental.5432cbe
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/dist/index.browser.cjs +216 -76
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +210 -73
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +291 -148
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +208 -73
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +216 -76
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +210 -73
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +11 -6
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/blockhash.d.ts +9 -1
- package/dist/types/compile-address-table-lookups.d.ts +1 -1
- package/dist/types/compile-instructions.d.ts +1 -1
- package/dist/types/compile-static-accounts.d.ts +1 -1
- package/dist/types/compile-transaction.d.ts +11 -0
- package/dist/types/durable-nonce.d.ts +19 -7
- package/dist/types/fee-payer.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/serializers/transaction.d.ts +6 -0
- package/dist/types/signatures.d.ts +5 -6
- package/dist/types/types.d.ts +7 -0
- package/dist/types/unsigned-transaction.d.ts +4 -0
- package/dist/types/wire-transaction.d.ts +6 -0
- package/package.json +16 -18
- package/dist/types/accounts.d.ts.map +0 -1
- package/dist/types/blockhash.d.ts.map +0 -1
- package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
- package/dist/types/compile-header.d.ts.map +0 -1
- package/dist/types/compile-instructions.d.ts.map +0 -1
- package/dist/types/compile-lifetime-token.d.ts.map +0 -1
- package/dist/types/compile-static-accounts.d.ts.map +0 -1
- package/dist/types/create-transaction.d.ts.map +0 -1
- package/dist/types/durable-nonce.d.ts.map +0 -1
- package/dist/types/fee-payer.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/instructions.d.ts.map +0 -1
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
- package/dist/types/serializers/header.d.ts.map +0 -1
- package/dist/types/serializers/instruction.d.ts.map +0 -1
- package/dist/types/serializers/message.d.ts.map +0 -1
- package/dist/types/serializers/transaction-version.d.ts.map +0 -1
- package/dist/types/serializers/unimplemented.d.ts.map +0 -1
- package/dist/types/signatures.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
|
@@ -9,79 +9,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
//
|
|
13
|
-
function createTransaction({
|
|
14
|
-
version
|
|
15
|
-
}) {
|
|
16
|
-
const out = {
|
|
17
|
-
instructions: [],
|
|
18
|
-
version
|
|
19
|
-
};
|
|
20
|
-
Object.freeze(out);
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// src/fee-payer.ts
|
|
25
|
-
function setTransactionFeePayer(feePayer, transaction) {
|
|
26
|
-
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
27
|
-
return transaction;
|
|
28
|
-
}
|
|
29
|
-
let out;
|
|
30
|
-
if ("signatures" in transaction) {
|
|
31
|
-
const {
|
|
32
|
-
signatures: _,
|
|
33
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
34
|
-
...unsignedTransaction
|
|
35
|
-
} = transaction;
|
|
36
|
-
out = {
|
|
37
|
-
...unsignedTransaction,
|
|
38
|
-
feePayer
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
out = {
|
|
42
|
-
...transaction,
|
|
43
|
-
feePayer
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
Object.freeze(out);
|
|
47
|
-
return out;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/instructions.ts
|
|
51
|
-
function replaceInstructions(transaction, nextInstructions) {
|
|
52
|
-
let out;
|
|
53
|
-
if ("signatures" in transaction) {
|
|
54
|
-
const {
|
|
55
|
-
signatures: _,
|
|
56
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
57
|
-
...unsignedTransaction
|
|
58
|
-
} = transaction;
|
|
59
|
-
out = {
|
|
60
|
-
...unsignedTransaction,
|
|
61
|
-
instructions: nextInstructions
|
|
62
|
-
};
|
|
63
|
-
} else {
|
|
64
|
-
out = {
|
|
65
|
-
...transaction,
|
|
66
|
-
instructions: nextInstructions
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return out;
|
|
70
|
-
}
|
|
71
|
-
function appendTransactionInstruction(instruction, transaction) {
|
|
72
|
-
const nextInstructions = [...transaction.instructions, instruction];
|
|
73
|
-
const out = replaceInstructions(transaction, nextInstructions);
|
|
74
|
-
Object.freeze(out);
|
|
75
|
-
return out;
|
|
76
|
-
}
|
|
77
|
-
function prependTransactionInstruction(instruction, transaction) {
|
|
78
|
-
const nextInstructions = [instruction, ...transaction.instructions];
|
|
79
|
-
const out = replaceInstructions(transaction, nextInstructions);
|
|
80
|
-
Object.freeze(out);
|
|
81
|
-
return out;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
12
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
85
13
|
var mergeBytes = (bytesArr) => {
|
|
86
14
|
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
87
15
|
const result = new Uint8Array(totalLength);
|
|
@@ -101,7 +29,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
101
29
|
};
|
|
102
30
|
var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
|
|
103
31
|
|
|
104
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
32
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
|
|
105
33
|
var DeserializingEmptyBufferError = class extends Error {
|
|
106
34
|
constructor(serializer) {
|
|
107
35
|
super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
|
|
@@ -122,7 +50,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
122
50
|
}
|
|
123
51
|
};
|
|
124
52
|
|
|
125
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
53
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
|
|
126
54
|
function fixSerializer(serializer, fixedBytes, description) {
|
|
127
55
|
return {
|
|
128
56
|
description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
|
|
@@ -143,7 +71,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
143
71
|
};
|
|
144
72
|
}
|
|
145
73
|
|
|
146
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
74
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
|
|
147
75
|
function mapSerializer(serializer, unmap, map) {
|
|
148
76
|
return {
|
|
149
77
|
description: serializer.description,
|
|
@@ -157,7 +85,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
157
85
|
};
|
|
158
86
|
}
|
|
159
87
|
|
|
160
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
88
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
161
89
|
var InvalidBaseStringError = class extends Error {
|
|
162
90
|
constructor(value, base, cause) {
|
|
163
91
|
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
@@ -167,7 +95,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
167
95
|
}
|
|
168
96
|
};
|
|
169
97
|
|
|
170
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
98
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
171
99
|
var baseX = (alphabet) => {
|
|
172
100
|
const base = alphabet.length;
|
|
173
101
|
const baseBigInt = BigInt(base);
|
|
@@ -221,16 +149,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
221
149
|
};
|
|
222
150
|
};
|
|
223
151
|
|
|
224
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
152
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
225
153
|
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
226
154
|
|
|
227
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
155
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
|
|
228
156
|
var removeNullCharacters = (value) => (
|
|
229
157
|
// eslint-disable-next-line no-control-regex
|
|
230
158
|
value.replace(/\u0000/g, "")
|
|
231
159
|
);
|
|
232
160
|
|
|
233
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.
|
|
161
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
|
|
234
162
|
var utf8 = {
|
|
235
163
|
description: "utf8",
|
|
236
164
|
fixedSize: null,
|
|
@@ -244,14 +172,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
244
172
|
}
|
|
245
173
|
};
|
|
246
174
|
|
|
247
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
175
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
|
|
248
176
|
var Endian;
|
|
249
177
|
(function(Endian2) {
|
|
250
178
|
Endian2["Little"] = "le";
|
|
251
179
|
Endian2["Big"] = "be";
|
|
252
180
|
})(Endian || (Endian = {}));
|
|
253
181
|
|
|
254
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
182
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
|
|
255
183
|
var NumberOutOfRangeError = class extends RangeError {
|
|
256
184
|
constructor(serializer, min, max, actual) {
|
|
257
185
|
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
|
|
@@ -259,7 +187,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
259
187
|
}
|
|
260
188
|
};
|
|
261
189
|
|
|
262
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
190
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
|
|
263
191
|
function numberFactory(input) {
|
|
264
192
|
let littleEndian;
|
|
265
193
|
let defaultDescription = input.name;
|
|
@@ -303,7 +231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
303
231
|
}
|
|
304
232
|
};
|
|
305
233
|
|
|
306
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
234
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
|
|
307
235
|
var u8 = (options = {}) => numberFactory({
|
|
308
236
|
name: "u8",
|
|
309
237
|
size: 1,
|
|
@@ -313,7 +241,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
313
241
|
options
|
|
314
242
|
});
|
|
315
243
|
|
|
316
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
244
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
317
245
|
var u32 = (options = {}) => numberFactory({
|
|
318
246
|
name: "u32",
|
|
319
247
|
size: 4,
|
|
@@ -323,7 +251,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
323
251
|
options
|
|
324
252
|
});
|
|
325
253
|
|
|
326
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.
|
|
254
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
327
255
|
var shortU16 = (options = {}) => ({
|
|
328
256
|
description: options.description ?? "shortU16",
|
|
329
257
|
fixedSize: null,
|
|
@@ -360,7 +288,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
360
288
|
}
|
|
361
289
|
});
|
|
362
290
|
|
|
363
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
291
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
|
|
364
292
|
var InvalidNumberOfItemsError = class extends Error {
|
|
365
293
|
constructor(serializer, expected, actual) {
|
|
366
294
|
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
@@ -380,12 +308,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
380
308
|
}
|
|
381
309
|
};
|
|
382
310
|
|
|
383
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
311
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
384
312
|
function sumSerializerSizes(sizes) {
|
|
385
313
|
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
386
314
|
}
|
|
387
315
|
|
|
388
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
316
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
389
317
|
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
390
318
|
if (typeof size === "number") {
|
|
391
319
|
return [size, offset];
|
|
@@ -421,7 +349,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
421
349
|
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
422
350
|
}
|
|
423
351
|
|
|
424
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
352
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
|
|
425
353
|
function array(item, options = {}) {
|
|
426
354
|
const size = options.size ?? u32();
|
|
427
355
|
if (size === "remainder" && item.fixedSize === null) {
|
|
@@ -454,7 +382,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
454
382
|
};
|
|
455
383
|
}
|
|
456
384
|
|
|
457
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
385
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
458
386
|
function bytes(options = {}) {
|
|
459
387
|
const size = options.size ?? "variable";
|
|
460
388
|
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
@@ -501,7 +429,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
501
429
|
};
|
|
502
430
|
}
|
|
503
431
|
|
|
504
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
432
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
|
|
505
433
|
function string(options = {}) {
|
|
506
434
|
const size = options.size ?? u32();
|
|
507
435
|
const encoding = options.encoding ?? utf8;
|
|
@@ -542,7 +470,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
542
470
|
};
|
|
543
471
|
}
|
|
544
472
|
|
|
545
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.
|
|
473
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
546
474
|
function struct(fields, options = {}) {
|
|
547
475
|
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
548
476
|
return {
|
|
@@ -564,23 +492,180 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
564
492
|
}
|
|
565
493
|
};
|
|
566
494
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
495
|
+
|
|
496
|
+
// src/unsigned-transaction.ts
|
|
497
|
+
function getUnsignedTransaction(transaction) {
|
|
498
|
+
if ("signatures" in transaction) {
|
|
499
|
+
const {
|
|
500
|
+
signatures: _,
|
|
501
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
502
|
+
...unsignedTransaction
|
|
503
|
+
} = transaction;
|
|
504
|
+
return unsignedTransaction;
|
|
505
|
+
} else {
|
|
506
|
+
return transaction;
|
|
507
|
+
}
|
|
573
508
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
509
|
+
|
|
510
|
+
// src/blockhash.ts
|
|
511
|
+
function assertIsBlockhash(putativeBlockhash) {
|
|
512
|
+
try {
|
|
513
|
+
if (
|
|
514
|
+
// Lowest value (32 bytes of zeroes)
|
|
515
|
+
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
|
|
516
|
+
putativeBlockhash.length > 44
|
|
517
|
+
) {
|
|
518
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
519
|
+
}
|
|
520
|
+
const bytes2 = base58.serialize(putativeBlockhash);
|
|
521
|
+
const numBytes = bytes2.byteLength;
|
|
522
|
+
if (numBytes !== 32) {
|
|
523
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
524
|
+
}
|
|
525
|
+
} catch (e) {
|
|
526
|
+
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
527
|
+
cause: e
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
532
|
+
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
533
|
+
return transaction;
|
|
534
|
+
}
|
|
535
|
+
const out = {
|
|
536
|
+
...getUnsignedTransaction(transaction),
|
|
537
|
+
lifetimeConstraint: blockhashLifetimeConstraint
|
|
538
|
+
};
|
|
539
|
+
Object.freeze(out);
|
|
540
|
+
return out;
|
|
583
541
|
}
|
|
542
|
+
|
|
543
|
+
// src/create-transaction.ts
|
|
544
|
+
function createTransaction({
|
|
545
|
+
version
|
|
546
|
+
}) {
|
|
547
|
+
const out = {
|
|
548
|
+
instructions: [],
|
|
549
|
+
version
|
|
550
|
+
};
|
|
551
|
+
Object.freeze(out);
|
|
552
|
+
return out;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// ../instructions/dist/index.browser.js
|
|
556
|
+
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
557
|
+
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
558
|
+
3] = "WRITABLE_SIGNER";
|
|
559
|
+
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
560
|
+
2] = "READONLY_SIGNER";
|
|
561
|
+
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
562
|
+
1] = "WRITABLE";
|
|
563
|
+
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
564
|
+
0] = "READONLY";
|
|
565
|
+
return AccountRole2;
|
|
566
|
+
})(AccountRole || {});
|
|
567
|
+
var IS_WRITABLE_BITMASK = 1;
|
|
568
|
+
function isSignerRole(role) {
|
|
569
|
+
return role >= 2;
|
|
570
|
+
}
|
|
571
|
+
function isWritableRole(role) {
|
|
572
|
+
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
573
|
+
}
|
|
574
|
+
function mergeRoles(roleA, roleB) {
|
|
575
|
+
return roleA | roleB;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// src/durable-nonce.ts
|
|
579
|
+
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
580
|
+
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
581
|
+
function assertIsDurableNonceTransaction(transaction) {
|
|
582
|
+
if (!isDurableNonceTransaction(transaction)) {
|
|
583
|
+
throw new Error("Transaction is not a durable nonce transaction");
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
587
|
+
return {
|
|
588
|
+
accounts: [
|
|
589
|
+
{ address: nonceAccountAddress, role: AccountRole.WRITABLE },
|
|
590
|
+
{
|
|
591
|
+
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
592
|
+
role: AccountRole.READONLY
|
|
593
|
+
},
|
|
594
|
+
{ address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
|
|
595
|
+
],
|
|
596
|
+
data: new Uint8Array([4, 0, 0, 0]),
|
|
597
|
+
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function isAdvanceNonceAccountInstruction(instruction) {
|
|
601
|
+
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
602
|
+
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
603
|
+
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
604
|
+
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
605
|
+
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
606
|
+
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
|
|
607
|
+
}
|
|
608
|
+
function isAdvanceNonceAccountInstructionData(data) {
|
|
609
|
+
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
610
|
+
}
|
|
611
|
+
function isDurableNonceTransaction(transaction) {
|
|
612
|
+
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
613
|
+
}
|
|
614
|
+
function setTransactionLifetimeUsingDurableNonce({
|
|
615
|
+
nonce,
|
|
616
|
+
nonceAccountAddress,
|
|
617
|
+
nonceAuthorityAddress
|
|
618
|
+
}, transaction) {
|
|
619
|
+
const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
|
|
620
|
+
if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
|
|
621
|
+
return transaction;
|
|
622
|
+
}
|
|
623
|
+
const out = {
|
|
624
|
+
...getUnsignedTransaction(transaction),
|
|
625
|
+
instructions: [
|
|
626
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
627
|
+
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
628
|
+
],
|
|
629
|
+
lifetimeConstraint: {
|
|
630
|
+
nonce
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
Object.freeze(out);
|
|
634
|
+
return out;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// src/fee-payer.ts
|
|
638
|
+
function setTransactionFeePayer(feePayer, transaction) {
|
|
639
|
+
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
640
|
+
return transaction;
|
|
641
|
+
}
|
|
642
|
+
const out = {
|
|
643
|
+
...getUnsignedTransaction(transaction),
|
|
644
|
+
feePayer
|
|
645
|
+
};
|
|
646
|
+
Object.freeze(out);
|
|
647
|
+
return out;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// src/instructions.ts
|
|
651
|
+
function appendTransactionInstruction(instruction, transaction) {
|
|
652
|
+
const out = {
|
|
653
|
+
...getUnsignedTransaction(transaction),
|
|
654
|
+
instructions: [...transaction.instructions, instruction]
|
|
655
|
+
};
|
|
656
|
+
Object.freeze(out);
|
|
657
|
+
return out;
|
|
658
|
+
}
|
|
659
|
+
function prependTransactionInstruction(instruction, transaction) {
|
|
660
|
+
const out = {
|
|
661
|
+
...getUnsignedTransaction(transaction),
|
|
662
|
+
instructions: [instruction, ...transaction.instructions]
|
|
663
|
+
};
|
|
664
|
+
Object.freeze(out);
|
|
665
|
+
return out;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// ../assertions/dist/index.browser.js
|
|
584
669
|
function assertIsSecureContext() {
|
|
585
670
|
if (!globalThis.isSecureContext) {
|
|
586
671
|
throw new Error(
|
|
@@ -600,7 +685,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
600
685
|
throw new Error("No signing implementation could be found");
|
|
601
686
|
}
|
|
602
687
|
}
|
|
603
|
-
|
|
688
|
+
function getBase58EncodedAddressCodec(config) {
|
|
689
|
+
return string({
|
|
690
|
+
description: config?.description ?? ("A 32-byte account address" ),
|
|
691
|
+
encoding: base58,
|
|
692
|
+
size: 32
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function getBase58EncodedAddressComparator() {
|
|
696
|
+
return new Intl.Collator("en", {
|
|
697
|
+
caseFirst: "lower",
|
|
698
|
+
ignorePunctuation: false,
|
|
699
|
+
localeMatcher: "best fit",
|
|
700
|
+
numeric: false,
|
|
701
|
+
sensitivity: "variant",
|
|
702
|
+
usage: "sort"
|
|
703
|
+
}).compare;
|
|
704
|
+
}
|
|
705
|
+
async function getAddressFromPublicKey(publicKey) {
|
|
604
706
|
await assertKeyExporterIsAvailable();
|
|
605
707
|
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
606
708
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
@@ -609,35 +711,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
609
711
|
const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
610
712
|
return base58EncodedAddress;
|
|
611
713
|
}
|
|
714
|
+
|
|
715
|
+
// ../keys/dist/index.browser.js
|
|
612
716
|
async function signBytes(key, data) {
|
|
613
717
|
await assertSigningCapabilityIsAvailable();
|
|
614
718
|
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
615
719
|
return new Uint8Array(signedData);
|
|
616
720
|
}
|
|
617
721
|
|
|
618
|
-
// ../instructions/dist/index.browser.js
|
|
619
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
620
|
-
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
621
|
-
3] = "WRITABLE_SIGNER";
|
|
622
|
-
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
623
|
-
2] = "READONLY_SIGNER";
|
|
624
|
-
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
625
|
-
1] = "WRITABLE";
|
|
626
|
-
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
627
|
-
0] = "READONLY";
|
|
628
|
-
return AccountRole2;
|
|
629
|
-
})(AccountRole || {});
|
|
630
|
-
var IS_WRITABLE_BITMASK = 1;
|
|
631
|
-
function isSignerRole(role) {
|
|
632
|
-
return role >= 2;
|
|
633
|
-
}
|
|
634
|
-
function isWritableRole(role) {
|
|
635
|
-
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
636
|
-
}
|
|
637
|
-
function mergeRoles(roleA, roleB) {
|
|
638
|
-
return roleA | roleB;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
722
|
// src/accounts.ts
|
|
642
723
|
function upsert(addressMap, address, update) {
|
|
643
724
|
addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
|
|
@@ -993,7 +1074,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
993
1074
|
)
|
|
994
1075
|
],
|
|
995
1076
|
[
|
|
996
|
-
"
|
|
1077
|
+
"accountIndices",
|
|
997
1078
|
array(
|
|
998
1079
|
u8({
|
|
999
1080
|
description: "The index of an account, according to the well-ordered accounts list for this transaction"
|
|
@@ -1013,23 +1094,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1013
1094
|
]
|
|
1014
1095
|
]),
|
|
1015
1096
|
(value) => {
|
|
1016
|
-
if (value.
|
|
1097
|
+
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1017
1098
|
return value;
|
|
1018
1099
|
}
|
|
1019
1100
|
return {
|
|
1020
1101
|
...value,
|
|
1021
|
-
|
|
1102
|
+
accountIndices: value.accountIndices ?? [],
|
|
1022
1103
|
data: value.data ?? new Uint8Array(0)
|
|
1023
1104
|
};
|
|
1024
1105
|
},
|
|
1025
1106
|
(value) => {
|
|
1026
|
-
if (value.
|
|
1107
|
+
if (value.accountIndices.length && value.data.byteLength) {
|
|
1027
1108
|
return value;
|
|
1028
1109
|
}
|
|
1029
|
-
const {
|
|
1110
|
+
const { accountIndices, data, ...rest } = value;
|
|
1030
1111
|
return {
|
|
1031
1112
|
...rest,
|
|
1032
|
-
...
|
|
1113
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1033
1114
|
...data.byteLength ? { data } : null
|
|
1034
1115
|
};
|
|
1035
1116
|
}
|
|
@@ -1157,16 +1238,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1157
1238
|
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1158
1239
|
return signature;
|
|
1159
1240
|
}
|
|
1160
|
-
async function signTransaction(
|
|
1241
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1161
1242
|
const compiledMessage = compileMessage(transaction);
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1243
|
+
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1244
|
+
const publicKeySignaturePairs = await Promise.all(
|
|
1245
|
+
keyPairs.map(
|
|
1246
|
+
(keyPair) => Promise.all([
|
|
1247
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1248
|
+
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1249
|
+
])
|
|
1250
|
+
)
|
|
1251
|
+
);
|
|
1252
|
+
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
1253
|
+
nextSignatures[signerPublicKey] = signature;
|
|
1254
|
+
}
|
|
1170
1255
|
const out = {
|
|
1171
1256
|
...transaction,
|
|
1172
1257
|
signatures: nextSignatures
|
|
@@ -1175,10 +1260,68 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1175
1260
|
return out;
|
|
1176
1261
|
}
|
|
1177
1262
|
|
|
1263
|
+
// src/compile-transaction.ts
|
|
1264
|
+
function getCompiledTransaction(transaction) {
|
|
1265
|
+
const compiledMessage = compileMessage(transaction);
|
|
1266
|
+
let signatures;
|
|
1267
|
+
if ("signatures" in transaction) {
|
|
1268
|
+
signatures = [];
|
|
1269
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1270
|
+
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1271
|
+
}
|
|
1272
|
+
} else {
|
|
1273
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1274
|
+
}
|
|
1275
|
+
return {
|
|
1276
|
+
compiledMessage,
|
|
1277
|
+
signatures
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
// src/serializers/transaction.ts
|
|
1282
|
+
var BASE_CONFIG3 = {
|
|
1283
|
+
description: "The wire format of a Solana transaction" ,
|
|
1284
|
+
fixedSize: null,
|
|
1285
|
+
maxSize: null
|
|
1286
|
+
};
|
|
1287
|
+
function serialize3(transaction) {
|
|
1288
|
+
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1289
|
+
return struct([
|
|
1290
|
+
[
|
|
1291
|
+
"signatures",
|
|
1292
|
+
array(bytes({ size: 64 }), {
|
|
1293
|
+
...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
|
|
1294
|
+
size: shortU16()
|
|
1295
|
+
})
|
|
1296
|
+
],
|
|
1297
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
1298
|
+
]).serialize(compiledTransaction);
|
|
1299
|
+
}
|
|
1300
|
+
function getTransactionEncoder() {
|
|
1301
|
+
return {
|
|
1302
|
+
...BASE_CONFIG3,
|
|
1303
|
+
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
1304
|
+
serialize: serialize3
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// src/wire-transaction.ts
|
|
1309
|
+
function getBase64EncodedWireTransaction(transaction) {
|
|
1310
|
+
const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
|
|
1311
|
+
{
|
|
1312
|
+
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1178
1316
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1317
|
+
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1318
|
+
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1179
1319
|
exports.createTransaction = createTransaction;
|
|
1320
|
+
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1180
1321
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1181
1322
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1323
|
+
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1324
|
+
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1182
1325
|
exports.signTransaction = signTransaction;
|
|
1183
1326
|
|
|
1184
1327
|
return exports;
|