@solana/signers 2.0.0-experimental.ef09aec → 2.0.0-experimental.fb88a79
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 +79 -21
- package/dist/index.browser.cjs +73 -14
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +70 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +387 -400
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +70 -15
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +73 -14
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +70 -15
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +31 -27
- package/dist/types/account-signer-meta.d.ts +6 -4
- package/dist/types/account-signer-meta.d.ts.map +1 -0
- package/dist/types/add-signers.d.ts +9 -0
- package/dist/types/add-signers.d.ts.map +1 -0
- package/dist/types/deduplicate-signers.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keypair-signer.d.ts.map +1 -0
- package/dist/types/message-modifying-signer.d.ts.map +1 -0
- package/dist/types/message-partial-signer.d.ts.map +1 -0
- package/dist/types/message-signer.d.ts.map +1 -0
- package/dist/types/noop-signer.d.ts.map +1 -0
- package/dist/types/sign-transaction.d.ts +5 -6
- package/dist/types/sign-transaction.d.ts.map +1 -0
- package/dist/types/signable-message.d.ts.map +1 -0
- package/dist/types/transaction-modifying-signer.d.ts.map +1 -0
- package/dist/types/transaction-partial-signer.d.ts.map +1 -0
- package/dist/types/transaction-sending-signer.d.ts.map +1 -0
- package/dist/types/transaction-signer.d.ts.map +1 -0
- package/dist/types/transaction-with-single-sending-signer.d.ts +11 -0
- package/dist/types/transaction-with-single-sending-signer.d.ts.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +6 -6
|
@@ -28,6 +28,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
28
28
|
return deduplicateSigners(transaction.instructions.flatMap(getSignersFromInstruction));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// ../instructions/dist/index.browser.js
|
|
32
|
+
function isSignerRole(role) {
|
|
33
|
+
return role >= 2;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/add-signers.ts
|
|
37
|
+
function addSignersToInstruction(signers, instruction) {
|
|
38
|
+
if (!instruction.accounts || instruction.accounts.length === 0) {
|
|
39
|
+
return instruction;
|
|
40
|
+
}
|
|
41
|
+
const signerByAddress = new Map(deduplicateSigners(signers).map((signer) => [signer.address, signer]));
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
...instruction,
|
|
44
|
+
accounts: instruction.accounts.map((account) => {
|
|
45
|
+
const signer = signerByAddress.get(account.address);
|
|
46
|
+
if (!isSignerRole(account.role) || "signer" in account || !signer) {
|
|
47
|
+
return account;
|
|
48
|
+
}
|
|
49
|
+
return Object.freeze({ ...account, signer });
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function addSignersToTransaction(signers, transaction) {
|
|
54
|
+
if (transaction.instructions.length === 0) {
|
|
55
|
+
return transaction;
|
|
56
|
+
}
|
|
57
|
+
return Object.freeze({
|
|
58
|
+
...transaction,
|
|
59
|
+
instructions: transaction.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
31
63
|
// ../codecs-core/dist/index.browser.js
|
|
32
64
|
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
33
65
|
if (bytes.length - offset <= 0) {
|
|
@@ -40,23 +72,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
40
72
|
throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
|
|
41
73
|
}
|
|
42
74
|
}
|
|
43
|
-
var mergeBytes = (byteArrays) => {
|
|
44
|
-
const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
|
|
45
|
-
if (nonEmptyByteArrays.length === 0) {
|
|
46
|
-
return byteArrays.length ? byteArrays[0] : new Uint8Array();
|
|
47
|
-
}
|
|
48
|
-
if (nonEmptyByteArrays.length === 1) {
|
|
49
|
-
return nonEmptyByteArrays[0];
|
|
50
|
-
}
|
|
51
|
-
const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
|
|
52
|
-
const result = new Uint8Array(totalLength);
|
|
53
|
-
let offset = 0;
|
|
54
|
-
nonEmptyByteArrays.forEach((arr) => {
|
|
55
|
-
result.set(arr, offset);
|
|
56
|
-
offset += arr.length;
|
|
57
|
-
});
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
75
|
var padBytes = (bytes, length) => {
|
|
61
76
|
if (bytes.length >= length)
|
|
62
77
|
return bytes;
|
|
@@ -65,42 +80,68 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
65
80
|
return paddedBytes;
|
|
66
81
|
};
|
|
67
82
|
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
68
|
-
function
|
|
69
|
-
return
|
|
70
|
-
description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
|
|
71
|
-
fixedSize: fixedBytes,
|
|
72
|
-
maxSize: fixedBytes
|
|
73
|
-
};
|
|
83
|
+
function getEncodedSize(value, encoder) {
|
|
84
|
+
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
74
85
|
}
|
|
75
|
-
function
|
|
76
|
-
return {
|
|
77
|
-
...
|
|
78
|
-
encode: (value) =>
|
|
79
|
-
|
|
86
|
+
function createEncoder(encoder) {
|
|
87
|
+
return Object.freeze({
|
|
88
|
+
...encoder,
|
|
89
|
+
encode: (value) => {
|
|
90
|
+
const bytes = new Uint8Array(getEncodedSize(value, encoder));
|
|
91
|
+
encoder.write(value, bytes, 0);
|
|
92
|
+
return bytes;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
80
95
|
}
|
|
81
|
-
function
|
|
82
|
-
return {
|
|
83
|
-
...
|
|
84
|
-
decode: (bytes, offset = 0) =>
|
|
96
|
+
function createDecoder(decoder) {
|
|
97
|
+
return Object.freeze({
|
|
98
|
+
...decoder,
|
|
99
|
+
decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function isFixedSize(codec) {
|
|
103
|
+
return "fixedSize" in codec && typeof codec.fixedSize === "number";
|
|
104
|
+
}
|
|
105
|
+
function assertIsFixedSize(codec, message) {
|
|
106
|
+
if (!isFixedSize(codec)) {
|
|
107
|
+
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function isVariableSize(codec) {
|
|
111
|
+
return !isFixedSize(codec);
|
|
112
|
+
}
|
|
113
|
+
function fixEncoder(encoder, fixedBytes) {
|
|
114
|
+
return createEncoder({
|
|
115
|
+
fixedSize: fixedBytes,
|
|
116
|
+
write: (value, bytes, offset) => {
|
|
117
|
+
const variableByteArray = encoder.encode(value);
|
|
118
|
+
const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray;
|
|
119
|
+
bytes.set(fixedByteArray, offset);
|
|
120
|
+
return offset + fixedBytes;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function fixDecoder(decoder, fixedBytes) {
|
|
125
|
+
return createDecoder({
|
|
126
|
+
fixedSize: fixedBytes,
|
|
127
|
+
read: (bytes, offset) => {
|
|
85
128
|
assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
|
|
86
129
|
if (offset > 0 || bytes.length > fixedBytes) {
|
|
87
130
|
bytes = bytes.slice(offset, offset + fixedBytes);
|
|
88
131
|
}
|
|
89
|
-
if (decoder
|
|
132
|
+
if (isFixedSize(decoder)) {
|
|
90
133
|
bytes = fixBytes(bytes, decoder.fixedSize);
|
|
91
134
|
}
|
|
92
|
-
const [value] = decoder.
|
|
135
|
+
const [value] = decoder.read(bytes, 0);
|
|
93
136
|
return [value, offset + fixedBytes];
|
|
94
137
|
}
|
|
95
|
-
};
|
|
138
|
+
});
|
|
96
139
|
}
|
|
97
140
|
function mapEncoder(encoder, unmap) {
|
|
98
|
-
return {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
maxSize: encoder.maxSize
|
|
103
|
-
};
|
|
141
|
+
return createEncoder({
|
|
142
|
+
...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder,
|
|
143
|
+
write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset)
|
|
144
|
+
});
|
|
104
145
|
}
|
|
105
146
|
|
|
106
147
|
// ../codecs-numbers/dist/index.browser.js
|
|
@@ -111,80 +152,66 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
111
152
|
);
|
|
112
153
|
}
|
|
113
154
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
let littleEndian;
|
|
117
|
-
let defaultDescription = input.name;
|
|
118
|
-
if (input.size > 1) {
|
|
119
|
-
littleEndian = !("endian" in input.config) || input.config.endian === 0;
|
|
120
|
-
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
description: (_a = input.config.description) != null ? _a : defaultDescription,
|
|
124
|
-
fixedSize: input.size,
|
|
125
|
-
littleEndian,
|
|
126
|
-
maxSize: input.size
|
|
127
|
-
};
|
|
155
|
+
function isLittleEndian(config) {
|
|
156
|
+
return (config == null ? void 0 : config.endian) === 1 ? false : true;
|
|
128
157
|
}
|
|
129
158
|
function numberEncoderFactory(input) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
encode(value) {
|
|
159
|
+
return createEncoder({
|
|
160
|
+
fixedSize: input.size,
|
|
161
|
+
write(value, bytes, offset) {
|
|
134
162
|
if (input.range) {
|
|
135
163
|
assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
|
|
136
164
|
}
|
|
137
165
|
const arrayBuffer = new ArrayBuffer(input.size);
|
|
138
|
-
input.set(new DataView(arrayBuffer), value,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
166
|
+
input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
|
|
167
|
+
bytes.set(new Uint8Array(arrayBuffer), offset);
|
|
168
|
+
return offset + input.size;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
144
171
|
}
|
|
145
172
|
function numberDecoderFactory(input) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
assertByteArrayIsNotEmptyForCodec(
|
|
150
|
-
assertByteArrayHasEnoughBytesForCodec(
|
|
173
|
+
return createDecoder({
|
|
174
|
+
fixedSize: input.size,
|
|
175
|
+
read(bytes, offset = 0) {
|
|
176
|
+
assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
|
|
177
|
+
assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
|
|
151
178
|
const view = new DataView(toArrayBuffer(bytes, offset, input.size));
|
|
152
|
-
return [input.get(view,
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
fixedSize: codecData.fixedSize,
|
|
156
|
-
maxSize: codecData.maxSize
|
|
157
|
-
};
|
|
179
|
+
return [input.get(view, isLittleEndian(input.config)), offset + input.size];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
158
182
|
}
|
|
159
183
|
function toArrayBuffer(bytes, offset, length) {
|
|
160
184
|
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
161
185
|
const bytesLength = length != null ? length : bytes.byteLength;
|
|
162
186
|
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
163
187
|
}
|
|
164
|
-
var getShortU16Encoder = (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
188
|
+
var getShortU16Encoder = () => createEncoder({
|
|
189
|
+
getSizeFromValue: (value) => {
|
|
190
|
+
if (value <= 127)
|
|
191
|
+
return 1;
|
|
192
|
+
if (value <= 16383)
|
|
193
|
+
return 2;
|
|
194
|
+
return 3;
|
|
195
|
+
},
|
|
196
|
+
maxSize: 3,
|
|
197
|
+
write: (value, bytes, offset) => {
|
|
198
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
199
|
+
const shortU16Bytes = [0];
|
|
200
|
+
for (let ii = 0; ; ii += 1) {
|
|
201
|
+
const alignedValue = value >> ii * 7;
|
|
202
|
+
if (alignedValue === 0) {
|
|
203
|
+
break;
|
|
181
204
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
const nextSevenBits = 127 & alignedValue;
|
|
206
|
+
shortU16Bytes[ii] = nextSevenBits;
|
|
207
|
+
if (ii > 0) {
|
|
208
|
+
shortU16Bytes[ii - 1] |= 128;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
bytes.set(shortU16Bytes, offset);
|
|
212
|
+
return offset + shortU16Bytes.length;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
188
215
|
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
189
216
|
config,
|
|
190
217
|
name: "u32",
|
|
@@ -198,8 +225,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
198
225
|
name: "u32",
|
|
199
226
|
size: 4
|
|
200
227
|
});
|
|
201
|
-
var getU8Encoder = (
|
|
202
|
-
config,
|
|
228
|
+
var getU8Encoder = () => numberEncoderFactory({
|
|
203
229
|
name: "u8",
|
|
204
230
|
range: [0, Number("0xff")],
|
|
205
231
|
set: (view, value) => view.setUint8(0, value),
|
|
@@ -213,43 +239,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
213
239
|
}
|
|
214
240
|
}
|
|
215
241
|
var getBaseXEncoder = (alphabet4) => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
242
|
+
return createEncoder({
|
|
243
|
+
getSizeFromValue: (value) => {
|
|
244
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
245
|
+
if (tailChars === "")
|
|
246
|
+
return value.length;
|
|
247
|
+
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
248
|
+
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
|
|
249
|
+
},
|
|
250
|
+
write(value, bytes, offset) {
|
|
221
251
|
assertValidBaseString(alphabet4, value);
|
|
222
252
|
if (value === "")
|
|
223
|
-
return
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (trailIndex === chars.length)
|
|
229
|
-
return Uint8Array.from(leadingZeroes);
|
|
230
|
-
const tailChars = chars.slice(trailIndex);
|
|
231
|
-
let base10Number = 0n;
|
|
232
|
-
let baseXPower = 1n;
|
|
233
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
234
|
-
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
235
|
-
baseXPower *= baseBigInt;
|
|
253
|
+
return offset;
|
|
254
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
255
|
+
if (tailChars === "") {
|
|
256
|
+
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
|
|
257
|
+
return offset + leadingZeroes.length;
|
|
236
258
|
}
|
|
259
|
+
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
237
260
|
const tailBytes = [];
|
|
238
261
|
while (base10Number > 0n) {
|
|
239
262
|
tailBytes.unshift(Number(base10Number % 256n));
|
|
240
263
|
base10Number /= 256n;
|
|
241
264
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
};
|
|
265
|
+
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
|
|
266
|
+
bytes.set(bytesToAdd, offset);
|
|
267
|
+
return offset + bytesToAdd.length;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
247
270
|
};
|
|
248
271
|
var getBaseXDecoder = (alphabet4) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
decode(rawBytes, offset = 0) {
|
|
272
|
+
return createDecoder({
|
|
273
|
+
read(rawBytes, offset) {
|
|
253
274
|
const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
|
|
254
275
|
if (bytes.length === 0)
|
|
255
276
|
return ["", 0];
|
|
@@ -258,19 +279,29 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
258
279
|
const leadingZeroes = alphabet4[0].repeat(trailIndex);
|
|
259
280
|
if (trailIndex === bytes.length)
|
|
260
281
|
return [leadingZeroes, rawBytes.length];
|
|
261
|
-
|
|
262
|
-
const tailChars =
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
return [leadingZeroes + tailChars.join(""), rawBytes.length];
|
|
268
|
-
},
|
|
269
|
-
description: `base${base}`,
|
|
270
|
-
fixedSize: null,
|
|
271
|
-
maxSize: null
|
|
272
|
-
};
|
|
282
|
+
const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
283
|
+
const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
|
|
284
|
+
return [leadingZeroes + tailChars, rawBytes.length];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
273
287
|
};
|
|
288
|
+
function partitionLeadingZeroes(value, zeroCharacter) {
|
|
289
|
+
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
|
|
290
|
+
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
|
|
291
|
+
}
|
|
292
|
+
function getBigIntFromBaseX(value, alphabet4) {
|
|
293
|
+
const base = BigInt(alphabet4.length);
|
|
294
|
+
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
|
|
295
|
+
}
|
|
296
|
+
function getBaseXFromBigInt(value, alphabet4) {
|
|
297
|
+
const base = BigInt(alphabet4.length);
|
|
298
|
+
const tailChars = [];
|
|
299
|
+
while (value > 0n) {
|
|
300
|
+
tailChars.unshift(alphabet4[Number(value % base)]);
|
|
301
|
+
value /= base;
|
|
302
|
+
}
|
|
303
|
+
return tailChars.join("");
|
|
304
|
+
}
|
|
274
305
|
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
275
306
|
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
276
307
|
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
@@ -282,77 +313,69 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
282
313
|
var o = globalThis.TextEncoder;
|
|
283
314
|
var getUtf8Encoder = () => {
|
|
284
315
|
let textEncoder;
|
|
285
|
-
return {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
316
|
+
return createEncoder({
|
|
317
|
+
getSizeFromValue: (value) => (textEncoder || (textEncoder = new o())).encode(value).length,
|
|
318
|
+
write: (value, bytes, offset) => {
|
|
319
|
+
const bytesToAdd = (textEncoder || (textEncoder = new o())).encode(value);
|
|
320
|
+
bytes.set(bytesToAdd, offset);
|
|
321
|
+
return offset + bytesToAdd.length;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
291
324
|
};
|
|
292
325
|
var getUtf8Decoder = () => {
|
|
293
326
|
let textDecoder;
|
|
294
|
-
return {
|
|
295
|
-
|
|
327
|
+
return createDecoder({
|
|
328
|
+
read(bytes, offset) {
|
|
296
329
|
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
297
330
|
return [removeNullCharacters(value), bytes.length];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
fixedSize: null,
|
|
301
|
-
maxSize: null
|
|
302
|
-
};
|
|
331
|
+
}
|
|
332
|
+
});
|
|
303
333
|
};
|
|
304
|
-
|
|
305
|
-
var _a, _b
|
|
334
|
+
function getStringEncoder(config = {}) {
|
|
335
|
+
var _a, _b;
|
|
306
336
|
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
307
337
|
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
|
|
308
|
-
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
309
338
|
if (size === "variable") {
|
|
310
|
-
return
|
|
339
|
+
return encoding;
|
|
311
340
|
}
|
|
312
341
|
if (typeof size === "number") {
|
|
313
|
-
return fixEncoder(encoding, size
|
|
342
|
+
return fixEncoder(encoding, size);
|
|
314
343
|
}
|
|
315
|
-
return {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const lengthBytes = size.encode(contentBytes.length);
|
|
320
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
344
|
+
return createEncoder({
|
|
345
|
+
getSizeFromValue: (value) => {
|
|
346
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
347
|
+
return getEncodedSize(contentSize, size) + contentSize;
|
|
321
348
|
},
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
349
|
+
write: (value, bytes, offset) => {
|
|
350
|
+
const contentSize = getEncodedSize(value, encoding);
|
|
351
|
+
offset = size.write(contentSize, bytes, offset);
|
|
352
|
+
return encoding.write(value, bytes, offset);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
function getStringDecoder(config = {}) {
|
|
357
|
+
var _a, _b;
|
|
328
358
|
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
329
359
|
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
|
|
330
|
-
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
331
360
|
if (size === "variable") {
|
|
332
|
-
return
|
|
361
|
+
return encoding;
|
|
333
362
|
}
|
|
334
363
|
if (typeof size === "number") {
|
|
335
|
-
return fixDecoder(encoding, size
|
|
364
|
+
return fixDecoder(encoding, size);
|
|
336
365
|
}
|
|
337
|
-
return {
|
|
338
|
-
|
|
366
|
+
return createDecoder({
|
|
367
|
+
read: (bytes, offset = 0) => {
|
|
339
368
|
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
340
|
-
const [lengthBigInt, lengthOffset] = size.
|
|
369
|
+
const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
|
|
341
370
|
const length = Number(lengthBigInt);
|
|
342
371
|
offset = lengthOffset;
|
|
343
372
|
const contentBytes = bytes.slice(offset, offset + length);
|
|
344
373
|
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
345
|
-
const [value, contentOffset] = encoding.
|
|
374
|
+
const [value, contentOffset] = encoding.read(contentBytes, 0);
|
|
346
375
|
offset += contentOffset;
|
|
347
376
|
return [value, offset];
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
fixedSize: null,
|
|
351
|
-
maxSize: null
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
function getSizeDescription(size) {
|
|
355
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
377
|
+
}
|
|
378
|
+
});
|
|
356
379
|
}
|
|
357
380
|
|
|
358
381
|
// ../assertions/dist/index.browser.js
|
|
@@ -466,24 +489,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
466
489
|
assertIsAddress(putativeAddress);
|
|
467
490
|
return putativeAddress;
|
|
468
491
|
}
|
|
469
|
-
function getAddressEncoder(
|
|
470
|
-
var _a;
|
|
492
|
+
function getAddressEncoder() {
|
|
471
493
|
return mapEncoder(
|
|
472
|
-
getStringEncoder({
|
|
473
|
-
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
474
|
-
encoding: getMemoizedBase58Encoder(),
|
|
475
|
-
size: 32
|
|
476
|
-
}),
|
|
494
|
+
getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }),
|
|
477
495
|
(putativeAddress) => address(putativeAddress)
|
|
478
496
|
);
|
|
479
497
|
}
|
|
480
|
-
function getAddressDecoder(
|
|
481
|
-
|
|
482
|
-
return getStringDecoder({
|
|
483
|
-
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
484
|
-
encoding: getMemoizedBase58Decoder(),
|
|
485
|
-
size: 32
|
|
486
|
-
});
|
|
498
|
+
function getAddressDecoder() {
|
|
499
|
+
return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 });
|
|
487
500
|
}
|
|
488
501
|
function getAddressComparator() {
|
|
489
502
|
return new Intl.Collator("en", {
|
|
@@ -501,8 +514,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
501
514
|
throw new Error("The `CryptoKey` must be an `Ed25519` public key");
|
|
502
515
|
}
|
|
503
516
|
const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
|
|
504
|
-
|
|
505
|
-
return base58EncodedAddress;
|
|
517
|
+
return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
|
|
506
518
|
}
|
|
507
519
|
|
|
508
520
|
// ../keys/dist/index.browser.js
|
|
@@ -527,94 +539,102 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
527
539
|
}
|
|
528
540
|
|
|
529
541
|
// ../codecs-data-structures/dist/index.browser.js
|
|
530
|
-
function sumCodecSizes(sizes) {
|
|
531
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
532
|
-
}
|
|
533
|
-
function getArrayLikeCodecSizeDescription(size) {
|
|
534
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
535
|
-
}
|
|
536
|
-
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
537
|
-
if (typeof size !== "number")
|
|
538
|
-
return null;
|
|
539
|
-
if (size === 0)
|
|
540
|
-
return 0;
|
|
541
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
542
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
543
|
-
}
|
|
544
|
-
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
545
|
-
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
546
|
-
}
|
|
547
542
|
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
548
543
|
if (expected !== actual) {
|
|
549
544
|
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
550
545
|
}
|
|
551
546
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
554
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
555
|
-
}
|
|
556
|
-
return {
|
|
557
|
-
description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
558
|
-
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
559
|
-
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
560
|
-
};
|
|
547
|
+
function sumCodecSizes(sizes) {
|
|
548
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
561
549
|
}
|
|
562
|
-
function
|
|
550
|
+
function getFixedSize(codec) {
|
|
551
|
+
return isFixedSize(codec) ? codec.fixedSize : null;
|
|
552
|
+
}
|
|
553
|
+
function getMaxSize(codec) {
|
|
563
554
|
var _a;
|
|
555
|
+
return isFixedSize(codec) ? codec.fixedSize : (_a = codec.maxSize) != null ? _a : null;
|
|
556
|
+
}
|
|
557
|
+
function getArrayEncoder(item, config = {}) {
|
|
558
|
+
var _a, _b;
|
|
564
559
|
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
560
|
+
if (size === "remainder") {
|
|
561
|
+
assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
|
|
562
|
+
}
|
|
563
|
+
const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
|
|
564
|
+
const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
|
|
565
|
+
return createEncoder({
|
|
566
|
+
...fixedSize !== null ? { fixedSize } : {
|
|
567
|
+
getSizeFromValue: (array) => {
|
|
568
|
+
const prefixSize = typeof size === "object" ? getEncodedSize(array.length, size) : 0;
|
|
569
|
+
return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);
|
|
570
|
+
},
|
|
571
|
+
maxSize
|
|
572
|
+
},
|
|
573
|
+
write: (array, bytes, offset) => {
|
|
568
574
|
if (typeof size === "number") {
|
|
569
|
-
assertValidNumberOfItemsForCodec("array", size,
|
|
575
|
+
assertValidNumberOfItemsForCodec("array", size, array.length);
|
|
576
|
+
}
|
|
577
|
+
if (typeof size === "object") {
|
|
578
|
+
offset = size.write(array.length, bytes, offset);
|
|
570
579
|
}
|
|
571
|
-
|
|
580
|
+
array.forEach((value) => {
|
|
581
|
+
offset = item.write(value, bytes, offset);
|
|
582
|
+
});
|
|
583
|
+
return offset;
|
|
572
584
|
}
|
|
573
|
-
};
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
function computeArrayLikeCodecSize(size, itemSize) {
|
|
588
|
+
if (typeof size !== "number")
|
|
589
|
+
return null;
|
|
590
|
+
if (size === 0)
|
|
591
|
+
return 0;
|
|
592
|
+
return itemSize === null ? null : itemSize * size;
|
|
574
593
|
}
|
|
575
594
|
function getBytesEncoder(config = {}) {
|
|
576
|
-
var _a
|
|
595
|
+
var _a;
|
|
577
596
|
const size = (_a = config.size) != null ? _a : "variable";
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
};
|
|
597
|
+
const byteEncoder = createEncoder({
|
|
598
|
+
getSizeFromValue: (value) => value.length,
|
|
599
|
+
write: (value, bytes, offset) => {
|
|
600
|
+
bytes.set(value, offset);
|
|
601
|
+
return offset + value.length;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
586
604
|
if (size === "variable") {
|
|
587
605
|
return byteEncoder;
|
|
588
606
|
}
|
|
589
607
|
if (typeof size === "number") {
|
|
590
|
-
return fixEncoder(byteEncoder, size
|
|
608
|
+
return fixEncoder(byteEncoder, size);
|
|
591
609
|
}
|
|
592
|
-
return {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
610
|
+
return createEncoder({
|
|
611
|
+
getSizeFromValue: (value) => getEncodedSize(value.length, size) + value.length,
|
|
612
|
+
write: (value, bytes, offset) => {
|
|
613
|
+
offset = size.write(value.length, bytes, offset);
|
|
614
|
+
return byteEncoder.write(value, bytes, offset);
|
|
598
615
|
}
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
function structCodecHelper(fields, description) {
|
|
602
|
-
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
603
|
-
return {
|
|
604
|
-
description: description != null ? description : `struct(${fieldDescriptions})`,
|
|
605
|
-
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
606
|
-
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
607
|
-
};
|
|
616
|
+
});
|
|
608
617
|
}
|
|
609
|
-
function getStructEncoder(fields
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
618
|
+
function getStructEncoder(fields) {
|
|
619
|
+
var _a;
|
|
620
|
+
const fieldCodecs = fields.map(([, codec]) => codec);
|
|
621
|
+
const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
|
|
622
|
+
const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
|
|
623
|
+
return createEncoder({
|
|
624
|
+
...fixedSize === null ? {
|
|
625
|
+
getSizeFromValue: (value) => fields.map(([key, codec]) => getEncodedSize(value[key], codec)).reduce((all, one) => all + one, 0),
|
|
626
|
+
maxSize
|
|
627
|
+
} : { fixedSize },
|
|
628
|
+
write: (struct, bytes, offset) => {
|
|
629
|
+
fields.forEach(([key, codec]) => {
|
|
630
|
+
offset = codec.write(struct[key], bytes, offset);
|
|
631
|
+
});
|
|
632
|
+
return offset;
|
|
615
633
|
}
|
|
616
|
-
};
|
|
634
|
+
});
|
|
617
635
|
}
|
|
636
|
+
|
|
637
|
+
// ../transactions/dist/index.browser.js
|
|
618
638
|
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
619
639
|
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
620
640
|
3] = "WRITABLE_SIGNER";
|
|
@@ -627,7 +647,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
627
647
|
return AccountRole2;
|
|
628
648
|
})(AccountRole || {});
|
|
629
649
|
var IS_WRITABLE_BITMASK = 1;
|
|
630
|
-
function
|
|
650
|
+
function isSignerRole2(role) {
|
|
631
651
|
return role >= 2;
|
|
632
652
|
}
|
|
633
653
|
function isWritableRole(role) {
|
|
@@ -701,7 +721,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
701
721
|
role: nextRole
|
|
702
722
|
};
|
|
703
723
|
}
|
|
704
|
-
} else if (
|
|
724
|
+
} else if (isSignerRole2(accountMeta.role)) {
|
|
705
725
|
return {
|
|
706
726
|
[TYPE]: 2,
|
|
707
727
|
role: nextRole
|
|
@@ -738,7 +758,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
738
758
|
}
|
|
739
759
|
} else if ("lookupTableAddress" in accountMeta && // Static accounts can be 'upgraded' to lookup table accounts as
|
|
740
760
|
// long as they are not require to sign the transaction.
|
|
741
|
-
!
|
|
761
|
+
!isSignerRole2(entry.role)) {
|
|
742
762
|
return {
|
|
743
763
|
...accountMeta,
|
|
744
764
|
[TYPE]: 1,
|
|
@@ -789,8 +809,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
789
809
|
return 1;
|
|
790
810
|
}
|
|
791
811
|
}
|
|
792
|
-
const leftIsSigner =
|
|
793
|
-
if (leftIsSigner !==
|
|
812
|
+
const leftIsSigner = isSignerRole2(leftEntry.role);
|
|
813
|
+
if (leftIsSigner !== isSignerRole2(rightEntry.role)) {
|
|
794
814
|
return leftIsSigner ? -1 : 1;
|
|
795
815
|
}
|
|
796
816
|
const leftIsWritable = isWritableRole(leftEntry.role);
|
|
@@ -840,7 +860,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
840
860
|
break;
|
|
841
861
|
}
|
|
842
862
|
const accountIsWritable = isWritableRole(account.role);
|
|
843
|
-
if (
|
|
863
|
+
if (isSignerRole2(account.role)) {
|
|
844
864
|
numSignerAccounts++;
|
|
845
865
|
if (!accountIsWritable) {
|
|
846
866
|
numReadonlySignerAccounts++;
|
|
@@ -895,33 +915,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
895
915
|
version: transaction.version
|
|
896
916
|
};
|
|
897
917
|
}
|
|
898
|
-
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
899
|
-
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
900
|
-
var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
|
|
901
|
-
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" ;
|
|
902
918
|
var memoizedAddressTableLookupEncoder;
|
|
903
919
|
function getAddressTableLookupEncoder() {
|
|
904
920
|
if (!memoizedAddressTableLookupEncoder) {
|
|
905
|
-
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
921
|
+
memoizedAddressTableLookupEncoder = getStructEncoder([
|
|
922
|
+
["lookupTableAddress", getAddressEncoder()],
|
|
906
923
|
[
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
"writableIndices",
|
|
910
|
-
getArrayEncoder(getU8Encoder(), {
|
|
911
|
-
description: writableIndicesDescription,
|
|
912
|
-
size: getShortU16Encoder()
|
|
913
|
-
})
|
|
914
|
-
],
|
|
915
|
-
[
|
|
916
|
-
"readableIndices",
|
|
917
|
-
getArrayEncoder(getU8Encoder(), {
|
|
918
|
-
description: readableIndicesDescription,
|
|
919
|
-
size: getShortU16Encoder()
|
|
920
|
-
})
|
|
921
|
-
]
|
|
924
|
+
"writableIndices",
|
|
925
|
+
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
|
|
922
926
|
],
|
|
923
|
-
|
|
924
|
-
|
|
927
|
+
[
|
|
928
|
+
"readableIndices",
|
|
929
|
+
getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
|
|
930
|
+
]
|
|
931
|
+
]);
|
|
925
932
|
}
|
|
926
933
|
return memoizedAddressTableLookupEncoder;
|
|
927
934
|
}
|
|
@@ -931,47 +938,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
931
938
|
memoizedU8Encoder = getU8Encoder();
|
|
932
939
|
return memoizedU8Encoder;
|
|
933
940
|
}
|
|
934
|
-
function getMemoizedU8EncoderDescription(description) {
|
|
935
|
-
const encoder = getMemoizedU8Encoder();
|
|
936
|
-
return {
|
|
937
|
-
...encoder,
|
|
938
|
-
description: description != null ? description : encoder.description
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
942
|
-
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" ;
|
|
943
|
-
var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
|
|
944
|
-
var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
|
|
945
941
|
function getMessageHeaderEncoder() {
|
|
946
|
-
return getStructEncoder(
|
|
947
|
-
[
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
],
|
|
952
|
-
{
|
|
953
|
-
description: messageHeaderDescription
|
|
954
|
-
}
|
|
955
|
-
);
|
|
942
|
+
return getStructEncoder([
|
|
943
|
+
["numSignerAccounts", getMemoizedU8Encoder()],
|
|
944
|
+
["numReadonlySignerAccounts", getMemoizedU8Encoder()],
|
|
945
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
|
|
946
|
+
]);
|
|
956
947
|
}
|
|
957
|
-
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
958
|
-
var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
|
|
959
|
-
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" ;
|
|
960
|
-
var dataDescription = "An optional buffer of data passed to the instruction" ;
|
|
961
948
|
var memoizedGetInstructionEncoder;
|
|
962
949
|
function getInstructionEncoder() {
|
|
963
950
|
if (!memoizedGetInstructionEncoder) {
|
|
964
951
|
memoizedGetInstructionEncoder = mapEncoder(
|
|
965
952
|
getStructEncoder([
|
|
966
|
-
["programAddressIndex", getU8Encoder(
|
|
967
|
-
[
|
|
968
|
-
|
|
969
|
-
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
970
|
-
description: accountIndicesDescription,
|
|
971
|
-
size: getShortU16Encoder()
|
|
972
|
-
})
|
|
973
|
-
],
|
|
974
|
-
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
953
|
+
["programAddressIndex", getU8Encoder()],
|
|
954
|
+
["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],
|
|
955
|
+
["data", getBytesEncoder({ size: getShortU16Encoder() })]
|
|
975
956
|
]),
|
|
976
957
|
// Convert an instruction to have all fields defined
|
|
977
958
|
(instruction) => {
|
|
@@ -990,30 +971,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
990
971
|
return memoizedGetInstructionEncoder;
|
|
991
972
|
}
|
|
992
973
|
var VERSION_FLAG_MASK = 128;
|
|
993
|
-
var BASE_CONFIG = {
|
|
994
|
-
description: "A single byte that encodes the version of the transaction" ,
|
|
995
|
-
fixedSize: null,
|
|
996
|
-
maxSize: 1
|
|
997
|
-
};
|
|
998
|
-
function encode(value) {
|
|
999
|
-
if (value === "legacy") {
|
|
1000
|
-
return new Uint8Array();
|
|
1001
|
-
}
|
|
1002
|
-
if (value < 0 || value > 127) {
|
|
1003
|
-
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
1004
|
-
}
|
|
1005
|
-
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1006
|
-
}
|
|
1007
974
|
function getTransactionVersionEncoder() {
|
|
1008
|
-
return {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
975
|
+
return createEncoder({
|
|
976
|
+
getSizeFromValue: (value) => value === "legacy" ? 0 : 1,
|
|
977
|
+
maxSize: 1,
|
|
978
|
+
write: (value, bytes, offset) => {
|
|
979
|
+
if (value === "legacy") {
|
|
980
|
+
return offset;
|
|
981
|
+
}
|
|
982
|
+
if (value < 0 || value > 127) {
|
|
983
|
+
throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
|
|
984
|
+
}
|
|
985
|
+
bytes.set([value | VERSION_FLAG_MASK], offset);
|
|
986
|
+
return offset + 1;
|
|
987
|
+
}
|
|
988
|
+
});
|
|
1012
989
|
}
|
|
1013
|
-
var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
|
|
1014
|
-
var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
|
|
1015
|
-
var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
|
|
1016
|
-
var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
|
|
1017
990
|
function getCompiledMessageLegacyEncoder() {
|
|
1018
991
|
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
1019
992
|
}
|
|
@@ -1039,50 +1012,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1039
1012
|
return [
|
|
1040
1013
|
["version", getTransactionVersionEncoder()],
|
|
1041
1014
|
["header", getMessageHeaderEncoder()],
|
|
1042
|
-
[
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
description: staticAccountsDescription,
|
|
1046
|
-
size: getShortU16Encoder()
|
|
1047
|
-
})
|
|
1048
|
-
],
|
|
1049
|
-
[
|
|
1050
|
-
"lifetimeToken",
|
|
1051
|
-
getStringEncoder({
|
|
1052
|
-
description: lifetimeTokenDescription,
|
|
1053
|
-
encoding: getBase58Encoder(),
|
|
1054
|
-
size: 32
|
|
1055
|
-
})
|
|
1056
|
-
],
|
|
1057
|
-
[
|
|
1058
|
-
"instructions",
|
|
1059
|
-
getArrayEncoder(getInstructionEncoder(), {
|
|
1060
|
-
description: instructionsDescription,
|
|
1061
|
-
size: getShortU16Encoder()
|
|
1062
|
-
})
|
|
1063
|
-
]
|
|
1015
|
+
["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],
|
|
1016
|
+
["lifetimeToken", getStringEncoder({ encoding: getBase58Encoder(), size: 32 })],
|
|
1017
|
+
["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })]
|
|
1064
1018
|
];
|
|
1065
1019
|
}
|
|
1066
1020
|
function getAddressTableLookupArrayEncoder() {
|
|
1067
|
-
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
1068
|
-
description: addressTableLookupsDescription,
|
|
1069
|
-
size: getShortU16Encoder()
|
|
1070
|
-
});
|
|
1021
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() });
|
|
1071
1022
|
}
|
|
1072
|
-
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1073
1023
|
function getCompiledMessageEncoder() {
|
|
1074
|
-
return {
|
|
1075
|
-
|
|
1076
|
-
encode: (compiledMessage) => {
|
|
1024
|
+
return createEncoder({
|
|
1025
|
+
getSizeFromValue: (compiledMessage) => {
|
|
1077
1026
|
if (compiledMessage.version === "legacy") {
|
|
1078
|
-
return getCompiledMessageLegacyEncoder().
|
|
1027
|
+
return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);
|
|
1079
1028
|
} else {
|
|
1080
|
-
return getCompiledMessageVersionedEncoder().
|
|
1029
|
+
return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);
|
|
1081
1030
|
}
|
|
1082
1031
|
},
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1032
|
+
write: (compiledMessage, bytes, offset) => {
|
|
1033
|
+
if (compiledMessage.version === "legacy") {
|
|
1034
|
+
return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);
|
|
1035
|
+
} else {
|
|
1036
|
+
return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1086
1040
|
}
|
|
1087
1041
|
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1088
1042
|
const compiledMessage = compileMessage(transaction);
|
|
@@ -1106,7 +1060,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1106
1060
|
function assertTransactionIsFullySigned(transaction) {
|
|
1107
1061
|
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
|
|
1108
1062
|
var _a, _b;
|
|
1109
|
-
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) =>
|
|
1063
|
+
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : [];
|
|
1110
1064
|
}).map((a) => a.address);
|
|
1111
1065
|
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
1112
1066
|
requiredSigners.forEach((address2) => {
|
|
@@ -1253,16 +1207,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1253
1207
|
partialSigners,
|
|
1254
1208
|
abortSignal
|
|
1255
1209
|
);
|
|
1256
|
-
if (sendingSigner) {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
}
|
|
1261
|
-
if (config.fallbackSender) {
|
|
1262
|
-
assertTransactionIsFullySigned(signedTransaction);
|
|
1263
|
-
return config.fallbackSender(signedTransaction);
|
|
1210
|
+
if (!sendingSigner) {
|
|
1211
|
+
throw new Error(
|
|
1212
|
+
"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction."
|
|
1213
|
+
);
|
|
1264
1214
|
}
|
|
1265
|
-
|
|
1215
|
+
abortSignal == null ? void 0 : abortSignal.throwIfAborted();
|
|
1216
|
+
const [signature] = await sendingSigner.signAndSendTransactions([signedTransaction], { abortSignal });
|
|
1217
|
+
abortSignal == null ? void 0 : abortSignal.throwIfAborted();
|
|
1218
|
+
return signature;
|
|
1266
1219
|
}
|
|
1267
1220
|
function categorizeTransactionSigners(signers, config = {}) {
|
|
1268
1221
|
var _a;
|
|
@@ -1298,11 +1251,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1298
1251
|
}
|
|
1299
1252
|
async function signModifyingAndPartialTransactionSigners(transaction, modifyingSigners = [], partialSigners = [], abortSignal) {
|
|
1300
1253
|
var _a;
|
|
1301
|
-
const modifiedTransaction = await modifyingSigners.reduce(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1254
|
+
const modifiedTransaction = await modifyingSigners.reduce(
|
|
1255
|
+
async (transaction2, modifyingSigner) => {
|
|
1256
|
+
abortSignal == null ? void 0 : abortSignal.throwIfAborted();
|
|
1257
|
+
const [tx] = await modifyingSigner.modifyAndSignTransactions([await transaction2], { abortSignal });
|
|
1258
|
+
return Object.freeze(tx);
|
|
1259
|
+
},
|
|
1260
|
+
Promise.resolve(transaction)
|
|
1261
|
+
);
|
|
1306
1262
|
abortSignal == null ? void 0 : abortSignal.throwIfAborted();
|
|
1307
1263
|
const signatureDictionaries = await Promise.all(
|
|
1308
1264
|
partialSigners.map(async (partialSigner) => {
|
|
@@ -1330,6 +1286,35 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1330
1286
|
});
|
|
1331
1287
|
}
|
|
1332
1288
|
|
|
1289
|
+
// src/transaction-with-single-sending-signer.ts
|
|
1290
|
+
function isTransactionWithSingleSendingSigner(transaction) {
|
|
1291
|
+
try {
|
|
1292
|
+
assertIsTransactionWithSingleSendingSigner(transaction);
|
|
1293
|
+
return true;
|
|
1294
|
+
} catch {
|
|
1295
|
+
return false;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
function assertIsTransactionWithSingleSendingSigner(transaction) {
|
|
1299
|
+
const signers = getSignersFromTransaction(transaction);
|
|
1300
|
+
const sendingSigners = signers.filter(isTransactionSendingSigner);
|
|
1301
|
+
if (sendingSigners.length === 0) {
|
|
1302
|
+
const error = new Error("No `TransactionSendingSigner` was identified.");
|
|
1303
|
+
error.name = "MissingTransactionSendingSignerError";
|
|
1304
|
+
throw error;
|
|
1305
|
+
}
|
|
1306
|
+
const sendingOnlySigners = sendingSigners.filter(
|
|
1307
|
+
(signer) => !isTransactionPartialSigner(signer) && !isTransactionModifyingSigner(signer)
|
|
1308
|
+
);
|
|
1309
|
+
if (sendingOnlySigners.length > 1) {
|
|
1310
|
+
const error = new Error("More than one `TransactionSendingSigner` was identified.");
|
|
1311
|
+
error.name = "MultipleTransactionSendingSignersError";
|
|
1312
|
+
throw error;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
exports.addSignersToInstruction = addSignersToInstruction;
|
|
1317
|
+
exports.addSignersToTransaction = addSignersToTransaction;
|
|
1333
1318
|
exports.assertIsKeyPairSigner = assertIsKeyPairSigner;
|
|
1334
1319
|
exports.assertIsMessageModifyingSigner = assertIsMessageModifyingSigner;
|
|
1335
1320
|
exports.assertIsMessagePartialSigner = assertIsMessagePartialSigner;
|
|
@@ -1338,6 +1323,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1338
1323
|
exports.assertIsTransactionPartialSigner = assertIsTransactionPartialSigner;
|
|
1339
1324
|
exports.assertIsTransactionSendingSigner = assertIsTransactionSendingSigner;
|
|
1340
1325
|
exports.assertIsTransactionSigner = assertIsTransactionSigner;
|
|
1326
|
+
exports.assertIsTransactionWithSingleSendingSigner = assertIsTransactionWithSingleSendingSigner;
|
|
1341
1327
|
exports.createNoopSigner = createNoopSigner;
|
|
1342
1328
|
exports.createSignableMessage = createSignableMessage;
|
|
1343
1329
|
exports.createSignerFromKeyPair = createSignerFromKeyPair;
|
|
@@ -1352,6 +1338,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1352
1338
|
exports.isTransactionPartialSigner = isTransactionPartialSigner;
|
|
1353
1339
|
exports.isTransactionSendingSigner = isTransactionSendingSigner;
|
|
1354
1340
|
exports.isTransactionSigner = isTransactionSigner;
|
|
1341
|
+
exports.isTransactionWithSingleSendingSigner = isTransactionWithSingleSendingSigner;
|
|
1355
1342
|
exports.partiallySignTransactionWithSigners = partiallySignTransactionWithSigners;
|
|
1356
1343
|
exports.signAndSendTransactionWithSigners = signAndSendTransactionWithSigners;
|
|
1357
1344
|
exports.signTransactionWithSigners = signTransactionWithSigners;
|