@solana/transactions 2.0.0-experimental.0eb69ae → 2.0.0-experimental.0f3404a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +115 -246
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +114 -248
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +461 -616
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +114 -248
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +113 -246
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +114 -248
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +23 -22
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compilable-transaction.d.ts.map +1 -0
- 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.map +1 -0
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/decompile-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts +4 -4
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
- package/dist/types/serializers/header.d.ts +4 -4
- 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 -4
- 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 +4 -4
- package/dist/types/serializers/transaction-version.d.ts.map +1 -0
- package/dist/types/serializers/transaction.d.ts +4 -4
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +12 -12
|
@@ -14,23 +14,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
14
14
|
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
15
15
|
}
|
|
16
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);
|
|
26
|
-
const result = new Uint8Array(totalLength);
|
|
27
|
-
let offset = 0;
|
|
28
|
-
nonEmptyByteArrays.forEach((arr) => {
|
|
29
|
-
result.set(arr, offset);
|
|
30
|
-
offset += arr.length;
|
|
31
|
-
});
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
17
|
var padBytes = (bytes, length) => {
|
|
35
18
|
if (bytes.length >= length)
|
|
36
19
|
return bytes;
|
|
@@ -39,77 +22,100 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
39
22
|
return paddedBytes;
|
|
40
23
|
};
|
|
41
24
|
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
42
|
-
function
|
|
43
|
-
|
|
25
|
+
function getEncodedSize(value, encoder) {
|
|
26
|
+
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
27
|
+
}
|
|
28
|
+
function createEncoder(encoder) {
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
...encoder,
|
|
31
|
+
encode: (value) => {
|
|
32
|
+
const bytes = new Uint8Array(getEncodedSize(value, encoder));
|
|
33
|
+
encoder.write(value, bytes, 0);
|
|
34
|
+
return bytes;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createDecoder(decoder) {
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
...decoder,
|
|
41
|
+
decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function isFixedSize(codec) {
|
|
45
|
+
return "fixedSize" in codec && typeof codec.fixedSize === "number";
|
|
46
|
+
}
|
|
47
|
+
function assertIsFixedSize(codec, message) {
|
|
48
|
+
if (!isFixedSize(codec)) {
|
|
49
|
+
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function isVariableSize(codec) {
|
|
53
|
+
return !isFixedSize(codec);
|
|
54
|
+
}
|
|
55
|
+
function combineCodec(encoder, decoder) {
|
|
56
|
+
if (isFixedSize(encoder) !== isFixedSize(decoder)) {
|
|
57
|
+
throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);
|
|
58
|
+
}
|
|
59
|
+
if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
|
|
44
60
|
throw new Error(
|
|
45
61
|
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
46
62
|
);
|
|
47
63
|
}
|
|
48
|
-
if (encoder.maxSize !== decoder.maxSize) {
|
|
64
|
+
if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
|
|
49
65
|
throw new Error(
|
|
50
66
|
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
51
67
|
);
|
|
52
68
|
}
|
|
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
|
-
);
|
|
57
|
-
}
|
|
58
69
|
return {
|
|
70
|
+
...decoder,
|
|
71
|
+
...encoder,
|
|
59
72
|
decode: decoder.decode,
|
|
60
|
-
description: description != null ? description : encoder.description,
|
|
61
73
|
encode: encoder.encode,
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
read: decoder.read,
|
|
75
|
+
write: encoder.write
|
|
64
76
|
};
|
|
65
77
|
}
|
|
66
|
-
function
|
|
67
|
-
return {
|
|
68
|
-
description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
|
|
78
|
+
function fixEncoder(encoder, fixedBytes) {
|
|
79
|
+
return createEncoder({
|
|
69
80
|
fixedSize: fixedBytes,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
81
|
+
write: (value, bytes, offset) => {
|
|
82
|
+
const variableByteArray = encoder.encode(value);
|
|
83
|
+
const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray;
|
|
84
|
+
bytes.set(fixedByteArray, offset);
|
|
85
|
+
return offset + fixedBytes;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
78
88
|
}
|
|
79
|
-
function fixDecoder(decoder, fixedBytes
|
|
80
|
-
return {
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
function fixDecoder(decoder, fixedBytes) {
|
|
90
|
+
return createDecoder({
|
|
91
|
+
fixedSize: fixedBytes,
|
|
92
|
+
read: (bytes, offset) => {
|
|
83
93
|
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
84
94
|
if (offset > 0 || bytes.length > fixedBytes) {
|
|
85
95
|
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
86
96
|
}
|
|
87
|
-
if (decoder
|
|
97
|
+
if (isFixedSize(decoder)) {
|
|
88
98
|
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
89
99
|
}
|
|
90
|
-
const [value] = decoder.
|
|
100
|
+
const [value] = decoder.read(bytes, 0);
|
|
91
101
|
return [value, offset + fixedBytes];
|
|
92
102
|
}
|
|
93
|
-
};
|
|
103
|
+
});
|
|
94
104
|
}
|
|
95
105
|
function mapEncoder(encoder, unmap) {
|
|
96
|
-
return {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
maxSize: encoder.maxSize
|
|
101
|
-
};
|
|
106
|
+
return createEncoder({
|
|
107
|
+
...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder,
|
|
108
|
+
write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset)
|
|
109
|
+
});
|
|
102
110
|
}
|
|
103
111
|
function mapDecoder(decoder, map) {
|
|
104
|
-
return {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
maxSize: decoder.maxSize
|
|
112
|
-
};
|
|
112
|
+
return createDecoder({
|
|
113
|
+
...decoder,
|
|
114
|
+
read: (bytes, offset) => {
|
|
115
|
+
const [value, newOffset] = decoder.read(bytes, offset);
|
|
116
|
+
return [map(value, bytes, offset), newOffset];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
// ../codecs-numbers/dist/index.browser.js
|
|
@@ -120,102 +126,83 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
120
126
|
);
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
let littleEndian;
|
|
126
|
-
let defaultDescription = input.name;
|
|
127
|
-
if (input.size > 1) {
|
|
128
|
-
littleEndian = !("endian" in input.config) || input.config.endian === 0;
|
|
129
|
-
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
description: (_a = input.config.description) != null ? _a : defaultDescription,
|
|
133
|
-
fixedSize: input.size,
|
|
134
|
-
littleEndian,
|
|
135
|
-
maxSize: input.size
|
|
136
|
-
};
|
|
129
|
+
function isLittleEndian(config) {
|
|
130
|
+
return (config == null ? void 0 : config.endian) === 1 ? false : true;
|
|
137
131
|
}
|
|
138
132
|
function numberEncoderFactory(input) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
encode(value) {
|
|
133
|
+
return createEncoder({
|
|
134
|
+
fixedSize: input.size,
|
|
135
|
+
write(value, bytes, offset) {
|
|
143
136
|
if (input.range) {
|
|
144
137
|
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
145
138
|
}
|
|
146
139
|
const arrayBuffer = new ArrayBuffer(input.size);
|
|
147
|
-
input.set(new DataView(arrayBuffer), value,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
140
|
+
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
|
|
141
|
+
bytes.set(new Uint8Array(arrayBuffer), offset);
|
|
142
|
+
return offset + input.size;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
153
145
|
}
|
|
154
146
|
function numberDecoderFactory(input) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
assertByteArrayIsNotEmptyForCodec(
|
|
159
|
-
assertByteArrayHasEnoughBytesForCodec(
|
|
147
|
+
return createDecoder({
|
|
148
|
+
fixedSize: input.size,
|
|
149
|
+
read(bytes, offset = 0) {
|
|
150
|
+
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
|
|
151
|
+
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
|
|
160
152
|
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
161
|
-
return [input.get(view,
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
fixedSize: codecData.fixedSize,
|
|
165
|
-
maxSize: codecData.maxSize
|
|
166
|
-
};
|
|
153
|
+
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
167
156
|
}
|
|
168
157
|
function toArrayBuffer(bytes, offset, length) {
|
|
169
158
|
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
170
159
|
const bytesLength = length != null ? length : bytes.byteLength;
|
|
171
160
|
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
172
161
|
}
|
|
173
|
-
var getShortU16Encoder = (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
162
|
+
var getShortU16Encoder = () => createEncoder({
|
|
163
|
+
getSizeFromValue: (value) => {
|
|
164
|
+
if (value <= 127)
|
|
165
|
+
return 1;
|
|
166
|
+
if (value <= 16383)
|
|
167
|
+
return 2;
|
|
168
|
+
return 3;
|
|
169
|
+
},
|
|
170
|
+
maxSize: 3,
|
|
171
|
+
write: (value, bytes, offset) => {
|
|
172
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
173
|
+
const shortU16Bytes = [0];
|
|
174
|
+
for (let ii = 0; ; ii += 1) {
|
|
175
|
+
const alignedValue = value >> ii * 7;
|
|
176
|
+
if (alignedValue === 0) {
|
|
177
|
+
break;
|
|
190
178
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
var getShortU16Decoder = (config = {}) => {
|
|
198
|
-
var _a;
|
|
199
|
-
return {
|
|
200
|
-
decode: (bytes, offset = 0) => {
|
|
201
|
-
let value = 0;
|
|
202
|
-
let byteCount = 0;
|
|
203
|
-
while (++byteCount) {
|
|
204
|
-
const byteIndex = byteCount - 1;
|
|
205
|
-
const currentByte = bytes[offset + byteIndex];
|
|
206
|
-
const nextSevenBits = 127 & currentByte;
|
|
207
|
-
value |= nextSevenBits << byteIndex * 7;
|
|
208
|
-
if ((currentByte & 128) === 0) {
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
179
|
+
const nextSevenBits = 127 & alignedValue;
|
|
180
|
+
shortU16Bytes[ii] = nextSevenBits;
|
|
181
|
+
if (ii > 0) {
|
|
182
|
+
shortU16Bytes[ii - 1] |= 128;
|
|
211
183
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
184
|
+
}
|
|
185
|
+
bytes.set(shortU16Bytes, offset);
|
|
186
|
+
return offset + shortU16Bytes.length;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
var getShortU16Decoder = () => createDecoder({
|
|
190
|
+
maxSize: 3,
|
|
191
|
+
read: (bytes, offset) => {
|
|
192
|
+
let value = 0;
|
|
193
|
+
let byteCount = 0;
|
|
194
|
+
while (++byteCount) {
|
|
195
|
+
const byteIndex = byteCount - 1;
|
|
196
|
+
const currentByte = bytes[offset + byteIndex];
|
|
197
|
+
const nextSevenBits = 127 & currentByte;
|
|
198
|
+
value |= nextSevenBits << byteIndex * 7;
|
|
199
|
+
if ((currentByte & 128) === 0) {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [value, offset + byteCount];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
219
206
|
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
220
207
|
config,
|
|
221
208
|
name: "u32",
|
|
@@ -229,15 +216,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
229
216
|
name: "u32",
|
|
230
217
|
size: 4
|
|
231
218
|
});
|
|
232
|
-
var getU8Encoder = (
|
|
233
|
-
config,
|
|
219
|
+
var getU8Encoder = () => numberEncoderFactory({
|
|
234
220
|
name: "u8",
|
|
235
221
|
range: [0, Number("0xff")],
|
|
236
222
|
set: (view, value) => view.setUint8(0, value),
|
|
237
223
|
size: 1
|
|
238
224
|
});
|
|
239
|
-
var getU8Decoder = (
|
|
240
|
-
config,
|
|
225
|
+
var getU8Decoder = () => numberDecoderFactory({
|
|
241
226
|
get: (view) => view.getUint8(0),
|
|
242
227
|
name: "u8",
|
|
243
228
|
size: 1
|
|
@@ -250,43 +235,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
250
235
|
}
|
|
251
236
|
}
|
|
252
237
|
var getBaseXEncoder = (alphabet4) => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
238
|
+
return createEncoder({
|
|
239
|
+
getSizeFromValue: (value) => {
|
|
240
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
241
|
+
if (tailChars === "")
|
|
242
|
+
return value.length;
|
|
243
|
+
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
244
|
+
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
|
|
245
|
+
},
|
|
246
|
+
write(value, bytes, offset) {
|
|
258
247
|
assertValidBaseString(alphabet4, value);
|
|
259
248
|
if (value === "")
|
|
260
|
-
return
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (trailIndex === chars.length)
|
|
266
|
-
return Uint8Array.from(leadingZeroes);
|
|
267
|
-
const tailChars = chars.slice(trailIndex);
|
|
268
|
-
let base10Number = 0n;
|
|
269
|
-
let baseXPower = 1n;
|
|
270
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
271
|
-
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
272
|
-
baseXPower *= baseBigInt;
|
|
249
|
+
return offset;
|
|
250
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
251
|
+
if (tailChars === "") {
|
|
252
|
+
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
|
|
253
|
+
return offset + leadingZeroes.length;
|
|
273
254
|
}
|
|
255
|
+
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
274
256
|
const tailBytes = [];
|
|
275
257
|
while (base10Number > 0n) {
|
|
276
258
|
tailBytes.unshift(Number(base10Number % 256n));
|
|
277
259
|
base10Number /= 256n;
|
|
278
260
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
};
|
|
261
|
+
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
|
|
262
|
+
bytes.set(bytesToAdd, offset);
|
|
263
|
+
return offset + bytesToAdd.length;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
284
266
|
};
|
|
285
267
|
var getBaseXDecoder = (alphabet4) => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return {
|
|
289
|
-
decode(rawBytes, offset = 0) {
|
|
268
|
+
return createDecoder({
|
|
269
|
+
read(rawBytes, offset) {
|
|
290
270
|
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
291
271
|
if (bytes.length === 0)
|
|
292
272
|
return ["", 0];
|
|
@@ -295,34 +275,41 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
295
275
|
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
296
276
|
if (trailIndex === bytes.length)
|
|
297
277
|
return [leadingZeroes, rawBytes.length];
|
|
298
|
-
|
|
299
|
-
const tailChars =
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
305
|
-
},
|
|
306
|
-
description: `base${base}`,
|
|
307
|
-
fixedSize: null,
|
|
308
|
-
maxSize: null
|
|
309
|
-
};
|
|
278
|
+
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
279
|
+
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
|
|
280
|
+
return [leadingZeroes + tailChars, rawBytes.length];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
310
283
|
};
|
|
284
|
+
function partitionLeadingZeroes(value, zeroCharacter) {
|
|
285
|
+
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
|
|
286
|
+
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
|
|
287
|
+
}
|
|
288
|
+
function getBigIntFromBaseX(value, alphabet4) {
|
|
289
|
+
const base = BigInt(alphabet4.length);
|
|
290
|
+
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
|
|
291
|
+
}
|
|
292
|
+
function getBaseXFromBigInt(value, alphabet4) {
|
|
293
|
+
const base = BigInt(alphabet4.length);
|
|
294
|
+
const tailChars = [];
|
|
295
|
+
while (value > 0n) {
|
|
296
|
+
tailChars.unshift(alphabet4[Number(value % base)]);
|
|
297
|
+
value /= base;
|
|
298
|
+
}
|
|
299
|
+
return tailChars.join("");
|
|
300
|
+
}
|
|
311
301
|
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
312
302
|
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
313
303
|
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
314
304
|
var getBase64Decoder = () => {
|
|
315
305
|
{
|
|
316
|
-
return {
|
|
317
|
-
|
|
306
|
+
return createDecoder({
|
|
307
|
+
read(bytes, offset = 0) {
|
|
318
308
|
const slice = bytes.slice(offset);
|
|
319
309
|
const value = btoa(String.fromCharCode(...slice));
|
|
320
310
|
return [value, bytes.length];
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
fixedSize: null,
|
|
324
|
-
maxSize: null
|
|
325
|
-
};
|
|
311
|
+
}
|
|
312
|
+
});
|
|
326
313
|
}
|
|
327
314
|
};
|
|
328
315
|
var removeNullCharacters = (value) => (
|
|
@@ -333,77 +320,69 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
333
320
|
var o = globalThis.TextEncoder;
|
|
334
321
|
var getUtf8Encoder = () => {
|
|
335
322
|
let textEncoder;
|
|
336
|
-
return {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
323
|
+
return createEncoder({
|
|
324
|
+
getSizeFromValue: (value) => (textEncoder || (textEncoder = new o())).encode(value).length,
|
|
325
|
+
write: (value, bytes, offset) => {
|
|
326
|
+
const bytesToAdd = (textEncoder || (textEncoder = new o())).encode(value);
|
|
327
|
+
bytes.set(bytesToAdd, offset);
|
|
328
|
+
return offset + bytesToAdd.length;
|
|
329
|
+
}
|
|
330
|
+
});
|
|
342
331
|
};
|
|
343
332
|
var getUtf8Decoder = () => {
|
|
344
333
|
let textDecoder;
|
|
345
|
-
return {
|
|
346
|
-
|
|
334
|
+
return createDecoder({
|
|
335
|
+
read(bytes, offset) {
|
|
347
336
|
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
348
337
|
return [removeNullCharacters(value), bytes.length];
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
fixedSize: null,
|
|
352
|
-
maxSize: null
|
|
353
|
-
};
|
|
338
|
+
}
|
|
339
|
+
});
|
|
354
340
|
};
|
|
355
|
-
|
|
356
|
-
var _a, _b
|
|
341
|
+
function getStringEncoder(config = {}) {
|
|
342
|
+
var _a, _b;
|
|
357
343
|
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
358
344
|
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
|
|
359
|
-
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
360
345
|
if (size === "variable") {
|
|
361
|
-
return
|
|
346
|
+
return encoding;
|
|
362
347
|
}
|
|
363
348
|
if (typeof size === "number") {
|
|
364
|
-
return fixEncoder(encoding, size
|
|
349
|
+
return fixEncoder(encoding, size);
|
|
365
350
|
}
|
|
366
|
-
return {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const lengthBytes = size.encode(contentBytes.length);
|
|
371
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
351
|
+
return createEncoder({
|
|
352
|
+
getSizeFromValue: (value) => {
|
|
353
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
354
|
+
return getEncodedSize(contentSize, size) + contentSize;
|
|
372
355
|
},
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
356
|
+
write: (value, bytes, offset) => {
|
|
357
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
358
|
+
offset = size.write(contentSize, bytes, offset);
|
|
359
|
+
return encoding.write(value, bytes, offset);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function getStringDecoder(config = {}) {
|
|
364
|
+
var _a, _b;
|
|
379
365
|
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
380
366
|
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
|
|
381
|
-
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
382
367
|
if (size === "variable") {
|
|
383
|
-
return
|
|
368
|
+
return encoding;
|
|
384
369
|
}
|
|
385
370
|
if (typeof size === "number") {
|
|
386
|
-
return fixDecoder(encoding, size
|
|
371
|
+
return fixDecoder(encoding, size);
|
|
387
372
|
}
|
|
388
|
-
return {
|
|
389
|
-
|
|
373
|
+
return createDecoder({
|
|
374
|
+
read: (bytes, offset = 0) => {
|
|
390
375
|
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
391
|
-
const [lengthBigInt, lengthOffset] = size.
|
|
376
|
+
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
|
|
392
377
|
const length = Number(lengthBigInt);
|
|
393
378
|
offset = lengthOffset;
|
|
394
379
|
const contentBytes = bytes.slice(offset, offset + length);
|
|
395
380
|
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
396
|
-
const [value, contentOffset] = encoding.
|
|
381
|
+
const [value, contentOffset] = encoding.read(contentBytes, 0);
|
|
397
382
|
offset += contentOffset;
|
|
398
383
|
return [value, offset];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
fixedSize: null,
|
|
402
|
-
maxSize: null
|
|
403
|
-
};
|
|
404
|
-
};
|
|
405
|
-
function getSizeDescription(size) {
|
|
406
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
384
|
+
}
|
|
385
|
+
});
|
|
407
386
|
}
|
|
408
387
|
|
|
409
388
|
// src/unsigned-transaction.ts
|
|
@@ -444,6 +423,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
444
423
|
});
|
|
445
424
|
}
|
|
446
425
|
}
|
|
426
|
+
function isTransactionWithBlockhashLifetime(transaction) {
|
|
427
|
+
const lifetimeConstraintShapeMatches = "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.blockhash === "string" && typeof transaction.lifetimeConstraint.lastValidBlockHeight === "bigint";
|
|
428
|
+
if (!lifetimeConstraintShapeMatches)
|
|
429
|
+
return false;
|
|
430
|
+
try {
|
|
431
|
+
assertIsBlockhash(transaction.lifetimeConstraint.blockhash);
|
|
432
|
+
return true;
|
|
433
|
+
} catch {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function assertIsTransactionWithBlockhashLifetime(transaction) {
|
|
438
|
+
if (!isTransactionWithBlockhashLifetime(transaction)) {
|
|
439
|
+
throw new Error("Transaction does not have a blockhash lifetime");
|
|
440
|
+
}
|
|
441
|
+
}
|
|
447
442
|
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
448
443
|
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
449
444
|
return transaction;
|
|
@@ -660,24 +655,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
660
655
|
assertIsAddress(putativeAddress);
|
|
661
656
|
return putativeAddress;
|
|
662
657
|
}
|
|
663
|
-
function getAddressEncoder(
|
|
664
|
-
var _a;
|
|
658
|
+
function getAddressEncoder() {
|
|
665
659
|
return mapEncoder(
|
|
666
|
-
getStringEncoder({
|
|
667
|
-
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
668
|
-
encoding: getMemoizedBase58Encoder(),
|
|
669
|
-
size: 32
|
|
670
|
-
}),
|
|
660
|
+
getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }),
|
|
671
661
|
(putativeAddress) => address(putativeAddress)
|
|
672
662
|
);
|
|
673
663
|
}
|
|
674
|
-
function getAddressDecoder(
|
|
675
|
-
|
|
676
|
-
return getStringDecoder({
|
|
677
|
-
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
678
|
-
encoding: getMemoizedBase58Decoder(),
|
|
679
|
-
size: 32
|
|
680
|
-
});
|
|
664
|
+
function getAddressDecoder() {
|
|
665
|
+
return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 });
|
|
681
666
|
}
|
|
682
667
|
function getAddressComparator() {
|
|
683
668
|
return new Intl.Collator("en", {
|
|
@@ -695,8 +680,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
695
680
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
696
681
|
}
|
|
697
682
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
698
|
-
|
|
699
|
-
return base58EncodedAddress;
|
|
683
|
+
return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
700
684
|
}
|
|
701
685
|
|
|
702
686
|
// src/accounts.ts
|
|
@@ -971,241 +955,222 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
971
955
|
}
|
|
972
956
|
|
|
973
957
|
// ../codecs-data-structures/dist/index.browser.js
|
|
974
|
-
function sumCodecSizes(sizes) {
|
|
975
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
976
|
-
}
|
|
977
|
-
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
978
|
-
if (typeof size === "number") {
|
|
979
|
-
return [size, offset];
|
|
980
|
-
}
|
|
981
|
-
if (typeof size === "object") {
|
|
982
|
-
return size.decode(bytes, offset);
|
|
983
|
-
}
|
|
984
|
-
if (size === "remainder") {
|
|
985
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
986
|
-
if (childrenSize === null) {
|
|
987
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
988
|
-
}
|
|
989
|
-
const remainder = bytes.slice(offset).length;
|
|
990
|
-
if (remainder % childrenSize !== 0) {
|
|
991
|
-
throw new Error(
|
|
992
|
-
`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.`
|
|
993
|
-
);
|
|
994
|
-
}
|
|
995
|
-
return [remainder / childrenSize, offset];
|
|
996
|
-
}
|
|
997
|
-
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
998
|
-
}
|
|
999
|
-
function getArrayLikeCodecSizeDescription(size) {
|
|
1000
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
1001
|
-
}
|
|
1002
|
-
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
1003
|
-
if (typeof size !== "number")
|
|
1004
|
-
return null;
|
|
1005
|
-
if (size === 0)
|
|
1006
|
-
return 0;
|
|
1007
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
1008
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
1009
|
-
}
|
|
1010
|
-
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
1011
|
-
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
1012
|
-
}
|
|
1013
958
|
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
1014
959
|
if (expected !== actual) {
|
|
1015
960
|
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
1016
961
|
}
|
|
1017
962
|
}
|
|
1018
|
-
function
|
|
1019
|
-
|
|
1020
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1021
|
-
}
|
|
1022
|
-
return {
|
|
1023
|
-
description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
1024
|
-
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
1025
|
-
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
1026
|
-
};
|
|
963
|
+
function sumCodecSizes(sizes) {
|
|
964
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
1027
965
|
}
|
|
1028
|
-
function
|
|
966
|
+
function getFixedSize(codec) {
|
|
967
|
+
return isFixedSize(codec) ? codec.fixedSize : null;
|
|
968
|
+
}
|
|
969
|
+
function getMaxSize(codec) {
|
|
1029
970
|
var _a;
|
|
971
|
+
return isFixedSize(codec) ? codec.fixedSize : (_a = codec.maxSize) != null ? _a : null;
|
|
972
|
+
}
|
|
973
|
+
function getArrayEncoder(item, config = {}) {
|
|
974
|
+
var _a, _b;
|
|
1030
975
|
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
976
|
+
if (size === "remainder") {
|
|
977
|
+
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
978
|
+
}
|
|
979
|
+
const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
|
|
980
|
+
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
981
|
+
return createEncoder({
|
|
982
|
+
...fixedSize !== null ? { fixedSize } : {
|
|
983
|
+
getSizeFromValue: (array) => {
|
|
984
|
+
const prefixSize = typeof size === "object" ? getEncodedSize(array.length, size) : 0;
|
|
985
|
+
return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);
|
|
986
|
+
},
|
|
987
|
+
maxSize
|
|
988
|
+
},
|
|
989
|
+
write: (array, bytes, offset) => {
|
|
1034
990
|
if (typeof size === "number") {
|
|
1035
|
-
assertValidNumberOfItemsForCodec("array", size,
|
|
991
|
+
assertValidNumberOfItemsForCodec("array", size, array.length);
|
|
992
|
+
}
|
|
993
|
+
if (typeof size === "object") {
|
|
994
|
+
offset = size.write(array.length, bytes, offset);
|
|
1036
995
|
}
|
|
1037
|
-
|
|
996
|
+
array.forEach((value) => {
|
|
997
|
+
offset = item.write(value, bytes, offset);
|
|
998
|
+
});
|
|
999
|
+
return offset;
|
|
1038
1000
|
}
|
|
1039
|
-
};
|
|
1001
|
+
});
|
|
1040
1002
|
}
|
|
1041
1003
|
function getArrayDecoder(item, config = {}) {
|
|
1042
|
-
var _a;
|
|
1004
|
+
var _a, _b;
|
|
1043
1005
|
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1006
|
+
if (size === "remainder") {
|
|
1007
|
+
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
1008
|
+
}
|
|
1009
|
+
const itemSize = getFixedSize(item);
|
|
1010
|
+
const fixedSize = computeArrayLikeCodecSize(size, itemSize);
|
|
1011
|
+
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
1012
|
+
return createDecoder({
|
|
1013
|
+
...fixedSize !== null ? { fixedSize } : { maxSize },
|
|
1014
|
+
read: (bytes, offset) => {
|
|
1015
|
+
const array = [];
|
|
1047
1016
|
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
1048
|
-
return [
|
|
1017
|
+
return [array, offset];
|
|
1049
1018
|
}
|
|
1050
|
-
const [resolvedSize, newOffset] =
|
|
1019
|
+
const [resolvedSize, newOffset] = readArrayLikeCodecSize(size, itemSize, bytes, offset);
|
|
1051
1020
|
offset = newOffset;
|
|
1052
|
-
const values = [];
|
|
1053
1021
|
for (let i = 0; i < resolvedSize; i += 1) {
|
|
1054
|
-
const [value, newOffset2] = item.
|
|
1055
|
-
values.push(value);
|
|
1022
|
+
const [value, newOffset2] = item.read(bytes, offset);
|
|
1056
1023
|
offset = newOffset2;
|
|
1024
|
+
array.push(value);
|
|
1057
1025
|
}
|
|
1058
|
-
return [
|
|
1026
|
+
return [array, offset];
|
|
1059
1027
|
}
|
|
1060
|
-
};
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
function readArrayLikeCodecSize(size, itemSize, bytes, offset) {
|
|
1031
|
+
if (typeof size === "number") {
|
|
1032
|
+
return [size, offset];
|
|
1033
|
+
}
|
|
1034
|
+
if (typeof size === "object") {
|
|
1035
|
+
return size.read(bytes, offset);
|
|
1036
|
+
}
|
|
1037
|
+
if (size === "remainder") {
|
|
1038
|
+
if (itemSize === null) {
|
|
1039
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
1040
|
+
}
|
|
1041
|
+
const remainder = Math.max(0, bytes.length - offset);
|
|
1042
|
+
if (remainder % itemSize !== 0) {
|
|
1043
|
+
throw new Error(
|
|
1044
|
+
`The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${itemSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${itemSize} should be equal to zero.`
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
return [remainder / itemSize, offset];
|
|
1048
|
+
}
|
|
1049
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
1050
|
+
}
|
|
1051
|
+
function computeArrayLikeCodecSize(size, itemSize) {
|
|
1052
|
+
if (typeof size !== "number")
|
|
1053
|
+
return null;
|
|
1054
|
+
if (size === 0)
|
|
1055
|
+
return 0;
|
|
1056
|
+
return itemSize === null ? null : itemSize * size;
|
|
1061
1057
|
}
|
|
1062
1058
|
function getBytesEncoder(config = {}) {
|
|
1063
|
-
var _a
|
|
1059
|
+
var _a;
|
|
1064
1060
|
const size = (_a = config.size) != null ? _a : "variable";
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
};
|
|
1061
|
+
const byteEncoder = createEncoder({
|
|
1062
|
+
getSizeFromValue: (value) => value.length,
|
|
1063
|
+
write: (value, bytes, offset) => {
|
|
1064
|
+
bytes.set(value, offset);
|
|
1065
|
+
return offset + value.length;
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1073
1068
|
if (size === "variable") {
|
|
1074
1069
|
return byteEncoder;
|
|
1075
1070
|
}
|
|
1076
1071
|
if (typeof size === "number") {
|
|
1077
|
-
return fixEncoder(byteEncoder, size
|
|
1072
|
+
return fixEncoder(byteEncoder, size);
|
|
1078
1073
|
}
|
|
1079
|
-
return {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
1074
|
+
return createEncoder({
|
|
1075
|
+
getSizeFromValue: (value) => getEncodedSize(value.length, size) + value.length,
|
|
1076
|
+
write: (value, bytes, offset) => {
|
|
1077
|
+
offset = size.write(value.length, bytes, offset);
|
|
1078
|
+
return byteEncoder.write(value, bytes, offset);
|
|
1085
1079
|
}
|
|
1086
|
-
};
|
|
1080
|
+
});
|
|
1087
1081
|
}
|
|
1088
1082
|
function getBytesDecoder(config = {}) {
|
|
1089
|
-
var _a
|
|
1083
|
+
var _a;
|
|
1090
1084
|
const size = (_a = config.size) != null ? _a : "variable";
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
const byteDecoder = {
|
|
1094
|
-
decode: (bytes, offset = 0) => {
|
|
1085
|
+
const byteDecoder = createDecoder({
|
|
1086
|
+
read: (bytes, offset) => {
|
|
1095
1087
|
const slice = bytes.slice(offset);
|
|
1096
1088
|
return [slice, offset + slice.length];
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
fixedSize: null,
|
|
1100
|
-
maxSize: null
|
|
1101
|
-
};
|
|
1089
|
+
}
|
|
1090
|
+
});
|
|
1102
1091
|
if (size === "variable") {
|
|
1103
1092
|
return byteDecoder;
|
|
1104
1093
|
}
|
|
1105
1094
|
if (typeof size === "number") {
|
|
1106
|
-
return fixDecoder(byteDecoder, size
|
|
1095
|
+
return fixDecoder(byteDecoder, size);
|
|
1107
1096
|
}
|
|
1108
|
-
return {
|
|
1109
|
-
|
|
1110
|
-
decode: (bytes, offset = 0) => {
|
|
1097
|
+
return createDecoder({
|
|
1098
|
+
read: (bytes, offset) => {
|
|
1111
1099
|
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
1112
|
-
const [lengthBigInt, lengthOffset] = size.
|
|
1100
|
+
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
|
|
1113
1101
|
const length = Number(lengthBigInt);
|
|
1114
1102
|
offset = lengthOffset;
|
|
1115
1103
|
const contentBytes = bytes.slice(offset, offset + length);
|
|
1116
1104
|
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
1117
|
-
const [value, contentOffset] = byteDecoder.
|
|
1105
|
+
const [value, contentOffset] = byteDecoder.read(contentBytes, 0);
|
|
1118
1106
|
offset += contentOffset;
|
|
1119
1107
|
return [value, offset];
|
|
1120
1108
|
}
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
function structCodecHelper(fields, description) {
|
|
1124
|
-
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
1125
|
-
return {
|
|
1126
|
-
description: description != null ? description : `struct(${fieldDescriptions})`,
|
|
1127
|
-
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
1128
|
-
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
1129
|
-
};
|
|
1109
|
+
});
|
|
1130
1110
|
}
|
|
1131
|
-
function getStructEncoder(fields
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1111
|
+
function getStructEncoder(fields) {
|
|
1112
|
+
var _a;
|
|
1113
|
+
const fieldCodecs = fields.map(([, codec]) => codec);
|
|
1114
|
+
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
|
|
1115
|
+
const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
|
|
1116
|
+
return createEncoder({
|
|
1117
|
+
...fixedSize === null ? {
|
|
1118
|
+
getSizeFromValue: (value) => fields.map(([key, codec]) => getEncodedSize(value[key], codec)).reduce((all, one) => all + one, 0),
|
|
1119
|
+
maxSize
|
|
1120
|
+
} : { fixedSize },
|
|
1121
|
+
write: (struct, bytes, offset) => {
|
|
1122
|
+
fields.forEach(([key, codec]) => {
|
|
1123
|
+
offset = codec.write(struct[key], bytes, offset);
|
|
1124
|
+
});
|
|
1125
|
+
return offset;
|
|
1137
1126
|
}
|
|
1138
|
-
};
|
|
1127
|
+
});
|
|
1139
1128
|
}
|
|
1140
|
-
function getStructDecoder(fields
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1129
|
+
function getStructDecoder(fields) {
|
|
1130
|
+
var _a;
|
|
1131
|
+
const fieldCodecs = fields.map(([, codec]) => codec);
|
|
1132
|
+
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
|
|
1133
|
+
const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
|
|
1134
|
+
return createDecoder({
|
|
1135
|
+
...fixedSize === null ? { maxSize } : { fixedSize },
|
|
1136
|
+
read: (bytes, offset) => {
|
|
1144
1137
|
const struct = {};
|
|
1145
1138
|
fields.forEach(([key, codec]) => {
|
|
1146
|
-
const [value, newOffset] = codec.
|
|
1139
|
+
const [value, newOffset] = codec.read(bytes, offset);
|
|
1147
1140
|
offset = newOffset;
|
|
1148
1141
|
struct[key] = value;
|
|
1149
1142
|
});
|
|
1150
1143
|
return [struct, offset];
|
|
1151
1144
|
}
|
|
1152
|
-
};
|
|
1145
|
+
});
|
|
1153
1146
|
}
|
|
1154
1147
|
|
|
1155
1148
|
// src/serializers/address-table-lookup.ts
|
|
1156
|
-
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
1157
|
-
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
1158
|
-
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
1159
|
-
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" ;
|
|
1160
1149
|
var memoizedAddressTableLookupEncoder;
|
|
1161
1150
|
function getAddressTableLookupEncoder() {
|
|
1162
1151
|
if (!memoizedAddressTableLookupEncoder) {
|
|
1163
|
-
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
1152
|
+
memoizedAddressTableLookupEncoder = getStructEncoder([
|
|
1153
|
+
["lookupTableAddress", getAddressEncoder()],
|
|
1164
1154
|
[
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
"writableIndices",
|
|
1168
|
-
getArrayEncoder(getU8Encoder(), {
|
|
1169
|
-
description: writableIndicesDescription,
|
|
1170
|
-
size: getShortU16Encoder()
|
|
1171
|
-
})
|
|
1172
|
-
],
|
|
1173
|
-
[
|
|
1174
|
-
"readableIndices",
|
|
1175
|
-
getArrayEncoder(getU8Encoder(), {
|
|
1176
|
-
description: readableIndicesDescription,
|
|
1177
|
-
size: getShortU16Encoder()
|
|
1178
|
-
})
|
|
1179
|
-
]
|
|
1155
|
+
"writableIndices",
|
|
1156
|
+
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
|
|
1180
1157
|
],
|
|
1181
|
-
|
|
1182
|
-
|
|
1158
|
+
[
|
|
1159
|
+
"readableIndices",
|
|
1160
|
+
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
|
|
1161
|
+
]
|
|
1162
|
+
]);
|
|
1183
1163
|
}
|
|
1184
1164
|
return memoizedAddressTableLookupEncoder;
|
|
1185
1165
|
}
|
|
1186
1166
|
var memoizedAddressTableLookupDecoder;
|
|
1187
1167
|
function getAddressTableLookupDecoder() {
|
|
1188
1168
|
if (!memoizedAddressTableLookupDecoder) {
|
|
1189
|
-
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1190
|
-
[
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
getArrayDecoder(getU8Decoder(), {
|
|
1195
|
-
description: writableIndicesDescription,
|
|
1196
|
-
size: getShortU16Decoder()
|
|
1197
|
-
})
|
|
1198
|
-
],
|
|
1199
|
-
[
|
|
1200
|
-
"readableIndices",
|
|
1201
|
-
getArrayDecoder(getU8Decoder(), {
|
|
1202
|
-
description: readableIndicesDescription,
|
|
1203
|
-
size: getShortU16Decoder()
|
|
1204
|
-
})
|
|
1205
|
-
]
|
|
1206
|
-
],
|
|
1207
|
-
{ description: addressTableLookupDescription }
|
|
1208
|
-
);
|
|
1169
|
+
memoizedAddressTableLookupDecoder = getStructDecoder([
|
|
1170
|
+
["lookupTableAddress", getAddressDecoder()],
|
|
1171
|
+
["writableIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
|
|
1172
|
+
["readableIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })]
|
|
1173
|
+
]);
|
|
1209
1174
|
}
|
|
1210
1175
|
return memoizedAddressTableLookupDecoder;
|
|
1211
1176
|
}
|
|
@@ -1217,74 +1182,36 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1217
1182
|
memoizedU8Encoder = getU8Encoder();
|
|
1218
1183
|
return memoizedU8Encoder;
|
|
1219
1184
|
}
|
|
1220
|
-
function getMemoizedU8EncoderDescription(description) {
|
|
1221
|
-
const encoder = getMemoizedU8Encoder();
|
|
1222
|
-
return {
|
|
1223
|
-
...encoder,
|
|
1224
|
-
description: description != null ? description : encoder.description
|
|
1225
|
-
};
|
|
1226
|
-
}
|
|
1227
1185
|
var memoizedU8Decoder;
|
|
1228
1186
|
function getMemoizedU8Decoder() {
|
|
1229
1187
|
if (!memoizedU8Decoder)
|
|
1230
1188
|
memoizedU8Decoder = getU8Decoder();
|
|
1231
1189
|
return memoizedU8Decoder;
|
|
1232
1190
|
}
|
|
1233
|
-
function getMemoizedU8DecoderDescription(description) {
|
|
1234
|
-
const decoder = getMemoizedU8Decoder();
|
|
1235
|
-
return {
|
|
1236
|
-
...decoder,
|
|
1237
|
-
description: description != null ? description : decoder.description
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
1241
|
-
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" ;
|
|
1242
|
-
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
1243
|
-
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
1244
1191
|
function getMessageHeaderEncoder() {
|
|
1245
|
-
return getStructEncoder(
|
|
1246
|
-
[
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
],
|
|
1251
|
-
{
|
|
1252
|
-
description: messageHeaderDescription
|
|
1253
|
-
}
|
|
1254
|
-
);
|
|
1192
|
+
return getStructEncoder([
|
|
1193
|
+
["numSignerAccounts", getMemoizedU8Encoder()],
|
|
1194
|
+
["numReadonlySignerAccounts", getMemoizedU8Encoder()],
|
|
1195
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
|
|
1196
|
+
]);
|
|
1255
1197
|
}
|
|
1256
1198
|
function getMessageHeaderDecoder() {
|
|
1257
|
-
return getStructDecoder(
|
|
1258
|
-
[
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
],
|
|
1263
|
-
{
|
|
1264
|
-
description: messageHeaderDescription
|
|
1265
|
-
}
|
|
1266
|
-
);
|
|
1199
|
+
return getStructDecoder([
|
|
1200
|
+
["numSignerAccounts", getMemoizedU8Decoder()],
|
|
1201
|
+
["numReadonlySignerAccounts", getMemoizedU8Decoder()],
|
|
1202
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()]
|
|
1203
|
+
]);
|
|
1267
1204
|
}
|
|
1268
1205
|
|
|
1269
1206
|
// src/serializers/instruction.ts
|
|
1270
|
-
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
1271
|
-
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
1272
|
-
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" ;
|
|
1273
|
-
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
1274
1207
|
var memoizedGetInstructionEncoder;
|
|
1275
1208
|
function getInstructionEncoder() {
|
|
1276
1209
|
if (!memoizedGetInstructionEncoder) {
|
|
1277
1210
|
memoizedGetInstructionEncoder = mapEncoder(
|
|
1278
1211
|
getStructEncoder([
|
|
1279
|
-
["programAddressIndex", getU8Encoder(
|
|
1280
|
-
[
|
|
1281
|
-
|
|
1282
|
-
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
1283
|
-
description: accountIndicesDescription,
|
|
1284
|
-
size: getShortU16Encoder()
|
|
1285
|
-
})
|
|
1286
|
-
],
|
|
1287
|
-
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
1212
|
+
["programAddressIndex", getU8Encoder()],
|
|
1213
|
+
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],
|
|
1214
|
+
["data", getBytesEncoder({ size: getShortU16Encoder() })]
|
|
1288
1215
|
]),
|
|
1289
1216
|
// Convert an instruction to have all fields defined
|
|
1290
1217
|
(instruction) => {
|
|
@@ -1307,15 +1234,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1307
1234
|
if (!memoizedGetInstructionDecoder) {
|
|
1308
1235
|
memoizedGetInstructionDecoder = mapDecoder(
|
|
1309
1236
|
getStructDecoder([
|
|
1310
|
-
["programAddressIndex", getU8Decoder(
|
|
1311
|
-
[
|
|
1312
|
-
|
|
1313
|
-
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
1314
|
-
description: accountIndicesDescription,
|
|
1315
|
-
size: getShortU16Decoder()
|
|
1316
|
-
})
|
|
1317
|
-
],
|
|
1318
|
-
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
1237
|
+
["programAddressIndex", getU8Decoder()],
|
|
1238
|
+
["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
|
|
1239
|
+
["data", getBytesDecoder({ size: getShortU16Decoder() })]
|
|
1319
1240
|
]),
|
|
1320
1241
|
// Convert an instruction to exclude optional fields if they are empty
|
|
1321
1242
|
(instruction) => {
|
|
@@ -1336,47 +1257,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1336
1257
|
|
|
1337
1258
|
// src/serializers/transaction-version.ts
|
|
1338
1259
|
var VERSION_FLAG_MASK = 128;
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
if (value === "legacy") {
|
|
1355
|
-
return new Uint8Array();
|
|
1356
|
-
}
|
|
1357
|
-
if (value < 0 || value > 127) {
|
|
1358
|
-
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
1359
|
-
}
|
|
1360
|
-
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1260
|
+
function getTransactionVersionEncoder() {
|
|
1261
|
+
return createEncoder({
|
|
1262
|
+
getSizeFromValue: (value) => value === "legacy" ? 0 : 1,
|
|
1263
|
+
maxSize: 1,
|
|
1264
|
+
write: (value, bytes, offset) => {
|
|
1265
|
+
if (value === "legacy") {
|
|
1266
|
+
return offset;
|
|
1267
|
+
}
|
|
1268
|
+
if (value < 0 || value > 127) {
|
|
1269
|
+
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
1270
|
+
}
|
|
1271
|
+
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
1272
|
+
return offset + 1;
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1361
1275
|
}
|
|
1362
1276
|
function getTransactionVersionDecoder() {
|
|
1363
|
-
return {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1277
|
+
return createDecoder({
|
|
1278
|
+
maxSize: 1,
|
|
1279
|
+
read: (bytes, offset) => {
|
|
1280
|
+
const firstByte = bytes[offset];
|
|
1281
|
+
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1282
|
+
return ["legacy", offset];
|
|
1283
|
+
} else {
|
|
1284
|
+
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
1285
|
+
return [version, offset + 1];
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1373
1289
|
}
|
|
1374
1290
|
|
|
1375
1291
|
// src/serializers/message.ts
|
|
1376
|
-
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
|
|
1377
|
-
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
|
|
1378
|
-
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
|
|
1379
|
-
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
|
|
1380
1292
|
function getCompiledMessageLegacyEncoder() {
|
|
1381
1293
|
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
1382
1294
|
}
|
|
@@ -1402,98 +1314,52 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1402
1314
|
return [
|
|
1403
1315
|
["version", getTransactionVersionEncoder()],
|
|
1404
1316
|
["header", getMessageHeaderEncoder()],
|
|
1405
|
-
[
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
description: staticAccountsDescription,
|
|
1409
|
-
size: getShortU16Encoder()
|
|
1410
|
-
})
|
|
1411
|
-
],
|
|
1412
|
-
[
|
|
1413
|
-
"lifetimeToken",
|
|
1414
|
-
getStringEncoder({
|
|
1415
|
-
description: lifetimeTokenDescription,
|
|
1416
|
-
encoding: getBase58Encoder(),
|
|
1417
|
-
size: 32
|
|
1418
|
-
})
|
|
1419
|
-
],
|
|
1420
|
-
[
|
|
1421
|
-
"instructions",
|
|
1422
|
-
getArrayEncoder(getInstructionEncoder(), {
|
|
1423
|
-
description: instructionsDescription,
|
|
1424
|
-
size: getShortU16Encoder()
|
|
1425
|
-
})
|
|
1426
|
-
]
|
|
1317
|
+
["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],
|
|
1318
|
+
["lifetimeToken", getStringEncoder({ encoding: getBase58Encoder(), size: 32 })],
|
|
1319
|
+
["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })]
|
|
1427
1320
|
];
|
|
1428
1321
|
}
|
|
1429
1322
|
function getPreludeStructDecoderTuple() {
|
|
1430
1323
|
return [
|
|
1431
1324
|
["version", getTransactionVersionDecoder()],
|
|
1432
1325
|
["header", getMessageHeaderDecoder()],
|
|
1433
|
-
[
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
description: staticAccountsDescription,
|
|
1437
|
-
size: getShortU16Decoder()
|
|
1438
|
-
})
|
|
1439
|
-
],
|
|
1440
|
-
[
|
|
1441
|
-
"lifetimeToken",
|
|
1442
|
-
getStringDecoder({
|
|
1443
|
-
description: lifetimeTokenDescription,
|
|
1444
|
-
encoding: getBase58Decoder(),
|
|
1445
|
-
size: 32
|
|
1446
|
-
})
|
|
1447
|
-
],
|
|
1448
|
-
[
|
|
1449
|
-
"instructions",
|
|
1450
|
-
getArrayDecoder(getInstructionDecoder(), {
|
|
1451
|
-
description: instructionsDescription,
|
|
1452
|
-
size: getShortU16Decoder()
|
|
1453
|
-
})
|
|
1454
|
-
],
|
|
1326
|
+
["staticAccounts", getArrayDecoder(getAddressDecoder(), { size: getShortU16Decoder() })],
|
|
1327
|
+
["lifetimeToken", getStringDecoder({ encoding: getBase58Decoder(), size: 32 })],
|
|
1328
|
+
["instructions", getArrayDecoder(getInstructionDecoder(), { size: getShortU16Decoder() })],
|
|
1455
1329
|
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
1456
1330
|
];
|
|
1457
1331
|
}
|
|
1458
1332
|
function getAddressTableLookupArrayEncoder() {
|
|
1459
|
-
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
1460
|
-
description: addressTableLookupsDescription,
|
|
1461
|
-
size: getShortU16Encoder()
|
|
1462
|
-
});
|
|
1333
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() });
|
|
1463
1334
|
}
|
|
1464
1335
|
function getAddressTableLookupArrayDecoder() {
|
|
1465
|
-
return getArrayDecoder(getAddressTableLookupDecoder(), {
|
|
1466
|
-
description: addressTableLookupsDescription,
|
|
1467
|
-
size: getShortU16Decoder()
|
|
1468
|
-
});
|
|
1336
|
+
return getArrayDecoder(getAddressTableLookupDecoder(), { size: getShortU16Decoder() });
|
|
1469
1337
|
}
|
|
1470
|
-
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1471
1338
|
function getCompiledMessageEncoder() {
|
|
1472
|
-
return {
|
|
1473
|
-
|
|
1474
|
-
encode: (compiledMessage) => {
|
|
1339
|
+
return createEncoder({
|
|
1340
|
+
getSizeFromValue: (compiledMessage) => {
|
|
1475
1341
|
if (compiledMessage.version === "legacy") {
|
|
1476
|
-
return getCompiledMessageLegacyEncoder().
|
|
1342
|
+
return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);
|
|
1477
1343
|
} else {
|
|
1478
|
-
return getCompiledMessageVersionedEncoder().
|
|
1344
|
+
return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);
|
|
1479
1345
|
}
|
|
1480
1346
|
},
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1347
|
+
write: (compiledMessage, bytes, offset) => {
|
|
1348
|
+
if (compiledMessage.version === "legacy") {
|
|
1349
|
+
return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);
|
|
1350
|
+
} else {
|
|
1351
|
+
return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1484
1355
|
}
|
|
1485
1356
|
function getCompiledMessageDecoder() {
|
|
1486
|
-
return mapDecoder(
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
}),
|
|
1490
|
-
({ addressTableLookups, ...restOfMessage }) => {
|
|
1491
|
-
if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
|
|
1492
|
-
return restOfMessage;
|
|
1493
|
-
}
|
|
1494
|
-
return { ...restOfMessage, addressTableLookups };
|
|
1357
|
+
return mapDecoder(getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {
|
|
1358
|
+
if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
|
|
1359
|
+
return restOfMessage;
|
|
1495
1360
|
}
|
|
1496
|
-
|
|
1361
|
+
return { ...restOfMessage, addressTableLookups };
|
|
1362
|
+
});
|
|
1497
1363
|
}
|
|
1498
1364
|
function getCompiledMessageCodec() {
|
|
1499
1365
|
return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
|
|
@@ -1637,44 +1503,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1637
1503
|
}
|
|
1638
1504
|
|
|
1639
1505
|
// src/serializers/transaction.ts
|
|
1640
|
-
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
1641
|
-
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
1642
1506
|
function getCompiledTransactionEncoder() {
|
|
1643
|
-
return getStructEncoder(
|
|
1644
|
-
[
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
getArrayEncoder(getBytesEncoder({ size: 64 }), {
|
|
1648
|
-
description: signaturesDescription,
|
|
1649
|
-
size: getShortU16Encoder()
|
|
1650
|
-
})
|
|
1651
|
-
],
|
|
1652
|
-
["compiledMessage", getCompiledMessageEncoder()]
|
|
1653
|
-
],
|
|
1654
|
-
{
|
|
1655
|
-
description: transactionDescription
|
|
1656
|
-
}
|
|
1657
|
-
);
|
|
1658
|
-
}
|
|
1659
|
-
function getSignatureDecoder() {
|
|
1660
|
-
return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
|
|
1507
|
+
return getStructEncoder([
|
|
1508
|
+
["signatures", getArrayEncoder(getBytesEncoder({ size: 64 }), { size: getShortU16Encoder() })],
|
|
1509
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
1510
|
+
]);
|
|
1661
1511
|
}
|
|
1662
1512
|
function getCompiledTransactionDecoder() {
|
|
1663
|
-
return getStructDecoder(
|
|
1513
|
+
return getStructDecoder([
|
|
1664
1514
|
[
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
size: getShortU16Decoder()
|
|
1670
|
-
})
|
|
1671
|
-
],
|
|
1672
|
-
["compiledMessage", getCompiledMessageDecoder()]
|
|
1515
|
+
"signatures",
|
|
1516
|
+
getArrayDecoder(getBytesDecoder({ size: 64 }), {
|
|
1517
|
+
size: getShortU16Decoder()
|
|
1518
|
+
})
|
|
1673
1519
|
],
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
}
|
|
1677
|
-
);
|
|
1520
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
1521
|
+
]);
|
|
1678
1522
|
}
|
|
1679
1523
|
function getTransactionEncoder() {
|
|
1680
1524
|
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
@@ -1707,7 +1551,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1707
1551
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1708
1552
|
);
|
|
1709
1553
|
}
|
|
1710
|
-
const transactionSignature = base58Decoder.decode(signatureBytes)
|
|
1554
|
+
const transactionSignature = base58Decoder.decode(signatureBytes);
|
|
1711
1555
|
return transactionSignature;
|
|
1712
1556
|
}
|
|
1713
1557
|
async function partiallySignTransaction(keyPairs, transaction) {
|
|
@@ -1751,12 +1595,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1751
1595
|
// src/wire-transaction.ts
|
|
1752
1596
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1753
1597
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1754
|
-
return getBase64Decoder().decode(wireTransactionBytes)
|
|
1598
|
+
return getBase64Decoder().decode(wireTransactionBytes);
|
|
1755
1599
|
}
|
|
1756
1600
|
|
|
1757
1601
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1758
1602
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1759
1603
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1604
|
+
exports.assertIsTransactionWithBlockhashLifetime = assertIsTransactionWithBlockhashLifetime;
|
|
1760
1605
|
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1761
1606
|
exports.compileMessage = compileMessage;
|
|
1762
1607
|
exports.createTransaction = createTransaction;
|