From c82ad616574c302569aad879a839b6e516d00c95 Mon Sep 17 00:00:00 2001 From: Ankit Kokane Date: Sun, 28 Sep 2025 02:24:06 +0530 Subject: [PATCH 1/2] added content hash for walrus --- README.md | 1 + src/map.ts | 2 ++ src/profiles.ts | 7 +++++++ tsconfig.base.json | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6bab99..4163b43 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ - `onion3` - `skynet` - `arweave` +- `walrus` ## 📥 Install diff --git a/src/map.ts b/src/map.ts index 7103314..0c404a0 100644 --- a/src/map.ts +++ b/src/map.ts @@ -6,6 +6,7 @@ export const codeToName = { 0x01bd: "onion3", 0xb19910: "skynet", 0xb29910: "arweave", + 0xb59910: "walrus", } as const; export const nameToCode = { @@ -16,6 +17,7 @@ export const nameToCode = { onion3: 0x01bd, skynet: 0xb19910, arweave: 0xb29910, + walrus: 0xb59910, } as const; export type CodecId = keyof typeof codeToName; diff --git a/src/profiles.ts b/src/profiles.ts index 8060f41..74dd4cf 100644 --- a/src/profiles.ts +++ b/src/profiles.ts @@ -114,6 +114,9 @@ const encodes = { arweave: (value: string): Bytes => { return base64Decode(value); }, + walrus: (value: string): Bytes => { + return base64Decode(value); + } }; /** @@ -183,6 +186,10 @@ export const profiles = { encode: encodes.arweave, decode: decodes.base64, }, + walrus: { + encode: encodes.walrus, + decode: decodes.base64, + }, default: { encode: encodes.utf8, decode: decodes.utf8, diff --git a/tsconfig.base.json b/tsconfig.base.json index 3be3fbb..1457290 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -31,7 +31,7 @@ "importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers. // Language and environment - "moduleResolution": "NodeNext", + "moduleResolution": "Node", "module": "ESNext", "target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. From cc23a61fe2ab5c7dc73766291ecb53f3783f8537 Mon Sep 17 00:00:00 2001 From: Ankit Kokane Date: Sun, 28 Sep 2025 07:51:03 +0530 Subject: [PATCH 2/2] updated for hex --- src/profiles.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/profiles.ts b/src/profiles.ts index 74dd4cf..c90f012 100644 --- a/src/profiles.ts +++ b/src/profiles.ts @@ -115,7 +115,7 @@ const encodes = { return base64Decode(value); }, walrus: (value: string): Bytes => { - return base64Decode(value); + return hexStringToBytes(value); } }; @@ -153,6 +153,9 @@ const decodes = { base64: (value: Bytes): string => { return base64url.encode(value).substring(1); }, + hex: (value: Bytes): string => { + return bytesToHexString(value); + }, }; export type Profile = { @@ -188,7 +191,7 @@ export const profiles = { }, walrus: { encode: encodes.walrus, - decode: decodes.base64, + decode: decodes.hex, }, default: { encode: encodes.utf8,