@solana/transactions 2.0.0-experimental.c5061ae → 2.0.0-experimental.c8d8b83
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 +148 -53
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +142 -55
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +197 -99
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +142 -55
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +146 -53
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +144 -55
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +16 -10
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts +1 -1
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +1 -1
- package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
- package/dist/types/compile-header.d.ts.map +1 -0
- package/dist/types/compile-instructions.d.ts +1 -1
- package/dist/types/compile-instructions.d.ts.map +1 -0
- package/dist/types/compile-lifetime-token.d.ts.map +1 -0
- package/dist/types/compile-static-accounts.d.ts +1 -1
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +10 -2
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +3 -2
- package/dist/types/fee-payer.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
- package/dist/types/serializers/header.d.ts.map +1 -0
- package/dist/types/serializers/index.d.ts +2 -0
- package/dist/types/serializers/index.d.ts.map +1 -0
- package/dist/types/serializers/instruction.d.ts.map +1 -0
- package/dist/types/serializers/message.d.ts.map +1 -0
- package/dist/types/serializers/transaction-version.d.ts.map +1 -0
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/serializers/unimplemented.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +12 -3
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts +1 -1
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +18 -18
|
@@ -9,7 +9,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
9
9
|
return value;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.
|
|
12
|
+
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
|
|
13
13
|
var mergeBytes = (bytesArr) => {
|
|
14
14
|
const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
|
|
15
15
|
const result = new Uint8Array(totalLength);
|
|
@@ -29,7 +29,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
29
29
|
};
|
|
30
30
|
var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
|
|
31
31
|
|
|
32
|
-
// ../../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
|
|
33
33
|
var DeserializingEmptyBufferError = class extends Error {
|
|
34
34
|
constructor(serializer) {
|
|
35
35
|
super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
|
|
@@ -50,7 +50,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
// ../../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
|
|
54
54
|
function fixSerializer(serializer, fixedBytes, description) {
|
|
55
55
|
return {
|
|
56
56
|
description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
|
|
@@ -71,7 +71,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// ../../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
|
|
75
75
|
function mapSerializer(serializer, unmap, map) {
|
|
76
76
|
return {
|
|
77
77
|
description: serializer.description,
|
|
@@ -85,7 +85,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
// ../../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
|
|
89
89
|
var InvalidBaseStringError = class extends Error {
|
|
90
90
|
constructor(value, base, cause) {
|
|
91
91
|
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
@@ -95,7 +95,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
// ../../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
|
|
99
99
|
var baseX = (alphabet) => {
|
|
100
100
|
const base = alphabet.length;
|
|
101
101
|
const baseBigInt = BigInt(base);
|
|
@@ -149,16 +149,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
// ../../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
|
|
153
153
|
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
154
154
|
|
|
155
|
-
// ../../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
|
|
156
156
|
var removeNullCharacters = (value) => (
|
|
157
157
|
// eslint-disable-next-line no-control-regex
|
|
158
158
|
value.replace(/\u0000/g, "")
|
|
159
159
|
);
|
|
160
160
|
|
|
161
|
-
// ../../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
|
|
162
162
|
var utf8 = {
|
|
163
163
|
description: "utf8",
|
|
164
164
|
fixedSize: null,
|
|
@@ -172,14 +172,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
-
// ../../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
|
|
176
176
|
var Endian;
|
|
177
177
|
(function(Endian2) {
|
|
178
178
|
Endian2["Little"] = "le";
|
|
179
179
|
Endian2["Big"] = "be";
|
|
180
180
|
})(Endian || (Endian = {}));
|
|
181
181
|
|
|
182
|
-
// ../../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
|
|
183
183
|
var NumberOutOfRangeError = class extends RangeError {
|
|
184
184
|
constructor(serializer, min, max, actual) {
|
|
185
185
|
super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
|
|
@@ -187,7 +187,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
// ../../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
|
|
191
191
|
function numberFactory(input) {
|
|
192
192
|
let littleEndian;
|
|
193
193
|
let defaultDescription = input.name;
|
|
@@ -231,7 +231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
// ../../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
|
|
235
235
|
var u8 = (options = {}) => numberFactory({
|
|
236
236
|
name: "u8",
|
|
237
237
|
size: 1,
|
|
@@ -241,7 +241,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
241
241
|
options
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
-
// ../../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
|
|
245
245
|
var u32 = (options = {}) => numberFactory({
|
|
246
246
|
name: "u32",
|
|
247
247
|
size: 4,
|
|
@@ -251,7 +251,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
251
251
|
options
|
|
252
252
|
});
|
|
253
253
|
|
|
254
|
-
// ../../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
|
|
255
255
|
var shortU16 = (options = {}) => ({
|
|
256
256
|
description: options.description ?? "shortU16",
|
|
257
257
|
fixedSize: null,
|
|
@@ -288,7 +288,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
288
288
|
}
|
|
289
289
|
});
|
|
290
290
|
|
|
291
|
-
// ../../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
|
|
292
292
|
var InvalidNumberOfItemsError = class extends Error {
|
|
293
293
|
constructor(serializer, expected, actual) {
|
|
294
294
|
super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
|
|
@@ -308,12 +308,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
// ../../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
|
|
312
312
|
function sumSerializerSizes(sizes) {
|
|
313
313
|
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
// ../../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
|
|
317
317
|
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
318
318
|
if (typeof size === "number") {
|
|
319
319
|
return [size, offset];
|
|
@@ -349,7 +349,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
349
349
|
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
// ../../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
|
|
353
353
|
function array(item, options = {}) {
|
|
354
354
|
const size = options.size ?? u32();
|
|
355
355
|
if (size === "remainder" && item.fixedSize === null) {
|
|
@@ -382,7 +382,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
// ../../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
|
|
386
386
|
function bytes(options = {}) {
|
|
387
387
|
const size = options.size ?? "variable";
|
|
388
388
|
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
@@ -429,7 +429,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
// ../../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
|
|
433
433
|
function string(options = {}) {
|
|
434
434
|
const size = options.size ?? u32();
|
|
435
435
|
const encoding = options.encoding ?? utf8;
|
|
@@ -470,7 +470,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
// ../../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
|
|
474
474
|
function struct(fields, options = {}) {
|
|
475
475
|
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
476
476
|
return {
|
|
@@ -583,6 +583,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
583
583
|
throw new Error("Transaction is not a durable nonce transaction");
|
|
584
584
|
}
|
|
585
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
|
+
}
|
|
586
600
|
function isAdvanceNonceAccountInstruction(instruction) {
|
|
587
601
|
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
588
602
|
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
@@ -597,6 +611,28 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
597
611
|
function isDurableNonceTransaction(transaction) {
|
|
598
612
|
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
599
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
|
+
}
|
|
600
636
|
|
|
601
637
|
// src/fee-payer.ts
|
|
602
638
|
function setTransactionFeePayer(feePayer, transaction) {
|
|
@@ -628,23 +664,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
628
664
|
Object.freeze(out);
|
|
629
665
|
return out;
|
|
630
666
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
description: config?.description ?? ("A 32-byte account address" ),
|
|
634
|
-
encoding: base58,
|
|
635
|
-
size: 32
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
function getBase58EncodedAddressComparator() {
|
|
639
|
-
return new Intl.Collator("en", {
|
|
640
|
-
caseFirst: "lower",
|
|
641
|
-
ignorePunctuation: false,
|
|
642
|
-
localeMatcher: "best fit",
|
|
643
|
-
numeric: false,
|
|
644
|
-
sensitivity: "variant",
|
|
645
|
-
usage: "sort"
|
|
646
|
-
}).compare;
|
|
647
|
-
}
|
|
667
|
+
|
|
668
|
+
// ../assertions/dist/index.browser.js
|
|
648
669
|
function assertIsSecureContext() {
|
|
649
670
|
if (!globalThis.isSecureContext) {
|
|
650
671
|
throw new Error(
|
|
@@ -664,20 +685,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
664
685
|
throw new Error("No signing implementation could be found");
|
|
665
686
|
}
|
|
666
687
|
}
|
|
667
|
-
|
|
688
|
+
function getAddressCodec(config) {
|
|
689
|
+
return string({
|
|
690
|
+
description: config?.description ?? ("A 32-byte account address" ),
|
|
691
|
+
encoding: base58,
|
|
692
|
+
size: 32
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function getAddressComparator() {
|
|
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) {
|
|
668
706
|
await assertKeyExporterIsAvailable();
|
|
669
707
|
if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
|
|
670
708
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
671
709
|
}
|
|
672
710
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
673
|
-
const [base58EncodedAddress] =
|
|
711
|
+
const [base58EncodedAddress] = getAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
|
|
674
712
|
return base58EncodedAddress;
|
|
675
713
|
}
|
|
676
|
-
async function signBytes(key, data) {
|
|
677
|
-
await assertSigningCapabilityIsAvailable();
|
|
678
|
-
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
679
|
-
return new Uint8Array(signedData);
|
|
680
|
-
}
|
|
681
714
|
|
|
682
715
|
// src/accounts.ts
|
|
683
716
|
function upsert(addressMap, address, update) {
|
|
@@ -732,7 +765,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
732
765
|
const shouldReplaceEntry = (
|
|
733
766
|
// Consider using the new LOOKUP_TABLE if its address is different...
|
|
734
767
|
entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
|
|
735
|
-
(addressComparator || (addressComparator =
|
|
768
|
+
(addressComparator || (addressComparator = getAddressComparator()))(
|
|
736
769
|
accountMeta.lookupTableAddress,
|
|
737
770
|
entry.lookupTableAddress
|
|
738
771
|
) < 0
|
|
@@ -838,7 +871,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
838
871
|
if (leftIsWritable !== isWritableRole(rightEntry.role)) {
|
|
839
872
|
return leftIsWritable ? -1 : 1;
|
|
840
873
|
}
|
|
841
|
-
addressComparator || (addressComparator =
|
|
874
|
+
addressComparator || (addressComparator = getAddressComparator());
|
|
842
875
|
if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
|
|
843
876
|
return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
|
|
844
877
|
} else {
|
|
@@ -869,7 +902,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
869
902
|
entry.readableIndices.push(account.addressIndex);
|
|
870
903
|
}
|
|
871
904
|
}
|
|
872
|
-
return Object.keys(index).sort(
|
|
905
|
+
return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
|
|
873
906
|
lookupTableAddress,
|
|
874
907
|
...index[lookupTableAddress]
|
|
875
908
|
}));
|
|
@@ -949,13 +982,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
949
982
|
};
|
|
950
983
|
}
|
|
951
984
|
|
|
985
|
+
// src/compile-transaction.ts
|
|
986
|
+
function getCompiledTransaction(transaction) {
|
|
987
|
+
const compiledMessage = compileMessage(transaction);
|
|
988
|
+
let signatures;
|
|
989
|
+
if ("signatures" in transaction) {
|
|
990
|
+
signatures = [];
|
|
991
|
+
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
992
|
+
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
993
|
+
}
|
|
994
|
+
} else {
|
|
995
|
+
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
996
|
+
}
|
|
997
|
+
return {
|
|
998
|
+
compiledMessage,
|
|
999
|
+
signatures
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
952
1003
|
// src/serializers/address-table-lookup.ts
|
|
953
1004
|
function getAddressTableLookupCodec() {
|
|
954
1005
|
return struct(
|
|
955
1006
|
[
|
|
956
1007
|
[
|
|
957
1008
|
"lookupTableAddress",
|
|
958
|
-
|
|
1009
|
+
getAddressCodec(
|
|
959
1010
|
{
|
|
960
1011
|
description: "The address of the address lookup table account from which instruction addresses should be looked up"
|
|
961
1012
|
}
|
|
@@ -1034,7 +1085,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1034
1085
|
)
|
|
1035
1086
|
],
|
|
1036
1087
|
[
|
|
1037
|
-
"
|
|
1088
|
+
"accountIndices",
|
|
1038
1089
|
array(
|
|
1039
1090
|
u8({
|
|
1040
1091
|
description: "The index of an account, according to the well-ordered accounts list for this transaction"
|
|
@@ -1054,23 +1105,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1054
1105
|
]
|
|
1055
1106
|
]),
|
|
1056
1107
|
(value) => {
|
|
1057
|
-
if (value.
|
|
1108
|
+
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1058
1109
|
return value;
|
|
1059
1110
|
}
|
|
1060
1111
|
return {
|
|
1061
1112
|
...value,
|
|
1062
|
-
|
|
1113
|
+
accountIndices: value.accountIndices ?? [],
|
|
1063
1114
|
data: value.data ?? new Uint8Array(0)
|
|
1064
1115
|
};
|
|
1065
1116
|
},
|
|
1066
1117
|
(value) => {
|
|
1067
|
-
if (value.
|
|
1118
|
+
if (value.accountIndices.length && value.data.byteLength) {
|
|
1068
1119
|
return value;
|
|
1069
1120
|
}
|
|
1070
|
-
const {
|
|
1121
|
+
const { accountIndices, data, ...rest } = value;
|
|
1071
1122
|
return {
|
|
1072
1123
|
...rest,
|
|
1073
|
-
...
|
|
1124
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1074
1125
|
...data.byteLength ? { data } : null
|
|
1075
1126
|
};
|
|
1076
1127
|
}
|
|
@@ -1156,7 +1207,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1156
1207
|
["header", getMessageHeaderCodec()],
|
|
1157
1208
|
[
|
|
1158
1209
|
"staticAccounts",
|
|
1159
|
-
array(
|
|
1210
|
+
array(getAddressCodec(), {
|
|
1160
1211
|
description: "A compact-array of static account addresses belonging to this transaction" ,
|
|
1161
1212
|
size: shortU16()
|
|
1162
1213
|
})
|
|
@@ -1192,48 +1243,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1192
1243
|
};
|
|
1193
1244
|
}
|
|
1194
1245
|
|
|
1195
|
-
// src/signatures.ts
|
|
1196
|
-
async function getCompiledMessageSignature(message, secretKey) {
|
|
1197
|
-
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1198
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1199
|
-
return signature;
|
|
1200
|
-
}
|
|
1201
|
-
async function signTransaction(keyPair, transaction) {
|
|
1202
|
-
const compiledMessage = compileMessage(transaction);
|
|
1203
|
-
const [signerPublicKey, signature] = await Promise.all([
|
|
1204
|
-
getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
|
|
1205
|
-
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1206
|
-
]);
|
|
1207
|
-
const nextSignatures = {
|
|
1208
|
-
..."signatures" in transaction ? transaction.signatures : null,
|
|
1209
|
-
...{ [signerPublicKey]: signature }
|
|
1210
|
-
};
|
|
1211
|
-
const out = {
|
|
1212
|
-
...transaction,
|
|
1213
|
-
signatures: nextSignatures
|
|
1214
|
-
};
|
|
1215
|
-
Object.freeze(out);
|
|
1216
|
-
return out;
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
// src/compile-transaction.ts
|
|
1220
|
-
function getCompiledTransaction(transaction) {
|
|
1221
|
-
const compiledMessage = compileMessage(transaction);
|
|
1222
|
-
let signatures;
|
|
1223
|
-
if ("signatures" in transaction) {
|
|
1224
|
-
signatures = [];
|
|
1225
|
-
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1226
|
-
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
|
|
1227
|
-
}
|
|
1228
|
-
} else {
|
|
1229
|
-
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
1230
|
-
}
|
|
1231
|
-
return {
|
|
1232
|
-
compiledMessage,
|
|
1233
|
-
signatures
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
1246
|
// src/serializers/transaction.ts
|
|
1238
1247
|
var BASE_CONFIG3 = {
|
|
1239
1248
|
description: "The wire format of a Solana transaction" ,
|
|
@@ -1261,6 +1270,89 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1261
1270
|
};
|
|
1262
1271
|
}
|
|
1263
1272
|
|
|
1273
|
+
// ../keys/dist/index.browser.js
|
|
1274
|
+
async function signBytes(key, data) {
|
|
1275
|
+
await assertSigningCapabilityIsAvailable();
|
|
1276
|
+
const signedData = await crypto.subtle.sign("Ed25519", key, data);
|
|
1277
|
+
return new Uint8Array(signedData);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// src/signatures.ts
|
|
1281
|
+
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
1282
|
+
try {
|
|
1283
|
+
if (
|
|
1284
|
+
// Lowest value (64 bytes of zeroes)
|
|
1285
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1286
|
+
putativeTransactionSignature.length > 88
|
|
1287
|
+
) {
|
|
1288
|
+
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1289
|
+
}
|
|
1290
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1291
|
+
const numBytes = bytes2.byteLength;
|
|
1292
|
+
if (numBytes !== 64) {
|
|
1293
|
+
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1294
|
+
}
|
|
1295
|
+
} catch (e) {
|
|
1296
|
+
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1297
|
+
cause: e
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function isTransactionSignature(putativeTransactionSignature) {
|
|
1302
|
+
if (
|
|
1303
|
+
// Lowest value (64 bytes of zeroes)
|
|
1304
|
+
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1305
|
+
putativeTransactionSignature.length > 88
|
|
1306
|
+
) {
|
|
1307
|
+
return false;
|
|
1308
|
+
}
|
|
1309
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1310
|
+
const numBytes = bytes2.byteLength;
|
|
1311
|
+
if (numBytes !== 64) {
|
|
1312
|
+
return false;
|
|
1313
|
+
}
|
|
1314
|
+
return true;
|
|
1315
|
+
}
|
|
1316
|
+
async function getCompiledMessageSignature(message, secretKey) {
|
|
1317
|
+
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1318
|
+
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1319
|
+
return signature;
|
|
1320
|
+
}
|
|
1321
|
+
function getSignatureFromTransaction(transaction) {
|
|
1322
|
+
const signature = transaction.signatures[transaction.feePayer];
|
|
1323
|
+
if (!signature) {
|
|
1324
|
+
throw new Error(
|
|
1325
|
+
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
return signature;
|
|
1329
|
+
}
|
|
1330
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1331
|
+
const compiledMessage = compileMessage(transaction);
|
|
1332
|
+
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1333
|
+
const publicKeySignaturePairs = await Promise.all(
|
|
1334
|
+
keyPairs.map(
|
|
1335
|
+
(keyPair) => Promise.all([
|
|
1336
|
+
getAddressFromPublicKey(keyPair.publicKey),
|
|
1337
|
+
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1338
|
+
])
|
|
1339
|
+
)
|
|
1340
|
+
);
|
|
1341
|
+
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
1342
|
+
nextSignatures[signerPublicKey] = signature;
|
|
1343
|
+
}
|
|
1344
|
+
const out = {
|
|
1345
|
+
...transaction,
|
|
1346
|
+
signatures: nextSignatures
|
|
1347
|
+
};
|
|
1348
|
+
Object.freeze(out);
|
|
1349
|
+
return out;
|
|
1350
|
+
}
|
|
1351
|
+
function transactionSignature(putativeTransactionSignature) {
|
|
1352
|
+
assertIsTransactionSignature(putativeTransactionSignature);
|
|
1353
|
+
return putativeTransactionSignature;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1264
1356
|
// src/wire-transaction.ts
|
|
1265
1357
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1266
1358
|
const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
|
|
@@ -1272,12 +1364,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1272
1364
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1273
1365
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1274
1366
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1367
|
+
exports.assertIsTransactionSignature = assertIsTransactionSignature;
|
|
1275
1368
|
exports.createTransaction = createTransaction;
|
|
1276
1369
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1370
|
+
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1371
|
+
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1372
|
+
exports.isTransactionSignature = isTransactionSignature;
|
|
1277
1373
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1278
1374
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1279
1375
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1376
|
+
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1280
1377
|
exports.signTransaction = signTransaction;
|
|
1378
|
+
exports.transactionSignature = transactionSignature;
|
|
1281
1379
|
|
|
1282
1380
|
return exports;
|
|
1283
1381
|
|