@solana/codecs-core 8.5.0 → 8.5.1-canary-20261021065018

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.
@@ -112,7 +112,10 @@ function combineCodec(encoder, decoder) {
112
112
  function addEncoderSentinel(encoder, sentinel) {
113
113
  const write = ((value, bytes, offset) => {
114
114
  const encoderBytes = encoder.encode(value);
115
- if (findSentinelIndex(encoderBytes, sentinel) >= 0) {
115
+ const encoderBytesWithSentinel = new Uint8Array(encoderBytes.length + sentinel.length);
116
+ encoderBytesWithSentinel.set(encoderBytes);
117
+ encoderBytesWithSentinel.set(sentinel, encoderBytes.length);
118
+ if (findSentinelIndex(encoderBytesWithSentinel, sentinel) < encoderBytes.length) {
116
119
  throw new errors.SolanaError(errors.SOLANA_ERROR__CODECS__ENCODED_BYTES_MUST_NOT_INCLUDE_SENTINEL, {
117
120
  encodedBytes: encoderBytes,
118
121
  hexEncodedBytes: hexBytes(encoderBytes),
@@ -120,11 +123,8 @@ function addEncoderSentinel(encoder, sentinel) {
120
123
  sentinel
121
124
  });
122
125
  }
123
- bytes.set(encoderBytes, offset);
124
- offset += encoderBytes.length;
125
- bytes.set(sentinel, offset);
126
- offset += sentinel.length;
127
- return offset;
126
+ bytes.set(encoderBytesWithSentinel, offset);
127
+ return offset + encoderBytesWithSentinel.length;
128
128
  });
129
129
  if (isFixedSize(encoder)) {
130
130
  return createEncoder({ ...encoder, fixedSize: encoder.fixedSize + sentinel.length, write });