diff --git a/src/_type_test.ts b/src/_type_test.ts
index 4e9af7c..8cd30fd 100644
--- a/src/_type_test.ts
+++ b/src/_type_test.ts
@@ -70,7 +70,7 @@ assertType
);
// NOTE: U256 is bigint by default, but we can cast it to number
assertType>(
- P.tag(P.apply(P.U256BE, P.coders.number), { 1: P.cstring, 2: P.bool })
+ P.tag(P.apply(P.U256BE, P.coders.numberBigint), { 1: P.cstring, 2: P.bool })
);
// MappedTag
assertType>(
@@ -113,7 +113,7 @@ assertType>(e);
// match
assertType>>(
- P.coders.match([P.coders.number, P.coders.dict()])
+ P.coders.match([P.coders.numberBigint, P.coders.dict()])
);
const m1: base.Coder = 1 as any;
diff --git a/src/index.ts b/src/index.ts
index 4b6dd80..8d707ba 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,18 +1,6 @@
import type { Coder as BaseCoder } from '@scure/base';
import { hex as baseHex, utf8 } from '@scure/base';
-// copied from scure-base
-// export interface BCoder {
-// encode(from: F): T;
-// decode(to: T): F;
-// }
-// declare const TextEncoder: any;
-// declare const TextDecoder: any;
-// const utf8: BytesCoder = {
-// encode: (data) => new TextDecoder().decode(data),
-// decode: (str) => new TextEncoder().encode(str),
-// };
-
/**
* Define complex binary structures using composable primitives.
* Main ideas:
@@ -35,6 +23,8 @@ import { hex as baseHex, utf8 } from '@scure/base';
* });
*/
+// TODO: remove dependency on scure-base & inline?
+
/**
* Shortcut to zero-length (empty) byte array
*/
@@ -104,7 +94,6 @@ export const utils = {
equalBytes,
isBytes,
isCoder,
- checkBounds,
concatBytes,
createView,
isPlainObject,
@@ -1186,7 +1175,7 @@ export const int = (size: number, le = false, signed = false, sized = true): Cod
if (typeof sized !== 'boolean')
throw new Error(`int/sized: expected boolean, got ${typeof sized}`);
if (size > 6) throw new Error('int supports size up to 6 bytes (48 bits): use bigints instead');
- return apply(bigint(size, le, signed, sized), coders.number);
+ return apply(bigint(size, le, signed, sized), coders.numberBigint);
};
type ViewCoder = {
diff --git a/test/debugger.test.js b/test/debugger.test.js
index 3474b5b..4efc14d 100644
--- a/test/debugger.test.js
+++ b/test/debugger.test.js
@@ -55,7 +55,7 @@ should('PSBT1', () => {
return num;
},
});
- const CompactSizeLen = P.apply(CompactSize, P.coders.number);
+ const CompactSizeLen = P.apply(CompactSize, P.coders.numberBigint);
const PKey = P.struct({ type: CompactSizeLen, data: P.bytes(null) });
const PSBTKeyPair = P.array(
P.NULL,
diff --git a/test/index.js b/test/index.js
index ce0807e..f84c0af 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1121,9 +1121,9 @@ describe('structures', () => {
describe('coders', () => {
should('number', () => {
- deepStrictEqual(P.coders.number.encode(1000n), 1000);
- deepStrictEqual(P.coders.number.encode(9007199254740991n), 9007199254740991);
- throws(() => P.coders.number.encode(9007199254740992n));
+ deepStrictEqual(P.coders.numberBigint.encode(1000n), 1000);
+ deepStrictEqual(P.coders.numberBigint.encode(9007199254740991n), 9007199254740991);
+ throws(() => P.coders.numberBigint.encode(9007199254740992n));
});
should('decimal', () => {