From 808f1b362bd2275424cf93ac6333049cde90216e Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Tue, 12 Dec 2023 10:20:43 -0500 Subject: [PATCH] fix: Rename JSONURLDataToEncode --- src/lib/encoder.test.ts | 4 ++-- src/lib/encoder.ts | 6 +++--- src/lib/utils.ts | 16 ++++++++-------- src/types/encodeData/JSONURL.ts | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/encoder.test.ts b/src/lib/encoder.test.ts index a9c361be..6ddb3c86 100644 --- a/src/lib/encoder.test.ts +++ b/src/lib/encoder.test.ts @@ -35,7 +35,7 @@ import { SUPPORTED_VERIFICATION_METHOD_HASHES, SUPPORTED_VERIFICATION_METHOD_STRINGS, } from '../constants/constants'; -import { JSONURLDataToEncode, URLDataWithHash } from '../types'; +import { URLDataToEncode, URLDataWithHash } from '../types'; describe('encoder', () => { describe('valueType', () => { @@ -947,7 +947,7 @@ describe('encoder', () => { }); it('encodes/decodes: JSONURL', () => { - const dataToEncode: JSONURLDataToEncode = { + const dataToEncode: URLDataToEncode = { url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx', json: { myProperty: 'is a string', diff --git a/src/lib/encoder.ts b/src/lib/encoder.ts index 99f6e8c9..44c4d979 100644 --- a/src/lib/encoder.ts +++ b/src/lib/encoder.ts @@ -44,7 +44,7 @@ import { toBN, } from 'web3-utils'; -import { JSONURLDataToEncode, URLDataWithHash, Verification } from '../types'; +import { URLDataToEncode, URLDataWithHash, Verification } from '../types'; import { AssetURLEncode } from '../types/encodeData'; import { @@ -687,7 +687,7 @@ export const valueContentEncodingMap = ( case 'VerifiableURL': { return { type: 'custom', - encode: (dataToEncode: JSONURLDataToEncode) => { + encode: (dataToEncode: URLDataToEncode) => { const { verification: { data, method } = {}, json, @@ -859,7 +859,7 @@ export function decodeValueType( export function encodeValueContent( valueContent: string, - value: string | number | AssetURLEncode | JSONURLDataToEncode | boolean, + value: string | number | AssetURLEncode | URLDataToEncode | boolean, ): string | false { if (valueContent.slice(0, 2) === '0x') { return valueContent === value ? value : false; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 7024068f..20899de3 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -29,7 +29,7 @@ import { import { arrToBufArr } from 'ethereumjs-util'; import { - JSONURLDataToEncode, + URLDataToEncode, EncodeDataReturn, URLDataWithHash, Verification, @@ -77,8 +77,8 @@ export function encodeKeyValue( | string[] | number | number[] - | JSONURLDataToEncode - | JSONURLDataToEncode[] + | URLDataToEncode + | URLDataToEncode[] | boolean, name?: string, ): string | false { @@ -176,7 +176,7 @@ export function guessKeyTypeFromKeyName( export const encodeTupleKeyValue = ( valueContent: string, // i.e. (bytes4,Number,bytes16) valueType: string, // i.e. (bytes4,bytes8,bytes16) - decodedValues: Array, + decodedValues: Array, ) => { // We assume data has already been validated at this stage @@ -239,8 +239,8 @@ export function encodeKey( | number | (string | number)[] | string[][] - | JSONURLDataToEncode - | JSONURLDataToEncode[] + | URLDataToEncode + | URLDataToEncode[] | boolean, ) { // NOTE: This will not guarantee order of array as on chain. Assumes developer must set correct order @@ -340,8 +340,8 @@ export function encodeKey( | string[] | number | number[] - | JSONURLDataToEncode - | JSONURLDataToEncode[], + | URLDataToEncode + | URLDataToEncode[], schema.name, ); default: diff --git a/src/types/encodeData/JSONURL.ts b/src/types/encodeData/JSONURL.ts index 4948cdc9..440e6f72 100644 --- a/src/types/encodeData/JSONURL.ts +++ b/src/types/encodeData/JSONURL.ts @@ -25,12 +25,12 @@ export interface URLDataWithJson extends URLData { json: Record; } -export type JSONURLDataToEncode = URLDataWithHash | URLDataWithJson; +export type URLDataToEncode = URLDataWithHash | URLDataWithJson; export type EncodeDataType = | string | string[] - | JSONURLDataToEncode + | URLDataToEncode | boolean | number;