@solana/transactions 2.0.0-experimental.e1ca396 → 2.0.0-experimental.e58bb22
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/dist/index.browser.cjs +178 -137
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +181 -141
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +181 -141
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +178 -137
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +183 -141
- package/dist/index.node.js.map +1 -1
- package/dist/types/blockhash.d.ts +4 -7
- package/dist/types/blockhash.d.ts.map +1 -1
- package/dist/types/compilable-transaction.d.ts +4 -4
- package/dist/types/compile-address-table-lookups.d.ts +1 -1
- package/dist/types/compile-header.d.ts +1 -1
- package/dist/types/compile-instructions.d.ts +1 -1
- package/dist/types/compile-lifetime-token.d.ts +1 -1
- package/dist/types/compile-static-accounts.d.ts +1 -1
- package/dist/types/compile-transaction.d.ts +3 -3
- package/dist/types/create-transaction.d.ts +1 -1
- package/dist/types/decompile-transaction.d.ts +12 -4
- package/dist/types/decompile-transaction.d.ts.map +1 -1
- package/dist/types/durable-nonce.d.ts +2 -2
- package/dist/types/fee-payer.d.ts +2 -2
- package/dist/types/index.d.ts +12 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/instructions.d.ts +2 -2
- package/dist/types/message.d.ts +6 -6
- package/dist/types/serializers/address-table-lookup.d.ts +1 -1
- package/dist/types/serializers/header.d.ts +1 -1
- package/dist/types/serializers/index.d.ts +2 -2
- package/dist/types/serializers/instruction.d.ts +1 -1
- package/dist/types/serializers/message.d.ts +1 -1
- package/dist/types/serializers/transaction-version.d.ts +1 -1
- package/dist/types/serializers/transaction.d.ts +7 -4
- package/dist/types/serializers/transaction.d.ts.map +1 -1
- package/dist/types/signatures.d.ts +2 -2
- package/dist/types/signatures.d.ts.map +1 -1
- package/dist/types/unsigned-transaction.d.ts +1 -1
- package/dist/types/wire-transaction.d.ts +1 -1
- package/package.json +17 -15
- package/dist/index.development.js +0 -1628
- package/dist/index.development.js.map +0 -1
- package/dist/index.production.min.js +0 -32
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../codecs-core/dist/index.browser.js","../../codecs-numbers/dist/index.browser.js","../../codecs-strings/dist/index.browser.js","../src/unsigned-transaction.ts","../src/blockhash.ts","../src/create-transaction.ts","../../instructions/src/roles.ts","../src/durable-nonce.ts","../src/fee-payer.ts","../src/instructions.ts","../../assertions/src/subtle-crypto.ts","../../addresses/dist/index.browser.js","../src/accounts.ts","../src/compile-address-table-lookups.ts","../src/compile-header.ts","../src/compile-instructions.ts","../src/compile-lifetime-token.ts","../src/compile-static-accounts.ts","../src/message.ts","../../codecs-data-structures/src/array.ts","../../codecs-data-structures/src/utils.ts","../../codecs-data-structures/src/bit-array.ts","../../codecs-data-structures/src/boolean.ts","../../codecs-data-structures/src/bytes.ts","../../codecs-data-structures/src/nullable.ts","../../codecs-data-structures/src/scalar-enum.ts","../src/serializers/address-table-lookup.ts","../src/serializers/header.ts","../src/serializers/instruction.ts","../src/serializers/transaction-version.ts","../src/serializers/message.ts","../src/compile-transaction.ts","../../functional/src/pipe.ts","../src/decompile-transaction.ts","../src/serializers/transaction.ts","../../keys/src/signatures.ts","../src/signatures.ts","../src/wire-transaction.ts"],"names":["e","AccountRole","base58Encoder","address","combineCodec","assertIsFixedSize","createDecoder","createEncoder","getEncodedSize","mapDecoder","mapEncoder","getU8Decoder"],"mappings":";AACA,SAAS,kCAAkC,kBAAkB,OAAO,SAAS,GAAG;AAC9E,MAAI,MAAM,SAAS,UAAU,GAAG;AAC9B,UAAM,IAAI,MAAM,UAAU,gBAAgB,oCAAoC;AAAA,EAChF;AACF;AACA,SAAS,sCAAsC,kBAAkB,UAAU,OAAO,SAAS,GAAG;AAC5F,QAAM,cAAc,MAAM,SAAS;AACnC,MAAI,cAAc,UAAU;AAC1B,UAAM,IAAI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AAO;AACvB,QAAM,kBAAkB,oBAAI,IAAI,CAAC,YAAY,UAAU,GAAG,+BAA+B,CAAC;AAE1F,kBAAgB,QAAQ,CAAAA,aAAW;AAC/B,QAAI,CAAC,YAAY,WAAWA,QAAO,GAAG;AAElC,YAAM,IAAI,MAAM,kDAAkDA,QAAO,IAAI;AAAA,IACjF;AAAA,EACJ,CAAC;AACL;;;AC7EO,SAAS,gCACZ,aAC4B;AAC5B,QAAM,uBAAuB,sBAAsB,EAAE,OAAO,WAAW;AACvE,SAAO,iBAAiB,EAAE,OAAO,oBAAoB;AACzD","sourcesContent":["// 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 { combineCodec, createEncoder, createDecoder, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';\n\n// src/assertions.ts\nfunction assertNumberIsBetweenForCodec(codecDescription, min, max, value) {\n if (value < min || value > max) {\n throw new Error(\n `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`\n );\n }\n}\n\n// src/common.ts\nvar Endian = /* @__PURE__ */ ((Endian2) => {\n Endian2[Endian2[\"LITTLE\"] = 0] = \"LITTLE\";\n Endian2[Endian2[\"BIG\"] = 1] = \"BIG\";\n return Endian2;\n})(Endian || {});\nfunction isLittleEndian(config) {\n return config?.endian === 1 /* BIG */ ? false : true;\n}\nfunction numberEncoderFactory(input) {\n return createEncoder({\n fixedSize: input.size,\n write(value, bytes, offset) {\n if (input.range) {\n assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);\n }\n const arrayBuffer = new ArrayBuffer(input.size);\n input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));\n bytes.set(new Uint8Array(arrayBuffer), offset);\n return offset + input.size;\n }\n });\n}\nfunction numberDecoderFactory(input) {\n return createDecoder({\n fixedSize: input.size,\n read(bytes, offset = 0) {\n assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);\n assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);\n const view = new DataView(toArrayBuffer(bytes, offset, input.size));\n return [input.get(view, isLittleEndian(input.config)), offset + input.size];\n }\n });\n}\nfunction toArrayBuffer(bytes, offset, length) {\n const bytesOffset = bytes.byteOffset + (offset ?? 0);\n const bytesLength = length ?? bytes.byteLength;\n return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);\n}\n\n// src/f32.ts\nvar getF32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"f32\",\n set: (view, value, le) => view.setFloat32(0, value, le),\n size: 4\n});\nvar getF32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getFloat32(0, le),\n name: \"f32\",\n size: 4\n});\nvar getF32Codec = (config = {}) => combineCodec(getF32Encoder(config), getF32Decoder(config));\nvar getF64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"f64\",\n set: (view, value, le) => view.setFloat64(0, value, le),\n size: 8\n});\nvar getF64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getFloat64(0, le),\n name: \"f64\",\n size: 8\n});\nvar getF64Codec = (config = {}) => combineCodec(getF64Encoder(config), getF64Decoder(config));\nvar getI128Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i128\",\n range: [-BigInt(\"0x7fffffffffffffffffffffffffffffff\") - 1n, BigInt(\"0x7fffffffffffffffffffffffffffffff\")],\n set: (view, value, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const rightMask = 0xffffffffffffffffn;\n view.setBigInt64(leftOffset, BigInt(value) >> 64n, le);\n view.setBigUint64(rightOffset, BigInt(value) & rightMask, le);\n },\n size: 16\n});\nvar getI128Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const left = view.getBigInt64(leftOffset, le);\n const right = view.getBigUint64(rightOffset, le);\n return (left << 64n) + right;\n },\n name: \"i128\",\n size: 16\n});\nvar getI128Codec = (config = {}) => combineCodec(getI128Encoder(config), getI128Decoder(config));\nvar getI16Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i16\",\n range: [-Number(\"0x7fff\") - 1, Number(\"0x7fff\")],\n set: (view, value, le) => view.setInt16(0, value, le),\n size: 2\n});\nvar getI16Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getInt16(0, le),\n name: \"i16\",\n size: 2\n});\nvar getI16Codec = (config = {}) => combineCodec(getI16Encoder(config), getI16Decoder(config));\nvar getI32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i32\",\n range: [-Number(\"0x7fffffff\") - 1, Number(\"0x7fffffff\")],\n set: (view, value, le) => view.setInt32(0, value, le),\n size: 4\n});\nvar getI32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getInt32(0, le),\n name: \"i32\",\n size: 4\n});\nvar getI32Codec = (config = {}) => combineCodec(getI32Encoder(config), getI32Decoder(config));\nvar getI64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i64\",\n range: [-BigInt(\"0x7fffffffffffffff\") - 1n, BigInt(\"0x7fffffffffffffff\")],\n set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),\n size: 8\n});\nvar getI64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getBigInt64(0, le),\n name: \"i64\",\n size: 8\n});\nvar getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));\nvar getI8Encoder = () => numberEncoderFactory({\n name: \"i8\",\n range: [-Number(\"0x7f\") - 1, Number(\"0x7f\")],\n set: (view, value) => view.setInt8(0, value),\n size: 1\n});\nvar getI8Decoder = () => numberDecoderFactory({\n get: (view) => view.getInt8(0),\n name: \"i8\",\n size: 1\n});\nvar getI8Codec = () => combineCodec(getI8Encoder(), getI8Decoder());\nvar getShortU16Encoder = () => createEncoder({\n getSizeFromValue: (value) => {\n if (value <= 127)\n return 1;\n if (value <= 16383)\n return 2;\n return 3;\n },\n maxSize: 3,\n write: (value, bytes, offset) => {\n assertNumberIsBetweenForCodec(\"shortU16\", 0, 65535, value);\n const shortU16Bytes = [0];\n for (let ii = 0; ; ii += 1) {\n const alignedValue = value >> ii * 7;\n if (alignedValue === 0) {\n break;\n }\n const nextSevenBits = 127 & alignedValue;\n shortU16Bytes[ii] = nextSevenBits;\n if (ii > 0) {\n shortU16Bytes[ii - 1] |= 128;\n }\n }\n bytes.set(shortU16Bytes, offset);\n return offset + shortU16Bytes.length;\n }\n});\nvar getShortU16Decoder = () => createDecoder({\n maxSize: 3,\n read: (bytes, offset) => {\n let value = 0;\n let byteCount = 0;\n while (++byteCount) {\n const byteIndex = byteCount - 1;\n const currentByte = bytes[offset + byteIndex];\n const nextSevenBits = 127 & currentByte;\n value |= nextSevenBits << byteIndex * 7;\n if ((currentByte & 128) === 0) {\n break;\n }\n }\n return [value, offset + byteCount];\n }\n});\nvar getShortU16Codec = () => combineCodec(getShortU16Encoder(), getShortU16Decoder());\nvar getU128Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u128\",\n range: [0, BigInt(\"0xffffffffffffffffffffffffffffffff\")],\n set: (view, value, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const rightMask = 0xffffffffffffffffn;\n view.setBigUint64(leftOffset, BigInt(value) >> 64n, le);\n view.setBigUint64(rightOffset, BigInt(value) & rightMask, le);\n },\n size: 16\n});\nvar getU128Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const left = view.getBigUint64(leftOffset, le);\n const right = view.getBigUint64(rightOffset, le);\n return (left << 64n) + right;\n },\n name: \"u128\",\n size: 16\n});\nvar getU128Codec = (config = {}) => combineCodec(getU128Encoder(config), getU128Decoder(config));\nvar getU16Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u16\",\n range: [0, Number(\"0xffff\")],\n set: (view, value, le) => view.setUint16(0, value, le),\n size: 2\n});\nvar getU16Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getUint16(0, le),\n name: \"u16\",\n size: 2\n});\nvar getU16Codec = (config = {}) => combineCodec(getU16Encoder(config), getU16Decoder(config));\nvar getU32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u32\",\n range: [0, Number(\"0xffffffff\")],\n set: (view, value, le) => view.setUint32(0, value, le),\n size: 4\n});\nvar getU32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getUint32(0, le),\n name: \"u32\",\n size: 4\n});\nvar getU32Codec = (config = {}) => combineCodec(getU32Encoder(config), getU32Decoder(config));\nvar getU64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u64\",\n range: [0, BigInt(\"0xffffffffffffffff\")],\n set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),\n size: 8\n});\nvar getU64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getBigUint64(0, le),\n name: \"u64\",\n size: 8\n});\nvar getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));\nvar getU8Encoder = () => numberEncoderFactory({\n name: \"u8\",\n range: [0, Number(\"0xff\")],\n set: (view, value) => view.setUint8(0, value),\n size: 1\n});\nvar getU8Decoder = () => numberDecoderFactory({\n get: (view) => view.getUint8(0),\n name: \"u8\",\n size: 1\n});\nvar getU8Codec = () => combineCodec(getU8Encoder(), getU8Decoder());\n\nexport { Endian, assertNumberIsBetweenForCodec, getF32Codec, getF32Decoder, getF32Encoder, getF64Codec, getF64Decoder, getF64Encoder, getI128Codec, getI128Decoder, getI128Encoder, getI16Codec, getI16Decoder, getI16Encoder, getI32Codec, getI32Decoder, getI32Encoder, getI64Codec, getI64Decoder, getI64Encoder, getI8Codec, getI8Decoder, getI8Encoder, getShortU16Codec, getShortU16Decoder, getShortU16Encoder, getU128Codec, getU128Decoder, getU128Encoder, getU16Codec, getU16Decoder, getU16Encoder, getU32Codec, getU32Decoder, getU32Encoder, getU64Codec, getU64Decoder, getU64Encoder, getU8Codec, getU8Decoder, getU8Encoder };\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}\nvar getBase64Encoder = () => {\n {\n return createEncoder({\n getSizeFromValue: (value) => {\n try {\n return atob(value).length;\n } catch (e2) {\n throw new Error(`Expected a string of base 64, got [${value}].`);\n }\n },\n write(value, bytes, offset) {\n try {\n const bytesToAdd = atob(value).split(\"\").map((c) => c.charCodeAt(0));\n bytes.set(bytesToAdd, offset);\n return bytesToAdd.length + offset;\n } catch (e2) {\n throw new Error(`Expected a string of base 64, got [${value}].`);\n }\n }\n });\n }\n};\nvar getBase64Decoder = () => {\n {\n return createDecoder({\n read(bytes, offset = 0) {\n const slice = bytes.slice(offset);\n const value = btoa(String.fromCharCode(...slice));\n return [value, bytes.length];\n }\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 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 { 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 { Encoder } from '@solana/codecs-core';\nimport { getBase58Encoder } from '@solana/codecs-strings';\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\nlet base58Encoder: Encoder<string> | undefined;\n\nexport function assertIsBlockhash(putativeBlockhash: string): asserts putativeBlockhash is Blockhash {\n if (!base58Encoder) base58Encoder = getBase58Encoder();\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 = base58Encoder.encode(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\nfunction isTransactionWithBlockhashLifetime(\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime),\n): transaction is BaseTransaction & ITransactionWithBlockhashLifetime {\n const lifetimeConstraintShapeMatches =\n 'lifetimeConstraint' in transaction &&\n typeof transaction.lifetimeConstraint.blockhash === 'string' &&\n typeof transaction.lifetimeConstraint.lastValidBlockHeight === 'bigint';\n if (!lifetimeConstraintShapeMatches) return false;\n try {\n assertIsBlockhash(transaction.lifetimeConstraint.blockhash);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function assertIsTransactionWithBlockhashLifetime(\n transaction: BaseTransaction | (BaseTransaction & ITransactionWithBlockhashLifetime),\n): asserts transaction is BaseTransaction & ITransactionWithBlockhashLifetime {\n if (!isTransactionWithBlockhashLifetime(transaction)) {\n // TODO: Coded error.\n throw new Error('Transaction does not have a blockhash lifetime');\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","/**\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 { Address } from '@solana/addresses';\nimport {\n AccountRole,\n IInstruction,\n IInstructionWithAccounts,\n IInstructionWithData,\n isSignerRole,\n ReadonlyAccount,\n ReadonlySignerAccount,\n WritableAccount,\n WritableSignerAccount,\n} from '@solana/instructions';\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> | WritableSignerAccount<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: Address<TNonceAccountAddress>;\n readonly nonceAuthorityAddress: Address<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 Address<'SysvarRecentB1ockHashes11111111111111111111'>;\nconst SYSTEM_PROGRAM_ADDRESS = '11111111111111111111111111111111' as Address<'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: Address<TNonceAccountAddress>,\n nonceAuthorityAddress: Address<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 isSignerRole(instruction.accounts[2].role)\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\nfunction isAdvanceNonceAccountInstructionForNonce<\n TNonceAccountAddress extends Address = Address,\n TNonceAuthorityAddress extends Address = Address,\n>(\n instruction: AdvanceNonceAccountInstruction,\n nonceAccountAddress: TNonceAccountAddress,\n nonceAuthorityAddress: TNonceAuthorityAddress,\n): instruction is AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress> {\n return (\n instruction.accounts[0].address === nonceAccountAddress &&\n instruction.accounts[2].address === nonceAuthorityAddress\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 let newInstructions: [\n AdvanceNonceAccountInstruction<TNonceAccountAddress, TNonceAuthorityAddress>,\n ...IInstruction[],\n ];\n\n const firstInstruction = transaction.instructions[0];\n if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {\n if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {\n if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {\n return transaction as TTransaction &\n IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n } else {\n // we already have the right first instruction, leave it as-is\n newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];\n }\n } else {\n // we have a different advance nonce instruction as the first instruction, replace it\n newInstructions = [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...transaction.instructions.slice(1),\n ];\n }\n } else {\n // we don't have an existing advance nonce instruction as the first instruction, prepend one\n newInstructions = [\n createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),\n ...transaction.instructions,\n ];\n }\n\n const out = {\n ...getUnsignedTransaction(transaction),\n instructions: newInstructions,\n lifetimeConstraint: {\n nonce,\n },\n } as TTransaction & IDurableNonceTransaction<TNonceAccountAddress, TNonceAuthorityAddress, TNonceValue>;\n Object.freeze(out);\n return out;\n}\n","import { Address } 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: Address<TAddress>;\n}\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Address<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: Address<TFeePayerAddress>,\n transaction: TTransaction | (TTransaction & ITransactionWithFeePayer<string>),\n): TTransaction & ITransactionWithFeePayer<TFeePayerAddress>;\n\nexport function setTransactionFeePayer<TFeePayerAddress extends string, TTransaction extends BaseTransaction>(\n feePayer: Address<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","function assertIsSecureContext() {\n if (__BROWSER__ && !globalThis.isSecureContext) {\n // TODO: Coded error.\n throw new Error(\n 'Cryptographic operations are only allowed in secure browser contexts. Read more ' +\n 'here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts',\n );\n }\n}\n\nlet cachedEd25519Decision: PromiseLike<boolean> | boolean | undefined;\nasync function isEd25519CurveSupported(subtle: SubtleCrypto): Promise<boolean> {\n if (cachedEd25519Decision === undefined) {\n cachedEd25519Decision = new Promise(resolve => {\n subtle\n .generateKey('Ed25519', /* extractable */ false, ['sign', 'verify'])\n .catch(() => {\n resolve((cachedEd25519Decision = false));\n })\n .then(() => {\n resolve((cachedEd25519Decision = true));\n });\n });\n }\n if (typeof cachedEd25519Decision === 'boolean') {\n return cachedEd25519Decision;\n } else {\n return await cachedEd25519Decision;\n }\n}\n\nexport async function assertDigestCapabilityIsAvailable() {\n assertIsSecureContext();\n if (typeof globalThis.crypto === 'undefined' || typeof globalThis.crypto.subtle?.digest !== 'function') {\n // TODO: Coded error.\n throw new Error('No digest implementation could be found');\n }\n}\n\nexport async function assertKeyGenerationIsAvailable() {\n assertIsSecureContext();\n if (typeof globalThis.crypto === 'undefined' || typeof globalThis.crypto.subtle?.generateKey !== 'function') {\n // TODO: Coded error.\n throw new Error('No key generation implementation could be found');\n }\n if (!(await isEd25519CurveSupported(globalThis.crypto.subtle))) {\n // TODO: Coded error.\n throw new Error(\n 'This runtime does not support the generation of Ed25519 key pairs.\\n\\nInstall and ' +\n 'import `@solana/webcrypto-ed25519-polyfill` before generating keys in ' +\n 'environments that do not support Ed25519.\\n\\nFor a list of runtimes that ' +\n 'currently support Ed25519 operations, visit ' +\n 'https://github.com/WICG/webcrypto-secure-curves/issues/20',\n );\n }\n}\n\nexport async function assertKeyExporterIsAvailable() {\n assertIsSecureContext();\n if (typeof globalThis.crypto === 'undefined' || typeof globalThis.crypto.subtle?.exportKey !== 'function') {\n // TODO: Coded error.\n throw new Error('No key export implementation could be found');\n }\n}\n\nexport async function assertSigningCapabilityIsAvailable() {\n assertIsSecureContext();\n if (typeof globalThis.crypto === 'undefined' || typeof globalThis.crypto.subtle?.sign !== 'function') {\n // TODO: Coded error.\n throw new Error('No signing implementation could be found');\n }\n}\n\nexport async function assertVerificationCapabilityIsAvailable() {\n assertIsSecureContext();\n if (typeof globalThis.crypto === 'undefined' || typeof globalThis.crypto.subtle?.verify !== 'function') {\n // TODO: Coded error.\n throw new Error('No signature verification implementation could be found');\n }\n}\n","import { mapEncoder, combineCodec } from '@solana/codecs-core';\nimport { getStringEncoder, getStringDecoder, getBase58Encoder, getBase58Decoder } from '@solana/codecs-strings';\nimport { assertKeyExporterIsAvailable, assertDigestCapabilityIsAvailable } from '@solana/assertions';\n\n// src/address.ts\nvar memoizedBase58Encoder;\nvar memoizedBase58Decoder;\nfunction getMemoizedBase58Encoder() {\n if (!memoizedBase58Encoder)\n memoizedBase58Encoder = getBase58Encoder();\n return memoizedBase58Encoder;\n}\nfunction getMemoizedBase58Decoder() {\n if (!memoizedBase58Decoder)\n memoizedBase58Decoder = getBase58Decoder();\n return memoizedBase58Decoder;\n}\nfunction isAddress(putativeAddress) {\n if (\n // Lowest address (32 bytes of zeroes)\n putativeAddress.length < 32 || // Highest address (32 bytes of 255)\n putativeAddress.length > 44\n ) {\n return false;\n }\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}\nfunction assertIsAddress(putativeAddress) {\n try {\n if (\n // Lowest address (32 bytes of zeroes)\n putativeAddress.length < 32 || // 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 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}\nfunction address(putativeAddress) {\n assertIsAddress(putativeAddress);\n return putativeAddress;\n}\nfunction getAddressEncoder() {\n return mapEncoder(\n getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }),\n (putativeAddress) => address(putativeAddress)\n );\n}\nfunction getAddressDecoder() {\n return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 });\n}\nfunction getAddressCodec() {\n return combineCodec(getAddressEncoder(), getAddressDecoder());\n}\nfunction getAddressComparator() {\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// src/vendor/noble/ed25519.ts\nvar D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;\nvar P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;\nvar RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;\nfunction mod(a) {\n const r = a % P;\n return r >= 0n ? r : P + r;\n}\nfunction pow2(x, power) {\n let r = x;\n while (power-- > 0n) {\n r *= r;\n r %= P;\n }\n return r;\n}\nfunction pow_2_252_3(x) {\n const x2 = x * x % P;\n const b2 = x2 * x % P;\n const b4 = pow2(b2, 2n) * b2 % P;\n const b5 = pow2(b4, 1n) * x % P;\n const b10 = pow2(b5, 5n) * b5 % P;\n const b20 = pow2(b10, 10n) * b10 % P;\n const b40 = pow2(b20, 20n) * b20 % P;\n const b80 = pow2(b40, 40n) * b40 % P;\n const b160 = pow2(b80, 80n) * b80 % P;\n const b240 = pow2(b160, 80n) * b80 % P;\n const b250 = pow2(b240, 10n) * b10 % P;\n const pow_p_5_8 = pow2(b250, 2n) * x % P;\n return pow_p_5_8;\n}\nfunction uvRatio(u, v) {\n const v3 = mod(v * v * v);\n const v7 = mod(v3 * v3 * v);\n const pow = pow_2_252_3(u * v7);\n let x = mod(u * v3 * pow);\n const vx2 = mod(v * x * x);\n const root1 = x;\n const root2 = mod(x * RM1);\n const useRoot1 = vx2 === u;\n const useRoot2 = vx2 === mod(-u);\n const noRoot = vx2 === mod(-u * RM1);\n if (useRoot1)\n x = root1;\n if (useRoot2 || noRoot)\n x = root2;\n if ((mod(x) & 1n) === 1n)\n x = mod(-x);\n if (!useRoot1 && !useRoot2) {\n return null;\n }\n return x;\n}\nfunction pointIsOnCurve(y, lastByte) {\n const y2 = mod(y * y);\n const u = mod(y2 - 1n);\n const v = mod(D * y2 + 1n);\n const x = uvRatio(u, v);\n if (x === null) {\n return false;\n }\n const isLastByteOdd = (lastByte & 128) !== 0;\n if (x === 0n && isLastByteOdd) {\n return false;\n }\n return true;\n}\n\n// src/curve.ts\nfunction byteToHex(byte) {\n const hexString = byte.toString(16);\n if (hexString.length === 1) {\n return `0${hexString}`;\n } else {\n return hexString;\n }\n}\nfunction decompressPointBytes(bytes) {\n const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, \"\");\n const integerLiteralString = `0x${hexString}`;\n return BigInt(integerLiteralString);\n}\nasync function compressedPointBytesAreOnCurve(bytes) {\n if (bytes.byteLength !== 32) {\n return false;\n }\n const y = decompressPointBytes(bytes);\n return pointIsOnCurve(y, bytes[31]);\n}\n\n// src/program-derived-address.ts\nfunction isProgramDerivedAddress(value) {\n return Array.isArray(value) && value.length === 2 && typeof value[0] === \"string\" && typeof value[1] === \"number\" && value[1] >= 0 && value[1] <= 255 && isAddress(value[0]);\n}\nfunction assertIsProgramDerivedAddress(value) {\n const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === \"string\" && typeof value[1] === \"number\";\n if (!validFormat) {\n throw new Error(\n `Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].`\n );\n }\n if (value[1] < 0 || value[1] > 255) {\n throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);\n }\n assertIsAddress(value[0]);\n}\nvar MAX_SEED_LENGTH = 32;\nvar MAX_SEEDS = 16;\nvar PDA_MARKER_BYTES = [\n // The string 'ProgramDerivedAddress'\n 80,\n 114,\n 111,\n 103,\n 114,\n 97,\n 109,\n 68,\n 101,\n 114,\n 105,\n 118,\n 101,\n 100,\n 65,\n 100,\n 100,\n 114,\n 101,\n 115,\n 115\n];\nvar PointOnCurveError = class extends Error {\n};\nasync function createProgramDerivedAddress({ programAddress, seeds }) {\n await assertDigestCapabilityIsAvailable();\n if (seeds.length > MAX_SEEDS) {\n throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);\n }\n let textEncoder;\n const seedBytes = seeds.reduce((acc, seed, ii) => {\n const bytes = typeof seed === \"string\" ? (textEncoder ||= new TextEncoder()).encode(seed) : seed;\n if (bytes.byteLength > MAX_SEED_LENGTH) {\n throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);\n }\n acc.push(...bytes);\n return acc;\n }, []);\n const base58EncodedAddressCodec = getAddressCodec();\n const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);\n const addressBytesBuffer = await crypto.subtle.digest(\n \"SHA-256\",\n new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])\n );\n const addressBytes = new Uint8Array(addressBytesBuffer);\n if (await compressedPointBytesAreOnCurve(addressBytes)) {\n throw new PointOnCurveError(\"Invalid seeds; point must fall off the Ed25519 curve\");\n }\n return base58EncodedAddressCodec.decode(addressBytes);\n}\nasync function getProgramDerivedAddress({\n programAddress,\n seeds\n}) {\n let bumpSeed = 255;\n while (bumpSeed > 0) {\n try {\n const address2 = await createProgramDerivedAddress({\n programAddress,\n seeds: [...seeds, new Uint8Array([bumpSeed])]\n });\n return [address2, bumpSeed];\n } catch (e) {\n if (e instanceof PointOnCurveError) {\n bumpSeed--;\n } else {\n throw e;\n }\n }\n }\n throw new Error(\"Unable to find a viable program address bump seed\");\n}\nasync function createAddressWithSeed({ baseAddress, programAddress, seed }) {\n const { encode, decode } = getAddressCodec();\n const seedBytes = typeof seed === \"string\" ? new TextEncoder().encode(seed) : seed;\n if (seedBytes.byteLength > MAX_SEED_LENGTH) {\n throw new Error(`The seed exceeds the maximum length of 32 bytes`);\n }\n const programAddressBytes = encode(programAddress);\n if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {\n throw new Error(`programAddress cannot end with the PDA marker`);\n }\n const addressBytesBuffer = await crypto.subtle.digest(\n \"SHA-256\",\n new Uint8Array([...encode(baseAddress), ...seedBytes, ...programAddressBytes])\n );\n const addressBytes = new Uint8Array(addressBytesBuffer);\n return decode(addressBytes);\n}\nasync function getAddressFromPublicKey(publicKey) {\n await assertKeyExporterIsAvailable();\n if (publicKey.type !== \"public\" || publicKey.algorithm.name !== \"Ed25519\") {\n throw new Error(\"The `CryptoKey` must be an `Ed25519` public key\");\n }\n const publicKeyBytes = await crypto.subtle.exportKey(\"raw\", publicKey);\n return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));\n}\n\nexport { address, assertIsAddress, assertIsProgramDerivedAddress, createAddressWithSeed, getAddressCodec, getAddressComparator, getAddressDecoder, getAddressEncoder, getAddressFromPublicKey, getProgramDerivedAddress, isAddress, isProgramDerivedAddress };\n","import { Address, 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: Address,\n update: (\n entry: FeePayerAccountEntry | LookupTableAccountEntry | StaticAccountEntry | Record<never, never>,\n ) => AddressMap[Address],\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(feePayer: Address, instructions: readonly IInstruction[]): AddressMap {\n const addressMap: AddressMap = {\n [feePayer]: { [TYPE]: AddressMapEntryType.FEE_PAYER, role: AccountRole.WRITABLE_SIGNER },\n };\n const addressesOfInvokedPrograms = new Set<Address>();\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 Address<typeof address>,\n ...addressMeta,\n }));\n return orderedAccounts as unknown as OrderedAccounts;\n}\n","import { Address, getAddressComparator } from '@solana/addresses';\nimport { AccountRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype AddressTableLookup = Readonly<{\n lookupTableAddress: Address;\n readableIndices: readonly number[];\n writableIndices: readonly number[];\n}>;\n\nexport function getCompiledAddressTableLookups(orderedAccounts: OrderedAccounts): AddressTableLookup[] {\n const index: Record<Address, { readonly readableIndices: number[]; readonly writableIndices: number[] }> = {};\n for (const account of orderedAccounts) {\n if (!('lookupTableAddress' in account)) {\n continue;\n }\n const entry = (index[account.lookupTableAddress] ||= {\n readableIndices: [],\n writableIndices: [],\n });\n if (account.role === AccountRole.WRITABLE) {\n entry.writableIndices.push(account.addressIndex);\n } else {\n entry.readableIndices.push(account.addressIndex);\n }\n }\n return Object.keys(index)\n .sort(getAddressComparator())\n .map(lookupTableAddress => ({\n lookupTableAddress: lookupTableAddress as Address,\n ...index[lookupTableAddress as unknown as Address],\n }));\n}\n","import { isSignerRole, isWritableRole } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype MessageHeader = Readonly<{\n numReadonlyNonSignerAccounts: number;\n numReadonlySignerAccounts: number;\n numSignerAccounts: number;\n}>;\n\nexport function getCompiledMessageHeader(orderedAccounts: OrderedAccounts): MessageHeader {\n let numReadonlyNonSignerAccounts = 0;\n let numReadonlySignerAccounts = 0;\n let numSignerAccounts = 0;\n for (const account of orderedAccounts) {\n if ('lookupTableAddress' in account) {\n break;\n }\n const accountIsWritable = isWritableRole(account.role);\n if (isSignerRole(account.role)) {\n numSignerAccounts++;\n if (!accountIsWritable) {\n numReadonlySignerAccounts++;\n }\n } else if (!accountIsWritable) {\n numReadonlyNonSignerAccounts++;\n }\n }\n return {\n numReadonlyNonSignerAccounts,\n numReadonlySignerAccounts,\n numSignerAccounts,\n };\n}\n","import { Address } from '@solana/addresses';\nimport { IInstruction } from '@solana/instructions';\n\nimport { OrderedAccounts } from './accounts';\n\ntype CompiledInstruction = Readonly<{\n accountIndices?: number[];\n data?: Uint8Array;\n programAddressIndex: number;\n}>;\n\nfunction getAccountIndex(orderedAccounts: OrderedAccounts) {\n const out: Record<Address, number> = {};\n for (const [index, account] of orderedAccounts.entries()) {\n out[account.address] = index;\n }\n return out;\n}\n\nexport function getCompiledInstructions(\n instructions: readonly IInstruction[],\n orderedAccounts: OrderedAccounts,\n): CompiledInstruction[] {\n const accountIndex = getAccountIndex(orderedAccounts);\n return instructions.map(({ accounts, data, programAddress }) => {\n return {\n programAddressIndex: accountIndex[programAddress],\n ...(accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null),\n ...(data ? { data } : null),\n };\n });\n}\n","import { IDurableNonceTransaction, ITransactionWithBlockhashLifetime } from './index';\n\nexport function getCompiledLifetimeToken(\n lifetimeConstraint: (ITransactionWithBlockhashLifetime | IDurableNonceTransaction)['lifetimeConstraint'],\n): string {\n if ('nonce' in lifetimeConstraint) {\n return lifetimeConstraint.nonce;\n }\n return lifetimeConstraint.blockhash;\n}\n","import { Address } from '@solana/addresses';\n\nimport { OrderedAccounts } from './accounts';\n\nexport function getCompiledStaticAccounts(orderedAccounts: OrderedAccounts): Address[] {\n const firstLookupTableAccountIndex = orderedAccounts.findIndex(account => 'lookupTableAddress' in account);\n const orderedStaticAccounts =\n firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);\n return orderedStaticAccounts.map(({ address }) => address);\n}\n","import { getAddressMapFromInstructions, getOrderedAccountsFromAddressMap } from './accounts';\nimport { CompilableTransaction } from './compilable-transaction';\nimport { getCompiledAddressTableLookups } from './compile-address-table-lookups';\nimport { getCompiledMessageHeader } from './compile-header';\nimport { getCompiledInstructions } from './compile-instructions';\nimport { getCompiledLifetimeToken } from './compile-lifetime-token';\nimport { getCompiledStaticAccounts } from './compile-static-accounts';\n\ntype BaseCompiledMessage = Readonly<{\n header: ReturnType<typeof getCompiledMessageHeader>;\n instructions: ReturnType<typeof getCompiledInstructions>;\n lifetimeToken: ReturnType<typeof getCompiledLifetimeToken>;\n staticAccounts: ReturnType<typeof getCompiledStaticAccounts>;\n}>;\n\nexport type CompiledMessage = LegacyCompiledMessage | VersionedCompiledMessage;\n\ntype LegacyCompiledMessage = BaseCompiledMessage &\n Readonly<{\n version: 'legacy';\n }>;\n\ntype VersionedCompiledMessage = BaseCompiledMessage &\n Readonly<{\n addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups>;\n version: number;\n }>;\n\nexport function compileMessage(\n transaction: CompilableTransaction & Readonly<{ version: 'legacy' }>,\n): LegacyCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): VersionedCompiledMessage;\nexport function compileMessage(transaction: CompilableTransaction): CompiledMessage {\n const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);\n const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);\n return {\n ...(transaction.version !== 'legacy'\n ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) }\n : null),\n header: getCompiledMessageHeader(orderedAccounts),\n instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),\n lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),\n staticAccounts: getCompiledStaticAccounts(orderedAccounts),\n version: transaction.version,\n };\n}\n","import {\n assertIsFixedSize,\n Codec,\n combineCodec,\n createDecoder,\n createEncoder,\n Decoder,\n Encoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n getEncodedSize,\n Offset,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { assertValidNumberOfItemsForCodec } from './assertions';\nimport { getFixedSize, getMaxSize } from './utils';\n\n/**\n * Represents all the size options for array-like codecs\n * — i.e. `array`, `map` and `set`.\n *\n * It can be one of the following:\n * - a {@link NumberCodec} that prefixes its content with its size.\n * - a fixed number of items.\n * - or `'remainder'` to infer the number of items by dividing\n * the rest of the byte array by the fixed size of its item.\n * Note that this option is only available for fixed-size items.\n */\nexport type ArrayLikeCodecSize<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> =\n | TPrefix\n | number\n | 'remainder';\n\n/** Defines the configs for array codecs. */\nexport type ArrayCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = {\n /**\n * The size of the array.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\n/**\n * Encodes an array of items.\n *\n * @param item - The encoder to use for the array's items.\n * @param config - A set of config for the encoder.\n */\nexport function getArrayEncoder<TFrom>(\n item: Encoder<TFrom>,\n config: ArrayCodecConfig<NumberEncoder> & { size: 0 },\n): FixedSizeEncoder<TFrom[], 0>;\nexport function getArrayEncoder<TFrom>(\n item: FixedSizeEncoder<TFrom>,\n config: ArrayCodecConfig<NumberEncoder> & { size: number },\n): FixedSizeEncoder<TFrom[]>;\nexport function getArrayEncoder<TFrom>(\n item: FixedSizeEncoder<TFrom>,\n config: ArrayCodecConfig<NumberEncoder> & { size: 'remainder' },\n): VariableSizeEncoder<TFrom[]>;\nexport function getArrayEncoder<TFrom>(\n item: Encoder<TFrom>,\n config?: ArrayCodecConfig<NumberEncoder> & { size?: number | NumberEncoder },\n): VariableSizeEncoder<TFrom[]>;\nexport function getArrayEncoder<TFrom>(\n item: Encoder<TFrom>,\n config: ArrayCodecConfig<NumberEncoder> = {},\n): Encoder<TFrom[]> {\n const size = config.size ?? getU32Encoder();\n if (size === 'remainder') {\n assertIsFixedSize(item, 'Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));\n const maxSize = computeArrayLikeCodecSize(size, getMaxSize(item)) ?? undefined;\n\n return createEncoder({\n ...(fixedSize !== null\n ? { fixedSize }\n : {\n getSizeFromValue: (array: TFrom[]) => {\n const prefixSize = typeof size === 'object' ? getEncodedSize(array.length, size) : 0;\n return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);\n },\n maxSize,\n }),\n write: (array: TFrom[], bytes, offset) => {\n if (typeof size === 'number') {\n assertValidNumberOfItemsForCodec('array', size, array.length);\n }\n if (typeof size === 'object') {\n offset = size.write(array.length, bytes, offset);\n }\n array.forEach(value => {\n offset = item.write(value, bytes, offset);\n });\n return offset;\n },\n });\n}\n\n/**\n * Decodes an array of items.\n *\n * @param item - The encoder to use for the array's items.\n * @param config - A set of config for the encoder.\n */\nexport function getArrayDecoder<TTo>(\n item: Decoder<TTo>,\n config: ArrayCodecConfig<NumberDecoder> & { size: 0 },\n): FixedSizeDecoder<TTo[], 0>;\nexport function getArrayDecoder<TTo>(\n item: FixedSizeDecoder<TTo>,\n config: ArrayCodecConfig<NumberDecoder> & { size: number },\n): FixedSizeDecoder<TTo[]>;\nexport function getArrayDecoder<TTo>(\n item: FixedSizeDecoder<TTo>,\n config: ArrayCodecConfig<NumberDecoder> & { size: 'remainder' },\n): VariableSizeDecoder<TTo[]>;\nexport function getArrayDecoder<TTo>(\n item: Decoder<TTo>,\n config?: ArrayCodecConfig<NumberDecoder> & { size?: number | NumberDecoder },\n): VariableSizeDecoder<TTo[]>;\nexport function getArrayDecoder<TTo>(item: Decoder<TTo>, config: ArrayCodecConfig<NumberDecoder> = {}): Decoder<TTo[]> {\n const size = config.size ?? getU32Decoder();\n if (size === 'remainder') {\n assertIsFixedSize(item, 'Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n const itemSize = getFixedSize(item);\n const fixedSize = computeArrayLikeCodecSize(size, itemSize);\n const maxSize = computeArrayLikeCodecSize(size, getMaxSize(item)) ?? undefined;\n\n return createDecoder({\n ...(fixedSize !== null ? { fixedSize } : { maxSize }),\n read: (bytes: Uint8Array, offset) => {\n const array: TTo[] = [];\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [array, offset];\n }\n const [resolvedSize, newOffset] = readArrayLikeCodecSize(size, itemSize, bytes, offset);\n offset = newOffset;\n for (let i = 0; i < resolvedSize; i += 1) {\n const [value, newOffset] = item.read(bytes, offset);\n offset = newOffset;\n array.push(value);\n }\n return [array, offset];\n },\n });\n}\n\n/**\n * Creates a codec for an array of items.\n *\n * @param item - The codec to use for the array's items.\n * @param config - A set of config for the codec.\n */\nexport function getArrayCodec<TFrom, TTo extends TFrom = TFrom>(\n item: Codec<TFrom, TTo>,\n config: ArrayCodecConfig<NumberCodec> & { size: 0 },\n): FixedSizeCodec<TFrom[], TTo[], 0>;\nexport function getArrayCodec<TFrom, TTo extends TFrom = TFrom>(\n item: FixedSizeCodec<TFrom, TTo>,\n config: ArrayCodecConfig<NumberCodec> & { size: number },\n): FixedSizeCodec<TFrom[], TTo[]>;\nexport function getArrayCodec<TFrom, TTo extends TFrom = TFrom>(\n item: FixedSizeCodec<TFrom, TTo>,\n config: ArrayCodecConfig<NumberCodec> & { size: 'remainder' },\n): VariableSizeCodec<TFrom[], TTo[]>;\nexport function getArrayCodec<TFrom, TTo extends TFrom = TFrom>(\n item: Codec<TFrom, TTo>,\n config?: ArrayCodecConfig<NumberCodec> & { size?: number | NumberCodec },\n): VariableSizeCodec<TFrom[], TTo[]>;\nexport function getArrayCodec<TFrom, TTo extends TFrom = TFrom>(\n item: Codec<TFrom, TTo>,\n config: ArrayCodecConfig<NumberCodec> = {},\n): Codec<TFrom[], TTo[]> {\n return combineCodec(getArrayEncoder(item, config as object), getArrayDecoder(item, config as object));\n}\n\nfunction readArrayLikeCodecSize(\n size: ArrayLikeCodecSize<NumberDecoder>,\n itemSize: number | null,\n bytes: Uint8Array,\n offset: Offset,\n): [number | bigint, Offset] {\n if (typeof size === 'number') {\n return [size, offset];\n }\n\n if (typeof size === 'object') {\n return size.read(bytes, offset);\n }\n\n if (size === 'remainder') {\n if (itemSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n const remainder = Math.max(0, bytes.length - offset);\n if (remainder % itemSize !== 0) {\n // TODO: Coded error.\n throw new Error(\n `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${itemSize} bytes. ` +\n `Codecs of \"remainder\" size must have a remainder that is a multiple of its item size. ` +\n `In other words, ${remainder} modulo ${itemSize} should be equal to zero.`,\n );\n }\n return [remainder / itemSize, offset];\n }\n\n // TODO: Coded error.\n throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);\n}\n\nfunction computeArrayLikeCodecSize(size: object | number | 'remainder', itemSize: number | null): number | null {\n if (typeof size !== 'number') return null;\n if (size === 0) return 0;\n return itemSize === null ? null : itemSize * size;\n}\n","import { isFixedSize } from '@solana/codecs-core';\n\nexport function maxCodecSizes(sizes: (number | null)[]): number | null {\n return sizes.reduce(\n (all, size) => (all === null || size === null ? null : Math.max(all, size)),\n 0 as number | null,\n );\n}\n\nexport function sumCodecSizes(sizes: (number | null)[]): number | null {\n return sizes.reduce((all, size) => (all === null || size === null ? null : all + size), 0 as number | null);\n}\n\nexport function getFixedSize(codec: { fixedSize: number } | { maxSize?: number }): number | null {\n return isFixedSize(codec) ? codec.fixedSize : null;\n}\n\nexport function getMaxSize(codec: { fixedSize: number } | { maxSize?: number }): number | null {\n return isFixedSize(codec) ? codec.fixedSize : codec.maxSize ?? null;\n}\n","import {\n assertByteArrayHasEnoughBytesForCodec,\n combineCodec,\n createDecoder,\n createEncoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n} from '@solana/codecs-core';\n\n/** Defines the config for bitArray codecs. */\nexport type BitArrayCodecConfig = {\n /**\n * Whether to read the bits in reverse order.\n * @defaultValue `false`\n */\n backward?: boolean;\n};\n\n/**\n * Encodes an array of booleans into bits.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the encoder.\n */\nexport function getBitArrayEncoder<TSize extends number>(\n size: TSize,\n config: BitArrayCodecConfig | boolean = {},\n): FixedSizeEncoder<boolean[], TSize> {\n const parsedConfig: BitArrayCodecConfig = typeof config === 'boolean' ? { backward: config } : config;\n const backward = parsedConfig.backward ?? false;\n return createEncoder({\n fixedSize: size,\n write(value: boolean[], bytes, offset) {\n const bytesToAdd: number[] = [];\n\n for (let i = 0; i < size; i += 1) {\n let byte = 0;\n for (let j = 0; j < 8; j += 1) {\n const feature = Number(value[i * 8 + j] ?? 0);\n byte |= feature << (backward ? j : 7 - j);\n }\n if (backward) {\n bytesToAdd.unshift(byte);\n } else {\n bytesToAdd.push(byte);\n }\n }\n\n bytes.set(bytesToAdd, offset);\n return size;\n },\n });\n}\n\n/**\n * Decodes bits into an array of booleans.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the decoder.\n */\nexport function getBitArrayDecoder<TSize extends number>(\n size: TSize,\n config: BitArrayCodecConfig | boolean = {},\n): FixedSizeDecoder<boolean[], TSize> {\n const parsedConfig: BitArrayCodecConfig = typeof config === 'boolean' ? { backward: config } : config;\n const backward = parsedConfig.backward ?? false;\n return createDecoder({\n fixedSize: size,\n read(bytes, offset) {\n assertByteArrayHasEnoughBytesForCodec('bitArray', size, bytes, offset);\n const booleans: boolean[] = [];\n let slice = bytes.slice(offset, offset + size);\n slice = backward ? slice.reverse() : slice;\n\n slice.forEach(byte => {\n for (let i = 0; i < 8; i += 1) {\n if (backward) {\n booleans.push(Boolean(byte & 1));\n byte >>= 1;\n } else {\n booleans.push(Boolean(byte & 0b1000_0000));\n byte <<= 1;\n }\n }\n });\n\n return [booleans, offset + size];\n },\n });\n}\n\n/**\n * An array of boolean codec that converts booleans to bits and vice versa.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the codec.\n */\nexport function getBitArrayCodec<TSize extends number>(\n size: TSize,\n config: BitArrayCodecConfig | boolean = {},\n): FixedSizeCodec<boolean[], boolean[], TSize> {\n return combineCodec(getBitArrayEncoder(size, config), getBitArrayDecoder(size, config));\n}\n","import {\n assertIsFixedSize,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n mapDecoder,\n mapEncoder,\n} from '@solana/codecs-core';\nimport {\n FixedSizeNumberCodec,\n FixedSizeNumberDecoder,\n FixedSizeNumberEncoder,\n getU8Decoder,\n getU8Encoder,\n NumberCodec,\n NumberDecoder,\n NumberEncoder,\n} from '@solana/codecs-numbers';\n\n/** Defines the config for boolean codecs. */\nexport type BooleanCodecConfig<TSize extends NumberCodec | NumberEncoder | NumberDecoder> = {\n /**\n * The number codec to delegate to.\n * @defaultValue u8 size.\n */\n size?: TSize;\n};\n\n/**\n * Encodes booleans.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getBooleanEncoder(): FixedSizeEncoder<boolean, 1>;\nexport function getBooleanEncoder<TSize extends number>(\n config: BooleanCodecConfig<NumberEncoder> & { size: FixedSizeNumberEncoder<TSize> },\n): FixedSizeEncoder<boolean, TSize>;\nexport function getBooleanEncoder(config: BooleanCodecConfig<NumberEncoder>): Encoder<boolean>;\nexport function getBooleanEncoder(config: BooleanCodecConfig<NumberEncoder> = {}): Encoder<boolean> {\n const size = config.size ?? getU8Encoder();\n assertIsFixedSize(size, 'Codec [bool] requires a fixed size.');\n return mapEncoder(size, (value: boolean) => (value ? 1 : 0));\n}\n\n/**\n * Decodes booleans.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getBooleanDecoder(): FixedSizeDecoder<boolean, 1>;\nexport function getBooleanDecoder<TSize extends number>(\n config: BooleanCodecConfig<NumberDecoder> & { size: FixedSizeNumberDecoder<TSize> },\n): FixedSizeDecoder<boolean, TSize>;\nexport function getBooleanDecoder(config: BooleanCodecConfig<NumberDecoder>): Decoder<boolean>;\nexport function getBooleanDecoder(config: BooleanCodecConfig<NumberDecoder> = {}): Decoder<boolean> {\n const size = config.size ?? getU8Decoder();\n assertIsFixedSize(size, 'Codec [bool] requires a fixed size.');\n return mapDecoder(size, (value: number | bigint): boolean => Number(value) === 1);\n}\n\n/**\n * Creates a boolean codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getBooleanCodec(): FixedSizeCodec<boolean, boolean, 1>;\nexport function getBooleanCodec<TSize extends number>(\n config: BooleanCodecConfig<NumberCodec> & { size: FixedSizeNumberCodec<TSize> },\n): FixedSizeCodec<boolean, boolean, TSize>;\nexport function getBooleanCodec(config: BooleanCodecConfig<NumberCodec>): Codec<boolean>;\nexport function getBooleanCodec(config: BooleanCodecConfig<NumberCodec> = {}): Codec<boolean> {\n return combineCodec(getBooleanEncoder(config), getBooleanDecoder(config));\n}\n","import {\n assertByteArrayHasEnoughBytesForCodec,\n assertByteArrayIsNotEmptyForCodec,\n Codec,\n combineCodec,\n createDecoder,\n createEncoder,\n Decoder,\n Encoder,\n fixDecoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n fixEncoder,\n getEncodedSize,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/** Defines the config for bytes codecs. */\nexport type BytesCodecConfig<TSize extends NumberCodec | NumberEncoder | NumberDecoder> = {\n /**\n * The size of the byte array. It can be one of the following:\n * - a {@link NumberSerializer} that prefixes the byte array with its size.\n * - a fixed number of bytes.\n * - or `'variable'` to use the rest of the byte array.\n * @defaultValue `'variable'`\n */\n size?: TSize | number | 'variable';\n};\n\n/**\n * Encodes sized bytes.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getBytesEncoder<TSize extends number>(\n config: BytesCodecConfig<NumberEncoder> & { size: TSize },\n): FixedSizeEncoder<Uint8Array, TSize>;\nexport function getBytesEncoder(config?: BytesCodecConfig<NumberEncoder>): VariableSizeEncoder<Uint8Array>;\nexport function getBytesEncoder(config: BytesCodecConfig<NumberEncoder> = {}): Encoder<Uint8Array> {\n const size = config.size ?? 'variable';\n\n const byteEncoder: Encoder<Uint8Array> = createEncoder({\n getSizeFromValue: (value: Uint8Array) => value.length,\n write: (value: Uint8Array, bytes, offset) => {\n bytes.set(value, offset);\n return offset + value.length;\n },\n });\n\n if (size === 'variable') {\n return byteEncoder;\n }\n\n if (typeof size === 'number') {\n return fixEncoder(byteEncoder, size);\n }\n\n return createEncoder({\n getSizeFromValue: (value: Uint8Array) => getEncodedSize(value.length, size) + value.length,\n write: (value: Uint8Array, bytes, offset) => {\n offset = size.write(value.length, bytes, offset);\n return byteEncoder.write(value, bytes, offset);\n },\n });\n}\n\n/**\n * Decodes sized bytes.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getBytesDecoder<TSize extends number>(\n config: BytesCodecConfig<NumberDecoder> & { size: TSize },\n): FixedSizeDecoder<Uint8Array, TSize>;\nexport function getBytesDecoder(config?: BytesCodecConfig<NumberDecoder>): VariableSizeDecoder<Uint8Array>;\nexport function getBytesDecoder(config: BytesCodecConfig<NumberDecoder> = {}): Decoder<Uint8Array> {\n const size = config.size ?? 'variable';\n\n const byteDecoder: Decoder<Uint8Array> = createDecoder({\n read: (bytes: Uint8Array, offset) => {\n const slice = bytes.slice(offset);\n return [slice, offset + slice.length];\n },\n });\n\n if (size === 'variable') {\n return byteDecoder;\n }\n\n if (typeof size === 'number') {\n return fixDecoder(byteDecoder, size);\n }\n\n return createDecoder({\n read: (bytes: Uint8Array, offset) => {\n assertByteArrayIsNotEmptyForCodec('bytes', 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('bytes', length, contentBytes);\n const [value, contentOffset] = byteDecoder.read(contentBytes, 0);\n offset += contentOffset;\n return [value, offset];\n },\n });\n}\n\n/**\n * Creates a sized bytes codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getBytesCodec<TSize extends number>(\n config: BytesCodecConfig<NumberCodec> & { size: TSize },\n): FixedSizeCodec<Uint8Array, Uint8Array, TSize>;\nexport function getBytesCodec(config?: BytesCodecConfig<NumberCodec>): VariableSizeCodec<Uint8Array>;\nexport function getBytesCodec(config: BytesCodecConfig<NumberCodec> = {}): Codec<Uint8Array> {\n return combineCodec(getBytesEncoder(config), getBytesDecoder(config));\n}\n","import {\n assertIsFixedSize,\n Codec,\n combineCodec,\n createDecoder,\n createEncoder,\n Decoder,\n Encoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n getEncodedSize,\n isFixedSize,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n FixedSizeNumberCodec,\n FixedSizeNumberDecoder,\n FixedSizeNumberEncoder,\n getU8Decoder,\n getU8Encoder,\n NumberCodec,\n NumberDecoder,\n NumberEncoder,\n} from '@solana/codecs-numbers';\n\nimport { getMaxSize, sumCodecSizes } from './utils';\n\n/** Defines the config for nullable codecs. */\nexport type NullableCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = {\n /**\n * The codec to use for the boolean prefix.\n * @defaultValue u8 prefix.\n */\n prefix?: TPrefix;\n\n /**\n * Whether the item codec should be of fixed size.\n *\n * When this is true, a `null` value will skip the bytes that would\n * have been used for the item. Note that this will only work if the\n * item codec is of fixed size.\n * @defaultValue `false`\n */\n fixed?: boolean;\n};\n\n/**\n * Creates a encoder for an optional value using `null` as the `None` value.\n *\n * @param item - The encoder to use for the value that may be present.\n * @param config - A set of config for the encoder.\n */\nexport function getNullableEncoder<TFrom>(\n item: FixedSizeEncoder<TFrom>,\n config: NullableCodecConfig<FixedSizeNumberEncoder> & { fixed: true },\n): FixedSizeEncoder<TFrom | null>;\nexport function getNullableEncoder<TFrom>(\n item: FixedSizeEncoder<TFrom, 0>,\n config?: NullableCodecConfig<FixedSizeNumberEncoder>,\n): FixedSizeEncoder<TFrom | null>;\nexport function getNullableEncoder<TFrom>(\n item: Encoder<TFrom>,\n config?: NullableCodecConfig<NumberEncoder> & { fixed?: false },\n): VariableSizeEncoder<TFrom | null>;\nexport function getNullableEncoder<TFrom>(\n item: Encoder<TFrom>,\n config: NullableCodecConfig<NumberEncoder> = {},\n): Encoder<TFrom | null> {\n const prefix = config.prefix ?? getU8Encoder();\n const fixed = config.fixed ?? false;\n\n const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;\n if (fixed || isZeroSizeItem) {\n assertIsFixedSize(item, 'Fixed nullables can only be used with fixed-size codecs.');\n assertIsFixedSize(prefix, 'Fixed nullables can only be used with fixed-size prefix.');\n const fixedSize = prefix.fixedSize + item.fixedSize;\n return createEncoder({\n fixedSize,\n write: (option: TFrom | null, bytes, offset) => {\n const prefixOffset = prefix.write(Number(option !== null), bytes, offset);\n if (option !== null) {\n item.write(option, bytes, prefixOffset);\n }\n return offset + fixedSize;\n },\n });\n }\n\n return createEncoder({\n getSizeFromValue: (option: TFrom | null) =>\n getEncodedSize(Number(option !== null), prefix) + (option !== null ? getEncodedSize(option, item) : 0),\n maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? undefined,\n write: (option: TFrom | null, bytes, offset) => {\n offset = prefix.write(Number(option !== null), bytes, offset);\n if (option !== null) {\n offset = item.write(option, bytes, offset);\n }\n return offset;\n },\n });\n}\n\n/**\n * Creates a decoder for an optional value using `null` as the `None` value.\n *\n * @param item - The decoder to use for the value that may be present.\n * @param config - A set of config for the decoder.\n */\nexport function getNullableDecoder<TTo>(\n item: FixedSizeDecoder<TTo>,\n config: NullableCodecConfig<FixedSizeNumberDecoder> & { fixed: true },\n): FixedSizeDecoder<TTo | null>;\nexport function getNullableDecoder<TTo>(\n item: FixedSizeDecoder<TTo, 0>,\n config?: NullableCodecConfig<FixedSizeNumberDecoder>,\n): FixedSizeDecoder<TTo | null>;\nexport function getNullableDecoder<TTo>(\n item: Decoder<TTo>,\n config?: NullableCodecConfig<NumberDecoder> & { fixed?: false },\n): VariableSizeDecoder<TTo | null>;\nexport function getNullableDecoder<TTo>(\n item: Decoder<TTo>,\n config: NullableCodecConfig<NumberDecoder> = {},\n): Decoder<TTo | null> {\n const prefix = config.prefix ?? getU8Decoder();\n const fixed = config.fixed ?? false;\n\n let fixedSize: number | null = null;\n const isZeroSizeItem = isFixedSize(item) && isFixedSize(prefix) && item.fixedSize === 0;\n if (fixed || isZeroSizeItem) {\n assertIsFixedSize(item, 'Fixed nullables can only be used with fixed-size codecs.');\n assertIsFixedSize(prefix, 'Fixed nullables can only be used with fixed-size prefix.');\n fixedSize = prefix.fixedSize + item.fixedSize;\n }\n\n return createDecoder({\n ...(fixedSize === null\n ? { maxSize: sumCodecSizes([prefix, item].map(getMaxSize)) ?? undefined }\n : { fixedSize }),\n read: (bytes: Uint8Array, offset) => {\n if (bytes.length - offset <= 0) {\n return [null, offset];\n }\n const [isSome, prefixOffset] = prefix.read(bytes, offset);\n if (isSome === 0) {\n return [null, fixedSize !== null ? offset + fixedSize : prefixOffset];\n }\n const [value, newOffset] = item.read(bytes, prefixOffset);\n return [value, fixedSize !== null ? offset + fixedSize : newOffset];\n },\n });\n}\n\n/**\n * Creates a codec for an optional value using `null` as the `None` value.\n *\n * @param item - The codec to use for the value that may be present.\n * @param config - A set of config for the codec.\n */\nexport function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(\n item: FixedSizeCodec<TFrom, TTo>,\n config: NullableCodecConfig<FixedSizeNumberCodec> & { fixed: true },\n): FixedSizeCodec<TFrom | null, TTo | null>;\nexport function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(\n item: FixedSizeCodec<TFrom, TTo, 0>,\n config?: NullableCodecConfig<FixedSizeNumberCodec>,\n): FixedSizeCodec<TFrom | null, TTo | null>;\nexport function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(\n item: Codec<TFrom, TTo>,\n config?: NullableCodecConfig<NumberCodec> & { fixed?: false },\n): VariableSizeCodec<TFrom | null, TTo | null>;\nexport function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(\n item: Codec<TFrom, TTo>,\n config: NullableCodecConfig<NumberCodec> = {},\n): Codec<TFrom | null, TTo | null> {\n const configCast = config as NullableCodecConfig<NumberCodec> & { fixed?: false };\n return combineCodec(getNullableEncoder<TFrom>(item, configCast), getNullableDecoder<TTo>(item, configCast));\n}\n","import {\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n FixedSizeCodec,\n FixedSizeDecoder,\n FixedSizeEncoder,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n FixedSizeNumberCodec,\n FixedSizeNumberDecoder,\n FixedSizeNumberEncoder,\n getU8Decoder,\n getU8Encoder,\n NumberCodec,\n NumberDecoder,\n NumberEncoder,\n} from '@solana/codecs-numbers';\n\n/**\n * Defines a scalar enum as a type from its constructor.\n *\n * @example\n * ```ts\n * enum Direction { Left, Right };\n * type DirectionType = ScalarEnum<Direction>;\n * ```\n */\nexport type ScalarEnum<T> = ({ [key: number | string]: string | number | T } | number | T) & NonNullable<unknown>;\n\n/** Defines the config for scalar enum codecs. */\nexport type ScalarEnumCodecConfig<TDiscriminator extends NumberCodec | NumberEncoder | NumberDecoder> = {\n /**\n * The codec to use for the enum discriminator.\n * @defaultValue u8 discriminator.\n */\n size?: TDiscriminator;\n};\n\n/**\n * Creates a scalar enum encoder.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the encoder.\n */\nexport function getScalarEnumEncoder<TFrom, TFromConstructor extends ScalarEnum<TFrom>>(\n constructor: TFromConstructor,\n): FixedSizeEncoder<TFrom, 1>;\nexport function getScalarEnumEncoder<TFrom, TFromConstructor extends ScalarEnum<TFrom>, TSize extends number>(\n constructor: TFromConstructor,\n config: ScalarEnumCodecConfig<NumberEncoder> & { size: FixedSizeNumberEncoder<TSize> },\n): FixedSizeEncoder<TFrom, TSize>;\nexport function getScalarEnumEncoder<TFrom, TFromConstructor extends ScalarEnum<TFrom>>(\n constructor: TFromConstructor,\n config?: ScalarEnumCodecConfig<NumberEncoder>,\n): VariableSizeEncoder<TFrom>;\nexport function getScalarEnumEncoder<TFrom, TFromConstructor extends ScalarEnum<TFrom>>(\n constructor: TFromConstructor,\n config: ScalarEnumCodecConfig<NumberEncoder> = {},\n): Encoder<TFrom> {\n const prefix = config.size ?? getU8Encoder();\n const { minRange, maxRange, stringValues, enumKeys, enumValues } = getScalarEnumStats(constructor);\n return mapEncoder(prefix, (value: TFrom): number => {\n const isInvalidNumber = typeof value === 'number' && (value < minRange || value > maxRange);\n const isInvalidString = typeof value === 'string' && !stringValues.includes(value);\n if (isInvalidNumber || isInvalidString) {\n // TODO: Coded error.\n throw new Error(\n `Invalid scalar enum variant. ` +\n `Expected one of [${stringValues.join(', ')}] ` +\n `or a number between ${minRange} and ${maxRange}, ` +\n `got \"${value}\".`,\n );\n }\n if (typeof value === 'number') return value;\n const valueIndex = enumValues.indexOf(value);\n if (valueIndex >= 0) return valueIndex;\n return enumKeys.indexOf(value as string);\n });\n}\n\n/**\n * Creates a scalar enum decoder.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the decoder.\n */\nexport function getScalarEnumDecoder<TTo, TToConstructor extends ScalarEnum<TTo>>(\n constructor: TToConstructor,\n): FixedSizeDecoder<TTo, 1>;\nexport function getScalarEnumDecoder<TTo, TToConstructor extends ScalarEnum<TTo>, TSize extends number>(\n constructor: TToConstructor,\n config: ScalarEnumCodecConfig<NumberDecoder> & { size: FixedSizeNumberDecoder<TSize> },\n): FixedSizeDecoder<TTo, TSize>;\nexport function getScalarEnumDecoder<TTo, TToConstructor extends ScalarEnum<TTo>>(\n constructor: TToConstructor,\n config?: ScalarEnumCodecConfig<NumberDecoder>,\n): VariableSizeDecoder<TTo>;\nexport function getScalarEnumDecoder<TTo, TToConstructor extends ScalarEnum<TTo>>(\n constructor: TToConstructor,\n config: ScalarEnumCodecConfig<NumberDecoder> = {},\n): Decoder<TTo> {\n const prefix = config.size ?? getU8Decoder();\n const { minRange, maxRange, isNumericEnum, enumValues } = getScalarEnumStats(constructor);\n return mapDecoder(prefix, (value: number | bigint): TTo => {\n const valueAsNumber = Number(value);\n if (valueAsNumber < minRange || valueAsNumber > maxRange) {\n // TODO: Coded error.\n throw new Error(\n `Enum discriminator out of range. ` +\n `Expected a number between ${minRange} and ${maxRange}, got ${valueAsNumber}.`,\n );\n }\n return (isNumericEnum ? valueAsNumber : enumValues[valueAsNumber]) as TTo;\n });\n}\n\n/**\n * Creates a scalar enum codec.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the codec.\n */\nexport function getScalarEnumCodec<TFrom, TFromConstructor extends ScalarEnum<TFrom>>(\n constructor: TFromConstructor,\n): FixedSizeCodec<TFrom, TFrom, 1>;\nexport function getScalarEnumCodec<TFrom, TFromConstructor extends ScalarEnum<TFrom>, TSize extends number>(\n constructor: TFromConstructor,\n config: ScalarEnumCodecConfig<NumberCodec> & { size: FixedSizeNumberCodec<TSize> },\n): FixedSizeCodec<TFrom, TFrom, TSize>;\nexport function getScalarEnumCodec<TFrom, TFromConstructor extends ScalarEnum<TFrom>>(\n constructor: TFromConstructor,\n config?: ScalarEnumCodecConfig<NumberCodec>,\n): VariableSizeCodec<TFrom>;\nexport function getScalarEnumCodec<TFrom, TFromConstructor extends ScalarEnum<TFrom>>(\n constructor: TFromConstructor,\n config: ScalarEnumCodecConfig<NumberCodec> = {},\n): Codec<TFrom> {\n return combineCodec(getScalarEnumEncoder(constructor, config), getScalarEnumDecoder(constructor, config));\n}\n\nfunction getScalarEnumStats<TFrom>(constructor: ScalarEnum<TFrom>): {\n enumKeys: string[];\n enumValues: TFrom[];\n isNumericEnum: boolean;\n minRange: number;\n maxRange: number;\n stringValues: string[];\n} {\n const enumKeys = Object.keys(constructor);\n const enumValues = Object.values(constructor);\n const isNumericEnum = enumValues.some(v => typeof v === 'number');\n const minRange = 0;\n const maxRange = isNumericEnum ? enumValues.length / 2 - 1 : enumValues.length - 1;\n const stringValues: string[] = isNumericEnum ? [...enumKeys] : [...new Set([...enumKeys, ...enumValues])];\n\n return {\n enumKeys,\n enumValues,\n isNumericEnum,\n maxRange,\n minRange,\n stringValues,\n };\n}\n","import { getAddressDecoder, getAddressEncoder } from '@solana/addresses';\nimport {\n combineCodec,\n type Encoder,\n type VariableSizeCodec,\n type VariableSizeDecoder,\n type VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport { getArrayDecoder, getArrayEncoder, getStructDecoder, getStructEncoder } from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport type { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\n\ntype AddressTableLookup = ReturnType<typeof getCompiledAddressTableLookups>[number];\n\nlet memoizedAddressTableLookupEncoder: VariableSizeEncoder<AddressTableLookup> | undefined;\nexport function getAddressTableLookupEncoder(): VariableSizeEncoder<AddressTableLookup> {\n if (!memoizedAddressTableLookupEncoder) {\n memoizedAddressTableLookupEncoder = getStructEncoder([\n ['lookupTableAddress', getAddressEncoder()],\n [\n 'writableIndices',\n getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() }) as Encoder<readonly number[]>,\n ],\n [\n 'readableIndices',\n getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() }) as Encoder<readonly number[]>,\n ],\n ]);\n }\n\n return memoizedAddressTableLookupEncoder;\n}\n\nlet memoizedAddressTableLookupDecoder: VariableSizeDecoder<AddressTableLookup> | undefined;\nexport function getAddressTableLookupDecoder(): VariableSizeDecoder<AddressTableLookup> {\n if (!memoizedAddressTableLookupDecoder) {\n memoizedAddressTableLookupDecoder = getStructDecoder([\n ['lookupTableAddress', getAddressDecoder()],\n ['writableIndices', getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],\n ['readableIndices', getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],\n ]);\n }\n\n return memoizedAddressTableLookupDecoder;\n}\n\nexport function getAddressTableLookupCodec(): VariableSizeCodec<AddressTableLookup> {\n return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());\n}\n","import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';\nimport { getStructCodec, getStructDecoder, getStructEncoder } from '@solana/codecs-data-structures';\nimport { getU8Codec, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport { getCompiledMessageHeader } from '../compile-header';\n\ntype MessageHeader = ReturnType<typeof getCompiledMessageHeader>;\n\nlet memoizedU8Encoder: FixedSizeEncoder<number, 1> | undefined;\nfunction getMemoizedU8Encoder(): FixedSizeEncoder<number, 1> {\n if (!memoizedU8Encoder) memoizedU8Encoder = getU8Encoder();\n return memoizedU8Encoder;\n}\n\nlet memoizedU8Decoder: FixedSizeDecoder<number, 1> | undefined;\nfunction getMemoizedU8Decoder(): FixedSizeDecoder<number, 1> {\n if (!memoizedU8Decoder) memoizedU8Decoder = getU8Decoder();\n return memoizedU8Decoder;\n}\n\nlet memoizedU8Codec: FixedSizeCodec<number, number, 1> | undefined;\nfunction getMemoizedU8Codec(): FixedSizeCodec<number, number, 1> {\n if (!memoizedU8Codec) memoizedU8Codec = getU8Codec();\n return memoizedU8Codec;\n}\n\nexport function getMessageHeaderEncoder(): FixedSizeEncoder<MessageHeader, 3> {\n return getStructEncoder([\n ['numSignerAccounts', getMemoizedU8Encoder()],\n ['numReadonlySignerAccounts', getMemoizedU8Encoder()],\n ['numReadonlyNonSignerAccounts', getMemoizedU8Encoder()],\n ]) as FixedSizeEncoder<MessageHeader, 3>;\n}\n\nexport function getMessageHeaderDecoder(): FixedSizeDecoder<MessageHeader, 3> {\n return getStructDecoder([\n ['numSignerAccounts', getMemoizedU8Decoder()],\n ['numReadonlySignerAccounts', getMemoizedU8Decoder()],\n ['numReadonlyNonSignerAccounts', getMemoizedU8Decoder()],\n ]) as FixedSizeDecoder<MessageHeader, 3>;\n}\n\nexport function getMessageHeaderCodec(): FixedSizeCodec<MessageHeader, MessageHeader, 3> {\n return getStructCodec([\n ['numSignerAccounts', getMemoizedU8Codec()],\n ['numReadonlySignerAccounts', getMemoizedU8Codec()],\n ['numReadonlyNonSignerAccounts', getMemoizedU8Codec()],\n ]) as FixedSizeCodec<MessageHeader, MessageHeader, 3>;\n}\n","import {\n combineCodec,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n getArrayDecoder,\n getArrayEncoder,\n getBytesDecoder,\n getBytesEncoder,\n getStructDecoder,\n getStructEncoder,\n} from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';\n\nimport { getCompiledInstructions } from '../compile-instructions';\n\ntype Instruction = ReturnType<typeof getCompiledInstructions>[number];\n\nlet memoizedGetInstructionEncoder: VariableSizeEncoder<Instruction> | undefined;\nexport function getInstructionEncoder(): VariableSizeEncoder<Instruction> {\n if (!memoizedGetInstructionEncoder) {\n memoizedGetInstructionEncoder = mapEncoder<Required<Instruction>, Instruction>(\n getStructEncoder([\n ['programAddressIndex', getU8Encoder()],\n ['accountIndices', getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],\n ['data', getBytesEncoder({ size: getShortU16Encoder() })],\n ]),\n // Convert an instruction to have all fields defined\n (instruction: Instruction): Required<Instruction> => {\n if (instruction.accountIndices !== undefined && instruction.data !== undefined) {\n return instruction as Required<Instruction>;\n }\n return {\n ...instruction,\n accountIndices: instruction.accountIndices ?? [],\n data: instruction.data ?? new Uint8Array(0),\n } as Required<Instruction>;\n },\n );\n }\n\n return memoizedGetInstructionEncoder;\n}\n\nlet memoizedGetInstructionDecoder: VariableSizeDecoder<Instruction> | undefined;\nexport function getInstructionDecoder(): VariableSizeDecoder<Instruction> {\n if (!memoizedGetInstructionDecoder) {\n memoizedGetInstructionDecoder = mapDecoder<Required<Instruction>, Instruction>(\n getStructDecoder([\n ['programAddressIndex', getU8Decoder()],\n ['accountIndices', getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],\n ['data', getBytesDecoder({ size: getShortU16Decoder() })],\n ]),\n // Convert an instruction to exclude optional fields if they are empty\n (instruction: Required<Instruction>): Instruction => {\n if (instruction.accountIndices.length && instruction.data.byteLength) {\n return instruction;\n }\n const { accountIndices, data, ...rest } = instruction;\n return {\n ...rest,\n ...(accountIndices.length ? { accountIndices } : null),\n ...(data.byteLength ? { data } : null),\n };\n },\n );\n }\n return memoizedGetInstructionDecoder;\n}\n\nexport function getInstructionCodec(): VariableSizeCodec<Instruction> {\n return combineCodec(getInstructionEncoder(), getInstructionDecoder());\n}\n","import {\n combineCodec,\n createDecoder,\n createEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\n\nimport { TransactionVersion } from '../types';\n\nconst VERSION_FLAG_MASK = 0x80;\n\nexport function getTransactionVersionEncoder(): VariableSizeEncoder<TransactionVersion> {\n return createEncoder({\n getSizeFromValue: value => (value === 'legacy' ? 0 : 1),\n maxSize: 1,\n write: (value, bytes, offset) => {\n if (value === 'legacy') {\n return offset;\n }\n if (value < 0 || value > 127) {\n // TODO: Coded error.\n throw new Error(`Transaction version must be in the range [0, 127]. \\`${value}\\` given.`);\n }\n bytes.set([value | VERSION_FLAG_MASK], offset);\n return offset + 1;\n },\n });\n}\n\nexport function getTransactionVersionDecoder(): VariableSizeDecoder<TransactionVersion> {\n return createDecoder({\n maxSize: 1,\n read: (bytes, offset) => {\n const firstByte = bytes[offset];\n if ((firstByte & VERSION_FLAG_MASK) === 0) {\n // No version flag set; it's a legacy (unversioned) transaction.\n return ['legacy', offset];\n } else {\n const version = (firstByte ^ VERSION_FLAG_MASK) as TransactionVersion;\n return [version, offset + 1];\n }\n },\n });\n}\n\nexport function getTransactionVersionCodec(): VariableSizeCodec<TransactionVersion> {\n return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());\n}\n","import { getAddressDecoder, getAddressEncoder } from '@solana/addresses';\nimport {\n combineCodec,\n createEncoder,\n Decoder,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n getArrayDecoder,\n getArrayEncoder,\n getStructDecoder,\n getStructEncoder,\n StructToDecoderTuple,\n StructToEncoderTuple,\n} from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder } from '@solana/codecs-numbers';\nimport { getBase58Decoder, getBase58Encoder, getStringDecoder, getStringEncoder } from '@solana/codecs-strings';\n\nimport { getCompiledAddressTableLookups } from '../compile-address-table-lookups';\nimport { CompiledMessage } from '../message';\nimport { getAddressTableLookupDecoder, getAddressTableLookupEncoder } from './address-table-lookup';\nimport { getMessageHeaderDecoder, getMessageHeaderEncoder } from './header';\nimport { getInstructionDecoder, getInstructionEncoder } from './instruction';\nimport { getTransactionVersionDecoder, getTransactionVersionEncoder } from './transaction-version';\n\nfunction getCompiledMessageLegacyEncoder(): VariableSizeEncoder<CompiledMessage> {\n return getStructEncoder(getPreludeStructEncoderTuple());\n}\n\nfunction getCompiledMessageVersionedEncoder(): VariableSizeEncoder<CompiledMessage> {\n return mapEncoder(\n getStructEncoder([\n ...getPreludeStructEncoderTuple(),\n ['addressTableLookups', getAddressTableLookupArrayEncoder()],\n ] as StructToEncoderTuple<CompiledMessage>),\n (value: CompiledMessage) => {\n if (value.version === 'legacy') {\n return value;\n }\n return {\n ...value,\n addressTableLookups: value.addressTableLookups ?? [],\n } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n },\n );\n}\n\nfunction getPreludeStructEncoderTuple(): StructToEncoderTuple<CompiledMessage> {\n return [\n ['version', getTransactionVersionEncoder()],\n ['header', getMessageHeaderEncoder()],\n ['staticAccounts', getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],\n ['lifetimeToken', getStringEncoder({ encoding: getBase58Encoder(), size: 32 })],\n ['instructions', getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })],\n ];\n}\n\nfunction getPreludeStructDecoderTuple(): StructToDecoderTuple<\n CompiledMessage & { addressTableLookups?: ReturnType<typeof getCompiledAddressTableLookups> }\n> {\n return [\n ['version', getTransactionVersionDecoder() as Decoder<number>],\n ['header', getMessageHeaderDecoder()],\n ['staticAccounts', getArrayDecoder(getAddressDecoder(), { size: getShortU16Decoder() })],\n ['lifetimeToken', getStringDecoder({ encoding: getBase58Decoder(), size: 32 })],\n ['instructions', getArrayDecoder(getInstructionDecoder(), { size: getShortU16Decoder() })],\n ['addressTableLookups', getAddressTableLookupArrayDecoder()],\n ];\n}\n\nfunction getAddressTableLookupArrayEncoder() {\n return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() });\n}\n\nfunction getAddressTableLookupArrayDecoder() {\n return getArrayDecoder(getAddressTableLookupDecoder(), { size: getShortU16Decoder() });\n}\n\nexport function getCompiledMessageEncoder(): VariableSizeEncoder<CompiledMessage> {\n return createEncoder({\n getSizeFromValue: (compiledMessage: CompiledMessage) => {\n if (compiledMessage.version === 'legacy') {\n return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);\n } else {\n return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);\n }\n },\n write: (compiledMessage, bytes, offset) => {\n if (compiledMessage.version === 'legacy') {\n return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);\n } else {\n return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);\n }\n },\n });\n}\n\nexport function getCompiledMessageDecoder(): VariableSizeDecoder<CompiledMessage> {\n return mapDecoder(getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {\n if (restOfMessage.version === 'legacy' || !addressTableLookups?.length) {\n return restOfMessage;\n }\n return { ...restOfMessage, addressTableLookups } as Exclude<CompiledMessage, { readonly version: 'legacy' }>;\n });\n}\n\nexport function getCompiledMessageCodec(): VariableSizeCodec<CompiledMessage> {\n return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());\n}\n","import { SignatureBytes } from '@solana/keys';\n\nimport { CompilableTransaction } from './compilable-transaction';\nimport { CompiledMessage, compileMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\n\nexport type CompiledTransaction = Readonly<{\n compiledMessage: CompiledMessage;\n signatures: SignatureBytes[];\n}>;\n\nexport function getCompiledTransaction(\n transaction: CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures),\n): CompiledTransaction {\n const compiledMessage = compileMessage(transaction);\n let signatures;\n if ('signatures' in transaction) {\n signatures = [];\n for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {\n signatures[ii] =\n transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));\n }\n } else {\n signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));\n }\n return {\n compiledMessage,\n signatures,\n };\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","import { Address, assertIsAddress } from '@solana/addresses';\nimport { pipe } from '@solana/functional';\nimport { AccountRole, IAccountMeta, IInstruction } from '@solana/instructions';\nimport { SignatureBytes } from '@solana/keys';\n\nimport { Blockhash, setTransactionLifetimeUsingBlockhash } from './blockhash';\nimport { CompilableTransaction } from './compilable-transaction';\nimport { CompiledTransaction } from './compile-transaction';\nimport { createTransaction } from './create-transaction';\nimport { isAdvanceNonceAccountInstruction, Nonce, setTransactionLifetimeUsingDurableNonce } from './durable-nonce';\nimport { setTransactionFeePayer } from './fee-payer';\nimport { appendTransactionInstruction } from './instructions';\nimport { CompiledMessage } from './message';\nimport { ITransactionWithSignatures } from './signatures';\nimport { TransactionVersion } from './types';\n\nfunction getAccountMetas(message: CompiledMessage): IAccountMeta[] {\n const { header } = message;\n const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;\n const numWritableNonSignerAccounts =\n message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;\n\n const accountMetas: IAccountMeta[] = [];\n\n let accountIndex = 0;\n for (let i = 0; i < numWritableSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.WRITABLE_SIGNER,\n });\n accountIndex++;\n }\n\n for (let i = 0; i < header.numReadonlySignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.READONLY_SIGNER,\n });\n accountIndex++;\n }\n\n for (let i = 0; i < numWritableNonSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.WRITABLE,\n });\n accountIndex++;\n }\n\n for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {\n accountMetas.push({\n address: message.staticAccounts[accountIndex],\n role: AccountRole.READONLY,\n });\n accountIndex++;\n }\n\n return accountMetas;\n}\n\nfunction convertInstruction(\n instruction: CompiledMessage['instructions'][0],\n accountMetas: IAccountMeta[],\n): IInstruction {\n const programAddress = accountMetas[instruction.programAddressIndex]?.address;\n if (!programAddress) {\n // TODO coded error\n throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);\n }\n\n const accounts = instruction.accountIndices?.map(accountIndex => accountMetas[accountIndex]);\n const { data } = instruction;\n\n return {\n programAddress,\n ...(accounts && accounts.length ? { accounts } : {}),\n ...(data && data.length ? { data } : {}),\n };\n}\n\ntype LifetimeConstraint =\n | {\n blockhash: Blockhash;\n lastValidBlockHeight: bigint;\n }\n | {\n nonce: Nonce;\n nonceAccountAddress: Address;\n nonceAuthorityAddress: Address;\n };\n\nfunction getLifetimeConstraint(\n messageLifetimeToken: string,\n firstInstruction?: IInstruction,\n lastValidBlockHeight?: bigint,\n): LifetimeConstraint {\n if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {\n // first instruction is not advance durable nonce, so use blockhash lifetime constraint\n return {\n blockhash: messageLifetimeToken as Blockhash,\n lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n, // U64 MAX\n };\n } else {\n // We know these accounts are defined because we checked `isAdvanceNonceAccountInstruction`\n const nonceAccountAddress = firstInstruction.accounts![0].address;\n assertIsAddress(nonceAccountAddress);\n\n const nonceAuthorityAddress = firstInstruction.accounts![2].address;\n assertIsAddress(nonceAuthorityAddress);\n\n return {\n nonce: messageLifetimeToken as Nonce,\n nonceAccountAddress,\n nonceAuthorityAddress,\n };\n }\n}\n\nfunction convertSignatures(compiledTransaction: CompiledTransaction): ITransactionWithSignatures['signatures'] {\n const {\n compiledMessage: { staticAccounts },\n signatures,\n } = compiledTransaction;\n return signatures.reduce((acc, sig, index) => {\n // compiled transaction includes a fake all 0 signature if it hasn't been signed\n // we don't store those 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 = staticAccounts[index];\n return { ...acc, [address]: sig as SignatureBytes };\n }, {});\n}\n\nexport function decompileTransaction(\n compiledTransaction: CompiledTransaction,\n lastValidBlockHeight?: bigint,\n): CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures) {\n const { compiledMessage } = compiledTransaction;\n\n // TODO: add support for address lookup tables\n if ('addressTableLookups' in compiledMessage && compiledMessage.addressTableLookups!.length > 0) {\n // TODO: coded error\n throw new Error('Cannot convert transaction with addressTableLookups');\n }\n\n const feePayer = compiledMessage.staticAccounts[0];\n // TODO: coded error\n if (!feePayer) throw new Error('No fee payer set in CompiledTransaction');\n\n const accountMetas = getAccountMetas(compiledMessage);\n\n const instructions: IInstruction[] = compiledMessage.instructions.map(compiledInstruction =>\n convertInstruction(compiledInstruction, accountMetas),\n );\n\n const firstInstruction = instructions[0];\n const lifetimeConstraint = getLifetimeConstraint(\n compiledMessage.lifetimeToken,\n firstInstruction,\n lastValidBlockHeight,\n );\n\n const signatures = convertSignatures(compiledTransaction);\n\n return pipe(\n createTransaction({ version: compiledMessage.version as TransactionVersion }),\n tx => setTransactionFeePayer(feePayer, tx),\n tx =>\n instructions.reduce((acc, instruction) => {\n return appendTransactionInstruction(instruction, acc);\n }, tx),\n tx =>\n 'blockhash' in lifetimeConstraint\n ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx)\n : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),\n tx => (compiledTransaction.signatures.length ? { ...tx, signatures } : tx),\n );\n}\n","import {\n combineCodec,\n FixedSizeDecoder,\n mapDecoder,\n mapEncoder,\n VariableSizeCodec,\n VariableSizeDecoder,\n VariableSizeEncoder,\n} from '@solana/codecs-core';\nimport {\n getArrayDecoder,\n getArrayEncoder,\n getBytesDecoder,\n getBytesEncoder,\n getStructDecoder,\n getStructEncoder,\n} from '@solana/codecs-data-structures';\nimport { getShortU16Decoder, getShortU16Encoder } from '@solana/codecs-numbers';\nimport { SignatureBytes } from '@solana/keys';\n\nimport { CompilableTransaction } from '../compilable-transaction';\nimport { CompiledTransaction, getCompiledTransaction } from '../compile-transaction';\nimport { decompileTransaction } from '../decompile-transaction';\nimport { ITransactionWithSignatures } from '../signatures';\nimport { getCompiledMessageDecoder, getCompiledMessageEncoder } from './message';\n\nfunction getCompiledTransactionEncoder(): VariableSizeEncoder<CompiledTransaction> {\n return getStructEncoder([\n ['signatures', getArrayEncoder(getBytesEncoder({ size: 64 }), { size: getShortU16Encoder() })],\n ['compiledMessage', getCompiledMessageEncoder()],\n ]);\n}\n\nfunction getCompiledTransactionDecoder(): VariableSizeDecoder<CompiledTransaction> {\n return getStructDecoder([\n [\n 'signatures',\n getArrayDecoder(getBytesDecoder({ size: 64 }) as FixedSizeDecoder<SignatureBytes, 64>, {\n size: getShortU16Decoder(),\n }),\n ],\n ['compiledMessage', getCompiledMessageDecoder()],\n ]);\n}\n\nexport function getTransactionEncoder(): VariableSizeEncoder<\n CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)\n> {\n return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);\n}\n\nexport function getTransactionDecoder(\n lastValidBlockHeight?: bigint,\n): VariableSizeDecoder<CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)> {\n return mapDecoder(getCompiledTransactionDecoder(), compiledTransaction =>\n decompileTransaction(compiledTransaction, lastValidBlockHeight),\n );\n}\n\nexport function getTransactionCodec(\n lastValidBlockHeight?: bigint,\n): VariableSizeCodec<CompilableTransaction | (CompilableTransaction & ITransactionWithSignatures)> {\n return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));\n}\n","import { assertSigningCapabilityIsAvailable, assertVerificationCapabilityIsAvailable } from '@solana/assertions';\nimport { Encoder } from '@solana/codecs-core';\nimport { getBase58Encoder } from '@solana/codecs-strings';\n\nexport type Signature = string & { readonly __brand: unique symbol };\nexport type SignatureBytes = Uint8Array & { readonly __brand: unique symbol };\n\nlet base58Encoder: Encoder<string> | undefined;\n\nexport function assertIsSignature(putativeSignature: string): asserts putativeSignature is Signature {\n if (!base58Encoder) base58Encoder = getBase58Encoder();\n\n try {\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (64 bytes of zeroes)\n putativeSignature.length < 64 ||\n // Highest value (64 bytes of 255)\n putativeSignature.length > 88\n ) {\n throw new Error('Expected input string to decode to a byte array of length 64.');\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58Encoder.encode(putativeSignature);\n const numBytes = bytes.byteLength;\n if (numBytes !== 64) {\n throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);\n }\n } catch (e) {\n throw new Error(`\\`${putativeSignature}\\` is not a signature`, {\n cause: e,\n });\n }\n}\n\nexport function isSignature(putativeSignature: string): putativeSignature is Signature {\n if (!base58Encoder) base58Encoder = getBase58Encoder();\n\n // Fast-path; see if the input string is of an acceptable length.\n if (\n // Lowest value (64 bytes of zeroes)\n putativeSignature.length < 64 ||\n // Highest value (64 bytes of 255)\n putativeSignature.length > 88\n ) {\n return false;\n }\n // Slow-path; actually attempt to decode the input string.\n const bytes = base58Encoder.encode(putativeSignature);\n const numBytes = bytes.byteLength;\n if (numBytes !== 64) {\n return false;\n }\n return true;\n}\n\nexport async function signBytes(key: CryptoKey, data: Uint8Array): Promise<SignatureBytes> {\n await assertSigningCapabilityIsAvailable();\n const signedData = await crypto.subtle.sign('Ed25519', key, data);\n return new Uint8Array(signedData) as SignatureBytes;\n}\n\nexport function signature(putativeSignature: string): Signature {\n assertIsSignature(putativeSignature);\n return putativeSignature;\n}\n\nexport async function verifySignature(key: CryptoKey, signature: SignatureBytes, data: Uint8Array): Promise<boolean> {\n await assertVerificationCapabilityIsAvailable();\n return await crypto.subtle.verify('Ed25519', key, signature, data);\n}\n","import { Address, getAddressFromPublicKey } from '@solana/addresses';\nimport { Decoder } from '@solana/codecs-core';\nimport { getBase58Decoder } from '@solana/codecs-strings';\nimport { isSignerRole } from '@solana/instructions';\nimport { Signature, SignatureBytes, signBytes } from '@solana/keys';\n\nimport { CompilableTransaction } from './compilable-transaction';\nimport { ITransactionWithFeePayer } from './fee-payer';\nimport { compileMessage } from './message';\nimport { getCompiledMessageEncoder } from './serializers/message';\n\nexport interface IFullySignedTransaction extends ITransactionWithSignatures {\n readonly __brand: unique symbol;\n}\nexport interface ITransactionWithSignatures {\n readonly signatures: Readonly<Record<Address, SignatureBytes>>;\n}\n\nlet base58Decoder: Decoder<string> | undefined;\n\nexport function getSignatureFromTransaction(\n transaction: ITransactionWithFeePayer & ITransactionWithSignatures,\n): Signature {\n if (!base58Decoder) base58Decoder = getBase58Decoder();\n\n const signatureBytes = transaction.signatures[transaction.feePayer];\n if (!signatureBytes) {\n // TODO: Coded error.\n throw new Error(\n \"Could not determine this transaction's signature. Make sure that the transaction \" +\n 'has been signed by its fee payer.',\n );\n }\n const transactionSignature = base58Decoder.decode(signatureBytes);\n return transactionSignature as Signature;\n}\n\nexport async function partiallySignTransaction<TTransaction extends CompilableTransaction>(\n keyPairs: CryptoKeyPair[],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): Promise<TTransaction & ITransactionWithSignatures> {\n const compiledMessage = compileMessage(transaction);\n const nextSignatures: Record<Address, SignatureBytes> =\n 'signatures' in transaction ? { ...transaction.signatures } : {};\n const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);\n const publicKeySignaturePairs = await Promise.all(\n keyPairs.map(keyPair =>\n Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)]),\n ),\n );\n for (const [signerPublicKey, signature] of publicKeySignaturePairs) {\n nextSignatures[signerPublicKey] = signature;\n }\n const out = {\n ...transaction,\n signatures: nextSignatures,\n };\n Object.freeze(out);\n return out;\n}\n\nexport async function signTransaction<TTransaction extends CompilableTransaction>(\n keyPairs: CryptoKeyPair[],\n transaction: TTransaction | (TTransaction & ITransactionWithSignatures),\n): Promise<TTransaction & IFullySignedTransaction> {\n const out = await partiallySignTransaction(keyPairs, transaction);\n assertTransactionIsFullySigned(out);\n Object.freeze(out);\n return out;\n}\n\nexport function assertTransactionIsFullySigned<TTransaction extends CompilableTransaction>(\n transaction: TTransaction & ITransactionWithSignatures,\n): asserts transaction is TTransaction & IFullySignedTransaction {\n const signerAddressesFromInstructions = transaction.instructions\n .flatMap(i => i.accounts?.filter(a => isSignerRole(a.role)) ?? [])\n .map(a => a.address);\n const requiredSigners = new Set([transaction.feePayer, ...signerAddressesFromInstructions]);\n\n requiredSigners.forEach(address => {\n if (!transaction.signatures[address]) {\n // TODO coded error\n throw new Error(`Transaction is missing signature for address \\`${address}\\``);\n }\n });\n}\n","import { getBase64Decoder } from '@solana/codecs-strings';\n\nimport { getTransactionEncoder } from './serializers/transaction';\n\nexport type Base64EncodedWireTransaction = string & {\n readonly __brand: unique symbol;\n};\n\nexport function getBase64EncodedWireTransaction(\n transaction: Parameters<ReturnType<typeof getTransactionEncoder>['encode']>[0],\n): Base64EncodedWireTransaction {\n const wireTransactionBytes = getTransactionEncoder().encode(transaction);\n return getBase64Decoder().decode(wireTransactionBytes) as Base64EncodedWireTransaction;\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
this.globalThis = this.globalThis || {};
|
|
2
|
-
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
function R(e,r,n=0){if(r.length-n<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function v(e,r,n,t=0){let o=n.length-t;if(o<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${o}.`)}var pr=(e,r)=>{if(e.length>=r)return e;let n=new Uint8Array(r).fill(0);return n.set(e),n},Tr=(e,r)=>pr(e.length<=r?e:e.slice(0,r),r);function x(e,r){return "fixedSize"in r?r.fixedSize:r.getSizeFromValue(e)}function g(e){return Object.freeze({...e,encode:r=>{let n=new Uint8Array(x(r,e));return e.write(r,n,0),n}})}function p(e){return Object.freeze({...e,decode:(r,n=0)=>e.read(r,n)[0]})}function T(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function te(e,r){if(!T(e))throw new Error(r!=null?r:"Expected a fixed-size codec, got a variable-size one.")}function yr(e){return !T(e)}function C(e,r){if(T(e)!==T(r))throw new Error("Encoder and decoder must either both be fixed-size or variable-size.");if(T(e)&&T(r)&&e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(!T(e)&&!T(r)&&e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);return {...r,...e,decode:r.decode,encode:e.encode,read:r.read,write:e.write}}function W(e,r){return g({fixedSize:r,write:(n,t,o)=>{let s=e.encode(n),i=s.length>r?s.slice(0,r):s;return t.set(i,o),o+r}})}function P(e,r){return p({fixedSize:r,read:(n,t)=>{v("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),T(e)&&(n=Tr(n,e.fixedSize));let[o]=e.read(n,0);return [o,t+r]}})}function z(e,r){return g({...yr(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(r(n))}:e,write:(n,t,o)=>e.write(r(n),t,o)})}function k(e,r){return p({...e,read:(n,t)=>{let[o,s]=e.read(n,t);return [r(o,n,t),s]}})}function Se(e,r,n,t){if(t<r||t>n)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${n}], got ${t}.`)}function Ee(e){return (e==null?void 0:e.endian)!==1}function Ie(e){return g({fixedSize:e.size,write(r,n,t){e.range&&Se(e.name,e.range[0],e.range[1],r);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),r,Ee(e.config)),n.set(new Uint8Array(o),t),t+e.size}})}function xe(e){return p({fixedSize:e.size,read(r,n=0){R(e.name,r,n),v(e.name,e.size,r,n);let t=new DataView(Ar(r,n,e.size));return [e.get(t,Ee(e.config)),n+e.size]}})}function Ar(e,r,n){let t=e.byteOffset+(r!=null?r:0),o=n!=null?n:e.byteLength;return e.buffer.slice(t,t+o)}var y=()=>g({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,r,n)=>{Se("shortU16",0,65535,e);let t=[0];for(let o=0;;o+=1){let s=e>>o*7;if(s===0)break;let i=127&s;t[o]=i,o>0&&(t[o-1]|=128);}return r.set(t,n),n+t.length}}),A=()=>p({maxSize:3,read:(e,r)=>{let n=0,t=0;for(;++t;){let o=t-1,s=e[r+o],i=127&s;if(n|=i<<o*7,!(s&128))break}return [n,r+t]}});var _=(e={})=>Ie({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,n,t)=>r.setUint32(0,n,t),size:4}),$=(e={})=>xe({config:e,get:(r,n)=>r.getUint32(0,n),name:"u32",size:4});var B=()=>Ie({name:"u8",range:[0,+"0xff"],set:(e,r)=>e.setUint8(0,r),size:1}),D=()=>xe({get:e=>e.getUint8(0),name:"u8",size:1});function hr(e,r,n=r){if(!r.match(new RegExp(`^[${e}]*$`)))throw new Error(`Expected a string of base ${e.length}, got [${n}].`)}var br=e=>g({getSizeFromValue:r=>{let[n,t]=Ce(r,e[0]);if(t==="")return r.length;let o=we(t,e);return n.length+Math.ceil(o.toString(16).length/2)},write(r,n,t){if(hr(e,r),r==="")return t;let[o,s]=Ce(r,e[0]);if(s==="")return n.set(new Uint8Array(o.length).fill(0),t),t+o.length;let i=we(s,e),a=[];for(;i>0n;)a.unshift(Number(i%256n)),i/=256n;let d=[...Array(o.length).fill(0),...a];return n.set(d,t),t+d.length}}),Sr=e=>p({read(r,n){let t=n===0?r:r.slice(n);if(t.length===0)return ["",0];let o=t.findIndex(d=>d!==0);o=o===-1?t.length:o;let s=e[0].repeat(o);if(o===t.length)return [s,r.length];let i=t.slice(o).reduce((d,c)=>d*256n+BigInt(c),0n),a=Er(i,e);return [s+a,r.length]}});function Ce(e,r){let n=[...e].findIndex(t=>t!==r);return n===-1?[e,""]:[e.slice(0,n),e.slice(n)]}function we(e,r){let n=BigInt(r.length);return [...e].reduce((t,o)=>t*n+BigInt(r.indexOf(o)),0n)}function Er(e,r){let n=BigInt(r.length),t=[];for(;e>0n;)t.unshift(r[Number(e%n)]),e/=n;return t.join("")}var Be="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",M=()=>br(Be),F=()=>Sr(Be);var De=()=>p({read(e,r=0){let n=e.slice(r);return [btoa(String.fromCharCode(...n)),e.length]}});var Ir=e=>e.replace(/\u0000/g,"");var xr=globalThis.TextDecoder,ze=globalThis.TextEncoder,Cr=()=>{let e;return g({getSizeFromValue:r=>(e||(e=new ze)).encode(r).length,write:(r,n,t)=>{let o=(e||(e=new ze)).encode(r);return n.set(o,t),t+o.length}})},wr=()=>{let e;return p({read(r,n){let t=(e||(e=new xr)).decode(r.slice(n));return [Ir(t),r.length]}})};function H(e={}){var t,o;let r=(t=e.size)!=null?t:_(),n=(o=e.encoding)!=null?o:Cr();return r==="variable"?n:typeof r=="number"?W(n,r):g({getSizeFromValue:s=>{let i=x(s,n);return x(i,r)+i},write:(s,i,a)=>{let d=x(s,n);return a=r.write(d,i,a),n.write(s,i,a)}})}function K(e={}){var t,o;let r=(t=e.size)!=null?t:$(),n=(o=e.encoding)!=null?o:wr();return r==="variable"?n:typeof r=="number"?P(n,r):p({read:(s,i=0)=>{R("string",s,i);let[a,d]=r.read(s,i),c=Number(a);i=d;let l=s.slice(i,i+c);v("string",c,l);let[I,ne]=n.read(l,0);return i+=ne,[I,i]}})}function N(e){if("signatures"in e){let{signatures:r,...n}=e;return n}else return e}var oe;function zr(e){oe||(oe=M());try{if(e.length<32||e.length>44)throw new Error("Expected input string to decode to a byte array of length 32.");let n=oe.encode(e).byteLength;if(n!==32)throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${n}`)}catch(r){throw new Error(`\`${e}\` is not a blockhash`,{cause:r})}}function Br(e){if(!("lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"))return !1;try{return zr(e.lifetimeConstraint.blockhash),!0}catch{return !1}}function un(e){if(!Br(e))throw new Error("Transaction does not have a blockhash lifetime")}function Ne(e,r){if("lifetimeConstraint"in r&&r.lifetimeConstraint.blockhash===e.blockhash&&r.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight)return r;let n={...N(r),lifetimeConstraint:e};return Object.freeze(n),n}function ve({version:e}){let r={instructions:[],version:e};return Object.freeze(r),r}var m=(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))(m||{});var Dr=1;function h(e){return e>=2}function L(e){return (e&Dr)!==0}function ie(e,r){return e|r}var Le="SysvarRecentB1ockHashes11111111111111111111",Re="11111111111111111111111111111111";function wn(e){if(!Me(e))throw new Error("Transaction is not a durable nonce transaction")}function ke(e,r){return {accounts:[{address:e,role:m.WRITABLE},{address:Le,role:m.READONLY},{address:r,role:m.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Re}}function Y(e){var r;return e.programAddress===Re&&e.data!=null&&Nr(e.data)&&((r=e.accounts)==null?void 0:r.length)===3&&e.accounts[0].address!=null&&e.accounts[0].role===m.WRITABLE&&e.accounts[1].address===Le&&e.accounts[1].role===m.READONLY&&e.accounts[2].address!=null&&h(e.accounts[2].role)}function Nr(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Me(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Y(e.instructions[0])}function vr(e,r,n){return e.accounts[0].address===r&&e.accounts[2].address===n}function Fe({nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:n},t){let o,s=t.instructions[0];if(s&&Y(s))if(vr(s,r,n)){if(Me(t)&&t.lifetimeConstraint.nonce===e)return t;o=[s,...t.instructions.slice(1)];}else o=[ke(r,n),...t.instructions.slice(1)];else o=[ke(r,n),...t.instructions];let i={...N(t),instructions:o,lifetimeConstraint:{nonce:e}};return Object.freeze(i),i}function Ve(e,r){if("feePayer"in r&&e===r.feePayer)return r;let n={...N(r),feePayer:e};return Object.freeze(n),n}function Ue(e,r){let n={...N(r),instructions:[...r.instructions,e]};return Object.freeze(n),n}function Ln(e,r){let n={...N(r),instructions:[e,...r.instructions]};return Object.freeze(n),n}function Oe(){if(!globalThis.isSecureContext)throw new Error("Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts")}async function We(){var e;if(Oe(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.exportKey)!="function")throw new Error("No key export implementation could be found")}async function Pe(){var e;if(Oe(),typeof globalThis.crypto>"u"||typeof((e=globalThis.crypto.subtle)==null?void 0:e.sign)!="function")throw new Error("No signing implementation could be found")}var se,ae;function _e(){return se||(se=M()),se}function kr(){return ae||(ae=F()),ae}function j(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=_e().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 Lr(e){return j(e),e}function G(){return z(H({encoding:_e(),size:32}),e=>Lr(e))}function V(){return K({encoding:kr(),size:32})}function U(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}async function $e(e){if(await We(),e.type!=="public"||e.algorithm.name!=="Ed25519")throw new Error("The `CryptoKey` must be an `Ed25519` public key");let r=await crypto.subtle.exportKey("raw",e);return V().decode(new Uint8Array(r))}function He(e,r,n){var t;e[r]=n((t=e[r])!=null?t:{role:m.READONLY});}var f=Symbol("AddressMapTypeProperty");function Ke(e,r){let n={[e]:{[f]:0,role:m.WRITABLE_SIGNER}},t=new Set;for(let o of r){He(n,o.programAddress,i=>{if(t.add(o.programAddress),f in i){if(L(i.role))switch(i[f]){case 0:throw new Error(`This transaction includes an address (\`${o.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`);default:throw new Error(`This transaction includes an address (\`${o.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`)}if(i[f]===2)return i}return {[f]:2,role:m.READONLY}});let s;if(o.accounts)for(let i of o.accounts)He(n,i.address,a=>{let{address:d,...c}=i;if(f in a)switch(a[f]){case 0:return a;case 1:{let l=ie(a.role,c.role);if("lookupTableAddress"in c){if(a.lookupTableAddress!==c.lookupTableAddress&&(s||(s=U()))(c.lookupTableAddress,a.lookupTableAddress)<0)return {[f]:1,...c,role:l}}else if(h(c.role))return {[f]:2,role:l};return a.role!==l?{...a,role:l}:a}case 2:{let l=ie(a.role,c.role);if(t.has(i.address)){if(L(c.role))throw new Error(`This transaction includes an address (\`${i.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`);return a.role!==l?{...a,role:l}:a}else return "lookupTableAddress"in c&&!h(a.role)?{...c,[f]:1,role:l}:a.role!==l?{...a,role:l}:a}}return "lookupTableAddress"in c?{...c,[f]:1}:{...c,[f]:2}});}return n}function Ye(e){let r;return Object.entries(e).sort(([t,o],[s,i])=>{if(o[f]!==i[f]){if(o[f]===0)return -1;if(i[f]===0)return 1;if(o[f]===2)return -1;if(i[f]===2)return 1}let a=h(o.role);if(a!==h(i.role))return a?-1:1;let d=L(o.role);return d!==L(i.role)?d?-1:1:(r||(r=U()),o[f]===1&&i[f]===1&&o.lookupTableAddress!==i.lookupTableAddress?r(o.lookupTableAddress,i.lookupTableAddress):r(t,s))}).map(([t,o])=>({address:t,...o}))}function je(e){var n;let r={};for(let t of e){if(!("lookupTableAddress"in t))continue;let o=r[n=t.lookupTableAddress]||(r[n]={readableIndices:[],writableIndices:[]});t.role===m.WRITABLE?o.writableIndices.push(t.addressIndex):o.readableIndices.push(t.addressIndex);}return Object.keys(r).sort(U()).map(t=>({lookupTableAddress:t,...r[t]}))}function Ge(e){let r=0,n=0,t=0;for(let o of e){if("lookupTableAddress"in o)break;let s=L(o.role);h(o.role)?(t++,s||n++):s||r++;}return {numReadonlyNonSignerAccounts:r,numReadonlySignerAccounts:n,numSignerAccounts:t}}function Rr(e){let r={};for(let[n,t]of e.entries())r[t.address]=n;return r}function qe(e,r){let n=Rr(r);return e.map(({accounts:t,data:o,programAddress:s})=>({programAddressIndex:n[s],...t?{accountIndices:t.map(({address:i})=>n[i])}:null,...o?{data:o}:null}))}function Xe(e){return "nonce"in e?e.nonce:e.blockhash}function Ze(e){let r=e.findIndex(t=>"lookupTableAddress"in t);return (r===-1?e:e.slice(0,r)).map(({address:t})=>t)}function q(e){let r=Ke(e.feePayer,e.instructions),n=Ye(r);return {...e.version!=="legacy"?{addressTableLookups:je(n)}:null,header:Ge(n),instructions:qe(e.instructions,n),lifetimeToken:Xe(e.lifetimeConstraint),staticAccounts:Ze(n),version:e.version}}function Mr(e,r,n){if(r!==n)throw new Error(`Expected [${e}] to have ${r} items, got ${n}.`)}function X(e){return e.reduce((r,n)=>r===null||n===null?null:r+n,0)}function J(e){return T(e)?e.fixedSize:null}function Q(e){var r;return T(e)?e.fixedSize:(r=e.maxSize)!=null?r:null}function b(e,r={}){var s,i;let n=(s=r.size)!=null?s:_();n==="remainder"&&te(e,'Codecs of "remainder" size must have fixed-size items.');let t=Z(n,J(e)),o=(i=Z(n,Q(e)))!=null?i:void 0;return g({...t!==null?{fixedSize:t}:{getSizeFromValue:a=>(typeof n=="object"?x(a.length,n):0)+[...a].reduce((c,l)=>c+x(l,e),0),maxSize:o},write:(a,d,c)=>(typeof n=="number"&&Mr("array",n,a.length),typeof n=="object"&&(c=n.write(a.length,d,c)),a.forEach(l=>{c=e.write(l,d,c);}),c)})}function S(e,r={}){var i,a;let n=(i=r.size)!=null?i:$();n==="remainder"&&te(e,'Codecs of "remainder" size must have fixed-size items.');let t=J(e),o=Z(n,t),s=(a=Z(n,Q(e)))!=null?a:void 0;return p({...o!==null?{fixedSize:o}:{maxSize:s},read:(d,c)=>{let l=[];if(typeof n=="object"&&d.slice(c).length===0)return [l,c];let[I,ne]=Fr(n,t,d,c);c=ne;for(let be=0;be<I;be+=1){let[gr,mr]=e.read(d,c);c=mr,l.push(gr);}return [l,c]}})}function Fr(e,r,n,t){if(typeof e=="number")return [e,t];if(typeof e=="object")return e.read(n,t);if(e==="remainder"){if(r===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');let o=Math.max(0,n.length-t);if(o%r!==0)throw new Error(`The remainder of the byte array (${o} bytes) cannot be split into chunks of ${r} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${o} modulo ${r} should be equal to zero.`);return [o/r,t]}throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(e)}`)}function Z(e,r){return typeof e!="number"?null:e===0?0:r===null?null:r*e}function ee(e={}){var t;let r=(t=e.size)!=null?t:"variable",n=g({getSizeFromValue:o=>o.length,write:(o,s,i)=>(s.set(o,i),i+o.length)});return r==="variable"?n:typeof r=="number"?W(n,r):g({getSizeFromValue:o=>x(o.length,r)+o.length,write:(o,s,i)=>(i=r.write(o.length,s,i),n.write(o,s,i))})}function re(e={}){var t;let r=(t=e.size)!=null?t:"variable",n=p({read:(o,s)=>{let i=o.slice(s);return [i,s+i.length]}});return r==="variable"?n:typeof r=="number"?P(n,r):p({read:(o,s)=>{R("bytes",o,s);let[i,a]=r.read(o,s),d=Number(i);s=a;let c=o.slice(s,s+d);v("bytes",d,c);let[l,I]=n.read(c,0);return s+=I,[l,s]}})}function E(e){var o;let r=e.map(([,s])=>s),n=X(r.map(J)),t=(o=X(r.map(Q)))!=null?o:void 0;return g({...n===null?{getSizeFromValue:s=>e.map(([i,a])=>x(s[i],a)).reduce((i,a)=>i+a,0),maxSize:t}:{fixedSize:n},write:(s,i,a)=>(e.forEach(([d,c])=>{a=c.write(s[d],i,a);}),a)})}function w(e){var o;let r=e.map(([,s])=>s),n=X(r.map(J)),t=(o=X(r.map(Q)))!=null?o:void 0;return p({...n===null?{maxSize:t}:{fixedSize:n},read:(s,i)=>{let a={};return e.forEach(([d,c])=>{let[l,I]=c.read(s,i);i=I,a[d]=l;}),[a,i]}})}var ce;function Je(){return ce||(ce=E([["lookupTableAddress",G()],["writableIndices",b(B(),{size:y()})],["readableIndices",b(B(),{size:y()})]])),ce}var de;function Qe(){return de||(de=w([["lookupTableAddress",V()],["writableIndices",S(D(),{size:A()})],["readableIndices",S(D(),{size:A()})]])),de}var ue;function le(){return ue||(ue=B()),ue}var fe;function ge(){return fe||(fe=D()),fe}function er(){return E([["numSignerAccounts",le()],["numReadonlySignerAccounts",le()],["numReadonlyNonSignerAccounts",le()]])}function rr(){return w([["numSignerAccounts",ge()],["numReadonlySignerAccounts",ge()],["numReadonlyNonSignerAccounts",ge()]])}var me;function nr(){return me||(me=z(E([["programAddressIndex",B()],["accountIndices",b(B(),{size:y()})],["data",ee({size:y()})]]),e=>{var r,n;return e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:(r=e.accountIndices)!=null?r:[],data:(n=e.data)!=null?n:new Uint8Array(0)}})),me}var pe;function tr(){return pe||(pe=k(w([["programAddressIndex",D()],["accountIndices",S(D(),{size:A()})],["data",re({size:A()})]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:r,data:n,...t}=e;return {...t,...r.length?{accountIndices:r}:null,...n.byteLength?{data:n}:null}})),pe}var Te=128;function or(){return g({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,r,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new Error(`Transaction version must be in the range [0, 127]. \`${e}\` given.`);return r.set([e|Te],n),n+1}})}function ir(){return p({maxSize:1,read:(e,r)=>{let n=e[r];return n&Te?[n^Te,r+1]:["legacy",r]}})}function sr(){return E(cr())}function ar(){return z(E([...cr(),["addressTableLookups",Ur()]]),e=>{var r;return e.version==="legacy"?e:{...e,addressTableLookups:(r=e.addressTableLookups)!=null?r:[]}})}function cr(){return [["version",or()],["header",er()],["staticAccounts",b(G(),{size:y()})],["lifetimeToken",H({encoding:M(),size:32})],["instructions",b(nr(),{size:y()})]]}function Vr(){return [["version",ir()],["header",rr()],["staticAccounts",S(V(),{size:A()})],["lifetimeToken",K({encoding:F(),size:32})],["instructions",S(tr(),{size:A()})],["addressTableLookups",Or()]]}function Ur(){return b(Je(),{size:y()})}function Or(){return S(Qe(),{size:A()})}function O(){return g({getSizeFromValue:e=>e.version==="legacy"?sr().getSizeFromValue(e):ar().getSizeFromValue(e),write:(e,r,n)=>e.version==="legacy"?sr().write(e,r,n):ar().write(e,r,n)})}function ye(){return k(w(Vr()),({addressTableLookups:e,...r})=>r.version==="legacy"||!(e!=null&&e.length)?r:{...r,addressTableLookups:e})}function yo(){return C(O(),ye())}function dr(e){var t;let r=q(e),n;if("signatures"in e){n=[];for(let o=0;o<r.header.numSignerAccounts;o++)n[o]=(t=e.signatures[r.staticAccounts[o]])!=null?t:new Uint8Array(Array(64).fill(0));}else n=Array(r.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));return {compiledMessage:r,signatures:n}}function ur(e,...r){return r.reduce((n,t)=>t(n),e)}function Wr(e){let{header:r}=e,n=r.numSignerAccounts-r.numReadonlySignerAccounts,t=e.staticAccounts.length-r.numSignerAccounts-r.numReadonlyNonSignerAccounts,o=[],s=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[s],role:m.WRITABLE_SIGNER}),s++;for(let i=0;i<r.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[s],role:m.READONLY_SIGNER}),s++;for(let i=0;i<t;i++)o.push({address:e.staticAccounts[s],role:m.WRITABLE}),s++;for(let i=0;i<r.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[s],role:m.READONLY}),s++;return o}function Pr(e,r){var s,i;let n=(s=r[e.programAddressIndex])==null?void 0:s.address;if(!n)throw new Error(`Could not find program address at index ${e.programAddressIndex}`);let t=(i=e.accountIndices)==null?void 0:i.map(a=>r[a]),{data:o}=e;return {programAddress:n,...t&&t.length?{accounts:t}:{},...o&&o.length?{data:o}:{}}}function _r(e,r,n){if(!r||!Y(r))return {blockhash:e,lastValidBlockHeight:n!=null?n:2n**64n-1n};{let t=r.accounts[0].address;j(t);let o=r.accounts[2].address;return j(o),{nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:o}}}function $r(e){let{compiledMessage:{staticAccounts:r},signatures:n}=e;return n.reduce((t,o,s)=>{if(o.every(d=>d===0))return t;let a=r[s];return {...t,[a]:o}},{})}function lr(e,r){let{compiledMessage:n}=e;if("addressTableLookups"in n&&n.addressTableLookups.length>0)throw new Error("Cannot convert transaction with addressTableLookups");let t=n.staticAccounts[0];if(!t)throw new Error("No fee payer set in CompiledTransaction");let o=Wr(n),s=n.instructions.map(c=>Pr(c,o)),i=s[0],a=_r(n.lifetimeToken,i,r),d=$r(e);return ur(ve({version:n.version}),c=>Ve(t,c),c=>s.reduce((l,I)=>Ue(I,l),c),c=>"blockhash"in a?Ne(a,c):Fe(a,c),c=>e.signatures.length?{...c,signatures:d}:c)}function Hr(){return E([["signatures",b(ee({size:64}),{size:y()})],["compiledMessage",O()]])}function Kr(){return w([["signatures",S(re({size:64}),{size:A()})],["compiledMessage",ye()]])}function Ae(){return z(Hr(),dr)}function Yr(e){return k(Kr(),r=>lr(r,e))}function Jo(e){return C(Ae(),Yr(e))}async function fr(e,r){await Pe();let n=await crypto.subtle.sign("Ed25519",e,r);return new Uint8Array(n)}var he;function pi(e){he||(he=F());let r=e.signatures[e.feePayer];if(!r)throw new Error("Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.");return he.decode(r)}async function jr(e,r){let n=q(r),t="signatures"in r?{...r.signatures}:{},o=O().encode(n),s=await Promise.all(e.map(a=>Promise.all([$e(a.publicKey),fr(a.privateKey,o)])));for(let[a,d]of s)t[a]=d;let i={...r,signatures:t};return Object.freeze(i),i}async function Ti(e,r){let n=await jr(e,r);return Gr(n),Object.freeze(n),n}function Gr(e){let r=e.instructions.flatMap(t=>{var o,s;return (s=(o=t.accounts)==null?void 0:o.filter(i=>h(i.role)))!=null?s:[]}).map(t=>t.address);new Set([e.feePayer,...r]).forEach(t=>{if(!e.signatures[t])throw new Error(`Transaction is missing signature for address \`${t}\``)});}function Si(e){let r=Ae().encode(e);return De().decode(r)}
|
|
6
|
-
|
|
7
|
-
exports.appendTransactionInstruction = Ue;
|
|
8
|
-
exports.assertIsBlockhash = zr;
|
|
9
|
-
exports.assertIsDurableNonceTransaction = wn;
|
|
10
|
-
exports.assertIsTransactionWithBlockhashLifetime = un;
|
|
11
|
-
exports.assertTransactionIsFullySigned = Gr;
|
|
12
|
-
exports.compileMessage = q;
|
|
13
|
-
exports.createTransaction = ve;
|
|
14
|
-
exports.getBase64EncodedWireTransaction = Si;
|
|
15
|
-
exports.getCompiledMessageCodec = yo;
|
|
16
|
-
exports.getCompiledMessageDecoder = ye;
|
|
17
|
-
exports.getCompiledMessageEncoder = O;
|
|
18
|
-
exports.getSignatureFromTransaction = pi;
|
|
19
|
-
exports.getTransactionCodec = Jo;
|
|
20
|
-
exports.getTransactionDecoder = Yr;
|
|
21
|
-
exports.getTransactionEncoder = Ae;
|
|
22
|
-
exports.isAdvanceNonceAccountInstruction = Y;
|
|
23
|
-
exports.partiallySignTransaction = jr;
|
|
24
|
-
exports.prependTransactionInstruction = Ln;
|
|
25
|
-
exports.setTransactionFeePayer = Ve;
|
|
26
|
-
exports.setTransactionLifetimeUsingBlockhash = Ne;
|
|
27
|
-
exports.setTransactionLifetimeUsingDurableNonce = Fe;
|
|
28
|
-
exports.signTransaction = Ti;
|
|
29
|
-
|
|
30
|
-
return exports;
|
|
31
|
-
|
|
32
|
-
})({});
|