@solana/compat 2.0.0-experimental.72efece → 2.0.0-experimental.745437f
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 +146 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +145 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +294 -7
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +145 -5
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +146 -1
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +145 -3
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +5 -2
- package/dist/types/address.d.ts +9 -0
- package/dist/types/address.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keypair.d.ts +8 -0
- package/dist/types/keypair.d.ts.map +1 -0
- package/dist/types/transaction.d.ts +2 -1
- package/dist/types/transaction.d.ts.map +1 -0
- package/package.json +16 -15
package/dist/index.node.js
CHANGED
|
@@ -1,8 +1,113 @@
|
|
|
1
|
+
import { createPrivateKeyFromBytes } from '@solana/keys';
|
|
1
2
|
import { pipe } from '@solana/functional';
|
|
2
3
|
import { AccountRole } from '@solana/instructions';
|
|
3
|
-
import { createTransaction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, appendTransactionInstruction } from '@solana/transactions';
|
|
4
|
+
import { createTransaction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, appendTransactionInstruction, isAdvanceNonceAccountInstruction, setTransactionLifetimeUsingDurableNonce } from '@solana/transactions';
|
|
4
5
|
|
|
5
|
-
// src/
|
|
6
|
+
// src/address.ts
|
|
7
|
+
function fromLegacyPublicKey(publicKey) {
|
|
8
|
+
return publicKey.toBase58();
|
|
9
|
+
}
|
|
10
|
+
async function fromLegacyKeypair(keypair, extractable) {
|
|
11
|
+
const [publicKey, privateKey] = await Promise.all([
|
|
12
|
+
crypto.subtle.importKey("raw", keypair.publicKey.toBytes(), "Ed25519", true, ["verify"]),
|
|
13
|
+
createPrivateKeyFromBytes(keypair.secretKey.slice(0, 32), extractable)
|
|
14
|
+
]);
|
|
15
|
+
return {
|
|
16
|
+
privateKey,
|
|
17
|
+
publicKey
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ../codecs-core/dist/index.node.js
|
|
22
|
+
function getEncodedSize(value, encoder) {
|
|
23
|
+
return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
|
|
24
|
+
}
|
|
25
|
+
function createEncoder(encoder) {
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
...encoder,
|
|
28
|
+
encode: (value) => {
|
|
29
|
+
const bytes = new Uint8Array(getEncodedSize(value, encoder));
|
|
30
|
+
encoder.write(value, bytes, 0);
|
|
31
|
+
return bytes;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ../codecs-strings/dist/index.node.js
|
|
37
|
+
function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
|
|
38
|
+
if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
|
|
39
|
+
throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var getBaseXEncoder = (alphabet4) => {
|
|
43
|
+
return createEncoder({
|
|
44
|
+
getSizeFromValue: (value) => {
|
|
45
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
46
|
+
if (tailChars === "")
|
|
47
|
+
return value.length;
|
|
48
|
+
const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
49
|
+
return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
|
|
50
|
+
},
|
|
51
|
+
write(value, bytes, offset) {
|
|
52
|
+
assertValidBaseString(alphabet4, value);
|
|
53
|
+
if (value === "")
|
|
54
|
+
return offset;
|
|
55
|
+
const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
|
|
56
|
+
if (tailChars === "") {
|
|
57
|
+
bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
|
|
58
|
+
return offset + leadingZeroes.length;
|
|
59
|
+
}
|
|
60
|
+
let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
|
|
61
|
+
const tailBytes = [];
|
|
62
|
+
while (base10Number > 0n) {
|
|
63
|
+
tailBytes.unshift(Number(base10Number % 256n));
|
|
64
|
+
base10Number /= 256n;
|
|
65
|
+
}
|
|
66
|
+
const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
|
|
67
|
+
bytes.set(bytesToAdd, offset);
|
|
68
|
+
return offset + bytesToAdd.length;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
function partitionLeadingZeroes(value, zeroCharacter) {
|
|
73
|
+
const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
|
|
74
|
+
return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
|
|
75
|
+
}
|
|
76
|
+
function getBigIntFromBaseX(value, alphabet4) {
|
|
77
|
+
const base = BigInt(alphabet4.length);
|
|
78
|
+
return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
|
|
79
|
+
}
|
|
80
|
+
var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
81
|
+
var getBase58Encoder = () => getBaseXEncoder(alphabet2);
|
|
82
|
+
|
|
83
|
+
// ../addresses/dist/index.node.js
|
|
84
|
+
var memoizedBase58Encoder;
|
|
85
|
+
function getMemoizedBase58Encoder() {
|
|
86
|
+
if (!memoizedBase58Encoder)
|
|
87
|
+
memoizedBase58Encoder = getBase58Encoder();
|
|
88
|
+
return memoizedBase58Encoder;
|
|
89
|
+
}
|
|
90
|
+
function assertIsAddress(putativeAddress) {
|
|
91
|
+
try {
|
|
92
|
+
if (
|
|
93
|
+
// Lowest address (32 bytes of zeroes)
|
|
94
|
+
putativeAddress.length < 32 || // Highest address (32 bytes of 255)
|
|
95
|
+
putativeAddress.length > 44
|
|
96
|
+
) {
|
|
97
|
+
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
98
|
+
}
|
|
99
|
+
const base58Encoder = getMemoizedBase58Encoder();
|
|
100
|
+
const bytes = base58Encoder.encode(putativeAddress);
|
|
101
|
+
const numBytes = bytes.byteLength;
|
|
102
|
+
if (numBytes !== 32) {
|
|
103
|
+
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
104
|
+
}
|
|
105
|
+
} catch (e2) {
|
|
106
|
+
throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
|
|
107
|
+
cause: e2
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
6
111
|
function convertAccount(message, accountKeys, accountIndex) {
|
|
7
112
|
const accountPublicKey = accountKeys.get(accountIndex);
|
|
8
113
|
if (!accountPublicKey) {
|
|
@@ -66,7 +171,44 @@ function fromVersionedTransactionWithBlockhash(transaction, lastValidBlockHeight
|
|
|
66
171
|
(tx) => transaction.signatures.length ? { ...tx, signatures } : tx
|
|
67
172
|
);
|
|
68
173
|
}
|
|
174
|
+
function fromVersionedTransactionWithDurableNonce(transaction) {
|
|
175
|
+
if (transaction.message.addressTableLookups.length > 0) {
|
|
176
|
+
throw new Error("Cannot convert transaction with addressTableLookups");
|
|
177
|
+
}
|
|
178
|
+
const accountKeys = transaction.message.getAccountKeys();
|
|
179
|
+
const feePayer = accountKeys.staticAccountKeys[0];
|
|
180
|
+
if (!feePayer)
|
|
181
|
+
throw new Error("No fee payer set in VersionedTransaction");
|
|
182
|
+
const instructions = transaction.message.compiledInstructions.map(
|
|
183
|
+
(instruction) => convertInstruction(transaction.message, accountKeys, instruction)
|
|
184
|
+
);
|
|
185
|
+
if (instructions.length === 0) {
|
|
186
|
+
throw new Error("transaction with no instructions cannot be durable nonce transaction");
|
|
187
|
+
}
|
|
188
|
+
if (!isAdvanceNonceAccountInstruction(instructions[0])) {
|
|
189
|
+
throw new Error("transaction first instruction is not advance nonce account instruction");
|
|
190
|
+
}
|
|
191
|
+
const nonceAccountAddress = instructions[0].accounts[0].address;
|
|
192
|
+
assertIsAddress(nonceAccountAddress);
|
|
193
|
+
const nonceAuthorityAddress = instructions[0].accounts[2].address;
|
|
194
|
+
assertIsAddress(nonceAuthorityAddress);
|
|
195
|
+
const durableNonceLifetime = {
|
|
196
|
+
nonce: transaction.message.recentBlockhash,
|
|
197
|
+
nonceAccountAddress,
|
|
198
|
+
nonceAuthorityAddress
|
|
199
|
+
};
|
|
200
|
+
const signatures = convertSignatures(transaction, accountKeys.staticAccountKeys);
|
|
201
|
+
return pipe(
|
|
202
|
+
createTransaction({ version: transaction.version }),
|
|
203
|
+
(tx) => setTransactionFeePayer(feePayer.toBase58(), tx),
|
|
204
|
+
(tx) => setTransactionLifetimeUsingDurableNonce(durableNonceLifetime, tx),
|
|
205
|
+
(tx) => instructions.slice(1).reduce((acc, instruction) => {
|
|
206
|
+
return appendTransactionInstruction(instruction, acc);
|
|
207
|
+
}, tx),
|
|
208
|
+
(tx) => transaction.signatures.length ? { ...tx, signatures } : tx
|
|
209
|
+
);
|
|
210
|
+
}
|
|
69
211
|
|
|
70
|
-
export { fromVersionedTransactionWithBlockhash };
|
|
212
|
+
export { fromLegacyKeypair, fromLegacyPublicKey, fromVersionedTransactionWithBlockhash, fromVersionedTransactionWithDurableNonce };
|
|
71
213
|
//# sourceMappingURL=out.js.map
|
|
72
214
|
//# sourceMappingURL=index.node.js.map
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transaction.ts"],"names":[],"mappings":";AACA,SAAS,YAAY;AAErB,SAAS,mBAAmB;AAS5B;AAAA,EACI;A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AoB,SAAS,GAAG;AAEpD,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACzE;AAEA,QAAM,cAAc,YAAY,QAAQ,eAAe;AAGvD,QAAM,WAAW,YAAY,kBAAkB,CAAC;AAEhD,MAAI,CAAC;AAAU,UAAM,IAAI,MAAM,0CAA0C;AAGzE,QAAM,oBAAoB;AAAA,IACtB,WAAW,YAAY,QAAQ;AAAA,IAC/B,sBAAsB,wBAAwB,MAAM,MAAM;AAAA;AAAA,EAC9D;AAEA,QAAM,eAAe,YAAY,QAAQ,qBAAqB;AAAA,IAAI,iBAC9D,mBAAmB,YAAY,SAAS,aAAa,WAAW;AAAA,EACpE;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,qCAAqC,mBAAmB,EAAE;AAAA,IAChE,QACI,aAAa,OAAO,CAAC,KAAK,gBAAgB;AACtC,aAAO,6BAA6B,aAAa,GAAG;AAAA,IACxD,GAAG,EAAE;AAAA,IACT,QAAO,YAAY,WAAW,SAAS,EAAE,GAAG,IAAI,WAAW,IAAI;AAAA,EACnE;AACJ","sourcesContent":["import 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 type {\n Blockhash,\n ITransactionWithBlockhashLifetime,\n ITransactionWithFeePayer,\n ITransactionWithSignatures,\n Transaction,\n} from '@solana/transactions';\nimport {\n appendTransactionInstruction,\n createTransaction,\n setTransactionFeePayer,\n setTransactionLifetimeUsingBlockhash,\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"]}
|
|
1
|
+
{"version":3,"sources":["../src/address.ts","../src/keypair.ts","../../codecs-core/dist/index.node.js","../../codecs-strings/dist/index.node.js","../../addresses/src/address.ts","../src/transaction.ts"],"names":["e"],"mappings":";AAQO,SAAS,oBAA6C,WAAyC;AAClG,SAAO,UAAU,SAAS;AAC9B;;;ACVA,SAAS,iCAAiC;AAQ1C,eAAsB,kBAAkB,SAAkB,aAA+C;AACrG,QAAM,CAAC,WAAW,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC9C,OAAO,OAAO,UAAU,OAAO,QAAQ,UAAU,QAAQ,GAAG,WAAW,MAAM,CAAC,QAAQ,CAAC;AAAA,IACvF,0BAA0B,QAAQ,UAAU,MAAM,GAAG,EAAE,GAAG,WAAW;AAAA,EACzE,CAAC;AACD,SAAO;AAA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QAAQ,qBAAqB;AAAA,IAAI,iBAC9D,mBAAmB,YAAY,SAAS,aAAa,WAAW;AAAA,EACpE;AAGA,MAAI,aAAa,WAAW,GAAG;AAE3B,UAAM,IAAI,MAAM,sEAAsE;AAAA,EAC1F;AAEA,MAAI,CAAC,iCAAiC,aAAa,CAAC,CAAC,GAAG;AAEpD,UAAM,IAAI,MAAM,wEAAwE;AAAA,EAC5F;AAGA,QAAM,sBAAsB,aAAa,CAAC,EAAE,SAAU,CAAC,EAAE;AACzD,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,GAAc,EAAE;AAAA,IAC/D,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 { Address } from '@solana/addresses';\nimport { PublicKey } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS PublicKey to a base58 encoded address\n * @param publicKey The PublicKey to convert\n * @returns An Address\n */\nexport function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress> {\n return publicKey.toBase58() as Address<TAddress>;\n}\n","import { createPrivateKeyFromBytes } from '@solana/keys';\nimport { Keypair } from '@solana/web3.js';\n\n/**\n * Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair\n * @param keypair The Keypair to convert\n * @returns A CryptoKeyPair\n */\nexport async function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair> {\n const [publicKey, privateKey] = await Promise.all([\n crypto.subtle.importKey('raw', keypair.publicKey.toBytes(), 'Ed25519', true, ['verify']),\n createPrivateKeyFromBytes(keypair.secretKey.slice(0, 32), extractable),\n ]);\n return {\n privateKey,\n publicKey,\n } as CryptoKeyPair;\n}\n","// src/assertions.ts\nfunction assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {\n if (bytes.length - offset <= 0) {\n throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);\n }\n}\nfunction assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {\n const bytesLength = bytes.length - offset;\n if (bytesLength < expected) {\n throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);\n }\n}\n\n// src/bytes.ts\nvar mergeBytes = (byteArrays) => {\n const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);\n if (nonEmptyByteArrays.length === 0) {\n return byteArrays.length ? byteArrays[0] : new Uint8Array();\n }\n if (nonEmptyByteArrays.length === 1) {\n return nonEmptyByteArrays[0];\n }\n const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n nonEmptyByteArrays.forEach((arr) => {\n result.set(arr, offset);\n offset += arr.length;\n });\n return result;\n};\nvar padBytes = (bytes, length) => {\n if (bytes.length >= length)\n return bytes;\n const paddedBytes = new Uint8Array(length).fill(0);\n paddedBytes.set(bytes);\n return paddedBytes;\n};\nvar fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);\n\n// src/codec.ts\nfunction getEncodedSize(value, encoder) {\n return \"fixedSize\" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);\n}\nfunction createEncoder(encoder) {\n return Object.freeze({\n ...encoder,\n encode: (value) => {\n const bytes = new Uint8Array(getEncodedSize(value, encoder));\n encoder.write(value, bytes, 0);\n return bytes;\n }\n });\n}\nfunction createDecoder(decoder) {\n return Object.freeze({\n ...decoder,\n decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]\n });\n}\nfunction createCodec(codec) {\n return Object.freeze({\n ...codec,\n decode: (bytes, offset = 0) => codec.read(bytes, offset)[0],\n encode: (value) => {\n const bytes = new Uint8Array(getEncodedSize(value, codec));\n codec.write(value, bytes, 0);\n return bytes;\n }\n });\n}\nfunction isFixedSize(codec) {\n return \"fixedSize\" in codec && typeof codec.fixedSize === \"number\";\n}\nfunction assertIsFixedSize(codec, message) {\n if (!isFixedSize(codec)) {\n throw new Error(message ?? \"Expected a fixed-size codec, got a variable-size one.\");\n }\n}\nfunction isVariableSize(codec) {\n return !isFixedSize(codec);\n}\nfunction assertIsVariableSize(codec, message) {\n if (!isVariableSize(codec)) {\n throw new Error(message ?? \"Expected a variable-size codec, got a fixed-size one.\");\n }\n}\n\n// src/combine-codec.ts\nfunction combineCodec(encoder, decoder) {\n if (isFixedSize(encoder) !== isFixedSize(decoder)) {\n throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);\n }\n if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {\n throw new Error(\n `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`\n );\n }\n if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {\n throw new Error(\n `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`\n );\n }\n return {\n ...decoder,\n ...encoder,\n decode: decoder.decode,\n encode: encoder.encode,\n read: decoder.read,\n write: encoder.write\n };\n}\n\n// src/fix-codec.ts\nfunction fixEncoder(encoder, fixedBytes) {\n return createEncoder({\n fixedSize: fixedBytes,\n write: (value, bytes, offset) => {\n const variableByteArray = encoder.encode(value);\n const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray;\n bytes.set(fixedByteArray, offset);\n return offset + fixedBytes;\n }\n });\n}\nfunction fixDecoder(decoder, fixedBytes) {\n return createDecoder({\n fixedSize: fixedBytes,\n read: (bytes, offset) => {\n assertByteArrayHasEnoughBytesForCodec(\"fixCodec\", fixedBytes, bytes, offset);\n if (offset > 0 || bytes.length > fixedBytes) {\n bytes = bytes.slice(offset, offset + fixedBytes);\n }\n if (isFixedSize(decoder)) {\n bytes = fixBytes(bytes, decoder.fixedSize);\n }\n const [value] = decoder.read(bytes, 0);\n return [value, offset + fixedBytes];\n }\n });\n}\nfunction fixCodec(codec, fixedBytes) {\n return combineCodec(fixEncoder(codec, fixedBytes), fixDecoder(codec, fixedBytes));\n}\n\n// src/map-codec.ts\nfunction mapEncoder(encoder, unmap) {\n return createEncoder({\n ...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder,\n write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset)\n });\n}\nfunction mapDecoder(decoder, map) {\n return createDecoder({\n ...decoder,\n read: (bytes, offset) => {\n const [value, newOffset] = decoder.read(bytes, offset);\n return [map(value, bytes, offset), newOffset];\n }\n });\n}\nfunction mapCodec(codec, unmap, map) {\n return createCodec({\n ...mapEncoder(codec, unmap),\n read: map ? mapDecoder(codec, map).read : codec.read\n });\n}\n\n// src/reverse-codec.ts\nfunction reverseEncoder(encoder) {\n assertIsFixedSize(encoder, \"Cannot reverse a codec of variable size.\");\n return createEncoder({\n ...encoder,\n write: (value, bytes, offset) => {\n const newOffset = encoder.write(value, bytes, offset);\n const slice = bytes.slice(offset, offset + encoder.fixedSize).reverse();\n bytes.set(slice, offset);\n return newOffset;\n }\n });\n}\nfunction reverseDecoder(decoder) {\n assertIsFixedSize(decoder, \"Cannot reverse a codec of variable size.\");\n return createDecoder({\n ...decoder,\n read: (bytes, offset) => {\n const reverseEnd = offset + decoder.fixedSize;\n if (offset === 0 && bytes.length === reverseEnd) {\n return decoder.read(bytes.reverse(), offset);\n }\n const reversedBytes = bytes.slice();\n reversedBytes.set(bytes.slice(offset, reverseEnd).reverse(), offset);\n return decoder.read(reversedBytes, offset);\n }\n });\n}\nfunction reverseCodec(codec) {\n return combineCodec(reverseEncoder(codec), reverseDecoder(codec));\n}\n\nexport { assertByteArrayHasEnoughBytesForCodec, assertByteArrayIsNotEmptyForCodec, assertIsFixedSize, assertIsVariableSize, combineCodec, createCodec, createDecoder, createEncoder, fixBytes, fixCodec, fixDecoder, fixEncoder, getEncodedSize, isFixedSize, isVariableSize, mapCodec, mapDecoder, mapEncoder, mergeBytes, padBytes, reverseCodec, reverseDecoder, reverseEncoder };\n","import { createEncoder, createDecoder, combineCodec, fixEncoder, getEncodedSize, 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 return createEncoder({\n getSizeFromValue: (value) => {\n const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);\n if (tailChars === \"\")\n return value.length;\n const base10Number = getBigIntFromBaseX(tailChars, alphabet4);\n return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);\n },\n write(value, bytes, offset) {\n assertValidBaseString(alphabet4, value);\n if (value === \"\")\n return offset;\n const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);\n if (tailChars === \"\") {\n bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);\n return offset + leadingZeroes.length;\n }\n let base10Number = getBigIntFromBaseX(tailChars, alphabet4);\n const tailBytes = [];\n while (base10Number > 0n) {\n tailBytes.unshift(Number(base10Number % 256n));\n base10Number /= 256n;\n }\n const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];\n bytes.set(bytesToAdd, offset);\n return offset + bytesToAdd.length;\n }\n });\n};\nvar getBaseXDecoder = (alphabet4) => {\n return createDecoder({\n read(rawBytes, offset) {\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 const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);\n const tailChars = getBaseXFromBigInt(base10Number, alphabet4);\n return [leadingZeroes + tailChars, rawBytes.length];\n }\n });\n};\nvar getBaseXCodec = (alphabet4) => combineCodec(getBaseXEncoder(alphabet4), getBaseXDecoder(alphabet4));\nfunction partitionLeadingZeroes(value, zeroCharacter) {\n const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);\n return leadingZeroIndex === -1 ? [value, \"\"] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];\n}\nfunction getBigIntFromBaseX(value, alphabet4) {\n const base = BigInt(alphabet4.length);\n return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);\n}\nfunction getBaseXFromBigInt(value, alphabet4) {\n const base = BigInt(alphabet4.length);\n const tailChars = [];\n while (value > 0n) {\n tailChars.unshift(alphabet4[Number(value % base)]);\n value /= base;\n }\n return tailChars.join(\"\");\n}\n\n// src/base10.ts\nvar alphabet = \"0123456789\";\nvar getBase10Encoder = () => getBaseXEncoder(alphabet);\nvar getBase10Decoder = () => getBaseXDecoder(alphabet);\nvar getBase10Codec = () => getBaseXCodec(alphabet);\nvar getBase16Encoder = () => createEncoder({\n getSizeFromValue: (value) => Math.ceil(value.length / 2),\n write(value, bytes, offset) {\n const lowercaseValue = value.toLowerCase();\n assertValidBaseString(\"0123456789abcdef\", lowercaseValue, value);\n const matches = lowercaseValue.match(/.{1,2}/g);\n const hexBytes = matches ? matches.map((byte) => parseInt(byte, 16)) : [];\n bytes.set(hexBytes, offset);\n return hexBytes.length + offset;\n }\n});\nvar getBase16Decoder = () => createDecoder({\n read(bytes, offset) {\n const value = bytes.slice(offset).reduce((str, byte) => str + byte.toString(16).padStart(2, \"0\"), \"\");\n return [value, bytes.length];\n }\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) => createEncoder({\n getSizeFromValue: (value) => Math.floor(value.length * bits / 8),\n write(value, bytes, offset) {\n assertValidBaseString(alphabet4, value);\n if (value === \"\")\n return offset;\n const charIndices = [...value].map((c) => alphabet4.indexOf(c));\n const reslicedBytes = reslice(charIndices, bits, 8, false);\n bytes.set(reslicedBytes, offset);\n return reslicedBytes.length + offset;\n }\n});\nvar getBaseXResliceDecoder = (alphabet4, bits) => createDecoder({\n read(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});\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}\n\n// src/base64.ts\nvar alphabet3 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nvar getBase64Encoder = () => {\n {\n return createEncoder({\n getSizeFromValue: (value) => Buffer.from(value, \"base64\").length,\n write(value, bytes, offset) {\n assertValidBaseString(alphabet3, value.replace(/=/g, \"\"));\n const buffer = Buffer.from(value, \"base64\");\n bytes.set(buffer, offset);\n return buffer.length + offset;\n }\n });\n }\n};\nvar getBase64Decoder = () => {\n {\n return createDecoder({\n read: (bytes, offset = 0) => [Buffer.from(bytes, offset).toString(\"base64\"), bytes.length]\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.node.js\nvar e = globalThis.TextDecoder;\nvar o = globalThis.TextEncoder;\n\n// src/utf8.ts\nvar getUtf8Encoder = () => {\n let textEncoder;\n return createEncoder({\n getSizeFromValue: (value) => (textEncoder ||= new o()).encode(value).length,\n write: (value, bytes, offset) => {\n const bytesToAdd = (textEncoder ||= new o()).encode(value);\n bytes.set(bytesToAdd, offset);\n return offset + bytesToAdd.length;\n }\n });\n};\nvar getUtf8Decoder = () => {\n let textDecoder;\n return createDecoder({\n read(bytes, offset) {\n const value = (textDecoder ||= new e()).decode(bytes.slice(offset));\n return [removeNullCharacters(value), bytes.length];\n }\n });\n};\nvar getUtf8Codec = () => combineCodec(getUtf8Encoder(), getUtf8Decoder());\n\n// src/string.ts\nfunction getStringEncoder(config = {}) {\n const size = config.size ?? getU32Encoder();\n const encoding = config.encoding ?? getUtf8Encoder();\n if (size === \"variable\") {\n return encoding;\n }\n if (typeof size === \"number\") {\n return fixEncoder(encoding, size);\n }\n return createEncoder({\n getSizeFromValue: (value) => {\n const contentSize = getEncodedSize(value, encoding);\n return getEncodedSize(contentSize, size) + contentSize;\n },\n write: (value, bytes, offset) => {\n const contentSize = getEncodedSize(value, encoding);\n offset = size.write(contentSize, bytes, offset);\n return encoding.write(value, bytes, offset);\n }\n });\n}\nfunction getStringDecoder(config = {}) {\n const size = config.size ?? getU32Decoder();\n const encoding = config.encoding ?? getUtf8Decoder();\n if (size === \"variable\") {\n return encoding;\n }\n if (typeof size === \"number\") {\n return fixDecoder(encoding, size);\n }\n return createDecoder({\n read: (bytes, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec(\"string\", bytes, offset);\n const [lengthBigInt, lengthOffset] = size.read(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.read(contentBytes, 0);\n offset += contentOffset;\n return [value, offset];\n }\n });\n}\nfunction getStringCodec(config = {}) {\n return combineCodec(getStringEncoder(config), getStringDecoder(config));\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 {\n combineCodec,\n Decoder,\n Encoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n mapEncoder,\n} from '@solana/codecs-core';\nimport { getBase58Decoder, getBase58Encoder, getStringDecoder, getStringEncoder } from '@solana/codecs-strings';\n\nexport type Address<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(putativeAddress: string): putativeAddress is Address<typeof putativeAddress> {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest address (32 bytes of zeroes)\n putativeAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeAddress.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(putativeAddress);\n const numBytes = bytes.byteLength;\n if (numBytes !== 32) {\n return false;\n }\n return true;\n}\n\nexport function assertIsAddress(putativeAddress: string): asserts putativeAddress is Address<typeof putativeAddress> {\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 putativeAddress.length < 32 ||\n // Highest address (32 bytes of 255)\n putativeAddress.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(putativeAddress);\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(`\\`${putativeAddress}\\` is not a base-58 encoded address`, {\n cause: e,\n });\n }\n}\n\nexport function address<TAddress extends string = string>(putativeAddress: TAddress): Address<TAddress> {\n assertIsAddress(putativeAddress);\n return putativeAddress as Address<TAddress>;\n}\n\nexport function getAddressEncoder(): FixedSizeEncoder<Address, 32> {\n return mapEncoder(getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }), putativeAddress =>\n address(putativeAddress),\n );\n}\n\nexport function getAddressDecoder(): FixedSizeDecoder<Address, 32> {\n return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 }) as FixedSizeDecoder<Address, 32>;\n}\n\nexport function getAddressCodec(): FixedSizeCodec<Address, Address, 32> {\n return combineCodec(getAddressEncoder(), getAddressDecoder());\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","import { type Address, assertIsAddress } from '@solana/addresses';\nimport { pipe } from '@solana/functional';\nimport type { IAccountMeta, IInstruction } from '@solana/instructions';\nimport { AccountRole } from '@solana/instructions';\nimport type { SignatureBytes } 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 Address,\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 Address,\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 Address;\n return { ...acc, [address]: sig as SignatureBytes };\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 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 Address, 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 Address, 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"]}
|
|
@@ -2,9 +2,12 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function Y(e){return e.toBase58()}function w(e,r){return "fixedSize"in r?r.fixedSize:r.getSizeFromValue(e)}function S(e){return Object.freeze({...e,encode:r=>{let n=new Uint8Array(w(r,e));return e.write(r,n,0),n}})}function P(e,r,n=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${n}].`)}var K=e=>S({getSizeFromValue:r=>{let[n,t]=I(r,e[0]);if(t==="")return r.length;let o=T(t,e);return n.length+Math.ceil(o.toString(16).length/2)},write(r,n,t){if(P(e,r),r==="")return t;let[o,s]=I(r,e[0]);if(s==="")return n.set(new Uint8Array(o.length).fill(0),t),t+o.length;let a=T(s,e),i=[];for(;a>0n;)i.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...i];return n.set(c,t),t+c.length}});function I(e,r){let n=[...e].findIndex(t=>t!==r);return n===-1?[e,""]:[e.slice(0,n),e.slice(n)]}function T(e,r){let n=BigInt(r.length);return [...e].reduce((t,o)=>t*n+BigInt(r.indexOf(o)),0n)}var M="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",v=()=>K(M);function _(e){return new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32,...e])}async function B(e,r){if(e.byteLength!==32)throw new Error("Private key bytes must be of length 32");let n=_(e);return await crypto.subtle.importKey("pkcs8",n,"Ed25519",r!=null?r:!1,["sign"])}async function le(e,r){let[n,t]=await Promise.all([crypto.subtle.importKey("raw",e.publicKey.toBytes(),"Ed25519",!0,["verify"]),B(e.secretKey.slice(0,32),r)]);return {privateKey:t,publicKey:n}}var h;function O(){return h||(h=v()),h}function p(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=O().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 y(e,...r){return r.reduce((n,t)=>t(n),e)}var u=(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))(u||{});function g(e){if("signatures"in e){let{signatures:r,...n}=e;return n}else return e}function x(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let n={...g(r),lifetimeConstraint:e};return Object.freeze(n),n}function A({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}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 F(e){return e>=2}var C="SysvarRecentB1ockHashes11111111111111111111",D="11111111111111111111111111111111";function z(e,r){return {accounts:[{address:e,role:l.WRITABLE},{address:C,role:l.READONLY},{address:r,role:l.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:D}}function f(e){var r;return e.programAddress===D&&e.data!=null&&W(e.data)&&((r=e.accounts)==null?void 0:r.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===l.WRITABLE&&e.accounts[1].address===C&&e.accounts[1].role===l.READONLY&&e.accounts[2].address!=null&&F(e.accounts[2].role)}function W(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&&f(e.instructions[0])}function $(e,r,n){return e.accounts[0].address===r&&e.accounts[2].address===n}function L({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n},t){let o,s=t.instructions[0];if(s&&f(s))if($(s,r,n)){if(U(t)&&t.lifetimeConstraint.nonce===e)return t;o=[s,...t.instructions.slice(1)];}else o=[z(r,n),...t.instructions.slice(1)];else o=[z(r,n),...t.instructions];let a={...g(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(a),a}function E(e,r){if("feePayer"in r&&e===r.feePayer)return r;let n={...g(r),feePayer:e};return Object.freeze(n),n}function b(e,r){let n={...g(r),instructions:[...r.instructions,e]};return Object.freeze(n),n}function V(e,r,n){let t=r.get(n);if(!t)throw new Error(`Could not find account address at index ${n}`);let o=e.isAccountSigner(n),s=e.isAccountWritable(n),a=o?s?u.WRITABLE_SIGNER:u.READONLY_SIGNER:s?u.WRITABLE:u.READONLY;return {address:t.toBase58(),role:a}}function R(e,r,n){let t=r.get(n.programIdIndex);if(!t)throw new Error(`Could not find program address at index ${n.programIdIndex}`);let o=n.accountKeyIndexes.map(s=>V(e,r,s));return {programAddress:t.toBase58(),...o.length?{accounts:o}:{},...n.data.length?{data:n.data}:{}}}function N(e,r){return e.signatures.reduce((n,t,o)=>{if(t.every(i=>i===0))return n;let a=r[o].toBase58();return {...n,[a]:t}},{})}function Le(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 o={blockhash:e.message.recentBlockhash,lastValidBlockHeight:r!=null?r:2n**64n-1n},s=e.message.compiledInstructions.map(i=>R(e.message,n,i)),a=N(e,n.staticAccountKeys);return y(A({version:e.version}),i=>E(t.toBase58(),i),i=>x(o,i),i=>s.reduce((c,m)=>b(m,c),i),i=>e.signatures.length?{...i,signatures:a}:i)}function Re(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=>R(e.message,r,c));if(t.length===0)throw new Error("transaction with no instructions cannot be durable nonce transaction");if(!f(t[0]))throw new Error("transaction first instruction is not advance nonce account instruction");let o=t[0].accounts[0].address;p(o);let s=t[0].accounts[2].address;p(s);let a={nonce:e.message.recentBlockhash,nonceAccountAddress:o,nonceAuthorityAddress:s},i=N(e,r.staticAccountKeys);return y(A({version:e.version}),c=>E(n.toBase58(),c),c=>L(a,c),c=>t.slice(1).reduce((m,k)=>b(k,m),c),c=>e.signatures.length?{...c,signatures:i}:c)}
|
|
6
6
|
|
|
7
|
-
exports.
|
|
7
|
+
exports.fromLegacyKeypair = le;
|
|
8
|
+
exports.fromLegacyPublicKey = Y;
|
|
9
|
+
exports.fromVersionedTransactionWithBlockhash = Le;
|
|
10
|
+
exports.fromVersionedTransactionWithDurableNonce = Re;
|
|
8
11
|
|
|
9
12
|
return exports;
|
|
10
13
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Address } from '@solana/addresses';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert from a Legacy Web3 JS PublicKey to a base58 encoded address
|
|
5
|
+
* @param publicKey The PublicKey to convert
|
|
6
|
+
* @returns An Address
|
|
7
|
+
*/
|
|
8
|
+
export declare function fromLegacyPublicKey<TAddress extends string>(publicKey: PublicKey): Address<TAddress>;
|
|
9
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpG"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Keypair } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert from a Legacy Web3 JS Keypair to a CryptoKeyPair
|
|
4
|
+
* @param keypair The Keypair to convert
|
|
5
|
+
* @returns A CryptoKeyPair
|
|
6
|
+
*/
|
|
7
|
+
export declare function fromLegacyKeypair(keypair: Keypair, extractable?: boolean): Promise<CryptoKeyPair>;
|
|
8
|
+
//# sourceMappingURL=keypair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keypair.d.ts","sourceRoot":"","sources":["../../src/keypair.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CASvG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IDurableNonceTransaction, type ITransactionWithBlockhashLifetime, type ITransactionWithFeePayer, type Transaction } from '@solana/transactions';
|
|
2
2
|
import type { VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
export declare function fromVersionedTransactionWithBlockhash(transaction: VersionedTransaction, lastValidBlockHeight?: bigint): Transaction & ITransactionWithFeePayer & ITransactionWithBlockhashLifetime;
|
|
4
|
+
export declare function fromVersionedTransactionWithDurableNonce(transaction: VersionedTransaction): Transaction & ITransactionWithFeePayer & IDurableNonceTransaction;
|
|
4
5
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/transaction.ts"],"names":[],"mappings":"AAKA,OAAO,EAIH,KAAK,wBAAwB,EAE7B,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAM7B,KAAK,WAAW,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAKR,oBAAoB,EACvB,MAAM,iBAAiB,CAAC;AAkEzB,wBAAgB,qCAAqC,CACjD,WAAW,EAAE,oBAAoB,EACjC,oBAAoB,CAAC,EAAE,MAAM,GAC9B,WAAW,GAAG,wBAAwB,GAAG,iCAAiC,CAqC5E;AAED,wBAAgB,wCAAwC,CACpD,WAAW,EAAE,oBAAoB,GAClC,WAAW,GAAG,wBAAwB,GAAG,wBAAwB,CAwDnE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/compat",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.745437f",
|
|
4
4
|
"description": "Helpers for converting from legacy web3js classes",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -49,34 +49,35 @@
|
|
|
49
49
|
"node": ">=17.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@solana/functional": "2.0.0-experimental.
|
|
53
|
-
"@solana/
|
|
54
|
-
"@solana/
|
|
52
|
+
"@solana/functional": "2.0.0-experimental.745437f",
|
|
53
|
+
"@solana/keys": "2.0.0-experimental.745437f",
|
|
54
|
+
"@solana/instructions": "2.0.0-experimental.745437f",
|
|
55
|
+
"@solana/transactions": "2.0.0-experimental.745437f"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@solana/eslint-config-solana": "^1.0.2",
|
|
58
|
-
"@swc/jest": "^0.2.
|
|
59
|
-
"@types/jest": "^29.5.
|
|
59
|
+
"@swc/jest": "^0.2.29",
|
|
60
|
+
"@types/jest": "^29.5.6",
|
|
60
61
|
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
61
62
|
"@typescript-eslint/parser": "^6.3.0",
|
|
62
63
|
"agadoo": "^3.0.0",
|
|
63
64
|
"eslint": "^8.45.0",
|
|
64
|
-
"eslint-plugin-jest": "^27.2
|
|
65
|
+
"eslint-plugin-jest": "^27.4.2",
|
|
65
66
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
66
67
|
"jest": "^29.7.0",
|
|
67
|
-
"jest-environment-jsdom": "^29.
|
|
68
|
-
"jest-runner-eslint": "^2.1.
|
|
68
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
69
|
+
"jest-runner-eslint": "^2.1.2",
|
|
69
70
|
"jest-runner-prettier": "^1.0.0",
|
|
70
|
-
"prettier": "^
|
|
71
|
-
"tsup": "
|
|
71
|
+
"prettier": "^3.1",
|
|
72
|
+
"tsup": "^8.0.1",
|
|
72
73
|
"typescript": "^5.2.2",
|
|
73
74
|
"version-from-git": "^1.1.1",
|
|
75
|
+
"@solana/addresses": "2.0.0-experimental.745437f",
|
|
76
|
+
"@solana/keys": "2.0.0-experimental.745437f",
|
|
77
|
+
"@solana/web3.js": "0.0.0-development",
|
|
74
78
|
"build-scripts": "0.0.0",
|
|
75
79
|
"test-config": "0.0.0",
|
|
76
|
-
"tsconfig": "0.0.0"
|
|
77
|
-
"@solana/addresses": "2.0.0-experimental.72efece",
|
|
78
|
-
"@solana/keys": "2.0.0-experimental.72efece",
|
|
79
|
-
"@solana/web3.js": "1.87.2"
|
|
80
|
+
"tsconfig": "0.0.0"
|
|
80
81
|
},
|
|
81
82
|
"bundlewatch": {
|
|
82
83
|
"defaultCompression": "gzip",
|