Skip to content

Commit

Permalink
Merge pull request #333 from kalote/feat/hash-function-rename
Browse files Browse the repository at this point in the history
renaming hashFunction
  • Loading branch information
CallumGrindle authored Nov 2, 2023
2 parents 1376391 + a7c60d0 commit 1a1170c
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 176 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ await myErc725.getData();
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x70546a2accab18748420b63c63b5af4cf710848ae83afc0c51dd8ad17fb5e8b3',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x70546a2accab18748420b63c63b5af4cf710848ae83afc0c51dd8ad17fb5e8b3',
url: 'ipfs://QmecrGejUQVXpW4zS948pNvcnQrJ1KiAoM6bdfrVcWZsn5',
},
},
Expand Down
46 changes: 24 additions & 22 deletions docs/classes/ERC725.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ myErc725.decodeData([
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
},
Expand All @@ -165,8 +165,8 @@ myErc725.decodeData({
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
}
Expand Down Expand Up @@ -206,8 +206,8 @@ myErc725.decodeData([
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
hashFunction: 'keccak256(utf8)',
verificationData: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
},
Expand Down Expand Up @@ -256,8 +256,8 @@ myErc725.decodeData(
name: 'MyKeyName:aaaabbbbccccddddeeeeffff111122223333444455556666777788889999aaaa:true',
key: '0x35e6950bc8d2aaaabbbb00000000000000000000000000000000000000000001',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ifps://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
},
Expand Down Expand Up @@ -479,8 +479,9 @@ myErc725.encodeData([
{
keyName: 'LSP3Profile',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData:
'0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
},
Expand Down Expand Up @@ -564,8 +565,9 @@ myErc725.encodeData([
{
keyName: 'LSP3Profile',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData:
'0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
},
Expand Down Expand Up @@ -1063,8 +1065,8 @@ await myErc725.getData();
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x70546a2accab18748420b63c63b5af4cf710848ae83afc0c51dd8ad17fb5e8b3',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x70546a2accab18748420b63c63b5af4cf710848ae83afc0c51dd8ad17fb5e8b3',
url: 'ipfs://QmecrGejUQVXpW4zS948pNvcnQrJ1KiAoM6bdfrVcWZsn5',
},
},
Expand All @@ -1081,8 +1083,8 @@ await myErc725.getData('LSP3Profile');
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
url: 'ipfs://QmbTmcbp8ZW23vkQrqkasMFqNg2z1iP4e3BCUMz9PKDsSV'
},
}
Expand All @@ -1095,8 +1097,8 @@ await myErc725.getData(['LSP3Profile']);
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
url: 'ipfs://QmbTmcbp8ZW23vkQrqkasMFqNg2z1iP4e3BCUMz9PKDsSV'
},
}
Expand All @@ -1123,8 +1125,8 @@ await myErc725.getData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xeeafeebeb416923dfb0dcf4c66b045c72742121ce2a06f93ae044ee0efb70777',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xeeafeebeb416923dfb0dcf4c66b045c72742121ce2a06f93ae044ee0efb70777',
url: 'ipfs://QmZnG5Z5B5Dq8iFFtsL5i7AnrgH16P4DJ8UhY7j8RzX51p'
}
},
Expand Down Expand Up @@ -1183,8 +1185,8 @@ await myErc725.getData([
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xeeafeebeb416923dfb0dcf4c66b045c72742121ce2a06f93ae044ee0efb70777',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xeeafeebeb416923dfb0dcf4c66b045c72742121ce2a06f93ae044ee0efb70777',
url: 'ipfs://QmZnG5Z5B5Dq8iFFtsL5i7AnrgH16P4DJ8UhY7j8RzX51p'
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ await erc725.getData(['LSP3Profile', 'SupportedStandards:LSP3Profile']);
{
LSP3Profile: {
url: 'ipfs://QmXybv2LdJWscy1C6yRKUjvnaj6aqKktZX4g4xmz2nyYj2',
hash: '0xb4f9d72e83bbe7e250ed9ec80332c493b7b3d73e0d72f7b2c7ab01c39216eb1a',
hashFunction: 'keccak256(utf8)'
verificationData: '0xb4f9d72e83bbe7e250ed9ec80332c493b7b3d73e0d72f7b2c7ab01c39216eb1a',
verificationFunction: 'keccak256(utf8)'
},
'SupportedStandards:LSP3Profile': '0x5ef83ad9'
}
Expand Down
8 changes: 4 additions & 4 deletions examples/src/decodeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const decodedDataOneKey = myERC725.decodeData([
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx'
}
}
Expand Down Expand Up @@ -56,8 +56,8 @@ const decodedDataManyKeys = myERC725.decodeData([
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx'
}
},
Expand Down
10 changes: 6 additions & 4 deletions examples/src/encodeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ const encodedDataOneKey = myERC725.encodeData({
const encodedDataOneKeyV2 = myERC725.encodeData({
keyName: 'LSP3Profile',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData:
'0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
});
Expand All @@ -45,8 +46,9 @@ const encodedDataManyKeys = myERC725.encodeData([
{
keyName: 'LSP3Profile',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
verificationFunction: 'keccak256(utf8)',
verificationData:
'0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx',
},
},
Expand Down
12 changes: 6 additions & 6 deletions examples/src/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const dataAllKeys = await myERC725.getData();
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
url: 'ipfs://QmbTmcbp8ZW23vkQrqkasMFqNg2z1iP4e3BCUMz9PKDsSV'
}
},
Expand Down Expand Up @@ -46,8 +46,8 @@ const dataOneKey = await myERC725.getData('LSP3Profile');
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
name: 'LSP3Profile',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
url: 'ipfs://QmbTmcbp8ZW23vkQrqkasMFqNg2z1iP4e3BCUMz9PKDsSV'
}
}
Expand All @@ -63,8 +63,8 @@ const dataManyKeys = await myERC725.getData([
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
name: 'LSP3Profile',
value: {
hashFunction: 'keccak256(utf8)',
hash: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
verificationFunction: 'keccak256(utf8)',
verificationData: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
url: 'ipfs://QmbTmcbp8ZW23vkQrqkasMFqNg2z1iP4e3BCUMz9PKDsSV'
}
},
Expand Down
40 changes: 24 additions & 16 deletions examples/src/instantiation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,59 +61,67 @@ export const profileJson = {
{
width: 1800,
height: 1712,
hashFunction: 'keccak256(bytes)',
hash: '0xfbcfcbbc86d886e862419361c48251d778884a90429d36c8d002559cbcb52972',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0xfbcfcbbc86d886e862419361c48251d778884a90429d36c8d002559cbcb52972',
url: 'ipfs://QmNPh6hP5igFzPf4mPtKBa6Wttnmi3YNVMAptC7drzyeDB',
},
{
width: 1024,
height: 974,
hashFunction: 'keccak256(bytes)',
hash: '0xa9399df007997de92a820c6c2ec1cb2d3f5aa5fc1adf294157de563eba39bb6e',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0xa9399df007997de92a820c6c2ec1cb2d3f5aa5fc1adf294157de563eba39bb6e',
url: 'ipfs://QmW4wM4r9yWeY1gUCtt7c6v3ve7Fzdg8CKvTS96NU9Uiwr',
},
{
width: 640,
height: 609,
hashFunction: 'keccak256(bytes)',
hash: '0xb316a695125cb0566da252266cfc9d5750a740bbdffa86712bb17508e70e6a31',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0xb316a695125cb0566da252266cfc9d5750a740bbdffa86712bb17508e70e6a31',
url: 'ipfs://QmXGELsqGidAHMwYRsEv6Z4emzMggtc5GXZYGFK7r6zFBg',
},
{
width: 320,
height: 304,
hashFunction: 'keccak256(bytes)',
hash: '0xd22a272ff5b257056cc302bcdcca1c0ea00bf912aef310eb3fa7556696b1e780',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0xd22a272ff5b257056cc302bcdcca1c0ea00bf912aef310eb3fa7556696b1e780',
url: 'ipfs://QmRr2urTVi12VzYa5cSHDjJXACfapaeGZW2BuNmQ8rHjCG',
},
{
width: 180,
height: 171,
hashFunction: 'keccak256(bytes)',
hash: '0xf80d0c1492de5e148392b3a724739682e9b9564ef5fb97c06c1574bbb5e5f340',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0xf80d0c1492de5e148392b3a724739682e9b9564ef5fb97c06c1574bbb5e5f340',
url: 'ipfs://QmVeFyhHtdXR34UZanqU2qSuBTfGtBraG7hhN5byjJNAY5',
},
],
backgroundImage: [
{
width: 1800,
height: 1013,
hashFunction: 'keccak256(bytes)',
hash: '0x98fe032f81c43426fbcfb21c780c879667a08e2a65e8ae38027d4d61cdfe6f55',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0x98fe032f81c43426fbcfb21c780c879667a08e2a65e8ae38027d4d61cdfe6f55',
url: 'ipfs://QmPJESHbVkPtSaHntNVY5F6JDLW8v69M2d6khXEYGUMn7N',
},
{
width: 1024,
height: 576,
hashFunction: 'keccak256(bytes)',
hash: '0xfce1c7436a77a009a97e48e4e10c92e89fd95fe1556fc5c62ecef57cea51aa37',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0xfce1c7436a77a009a97e48e4e10c92e89fd95fe1556fc5c62ecef57cea51aa37',
url: 'ipfs://QmZc9uMJxyUeUpuowJ7AD6MKoNTaWdVNcBj72iisRyM9Su',
},
{
width: 640,
height: 360,
hashFunction: 'keccak256(bytes)',
hash: '0x10a5cf2479992f1c555ad71e0a2866827f66fef6941a0c99f8d3b03e6b8b4009',
verificationFunction: 'keccak256(bytes)',
verificationData:
'0x10a5cf2479992f1c555ad71e0a2866827f66fef6941a0c99f8d3b03e6b8b4009',
url: 'ipfs://QmbP3eTmUx1UQ2eZ8hrDz8j98yP2CTmsJvfp72LZKnkKj1',
},
],
Expand Down
35 changes: 18 additions & 17 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,22 @@ export const METHODS: Record<Method, MethodData> = {
},
};

export enum SUPPORTED_HASH_FUNCTION_STRINGS {
export enum SUPPORTED_VERIFICATION_FUNCTION_STRINGS {
KECCAK256_UTF8 = 'keccak256(utf8)',
KECCAK256_BYTES = 'keccak256(bytes)',
}

export enum SUPPORTED_HASH_FUNCTION_HASHES {
export enum SUPPORTED_VERIFICATION_FUNCTION_HASHES {
HASH_KECCAK256_UTF8 = '0x6f357c6a',
HASH_KECCAK256_BYTES = '0x8019f9b1',
}

export type SUPPORTED_HASH_FUNCTIONS =
| SUPPORTED_HASH_FUNCTION_STRINGS
| SUPPORTED_HASH_FUNCTION_HASHES;
export type SUPPORTED_VERIFICATION_FUNCTIONS =
| SUPPORTED_VERIFICATION_FUNCTION_STRINGS
| SUPPORTED_VERIFICATION_FUNCTION_HASHES;

export const SUPPORTED_HASH_FUNCTIONS_LIST = Object.values(
SUPPORTED_HASH_FUNCTION_STRINGS,
export const SUPPORTED_VERIFICATION_FUNCTIONS_LIST = Object.values(
SUPPORTED_VERIFICATION_FUNCTION_STRINGS,
);

function keccak256Utf8(data) {
Expand All @@ -128,27 +128,28 @@ function keccak256Utf8(data) {

const KECCAK256_UTF8 = {
method: keccak256Utf8,
name: SUPPORTED_HASH_FUNCTION_STRINGS.KECCAK256_UTF8,
sig: SUPPORTED_HASH_FUNCTION_HASHES.HASH_KECCAK256_UTF8,
name: SUPPORTED_VERIFICATION_FUNCTION_STRINGS.KECCAK256_UTF8,
sig: SUPPORTED_VERIFICATION_FUNCTION_HASHES.HASH_KECCAK256_UTF8,
};

const KECCAK256_BYTES = {
method: keccak256,
name: SUPPORTED_HASH_FUNCTION_STRINGS.KECCAK256_BYTES,
sig: SUPPORTED_HASH_FUNCTION_HASHES.HASH_KECCAK256_BYTES,
name: SUPPORTED_VERIFICATION_FUNCTION_STRINGS.KECCAK256_BYTES,
sig: SUPPORTED_VERIFICATION_FUNCTION_HASHES.HASH_KECCAK256_BYTES,
};

export const HASH_FUNCTIONS: {
[key: string]: {
method: Function;
name: SUPPORTED_HASH_FUNCTION_STRINGS;
sig: SUPPORTED_HASH_FUNCTIONS;
name: SUPPORTED_VERIFICATION_FUNCTION_STRINGS;
sig: SUPPORTED_VERIFICATION_FUNCTIONS;
};
} = {
[SUPPORTED_HASH_FUNCTION_STRINGS.KECCAK256_UTF8]: KECCAK256_UTF8,
[SUPPORTED_HASH_FUNCTION_HASHES.HASH_KECCAK256_UTF8]: KECCAK256_UTF8,
[SUPPORTED_HASH_FUNCTION_STRINGS.KECCAK256_BYTES]: KECCAK256_BYTES,
[SUPPORTED_HASH_FUNCTION_HASHES.HASH_KECCAK256_BYTES]: KECCAK256_BYTES,
[SUPPORTED_VERIFICATION_FUNCTION_STRINGS.KECCAK256_UTF8]: KECCAK256_UTF8,
[SUPPORTED_VERIFICATION_FUNCTION_HASHES.HASH_KECCAK256_UTF8]: KECCAK256_UTF8,
[SUPPORTED_VERIFICATION_FUNCTION_STRINGS.KECCAK256_BYTES]: KECCAK256_BYTES,
[SUPPORTED_VERIFICATION_FUNCTION_HASHES.HASH_KECCAK256_BYTES]:
KECCAK256_BYTES,
};

// TODO: These values can be imported from lsp-smartcontracts lib after release
Expand Down
Loading

0 comments on commit 1a1170c

Please sign in to comment.