@solana/transactions 2.0.0-experimental.a9e6db3 → 2.0.0-experimental.aa4a701
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 +272 -5
- package/dist/index.browser.cjs +465 -257
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +463 -257
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +900 -991
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +463 -257
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +465 -257
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +463 -257
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +18 -16
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts +7 -0
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts +2 -2
- 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.map +1 -0
- package/dist/types/compile-lifetime-token.d.ts.map +1 -0
- package/dist/types/compile-static-accounts.d.ts +2 -2
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts +5 -6
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/decompile-transaction.d.ts +5 -0
- package/dist/types/decompile-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +6 -6
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts +4 -4
- 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 +1 -5
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts +5 -3
- 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.map +1 -0
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/instruction.d.ts.map +1 -0
- package/dist/types/serializers/message.d.ts +4 -4
- 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 +6 -5
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +8 -12
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts +6 -13
- 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 +14 -13
- package/dist/types/serializers/unimplemented.d.ts +0 -3
|
@@ -2,282 +2,201 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
// ../codecs-core/dist/index.browser.js
|
|
6
|
+
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
7
|
+
if (bytes.length - offset <= 0) {
|
|
8
|
+
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
|
|
12
|
+
const bytesLength = bytes.length - offset;
|
|
13
|
+
if (bytesLength < expected) {
|
|
14
|
+
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
var mergeBytes = (byteArrays) => {
|
|
18
|
+
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
19
|
+
if (nonEmptyByteArrays.length === 0) {
|
|
20
|
+
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
21
|
+
}
|
|
22
|
+
if (nonEmptyByteArrays.length === 1) {
|
|
23
|
+
return nonEmptyByteArrays[0];
|
|
24
|
+
}
|
|
25
|
+
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
15
26
|
const result = new Uint8Array(totalLength);
|
|
16
27
|
let offset = 0;
|
|
17
|
-
|
|
28
|
+
nonEmptyByteArrays.forEach((arr) => {
|
|
18
29
|
result.set(arr, offset);
|
|
19
30
|
offset += arr.length;
|
|
20
31
|
});
|
|
21
32
|
return result;
|
|
22
33
|
};
|
|
23
|
-
var padBytes = (
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
34
|
+
var padBytes = (bytes, length) => {
|
|
35
|
+
if (bytes.length >= length)
|
|
36
|
+
return bytes;
|
|
26
37
|
const paddedBytes = new Uint8Array(length).fill(0);
|
|
27
|
-
paddedBytes.set(
|
|
38
|
+
paddedBytes.set(bytes);
|
|
28
39
|
return paddedBytes;
|
|
29
40
|
};
|
|
30
|
-
var fixBytes = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
__publicField(this, "name", "DeserializingEmptyBufferError");
|
|
41
|
+
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
42
|
+
function combineCodec(encoder, decoder, description) {
|
|
43
|
+
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
46
|
+
);
|
|
37
47
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
__publicField(this, "name", "NotEnoughBytesError");
|
|
48
|
+
if (encoder.maxSize !== decoder.maxSize) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
51
|
+
);
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
super(message);
|
|
49
|
-
__publicField(this, "name", "ExpectedFixedSizeSerializerError");
|
|
53
|
+
if (description === void 0 && encoder.description !== decoder.description) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
|
|
56
|
+
);
|
|
50
57
|
}
|
|
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
58
|
return {
|
|
56
|
-
|
|
59
|
+
decode: decoder.decode,
|
|
60
|
+
description: description ?? encoder.description,
|
|
61
|
+
encode: encoder.encode,
|
|
62
|
+
fixedSize: encoder.fixedSize,
|
|
63
|
+
maxSize: encoder.maxSize
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function fixCodecHelper(data, fixedBytes, description) {
|
|
67
|
+
return {
|
|
68
|
+
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
57
69
|
fixedSize: fixedBytes,
|
|
58
|
-
maxSize: fixedBytes
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
maxSize: fixedBytes
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function fixEncoder(encoder, fixedBytes, description) {
|
|
74
|
+
return {
|
|
75
|
+
...fixCodecHelper(encoder, fixedBytes, description),
|
|
76
|
+
encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function fixDecoder(decoder, fixedBytes, description) {
|
|
80
|
+
return {
|
|
81
|
+
...fixCodecHelper(decoder, fixedBytes, description),
|
|
82
|
+
decode: (bytes, offset = 0) => {
|
|
83
|
+
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
84
|
+
if (offset > 0 || bytes.length > fixedBytes) {
|
|
85
|
+
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
64
86
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
87
|
+
if (decoder.fixedSize !== null) {
|
|
88
|
+
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
67
89
|
}
|
|
68
|
-
const [value] =
|
|
90
|
+
const [value] = decoder.decode(bytes, 0);
|
|
69
91
|
return [value, offset + fixedBytes];
|
|
70
92
|
}
|
|
71
93
|
};
|
|
72
94
|
}
|
|
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) {
|
|
95
|
+
function mapEncoder(encoder, unmap) {
|
|
76
96
|
return {
|
|
77
|
-
description:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
deserialize: (buffer, offset = 0) => {
|
|
82
|
-
const [value, length] = serializer.deserialize(buffer, offset);
|
|
83
|
-
return map ? [map(value, buffer, offset), length] : [value, length];
|
|
84
|
-
}
|
|
97
|
+
description: encoder.description,
|
|
98
|
+
encode: (value) => encoder.encode(unmap(value)),
|
|
99
|
+
fixedSize: encoder.fixedSize,
|
|
100
|
+
maxSize: encoder.maxSize
|
|
85
101
|
};
|
|
86
102
|
}
|
|
87
|
-
|
|
88
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
89
|
-
var InvalidBaseStringError = class extends Error {
|
|
90
|
-
constructor(value, base, cause) {
|
|
91
|
-
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
92
|
-
super(message);
|
|
93
|
-
__publicField(this, "name", "InvalidBaseStringError");
|
|
94
|
-
this.cause = cause;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
99
|
-
var baseX = (alphabet) => {
|
|
100
|
-
const base = alphabet.length;
|
|
101
|
-
const baseBigInt = BigInt(base);
|
|
103
|
+
function mapDecoder(decoder, map) {
|
|
102
104
|
return {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
serialize(value) {
|
|
107
|
-
if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
|
|
108
|
-
throw new InvalidBaseStringError(value, base);
|
|
109
|
-
}
|
|
110
|
-
if (value === "")
|
|
111
|
-
return new Uint8Array();
|
|
112
|
-
const chars = [...value];
|
|
113
|
-
let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
|
|
114
|
-
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
115
|
-
const leadingZeroes = Array(trailIndex).fill(0);
|
|
116
|
-
if (trailIndex === chars.length)
|
|
117
|
-
return Uint8Array.from(leadingZeroes);
|
|
118
|
-
const tailChars = chars.slice(trailIndex);
|
|
119
|
-
let base10Number = 0n;
|
|
120
|
-
let baseXPower = 1n;
|
|
121
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
122
|
-
base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
|
|
123
|
-
baseXPower *= baseBigInt;
|
|
124
|
-
}
|
|
125
|
-
const tailBytes = [];
|
|
126
|
-
while (base10Number > 0n) {
|
|
127
|
-
tailBytes.unshift(Number(base10Number % 256n));
|
|
128
|
-
base10Number /= 256n;
|
|
129
|
-
}
|
|
130
|
-
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
105
|
+
decode: (bytes, offset = 0) => {
|
|
106
|
+
const [value, length] = decoder.decode(bytes, offset);
|
|
107
|
+
return [map(value, bytes, offset), length];
|
|
131
108
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const bytes2 = buffer.slice(offset);
|
|
136
|
-
let trailIndex = bytes2.findIndex((n) => n !== 0);
|
|
137
|
-
trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
|
|
138
|
-
const leadingZeroes = alphabet[0].repeat(trailIndex);
|
|
139
|
-
if (trailIndex === bytes2.length)
|
|
140
|
-
return [leadingZeroes, buffer.length];
|
|
141
|
-
let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
142
|
-
const tailChars = [];
|
|
143
|
-
while (base10Number > 0n) {
|
|
144
|
-
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
|
|
145
|
-
base10Number /= baseBigInt;
|
|
146
|
-
}
|
|
147
|
-
return [leadingZeroes + tailChars.join(""), buffer.length];
|
|
148
|
-
}
|
|
109
|
+
description: decoder.description,
|
|
110
|
+
fixedSize: decoder.fixedSize,
|
|
111
|
+
maxSize: decoder.maxSize
|
|
149
112
|
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
153
|
-
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
154
|
-
|
|
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 = {}));
|
|
113
|
+
}
|
|
181
114
|
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
115
|
+
// ../codecs-numbers/dist/index.browser.js
|
|
116
|
+
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
117
|
+
if (value < min || value > max) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
120
|
+
);
|
|
187
121
|
}
|
|
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) {
|
|
122
|
+
}
|
|
123
|
+
function sharedNumberFactory(input) {
|
|
192
124
|
let littleEndian;
|
|
193
125
|
let defaultDescription = input.name;
|
|
194
126
|
if (input.size > 1) {
|
|
195
|
-
littleEndian = !("endian" in input.options) || input.options.endian ===
|
|
127
|
+
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
196
128
|
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
197
129
|
}
|
|
198
130
|
return {
|
|
199
131
|
description: input.options.description ?? defaultDescription,
|
|
200
132
|
fixedSize: input.size,
|
|
201
|
-
|
|
202
|
-
|
|
133
|
+
littleEndian,
|
|
134
|
+
maxSize: input.size
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function numberEncoderFactory(input) {
|
|
138
|
+
const codecData = sharedNumberFactory(input);
|
|
139
|
+
return {
|
|
140
|
+
description: codecData.description,
|
|
141
|
+
encode(value) {
|
|
203
142
|
if (input.range) {
|
|
204
|
-
|
|
143
|
+
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
205
144
|
}
|
|
206
|
-
const
|
|
207
|
-
input.set(new DataView(
|
|
208
|
-
return new Uint8Array(
|
|
145
|
+
const arrayBuffer = new ArrayBuffer(input.size);
|
|
146
|
+
input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
|
|
147
|
+
return new Uint8Array(arrayBuffer);
|
|
209
148
|
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
assertEnoughBytes("i8", slice, input.size);
|
|
213
|
-
const view = toDataView(slice);
|
|
214
|
-
return [input.get(view, littleEndian), offset + input.size];
|
|
215
|
-
}
|
|
149
|
+
fixedSize: codecData.fixedSize,
|
|
150
|
+
maxSize: codecData.maxSize
|
|
216
151
|
};
|
|
217
152
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
range: [0, Number("0xff")],
|
|
239
|
-
set: (view, value) => view.setUint8(0, Number(value)),
|
|
240
|
-
get: (view) => view.getUint8(0),
|
|
241
|
-
options
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
|
|
245
|
-
var u32 = (options = {}) => numberFactory({
|
|
246
|
-
name: "u32",
|
|
247
|
-
size: 4,
|
|
248
|
-
range: [0, Number("0xffffffff")],
|
|
249
|
-
set: (view, value, le) => view.setUint32(0, Number(value), le),
|
|
250
|
-
get: (view, le) => view.getUint32(0, le),
|
|
251
|
-
options
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
|
|
255
|
-
var shortU16 = (options = {}) => ({
|
|
153
|
+
function numberDecoderFactory(input) {
|
|
154
|
+
const codecData = sharedNumberFactory(input);
|
|
155
|
+
return {
|
|
156
|
+
decode(bytes, offset = 0) {
|
|
157
|
+
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
|
|
158
|
+
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
|
|
159
|
+
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
160
|
+
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
161
|
+
},
|
|
162
|
+
description: codecData.description,
|
|
163
|
+
fixedSize: codecData.fixedSize,
|
|
164
|
+
maxSize: codecData.maxSize
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function toArrayBuffer(bytes, offset, length) {
|
|
168
|
+
const bytesOffset = bytes.byteOffset + (offset ?? 0);
|
|
169
|
+
const bytesLength = length ?? bytes.byteLength;
|
|
170
|
+
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
171
|
+
}
|
|
172
|
+
var getShortU16Encoder = (options = {}) => ({
|
|
256
173
|
description: options.description ?? "shortU16",
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
assertRange("shortU16", 0, 65535, value);
|
|
261
|
-
const bytes2 = [0];
|
|
174
|
+
encode: (value) => {
|
|
175
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
176
|
+
const bytes = [0];
|
|
262
177
|
for (let ii = 0; ; ii += 1) {
|
|
263
178
|
const alignedValue = value >> ii * 7;
|
|
264
179
|
if (alignedValue === 0) {
|
|
265
180
|
break;
|
|
266
181
|
}
|
|
267
182
|
const nextSevenBits = 127 & alignedValue;
|
|
268
|
-
|
|
183
|
+
bytes[ii] = nextSevenBits;
|
|
269
184
|
if (ii > 0) {
|
|
270
|
-
|
|
185
|
+
bytes[ii - 1] |= 128;
|
|
271
186
|
}
|
|
272
187
|
}
|
|
273
|
-
return new Uint8Array(
|
|
188
|
+
return new Uint8Array(bytes);
|
|
274
189
|
},
|
|
275
|
-
|
|
190
|
+
fixedSize: null,
|
|
191
|
+
maxSize: 3
|
|
192
|
+
});
|
|
193
|
+
var getShortU16Decoder = (options = {}) => ({
|
|
194
|
+
decode: (bytes, offset = 0) => {
|
|
276
195
|
let value = 0;
|
|
277
196
|
let byteCount = 0;
|
|
278
197
|
while (++byteCount) {
|
|
279
198
|
const byteIndex = byteCount - 1;
|
|
280
|
-
const currentByte =
|
|
199
|
+
const currentByte = bytes[offset + byteIndex];
|
|
281
200
|
const nextSevenBits = 127 & currentByte;
|
|
282
201
|
value |= nextSevenBits << byteIndex * 7;
|
|
283
202
|
if ((currentByte & 128) === 0) {
|
|
@@ -285,212 +204,183 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
285
204
|
}
|
|
286
205
|
}
|
|
287
206
|
return [value, offset + byteCount];
|
|
288
|
-
}
|
|
207
|
+
},
|
|
208
|
+
description: options.description ?? "shortU16",
|
|
209
|
+
fixedSize: null,
|
|
210
|
+
maxSize: 3
|
|
211
|
+
});
|
|
212
|
+
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
213
|
+
name: "u32",
|
|
214
|
+
options,
|
|
215
|
+
range: [0, Number("0xffffffff")],
|
|
216
|
+
set: (view, value, le) => view.setUint32(0, value, le),
|
|
217
|
+
size: 4
|
|
218
|
+
});
|
|
219
|
+
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
220
|
+
get: (view, le) => view.getUint32(0, le),
|
|
221
|
+
name: "u32",
|
|
222
|
+
options,
|
|
223
|
+
size: 4
|
|
224
|
+
});
|
|
225
|
+
var getU8Encoder = (options = {}) => numberEncoderFactory({
|
|
226
|
+
name: "u8",
|
|
227
|
+
options,
|
|
228
|
+
range: [0, Number("0xff")],
|
|
229
|
+
set: (view, value) => view.setUint8(0, value),
|
|
230
|
+
size: 1
|
|
231
|
+
});
|
|
232
|
+
var getU8Decoder = (options = {}) => numberDecoderFactory({
|
|
233
|
+
get: (view) => view.getUint8(0),
|
|
234
|
+
name: "u8",
|
|
235
|
+
options,
|
|
236
|
+
size: 1
|
|
289
237
|
});
|
|
290
238
|
|
|
291
|
-
//
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
__publicField(this, "name", "InvalidNumberOfItemsError");
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
var InvalidArrayLikeRemainderSizeError = class extends Error {
|
|
299
|
-
constructor(remainderSize, itemSize) {
|
|
300
|
-
super(`The remainder of the buffer (${remainderSize} bytes) cannot be split into chunks of ${itemSize} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainderSize} modulo ${itemSize} should be equal to zero.`);
|
|
301
|
-
__publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
|
|
305
|
-
constructor(size) {
|
|
306
|
-
super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
|
|
307
|
-
__publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
|
|
312
|
-
function sumSerializerSizes(sizes) {
|
|
313
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
|
|
317
|
-
function getResolvedSize(size, childrenSizes, bytes2, offset) {
|
|
318
|
-
if (typeof size === "number") {
|
|
319
|
-
return [size, offset];
|
|
320
|
-
}
|
|
321
|
-
if (typeof size === "object") {
|
|
322
|
-
return size.deserialize(bytes2, offset);
|
|
323
|
-
}
|
|
324
|
-
if (size === "remainder") {
|
|
325
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
326
|
-
if (childrenSize === null) {
|
|
327
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
328
|
-
}
|
|
329
|
-
const remainder = bytes2.slice(offset).length;
|
|
330
|
-
if (remainder % childrenSize !== 0) {
|
|
331
|
-
throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
|
|
332
|
-
}
|
|
333
|
-
return [remainder / childrenSize, offset];
|
|
239
|
+
// ../codecs-strings/dist/index.browser.js
|
|
240
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
241
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
242
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
334
243
|
}
|
|
335
|
-
throw new UnrecognizedArrayLikeSerializerSizeError(size);
|
|
336
|
-
}
|
|
337
|
-
function getSizeDescription(size) {
|
|
338
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
339
|
-
}
|
|
340
|
-
function getSizeFromChildren(size, childrenSizes) {
|
|
341
|
-
if (typeof size !== "number")
|
|
342
|
-
return null;
|
|
343
|
-
if (size === 0)
|
|
344
|
-
return 0;
|
|
345
|
-
const childrenSize = sumSerializerSizes(childrenSizes);
|
|
346
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
347
|
-
}
|
|
348
|
-
function getSizePrefix(size, realSize) {
|
|
349
|
-
return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
|
|
350
244
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const size = options.size ?? u32();
|
|
355
|
-
if (size === "remainder" && item.fixedSize === null) {
|
|
356
|
-
throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
|
|
357
|
-
}
|
|
245
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
246
|
+
const base = alphabet4.length;
|
|
247
|
+
const baseBigInt = BigInt(base);
|
|
358
248
|
return {
|
|
359
|
-
description:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
|
|
386
|
-
function bytes(options = {}) {
|
|
387
|
-
const size = options.size ?? "variable";
|
|
388
|
-
const description = options.description ?? `bytes(${getSizeDescription(size)})`;
|
|
389
|
-
const byteSerializer = {
|
|
390
|
-
description,
|
|
249
|
+
description: `base${base}`,
|
|
250
|
+
encode(value) {
|
|
251
|
+
assertValidBaseString(alphabet4, value);
|
|
252
|
+
if (value === "")
|
|
253
|
+
return new Uint8Array();
|
|
254
|
+
const chars = [...value];
|
|
255
|
+
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
256
|
+
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
257
|
+
const leadingZeroes = Array(trailIndex).fill(0);
|
|
258
|
+
if (trailIndex === chars.length)
|
|
259
|
+
return Uint8Array.from(leadingZeroes);
|
|
260
|
+
const tailChars = chars.slice(trailIndex);
|
|
261
|
+
let base10Number = 0n;
|
|
262
|
+
let baseXPower = 1n;
|
|
263
|
+
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
264
|
+
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
265
|
+
baseXPower *= baseBigInt;
|
|
266
|
+
}
|
|
267
|
+
const tailBytes = [];
|
|
268
|
+
while (base10Number > 0n) {
|
|
269
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
270
|
+
base10Number /= 256n;
|
|
271
|
+
}
|
|
272
|
+
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
273
|
+
},
|
|
391
274
|
fixedSize: null,
|
|
392
|
-
maxSize: null
|
|
393
|
-
serialize: (value) => new Uint8Array(value),
|
|
394
|
-
deserialize: (bytes2, offset = 0) => {
|
|
395
|
-
const slice = bytes2.slice(offset);
|
|
396
|
-
return [slice, offset + slice.length];
|
|
397
|
-
}
|
|
275
|
+
maxSize: null
|
|
398
276
|
};
|
|
277
|
+
};
|
|
278
|
+
var getBaseXDecoder = (alphabet4) => {
|
|
279
|
+
const base = alphabet4.length;
|
|
280
|
+
const baseBigInt = BigInt(base);
|
|
281
|
+
return {
|
|
282
|
+
decode(rawBytes, offset = 0) {
|
|
283
|
+
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
284
|
+
if (bytes.length === 0)
|
|
285
|
+
return ["", 0];
|
|
286
|
+
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
287
|
+
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
288
|
+
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
289
|
+
if (trailIndex === bytes.length)
|
|
290
|
+
return [leadingZeroes, rawBytes.length];
|
|
291
|
+
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
292
|
+
const tailChars = [];
|
|
293
|
+
while (base10Number > 0n) {
|
|
294
|
+
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
295
|
+
base10Number /= baseBigInt;
|
|
296
|
+
}
|
|
297
|
+
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
298
|
+
},
|
|
299
|
+
description: `base${base}`,
|
|
300
|
+
fixedSize: null,
|
|
301
|
+
maxSize: null
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
305
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
306
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
307
|
+
var removeNullCharacters = (value) => (
|
|
308
|
+
// eslint-disable-next-line no-control-regex
|
|
309
|
+
value.replace(/\u0000/g, "")
|
|
310
|
+
);
|
|
311
|
+
var e = globalThis.TextDecoder;
|
|
312
|
+
var o = globalThis.TextEncoder;
|
|
313
|
+
var getUtf8Encoder = () => {
|
|
314
|
+
let textEncoder;
|
|
315
|
+
return {
|
|
316
|
+
description: "utf8",
|
|
317
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
318
|
+
fixedSize: null,
|
|
319
|
+
maxSize: null
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
var getUtf8Decoder = () => {
|
|
323
|
+
let textDecoder;
|
|
324
|
+
return {
|
|
325
|
+
decode(bytes, offset = 0) {
|
|
326
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
327
|
+
return [removeNullCharacters(value), bytes.length];
|
|
328
|
+
},
|
|
329
|
+
description: "utf8",
|
|
330
|
+
fixedSize: null,
|
|
331
|
+
maxSize: null
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
var getStringEncoder = (options = {}) => {
|
|
335
|
+
const size = options.size ?? getU32Encoder();
|
|
336
|
+
const encoding = options.encoding ?? getUtf8Encoder();
|
|
337
|
+
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
399
338
|
if (size === "variable") {
|
|
400
|
-
return
|
|
339
|
+
return { ...encoding, description };
|
|
401
340
|
}
|
|
402
341
|
if (typeof size === "number") {
|
|
403
|
-
return
|
|
342
|
+
return fixEncoder(encoding, size, description);
|
|
404
343
|
}
|
|
405
344
|
return {
|
|
406
345
|
description,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const contentBytes = byteSerializer.serialize(value);
|
|
411
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
346
|
+
encode: (value) => {
|
|
347
|
+
const contentBytes = encoding.encode(value);
|
|
348
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
412
349
|
return mergeBytes([lengthBytes, contentBytes]);
|
|
413
350
|
},
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
throw new DeserializingEmptyBufferError("bytes");
|
|
417
|
-
}
|
|
418
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
419
|
-
const length = Number(lengthBigInt);
|
|
420
|
-
offset = lengthOffset;
|
|
421
|
-
const contentBuffer = buffer.slice(offset, offset + length);
|
|
422
|
-
if (contentBuffer.length < length) {
|
|
423
|
-
throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
|
|
424
|
-
}
|
|
425
|
-
const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
|
|
426
|
-
offset += contentOffset;
|
|
427
|
-
return [value, offset];
|
|
428
|
-
}
|
|
351
|
+
fixedSize: null,
|
|
352
|
+
maxSize: null
|
|
429
353
|
};
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
const size = options.size ?? u32();
|
|
435
|
-
const encoding = options.encoding ?? utf8;
|
|
354
|
+
};
|
|
355
|
+
var getStringDecoder = (options = {}) => {
|
|
356
|
+
const size = options.size ?? getU32Decoder();
|
|
357
|
+
const encoding = options.encoding ?? getUtf8Decoder();
|
|
436
358
|
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
437
359
|
if (size === "variable") {
|
|
438
|
-
return {
|
|
439
|
-
...encoding,
|
|
440
|
-
description
|
|
441
|
-
};
|
|
360
|
+
return { ...encoding, description };
|
|
442
361
|
}
|
|
443
362
|
if (typeof size === "number") {
|
|
444
|
-
return
|
|
363
|
+
return fixDecoder(encoding, size, description);
|
|
445
364
|
}
|
|
446
365
|
return {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
serialize: (value) => {
|
|
451
|
-
const contentBytes = encoding.serialize(value);
|
|
452
|
-
const lengthBytes = size.serialize(contentBytes.length);
|
|
453
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
454
|
-
},
|
|
455
|
-
deserialize: (buffer, offset = 0) => {
|
|
456
|
-
if (buffer.slice(offset).length === 0) {
|
|
457
|
-
throw new DeserializingEmptyBufferError("string");
|
|
458
|
-
}
|
|
459
|
-
const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
|
|
366
|
+
decode: (bytes, offset = 0) => {
|
|
367
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
368
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
460
369
|
const length = Number(lengthBigInt);
|
|
461
370
|
offset = lengthOffset;
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
const [value, contentOffset] = encoding.deserialize(contentBuffer);
|
|
371
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
372
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
373
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
467
374
|
offset += contentOffset;
|
|
468
375
|
return [value, offset];
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
|
|
474
|
-
function struct(fields, options = {}) {
|
|
475
|
-
const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
|
|
476
|
-
return {
|
|
477
|
-
description: options.description ?? `struct(${fieldDescriptions})`,
|
|
478
|
-
fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
|
|
479
|
-
maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
|
|
480
|
-
serialize: (struct2) => {
|
|
481
|
-
const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
|
|
482
|
-
return mergeBytes(fieldBytes);
|
|
483
376
|
},
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
const [value, newOffset] = serializer.deserialize(bytes2, offset);
|
|
488
|
-
offset = newOffset;
|
|
489
|
-
struct2[key] = value;
|
|
490
|
-
});
|
|
491
|
-
return [struct2, offset];
|
|
492
|
-
}
|
|
377
|
+
description,
|
|
378
|
+
fixedSize: null,
|
|
379
|
+
maxSize: null
|
|
493
380
|
};
|
|
381
|
+
};
|
|
382
|
+
function getSizeDescription(size) {
|
|
383
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
494
384
|
}
|
|
495
385
|
|
|
496
386
|
// src/unsigned-transaction.ts
|
|
@@ -508,7 +398,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
508
398
|
}
|
|
509
399
|
|
|
510
400
|
// src/blockhash.ts
|
|
401
|
+
var base58Encoder;
|
|
511
402
|
function assertIsBlockhash(putativeBlockhash) {
|
|
403
|
+
if (!base58Encoder)
|
|
404
|
+
base58Encoder = getBase58Encoder();
|
|
512
405
|
try {
|
|
513
406
|
if (
|
|
514
407
|
// Lowest value (32 bytes of zeroes)
|
|
@@ -517,8 +410,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
517
410
|
) {
|
|
518
411
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
519
412
|
}
|
|
520
|
-
const
|
|
521
|
-
const numBytes =
|
|
413
|
+
const bytes = base58Encoder.encode(putativeBlockhash);
|
|
414
|
+
const numBytes = bytes.byteLength;
|
|
522
415
|
if (numBytes !== 32) {
|
|
523
416
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
524
417
|
}
|
|
@@ -603,7 +496,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
603
496
|
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
604
497
|
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
605
498
|
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
|
|
499
|
+
instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
|
|
607
500
|
}
|
|
608
501
|
function isAdvanceNonceAccountInstructionData(data) {
|
|
609
502
|
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
@@ -611,21 +504,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
611
504
|
function isDurableNonceTransaction(transaction) {
|
|
612
505
|
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
613
506
|
}
|
|
507
|
+
function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
|
|
508
|
+
return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
|
|
509
|
+
}
|
|
614
510
|
function setTransactionLifetimeUsingDurableNonce({
|
|
615
511
|
nonce,
|
|
616
512
|
nonceAccountAddress,
|
|
617
513
|
nonceAuthorityAddress
|
|
618
514
|
}, transaction) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
515
|
+
let newInstructions;
|
|
516
|
+
const firstInstruction = transaction.instructions[0];
|
|
517
|
+
if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
518
|
+
if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
|
|
519
|
+
if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
|
|
520
|
+
return transaction;
|
|
521
|
+
} else {
|
|
522
|
+
newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
|
|
523
|
+
}
|
|
524
|
+
} else {
|
|
525
|
+
newInstructions = [
|
|
526
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
527
|
+
...transaction.instructions.slice(1)
|
|
528
|
+
];
|
|
529
|
+
}
|
|
530
|
+
} else {
|
|
531
|
+
newInstructions = [
|
|
532
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
533
|
+
...transaction.instructions
|
|
534
|
+
];
|
|
622
535
|
}
|
|
623
536
|
const out = {
|
|
624
537
|
...getUnsignedTransaction(transaction),
|
|
625
|
-
instructions:
|
|
626
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
627
|
-
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
628
|
-
],
|
|
538
|
+
instructions: newInstructions,
|
|
629
539
|
lifetimeConstraint: {
|
|
630
540
|
nonce
|
|
631
541
|
}
|
|
@@ -665,335 +575,182 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
665
575
|
return out;
|
|
666
576
|
}
|
|
667
577
|
|
|
668
|
-
// ../codecs-
|
|
669
|
-
function
|
|
670
|
-
|
|
671
|
-
throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
|
|
675
|
-
const bytesLength = bytes2.length - offset;
|
|
676
|
-
if (bytesLength < expected) {
|
|
677
|
-
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
678
|
-
}
|
|
578
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
579
|
+
function sumCodecSizes(sizes) {
|
|
580
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
679
581
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
684
|
-
}
|
|
685
|
-
if (nonEmptyByteArrays.length === 1) {
|
|
686
|
-
return nonEmptyByteArrays[0];
|
|
687
|
-
}
|
|
688
|
-
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
689
|
-
const result = new Uint8Array(totalLength);
|
|
690
|
-
let offset = 0;
|
|
691
|
-
nonEmptyByteArrays.forEach((arr) => {
|
|
692
|
-
result.set(arr, offset);
|
|
693
|
-
offset += arr.length;
|
|
694
|
-
});
|
|
695
|
-
return result;
|
|
696
|
-
};
|
|
697
|
-
var padBytes2 = (bytes2, length) => {
|
|
698
|
-
if (bytes2.length >= length)
|
|
699
|
-
return bytes2;
|
|
700
|
-
const paddedBytes = new Uint8Array(length).fill(0);
|
|
701
|
-
paddedBytes.set(bytes2);
|
|
702
|
-
return paddedBytes;
|
|
703
|
-
};
|
|
704
|
-
var fixBytes2 = (bytes2, length) => padBytes2(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
|
|
705
|
-
function combineCodec(encoder, decoder, description) {
|
|
706
|
-
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
707
|
-
throw new Error(
|
|
708
|
-
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
709
|
-
);
|
|
582
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
583
|
+
if (typeof size === "number") {
|
|
584
|
+
return [size, offset];
|
|
710
585
|
}
|
|
711
|
-
if (
|
|
712
|
-
|
|
713
|
-
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
714
|
-
);
|
|
586
|
+
if (typeof size === "object") {
|
|
587
|
+
return size.decode(bytes, offset);
|
|
715
588
|
}
|
|
716
|
-
if (
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
589
|
+
if (size === "remainder") {
|
|
590
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
591
|
+
if (childrenSize === null) {
|
|
592
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
593
|
+
}
|
|
594
|
+
const remainder = bytes.slice(offset).length;
|
|
595
|
+
if (remainder % childrenSize !== 0) {
|
|
596
|
+
throw new Error(
|
|
597
|
+
`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.`
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
return [remainder / childrenSize, offset];
|
|
720
601
|
}
|
|
721
|
-
|
|
722
|
-
decode: decoder.decode,
|
|
723
|
-
description: description ?? encoder.description,
|
|
724
|
-
encode: encoder.encode,
|
|
725
|
-
fixedSize: encoder.fixedSize,
|
|
726
|
-
maxSize: encoder.maxSize
|
|
727
|
-
};
|
|
602
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
728
603
|
}
|
|
729
|
-
function
|
|
730
|
-
return {
|
|
731
|
-
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
732
|
-
fixedSize: fixedBytes,
|
|
733
|
-
maxSize: fixedBytes
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
function fixEncoder(encoder, fixedBytes, description) {
|
|
737
|
-
return {
|
|
738
|
-
...fixCodecHelper(encoder, fixedBytes, description),
|
|
739
|
-
encode: (value) => fixBytes2(encoder.encode(value), fixedBytes)
|
|
740
|
-
};
|
|
604
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
605
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
741
606
|
}
|
|
742
|
-
function
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
}
|
|
750
|
-
if (decoder.fixedSize !== null) {
|
|
751
|
-
bytes2 = fixBytes2(bytes2, decoder.fixedSize);
|
|
752
|
-
}
|
|
753
|
-
const [value] = decoder.decode(bytes2, 0);
|
|
754
|
-
return [value, offset + fixedBytes];
|
|
755
|
-
}
|
|
756
|
-
};
|
|
607
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
608
|
+
if (typeof size !== "number")
|
|
609
|
+
return null;
|
|
610
|
+
if (size === 0)
|
|
611
|
+
return 0;
|
|
612
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
613
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
757
614
|
}
|
|
758
|
-
function
|
|
759
|
-
return
|
|
760
|
-
description: encoder.description,
|
|
761
|
-
encode: (value) => encoder.encode(unmap(value)),
|
|
762
|
-
fixedSize: encoder.fixedSize,
|
|
763
|
-
maxSize: encoder.maxSize
|
|
764
|
-
};
|
|
615
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
616
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
765
617
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (value < min || value > max) {
|
|
770
|
-
throw new Error(
|
|
771
|
-
`Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
|
|
772
|
-
);
|
|
618
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
619
|
+
if (expected !== actual) {
|
|
620
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
773
621
|
}
|
|
774
622
|
}
|
|
775
|
-
function
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
if (input.size > 1) {
|
|
779
|
-
littleEndian = !("endian" in input.options) || input.options.endian === 0;
|
|
780
|
-
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
623
|
+
function arrayCodecHelper(item, size, description) {
|
|
624
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
625
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
781
626
|
}
|
|
782
627
|
return {
|
|
783
|
-
description:
|
|
784
|
-
fixedSize:
|
|
785
|
-
|
|
786
|
-
maxSize: input.size
|
|
628
|
+
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
629
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
630
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
787
631
|
};
|
|
788
632
|
}
|
|
789
|
-
function
|
|
790
|
-
const
|
|
633
|
+
function getArrayEncoder(item, options = {}) {
|
|
634
|
+
const size = options.size ?? getU32Encoder();
|
|
791
635
|
return {
|
|
792
|
-
|
|
793
|
-
encode(value) {
|
|
794
|
-
if (
|
|
795
|
-
|
|
636
|
+
...arrayCodecHelper(item, size, options.description),
|
|
637
|
+
encode: (value) => {
|
|
638
|
+
if (typeof size === "number") {
|
|
639
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
796
640
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
return new Uint8Array(arrayBuffer);
|
|
800
|
-
},
|
|
801
|
-
fixedSize: codecData.fixedSize,
|
|
802
|
-
maxSize: codecData.maxSize
|
|
803
|
-
};
|
|
804
|
-
}
|
|
805
|
-
function numberDecoderFactory(input) {
|
|
806
|
-
const codecData = sharedNumberFactory(input);
|
|
807
|
-
return {
|
|
808
|
-
decode(bytes2, offset = 0) {
|
|
809
|
-
assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
|
|
810
|
-
assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
|
|
811
|
-
const view = new DataView(toArrayBuffer2(bytes2, offset, input.size));
|
|
812
|
-
return [input.get(view, codecData.littleEndian), offset + input.size];
|
|
813
|
-
},
|
|
814
|
-
description: codecData.description,
|
|
815
|
-
fixedSize: codecData.fixedSize,
|
|
816
|
-
maxSize: codecData.maxSize
|
|
641
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
642
|
+
}
|
|
817
643
|
};
|
|
818
644
|
}
|
|
819
|
-
function
|
|
820
|
-
const
|
|
821
|
-
const bytesLength = length ?? bytes2.byteLength;
|
|
822
|
-
return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
823
|
-
}
|
|
824
|
-
var getU32Encoder = (options = {}) => numberEncoderFactory({
|
|
825
|
-
name: "u32",
|
|
826
|
-
options,
|
|
827
|
-
range: [0, Number("0xffffffff")],
|
|
828
|
-
set: (view, value, le) => view.setUint32(0, value, le),
|
|
829
|
-
size: 4
|
|
830
|
-
});
|
|
831
|
-
var getU32Decoder = (options = {}) => numberDecoderFactory({
|
|
832
|
-
get: (view, le) => view.getUint32(0, le),
|
|
833
|
-
name: "u32",
|
|
834
|
-
options,
|
|
835
|
-
size: 4
|
|
836
|
-
});
|
|
837
|
-
var getU8Encoder = (options = {}) => numberEncoderFactory({
|
|
838
|
-
name: "u8",
|
|
839
|
-
options,
|
|
840
|
-
range: [0, Number("0xff")],
|
|
841
|
-
set: (view, value) => view.setUint8(0, value),
|
|
842
|
-
size: 1
|
|
843
|
-
});
|
|
844
|
-
var getU8Decoder = (options = {}) => numberDecoderFactory({
|
|
845
|
-
get: (view) => view.getUint8(0),
|
|
846
|
-
name: "u8",
|
|
847
|
-
options,
|
|
848
|
-
size: 1
|
|
849
|
-
});
|
|
850
|
-
var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
|
|
851
|
-
|
|
852
|
-
// ../codecs-strings/dist/index.browser.js
|
|
853
|
-
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
854
|
-
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
855
|
-
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
var getBaseXEncoder = (alphabet4) => {
|
|
859
|
-
const base = alphabet4.length;
|
|
860
|
-
const baseBigInt = BigInt(base);
|
|
645
|
+
function getArrayDecoder(item, options = {}) {
|
|
646
|
+
const size = options.size ?? getU32Decoder();
|
|
861
647
|
return {
|
|
862
|
-
description
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
return new Uint8Array();
|
|
867
|
-
const chars = [...value];
|
|
868
|
-
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
869
|
-
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
870
|
-
const leadingZeroes = Array(trailIndex).fill(0);
|
|
871
|
-
if (trailIndex === chars.length)
|
|
872
|
-
return Uint8Array.from(leadingZeroes);
|
|
873
|
-
const tailChars = chars.slice(trailIndex);
|
|
874
|
-
let base10Number = 0n;
|
|
875
|
-
let baseXPower = 1n;
|
|
876
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
877
|
-
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
878
|
-
baseXPower *= baseBigInt;
|
|
879
|
-
}
|
|
880
|
-
const tailBytes = [];
|
|
881
|
-
while (base10Number > 0n) {
|
|
882
|
-
tailBytes.unshift(Number(base10Number % 256n));
|
|
883
|
-
base10Number /= 256n;
|
|
648
|
+
...arrayCodecHelper(item, size, options.description),
|
|
649
|
+
decode: (bytes, offset = 0) => {
|
|
650
|
+
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
651
|
+
return [[], offset];
|
|
884
652
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
const base = alphabet4.length;
|
|
893
|
-
const baseBigInt = BigInt(base);
|
|
894
|
-
return {
|
|
895
|
-
decode(rawBytes, offset = 0) {
|
|
896
|
-
const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
897
|
-
if (bytes2.length === 0)
|
|
898
|
-
return ["", 0];
|
|
899
|
-
let trailIndex = bytes2.findIndex((n) => n !== 0);
|
|
900
|
-
trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
|
|
901
|
-
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
902
|
-
if (trailIndex === bytes2.length)
|
|
903
|
-
return [leadingZeroes, rawBytes.length];
|
|
904
|
-
let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
905
|
-
const tailChars = [];
|
|
906
|
-
while (base10Number > 0n) {
|
|
907
|
-
tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
|
|
908
|
-
base10Number /= baseBigInt;
|
|
653
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
|
|
654
|
+
offset = newOffset;
|
|
655
|
+
const values = [];
|
|
656
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
657
|
+
const [value, newOffset2] = item.decode(bytes, offset);
|
|
658
|
+
values.push(value);
|
|
659
|
+
offset = newOffset2;
|
|
909
660
|
}
|
|
910
|
-
return [
|
|
911
|
-
}
|
|
912
|
-
description: `base${base}`,
|
|
913
|
-
fixedSize: null,
|
|
914
|
-
maxSize: null
|
|
915
|
-
};
|
|
916
|
-
};
|
|
917
|
-
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
918
|
-
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
919
|
-
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
920
|
-
var removeNullCharacters2 = (value) => (
|
|
921
|
-
// eslint-disable-next-line no-control-regex
|
|
922
|
-
value.replace(/\u0000/g, "")
|
|
923
|
-
);
|
|
924
|
-
var e = globalThis.TextDecoder;
|
|
925
|
-
var o = globalThis.TextEncoder;
|
|
926
|
-
var getUtf8Encoder = () => {
|
|
927
|
-
let textEncoder;
|
|
928
|
-
return {
|
|
929
|
-
description: "utf8",
|
|
930
|
-
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
931
|
-
fixedSize: null,
|
|
932
|
-
maxSize: null
|
|
661
|
+
return [values, offset];
|
|
662
|
+
}
|
|
933
663
|
};
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
description: "utf8",
|
|
664
|
+
}
|
|
665
|
+
function getBytesEncoder(options = {}) {
|
|
666
|
+
const size = options.size ?? "variable";
|
|
667
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
668
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
669
|
+
const byteEncoder = {
|
|
670
|
+
description,
|
|
671
|
+
encode: (value) => value,
|
|
943
672
|
fixedSize: null,
|
|
944
673
|
maxSize: null
|
|
945
|
-
};
|
|
946
|
-
};
|
|
947
|
-
var getStringEncoder = (options = {}) => {
|
|
948
|
-
const size = options.size ?? getU32Encoder();
|
|
949
|
-
const encoding = options.encoding ?? getUtf8Encoder();
|
|
950
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
674
|
+
};
|
|
951
675
|
if (size === "variable") {
|
|
952
|
-
return
|
|
676
|
+
return byteEncoder;
|
|
953
677
|
}
|
|
954
678
|
if (typeof size === "number") {
|
|
955
|
-
return fixEncoder(
|
|
679
|
+
return fixEncoder(byteEncoder, size, description);
|
|
956
680
|
}
|
|
957
681
|
return {
|
|
958
|
-
|
|
682
|
+
...byteEncoder,
|
|
959
683
|
encode: (value) => {
|
|
960
|
-
const contentBytes =
|
|
684
|
+
const contentBytes = byteEncoder.encode(value);
|
|
961
685
|
const lengthBytes = size.encode(contentBytes.length);
|
|
962
|
-
return
|
|
686
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
function getBytesDecoder(options = {}) {
|
|
691
|
+
const size = options.size ?? "variable";
|
|
692
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
693
|
+
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
694
|
+
const byteDecoder = {
|
|
695
|
+
decode: (bytes, offset = 0) => {
|
|
696
|
+
const slice = bytes.slice(offset);
|
|
697
|
+
return [slice, offset + slice.length];
|
|
963
698
|
},
|
|
699
|
+
description,
|
|
964
700
|
fixedSize: null,
|
|
965
701
|
maxSize: null
|
|
966
702
|
};
|
|
967
|
-
};
|
|
968
|
-
var getStringDecoder = (options = {}) => {
|
|
969
|
-
const size = options.size ?? getU32Decoder();
|
|
970
|
-
const encoding = options.encoding ?? getUtf8Decoder();
|
|
971
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
|
|
972
703
|
if (size === "variable") {
|
|
973
|
-
return
|
|
704
|
+
return byteDecoder;
|
|
974
705
|
}
|
|
975
706
|
if (typeof size === "number") {
|
|
976
|
-
return fixDecoder(
|
|
707
|
+
return fixDecoder(byteDecoder, size, description);
|
|
977
708
|
}
|
|
978
709
|
return {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
710
|
+
...byteDecoder,
|
|
711
|
+
decode: (bytes, offset = 0) => {
|
|
712
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
713
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
982
714
|
const length = Number(lengthBigInt);
|
|
983
715
|
offset = lengthOffset;
|
|
984
|
-
const contentBytes =
|
|
985
|
-
assertByteArrayHasEnoughBytesForCodec("
|
|
986
|
-
const [value, contentOffset] =
|
|
716
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
717
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
718
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
987
719
|
offset += contentOffset;
|
|
988
720
|
return [value, offset];
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
function structCodecHelper(fields, description) {
|
|
725
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
726
|
+
return {
|
|
727
|
+
description: description ?? `struct(${fieldDescriptions})`,
|
|
728
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
729
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function getStructEncoder(fields, options = {}) {
|
|
733
|
+
return {
|
|
734
|
+
...structCodecHelper(fields, options.description),
|
|
735
|
+
encode: (struct) => {
|
|
736
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
737
|
+
return mergeBytes(fieldBytes);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
function getStructDecoder(fields, options = {}) {
|
|
742
|
+
return {
|
|
743
|
+
...structCodecHelper(fields, options.description),
|
|
744
|
+
decode: (bytes, offset = 0) => {
|
|
745
|
+
const struct = {};
|
|
746
|
+
fields.forEach(([key, codec]) => {
|
|
747
|
+
const [value, newOffset] = codec.decode(bytes, offset);
|
|
748
|
+
offset = newOffset;
|
|
749
|
+
struct[key] = value;
|
|
750
|
+
});
|
|
751
|
+
return [struct, offset];
|
|
752
|
+
}
|
|
993
753
|
};
|
|
994
|
-
};
|
|
995
|
-
function getSizeDescription2(size) {
|
|
996
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
997
754
|
}
|
|
998
755
|
|
|
999
756
|
// ../assertions/dist/index.browser.js
|
|
@@ -1030,35 +787,35 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1030
787
|
memoizedBase58Decoder = getBase58Decoder();
|
|
1031
788
|
return memoizedBase58Decoder;
|
|
1032
789
|
}
|
|
1033
|
-
function assertIsAddress(
|
|
790
|
+
function assertIsAddress(putativeAddress) {
|
|
1034
791
|
try {
|
|
1035
792
|
if (
|
|
1036
793
|
// Lowest address (32 bytes of zeroes)
|
|
1037
|
-
|
|
1038
|
-
|
|
794
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
795
|
+
putativeAddress.length > 44
|
|
1039
796
|
) {
|
|
1040
797
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
1041
798
|
}
|
|
1042
|
-
const
|
|
1043
|
-
const
|
|
1044
|
-
const numBytes =
|
|
799
|
+
const base58Encoder2 = getMemoizedBase58Encoder();
|
|
800
|
+
const bytes = base58Encoder2.encode(putativeAddress);
|
|
801
|
+
const numBytes = bytes.byteLength;
|
|
1045
802
|
if (numBytes !== 32) {
|
|
1046
803
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
1047
804
|
}
|
|
1048
805
|
} catch (e2) {
|
|
1049
|
-
throw new Error(`\`${
|
|
806
|
+
throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
|
|
1050
807
|
cause: e2
|
|
1051
808
|
});
|
|
1052
809
|
}
|
|
1053
810
|
}
|
|
1054
|
-
function address(
|
|
1055
|
-
assertIsAddress(
|
|
1056
|
-
return
|
|
811
|
+
function address(putativeAddress) {
|
|
812
|
+
assertIsAddress(putativeAddress);
|
|
813
|
+
return putativeAddress;
|
|
1057
814
|
}
|
|
1058
815
|
function getAddressEncoder(config) {
|
|
1059
816
|
return mapEncoder(
|
|
1060
817
|
getStringEncoder({
|
|
1061
|
-
description: config?.description ?? "
|
|
818
|
+
description: config?.description ?? "Address",
|
|
1062
819
|
encoding: getMemoizedBase58Encoder(),
|
|
1063
820
|
size: 32
|
|
1064
821
|
}),
|
|
@@ -1067,14 +824,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1067
824
|
}
|
|
1068
825
|
function getAddressDecoder(config) {
|
|
1069
826
|
return getStringDecoder({
|
|
1070
|
-
description: config?.description ?? "
|
|
827
|
+
description: config?.description ?? "Address",
|
|
1071
828
|
encoding: getMemoizedBase58Decoder(),
|
|
1072
829
|
size: 32
|
|
1073
830
|
});
|
|
1074
831
|
}
|
|
1075
|
-
function getAddressCodec(config) {
|
|
1076
|
-
return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
|
|
1077
|
-
}
|
|
1078
832
|
function getAddressComparator() {
|
|
1079
833
|
return new Intl.Collator("en", {
|
|
1080
834
|
caseFirst: "lower",
|
|
@@ -1383,116 +1137,230 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1383
1137
|
};
|
|
1384
1138
|
}
|
|
1385
1139
|
|
|
1386
|
-
//
|
|
1387
|
-
function
|
|
1388
|
-
|
|
1140
|
+
// ../functional/dist/index.browser.js
|
|
1141
|
+
function pipe(init, ...fns) {
|
|
1142
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// src/decompile-transaction.ts
|
|
1146
|
+
function getAccountMetas(message) {
|
|
1147
|
+
const { header } = message;
|
|
1148
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
1149
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
1150
|
+
const accountMetas = [];
|
|
1151
|
+
let accountIndex = 0;
|
|
1152
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
1153
|
+
accountMetas.push({
|
|
1154
|
+
address: message.staticAccounts[accountIndex],
|
|
1155
|
+
role: AccountRole.WRITABLE_SIGNER
|
|
1156
|
+
});
|
|
1157
|
+
accountIndex++;
|
|
1158
|
+
}
|
|
1159
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
1160
|
+
accountMetas.push({
|
|
1161
|
+
address: message.staticAccounts[accountIndex],
|
|
1162
|
+
role: AccountRole.READONLY_SIGNER
|
|
1163
|
+
});
|
|
1164
|
+
accountIndex++;
|
|
1165
|
+
}
|
|
1166
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
1167
|
+
accountMetas.push({
|
|
1168
|
+
address: message.staticAccounts[accountIndex],
|
|
1169
|
+
role: AccountRole.WRITABLE
|
|
1170
|
+
});
|
|
1171
|
+
accountIndex++;
|
|
1172
|
+
}
|
|
1173
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
1174
|
+
accountMetas.push({
|
|
1175
|
+
address: message.staticAccounts[accountIndex],
|
|
1176
|
+
role: AccountRole.READONLY
|
|
1177
|
+
});
|
|
1178
|
+
accountIndex++;
|
|
1179
|
+
}
|
|
1180
|
+
return accountMetas;
|
|
1181
|
+
}
|
|
1182
|
+
function convertInstruction(instruction, accountMetas) {
|
|
1183
|
+
const programAddress = accountMetas[instruction.programAddressIndex]?.address;
|
|
1184
|
+
if (!programAddress) {
|
|
1185
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
1186
|
+
}
|
|
1187
|
+
const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
|
|
1188
|
+
const { data } = instruction;
|
|
1389
1189
|
return {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
maxSize: codec.maxSize,
|
|
1394
|
-
serialize: codec.encode
|
|
1190
|
+
programAddress,
|
|
1191
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
1192
|
+
...data && data.length ? { data } : {}
|
|
1395
1193
|
};
|
|
1396
1194
|
}
|
|
1397
|
-
function
|
|
1398
|
-
|
|
1399
|
-
|
|
1195
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
1196
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1197
|
+
return {
|
|
1198
|
+
blockhash: messageLifetimeToken,
|
|
1199
|
+
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
1200
|
+
// U64 MAX
|
|
1201
|
+
};
|
|
1202
|
+
} else {
|
|
1203
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
1204
|
+
assertIsAddress(nonceAccountAddress);
|
|
1205
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
1206
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
1207
|
+
return {
|
|
1208
|
+
nonce: messageLifetimeToken,
|
|
1209
|
+
nonceAccountAddress,
|
|
1210
|
+
nonceAuthorityAddress
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
function convertSignatures(compiledTransaction) {
|
|
1215
|
+
const {
|
|
1216
|
+
compiledMessage: { staticAccounts },
|
|
1217
|
+
signatures
|
|
1218
|
+
} = compiledTransaction;
|
|
1219
|
+
return signatures.reduce((acc, sig, index) => {
|
|
1220
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
1221
|
+
if (allZeros)
|
|
1222
|
+
return acc;
|
|
1223
|
+
const address2 = staticAccounts[index];
|
|
1224
|
+
return { ...acc, [address2]: sig };
|
|
1225
|
+
}, {});
|
|
1226
|
+
}
|
|
1227
|
+
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
1228
|
+
const { compiledMessage } = compiledTransaction;
|
|
1229
|
+
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
1230
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
1231
|
+
}
|
|
1232
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
1233
|
+
if (!feePayer)
|
|
1234
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
1235
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
1236
|
+
const instructions = compiledMessage.instructions.map(
|
|
1237
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
1238
|
+
);
|
|
1239
|
+
const firstInstruction = instructions[0];
|
|
1240
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
1241
|
+
compiledMessage.lifetimeToken,
|
|
1242
|
+
firstInstruction,
|
|
1243
|
+
lastValidBlockHeight
|
|
1244
|
+
);
|
|
1245
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
1246
|
+
return pipe(
|
|
1247
|
+
createTransaction({ version: compiledMessage.version }),
|
|
1248
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
1249
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
1250
|
+
return appendTransactionInstruction(instruction, acc);
|
|
1251
|
+
}, tx),
|
|
1252
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
1253
|
+
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// src/serializers/address-table-lookup.ts
|
|
1258
|
+
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
1259
|
+
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
1260
|
+
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
1261
|
+
var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
|
|
1262
|
+
var memoizedAddressTableLookupEncoder;
|
|
1263
|
+
function getAddressTableLookupEncoder() {
|
|
1264
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
1265
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
1400
1266
|
[
|
|
1401
|
-
"lookupTableAddress",
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1267
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
1268
|
+
[
|
|
1269
|
+
"writableIndices",
|
|
1270
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1271
|
+
description: writableIndicesDescription,
|
|
1272
|
+
size: getShortU16Encoder()
|
|
1273
|
+
})
|
|
1274
|
+
],
|
|
1275
|
+
[
|
|
1276
|
+
"readableIndices",
|
|
1277
|
+
getArrayEncoder(getU8Encoder(), {
|
|
1278
|
+
description: readableIndicesDescription,
|
|
1279
|
+
size: getShortU16Encoder()
|
|
1280
|
+
})
|
|
1281
|
+
]
|
|
1407
1282
|
],
|
|
1283
|
+
{ description: addressTableLookupDescription }
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
return memoizedAddressTableLookupEncoder;
|
|
1287
|
+
}
|
|
1288
|
+
var memoizedAddressTableLookupDecoder;
|
|
1289
|
+
function getAddressTableLookupDecoder() {
|
|
1290
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
1291
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1408
1292
|
[
|
|
1409
|
-
"
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1293
|
+
["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
|
|
1294
|
+
[
|
|
1295
|
+
"writableIndices",
|
|
1296
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1297
|
+
description: writableIndicesDescription,
|
|
1298
|
+
size: getShortU16Decoder()
|
|
1299
|
+
})
|
|
1300
|
+
],
|
|
1301
|
+
[
|
|
1302
|
+
"readableIndices",
|
|
1303
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1304
|
+
description: readableIndicesDescription,
|
|
1305
|
+
size: getShortU16Decoder()
|
|
1306
|
+
})
|
|
1307
|
+
]
|
|
1416
1308
|
],
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
description: "The indices of the accounts in the lookup table that should be loaded as read-only"
|
|
1422
|
-
} ,
|
|
1423
|
-
size: shortU16()
|
|
1424
|
-
})
|
|
1425
|
-
]
|
|
1426
|
-
],
|
|
1427
|
-
{
|
|
1428
|
-
description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
|
|
1429
|
-
}
|
|
1430
|
-
);
|
|
1309
|
+
{ description: addressTableLookupDescription }
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
return memoizedAddressTableLookupDecoder;
|
|
1431
1313
|
}
|
|
1432
1314
|
|
|
1433
|
-
//
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1443
|
-
};
|
|
1444
|
-
}
|
|
1445
|
-
function getStructEncoder(fields, options = {}) {
|
|
1446
|
-
return {
|
|
1447
|
-
...structCodecHelper(fields, options.description),
|
|
1448
|
-
encode: (struct2) => {
|
|
1449
|
-
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
|
|
1450
|
-
return mergeBytes2(fieldBytes);
|
|
1451
|
-
}
|
|
1452
|
-
};
|
|
1453
|
-
}
|
|
1454
|
-
function getStructDecoder(fields, options = {}) {
|
|
1315
|
+
// src/serializers/header.ts
|
|
1316
|
+
var memoizedU8Encoder;
|
|
1317
|
+
function getMemoizedU8Encoder() {
|
|
1318
|
+
if (!memoizedU8Encoder)
|
|
1319
|
+
memoizedU8Encoder = getU8Encoder();
|
|
1320
|
+
return memoizedU8Encoder;
|
|
1321
|
+
}
|
|
1322
|
+
function getMemoizedU8EncoderDescription(description) {
|
|
1323
|
+
const encoder = getMemoizedU8Encoder();
|
|
1455
1324
|
return {
|
|
1456
|
-
...
|
|
1457
|
-
|
|
1458
|
-
const struct2 = {};
|
|
1459
|
-
fields.forEach(([key, codec]) => {
|
|
1460
|
-
const [value, newOffset] = codec.decode(bytes2, offset);
|
|
1461
|
-
offset = newOffset;
|
|
1462
|
-
struct2[key] = value;
|
|
1463
|
-
});
|
|
1464
|
-
return [struct2, offset];
|
|
1465
|
-
}
|
|
1325
|
+
...encoder,
|
|
1326
|
+
description: description ?? encoder.description
|
|
1466
1327
|
};
|
|
1467
1328
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1329
|
+
var memoizedU8Decoder;
|
|
1330
|
+
function getMemoizedU8Decoder() {
|
|
1331
|
+
if (!memoizedU8Decoder)
|
|
1332
|
+
memoizedU8Decoder = getU8Decoder();
|
|
1333
|
+
return memoizedU8Decoder;
|
|
1470
1334
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
var memoizedU8Codec;
|
|
1474
|
-
function getMemoizedU8Codec() {
|
|
1475
|
-
if (!memoizedU8Codec)
|
|
1476
|
-
memoizedU8Codec = getU8Codec();
|
|
1477
|
-
return memoizedU8Codec;
|
|
1478
|
-
}
|
|
1479
|
-
function getMemoizedU8CodecDescription(description) {
|
|
1480
|
-
const codec = getMemoizedU8Codec();
|
|
1335
|
+
function getMemoizedU8DecoderDescription(description) {
|
|
1336
|
+
const decoder = getMemoizedU8Decoder();
|
|
1481
1337
|
return {
|
|
1482
|
-
...
|
|
1483
|
-
description: description ??
|
|
1338
|
+
...decoder,
|
|
1339
|
+
description: description ?? decoder.description
|
|
1484
1340
|
};
|
|
1485
1341
|
}
|
|
1486
1342
|
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
1487
1343
|
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" ;
|
|
1488
1344
|
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
1489
1345
|
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1490
|
-
function
|
|
1491
|
-
return
|
|
1346
|
+
function getMessageHeaderEncoder() {
|
|
1347
|
+
return getStructEncoder(
|
|
1348
|
+
[
|
|
1349
|
+
["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
|
|
1350
|
+
["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
|
|
1351
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1352
|
+
],
|
|
1353
|
+
{
|
|
1354
|
+
description: messageHeaderDescription
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
function getMessageHeaderDecoder() {
|
|
1359
|
+
return getStructDecoder(
|
|
1492
1360
|
[
|
|
1493
|
-
["numSignerAccounts",
|
|
1494
|
-
["numReadonlySignerAccounts",
|
|
1495
|
-
["numReadonlyNonSignerAccounts",
|
|
1361
|
+
["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
|
|
1362
|
+
["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
|
|
1363
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1496
1364
|
],
|
|
1497
1365
|
{
|
|
1498
1366
|
description: messageHeaderDescription
|
|
@@ -1501,59 +1369,70 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1501
1369
|
}
|
|
1502
1370
|
|
|
1503
1371
|
// src/serializers/instruction.ts
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
)
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
)
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
]
|
|
1534
|
-
]),
|
|
1535
|
-
(value) => {
|
|
1536
|
-
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
1537
|
-
return value;
|
|
1372
|
+
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
1373
|
+
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
1374
|
+
var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
|
|
1375
|
+
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
1376
|
+
var memoizedGetInstructionEncoder;
|
|
1377
|
+
function getInstructionEncoder() {
|
|
1378
|
+
if (!memoizedGetInstructionEncoder) {
|
|
1379
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
1380
|
+
getStructEncoder([
|
|
1381
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
1382
|
+
[
|
|
1383
|
+
"accountIndices",
|
|
1384
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
1385
|
+
description: accountIndicesDescription,
|
|
1386
|
+
size: getShortU16Encoder()
|
|
1387
|
+
})
|
|
1388
|
+
],
|
|
1389
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
1390
|
+
]),
|
|
1391
|
+
// Convert an instruction to have all fields defined
|
|
1392
|
+
(instruction) => {
|
|
1393
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1394
|
+
return instruction;
|
|
1395
|
+
}
|
|
1396
|
+
return {
|
|
1397
|
+
...instruction,
|
|
1398
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
1399
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
1400
|
+
};
|
|
1538
1401
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1402
|
+
);
|
|
1403
|
+
}
|
|
1404
|
+
return memoizedGetInstructionEncoder;
|
|
1405
|
+
}
|
|
1406
|
+
var memoizedGetInstructionDecoder;
|
|
1407
|
+
function getInstructionDecoder() {
|
|
1408
|
+
if (!memoizedGetInstructionDecoder) {
|
|
1409
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
1410
|
+
getStructDecoder([
|
|
1411
|
+
["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
|
|
1412
|
+
[
|
|
1413
|
+
"accountIndices",
|
|
1414
|
+
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
1415
|
+
description: accountIndicesDescription,
|
|
1416
|
+
size: getShortU16Decoder()
|
|
1417
|
+
})
|
|
1418
|
+
],
|
|
1419
|
+
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
1420
|
+
]),
|
|
1421
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
1422
|
+
(instruction) => {
|
|
1423
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
1424
|
+
return instruction;
|
|
1425
|
+
}
|
|
1426
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
1427
|
+
return {
|
|
1428
|
+
...rest,
|
|
1429
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1430
|
+
...data.byteLength ? { data } : null
|
|
1431
|
+
};
|
|
1548
1432
|
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
...accountIndices.length ? { accountIndices } : null,
|
|
1553
|
-
...data.byteLength ? { data } : null
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
);
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1435
|
+
return memoizedGetInstructionDecoder;
|
|
1557
1436
|
}
|
|
1558
1437
|
|
|
1559
1438
|
// src/serializers/transaction-version.ts
|
|
@@ -1563,8 +1442,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1563
1442
|
fixedSize: null,
|
|
1564
1443
|
maxSize: 1
|
|
1565
1444
|
};
|
|
1566
|
-
function decode(
|
|
1567
|
-
const firstByte =
|
|
1445
|
+
function decode(bytes, offset = 0) {
|
|
1446
|
+
const firstByte = bytes[offset];
|
|
1568
1447
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1569
1448
|
return ["legacy", offset];
|
|
1570
1449
|
} else {
|
|
@@ -1593,126 +1472,181 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1593
1472
|
encode
|
|
1594
1473
|
};
|
|
1595
1474
|
}
|
|
1596
|
-
function getTransactionVersionCodec() {
|
|
1597
|
-
return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
// src/serializers/unimplemented.ts
|
|
1601
|
-
function getError(type, name) {
|
|
1602
|
-
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
1603
|
-
return new Error(
|
|
1604
|
-
`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}`
|
|
1605
|
-
);
|
|
1606
|
-
}
|
|
1607
|
-
function getUnimplementedDecoder(name) {
|
|
1608
|
-
return () => {
|
|
1609
|
-
throw getError("decoder", name);
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
1475
|
|
|
1613
1476
|
// src/serializers/message.ts
|
|
1614
|
-
var
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
(value)
|
|
1629
|
-
|
|
1630
|
-
return value;
|
|
1631
|
-
}
|
|
1632
|
-
return {
|
|
1633
|
-
...value,
|
|
1634
|
-
addressTableLookups: value.addressTableLookups ?? []
|
|
1635
|
-
};
|
|
1477
|
+
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
|
|
1478
|
+
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
|
|
1479
|
+
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
|
|
1480
|
+
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
|
|
1481
|
+
function getCompiledMessageLegacyEncoder() {
|
|
1482
|
+
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
1483
|
+
}
|
|
1484
|
+
function getCompiledMessageVersionedEncoder() {
|
|
1485
|
+
return mapEncoder(
|
|
1486
|
+
getStructEncoder([
|
|
1487
|
+
...getPreludeStructEncoderTuple(),
|
|
1488
|
+
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1489
|
+
]),
|
|
1490
|
+
(value) => {
|
|
1491
|
+
if (value.version === "legacy") {
|
|
1492
|
+
return value;
|
|
1636
1493
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
deserialize: codec.decode,
|
|
1644
|
-
fixedSize: codec.fixedSize,
|
|
1645
|
-
maxSize: codec.maxSize,
|
|
1646
|
-
serialize: codec.encode
|
|
1647
|
-
};
|
|
1494
|
+
return {
|
|
1495
|
+
...value,
|
|
1496
|
+
addressTableLookups: value.addressTableLookups ?? []
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
);
|
|
1648
1500
|
}
|
|
1649
|
-
function
|
|
1501
|
+
function getPreludeStructEncoderTuple() {
|
|
1650
1502
|
return [
|
|
1651
|
-
["version",
|
|
1652
|
-
["header",
|
|
1503
|
+
["version", getTransactionVersionEncoder()],
|
|
1504
|
+
["header", getMessageHeaderEncoder()],
|
|
1653
1505
|
[
|
|
1654
1506
|
"staticAccounts",
|
|
1655
|
-
|
|
1656
|
-
description:
|
|
1657
|
-
size:
|
|
1507
|
+
getArrayEncoder(getAddressEncoder(), {
|
|
1508
|
+
description: staticAccountsDescription,
|
|
1509
|
+
size: getShortU16Encoder()
|
|
1658
1510
|
})
|
|
1659
1511
|
],
|
|
1660
1512
|
[
|
|
1661
1513
|
"lifetimeToken",
|
|
1662
|
-
|
|
1663
|
-
description:
|
|
1664
|
-
encoding:
|
|
1514
|
+
getStringEncoder({
|
|
1515
|
+
description: lifetimeTokenDescription,
|
|
1516
|
+
encoding: getBase58Encoder(),
|
|
1665
1517
|
size: 32
|
|
1666
1518
|
})
|
|
1667
1519
|
],
|
|
1668
1520
|
[
|
|
1669
1521
|
"instructions",
|
|
1670
|
-
|
|
1671
|
-
description:
|
|
1672
|
-
size:
|
|
1522
|
+
getArrayEncoder(getInstructionEncoder(), {
|
|
1523
|
+
description: instructionsDescription,
|
|
1524
|
+
size: getShortU16Encoder()
|
|
1673
1525
|
})
|
|
1674
1526
|
]
|
|
1675
1527
|
];
|
|
1676
1528
|
}
|
|
1677
|
-
function
|
|
1678
|
-
return
|
|
1679
|
-
|
|
1680
|
-
|
|
1529
|
+
function getPreludeStructDecoderTuple() {
|
|
1530
|
+
return [
|
|
1531
|
+
["version", getTransactionVersionDecoder()],
|
|
1532
|
+
["header", getMessageHeaderDecoder()],
|
|
1533
|
+
[
|
|
1534
|
+
"staticAccounts",
|
|
1535
|
+
getArrayDecoder(getAddressDecoder(), {
|
|
1536
|
+
description: staticAccountsDescription,
|
|
1537
|
+
size: getShortU16Decoder()
|
|
1538
|
+
})
|
|
1539
|
+
],
|
|
1540
|
+
[
|
|
1541
|
+
"lifetimeToken",
|
|
1542
|
+
getStringDecoder({
|
|
1543
|
+
description: lifetimeTokenDescription,
|
|
1544
|
+
encoding: getBase58Decoder(),
|
|
1545
|
+
size: 32
|
|
1546
|
+
})
|
|
1547
|
+
],
|
|
1548
|
+
[
|
|
1549
|
+
"instructions",
|
|
1550
|
+
getArrayDecoder(getInstructionDecoder(), {
|
|
1551
|
+
description: instructionsDescription,
|
|
1552
|
+
size: getShortU16Decoder()
|
|
1553
|
+
})
|
|
1554
|
+
],
|
|
1555
|
+
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
1556
|
+
];
|
|
1557
|
+
}
|
|
1558
|
+
function getAddressTableLookupArrayEncoder() {
|
|
1559
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
1560
|
+
description: addressTableLookupsDescription,
|
|
1561
|
+
size: getShortU16Encoder()
|
|
1681
1562
|
});
|
|
1682
1563
|
}
|
|
1564
|
+
function getAddressTableLookupArrayDecoder() {
|
|
1565
|
+
return getArrayDecoder(getAddressTableLookupDecoder(), {
|
|
1566
|
+
description: addressTableLookupsDescription,
|
|
1567
|
+
size: getShortU16Decoder()
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1683
1571
|
function getCompiledMessageEncoder() {
|
|
1684
1572
|
return {
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1573
|
+
description: messageDescription,
|
|
1574
|
+
encode: (compiledMessage) => {
|
|
1575
|
+
if (compiledMessage.version === "legacy") {
|
|
1576
|
+
return getCompiledMessageLegacyEncoder().encode(compiledMessage);
|
|
1577
|
+
} else {
|
|
1578
|
+
return getCompiledMessageVersionedEncoder().encode(compiledMessage);
|
|
1579
|
+
}
|
|
1580
|
+
},
|
|
1581
|
+
fixedSize: null,
|
|
1582
|
+
maxSize: null
|
|
1688
1583
|
};
|
|
1689
1584
|
}
|
|
1585
|
+
function getCompiledMessageDecoder() {
|
|
1586
|
+
return mapDecoder(
|
|
1587
|
+
getStructDecoder(getPreludeStructDecoderTuple(), {
|
|
1588
|
+
description: messageDescription
|
|
1589
|
+
}),
|
|
1590
|
+
({ addressTableLookups, ...restOfMessage }) => {
|
|
1591
|
+
if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
|
|
1592
|
+
return restOfMessage;
|
|
1593
|
+
}
|
|
1594
|
+
return { ...restOfMessage, addressTableLookups };
|
|
1595
|
+
}
|
|
1596
|
+
);
|
|
1597
|
+
}
|
|
1690
1598
|
|
|
1691
1599
|
// src/serializers/transaction.ts
|
|
1692
|
-
var
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
};
|
|
1697
|
-
function serialize2(transaction) {
|
|
1698
|
-
const compiledTransaction = getCompiledTransaction(transaction);
|
|
1699
|
-
return struct([
|
|
1600
|
+
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
1601
|
+
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
1602
|
+
function getCompiledTransactionEncoder() {
|
|
1603
|
+
return getStructEncoder(
|
|
1700
1604
|
[
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1605
|
+
[
|
|
1606
|
+
"signatures",
|
|
1607
|
+
getArrayEncoder(getBytesEncoder({ size: 64 }), {
|
|
1608
|
+
description: signaturesDescription,
|
|
1609
|
+
size: getShortU16Encoder()
|
|
1610
|
+
})
|
|
1611
|
+
],
|
|
1612
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
1613
|
+
],
|
|
1614
|
+
{
|
|
1615
|
+
description: transactionDescription
|
|
1616
|
+
}
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
function getSignatureDecoder() {
|
|
1620
|
+
return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
|
|
1621
|
+
}
|
|
1622
|
+
function getCompiledTransactionDecoder() {
|
|
1623
|
+
return getStructDecoder(
|
|
1624
|
+
[
|
|
1625
|
+
[
|
|
1626
|
+
"signatures",
|
|
1627
|
+
getArrayDecoder(getSignatureDecoder(), {
|
|
1628
|
+
description: signaturesDescription,
|
|
1629
|
+
size: getShortU16Decoder()
|
|
1630
|
+
})
|
|
1631
|
+
],
|
|
1632
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
1706
1633
|
],
|
|
1707
|
-
|
|
1708
|
-
|
|
1634
|
+
{
|
|
1635
|
+
description: transactionDescription
|
|
1636
|
+
}
|
|
1637
|
+
);
|
|
1709
1638
|
}
|
|
1710
1639
|
function getTransactionEncoder() {
|
|
1711
|
-
return
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1640
|
+
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
1641
|
+
}
|
|
1642
|
+
function getTransactionDecoder(lastValidBlockHeight) {
|
|
1643
|
+
return mapDecoder(
|
|
1644
|
+
getCompiledTransactionDecoder(),
|
|
1645
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
function getTransactionCodec(lastValidBlockHeight) {
|
|
1649
|
+
return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
1716
1650
|
}
|
|
1717
1651
|
|
|
1718
1652
|
// ../keys/dist/index.browser.js
|
|
@@ -1723,64 +1657,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1723
1657
|
}
|
|
1724
1658
|
|
|
1725
1659
|
// src/signatures.ts
|
|
1726
|
-
|
|
1727
|
-
try {
|
|
1728
|
-
if (
|
|
1729
|
-
// Lowest value (64 bytes of zeroes)
|
|
1730
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1731
|
-
putativeTransactionSignature.length > 88
|
|
1732
|
-
) {
|
|
1733
|
-
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1734
|
-
}
|
|
1735
|
-
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1736
|
-
const numBytes = bytes2.byteLength;
|
|
1737
|
-
if (numBytes !== 64) {
|
|
1738
|
-
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1739
|
-
}
|
|
1740
|
-
} catch (e2) {
|
|
1741
|
-
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1742
|
-
cause: e2
|
|
1743
|
-
});
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
function isTransactionSignature(putativeTransactionSignature) {
|
|
1747
|
-
if (
|
|
1748
|
-
// Lowest value (64 bytes of zeroes)
|
|
1749
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1750
|
-
putativeTransactionSignature.length > 88
|
|
1751
|
-
) {
|
|
1752
|
-
return false;
|
|
1753
|
-
}
|
|
1754
|
-
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
1755
|
-
const numBytes = bytes2.byteLength;
|
|
1756
|
-
if (numBytes !== 64) {
|
|
1757
|
-
return false;
|
|
1758
|
-
}
|
|
1759
|
-
return true;
|
|
1760
|
-
}
|
|
1761
|
-
async function getCompiledMessageSignature(message, secretKey) {
|
|
1762
|
-
const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
|
|
1763
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1764
|
-
return signature;
|
|
1765
|
-
}
|
|
1660
|
+
var base58Decoder;
|
|
1766
1661
|
function getSignatureFromTransaction(transaction) {
|
|
1767
|
-
|
|
1768
|
-
|
|
1662
|
+
if (!base58Decoder)
|
|
1663
|
+
base58Decoder = getBase58Decoder();
|
|
1664
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
1665
|
+
if (!signatureBytes) {
|
|
1769
1666
|
throw new Error(
|
|
1770
1667
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1771
1668
|
);
|
|
1772
1669
|
}
|
|
1773
|
-
|
|
1670
|
+
const transactionSignature = base58Decoder.decode(signatureBytes)[0];
|
|
1671
|
+
return transactionSignature;
|
|
1774
1672
|
}
|
|
1775
|
-
async function
|
|
1673
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1776
1674
|
const compiledMessage = compileMessage(transaction);
|
|
1777
1675
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1676
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
1778
1677
|
const publicKeySignaturePairs = await Promise.all(
|
|
1779
1678
|
keyPairs.map(
|
|
1780
|
-
(keyPair) => Promise.all([
|
|
1781
|
-
getAddressFromPublicKey(keyPair.publicKey),
|
|
1782
|
-
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1783
|
-
])
|
|
1679
|
+
(keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
|
|
1784
1680
|
)
|
|
1785
1681
|
);
|
|
1786
1682
|
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
@@ -1793,14 +1689,25 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1793
1689
|
Object.freeze(out);
|
|
1794
1690
|
return out;
|
|
1795
1691
|
}
|
|
1796
|
-
function
|
|
1797
|
-
|
|
1798
|
-
|
|
1692
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1693
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
1694
|
+
assertTransactionIsFullySigned(out);
|
|
1695
|
+
Object.freeze(out);
|
|
1696
|
+
return out;
|
|
1697
|
+
}
|
|
1698
|
+
function assertTransactionIsFullySigned(transaction) {
|
|
1699
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole(a.role)) ?? []).map((a) => a.address);
|
|
1700
|
+
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
1701
|
+
requiredSigners.forEach((address2) => {
|
|
1702
|
+
if (!transaction.signatures[address2]) {
|
|
1703
|
+
throw new Error(`Transaction is missing signature for address \`${address2}\``);
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1799
1706
|
}
|
|
1800
1707
|
|
|
1801
1708
|
// src/wire-transaction.ts
|
|
1802
1709
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1803
|
-
const wireTransactionBytes = getTransactionEncoder().
|
|
1710
|
+
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1804
1711
|
{
|
|
1805
1712
|
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1806
1713
|
}
|
|
@@ -1809,18 +1716,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1809
1716
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1810
1717
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1811
1718
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1812
|
-
exports.
|
|
1719
|
+
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1813
1720
|
exports.createTransaction = createTransaction;
|
|
1814
1721
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1815
1722
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1723
|
+
exports.getTransactionCodec = getTransactionCodec;
|
|
1724
|
+
exports.getTransactionDecoder = getTransactionDecoder;
|
|
1816
1725
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1817
|
-
exports.
|
|
1726
|
+
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1727
|
+
exports.partiallySignTransaction = partiallySignTransaction;
|
|
1818
1728
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1819
1729
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1820
1730
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1821
1731
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1822
1732
|
exports.signTransaction = signTransaction;
|
|
1823
|
-
exports.transactionSignature = transactionSignature;
|
|
1824
1733
|
|
|
1825
1734
|
return exports;
|
|
1826
1735
|
|