@solana/transactions 2.0.0-experimental.68e85dc → 2.0.0-experimental.699bde0
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 -43
- package/dist/index.browser.cjs +345 -75
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +348 -75
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +888 -490
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +346 -75
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +347 -73
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +348 -75
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +18 -17
- package/dist/types/accounts.d.ts +2 -2
- package/dist/types/compilable-transaction.d.ts +7 -0
- package/dist/types/compile-address-table-lookups.d.ts +2 -2
- package/dist/types/compile-static-accounts.d.ts +2 -2
- package/dist/types/compile-transaction.d.ts +5 -6
- package/dist/types/decompile-transaction.d.ts +5 -0
- package/dist/types/durable-nonce.d.ts +5 -6
- package/dist/types/fee-payer.d.ts +4 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/message.d.ts +1 -5
- package/dist/types/serializers/transaction.d.ts +5 -5
- package/dist/types/signatures.d.ts +8 -12
- package/dist/types/types.d.ts +6 -13
- package/package.json +13 -14
|
@@ -2,252 +2,6 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __publicField = (obj, key, value) => {
|
|
8
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
|
|
13
|
-
var InvalidBaseStringError = class extends Error {
|
|
14
|
-
constructor(value, base, cause) {
|
|
15
|
-
const message = `Expected a string of base ${base}, got [${value}].`;
|
|
16
|
-
super(message);
|
|
17
|
-
__publicField(this, "name", "InvalidBaseStringError");
|
|
18
|
-
this.cause = cause;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
|
|
23
|
-
var baseX = (alphabet) => {
|
|
24
|
-
const base = alphabet.length;
|
|
25
|
-
const baseBigInt = BigInt(base);
|
|
26
|
-
return {
|
|
27
|
-
description: `base${base}`,
|
|
28
|
-
fixedSize: null,
|
|
29
|
-
maxSize: null,
|
|
30
|
-
serialize(value) {
|
|
31
|
-
if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
|
|
32
|
-
throw new InvalidBaseStringError(value, base);
|
|
33
|
-
}
|
|
34
|
-
if (value === "")
|
|
35
|
-
return new Uint8Array();
|
|
36
|
-
const chars = [...value];
|
|
37
|
-
let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
|
|
38
|
-
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
39
|
-
const leadingZeroes = Array(trailIndex).fill(0);
|
|
40
|
-
if (trailIndex === chars.length)
|
|
41
|
-
return Uint8Array.from(leadingZeroes);
|
|
42
|
-
const tailChars = chars.slice(trailIndex);
|
|
43
|
-
let base10Number = 0n;
|
|
44
|
-
let baseXPower = 1n;
|
|
45
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
46
|
-
base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
|
|
47
|
-
baseXPower *= baseBigInt;
|
|
48
|
-
}
|
|
49
|
-
const tailBytes = [];
|
|
50
|
-
while (base10Number > 0n) {
|
|
51
|
-
tailBytes.unshift(Number(base10Number % 256n));
|
|
52
|
-
base10Number /= 256n;
|
|
53
|
-
}
|
|
54
|
-
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
55
|
-
},
|
|
56
|
-
deserialize(buffer, offset = 0) {
|
|
57
|
-
if (buffer.length === 0)
|
|
58
|
-
return ["", 0];
|
|
59
|
-
const bytes = buffer.slice(offset);
|
|
60
|
-
let trailIndex = bytes.findIndex((n) => n !== 0);
|
|
61
|
-
trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
|
|
62
|
-
const leadingZeroes = alphabet[0].repeat(trailIndex);
|
|
63
|
-
if (trailIndex === bytes.length)
|
|
64
|
-
return [leadingZeroes, buffer.length];
|
|
65
|
-
let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
|
|
66
|
-
const tailChars = [];
|
|
67
|
-
while (base10Number > 0n) {
|
|
68
|
-
tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
|
|
69
|
-
base10Number /= baseBigInt;
|
|
70
|
-
}
|
|
71
|
-
return [leadingZeroes + tailChars.join(""), buffer.length];
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
|
|
77
|
-
var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
78
|
-
|
|
79
|
-
// src/unsigned-transaction.ts
|
|
80
|
-
function getUnsignedTransaction(transaction) {
|
|
81
|
-
if ("signatures" in transaction) {
|
|
82
|
-
const {
|
|
83
|
-
signatures: _,
|
|
84
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
85
|
-
...unsignedTransaction
|
|
86
|
-
} = transaction;
|
|
87
|
-
return unsignedTransaction;
|
|
88
|
-
} else {
|
|
89
|
-
return transaction;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// src/blockhash.ts
|
|
94
|
-
function assertIsBlockhash(putativeBlockhash) {
|
|
95
|
-
try {
|
|
96
|
-
if (
|
|
97
|
-
// Lowest value (32 bytes of zeroes)
|
|
98
|
-
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
|
|
99
|
-
putativeBlockhash.length > 44
|
|
100
|
-
) {
|
|
101
|
-
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
102
|
-
}
|
|
103
|
-
const bytes = base58.serialize(putativeBlockhash);
|
|
104
|
-
const numBytes = bytes.byteLength;
|
|
105
|
-
if (numBytes !== 32) {
|
|
106
|
-
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
107
|
-
}
|
|
108
|
-
} catch (e2) {
|
|
109
|
-
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
110
|
-
cause: e2
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
115
|
-
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
116
|
-
return transaction;
|
|
117
|
-
}
|
|
118
|
-
const out = {
|
|
119
|
-
...getUnsignedTransaction(transaction),
|
|
120
|
-
lifetimeConstraint: blockhashLifetimeConstraint
|
|
121
|
-
};
|
|
122
|
-
Object.freeze(out);
|
|
123
|
-
return out;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/create-transaction.ts
|
|
127
|
-
function createTransaction({
|
|
128
|
-
version
|
|
129
|
-
}) {
|
|
130
|
-
const out = {
|
|
131
|
-
instructions: [],
|
|
132
|
-
version
|
|
133
|
-
};
|
|
134
|
-
Object.freeze(out);
|
|
135
|
-
return out;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ../instructions/dist/index.browser.js
|
|
139
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
140
|
-
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
141
|
-
3] = "WRITABLE_SIGNER";
|
|
142
|
-
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
143
|
-
2] = "READONLY_SIGNER";
|
|
144
|
-
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
145
|
-
1] = "WRITABLE";
|
|
146
|
-
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
147
|
-
0] = "READONLY";
|
|
148
|
-
return AccountRole2;
|
|
149
|
-
})(AccountRole || {});
|
|
150
|
-
var IS_WRITABLE_BITMASK = 1;
|
|
151
|
-
function isSignerRole(role) {
|
|
152
|
-
return role >= 2;
|
|
153
|
-
}
|
|
154
|
-
function isWritableRole(role) {
|
|
155
|
-
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
156
|
-
}
|
|
157
|
-
function mergeRoles(roleA, roleB) {
|
|
158
|
-
return roleA | roleB;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// src/durable-nonce.ts
|
|
162
|
-
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
163
|
-
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
164
|
-
function assertIsDurableNonceTransaction(transaction) {
|
|
165
|
-
if (!isDurableNonceTransaction(transaction)) {
|
|
166
|
-
throw new Error("Transaction is not a durable nonce transaction");
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
170
|
-
return {
|
|
171
|
-
accounts: [
|
|
172
|
-
{ address: nonceAccountAddress, role: AccountRole.WRITABLE },
|
|
173
|
-
{
|
|
174
|
-
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
175
|
-
role: AccountRole.READONLY
|
|
176
|
-
},
|
|
177
|
-
{ address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
|
|
178
|
-
],
|
|
179
|
-
data: new Uint8Array([4, 0, 0, 0]),
|
|
180
|
-
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function isAdvanceNonceAccountInstruction(instruction) {
|
|
184
|
-
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
185
|
-
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
186
|
-
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
187
|
-
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
188
|
-
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
189
|
-
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
|
|
190
|
-
}
|
|
191
|
-
function isAdvanceNonceAccountInstructionData(data) {
|
|
192
|
-
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
193
|
-
}
|
|
194
|
-
function isDurableNonceTransaction(transaction) {
|
|
195
|
-
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
196
|
-
}
|
|
197
|
-
function setTransactionLifetimeUsingDurableNonce({
|
|
198
|
-
nonce,
|
|
199
|
-
nonceAccountAddress,
|
|
200
|
-
nonceAuthorityAddress
|
|
201
|
-
}, transaction) {
|
|
202
|
-
const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
|
|
203
|
-
if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
|
|
204
|
-
return transaction;
|
|
205
|
-
}
|
|
206
|
-
const out = {
|
|
207
|
-
...getUnsignedTransaction(transaction),
|
|
208
|
-
instructions: [
|
|
209
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
210
|
-
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
211
|
-
],
|
|
212
|
-
lifetimeConstraint: {
|
|
213
|
-
nonce
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
Object.freeze(out);
|
|
217
|
-
return out;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/fee-payer.ts
|
|
221
|
-
function setTransactionFeePayer(feePayer, transaction) {
|
|
222
|
-
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
223
|
-
return transaction;
|
|
224
|
-
}
|
|
225
|
-
const out = {
|
|
226
|
-
...getUnsignedTransaction(transaction),
|
|
227
|
-
feePayer
|
|
228
|
-
};
|
|
229
|
-
Object.freeze(out);
|
|
230
|
-
return out;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// src/instructions.ts
|
|
234
|
-
function appendTransactionInstruction(instruction, transaction) {
|
|
235
|
-
const out = {
|
|
236
|
-
...getUnsignedTransaction(transaction),
|
|
237
|
-
instructions: [...transaction.instructions, instruction]
|
|
238
|
-
};
|
|
239
|
-
Object.freeze(out);
|
|
240
|
-
return out;
|
|
241
|
-
}
|
|
242
|
-
function prependTransactionInstruction(instruction, transaction) {
|
|
243
|
-
const out = {
|
|
244
|
-
...getUnsignedTransaction(transaction),
|
|
245
|
-
instructions: [instruction, ...transaction.instructions]
|
|
246
|
-
};
|
|
247
|
-
Object.freeze(out);
|
|
248
|
-
return out;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
5
|
// ../codecs-core/dist/index.browser.js
|
|
252
6
|
function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
|
|
253
7
|
if (bytes.length - offset <= 0) {
|
|
@@ -285,9 +39,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
285
39
|
return paddedBytes;
|
|
286
40
|
};
|
|
287
41
|
var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
|
|
42
|
+
function combineCodec(encoder, decoder, description) {
|
|
43
|
+
if (encoder.fixedSize !== decoder.fixedSize) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (encoder.maxSize !== decoder.maxSize) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
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
|
+
return {
|
|
59
|
+
decode: decoder.decode,
|
|
60
|
+
description: description != null ? description : encoder.description,
|
|
61
|
+
encode: encoder.encode,
|
|
62
|
+
fixedSize: encoder.fixedSize,
|
|
63
|
+
maxSize: encoder.maxSize
|
|
64
|
+
};
|
|
65
|
+
}
|
|
288
66
|
function fixCodecHelper(data, fixedBytes, description) {
|
|
289
67
|
return {
|
|
290
|
-
description: description
|
|
68
|
+
description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
|
|
291
69
|
fixedSize: fixedBytes,
|
|
292
70
|
maxSize: fixedBytes
|
|
293
71
|
};
|
|
@@ -322,6 +100,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
322
100
|
maxSize: encoder.maxSize
|
|
323
101
|
};
|
|
324
102
|
}
|
|
103
|
+
function mapDecoder(decoder, map) {
|
|
104
|
+
return {
|
|
105
|
+
decode: (bytes, offset = 0) => {
|
|
106
|
+
const [value, length] = decoder.decode(bytes, offset);
|
|
107
|
+
return [map(value, bytes, offset), length];
|
|
108
|
+
},
|
|
109
|
+
description: decoder.description,
|
|
110
|
+
fixedSize: decoder.fixedSize,
|
|
111
|
+
maxSize: decoder.maxSize
|
|
112
|
+
};
|
|
113
|
+
}
|
|
325
114
|
|
|
326
115
|
// ../codecs-numbers/dist/index.browser.js
|
|
327
116
|
function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
|
|
@@ -332,14 +121,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
332
121
|
}
|
|
333
122
|
}
|
|
334
123
|
function sharedNumberFactory(input) {
|
|
124
|
+
var _a;
|
|
335
125
|
let littleEndian;
|
|
336
126
|
let defaultDescription = input.name;
|
|
337
127
|
if (input.size > 1) {
|
|
338
|
-
littleEndian = !("endian" in input.
|
|
128
|
+
littleEndian = !("endian" in input.config) || input.config.endian === 0;
|
|
339
129
|
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
340
130
|
}
|
|
341
131
|
return {
|
|
342
|
-
description: input.
|
|
132
|
+
description: (_a = input.config.description) != null ? _a : defaultDescription,
|
|
343
133
|
fixedSize: input.size,
|
|
344
134
|
littleEndian,
|
|
345
135
|
maxSize: input.size
|
|
@@ -376,140 +166,83 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
376
166
|
};
|
|
377
167
|
}
|
|
378
168
|
function toArrayBuffer(bytes, offset, length) {
|
|
379
|
-
const bytesOffset = bytes.byteOffset + (offset
|
|
380
|
-
const bytesLength = length
|
|
169
|
+
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
170
|
+
const bytesLength = length != null ? length : bytes.byteLength;
|
|
381
171
|
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
382
172
|
}
|
|
383
|
-
var getShortU16Encoder = (
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
173
|
+
var getShortU16Encoder = (config = {}) => {
|
|
174
|
+
var _a;
|
|
175
|
+
return {
|
|
176
|
+
description: (_a = config.description) != null ? _a : "shortU16",
|
|
177
|
+
encode: (value) => {
|
|
178
|
+
assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
|
|
179
|
+
const bytes = [0];
|
|
180
|
+
for (let ii = 0; ; ii += 1) {
|
|
181
|
+
const alignedValue = value >> ii * 7;
|
|
182
|
+
if (alignedValue === 0) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
const nextSevenBits = 127 & alignedValue;
|
|
186
|
+
bytes[ii] = nextSevenBits;
|
|
187
|
+
if (ii > 0) {
|
|
188
|
+
bytes[ii - 1] |= 128;
|
|
189
|
+
}
|
|
392
190
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
191
|
+
return new Uint8Array(bytes);
|
|
192
|
+
},
|
|
193
|
+
fixedSize: null,
|
|
194
|
+
maxSize: 3
|
|
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
|
+
}
|
|
397
211
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
212
|
+
return [value, offset + byteCount];
|
|
213
|
+
},
|
|
214
|
+
description: (_a = config.description) != null ? _a : "shortU16",
|
|
215
|
+
fixedSize: null,
|
|
216
|
+
maxSize: 3
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
220
|
+
config,
|
|
405
221
|
name: "u32",
|
|
406
|
-
options,
|
|
407
222
|
range: [0, Number("0xffffffff")],
|
|
408
223
|
set: (view, value, le) => view.setUint32(0, value, le),
|
|
409
224
|
size: 4
|
|
410
225
|
});
|
|
411
|
-
var getU32Decoder = (
|
|
226
|
+
var getU32Decoder = (config = {}) => numberDecoderFactory({
|
|
227
|
+
config,
|
|
412
228
|
get: (view, le) => view.getUint32(0, le),
|
|
413
229
|
name: "u32",
|
|
414
|
-
options,
|
|
415
230
|
size: 4
|
|
416
231
|
});
|
|
417
|
-
var getU8Encoder = (
|
|
232
|
+
var getU8Encoder = (config = {}) => numberEncoderFactory({
|
|
233
|
+
config,
|
|
418
234
|
name: "u8",
|
|
419
|
-
options,
|
|
420
235
|
range: [0, Number("0xff")],
|
|
421
236
|
set: (view, value) => view.setUint8(0, value),
|
|
422
237
|
size: 1
|
|
423
238
|
});
|
|
239
|
+
var getU8Decoder = (config = {}) => numberDecoderFactory({
|
|
240
|
+
config,
|
|
241
|
+
get: (view) => view.getUint8(0),
|
|
242
|
+
name: "u8",
|
|
243
|
+
size: 1
|
|
244
|
+
});
|
|
424
245
|
|
|
425
|
-
// ../codecs-data-structures/dist/index.browser.js
|
|
426
|
-
function sumCodecSizes(sizes) {
|
|
427
|
-
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
428
|
-
}
|
|
429
|
-
function getArrayLikeCodecSizeDescription(size) {
|
|
430
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
431
|
-
}
|
|
432
|
-
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
433
|
-
if (typeof size !== "number")
|
|
434
|
-
return null;
|
|
435
|
-
if (size === 0)
|
|
436
|
-
return 0;
|
|
437
|
-
const childrenSize = sumCodecSizes(childrenSizes);
|
|
438
|
-
return childrenSize === null ? null : childrenSize * size;
|
|
439
|
-
}
|
|
440
|
-
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
441
|
-
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
442
|
-
}
|
|
443
|
-
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
444
|
-
if (expected !== actual) {
|
|
445
|
-
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
function arrayCodecHelper(item, size, description) {
|
|
449
|
-
if (size === "remainder" && item.fixedSize === null) {
|
|
450
|
-
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
451
|
-
}
|
|
452
|
-
return {
|
|
453
|
-
description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
454
|
-
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
455
|
-
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
function getArrayEncoder(item, options = {}) {
|
|
459
|
-
const size = options.size ?? getU32Encoder();
|
|
460
|
-
return {
|
|
461
|
-
...arrayCodecHelper(item, size, options.description),
|
|
462
|
-
encode: (value) => {
|
|
463
|
-
if (typeof size === "number") {
|
|
464
|
-
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
465
|
-
}
|
|
466
|
-
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
function getBytesEncoder(options = {}) {
|
|
471
|
-
const size = options.size ?? "variable";
|
|
472
|
-
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
473
|
-
const description = options.description ?? `bytes(${sizeDescription})`;
|
|
474
|
-
const byteEncoder = {
|
|
475
|
-
description,
|
|
476
|
-
encode: (value) => value,
|
|
477
|
-
fixedSize: null,
|
|
478
|
-
maxSize: null
|
|
479
|
-
};
|
|
480
|
-
if (size === "variable") {
|
|
481
|
-
return byteEncoder;
|
|
482
|
-
}
|
|
483
|
-
if (typeof size === "number") {
|
|
484
|
-
return fixEncoder(byteEncoder, size, description);
|
|
485
|
-
}
|
|
486
|
-
return {
|
|
487
|
-
...byteEncoder,
|
|
488
|
-
encode: (value) => {
|
|
489
|
-
const contentBytes = byteEncoder.encode(value);
|
|
490
|
-
const lengthBytes = size.encode(contentBytes.length);
|
|
491
|
-
return mergeBytes([lengthBytes, contentBytes]);
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
function structCodecHelper(fields, description) {
|
|
496
|
-
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
497
|
-
return {
|
|
498
|
-
description: description ?? `struct(${fieldDescriptions})`,
|
|
499
|
-
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
500
|
-
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
function getStructEncoder(fields, options = {}) {
|
|
504
|
-
return {
|
|
505
|
-
...structCodecHelper(fields, options.description),
|
|
506
|
-
encode: (struct) => {
|
|
507
|
-
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
508
|
-
return mergeBytes(fieldBytes);
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
|
|
513
246
|
// ../codecs-strings/dist/index.browser.js
|
|
514
247
|
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
515
248
|
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
@@ -574,87 +307,478 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
574
307
|
fixedSize: null,
|
|
575
308
|
maxSize: null
|
|
576
309
|
};
|
|
577
|
-
};
|
|
578
|
-
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
579
|
-
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
580
|
-
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
581
|
-
var
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
310
|
+
};
|
|
311
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
312
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
313
|
+
var getBase58Decoder = () => getBaseXDecoder(alphabet2);
|
|
314
|
+
var getBase64Decoder = () => {
|
|
315
|
+
{
|
|
316
|
+
return {
|
|
317
|
+
decode(bytes, offset = 0) {
|
|
318
|
+
const slice = bytes.slice(offset);
|
|
319
|
+
const value = btoa(String.fromCharCode(...slice));
|
|
320
|
+
return [value, bytes.length];
|
|
321
|
+
},
|
|
322
|
+
description: `base64`,
|
|
323
|
+
fixedSize: null,
|
|
324
|
+
maxSize: null
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var removeNullCharacters = (value) => (
|
|
329
|
+
// eslint-disable-next-line no-control-regex
|
|
330
|
+
value.replace(/\u0000/g, "")
|
|
331
|
+
);
|
|
332
|
+
var e = globalThis.TextDecoder;
|
|
333
|
+
var o = globalThis.TextEncoder;
|
|
334
|
+
var getUtf8Encoder = () => {
|
|
335
|
+
let textEncoder;
|
|
336
|
+
return {
|
|
337
|
+
description: "utf8",
|
|
338
|
+
encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
|
|
339
|
+
fixedSize: null,
|
|
340
|
+
maxSize: null
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
var getUtf8Decoder = () => {
|
|
344
|
+
let textDecoder;
|
|
345
|
+
return {
|
|
346
|
+
decode(bytes, offset = 0) {
|
|
347
|
+
const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
|
|
348
|
+
return [removeNullCharacters(value), bytes.length];
|
|
349
|
+
},
|
|
350
|
+
description: "utf8",
|
|
351
|
+
fixedSize: null,
|
|
352
|
+
maxSize: null
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
var getStringEncoder = (config = {}) => {
|
|
356
|
+
var _a, _b, _c;
|
|
357
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
358
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
|
|
359
|
+
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
360
|
+
if (size === "variable") {
|
|
361
|
+
return { ...encoding, description };
|
|
362
|
+
}
|
|
363
|
+
if (typeof size === "number") {
|
|
364
|
+
return fixEncoder(encoding, size, description);
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
description,
|
|
368
|
+
encode: (value) => {
|
|
369
|
+
const contentBytes = encoding.encode(value);
|
|
370
|
+
const lengthBytes = size.encode(contentBytes.length);
|
|
371
|
+
return mergeBytes([lengthBytes, contentBytes]);
|
|
372
|
+
},
|
|
373
|
+
fixedSize: null,
|
|
374
|
+
maxSize: null
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
var getStringDecoder = (config = {}) => {
|
|
378
|
+
var _a, _b, _c;
|
|
379
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
380
|
+
const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
|
|
381
|
+
const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
382
|
+
if (size === "variable") {
|
|
383
|
+
return { ...encoding, description };
|
|
384
|
+
}
|
|
385
|
+
if (typeof size === "number") {
|
|
386
|
+
return fixDecoder(encoding, size, description);
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
decode: (bytes, offset = 0) => {
|
|
390
|
+
assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
|
|
391
|
+
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
392
|
+
const length = Number(lengthBigInt);
|
|
393
|
+
offset = lengthOffset;
|
|
394
|
+
const contentBytes = bytes.slice(offset, offset + length);
|
|
395
|
+
assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
|
|
396
|
+
const [value, contentOffset] = encoding.decode(contentBytes);
|
|
397
|
+
offset += contentOffset;
|
|
398
|
+
return [value, offset];
|
|
399
|
+
},
|
|
400
|
+
description,
|
|
401
|
+
fixedSize: null,
|
|
402
|
+
maxSize: null
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
function getSizeDescription(size) {
|
|
406
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/unsigned-transaction.ts
|
|
410
|
+
function getUnsignedTransaction(transaction) {
|
|
411
|
+
if ("signatures" in transaction) {
|
|
412
|
+
const {
|
|
413
|
+
signatures: _,
|
|
414
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
415
|
+
...unsignedTransaction
|
|
416
|
+
} = transaction;
|
|
417
|
+
return unsignedTransaction;
|
|
418
|
+
} else {
|
|
419
|
+
return transaction;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// src/blockhash.ts
|
|
424
|
+
var base58Encoder;
|
|
425
|
+
function assertIsBlockhash(putativeBlockhash) {
|
|
426
|
+
if (!base58Encoder)
|
|
427
|
+
base58Encoder = getBase58Encoder();
|
|
428
|
+
try {
|
|
429
|
+
if (
|
|
430
|
+
// Lowest value (32 bytes of zeroes)
|
|
431
|
+
putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
|
|
432
|
+
putativeBlockhash.length > 44
|
|
433
|
+
) {
|
|
434
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
435
|
+
}
|
|
436
|
+
const bytes = base58Encoder.encode(putativeBlockhash);
|
|
437
|
+
const numBytes = bytes.byteLength;
|
|
438
|
+
if (numBytes !== 32) {
|
|
439
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
440
|
+
}
|
|
441
|
+
} catch (e2) {
|
|
442
|
+
throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
|
|
443
|
+
cause: e2
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
448
|
+
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
449
|
+
return transaction;
|
|
450
|
+
}
|
|
451
|
+
const out = {
|
|
452
|
+
...getUnsignedTransaction(transaction),
|
|
453
|
+
lifetimeConstraint: blockhashLifetimeConstraint
|
|
454
|
+
};
|
|
455
|
+
Object.freeze(out);
|
|
456
|
+
return out;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/create-transaction.ts
|
|
460
|
+
function createTransaction({
|
|
461
|
+
version
|
|
462
|
+
}) {
|
|
463
|
+
const out = {
|
|
464
|
+
instructions: [],
|
|
465
|
+
version
|
|
466
|
+
};
|
|
467
|
+
Object.freeze(out);
|
|
468
|
+
return out;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// ../instructions/dist/index.browser.js
|
|
472
|
+
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
473
|
+
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
474
|
+
3] = "WRITABLE_SIGNER";
|
|
475
|
+
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
476
|
+
2] = "READONLY_SIGNER";
|
|
477
|
+
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
478
|
+
1] = "WRITABLE";
|
|
479
|
+
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
480
|
+
0] = "READONLY";
|
|
481
|
+
return AccountRole2;
|
|
482
|
+
})(AccountRole || {});
|
|
483
|
+
var IS_WRITABLE_BITMASK = 1;
|
|
484
|
+
function isSignerRole(role) {
|
|
485
|
+
return role >= 2;
|
|
486
|
+
}
|
|
487
|
+
function isWritableRole(role) {
|
|
488
|
+
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
489
|
+
}
|
|
490
|
+
function mergeRoles(roleA, roleB) {
|
|
491
|
+
return roleA | roleB;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// src/durable-nonce.ts
|
|
495
|
+
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
496
|
+
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
497
|
+
function assertIsDurableNonceTransaction(transaction) {
|
|
498
|
+
if (!isDurableNonceTransaction(transaction)) {
|
|
499
|
+
throw new Error("Transaction is not a durable nonce transaction");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
503
|
+
return {
|
|
504
|
+
accounts: [
|
|
505
|
+
{ address: nonceAccountAddress, role: AccountRole.WRITABLE },
|
|
506
|
+
{
|
|
507
|
+
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
508
|
+
role: AccountRole.READONLY
|
|
509
|
+
},
|
|
510
|
+
{ address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
|
|
511
|
+
],
|
|
512
|
+
data: new Uint8Array([4, 0, 0, 0]),
|
|
513
|
+
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function isAdvanceNonceAccountInstruction(instruction) {
|
|
517
|
+
var _a;
|
|
518
|
+
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
519
|
+
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
520
|
+
((_a = instruction.accounts) == null ? void 0 : _a.length) === 3 && // First account is nonce account address
|
|
521
|
+
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
522
|
+
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
523
|
+
instruction.accounts[2].address != null && isSignerRole(instruction.accounts[2].role);
|
|
524
|
+
}
|
|
525
|
+
function isAdvanceNonceAccountInstructionData(data) {
|
|
526
|
+
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
527
|
+
}
|
|
528
|
+
function isDurableNonceTransaction(transaction) {
|
|
529
|
+
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
530
|
+
}
|
|
531
|
+
function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
|
|
532
|
+
return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
|
|
533
|
+
}
|
|
534
|
+
function setTransactionLifetimeUsingDurableNonce({
|
|
535
|
+
nonce,
|
|
536
|
+
nonceAccountAddress,
|
|
537
|
+
nonceAuthorityAddress
|
|
538
|
+
}, transaction) {
|
|
539
|
+
let newInstructions;
|
|
540
|
+
const firstInstruction = transaction.instructions[0];
|
|
541
|
+
if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
542
|
+
if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
|
|
543
|
+
if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
|
|
544
|
+
return transaction;
|
|
545
|
+
} else {
|
|
546
|
+
newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
newInstructions = [
|
|
550
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
551
|
+
...transaction.instructions.slice(1)
|
|
552
|
+
];
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
newInstructions = [
|
|
556
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
557
|
+
...transaction.instructions
|
|
558
|
+
];
|
|
559
|
+
}
|
|
560
|
+
const out = {
|
|
561
|
+
...getUnsignedTransaction(transaction),
|
|
562
|
+
instructions: newInstructions,
|
|
563
|
+
lifetimeConstraint: {
|
|
564
|
+
nonce
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
Object.freeze(out);
|
|
568
|
+
return out;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/fee-payer.ts
|
|
572
|
+
function setTransactionFeePayer(feePayer, transaction) {
|
|
573
|
+
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
574
|
+
return transaction;
|
|
575
|
+
}
|
|
576
|
+
const out = {
|
|
577
|
+
...getUnsignedTransaction(transaction),
|
|
578
|
+
feePayer
|
|
579
|
+
};
|
|
580
|
+
Object.freeze(out);
|
|
581
|
+
return out;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// src/instructions.ts
|
|
585
|
+
function appendTransactionInstruction(instruction, transaction) {
|
|
586
|
+
const out = {
|
|
587
|
+
...getUnsignedTransaction(transaction),
|
|
588
|
+
instructions: [...transaction.instructions, instruction]
|
|
589
|
+
};
|
|
590
|
+
Object.freeze(out);
|
|
591
|
+
return out;
|
|
592
|
+
}
|
|
593
|
+
function prependTransactionInstruction(instruction, transaction) {
|
|
594
|
+
const out = {
|
|
595
|
+
...getUnsignedTransaction(transaction),
|
|
596
|
+
instructions: [instruction, ...transaction.instructions]
|
|
597
|
+
};
|
|
598
|
+
Object.freeze(out);
|
|
599
|
+
return out;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// ../codecs-data-structures/dist/index.browser.js
|
|
603
|
+
function sumCodecSizes(sizes) {
|
|
604
|
+
return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
|
|
605
|
+
}
|
|
606
|
+
function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
|
|
607
|
+
if (typeof size === "number") {
|
|
608
|
+
return [size, offset];
|
|
609
|
+
}
|
|
610
|
+
if (typeof size === "object") {
|
|
611
|
+
return size.decode(bytes, offset);
|
|
612
|
+
}
|
|
613
|
+
if (size === "remainder") {
|
|
614
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
615
|
+
if (childrenSize === null) {
|
|
616
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
617
|
+
}
|
|
618
|
+
const remainder = bytes.slice(offset).length;
|
|
619
|
+
if (remainder % childrenSize !== 0) {
|
|
620
|
+
throw new Error(
|
|
621
|
+
`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.`
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
return [remainder / childrenSize, offset];
|
|
625
|
+
}
|
|
626
|
+
throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
|
|
627
|
+
}
|
|
628
|
+
function getArrayLikeCodecSizeDescription(size) {
|
|
629
|
+
return typeof size === "object" ? size.description : `${size}`;
|
|
630
|
+
}
|
|
631
|
+
function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
|
|
632
|
+
if (typeof size !== "number")
|
|
633
|
+
return null;
|
|
634
|
+
if (size === 0)
|
|
635
|
+
return 0;
|
|
636
|
+
const childrenSize = sumCodecSizes(childrenSizes);
|
|
637
|
+
return childrenSize === null ? null : childrenSize * size;
|
|
638
|
+
}
|
|
639
|
+
function getArrayLikeCodecSizePrefix(size, realSize) {
|
|
640
|
+
return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
|
|
641
|
+
}
|
|
642
|
+
function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
|
|
643
|
+
if (expected !== actual) {
|
|
644
|
+
throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function arrayCodecHelper(item, size, description) {
|
|
648
|
+
if (size === "remainder" && item.fixedSize === null) {
|
|
649
|
+
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
650
|
+
}
|
|
651
|
+
return {
|
|
652
|
+
description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
653
|
+
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
654
|
+
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function getArrayEncoder(item, config = {}) {
|
|
658
|
+
var _a;
|
|
659
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
589
660
|
return {
|
|
590
|
-
|
|
591
|
-
encode: (value) =>
|
|
592
|
-
|
|
593
|
-
|
|
661
|
+
...arrayCodecHelper(item, size, config.description),
|
|
662
|
+
encode: (value) => {
|
|
663
|
+
if (typeof size === "number") {
|
|
664
|
+
assertValidNumberOfItemsForCodec("array", size, value.length);
|
|
665
|
+
}
|
|
666
|
+
return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
|
|
667
|
+
}
|
|
594
668
|
};
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
669
|
+
}
|
|
670
|
+
function getArrayDecoder(item, config = {}) {
|
|
671
|
+
var _a;
|
|
672
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
598
673
|
return {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
674
|
+
...arrayCodecHelper(item, size, config.description),
|
|
675
|
+
decode: (bytes, offset = 0) => {
|
|
676
|
+
if (typeof size === "object" && bytes.slice(offset).length === 0) {
|
|
677
|
+
return [[], offset];
|
|
678
|
+
}
|
|
679
|
+
const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
|
|
680
|
+
offset = newOffset;
|
|
681
|
+
const values = [];
|
|
682
|
+
for (let i = 0; i < resolvedSize; i += 1) {
|
|
683
|
+
const [value, newOffset2] = item.decode(bytes, offset);
|
|
684
|
+
values.push(value);
|
|
685
|
+
offset = newOffset2;
|
|
686
|
+
}
|
|
687
|
+
return [values, offset];
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
function getBytesEncoder(config = {}) {
|
|
692
|
+
var _a, _b;
|
|
693
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
694
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
695
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
696
|
+
const byteEncoder = {
|
|
697
|
+
description,
|
|
698
|
+
encode: (value) => value,
|
|
604
699
|
fixedSize: null,
|
|
605
700
|
maxSize: null
|
|
606
701
|
};
|
|
607
|
-
};
|
|
608
|
-
var getStringEncoder = (options = {}) => {
|
|
609
|
-
const size = options.size ?? getU32Encoder();
|
|
610
|
-
const encoding = options.encoding ?? getUtf8Encoder();
|
|
611
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
612
702
|
if (size === "variable") {
|
|
613
|
-
return
|
|
703
|
+
return byteEncoder;
|
|
614
704
|
}
|
|
615
705
|
if (typeof size === "number") {
|
|
616
|
-
return fixEncoder(
|
|
706
|
+
return fixEncoder(byteEncoder, size, description);
|
|
617
707
|
}
|
|
618
708
|
return {
|
|
619
|
-
|
|
709
|
+
...byteEncoder,
|
|
620
710
|
encode: (value) => {
|
|
621
|
-
const contentBytes =
|
|
711
|
+
const contentBytes = byteEncoder.encode(value);
|
|
622
712
|
const lengthBytes = size.encode(contentBytes.length);
|
|
623
713
|
return mergeBytes([lengthBytes, contentBytes]);
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function getBytesDecoder(config = {}) {
|
|
718
|
+
var _a, _b;
|
|
719
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
720
|
+
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
721
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
722
|
+
const byteDecoder = {
|
|
723
|
+
decode: (bytes, offset = 0) => {
|
|
724
|
+
const slice = bytes.slice(offset);
|
|
725
|
+
return [slice, offset + slice.length];
|
|
624
726
|
},
|
|
727
|
+
description,
|
|
625
728
|
fixedSize: null,
|
|
626
729
|
maxSize: null
|
|
627
730
|
};
|
|
628
|
-
};
|
|
629
|
-
var getStringDecoder = (options = {}) => {
|
|
630
|
-
const size = options.size ?? getU32Decoder();
|
|
631
|
-
const encoding = options.encoding ?? getUtf8Decoder();
|
|
632
|
-
const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
|
|
633
731
|
if (size === "variable") {
|
|
634
|
-
return
|
|
732
|
+
return byteDecoder;
|
|
635
733
|
}
|
|
636
734
|
if (typeof size === "number") {
|
|
637
|
-
return fixDecoder(
|
|
735
|
+
return fixDecoder(byteDecoder, size, description);
|
|
638
736
|
}
|
|
639
737
|
return {
|
|
738
|
+
...byteDecoder,
|
|
640
739
|
decode: (bytes, offset = 0) => {
|
|
641
|
-
assertByteArrayIsNotEmptyForCodec("
|
|
740
|
+
assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
|
|
642
741
|
const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
|
|
643
742
|
const length = Number(lengthBigInt);
|
|
644
743
|
offset = lengthOffset;
|
|
645
744
|
const contentBytes = bytes.slice(offset, offset + length);
|
|
646
|
-
assertByteArrayHasEnoughBytesForCodec("
|
|
647
|
-
const [value, contentOffset] =
|
|
745
|
+
assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
|
|
746
|
+
const [value, contentOffset] = byteDecoder.decode(contentBytes);
|
|
648
747
|
offset += contentOffset;
|
|
649
748
|
return [value, offset];
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
function structCodecHelper(fields, description) {
|
|
753
|
+
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
754
|
+
return {
|
|
755
|
+
description: description != null ? description : `struct(${fieldDescriptions})`,
|
|
756
|
+
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
757
|
+
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
function getStructEncoder(fields, config = {}) {
|
|
761
|
+
return {
|
|
762
|
+
...structCodecHelper(fields, config.description),
|
|
763
|
+
encode: (struct) => {
|
|
764
|
+
const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
|
|
765
|
+
return mergeBytes(fieldBytes);
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function getStructDecoder(fields, config = {}) {
|
|
770
|
+
return {
|
|
771
|
+
...structCodecHelper(fields, config.description),
|
|
772
|
+
decode: (bytes, offset = 0) => {
|
|
773
|
+
const struct = {};
|
|
774
|
+
fields.forEach(([key, codec]) => {
|
|
775
|
+
const [value, newOffset] = codec.decode(bytes, offset);
|
|
776
|
+
offset = newOffset;
|
|
777
|
+
struct[key] = value;
|
|
778
|
+
});
|
|
779
|
+
return [struct, offset];
|
|
780
|
+
}
|
|
654
781
|
};
|
|
655
|
-
};
|
|
656
|
-
function getSizeDescription(size) {
|
|
657
|
-
return typeof size === "object" ? size.description : `${size}`;
|
|
658
782
|
}
|
|
659
783
|
|
|
660
784
|
// ../assertions/dist/index.browser.js
|
|
@@ -666,14 +790,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
666
790
|
}
|
|
667
791
|
}
|
|
668
792
|
async function assertKeyExporterIsAvailable() {
|
|
793
|
+
var _a;
|
|
669
794
|
assertIsSecureContext();
|
|
670
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
795
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
|
|
671
796
|
throw new Error("No key export implementation could be found");
|
|
672
797
|
}
|
|
673
798
|
}
|
|
674
799
|
async function assertSigningCapabilityIsAvailable() {
|
|
800
|
+
var _a;
|
|
675
801
|
assertIsSecureContext();
|
|
676
|
-
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle
|
|
802
|
+
if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
|
|
677
803
|
throw new Error("No signing implementation could be found");
|
|
678
804
|
}
|
|
679
805
|
}
|
|
@@ -691,35 +817,36 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
691
817
|
memoizedBase58Decoder = getBase58Decoder();
|
|
692
818
|
return memoizedBase58Decoder;
|
|
693
819
|
}
|
|
694
|
-
function assertIsAddress(
|
|
820
|
+
function assertIsAddress(putativeAddress) {
|
|
695
821
|
try {
|
|
696
822
|
if (
|
|
697
823
|
// Lowest address (32 bytes of zeroes)
|
|
698
|
-
|
|
699
|
-
|
|
824
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
825
|
+
putativeAddress.length > 44
|
|
700
826
|
) {
|
|
701
827
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
702
828
|
}
|
|
703
|
-
const
|
|
704
|
-
const bytes =
|
|
829
|
+
const base58Encoder2 = getMemoizedBase58Encoder();
|
|
830
|
+
const bytes = base58Encoder2.encode(putativeAddress);
|
|
705
831
|
const numBytes = bytes.byteLength;
|
|
706
832
|
if (numBytes !== 32) {
|
|
707
833
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
708
834
|
}
|
|
709
835
|
} catch (e2) {
|
|
710
|
-
throw new Error(`\`${
|
|
836
|
+
throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
|
|
711
837
|
cause: e2
|
|
712
838
|
});
|
|
713
839
|
}
|
|
714
840
|
}
|
|
715
|
-
function address(
|
|
716
|
-
assertIsAddress(
|
|
717
|
-
return
|
|
841
|
+
function address(putativeAddress) {
|
|
842
|
+
assertIsAddress(putativeAddress);
|
|
843
|
+
return putativeAddress;
|
|
718
844
|
}
|
|
719
845
|
function getAddressEncoder(config) {
|
|
846
|
+
var _a;
|
|
720
847
|
return mapEncoder(
|
|
721
848
|
getStringEncoder({
|
|
722
|
-
description: config
|
|
849
|
+
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
723
850
|
encoding: getMemoizedBase58Encoder(),
|
|
724
851
|
size: 32
|
|
725
852
|
}),
|
|
@@ -727,8 +854,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
727
854
|
);
|
|
728
855
|
}
|
|
729
856
|
function getAddressDecoder(config) {
|
|
857
|
+
var _a;
|
|
730
858
|
return getStringDecoder({
|
|
731
|
-
description: config
|
|
859
|
+
description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
|
|
732
860
|
encoding: getMemoizedBase58Decoder(),
|
|
733
861
|
size: 32
|
|
734
862
|
});
|
|
@@ -755,7 +883,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
755
883
|
|
|
756
884
|
// src/accounts.ts
|
|
757
885
|
function upsert(addressMap, address2, update) {
|
|
758
|
-
|
|
886
|
+
var _a;
|
|
887
|
+
addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole.READONLY });
|
|
759
888
|
}
|
|
760
889
|
var TYPE = Symbol("AddressMapTypeProperty");
|
|
761
890
|
function getAddressMapFromInstructions(feePayer, instructions) {
|
|
@@ -1025,12 +1154,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1025
1154
|
|
|
1026
1155
|
// src/compile-transaction.ts
|
|
1027
1156
|
function getCompiledTransaction(transaction) {
|
|
1157
|
+
var _a;
|
|
1028
1158
|
const compiledMessage = compileMessage(transaction);
|
|
1029
1159
|
let signatures;
|
|
1030
1160
|
if ("signatures" in transaction) {
|
|
1031
1161
|
signatures = [];
|
|
1032
1162
|
for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
|
|
1033
|
-
signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]]
|
|
1163
|
+
signatures[ii] = (_a = transaction.signatures[compiledMessage.staticAccounts[ii]]) != null ? _a : new Uint8Array(Array(64).fill(0));
|
|
1034
1164
|
}
|
|
1035
1165
|
} else {
|
|
1036
1166
|
signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
|
|
@@ -1041,6 +1171,124 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1041
1171
|
};
|
|
1042
1172
|
}
|
|
1043
1173
|
|
|
1174
|
+
// ../functional/dist/index.browser.js
|
|
1175
|
+
function pipe(init, ...fns) {
|
|
1176
|
+
return fns.reduce((acc, fn) => fn(acc), init);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/decompile-transaction.ts
|
|
1180
|
+
function getAccountMetas(message) {
|
|
1181
|
+
const { header } = message;
|
|
1182
|
+
const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
|
|
1183
|
+
const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
|
|
1184
|
+
const accountMetas = [];
|
|
1185
|
+
let accountIndex = 0;
|
|
1186
|
+
for (let i = 0; i < numWritableSignerAccounts; i++) {
|
|
1187
|
+
accountMetas.push({
|
|
1188
|
+
address: message.staticAccounts[accountIndex],
|
|
1189
|
+
role: AccountRole.WRITABLE_SIGNER
|
|
1190
|
+
});
|
|
1191
|
+
accountIndex++;
|
|
1192
|
+
}
|
|
1193
|
+
for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
|
|
1194
|
+
accountMetas.push({
|
|
1195
|
+
address: message.staticAccounts[accountIndex],
|
|
1196
|
+
role: AccountRole.READONLY_SIGNER
|
|
1197
|
+
});
|
|
1198
|
+
accountIndex++;
|
|
1199
|
+
}
|
|
1200
|
+
for (let i = 0; i < numWritableNonSignerAccounts; i++) {
|
|
1201
|
+
accountMetas.push({
|
|
1202
|
+
address: message.staticAccounts[accountIndex],
|
|
1203
|
+
role: AccountRole.WRITABLE
|
|
1204
|
+
});
|
|
1205
|
+
accountIndex++;
|
|
1206
|
+
}
|
|
1207
|
+
for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
|
|
1208
|
+
accountMetas.push({
|
|
1209
|
+
address: message.staticAccounts[accountIndex],
|
|
1210
|
+
role: AccountRole.READONLY
|
|
1211
|
+
});
|
|
1212
|
+
accountIndex++;
|
|
1213
|
+
}
|
|
1214
|
+
return accountMetas;
|
|
1215
|
+
}
|
|
1216
|
+
function convertInstruction(instruction, accountMetas) {
|
|
1217
|
+
var _a, _b;
|
|
1218
|
+
const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
|
|
1219
|
+
if (!programAddress) {
|
|
1220
|
+
throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
|
|
1221
|
+
}
|
|
1222
|
+
const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
|
|
1223
|
+
const { data } = instruction;
|
|
1224
|
+
return {
|
|
1225
|
+
programAddress,
|
|
1226
|
+
...accounts && accounts.length ? { accounts } : {},
|
|
1227
|
+
...data && data.length ? { data } : {}
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
|
|
1231
|
+
if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
|
|
1232
|
+
return {
|
|
1233
|
+
blockhash: messageLifetimeToken,
|
|
1234
|
+
lastValidBlockHeight: lastValidBlockHeight != null ? lastValidBlockHeight : 2n ** 64n - 1n
|
|
1235
|
+
// U64 MAX
|
|
1236
|
+
};
|
|
1237
|
+
} else {
|
|
1238
|
+
const nonceAccountAddress = firstInstruction.accounts[0].address;
|
|
1239
|
+
assertIsAddress(nonceAccountAddress);
|
|
1240
|
+
const nonceAuthorityAddress = firstInstruction.accounts[2].address;
|
|
1241
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
1242
|
+
return {
|
|
1243
|
+
nonce: messageLifetimeToken,
|
|
1244
|
+
nonceAccountAddress,
|
|
1245
|
+
nonceAuthorityAddress
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function convertSignatures(compiledTransaction) {
|
|
1250
|
+
const {
|
|
1251
|
+
compiledMessage: { staticAccounts },
|
|
1252
|
+
signatures
|
|
1253
|
+
} = compiledTransaction;
|
|
1254
|
+
return signatures.reduce((acc, sig, index) => {
|
|
1255
|
+
const allZeros = sig.every((byte) => byte === 0);
|
|
1256
|
+
if (allZeros)
|
|
1257
|
+
return acc;
|
|
1258
|
+
const address2 = staticAccounts[index];
|
|
1259
|
+
return { ...acc, [address2]: sig };
|
|
1260
|
+
}, {});
|
|
1261
|
+
}
|
|
1262
|
+
function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
|
|
1263
|
+
const { compiledMessage } = compiledTransaction;
|
|
1264
|
+
if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
|
|
1265
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
1266
|
+
}
|
|
1267
|
+
const feePayer = compiledMessage.staticAccounts[0];
|
|
1268
|
+
if (!feePayer)
|
|
1269
|
+
throw new Error("No fee payer set in CompiledTransaction");
|
|
1270
|
+
const accountMetas = getAccountMetas(compiledMessage);
|
|
1271
|
+
const instructions = compiledMessage.instructions.map(
|
|
1272
|
+
(compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
|
|
1273
|
+
);
|
|
1274
|
+
const firstInstruction = instructions[0];
|
|
1275
|
+
const lifetimeConstraint = getLifetimeConstraint(
|
|
1276
|
+
compiledMessage.lifetimeToken,
|
|
1277
|
+
firstInstruction,
|
|
1278
|
+
lastValidBlockHeight
|
|
1279
|
+
);
|
|
1280
|
+
const signatures = convertSignatures(compiledTransaction);
|
|
1281
|
+
return pipe(
|
|
1282
|
+
createTransaction({ version: compiledMessage.version }),
|
|
1283
|
+
(tx) => setTransactionFeePayer(feePayer, tx),
|
|
1284
|
+
(tx) => instructions.reduce((acc, instruction) => {
|
|
1285
|
+
return appendTransactionInstruction(instruction, acc);
|
|
1286
|
+
}, tx),
|
|
1287
|
+
(tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
|
|
1288
|
+
(tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1044
1292
|
// src/serializers/address-table-lookup.ts
|
|
1045
1293
|
var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
|
|
1046
1294
|
var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
|
|
@@ -1072,6 +1320,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1072
1320
|
}
|
|
1073
1321
|
return memoizedAddressTableLookupEncoder;
|
|
1074
1322
|
}
|
|
1323
|
+
var memoizedAddressTableLookupDecoder;
|
|
1324
|
+
function getAddressTableLookupDecoder() {
|
|
1325
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
1326
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
1327
|
+
[
|
|
1328
|
+
["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
|
|
1329
|
+
[
|
|
1330
|
+
"writableIndices",
|
|
1331
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1332
|
+
description: writableIndicesDescription,
|
|
1333
|
+
size: getShortU16Decoder()
|
|
1334
|
+
})
|
|
1335
|
+
],
|
|
1336
|
+
[
|
|
1337
|
+
"readableIndices",
|
|
1338
|
+
getArrayDecoder(getU8Decoder(), {
|
|
1339
|
+
description: readableIndicesDescription,
|
|
1340
|
+
size: getShortU16Decoder()
|
|
1341
|
+
})
|
|
1342
|
+
]
|
|
1343
|
+
],
|
|
1344
|
+
{ description: addressTableLookupDescription }
|
|
1345
|
+
);
|
|
1346
|
+
}
|
|
1347
|
+
return memoizedAddressTableLookupDecoder;
|
|
1348
|
+
}
|
|
1075
1349
|
|
|
1076
1350
|
// src/serializers/header.ts
|
|
1077
1351
|
var memoizedU8Encoder;
|
|
@@ -1084,7 +1358,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1084
1358
|
const encoder = getMemoizedU8Encoder();
|
|
1085
1359
|
return {
|
|
1086
1360
|
...encoder,
|
|
1087
|
-
description: description
|
|
1361
|
+
description: description != null ? description : encoder.description
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
var memoizedU8Decoder;
|
|
1365
|
+
function getMemoizedU8Decoder() {
|
|
1366
|
+
if (!memoizedU8Decoder)
|
|
1367
|
+
memoizedU8Decoder = getU8Decoder();
|
|
1368
|
+
return memoizedU8Decoder;
|
|
1369
|
+
}
|
|
1370
|
+
function getMemoizedU8DecoderDescription(description) {
|
|
1371
|
+
const decoder = getMemoizedU8Decoder();
|
|
1372
|
+
return {
|
|
1373
|
+
...decoder,
|
|
1374
|
+
description: description != null ? description : decoder.description
|
|
1088
1375
|
};
|
|
1089
1376
|
}
|
|
1090
1377
|
var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
|
|
@@ -1103,6 +1390,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1103
1390
|
}
|
|
1104
1391
|
);
|
|
1105
1392
|
}
|
|
1393
|
+
function getMessageHeaderDecoder() {
|
|
1394
|
+
return getStructDecoder(
|
|
1395
|
+
[
|
|
1396
|
+
["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
|
|
1397
|
+
["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
|
|
1398
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
1399
|
+
],
|
|
1400
|
+
{
|
|
1401
|
+
description: messageHeaderDescription
|
|
1402
|
+
}
|
|
1403
|
+
);
|
|
1404
|
+
}
|
|
1106
1405
|
|
|
1107
1406
|
// src/serializers/instruction.ts
|
|
1108
1407
|
var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
|
|
@@ -1126,19 +1425,51 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1126
1425
|
]),
|
|
1127
1426
|
// Convert an instruction to have all fields defined
|
|
1128
1427
|
(instruction) => {
|
|
1428
|
+
var _a, _b;
|
|
1129
1429
|
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
1130
1430
|
return instruction;
|
|
1131
1431
|
}
|
|
1132
1432
|
return {
|
|
1133
1433
|
...instruction,
|
|
1134
|
-
accountIndices: instruction.accountIndices
|
|
1135
|
-
data: instruction.data
|
|
1434
|
+
accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
|
|
1435
|
+
data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
|
|
1136
1436
|
};
|
|
1137
1437
|
}
|
|
1138
1438
|
);
|
|
1139
1439
|
}
|
|
1140
1440
|
return memoizedGetInstructionEncoder;
|
|
1141
1441
|
}
|
|
1442
|
+
var memoizedGetInstructionDecoder;
|
|
1443
|
+
function getInstructionDecoder() {
|
|
1444
|
+
if (!memoizedGetInstructionDecoder) {
|
|
1445
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
1446
|
+
getStructDecoder([
|
|
1447
|
+
["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
|
|
1448
|
+
[
|
|
1449
|
+
"accountIndices",
|
|
1450
|
+
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
1451
|
+
description: accountIndicesDescription,
|
|
1452
|
+
size: getShortU16Decoder()
|
|
1453
|
+
})
|
|
1454
|
+
],
|
|
1455
|
+
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
1456
|
+
]),
|
|
1457
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
1458
|
+
(instruction) => {
|
|
1459
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
1460
|
+
return instruction;
|
|
1461
|
+
}
|
|
1462
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
1463
|
+
return {
|
|
1464
|
+
...rest,
|
|
1465
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
1466
|
+
...data.byteLength ? { data } : null
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
return memoizedGetInstructionDecoder;
|
|
1472
|
+
}
|
|
1142
1473
|
|
|
1143
1474
|
// src/serializers/transaction-version.ts
|
|
1144
1475
|
var VERSION_FLAG_MASK = 128;
|
|
@@ -1147,6 +1478,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1147
1478
|
fixedSize: null,
|
|
1148
1479
|
maxSize: 1
|
|
1149
1480
|
};
|
|
1481
|
+
function decode(bytes, offset = 0) {
|
|
1482
|
+
const firstByte = bytes[offset];
|
|
1483
|
+
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
1484
|
+
return ["legacy", offset];
|
|
1485
|
+
} else {
|
|
1486
|
+
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
1487
|
+
return [version, offset + 1];
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1150
1490
|
function encode(value) {
|
|
1151
1491
|
if (value === "legacy") {
|
|
1152
1492
|
return new Uint8Array();
|
|
@@ -1156,6 +1496,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1156
1496
|
}
|
|
1157
1497
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
1158
1498
|
}
|
|
1499
|
+
function getTransactionVersionDecoder() {
|
|
1500
|
+
return {
|
|
1501
|
+
...BASE_CONFIG,
|
|
1502
|
+
decode
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1159
1505
|
function getTransactionVersionEncoder() {
|
|
1160
1506
|
return {
|
|
1161
1507
|
...BASE_CONFIG,
|
|
@@ -1178,12 +1524,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1178
1524
|
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
1179
1525
|
]),
|
|
1180
1526
|
(value) => {
|
|
1527
|
+
var _a;
|
|
1181
1528
|
if (value.version === "legacy") {
|
|
1182
1529
|
return value;
|
|
1183
1530
|
}
|
|
1184
1531
|
return {
|
|
1185
1532
|
...value,
|
|
1186
|
-
addressTableLookups: value.addressTableLookups
|
|
1533
|
+
addressTableLookups: (_a = value.addressTableLookups) != null ? _a : []
|
|
1187
1534
|
};
|
|
1188
1535
|
}
|
|
1189
1536
|
);
|
|
@@ -1216,12 +1563,47 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1216
1563
|
]
|
|
1217
1564
|
];
|
|
1218
1565
|
}
|
|
1566
|
+
function getPreludeStructDecoderTuple() {
|
|
1567
|
+
return [
|
|
1568
|
+
["version", getTransactionVersionDecoder()],
|
|
1569
|
+
["header", getMessageHeaderDecoder()],
|
|
1570
|
+
[
|
|
1571
|
+
"staticAccounts",
|
|
1572
|
+
getArrayDecoder(getAddressDecoder(), {
|
|
1573
|
+
description: staticAccountsDescription,
|
|
1574
|
+
size: getShortU16Decoder()
|
|
1575
|
+
})
|
|
1576
|
+
],
|
|
1577
|
+
[
|
|
1578
|
+
"lifetimeToken",
|
|
1579
|
+
getStringDecoder({
|
|
1580
|
+
description: lifetimeTokenDescription,
|
|
1581
|
+
encoding: getBase58Decoder(),
|
|
1582
|
+
size: 32
|
|
1583
|
+
})
|
|
1584
|
+
],
|
|
1585
|
+
[
|
|
1586
|
+
"instructions",
|
|
1587
|
+
getArrayDecoder(getInstructionDecoder(), {
|
|
1588
|
+
description: instructionsDescription,
|
|
1589
|
+
size: getShortU16Decoder()
|
|
1590
|
+
})
|
|
1591
|
+
],
|
|
1592
|
+
["addressTableLookups", getAddressTableLookupArrayDecoder()]
|
|
1593
|
+
];
|
|
1594
|
+
}
|
|
1219
1595
|
function getAddressTableLookupArrayEncoder() {
|
|
1220
1596
|
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
1221
1597
|
description: addressTableLookupsDescription,
|
|
1222
1598
|
size: getShortU16Encoder()
|
|
1223
1599
|
});
|
|
1224
1600
|
}
|
|
1601
|
+
function getAddressTableLookupArrayDecoder() {
|
|
1602
|
+
return getArrayDecoder(getAddressTableLookupDecoder(), {
|
|
1603
|
+
description: addressTableLookupsDescription,
|
|
1604
|
+
size: getShortU16Decoder()
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1225
1607
|
var messageDescription = "The wire format of a Solana transaction message" ;
|
|
1226
1608
|
function getCompiledMessageEncoder() {
|
|
1227
1609
|
return {
|
|
@@ -1237,10 +1619,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1237
1619
|
maxSize: null
|
|
1238
1620
|
};
|
|
1239
1621
|
}
|
|
1622
|
+
function getCompiledMessageDecoder() {
|
|
1623
|
+
return mapDecoder(
|
|
1624
|
+
getStructDecoder(getPreludeStructDecoderTuple(), {
|
|
1625
|
+
description: messageDescription
|
|
1626
|
+
}),
|
|
1627
|
+
({ addressTableLookups, ...restOfMessage }) => {
|
|
1628
|
+
if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
|
|
1629
|
+
return restOfMessage;
|
|
1630
|
+
}
|
|
1631
|
+
return { ...restOfMessage, addressTableLookups };
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1240
1635
|
|
|
1241
1636
|
// src/serializers/transaction.ts
|
|
1242
|
-
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
1243
1637
|
var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
|
|
1638
|
+
var transactionDescription = "The wire format of a Solana transaction" ;
|
|
1244
1639
|
function getCompiledTransactionEncoder() {
|
|
1245
1640
|
return getStructEncoder(
|
|
1246
1641
|
[
|
|
@@ -1258,9 +1653,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1258
1653
|
}
|
|
1259
1654
|
);
|
|
1260
1655
|
}
|
|
1656
|
+
function getSignatureDecoder() {
|
|
1657
|
+
return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
|
|
1658
|
+
}
|
|
1659
|
+
function getCompiledTransactionDecoder() {
|
|
1660
|
+
return getStructDecoder(
|
|
1661
|
+
[
|
|
1662
|
+
[
|
|
1663
|
+
"signatures",
|
|
1664
|
+
getArrayDecoder(getSignatureDecoder(), {
|
|
1665
|
+
description: signaturesDescription,
|
|
1666
|
+
size: getShortU16Decoder()
|
|
1667
|
+
})
|
|
1668
|
+
],
|
|
1669
|
+
["compiledMessage", getCompiledMessageDecoder()]
|
|
1670
|
+
],
|
|
1671
|
+
{
|
|
1672
|
+
description: transactionDescription
|
|
1673
|
+
}
|
|
1674
|
+
);
|
|
1675
|
+
}
|
|
1261
1676
|
function getTransactionEncoder() {
|
|
1262
1677
|
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
1263
1678
|
}
|
|
1679
|
+
function getTransactionDecoder(lastValidBlockHeight) {
|
|
1680
|
+
return mapDecoder(
|
|
1681
|
+
getCompiledTransactionDecoder(),
|
|
1682
|
+
(compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
function getTransactionCodec(lastValidBlockHeight) {
|
|
1686
|
+
return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
|
|
1687
|
+
}
|
|
1264
1688
|
|
|
1265
1689
|
// ../keys/dist/index.browser.js
|
|
1266
1690
|
async function signBytes(key, data) {
|
|
@@ -1270,65 +1694,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1270
1694
|
}
|
|
1271
1695
|
|
|
1272
1696
|
// src/signatures.ts
|
|
1273
|
-
|
|
1274
|
-
try {
|
|
1275
|
-
if (
|
|
1276
|
-
// Lowest value (64 bytes of zeroes)
|
|
1277
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1278
|
-
putativeTransactionSignature.length > 88
|
|
1279
|
-
) {
|
|
1280
|
-
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
1281
|
-
}
|
|
1282
|
-
const bytes = base58.serialize(putativeTransactionSignature);
|
|
1283
|
-
const numBytes = bytes.byteLength;
|
|
1284
|
-
if (numBytes !== 64) {
|
|
1285
|
-
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
1286
|
-
}
|
|
1287
|
-
} catch (e2) {
|
|
1288
|
-
throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
|
|
1289
|
-
cause: e2
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
function isTransactionSignature(putativeTransactionSignature) {
|
|
1294
|
-
if (
|
|
1295
|
-
// Lowest value (64 bytes of zeroes)
|
|
1296
|
-
putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
|
|
1297
|
-
putativeTransactionSignature.length > 88
|
|
1298
|
-
) {
|
|
1299
|
-
return false;
|
|
1300
|
-
}
|
|
1301
|
-
const bytes = base58.serialize(putativeTransactionSignature);
|
|
1302
|
-
const numBytes = bytes.byteLength;
|
|
1303
|
-
if (numBytes !== 64) {
|
|
1304
|
-
return false;
|
|
1305
|
-
}
|
|
1306
|
-
return true;
|
|
1307
|
-
}
|
|
1308
|
-
async function getCompiledMessageSignature(message, secretKey) {
|
|
1309
|
-
const wireMessageBytes = getCompiledMessageEncoder().encode(message);
|
|
1310
|
-
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
1311
|
-
return signature;
|
|
1312
|
-
}
|
|
1697
|
+
var base58Decoder;
|
|
1313
1698
|
function getSignatureFromTransaction(transaction) {
|
|
1699
|
+
if (!base58Decoder)
|
|
1700
|
+
base58Decoder = getBase58Decoder();
|
|
1314
1701
|
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
1315
1702
|
if (!signatureBytes) {
|
|
1316
1703
|
throw new Error(
|
|
1317
1704
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
1318
1705
|
);
|
|
1319
1706
|
}
|
|
1320
|
-
const
|
|
1321
|
-
return
|
|
1707
|
+
const transactionSignature = base58Decoder.decode(signatureBytes)[0];
|
|
1708
|
+
return transactionSignature;
|
|
1322
1709
|
}
|
|
1323
|
-
async function
|
|
1710
|
+
async function partiallySignTransaction(keyPairs, transaction) {
|
|
1324
1711
|
const compiledMessage = compileMessage(transaction);
|
|
1325
1712
|
const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
|
|
1713
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
|
|
1326
1714
|
const publicKeySignaturePairs = await Promise.all(
|
|
1327
1715
|
keyPairs.map(
|
|
1328
|
-
(keyPair) => Promise.all([
|
|
1329
|
-
getAddressFromPublicKey(keyPair.publicKey),
|
|
1330
|
-
getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
|
|
1331
|
-
])
|
|
1716
|
+
(keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
|
|
1332
1717
|
)
|
|
1333
1718
|
);
|
|
1334
1719
|
for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
|
|
@@ -1341,35 +1726,48 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1341
1726
|
Object.freeze(out);
|
|
1342
1727
|
return out;
|
|
1343
1728
|
}
|
|
1344
|
-
function
|
|
1345
|
-
|
|
1346
|
-
|
|
1729
|
+
async function signTransaction(keyPairs, transaction) {
|
|
1730
|
+
const out = await partiallySignTransaction(keyPairs, transaction);
|
|
1731
|
+
assertTransactionIsFullySigned(out);
|
|
1732
|
+
Object.freeze(out);
|
|
1733
|
+
return out;
|
|
1734
|
+
}
|
|
1735
|
+
function assertTransactionIsFullySigned(transaction) {
|
|
1736
|
+
const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
|
|
1737
|
+
var _a, _b;
|
|
1738
|
+
return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole(a.role))) != null ? _b : [];
|
|
1739
|
+
}).map((a) => a.address);
|
|
1740
|
+
const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
|
|
1741
|
+
requiredSigners.forEach((address2) => {
|
|
1742
|
+
if (!transaction.signatures[address2]) {
|
|
1743
|
+
throw new Error(`Transaction is missing signature for address \`${address2}\``);
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1347
1746
|
}
|
|
1348
1747
|
|
|
1349
1748
|
// src/wire-transaction.ts
|
|
1350
1749
|
function getBase64EncodedWireTransaction(transaction) {
|
|
1351
1750
|
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
1352
|
-
|
|
1353
|
-
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
1354
|
-
}
|
|
1751
|
+
return getBase64Decoder().decode(wireTransactionBytes)[0];
|
|
1355
1752
|
}
|
|
1356
1753
|
|
|
1357
1754
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1358
1755
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1359
1756
|
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1360
|
-
exports.
|
|
1757
|
+
exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
|
|
1361
1758
|
exports.createTransaction = createTransaction;
|
|
1362
1759
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1363
1760
|
exports.getSignatureFromTransaction = getSignatureFromTransaction;
|
|
1761
|
+
exports.getTransactionCodec = getTransactionCodec;
|
|
1762
|
+
exports.getTransactionDecoder = getTransactionDecoder;
|
|
1364
1763
|
exports.getTransactionEncoder = getTransactionEncoder;
|
|
1365
1764
|
exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
|
|
1366
|
-
exports.
|
|
1765
|
+
exports.partiallySignTransaction = partiallySignTransaction;
|
|
1367
1766
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1368
1767
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1369
1768
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1370
1769
|
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1371
1770
|
exports.signTransaction = signTransaction;
|
|
1372
|
-
exports.transactionSignature = transactionSignature;
|
|
1373
1771
|
|
|
1374
1772
|
return exports;
|
|
1375
1773
|
|