@solana/addresses 2.0.0-experimental.433f475 → 2.0.0-experimental.445121c
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 +1 -1
- package/dist/index.browser.cjs +10 -21
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +10 -21
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +173 -194
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +10 -19
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +10 -21
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +10 -21
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +13 -13
- package/dist/types/address.d.ts +4 -10
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/curve.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/program-derived-address.d.ts.map +1 -0
- package/dist/types/public-key.d.ts.map +1 -0
- package/dist/types/vendor/noble/ed25519.d.ts.map +1 -0
- package/package.json +6 -6
|
@@ -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,66 +22,86 @@ 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 isVariableSize(codec) {
|
|
48
|
+
return !isFixedSize(codec);
|
|
49
|
+
}
|
|
50
|
+
function combineCodec(encoder, decoder) {
|
|
51
|
+
if (isFixedSize(encoder) !== isFixedSize(decoder)) {
|
|
52
|
+
throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);
|
|
53
|
+
}
|
|
54
|
+
if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
|
|
44
55
|
throw new Error(
|
|
45
56
|
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
46
57
|
);
|
|
47
58
|
}
|
|
48
|
-
if (encoder.maxSize !== decoder.maxSize) {
|
|
59
|
+
if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
|
|
49
60
|
throw new Error(
|
|
50
61
|
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
51
62
|
);
|
|
52
63
|
}
|
|
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
64
|
return {
|
|
65
|
+
...decoder,
|
|
66
|
+
...encoder,
|
|
59
67
|
decode: decoder.decode,
|
|
60
|
-
description: description ?? encoder.description,
|
|
61
68
|
encode: encoder.encode,
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
read: decoder.read,
|
|
70
|
+
write: encoder.write
|
|
64
71
|
};
|
|
65
72
|
}
|
|
66
|
-
function
|
|
67
|
-
return {
|
|
68
|
-
description: description ?? `fixed(${fixedBytes}, ${data.description})`,
|
|
73
|
+
function fixEncoder(encoder, fixedBytes) {
|
|
74
|
+
return createEncoder({
|
|
69
75
|
fixedSize: fixedBytes,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
76
|
+
write: (value, bytes, offset) => {
|
|
77
|
+
const variableByteArray = encoder.encode(value);
|
|
78
|
+
const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray;
|
|
79
|
+
bytes.set(fixedByteArray, offset);
|
|
80
|
+
return offset + fixedBytes;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
78
83
|
}
|
|
79
|
-
function fixDecoder(decoder, fixedBytes
|
|
80
|
-
return {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
function fixDecoder(decoder, fixedBytes) {
|
|
85
|
+
return createDecoder({
|
|
86
|
+
fixedSize: fixedBytes,
|
|
87
|
+
read: (bytes, offset) => {
|
|
83
88
|
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
84
89
|
if (offset > 0 || bytes.length > fixedBytes) {
|
|
85
90
|
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
86
91
|
}
|
|
87
|
-
if (decoder
|
|
92
|
+
if (isFixedSize(decoder)) {
|
|
88
93
|
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
89
94
|
}
|
|
90
|
-
const [value] = decoder.
|
|
95
|
+
const [value] = decoder.read(bytes, 0);
|
|
91
96
|
return [value, offset + fixedBytes];
|
|
92
97
|
}
|
|
93
|
-
};
|
|
98
|
+
});
|
|
94
99
|
}
|
|
95
100
|
function mapEncoder(encoder, unmap) {
|
|
96
|
-
return {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
maxSize: encoder.maxSize
|
|
101
|
-
};
|
|
101
|
+
return createEncoder({
|
|
102
|
+
...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder,
|
|
103
|
+
write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset)
|
|
104
|
+
});
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
// ../codecs-numbers/dist/index.browser.js
|
|
@@ -109,53 +112,37 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
109
112
|
);
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
let defaultDescription = input.name;
|
|
115
|
-
if (input.size > 1) {
|
|
116
|
-
littleEndian = !("endian" in input.config) || input.config.endian === 0;
|
|
117
|
-
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
description: input.config.description ?? defaultDescription,
|
|
121
|
-
fixedSize: input.size,
|
|
122
|
-
littleEndian,
|
|
123
|
-
maxSize: input.size
|
|
124
|
-
};
|
|
115
|
+
function isLittleEndian(config) {
|
|
116
|
+
return (config == null ? void 0 : config.endian) === 1 ? false : true;
|
|
125
117
|
}
|
|
126
118
|
function numberEncoderFactory(input) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
encode(value) {
|
|
119
|
+
return createEncoder({
|
|
120
|
+
fixedSize: input.size,
|
|
121
|
+
write(value, bytes, offset) {
|
|
131
122
|
if (input.range) {
|
|
132
123
|
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
133
124
|
}
|
|
134
125
|
const arrayBuffer = new ArrayBuffer(input.size);
|
|
135
|
-
input.set(new DataView(arrayBuffer), value,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
126
|
+
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
|
|
127
|
+
bytes.set(new Uint8Array(arrayBuffer), offset);
|
|
128
|
+
return offset + input.size;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
141
131
|
}
|
|
142
132
|
function numberDecoderFactory(input) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
assertByteArrayIsNotEmptyForCodec(
|
|
147
|
-
assertByteArrayHasEnoughBytesForCodec(
|
|
133
|
+
return createDecoder({
|
|
134
|
+
fixedSize: input.size,
|
|
135
|
+
read(bytes, offset = 0) {
|
|
136
|
+
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
|
|
137
|
+
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
|
|
148
138
|
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
149
|
-
return [input.get(view,
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
fixedSize: codecData.fixedSize,
|
|
153
|
-
maxSize: codecData.maxSize
|
|
154
|
-
};
|
|
139
|
+
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
155
142
|
}
|
|
156
143
|
function toArrayBuffer(bytes, offset, length) {
|
|
157
|
-
const bytesOffset = bytes.byteOffset + (offset
|
|
158
|
-
const bytesLength = length
|
|
144
|
+
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
145
|
+
const bytesLength = length != null ? length : bytes.byteLength;
|
|
159
146
|
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
160
147
|
}
|
|
161
148
|
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
@@ -179,43 +166,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
179
166
|
}
|
|
180
167
|
}
|
|
181
168
|
var getBaseXEncoder = (alphabet4) => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
169
|
+
return createEncoder({
|
|
170
|
+
getSizeFromValue: (value) => {
|
|
171
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
172
|
+
if (tailChars === "")
|
|
173
|
+
return value.length;
|
|
174
|
+
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
175
|
+
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
|
|
176
|
+
},
|
|
177
|
+
write(value, bytes, offset) {
|
|
187
178
|
assertValidBaseString(alphabet4, value);
|
|
188
179
|
if (value === "")
|
|
189
|
-
return
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (trailIndex === chars.length)
|
|
195
|
-
return Uint8Array.from(leadingZeroes);
|
|
196
|
-
const tailChars = chars.slice(trailIndex);
|
|
197
|
-
let base10Number = 0n;
|
|
198
|
-
let baseXPower = 1n;
|
|
199
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
200
|
-
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
201
|
-
baseXPower *= baseBigInt;
|
|
180
|
+
return offset;
|
|
181
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
182
|
+
if (tailChars === "") {
|
|
183
|
+
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
|
|
184
|
+
return offset + leadingZeroes.length;
|
|
202
185
|
}
|
|
186
|
+
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
203
187
|
const tailBytes = [];
|
|
204
188
|
while (base10Number > 0n) {
|
|
205
189
|
tailBytes.unshift(Number(base10Number % 256n));
|
|
206
190
|
base10Number /= 256n;
|
|
207
191
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
192
|
+
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
|
|
193
|
+
bytes.set(bytesToAdd, offset);
|
|
194
|
+
return offset + bytesToAdd.length;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
213
197
|
};
|
|
214
198
|
var getBaseXDecoder = (alphabet4) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
decode(rawBytes, offset = 0) {
|
|
199
|
+
return createDecoder({
|
|
200
|
+
read(rawBytes, offset) {
|
|
219
201
|
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
220
202
|
if (bytes.length === 0)
|
|
221
203
|
return ["", 0];
|
|
@@ -224,19 +206,29 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
224
206
|
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
225
207
|
if (trailIndex === bytes.length)
|
|
226
208
|
return [leadingZeroes, rawBytes.length];
|
|
227
|
-
|
|
228
|
-
const tailChars =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
234
|
-
},
|
|
235
|
-
description: `base${base}`,
|
|
236
|
-
fixedSize: null,
|
|
237
|
-
maxSize: null
|
|
238
|
-
};
|
|
209
|
+
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
210
|
+
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
|
|
211
|
+
return [leadingZeroes + tailChars, rawBytes.length];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
239
214
|
};
|
|
215
|
+
function partitionLeadingZeroes(value, zeroCharacter) {
|
|
216
|
+
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
|
|
217
|
+
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
|
|
218
|
+
}
|
|
219
|
+
function getBigIntFromBaseX(value, alphabet4) {
|
|
220
|
+
const base = BigInt(alphabet4.length);
|
|
221
|
+
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
|
|
222
|
+
}
|
|
223
|
+
function getBaseXFromBigInt(value, alphabet4) {
|
|
224
|
+
const base = BigInt(alphabet4.length);
|
|
225
|
+
const tailChars = [];
|
|
226
|
+
while (value > 0n) {
|
|
227
|
+
tailChars.unshift(alphabet4[Number(value % base)]);
|
|
228
|
+
value /= base;
|
|
229
|
+
}
|
|
230
|
+
return tailChars.join("");
|
|
231
|
+
}
|
|
240
232
|
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
241
233
|
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
242
234
|
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
@@ -248,75 +240,69 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
248
240
|
var o = globalThis.TextEncoder;
|
|
249
241
|
var getUtf8Encoder = () => {
|
|
250
242
|
let textEncoder;
|
|
251
|
-
return {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
243
|
+
return createEncoder({
|
|
244
|
+
getSizeFromValue: (value) => (textEncoder || (textEncoder = new o())).encode(value).length,
|
|
245
|
+
write: (value, bytes, offset) => {
|
|
246
|
+
const bytesToAdd = (textEncoder || (textEncoder = new o())).encode(value);
|
|
247
|
+
bytes.set(bytesToAdd, offset);
|
|
248
|
+
return offset + bytesToAdd.length;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
257
251
|
};
|
|
258
252
|
var getUtf8Decoder = () => {
|
|
259
253
|
let textDecoder;
|
|
260
|
-
return {
|
|
261
|
-
|
|
254
|
+
return createDecoder({
|
|
255
|
+
read(bytes, offset) {
|
|
262
256
|
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
263
257
|
return [removeNullCharacters(value), bytes.length];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
fixedSize: null,
|
|
267
|
-
maxSize: null
|
|
268
|
-
};
|
|
258
|
+
}
|
|
259
|
+
});
|
|
269
260
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
const
|
|
261
|
+
function getStringEncoder(config = {}) {
|
|
262
|
+
var _a, _b;
|
|
263
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
264
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
|
|
274
265
|
if (size === "variable") {
|
|
275
|
-
return
|
|
266
|
+
return encoding;
|
|
276
267
|
}
|
|
277
268
|
if (typeof size === "number") {
|
|
278
|
-
return fixEncoder(encoding, size
|
|
269
|
+
return fixEncoder(encoding, size);
|
|
279
270
|
}
|
|
280
|
-
return {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const lengthBytes = size.encode(contentBytes.length);
|
|
285
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
271
|
+
return createEncoder({
|
|
272
|
+
getSizeFromValue: (value) => {
|
|
273
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
274
|
+
return getEncodedSize(contentSize, size) + contentSize;
|
|
286
275
|
},
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
276
|
+
write: (value, bytes, offset) => {
|
|
277
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
278
|
+
offset = size.write(contentSize, bytes, offset);
|
|
279
|
+
return encoding.write(value, bytes, offset);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function getStringDecoder(config = {}) {
|
|
284
|
+
var _a, _b;
|
|
285
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
286
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
|
|
295
287
|
if (size === "variable") {
|
|
296
|
-
return
|
|
288
|
+
return encoding;
|
|
297
289
|
}
|
|
298
290
|
if (typeof size === "number") {
|
|
299
|
-
return fixDecoder(encoding, size
|
|
291
|
+
return fixDecoder(encoding, size);
|
|
300
292
|
}
|
|
301
|
-
return {
|
|
302
|
-
|
|
293
|
+
return createDecoder({
|
|
294
|
+
read: (bytes, offset = 0) => {
|
|
303
295
|
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
304
|
-
const [lengthBigInt, lengthOffset] = size.
|
|
296
|
+
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
|
|
305
297
|
const length = Number(lengthBigInt);
|
|
306
298
|
offset = lengthOffset;
|
|
307
299
|
const contentBytes = bytes.slice(offset, offset + length);
|
|
308
300
|
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
309
|
-
const [value, contentOffset] = encoding.
|
|
301
|
+
const [value, contentOffset] = encoding.read(contentBytes, 0);
|
|
310
302
|
offset += contentOffset;
|
|
311
303
|
return [value, offset];
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
fixedSize: null,
|
|
315
|
-
maxSize: null
|
|
316
|
-
};
|
|
317
|
-
};
|
|
318
|
-
function getSizeDescription(size) {
|
|
319
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
320
306
|
}
|
|
321
307
|
|
|
322
308
|
// src/address.ts
|
|
@@ -373,25 +359,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
373
359
|
assertIsAddress(putativeAddress);
|
|
374
360
|
return putativeAddress;
|
|
375
361
|
}
|
|
376
|
-
function getAddressEncoder(
|
|
362
|
+
function getAddressEncoder() {
|
|
377
363
|
return mapEncoder(
|
|
378
|
-
getStringEncoder({
|
|
379
|
-
description: config?.description ?? "Address",
|
|
380
|
-
encoding: getMemoizedBase58Encoder(),
|
|
381
|
-
size: 32
|
|
382
|
-
}),
|
|
364
|
+
getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }),
|
|
383
365
|
(putativeAddress) => address(putativeAddress)
|
|
384
366
|
);
|
|
385
367
|
}
|
|
386
|
-
function getAddressDecoder(
|
|
387
|
-
return getStringDecoder({
|
|
388
|
-
description: config?.description ?? "Address",
|
|
389
|
-
encoding: getMemoizedBase58Decoder(),
|
|
390
|
-
size: 32
|
|
391
|
-
});
|
|
368
|
+
function getAddressDecoder() {
|
|
369
|
+
return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 });
|
|
392
370
|
}
|
|
393
|
-
function getAddressCodec(
|
|
394
|
-
return combineCodec(getAddressEncoder(
|
|
371
|
+
function getAddressCodec() {
|
|
372
|
+
return combineCodec(getAddressEncoder(), getAddressDecoder());
|
|
395
373
|
}
|
|
396
374
|
function getAddressComparator() {
|
|
397
375
|
return new Intl.Collator("en", {
|
|
@@ -413,14 +391,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
413
391
|
}
|
|
414
392
|
}
|
|
415
393
|
async function assertDigestCapabilityIsAvailable() {
|
|
394
|
+
var _a;
|
|
416
395
|
assertIsSecureContext();
|
|
417
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
396
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.digest) !== "function") {
|
|
418
397
|
throw new Error("No digest implementation could be found");
|
|
419
398
|
}
|
|
420
399
|
}
|
|
421
400
|
async function assertKeyExporterIsAvailable() {
|
|
401
|
+
var _a;
|
|
422
402
|
assertIsSecureContext();
|
|
423
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
403
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
|
|
424
404
|
throw new Error("No key export implementation could be found");
|
|
425
405
|
}
|
|
426
406
|
}
|
|
@@ -583,7 +563,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
583
563
|
if (await compressedPointBytesAreOnCurve(addressBytes)) {
|
|
584
564
|
throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
|
|
585
565
|
}
|
|
586
|
-
return base58EncodedAddressCodec.decode(addressBytes)
|
|
566
|
+
return base58EncodedAddressCodec.decode(addressBytes);
|
|
587
567
|
}
|
|
588
568
|
async function getProgramDerivedAddress({
|
|
589
569
|
programAddress,
|
|
@@ -622,7 +602,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
622
602
|
new Uint8Array([...encode(baseAddress), ...seedBytes, ...programAddressBytes])
|
|
623
603
|
);
|
|
624
604
|
const addressBytes = new Uint8Array(addressBytesBuffer);
|
|
625
|
-
return decode(addressBytes)
|
|
605
|
+
return decode(addressBytes);
|
|
626
606
|
}
|
|
627
607
|
|
|
628
608
|
// src/public-key.ts
|
|
@@ -632,8 +612,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
632
612
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
633
613
|
}
|
|
634
614
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
635
|
-
|
|
636
|
-
return base58EncodedAddress;
|
|
615
|
+
return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
637
616
|
}
|
|
638
617
|
|
|
639
618
|
exports.address = address;
|