@solana/compat 2.0.0-experimental.be901cf → 2.0.0-experimental.c144a41
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 +40 -4
- package/dist/index.browser.cjs +66 -28
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +65 -29
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +65 -29
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +68 -28
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +65 -29
- package/dist/index.node.js.map +1 -1
- package/dist/types/address.d.ts +9 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keypair.d.ts +8 -0
- package/dist/types/keypair.d.ts.map +1 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/package.json +13 -12
- package/dist/index.development.js +0 -320
- package/dist/index.development.js.map +0 -1
- package/dist/index.production.min.js +0 -12
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
this.globalThis = this.globalThis || {};
|
|
2
|
-
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
// ../codecs-strings/dist/index.browser.js
|
|
6
|
-
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
7
|
-
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
8
|
-
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
var getBaseXEncoder = (alphabet4) => {
|
|
12
|
-
const base = alphabet4.length;
|
|
13
|
-
const baseBigInt = BigInt(base);
|
|
14
|
-
return {
|
|
15
|
-
description: `base${base}`,
|
|
16
|
-
encode(value) {
|
|
17
|
-
assertValidBaseString(alphabet4, value);
|
|
18
|
-
if (value === "")
|
|
19
|
-
return new Uint8Array();
|
|
20
|
-
const chars = [...value];
|
|
21
|
-
let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
|
|
22
|
-
trailIndex = trailIndex === -1 ? chars.length : trailIndex;
|
|
23
|
-
const leadingZeroes = Array(trailIndex).fill(0);
|
|
24
|
-
if (trailIndex === chars.length)
|
|
25
|
-
return Uint8Array.from(leadingZeroes);
|
|
26
|
-
const tailChars = chars.slice(trailIndex);
|
|
27
|
-
let base10Number = 0n;
|
|
28
|
-
let baseXPower = 1n;
|
|
29
|
-
for (let i = tailChars.length - 1; i >= 0; i -= 1) {
|
|
30
|
-
base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
|
|
31
|
-
baseXPower *= baseBigInt;
|
|
32
|
-
}
|
|
33
|
-
const tailBytes = [];
|
|
34
|
-
while (base10Number > 0n) {
|
|
35
|
-
tailBytes.unshift(Number(base10Number % 256n));
|
|
36
|
-
base10Number /= 256n;
|
|
37
|
-
}
|
|
38
|
-
return Uint8Array.from(leadingZeroes.concat(tailBytes));
|
|
39
|
-
},
|
|
40
|
-
fixedSize: null,
|
|
41
|
-
maxSize: null
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
45
|
-
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
46
|
-
|
|
47
|
-
// ../addresses/dist/index.browser.js
|
|
48
|
-
var memoizedBase58Encoder;
|
|
49
|
-
function getMemoizedBase58Encoder() {
|
|
50
|
-
if (!memoizedBase58Encoder)
|
|
51
|
-
memoizedBase58Encoder = getBase58Encoder();
|
|
52
|
-
return memoizedBase58Encoder;
|
|
53
|
-
}
|
|
54
|
-
function assertIsAddress(putativeBase58EncodedAddress) {
|
|
55
|
-
try {
|
|
56
|
-
if (
|
|
57
|
-
// Lowest address (32 bytes of zeroes)
|
|
58
|
-
putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
59
|
-
putativeBase58EncodedAddress.length > 44
|
|
60
|
-
) {
|
|
61
|
-
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
62
|
-
}
|
|
63
|
-
const base58Encoder = getMemoizedBase58Encoder();
|
|
64
|
-
const bytes = base58Encoder.encode(putativeBase58EncodedAddress);
|
|
65
|
-
const numBytes = bytes.byteLength;
|
|
66
|
-
if (numBytes !== 32) {
|
|
67
|
-
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
68
|
-
}
|
|
69
|
-
} catch (e2) {
|
|
70
|
-
throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
|
|
71
|
-
cause: e2
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ../functional/dist/index.browser.js
|
|
77
|
-
function pipe(init, ...fns) {
|
|
78
|
-
return fns.reduce((acc, fn) => fn(acc), init);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ../instructions/dist/index.browser.js
|
|
82
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
|
|
83
|
-
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
84
|
-
3] = "WRITABLE_SIGNER";
|
|
85
|
-
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
86
|
-
2] = "READONLY_SIGNER";
|
|
87
|
-
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
88
|
-
1] = "WRITABLE";
|
|
89
|
-
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
90
|
-
0] = "READONLY";
|
|
91
|
-
return AccountRole22;
|
|
92
|
-
})(AccountRole || {});
|
|
93
|
-
|
|
94
|
-
// ../transactions/dist/index.browser.js
|
|
95
|
-
function getUnsignedTransaction(transaction) {
|
|
96
|
-
if ("signatures" in transaction) {
|
|
97
|
-
const {
|
|
98
|
-
signatures: _,
|
|
99
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
100
|
-
...unsignedTransaction
|
|
101
|
-
} = transaction;
|
|
102
|
-
return unsignedTransaction;
|
|
103
|
-
} else {
|
|
104
|
-
return transaction;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
108
|
-
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
109
|
-
return transaction;
|
|
110
|
-
}
|
|
111
|
-
const out = {
|
|
112
|
-
...getUnsignedTransaction(transaction),
|
|
113
|
-
lifetimeConstraint: blockhashLifetimeConstraint
|
|
114
|
-
};
|
|
115
|
-
Object.freeze(out);
|
|
116
|
-
return out;
|
|
117
|
-
}
|
|
118
|
-
function createTransaction({
|
|
119
|
-
version
|
|
120
|
-
}) {
|
|
121
|
-
const out = {
|
|
122
|
-
instructions: [],
|
|
123
|
-
version
|
|
124
|
-
};
|
|
125
|
-
Object.freeze(out);
|
|
126
|
-
return out;
|
|
127
|
-
}
|
|
128
|
-
var AccountRole2 = /* @__PURE__ */ ((AccountRole22) => {
|
|
129
|
-
AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
|
|
130
|
-
3] = "WRITABLE_SIGNER";
|
|
131
|
-
AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
|
|
132
|
-
2] = "READONLY_SIGNER";
|
|
133
|
-
AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
|
|
134
|
-
1] = "WRITABLE";
|
|
135
|
-
AccountRole22[AccountRole22["READONLY"] = /* 0 */
|
|
136
|
-
0] = "READONLY";
|
|
137
|
-
return AccountRole22;
|
|
138
|
-
})(AccountRole2 || {});
|
|
139
|
-
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
140
|
-
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
141
|
-
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
142
|
-
return {
|
|
143
|
-
accounts: [
|
|
144
|
-
{ address: nonceAccountAddress, role: AccountRole2.WRITABLE },
|
|
145
|
-
{
|
|
146
|
-
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
147
|
-
role: AccountRole2.READONLY
|
|
148
|
-
},
|
|
149
|
-
{ address: nonceAuthorityAddress, role: AccountRole2.READONLY_SIGNER }
|
|
150
|
-
],
|
|
151
|
-
data: new Uint8Array([4, 0, 0, 0]),
|
|
152
|
-
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function isAdvanceNonceAccountInstruction(instruction) {
|
|
156
|
-
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
157
|
-
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
158
|
-
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
159
|
-
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
|
|
160
|
-
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
|
|
161
|
-
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole2.READONLY_SIGNER;
|
|
162
|
-
}
|
|
163
|
-
function isAdvanceNonceAccountInstructionData(data) {
|
|
164
|
-
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
165
|
-
}
|
|
166
|
-
function isDurableNonceTransaction(transaction) {
|
|
167
|
-
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
168
|
-
}
|
|
169
|
-
function setTransactionLifetimeUsingDurableNonce({
|
|
170
|
-
nonce,
|
|
171
|
-
nonceAccountAddress,
|
|
172
|
-
nonceAuthorityAddress
|
|
173
|
-
}, transaction) {
|
|
174
|
-
const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
|
|
175
|
-
if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
|
|
176
|
-
return transaction;
|
|
177
|
-
}
|
|
178
|
-
const out = {
|
|
179
|
-
...getUnsignedTransaction(transaction),
|
|
180
|
-
instructions: [
|
|
181
|
-
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
182
|
-
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
183
|
-
],
|
|
184
|
-
lifetimeConstraint: {
|
|
185
|
-
nonce
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
Object.freeze(out);
|
|
189
|
-
return out;
|
|
190
|
-
}
|
|
191
|
-
function setTransactionFeePayer(feePayer, transaction) {
|
|
192
|
-
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
193
|
-
return transaction;
|
|
194
|
-
}
|
|
195
|
-
const out = {
|
|
196
|
-
...getUnsignedTransaction(transaction),
|
|
197
|
-
feePayer
|
|
198
|
-
};
|
|
199
|
-
Object.freeze(out);
|
|
200
|
-
return out;
|
|
201
|
-
}
|
|
202
|
-
function appendTransactionInstruction(instruction, transaction) {
|
|
203
|
-
const out = {
|
|
204
|
-
...getUnsignedTransaction(transaction),
|
|
205
|
-
instructions: [...transaction.instructions, instruction]
|
|
206
|
-
};
|
|
207
|
-
Object.freeze(out);
|
|
208
|
-
return out;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/transaction.ts
|
|
212
|
-
function convertAccount(message, accountKeys, accountIndex) {
|
|
213
|
-
const accountPublicKey = accountKeys.get(accountIndex);
|
|
214
|
-
if (!accountPublicKey) {
|
|
215
|
-
throw new Error(`Could not find account address at index ${accountIndex}`);
|
|
216
|
-
}
|
|
217
|
-
const isSigner = message.isAccountSigner(accountIndex);
|
|
218
|
-
const isWritable = message.isAccountWritable(accountIndex);
|
|
219
|
-
const role = isSigner ? isWritable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER : isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
220
|
-
return {
|
|
221
|
-
address: accountPublicKey.toBase58(),
|
|
222
|
-
role
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function convertInstruction(message, accountKeys, instruction) {
|
|
226
|
-
const programAddressPublicKey = accountKeys.get(instruction.programIdIndex);
|
|
227
|
-
if (!programAddressPublicKey) {
|
|
228
|
-
throw new Error(`Could not find program address at index ${instruction.programIdIndex}`);
|
|
229
|
-
}
|
|
230
|
-
const accounts = instruction.accountKeyIndexes.map(
|
|
231
|
-
(accountIndex) => convertAccount(message, accountKeys, accountIndex)
|
|
232
|
-
);
|
|
233
|
-
return {
|
|
234
|
-
programAddress: programAddressPublicKey.toBase58(),
|
|
235
|
-
...accounts.length ? { accounts } : {},
|
|
236
|
-
...instruction.data.length ? { data: instruction.data } : {}
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
function convertSignatures(transaction, staticAccountKeys) {
|
|
240
|
-
return transaction.signatures.reduce((acc, sig, index) => {
|
|
241
|
-
const allZeros = sig.every((byte) => byte === 0);
|
|
242
|
-
if (allZeros)
|
|
243
|
-
return acc;
|
|
244
|
-
const address = staticAccountKeys[index].toBase58();
|
|
245
|
-
return { ...acc, [address]: sig };
|
|
246
|
-
}, {});
|
|
247
|
-
}
|
|
248
|
-
function fromVersionedTransactionWithBlockhash(transaction, lastValidBlockHeight) {
|
|
249
|
-
if (transaction.message.addressTableLookups.length > 0) {
|
|
250
|
-
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
251
|
-
}
|
|
252
|
-
const accountKeys = transaction.message.getAccountKeys();
|
|
253
|
-
const feePayer = accountKeys.staticAccountKeys[0];
|
|
254
|
-
if (!feePayer)
|
|
255
|
-
throw new Error("No fee payer set in VersionedTransaction");
|
|
256
|
-
const blockhashLifetime = {
|
|
257
|
-
blockhash: transaction.message.recentBlockhash,
|
|
258
|
-
lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
|
|
259
|
-
// U64 MAX
|
|
260
|
-
};
|
|
261
|
-
const instructions = transaction.message.compiledInstructions.map(
|
|
262
|
-
(instruction) => convertInstruction(transaction.message, accountKeys, instruction)
|
|
263
|
-
);
|
|
264
|
-
const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);
|
|
265
|
-
return pipe(
|
|
266
|
-
createTransaction({ version: transaction.version }),
|
|
267
|
-
(tx) => setTransactionFeePayer(feePayer.toBase58(), tx),
|
|
268
|
-
(tx) => setTransactionLifetimeUsingBlockhash(blockhashLifetime, tx),
|
|
269
|
-
(tx) => instructions.reduce((acc, instruction) => {
|
|
270
|
-
return appendTransactionInstruction(instruction, acc);
|
|
271
|
-
}, tx),
|
|
272
|
-
(tx) => transaction.signatures.length ? { ...tx, signatures } : tx
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
function fromVersionedTransactionWithDurableNonce(transaction) {
|
|
276
|
-
if (transaction.message.addressTableLookups.length > 0) {
|
|
277
|
-
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
278
|
-
}
|
|
279
|
-
const accountKeys = transaction.message.getAccountKeys();
|
|
280
|
-
const feePayer = accountKeys.staticAccountKeys[0];
|
|
281
|
-
if (!feePayer)
|
|
282
|
-
throw new Error("No fee payer set in VersionedTransaction");
|
|
283
|
-
const instructions = transaction.message.compiledInstructions.map(
|
|
284
|
-
(instruction) => convertInstruction(transaction.message, accountKeys, instruction)
|
|
285
|
-
);
|
|
286
|
-
if (instructions.length === 0) {
|
|
287
|
-
throw new Error("transaction with no instructions cannot be durable nonce transaction");
|
|
288
|
-
}
|
|
289
|
-
if (!isAdvanceNonceAccountInstruction(instructions[0])) {
|
|
290
|
-
throw new Error("transaction first instruction is not advance nonce account instruction");
|
|
291
|
-
}
|
|
292
|
-
const nonceAccountAddress = instructions[0].accounts[0].address;
|
|
293
|
-
assertIsAddress(nonceAccountAddress);
|
|
294
|
-
const nonceAuthorityAddress = instructions[0].accounts[2].address;
|
|
295
|
-
assertIsAddress(nonceAuthorityAddress);
|
|
296
|
-
const durableNonceLifetime = {
|
|
297
|
-
nonce: transaction.message.recentBlockhash,
|
|
298
|
-
nonceAccountAddress,
|
|
299
|
-
nonceAuthorityAddress
|
|
300
|
-
};
|
|
301
|
-
const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);
|
|
302
|
-
return pipe(
|
|
303
|
-
createTransaction({ version: transaction.version }),
|
|
304
|
-
(tx) => setTransactionFeePayer(feePayer.toBase58(), tx),
|
|
305
|
-
(tx) => setTransactionLifetimeUsingDurableNonce(durableNonceLifetime, tx),
|
|
306
|
-
(tx) => instructions.slice(1).reduce((acc, instruction) => {
|
|
307
|
-
return appendTransactionInstruction(instruction, acc);
|
|
308
|
-
}, tx),
|
|
309
|
-
(tx) => transaction.signatures.length ? { ...tx, signatures } : tx
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
exports.fromVersionedTransactionWithBlockhash = fromVersionedTransactionWithBlockhash;
|
|
314
|
-
exports.fromVersionedTransactionWithDurableNonce = fromVersionedTransactionWithDurableNonce;
|
|
315
|
-
|
|
316
|
-
return exports;
|
|
317
|
-
|
|
318
|
-
})({});
|
|
319
|
-
//# sourceMappingURL=out.js.map
|
|
320
|
-
//# sourceMappingURL=index.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../codecs-strings/dist/index.browser.js","../../addresses/src/address.ts","../../functional/src/pipe.ts","../../instructions/src/roles.ts","../../transactions/src/unsigned-transaction.ts","../../transactions/src/blockhash.ts","../../transactions/src/create-transaction.ts","../../transactions/src/durable-nonce.ts","../../transactions/src/fee-payer.ts","../../transactions/src/instructions.ts","../../transactions/src/accounts.ts","../src/transaction.ts"],"names":["e","AccountRole","AccountRole2"],"mappings":";AAIA,SAAS,sBAAsB,WAAW,WAAW,aAAa,WAAW;AAC3E,MAAI,CAAC,UAAU,MAAM,IAAI,OAAO,KAAK,SAAS,KAAK,CAAC,GAAG;AACrD,UAAM,IAAI,MAAM,6BAA6B,UAAU,MAAM,UAAU,UAAU,IAAI;AAAA,EACvF;AACF;AACA,IAAI,kBAAkB,CAAC,cAAc;AACnC,QAAM,OAAO,UAAU;AACvB,QAAM,aAAa,OAAO,IAAI;AAC9B,SAAO;AAAA,IACL,aAAa,OAAO,IAAI;AAAA,IACxB,OAAO,OAAO;AACZ,4BAAsB,WAAW,KAAK;AACtC,UAAI,UAAU;AACZ,eAAO,IAAI,WAAW;AACxB,YAAM,QAAQ,CAAC,GAAG,KAAK;AACvB,UAAI,aAAa,MAAM,UAAU,CAAC,MAAM,MAAM,UAAU,CAAC,CAAC;AAC1D,mBAAa,eAAe,KAAK,MAAM,SAAS;AAChD,YAAM,gBAAgB,MAAM,UAAU,EAAE,KAAK,CAAC;AAC9C,UAAI,eAAe,MAAM;AACvB,eAAO,WAAW,KAAK,aAAa;AACtC,YAAM,YAAY,MAAM,MAAM,UAAU;AACxC,UAAI,eAAe;AACnB,UAAI,aAAa;AACjB,eAAS,IAAI,UAAU,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;AACjD,wBAAgB,aAAa,OAAO,UAAU,QAAQ,UAAU,CAAC,CAAC,CAAC;AACnE,sBAAc;AAAA,MAChB;AACA,YAAM,YAAY,CAAC;AACnB,aAAO,eAAe,IAAI;AACxB,kBAAU,QAAQ,OAAO,eAAe,IAAI,CAAC;AAC7C,wBAAgB;AAAA,MAClB;AACA,aAAO,WAAW,KAAK,cAAc,OAAO,SAAS,CAAC;AAAA,IACxD;AAAA,I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ACzD,kBAAgB,mBAAmB;AAEnC,QAAM,wBAAwB,aAAa,CAAC,EAAE,SAAU,CAAC,EAAE;AAC3D,kBAAgB,qBAAqB;AAErC,QAAM,uBAAuB;AAAA,IACzB,OAAO,YAAY,QAAQ;AAAA,IAC3B;AAAA,IACA;AAAA,EACJ;AAEA,QAAM,aAAa,kBAAkB,aAAa,YAAY,iBAAiB;AAE/E,SAAO;AAAA,IACH,kBAAkB,EAAE,SAAS,YAAY,QAAQ,CAAC;AAAA,IAClD,QAAM,uBAAuB,SAAS,SAAS,GAA2B,EAAE;AAAA,IAC5E,QAAM,wCAAwC,sBAAsB,EAAE;AAAA,IACtE,QACI,aAAa,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,gBAAgB;AAC/C,aAAO,6BAA6B,aAAa,GAAG;AAAA,IACxD,GAAG,EAAE;AAAA,IACT,QAAO,YAAY,WAAW,SAAS,EAAE,GAAG,IAAI,WAAW,IAAI;AAAA,EACnE;AACJ","sourcesContent":["import { combineCodec, fixEncoder, mergeBytes, fixDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';\nimport { getU32Encoder, getU32Decoder } from '@solana/codecs-numbers';\n\n// src/assertions.ts\nfunction assertValidBaseString(alphabet4, testValue, givenValue = testValue) {\n if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {\n throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);\n }\n}\nvar getBaseXEncoder = (alphabet4) => {\n const base = alphabet4.length;\n const baseBigInt = BigInt(base);\n return {\n description: `base${base}`,\n encode(value) {\n assertValidBaseString(alphabet4, value);\n if (value === \"\")\n return new Uint8Array();\n const chars = [...value];\n let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);\n trailIndex = trailIndex === -1 ? chars.length : trailIndex;\n const leadingZeroes = Array(trailIndex).fill(0);\n if (trailIndex === chars.length)\n return Uint8Array.from(leadingZeroes);\n const tailChars = chars.slice(trailIndex);\n let base10Number = 0n;\n let baseXPower = 1n;\n for (let i = tailChars.length - 1; i >= 0; i -= 1) {\n base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));\n baseXPower *= baseBigInt;\n }\n const tailBytes = [];\n while (base10Number > 0n) {\n tailBytes.unshift(Number(base10Number % 256n));\n base10Number /= 256n;\n }\n return Uint8Array.from(leadingZeroes.concat(tailBytes));\n },\n fixedSize: null,\n maxSize: null\n };\n};\nvar getBaseXDecoder = (alphabet4) => {\n const base = alphabet4.length;\n const baseBigInt = BigInt(base);\n return {\n decode(rawBytes, offset = 0) {\n const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);\n if (bytes.length === 0)\n return [\"\", 0];\n let trailIndex = bytes.findIndex((n) => n !== 0);\n trailIndex = trailIndex === -1 ? bytes.length : trailIndex;\n const leadingZeroes = alphabet4[0].repeat(trailIndex);\n if (trailIndex === bytes.length)\n return [leadingZeroes, rawBytes.length];\n let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);\n const tailChars = [];\n while (base10Number > 0n) {\n tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);\n base10Number /= baseBigInt;\n }\n return [leadingZeroes + tailChars.join(\"\"), rawBytes.length];\n },\n description: `base${base}`,\n fixedSize: null,\n maxSize: null\n };\n};\nvar getBaseXCodec = (alphabet4) => combineCodec(getBaseXEncoder(alphabet4), getBaseXDecoder(alphabet4));\n\n// src/base10.ts\nvar alphabet = \"0123456789\";\nvar getBase10Encoder = () => getBaseXEncoder(alphabet);\nvar getBase10Decoder = () => getBaseXDecoder(alphabet);\nvar getBase10Codec = () => getBaseXCodec(alphabet);\nvar getBase16Encoder = () => ({\n description: \"base16\",\n encode(value) {\n const lowercaseValue = value.toLowerCase();\n assertValidBaseString(\"0123456789abcdef\", lowercaseValue, value);\n const matches = lowercaseValue.match(/.{1,2}/g);\n return Uint8Array.from(matches ? matches.map((byte) => parseInt(byte, 16)) : []);\n },\n fixedSize: null,\n maxSize: null\n});\nvar getBase16Decoder = () => ({\n decode(bytes, offset = 0) {\n const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, \"0\"), \"\");\n return [value, bytes.length];\n },\n description: \"base16\",\n fixedSize: null,\n maxSize: null\n});\nvar getBase16Codec = () => combineCodec(getBase16Encoder(), getBase16Decoder());\n\n// src/base58.ts\nvar alphabet2 = \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\nvar getBase58Encoder = () => getBaseXEncoder(alphabet2);\nvar getBase58Decoder = () => getBaseXDecoder(alphabet2);\nvar getBase58Codec = () => getBaseXCodec(alphabet2);\nvar getBaseXResliceEncoder = (alphabet4, bits) => ({\n description: `base${alphabet4.length}`,\n encode(value) {\n assertValidBaseString(alphabet4, value);\n if (value === \"\")\n return new Uint8Array();\n const charIndices = [...value].map((c) => alphabet4.indexOf(c));\n return new Uint8Array(reslice(charIndices, bits, 8, false));\n },\n fixedSize: null,\n maxSize: null\n});\nvar getBaseXResliceDecoder = (alphabet4, bits) => ({\n decode(rawBytes, offset = 0) {\n const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);\n if (bytes.length === 0)\n return [\"\", rawBytes.length];\n const charIndices = reslice([...bytes], 8, bits, true);\n return [charIndices.map((i) => alphabet4[i]).join(\"\"), rawBytes.length];\n },\n description: `base${alphabet4.length}`,\n fixedSize: null,\n maxSize: null\n});\nvar getBaseXResliceCodec = (alphabet4, bits) => combineCodec(getBaseXResliceEncoder(alphabet4, bits), getBaseXResliceDecoder(alphabet4, bits));\nfunction reslice(input, inputBits, outputBits, useRemainder) {\n const output = [];\n let accumulator = 0;\n let bitsInAccumulator = 0;\n const mask = (1 << outputBits) - 1;\n for (const value of input) {\n accumulator = accumulator << inputBits | value;\n bitsInAccumulator += inputBits;\n while (bitsInAccumulator >= outputBits) {\n bitsInAccumulator -= outputBits;\n output.push(accumulator >> bitsInAccumulator & mask);\n }\n }\n if (useRemainder && bitsInAccumulator > 0) {\n output.push(accumulator << outputBits - bitsInAccumulator & mask);\n }\n return output;\n}\nvar getBase64Encoder = () => {\n {\n return {\n description: `base64`,\n encode(value) {\n try {\n const bytes = atob(value).split(\"\").map((c) => c.charCodeAt(0));\n return new Uint8Array(bytes);\n } catch (e2) {\n throw new Error(`Expected a string of base 64, got [${value}].`);\n }\n },\n fixedSize: null,\n maxSize: null\n };\n }\n};\nvar getBase64Decoder = () => {\n {\n return {\n decode(bytes, offset = 0) {\n const slice = bytes.slice(offset);\n const value = btoa(String.fromCharCode(...slice));\n return [value, bytes.length];\n },\n description: `base64`,\n fixedSize: null,\n maxSize: null\n };\n }\n};\nvar getBase64Codec = () => combineCodec(getBase64Encoder(), getBase64Decoder());\n\n// src/null-characters.ts\nvar removeNullCharacters = (value) => (\n // eslint-disable-next-line no-control-regex\n value.replace(/\\u0000/g, \"\")\n);\nvar padNullCharacters = (value, chars) => value.padEnd(chars, \"\\0\");\n\n// ../text-encoding-impl/dist/index.browser.js\nvar e = globalThis.TextDecoder;\nvar o = globalThis.TextEncoder;\n\n// src/utf8.ts\nvar getUtf8Encoder = () => {\n let textEncoder;\n return {\n description: \"utf8\",\n encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),\n fixedSize: null,\n maxSize: null\n };\n};\nvar getUtf8Decoder = () => {\n let textDecoder;\n return {\n decode(bytes, offset = 0) {\n const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));\n return [removeNullCharacters(value), bytes.length];\n },\n description: \"utf8\",\n fixedSize: null,\n maxSize: null\n };\n};\nvar getUtf8Codec = () => combineCodec(getUtf8Encoder(), getUtf8Decoder());\n\n// src/string.ts\nvar getStringEncoder = (options = {}) => {\n const size = options.size ?? getU32Encoder();\n const encoding = options.encoding ?? getUtf8Encoder();\n const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;\n if (size === \"variable\") {\n return { ...encoding, description };\n }\n if (typeof size === \"number\") {\n return fixEncoder(encoding, size, description);\n }\n return {\n description,\n encode: (value) => {\n const contentBytes = encoding.encode(value);\n const lengthBytes = size.encode(contentBytes.length);\n return mergeBytes([lengthBytes, contentBytes]);\n },\n fixedSize: null,\n maxSize: null\n };\n};\nvar getStringDecoder = (options = {}) => {\n const size = options.size ?? getU32Decoder();\n const encoding = options.encoding ?? getUtf8Decoder();\n const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;\n if (size === \"variable\") {\n return { ...encoding, description };\n }\n if (typeof size === \"number\") {\n return fixDecoder(encoding, size, description);\n }\n return {\n decode: (bytes, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec(\"string\", bytes, offset);\n const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);\n const length = Number(lengthBigInt);\n offset = lengthOffset;\n const contentBytes = bytes.slice(offset, offset + length);\n assertByteArrayHasEnoughBytesForCodec(\"string\", length, contentBytes);\n const [value, contentOffset] = encoding.decode(contentBytes);\n offset += contentOffset;\n return [value, offset];\n },\n description,\n fixedSize: null,\n maxSize: null\n };\n};\nvar getStringCodec = (options = {}) => combineCodec(getStringEncoder(options), getStringDecoder(options));\nfunction getSizeDescription(size) {\n return typeof size === \"object\" ? size.description : `${size}`;\n}\n\nexport { assertValidBaseString, getBase10Codec, getBase10Decoder, getBase10Encoder, getBase16Codec, getBase16Decoder, getBase16Encoder, getBase58Codec, getBase58Decoder, getBase58Encoder, getBase64Codec, getBase64Decoder, getBase64Encoder, getBaseXCodec, getBaseXDecoder, getBaseXEncoder, getBaseXResliceCodec, getBaseXResliceDecoder, getBaseXResliceEncoder, getStringCodec, getStringDecoder, getStringEncoder, getUtf8Codec, getUtf8Decoder, getUtf8Encoder, padNullCharacters, removeNullCharacters };\n","import { Codec, combineCodec, Decoder, Encoder, mapEncoder } from '@solana/codecs-core';\nimport { getBase58Decoder, getBase58Encoder, getStringDecoder, getStringEncoder } from '@solana/codecs-strings';\n\nexport type Base58EncodedAddress<TAddress extends string = string> = TAddress & {\n readonly __brand: unique symbol;\n};\n\nlet memoizedBase58Encoder: Encoder<string> | undefined;\nlet memoizedBase58Decoder: Decoder<string> | undefined;\n\nfunction getMemoizedBase58Encoder(): Encoder<string> {\n if (!memoizedBase58Encoder) memoizedBase58Encoder = getBase58Encoder();\n return memoizedBase58Encoder;\n}\n\nfunction getMemoizedBase58Decoder(): Decoder<string> {\n if (!memoizedBase58Decoder) memoizedBase58Decoder = getBase58Decoder();\n return memoizedBase58Decoder;\n}\n\nexport function isAddress(\n putativeBase58EncodedAddress: string\n): putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n return false;\n }\n // Slow-path; actually attempt to decode the input string.\n const base58Encoder = getMemoizedBase58Encoder();\n const bytes = base58Encoder.encode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n return false;\n }\n return true;\n}\n\nexport function assertIsAddress(\n putativeBase58EncodedAddress: string\n): asserts putativeBase58EncodedAddress is Base58EncodedAddress<typeof putativeBase58EncodedAddress> {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeBase58EncodedAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeBase58EncodedAddress.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const base58Encoder = getMemoizedBase58Encoder();\n const bytes = base58Encoder.encode(putativeBase58EncodedAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBase58EncodedAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function address<TAddress extends string = string>(\n putativeBase58EncodedAddress: TAddress\n): Base58EncodedAddress<TAddress> {\n assertIsAddress(putativeBase58EncodedAddress);\n return putativeBase58EncodedAddress as Base58EncodedAddress<TAddress>;\n}\n\nexport function getAddressEncoder(config?: Readonly<{ description: string }>): Encoder<Base58EncodedAddress> {\n return mapEncoder(\n getStringEncoder({\n description: config?.description ?? 'Base58EncodedAddress',\n encoding: getMemoizedBase58Encoder(),\n size: 32,\n }),\n putativeAddress => address(putativeAddress)\n );\n}\n\nexport function getAddressDecoder(config?: Readonly<{ description: string }>): Decoder<Base58EncodedAddress> {\n return getStringDecoder({\n description: config?.description ?? 'Base58EncodedAddress',\n encoding: getMemoizedBase58Decoder(),\n size: 32,\n }) as Decoder<Base58EncodedAddress>;\n}\n\nexport function getAddressCodec(config?: Readonly<{ description: string }>): Codec<Base58EncodedAddress> {\n return combineCodec(getAddressEncoder(config), getAddressDecoder(config));\n}\n\nexport function getAddressComparator(): (x: string, y: string) => number {\n return new Intl.Collator('en', {\n caseFirst: 'lower',\n ignorePunctuation: false,\n localeMatcher: 'best fit',\n numeric: false,\n sensitivity: 'variant',\n usage: 'sort',\n }).compare;\n}\n","/**\n * General pipe function.\n * Provide an initial value and a list of functions to pipe it through.\n *\n * Following common implementations of pipe functions that use TypeScript,\n * this function supports a maximum arity of 10 for type safety.\n * @see https://github.com/ramda/ramda/blob/master/source/pipe.js\n * @see https://github.com/darky/rocket-pipes/blob/master/index.ts\n *\n * Note you can use nested pipes to extend this limitation, like so:\n * ```typescript\n * const myValue = pipe(\n * pipe(\n * 1,\n * (x) => x + 1,\n * (x) => x * 2,\n * (x) => x - 1,\n * ),\n * (y) => y / 3,\n * (y) => y + 1,\n * );\n * ```\n * @param init The initial value\n * @param fns Any number of functions to pipe the value through\n * @returns The final value with all functions applied\n */\nexport function pipe<TInitial>(init: TInitial): TInitial;\nexport function pipe<TInitial, R1>(init: TInitial, init_r1: (init: TInitial) => R1): R1;\nexport function pipe<TInitial, R1, R2>(init: TInitial, init_r1: (init: TInitial) => R1, r1_r2: (r1: R1) => R2): R2;\nexport function pipe<TInitial, R1, R2, R3>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3\n): R3;\nexport function pipe<TInitial, R1, R2, R3, R4>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4\n): R4;\nexport function pipe<TInitial, R1, R2, R3, R4, R5>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5\n): R5;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6\n): R6;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7\n): R7;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7, R8>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7,\n r7_r8: (r7: R7) => R8\n): R8;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7, R8, R9>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7,\n r7_r8: (r7: R7) => R8,\n r8_r9: (r8: R8) => R9\n): R9;\nexport function pipe<TInitial, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(\n init: TInitial,\n init_r1: (init: TInitial) => R1,\n r1_r2: (r1: R1) => R2,\n r2_r3: (r2: R2) => R3,\n r3_r4: (r3: R3) => R4,\n r4_r5: (r4: R4) => R5,\n r5_r6: (r5: R5) => R6,\n r6_r7: (r6: R6) => R7,\n r7_r8: (r7: R7) => R8,\n r8_r9: (r8: R8) => R9,\n r9_r10: (r9: R9) => R10\n): R10;\nexport function pipe<TInitial>(init: TInitial, ...fns: CallableFunction[]) {\n return fns.reduce((acc, fn) => fn(acc), init);\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n","import { ITransactionWithSignatures } from '.';\nimport { BaseTransaction } from './types';\n\nexport function getUnsignedTransaction<TTransaction extends BaseTransaction>(\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction & ITransactionWithSignatures, keyof ITransactionWithSignatures> {\n if ('signatures' in transaction) {\n // The implication of the lifetime constraint changing is that any existing signatures are invalid.\n const {\n signatures: _, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...unsignedTransaction\n } = transaction;\n return unsignedTransaction;\n } else {\n return transaction;\n }\n}\n","import { base58 } from '@metaplex-foundation/umi-serializers';\n\nimport { IDurableNonceTransaction } from './durable-nonce';\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport type Blockhash = string & { readonly __brand: unique symbol };\n\ntype BlockhashLifetimeConstraint = Readonly<{\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n}>;\n\nexport interface ITransactionWithBlockhashLifetime {\n readonly lifetimeConstraint: BlockhashLifetimeConstraint;\n}\n\nexport function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash {\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (32 bytes of zeroes)\n putativeBlockhash.length < 32 ||\n // Highest value (32 bytes of 255)\n putativeBlockhash.length > 44\n ) {\n throw new Error('Expected input string to decode to a byte array of length 32.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58.serialize(putativeBlockhash);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeBlockhash}\\` is not a blockhash`, {\n cause: e,\n });\n }\n}\n\nexport function setTransactionLifetimeUsingBlockhash<TTransaction extends BaseTransaction & IDurableNonceTransaction>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures | 'lifetimeConstraint'> & ITransactionWithBlockhashLifetime;\n\nexport function setTransactionLifetimeUsingBlockhash<\n TTransaction extends BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)\n>(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithBlockhashLifetime;\n\nexport function setTransactionLifetimeUsingBlockhash(\n blockhashLifetimeConstraint: BlockhashLifetimeConstraint,\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime)\n) {\n if (\n 'lifetimeConstraint' in transaction &&\n transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash &&\n transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight\n ) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n lifetimeConstraint: blockhashLifetimeConstraint,\n };\n Object.freeze(out);\n return out;\n}\n","import { Transaction, TransactionVersion } from './types';\n\ntype TransactionConfig<TVersion extends TransactionVersion> = Readonly<{\n version: TVersion;\n}>;\n\nexport function createTransaction<TVersion extends TransactionVersion>(\n config: TransactionConfig<TVersion>\n): Extract<Transaction, { version: TVersion }>;\nexport function createTransaction<TVersion extends TransactionVersion>({\n version,\n}: TransactionConfig<TVersion>): Transaction {\n const out: Transaction = {\n instructions: [],\n version,\n };\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\nimport { AccountRole, IInstruction, IInstructionWithAccounts, IInstructionWithData } from '@solana/instructions';\nimport { ReadonlyAccount, ReadonlySignerAccount, WritableAccount } from '@solana/instructions/dist/types/accounts';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\ntype AdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string\n> = IInstruction<'11111111111111111111111111111111'> &\n IInstructionWithAccounts<\n readonly [\n WritableAccount<TNonceAccountAddress>,\n ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,\n ReadonlySignerAccount<TNonceAuthorityAddress>\n ]\n > &\n IInstructionWithData<AdvanceNonceAccountInstructionData>;\ntype AdvanceNonceAccountInstructionData = Uint8Array & {\n readonly __brand: unique symbol;\n};\ntype DurableNonceConfig<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n> = Readonly<{\n readonly nonce: Nonce<TNonceValue>;\n readonly nonceAccountAddress: Base58EncodedAddress<TNonceAccountAddress>;\n readonly nonceAuthorityAddress: Base58EncodedAddress<TNonceAuthorityAddress>;\n}>;\nexport type Nonce<TNonceValue extends string = string> = TNonceValue & { readonly __brand: unique symbol };\ntype NonceLifetimeConstraint<TNonceValue extends string = string> = Readonly<{\n nonce: Nonce<TNonceValue>;\n}>;\n\nconst RECENT_BLOCKHASHES_SYSVAR_ADDRESS =\n 'SysvarRecentB1ockHashes11111111111111111111' as Base58EncodedAddress<'SysvarRecentB1ockHashes11111111111111111111'>;\nconst SYSTEM_PROGRAM_ADDRESS =\n '11111111111111111111111111111111' as Base58EncodedAddress<'11111111111111111111111111111111'>;\n\nexport interface IDurableNonceTransaction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n> {\n readonly instructions: readonly [\n // The first instruction *must* be the system program's `AdvanceNonceAccount` instruction.\n AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,\n ...IInstruction[]\n ];\n readonly lifetimeConstraint: NonceLifetimeConstraint<TNonceValue>;\n}\n\nexport function assertIsDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)\n): asserts transaction is BaseTransaction & IDurableNonceTransaction {\n if (!isDurableNonceTransaction(transaction)) {\n // TODO: Coded error.\n throw new Error('Transaction is not a durable nonce transaction');\n }\n}\n\nfunction createAdvanceNonceAccountInstruction<\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string\n>(\n nonceAccountAddress: Base58EncodedAddress<TNonceAccountAddress>,\n nonceAuthorityAddress: Base58EncodedAddress<TNonceAuthorityAddress>\n): AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress> {\n return {\n accounts: [\n { address: nonceAccountAddress, role: AccountRole.WRITABLE },\n {\n address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,\n role: AccountRole.READONLY,\n },\n { address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER },\n ],\n data: new Uint8Array([4, 0, 0, 0]) as AdvanceNonceAccountInstructionData,\n programAddress: SYSTEM_PROGRAM_ADDRESS,\n };\n}\n\nexport function isAdvanceNonceAccountInstruction(\n instruction: IInstruction\n): instruction is AdvanceNonceAccountInstruction {\n return (\n instruction.programAddress === SYSTEM_PROGRAM_ADDRESS &&\n // Test for `AdvanceNonceAccount` instruction data\n instruction.data != null &&\n isAdvanceNonceAccountInstructionData(instruction.data) &&\n // Test for exactly 3 accounts\n instruction.accounts?.length === 3 &&\n // First account is nonce account address\n instruction.accounts[0].address != null &&\n instruction.accounts[0].role === AccountRole.WRITABLE &&\n // Second account is recent blockhashes sysvar\n instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS &&\n instruction.accounts[1].role === AccountRole.READONLY &&\n // Third account is nonce authority account\n instruction.accounts[2].address != null &&\n instruction.accounts[2].role === AccountRole.READONLY_SIGNER\n );\n}\n\nfunction isAdvanceNonceAccountInstructionData(data: Uint8Array): data is AdvanceNonceAccountInstructionData {\n // AdvanceNonceAccount is the fifth instruction in the System Program (index 4)\n return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;\n}\n\nfunction isDurableNonceTransaction(\n transaction: BaseTransaction | (BaseTransaction & IDurableNonceTransaction)\n): transaction is BaseTransaction & IDurableNonceTransaction {\n return (\n 'lifetimeConstraint' in transaction &&\n typeof transaction.lifetimeConstraint.nonce === 'string' &&\n transaction.instructions[0] != null &&\n isAdvanceNonceAccountInstruction(transaction.instructions[0])\n );\n}\n\nexport function setTransactionLifetimeUsingDurableNonce<\n TTransaction extends BaseTransaction,\n TNonceAccountAddress extends string = string,\n TNonceAuthorityAddress extends string = string,\n TNonceValue extends string = string\n>(\n {\n nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n }: DurableNonceConfig<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>,\n transaction: TTransaction | (TTransaction & IDurableNonceTransaction)\n): Omit<TTransaction, keyof ITransactionWithSignatures> &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue> {\n const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);\n if (\n isAlreadyDurableNonceTransaction &&\n transaction.lifetimeConstraint.nonce === nonce &&\n transaction.instructions[0].accounts[0].address === nonceAccountAddress &&\n transaction.instructions[0].accounts[2].address === nonceAuthorityAddress\n ) {\n return transaction as TTransaction &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...(isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions),\n ],\n lifetimeConstraint: {\n nonce,\n },\n } as TTransaction & IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress } from '@solana/addresses';\n\nimport { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport interface ITransactionWithFeePayer<TAddress extends string = string> {\n readonly feePayer: Base58EncodedAddress<TAddress>;\n}\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction:\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<string> & ITransactionWithSignatures)\n): Omit<TTransaction, keyof ITransactionWithSignatures> & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction: TTransaction | (TTransaction & ITransactionWithFeePayer<string>)\n): TTransaction & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Base58EncodedAddress<TFeePayerAddress>,\n transaction:\n | TTransaction\n | (TTransaction & ITransactionWithFeePayer<string>)\n | (TTransaction & ITransactionWithSignatures)\n | (TTransaction & ITransactionWithFeePayer<string> & ITransactionWithSignatures)\n) {\n if ('feePayer' in transaction && feePayer === transaction.feePayer) {\n return transaction;\n }\n const out = {\n ...getUnsignedTransaction(transaction),\n feePayer,\n };\n Object.freeze(out);\n return out;\n}\n","import { ITransactionWithSignatures } from './signatures';\nimport { BaseTransaction } from './types';\nimport { getUnsignedTransaction } from './unsigned-transaction';\n\nexport function appendTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [...transaction.instructions, instruction],\n };\n Object.freeze(out);\n return out;\n}\n\nexport function prependTransactionInstruction<TTransaction extends BaseTransaction>(\n instruction: TTransaction['instructions'][number],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures)\n): TTransaction | Omit<TTransaction, keyof ITransactionWithSignatures> {\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: [instruction, ...transaction.instructions],\n };\n Object.freeze(out);\n return out;\n}\n","import { Base58EncodedAddress, getAddressComparator } from '@solana/addresses';\nimport {\n AccountRole,\n IAccountLookupMeta,\n IAccountMeta,\n IInstruction,\n isSignerRole,\n isWritableRole,\n mergeRoles,\n ReadonlyAccount,\n ReadonlyAccountLookup,\n ReadonlySignerAccount,\n WritableAccount,\n WritableAccountLookup,\n WritableSignerAccount,\n} from '@solana/instructions';\n\nexport const enum AddressMapEntryType {\n FEE_PAYER,\n LOOKUP_TABLE,\n STATIC,\n}\n\ntype AddressMap = {\n [address: string]: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry;\n};\ntype FeePayerAccountEntry = Omit<WritableSignerAccount, 'address'> & {\n [TYPE]: AddressMapEntryType.FEE_PAYER;\n};\ntype LookupTableAccountEntry = Omit<ReadonlyAccountLookup | WritableAccountLookup, 'address'> & {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE;\n};\nexport type OrderedAccounts = (IAccountMeta | IAccountLookupMeta)[] & { readonly __brand: unique symbol };\ntype StaticAccountEntry = Omit<\n ReadonlyAccount | ReadonlySignerAccount | WritableAccount | WritableSignerAccount,\n 'address'\n> & { [TYPE]: AddressMapEntryType.STATIC };\n\nfunction upsert(\n addressMap: AddressMap,\n address: Base58EncodedAddress,\n update: (\n entry: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry | Record<never, never>\n ) => AddressMap[Base58EncodedAddress]\n) {\n addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });\n}\n\nconst TYPE = Symbol('AddressMapTypeProperty');\nexport const ADDRESS_MAP_TYPE_PROPERTY: typeof TYPE = TYPE;\n\nexport function getAddressMapFromInstructions(\n feePayer: Base58EncodedAddress,\n instructions: readonly IInstruction[]\n): AddressMap {\n const addressMap: AddressMap = {\n [feePayer]: { [TYPE]: AddressMapEntryType.FEE_PAYER, role: AccountRole.WRITABLE_SIGNER },\n };\n const addressesOfInvokedPrograms = new Set<Base58EncodedAddress>();\n for (const instruction of instructions) {\n upsert(addressMap, instruction.programAddress, entry => {\n addressesOfInvokedPrograms.add(instruction.programAddress);\n if (TYPE in entry) {\n if (isWritableRole(entry.role)) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and set as the fee payer. Program addresses may not pay fees.'\n );\n default:\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${instruction.programAddress}\\`) which is both invoked ` +\n 'and marked writable. Program addresses may not be writable.'\n );\n }\n }\n if (entry[TYPE] === AddressMapEntryType.STATIC) {\n return entry;\n }\n }\n return { [TYPE]: AddressMapEntryType.STATIC, role: AccountRole.READONLY };\n });\n let addressComparator: ReturnType<typeof getAddressComparator>;\n if (!instruction.accounts) {\n continue;\n }\n for (const account of instruction.accounts) {\n upsert(addressMap, account.address, entry => {\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n address: _,\n ...accountMeta\n } = account;\n if (TYPE in entry) {\n switch (entry[TYPE]) {\n case AddressMapEntryType.FEE_PAYER:\n // The fee payer already has the highest rank -- it is by definition\n // writable-signer. Return it, no matter how `account` is configured\n return entry as FeePayerAccountEntry;\n case AddressMapEntryType.LOOKUP_TABLE: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if ('lookupTableAddress' in accountMeta) {\n const shouldReplaceEntry =\n // Consider using the new LOOKUP_TABLE if its address is different...\n entry.lookupTableAddress !== accountMeta.lookupTableAddress &&\n // ...and sorts before the existing one.\n (addressComparator ||= getAddressComparator())(\n accountMeta.lookupTableAddress,\n entry.lookupTableAddress\n ) < 0;\n if (shouldReplaceEntry) {\n return {\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n ...accountMeta,\n role: nextRole,\n } as LookupTableAccountEntry;\n }\n } else if (isSignerRole(accountMeta.role)) {\n // Upgrade this LOOKUP_TABLE entry to a static entry if it must sign.\n return {\n [TYPE]: AddressMapEntryType.STATIC,\n role: nextRole,\n } as StaticAccountEntry;\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n return entry as LookupTableAccountEntry;\n }\n }\n case AddressMapEntryType.STATIC: {\n const nextRole = mergeRoles(entry.role, accountMeta.role);\n if (\n // Check to see if this address represents a program that is invoked\n // in this transaction.\n addressesOfInvokedPrograms.has(account.address)\n ) {\n if (isWritableRole(accountMeta.role)) {\n // TODO: Coded error.\n throw new Error(\n 'This transaction includes an address ' +\n `(\\`${account.address}\\`) which is both invoked and ` +\n 'marked writable. Program addresses may not be ' +\n 'writable.'\n );\n }\n if (entry.role !== nextRole) {\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n } else if (\n 'lookupTableAddress' in accountMeta &&\n // Static accounts can be 'upgraded' to lookup table accounts as\n // long as they are not require to sign the transaction.\n !isSignerRole(entry.role)\n ) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n role: nextRole,\n } as LookupTableAccountEntry;\n } else {\n if (entry.role !== nextRole) {\n // The account's role ranks higher than the current entry's.\n return {\n ...entry,\n role: nextRole,\n } as StaticAccountEntry;\n } else {\n return entry as StaticAccountEntry;\n }\n }\n }\n }\n }\n if ('lookupTableAddress' in accountMeta) {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.LOOKUP_TABLE,\n };\n } else {\n return {\n ...accountMeta,\n [TYPE]: AddressMapEntryType.STATIC,\n };\n }\n });\n }\n }\n return addressMap;\n}\n\nexport function getOrderedAccountsFromAddressMap(addressMap: AddressMap): OrderedAccounts {\n let addressComparator: ReturnType<typeof getAddressComparator>;\n const orderedAccounts: (IAccountMeta | IAccountLookupMeta)[] = Object.entries(addressMap)\n .sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {\n // STEP 1: Rapid precedence check. Fee payer, then static addresses, then lookups.\n if (leftEntry[TYPE] !== rightEntry[TYPE]) {\n if (leftEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.FEE_PAYER) {\n return 1;\n } else if (leftEntry[TYPE] === AddressMapEntryType.STATIC) {\n return -1;\n } else if (rightEntry[TYPE] === AddressMapEntryType.STATIC) {\n return 1;\n }\n }\n // STEP 2: Sort by signer-writability.\n const leftIsSigner = isSignerRole(leftEntry.role);\n if (leftIsSigner !== isSignerRole(rightEntry.role)) {\n return leftIsSigner ? -1 : 1;\n }\n const leftIsWritable = isWritableRole(leftEntry.role);\n if (leftIsWritable !== isWritableRole(rightEntry.role)) {\n return leftIsWritable ? -1 : 1;\n }\n // STEP 3: Sort by address.\n addressComparator ||= getAddressComparator();\n if (\n leftEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n rightEntry[TYPE] === AddressMapEntryType.LOOKUP_TABLE &&\n leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress\n ) {\n return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);\n } else {\n return addressComparator(leftAddress, rightAddress);\n }\n })\n .map(([address, addressMeta]) => ({\n address: address as Base58EncodedAddress<typeof address>,\n ...addressMeta,\n }));\n return orderedAccounts as unknown as OrderedAccounts;\n}\n","import { assertIsAddress, type Base58EncodedAddress } from '@solana/addresses';\nimport { pipe } from '@solana/functional';\nimport type { IAccountMeta, IInstruction } from '@solana/instructions';\nimport { AccountRole } from '@solana/instructions';\nimport type { Ed25519Signature } from '@solana/keys';\nimport {\n appendTransactionInstruction,\n type Blockhash,\n createTransaction,\n type IDurableNonceTransaction,\n isAdvanceNonceAccountInstruction,\n type ITransactionWithBlockhashLifetime,\n type ITransactionWithFeePayer,\n type ITransactionWithSignatures,\n type Nonce,\n setTransactionFeePayer,\n setTransactionLifetimeUsingBlockhash,\n setTransactionLifetimeUsingDurableNonce,\n type Transaction,\n} from '@solana/transactions';\nimport type {\n MessageAccountKeys,\n MessageCompiledInstruction,\n PublicKey,\n VersionedMessage,\n VersionedTransaction,\n} from '@solana/web3.js';\n\nfunction convertAccount(\n message: VersionedMessage,\n accountKeys: MessageAccountKeys,\n accountIndex: number\n): IAccountMeta {\n const accountPublicKey = accountKeys.get(accountIndex);\n if (!accountPublicKey) {\n // TODO coded error\n throw new Error(`Could not find account address at index ${accountIndex}`);\n }\n const isSigner = message.isAccountSigner(accountIndex);\n const isWritable = message.isAccountWritable(accountIndex);\n\n const role = isSigner\n ? isWritable\n ? AccountRole.WRITABLE_SIGNER\n : AccountRole.READONLY_SIGNER\n : isWritable\n ? AccountRole.WRITABLE\n : AccountRole.READONLY;\n\n return {\n address: accountPublicKey.toBase58() as Base58EncodedAddress,\n role,\n };\n}\n\nfunction convertInstruction(\n message: VersionedMessage,\n accountKeys: MessageAccountKeys,\n instruction: MessageCompiledInstruction\n): IInstruction {\n const programAddressPublicKey = accountKeys.get(instruction.programIdIndex);\n if (!programAddressPublicKey) {\n // TODO coded error\n throw new Error(`Could not find program address at index ${instruction.programIdIndex}`);\n }\n\n const accounts = instruction.accountKeyIndexes.map(accountIndex =>\n convertAccount(message, accountKeys, accountIndex)\n );\n\n return {\n programAddress: programAddressPublicKey.toBase58() as Base58EncodedAddress,\n ...(accounts.length ? { accounts } : {}),\n ...(instruction.data.length ? { data: instruction.data } : {}),\n };\n}\n\nfunction convertSignatures(\n transaction: VersionedTransaction,\n staticAccountKeys: PublicKey[]\n): ITransactionWithSignatures['signatures'] {\n return transaction.signatures.reduce((acc, sig, index) => {\n // legacy web3js includes a fake all 0 signature if it hasn't been signed\n // we don't do that for the new tx model. So just skip if it's all 0s\n const allZeros = sig.every(byte => byte === 0);\n if (allZeros) return acc;\n\n const address = staticAccountKeys[index].toBase58() as Base58EncodedAddress;\n return { ...acc, [address]: sig as Ed25519Signature };\n }, {});\n}\n\nexport function fromVersionedTransactionWithBlockhash(\n transaction: VersionedTransaction,\n lastValidBlockHeight?: bigint\n): Transaction & ITransactionWithFeePayer & ITransactionWithBlockhashLifetime {\n // TODO: add support for address table lookups\n // - will need to take `AddressLookupTableAccounts[]` as input\n // - will need to convert account instructions to `IAccountLookupMeta` when appropriate\n if (transaction.message.addressTableLookups.length > 0) {\n // TODO coded error\n throw new Error('Cannot convert transaction with addressTableLookups');\n }\n\n const accountKeys = transaction.message.getAccountKeys();\n\n // Fee payer is first account\n const feePayer = accountKeys.staticAccountKeys[0];\n // TODO: coded error\n if (!feePayer) throw new Error('No fee payer set in VersionedTransaction');\n\n // TOOD: add support for durable nonce transactions\n const blockhashLifetime = {\n blockhash: transaction.message.recentBlockhash as Blockhash,\n lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n, // U64 MAX\n };\n\n const instructions = transaction.message.compiledInstructions.map(instruction =>\n convertInstruction(transaction.message, accountKeys, instruction)\n );\n\n const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);\n\n return pipe(\n createTransaction({ version: transaction.version }),\n tx => setTransactionFeePayer(feePayer.toBase58() as Base58EncodedAddress, tx),\n tx => setTransactionLifetimeUsingBlockhash(blockhashLifetime, tx),\n tx =>\n instructions.reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n tx => (transaction.signatures.length ? { ...tx, signatures } : tx)\n );\n}\n\nexport function fromVersionedTransactionWithDurableNonce(\n transaction: VersionedTransaction\n): Transaction & ITransactionWithFeePayer & IDurableNonceTransaction {\n // TODO: add support for address table lookups\n // - will need to take `AddressLookupTableAccounts[]` as input\n // - will need to convert account instructions to `IAccountLookupMeta` when appropriate\n if (transaction.message.addressTableLookups.length > 0) {\n // TODO coded error\n throw new Error('Cannot convert transaction with addressTableLookups');\n }\n\n const accountKeys = transaction.message.getAccountKeys();\n\n // Fee payer is first account\n const feePayer = accountKeys.staticAccountKeys[0];\n // TODO: coded error\n if (!feePayer) throw new Error('No fee payer set in VersionedTransaction');\n\n const instructions = transaction.message.compiledInstructions.map(instruction =>\n convertInstruction(transaction.message, accountKeys, instruction)\n );\n\n // Check first instruction is durable nonce + extract params\n if (instructions.length === 0) {\n // TODO: coded error\n throw new Error('transaction with no instructions cannot be durable nonce transaction');\n }\n\n if (!isAdvanceNonceAccountInstruction(instructions[0])) {\n // TODO: coded error\n throw new Error('transaction first instruction is not advance nonce account instruction');\n }\n\n // We know these accounts are defined because we checked `isAdvanceNonceAccountInstruction`\n const nonceAccountAddress = instructions[0].accounts![0].address;\n assertIsAddress(nonceAccountAddress);\n\n const nonceAuthorityAddress = instructions[0].accounts![2].address;\n assertIsAddress(nonceAuthorityAddress);\n\n const durableNonceLifetime = {\n nonce: transaction.message.recentBlockhash as Nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n };\n\n const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);\n\n return pipe(\n createTransaction({ version: transaction.version }),\n tx => setTransactionFeePayer(feePayer.toBase58() as Base58EncodedAddress, tx),\n tx => setTransactionLifetimeUsingDurableNonce(durableNonceLifetime, tx),\n tx =>\n instructions.slice(1).reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n tx => (transaction.signatures.length ? { ...tx, signatures } : tx)\n );\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
this.globalThis = this.globalThis || {};
|
|
2
|
-
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
function k(e,r,n=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${n}].`)}var C=e=>{let r=e.length,n=BigInt(r);return {description:`base${r}`,encode(t){if(k(e,t),t==="")return new Uint8Array;let s=[...t],o=s.findIndex(g=>g!==e[0]);o=o===-1?s.length:o;let a=Array(o).fill(0);if(o===s.length)return Uint8Array.from(a);let i=s.slice(o),c=0n,u=1n;for(let g=i.length-1;g>=0;g-=1)c+=u*BigInt(e.indexOf(i[g])),u*=n;let p=[];for(;c>0n;)p.unshift(Number(c%256n)),c/=256n;return Uint8Array.from(a.concat(p))},fixedSize:null,maxSize:null}};var L="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",S=()=>C(L);var m;function R(){return m||(m=S()),m}function b(e){try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let t=R().encode(e).byteLength;if(t!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${t}`)}catch(r){throw new Error(`\`${e}\` is not a base-58 encoded address`,{cause:r})}}function A(e,...r){return r.reduce((n,t)=>t(n),e)}var l=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(l||{});function h(e){if("signatures"in e){let{signatures:r,...n}=e;return n}else return e}function T(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let n={...h(r),lifetimeConstraint:e};return Object.freeze(n),n}function y({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var d=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(d||{});var x="SysvarRecentB1ockHashes11111111111111111111",v="11111111111111111111111111111111";function N(e,r){return {accounts:[{address:e,role:d.WRITABLE},{address:x,role:d.READONLY},{address:r,role:d.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:v}}function E(e){return e.programAddress===v&&e.data!=null&&_(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===d.WRITABLE&&e.accounts[1].address===x&&e.accounts[1].role===d.READONLY&&e.accounts[2].address!=null&&e.accounts[2].role===d.READONLY_SIGNER}function _(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function U(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&E(e.instructions[0])}function B({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n},t){let s=U(t);if(s&&t.lifetimeConstraint.nonce===e&&t.instructions[0].accounts[0].address===r&&t.instructions[0].accounts[2].address===n)return t;let o={...h(t),instructions:[N(r,n),...s?t.instructions.slice(1):t.instructions],lifetimeConstraint:{nonce:e}};return Object.freeze(o),o}function w(e,r){if("feePayer"in r&&e===r.feePayer)return r;let n={...h(r),feePayer:e};return Object.freeze(n),n}function I(e,r){let n={...h(r),instructions:[...r.instructions,e]};return Object.freeze(n),n}function O(e,r,n){let t=r.get(n);if(!t)throw new Error(`Could not find account address at index ${n}`);let s=e.isAccountSigner(n),o=e.isAccountWritable(n),a=s?o?l.WRITABLE_SIGNER:l.READONLY_SIGNER:o?l.WRITABLE:l.READONLY;return {address:t.toBase58(),role:a}}function z(e,r,n){let t=r.get(n.programIdIndex);if(!t)throw new Error(`Could not find program address at index ${n.programIdIndex}`);let s=n.accountKeyIndexes.map(o=>O(e,r,o));return {programAddress:t.toBase58(),...s.length?{accounts:s}:{},...n.data.length?{data:n.data}:{}}}function D(e,r){return e.signatures.reduce((n,t,s)=>{if(t.every(i=>i===0))return n;let a=r[s].toBase58();return {...n,[a]:t}},{})}function ie(e,r){if(e.message.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let n=e.message.getAccountKeys(),t=n.staticAccountKeys[0];if(!t)throw new Error("No fee payer set in VersionedTransaction");let s={blockhash:e.message.recentBlockhash,lastValidBlockHeight:r??2n**64n-1n},o=e.message.compiledInstructions.map(i=>z(e.message,n,i)),a=D(e,n.staticAccountKeys);return A(y({version:e.version}),i=>w(t.toBase58(),i),i=>T(s,i),i=>o.reduce((c,u)=>I(u,c),i),i=>e.signatures.length?{...i,signatures:a}:i)}function ce(e){if(e.message.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let r=e.message.getAccountKeys(),n=r.staticAccountKeys[0];if(!n)throw new Error("No fee payer set in VersionedTransaction");let t=e.message.compiledInstructions.map(c=>z(e.message,r,c));if(t.length===0)throw new Error("transaction with no instructions cannot be durable nonce transaction");if(!E(t[0]))throw new Error("transaction first instruction is not advance nonce account instruction");let s=t[0].accounts[0].address;b(s);let o=t[0].accounts[2].address;b(o);let a={nonce:e.message.recentBlockhash,nonceAccountAddress:s,nonceAuthorityAddress:o},i=D(e,r.staticAccountKeys);return A(y({version:e.version}),c=>w(n.toBase58(),c),c=>B(a,c),c=>t.slice(1).reduce((u,p)=>I(p,u),c),c=>e.signatures.length?{...c,signatures:i}:c)}
|
|
6
|
-
|
|
7
|
-
exports.fromVersionedTransactionWithBlockhash = ie;
|
|
8
|
-
exports.fromVersionedTransactionWithDurableNonce = ce;
|
|
9
|
-
|
|
10
|
-
return exports;
|
|
11
|
-
|
|
12
|
-
})({});
|