Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP28 Grid Data Key Addition #118

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components/DataKeysTable/DataKeysTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const DataKeysTable: React.FC<Props> = ({
const dataKeys = schemaToLoad.map((schema) => schema.key);

const result = await getDataBatch(address, dataKeys, web3);

result.map((_, i) => {
dataResult.push({
key: dataKeys[i],
Expand Down
7 changes: 7 additions & 0 deletions components/DataKeysTable/ProfileSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
"valueType": "bytes",
"valueContent": "VerifiableURI"
},
{
"name": "LSP28TheGrid",
"key": "0x724141d9918ce69e6b8afcf53a91748466086ba2c74b94cab43c649ae2ac23ff",
"keyType": "Singleton",
"valueType": "bytes",
"valueContent": "VerifiableURI"
},
{
"name": "LSP5ReceivedAssets[]",
"key": "0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b",
Expand Down
2 changes: 2 additions & 0 deletions components/DataKeysTable/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum SchemaName {
'AddressPermissions[]' = 'AddressPermissions[]',
'LSP10Vaults[]' = 'LSP10Vaults[]',
'LSP12IssuedAssets[]' = 'LSP12IssuedAssets[]',
'LSP28TheGrid' = 'LSP28TheGrid',
}

export const SCHEMA_DOCS_LINKS: { [key in SchemaName]: string } = {
Expand All @@ -23,4 +24,5 @@ export const SCHEMA_DOCS_LINKS: { [key in SchemaName]: string } = {
'https://docs.lukso.tech/standards/universal-profile/lsp10-received-vaults',
'LSP12IssuedAssets[]':
'https://docs.lukso.tech/standards/universal-profile/lsp12-issued-assets',
LSP28TheGrid: 'https://docs.lukso.tech/standards/standard-detection', // TODO: update with correct link
};
39 changes: 24 additions & 15 deletions components/ValueTypeDecoder/ValueTypeDecoder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ const ValueTypeDecoder: React.FC<Props> = ({
erc725JSONSchema.valueContent === 'VerifiableURI' ||
erc725JSONSchema.valueContent === 'JSONURL'
) {
if (
!decodedDataOneKey ||
!decodedDataOneKey[0] ||
!decodedDataOneKey[0].value
) {
return <span className="help">No data found for this key.</span>;
}

return (
<>
<pre>{JSON.stringify(decodedDataOneKey[0].value, null, 4)}</pre>
Expand All @@ -147,21 +155,22 @@ const ValueTypeDecoder: React.FC<Props> = ({
URL:
<code className="ml-2">{decodedDataOneKey[0].value.url}</code>
</span>
{decodedDataOneKey[0].value.url.indexOf('ipfs://') !== -1 && (
<>
<a
className="has-text-link button is-small is-light is-info"
target="_blank"
rel="noreferrer"
href={`${LUKSO_IPFS_BASE_URL}/${decodedDataOneKey[0].value.url.replace(
'ipfs://',
'',
)}`}
>
Retrieve IPFS File ↗️
</a>
</>
)}
{decodedDataOneKey[0].value.url &&
decodedDataOneKey[0].value.url.indexOf('ipfs://') !== -1 && (
<>
<a
className="has-text-link button is-small is-light is-info"
target="_blank"
rel="noreferrer"
href={`${LUKSO_IPFS_BASE_URL}/${decodedDataOneKey[0].value.url.replace(
'ipfs://',
'',
)}`}
>
Retrieve IPFS File ↗️
</a>
</>
)}
</>
);
}
Expand Down
31 changes: 25 additions & 6 deletions pages/data-fetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import { NetworkContext } from '@/contexts/NetworksContext';
import { useRouter } from 'next/router';
import { isValidTuple } from '@erc725/erc725.js/build/main/src/lib/decodeData';

// using local variable for LSP28TheGrid key for now
const LSP28_THE_GRID_KEY =
'0x724141d9918ce69e6b8afcf53a91748466086ba2c74b94cab43c649ae2ac23ff';

const dataKeyList = [
...LSP1DataKeys.map((key) => ({ name: key.name, key: key.key, icon: '📢' })),
...LSP3DataKeys.map((key) => ({ name: key.name, key: key.key, icon: '👤' })),
Expand All @@ -40,6 +44,7 @@ const dataKeyList = [
...LSP10DataKeys.map((key) => ({ name: key.name, key: key.key, icon: '🔒' })),
...LSP12DataKeys.map((key) => ({ name: key.name, key: key.key, icon: '🖼️' })),
...LSP17DataKeys.map((key) => ({ name: key.name, key: key.key, icon: '💎' })),
{ name: 'LSP28TheGrid', key: LSP28_THE_GRID_KEY, icon: '🌐' },
];

const GetData: NextPage = () => {
Expand Down Expand Up @@ -73,6 +78,13 @@ const GetData: NextPage = () => {
...LSP10DataKeys,
...LSP12DataKeys,
...LSP17DataKeys,
{
name: 'LSP28TheGrid',
key: LSP28_THE_GRID_KEY,
keyType: 'Singleton',
valueType: 'bytes',
valueContent: 'VerifiableURI',
},
];

useEffect(() => {
Expand Down Expand Up @@ -164,12 +176,21 @@ const GetData: NextPage = () => {
setData(data);

const foundSchema = getSchema(dataKey) as ERC725JSONSchema;

if (!foundSchema) {
if (!foundSchema && dataKey !== LSP28_THE_GRID_KEY) {
return;
}
let keyName, valueType, valueContent;

if (foundSchema) {
({ name: keyName, valueType, valueContent } = foundSchema);
} else if (dataKey === LSP28_THE_GRID_KEY) {
keyName = 'LSP28TheGrid';
valueType = 'bytes';
valueContent = 'VerifiableURI';
} else {
console.error('Unknown schema');
return;
}

const { name: keyName, valueType, valueContent } = foundSchema;

let decodedValue;

Expand All @@ -189,12 +210,10 @@ const GetData: NextPage = () => {
},
]);
}

const decodedResult =
valueContent == 'VerifiableURI' || isValidTuple(valueType, valueContent)
? JSON.stringify(decodedValue[0].value, null, 4)
: decodedValue[0].value;

setDecodedData(decodedResult);
}
};
Expand Down