Skip to content

Commit

Permalink
Feat(Identity): Unify Alias and Identity view (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass authored Dec 12, 2023
1 parent b8dd40e commit c22ebdf
Show file tree
Hide file tree
Showing 23 changed files with 672 additions and 268 deletions.
27 changes: 23 additions & 4 deletions api/src/utils/stardust/searchExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,30 @@ export class SearchExecutor {
const searchQuery = this.query;
const promises: Promise<void>[] = [];
let promisesResult: ISearchResponse | null = null;

if (searchQuery.did) {
return {
did: searchQuery.did
};
promises.push(
new Promise((resolve, reject) => {
StardustTangleHelper.tryFetchNodeThenPermanode<string, string>(
searchQuery.aliasId,
"aliasOutputId",
network
).then(
aliasOutputs => {
if (aliasOutputs) {
promisesResult = {
aliasId: searchQuery.aliasId,
did: searchQuery.did
};
resolve();
} else {
reject(new Error("Output (aliasId) not present"));
}
}
).catch(_ => {
reject(new Error("Output (aliasId) fetch failed"));
});
})
);
}

if (searchQuery.milestoneIndex) {
Expand Down
18 changes: 16 additions & 2 deletions api/src/utils/stardust/searchQueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class SearchQueryBuilder {
let foundryId: string;
let tag: HexEncodedString;

const did = this.queryLower.startsWith("did:iota:") ? this.query : undefined;
const did = this.isDIDString(this.queryLower) ? this.query : undefined;
const milestoneIndex = /^\d+$/.test(this.query) ? Number.parseInt(this.query, 10) : undefined;
const queryDetails = this.buildQueryDetails();

Expand Down Expand Up @@ -194,9 +194,14 @@ export class SearchQueryBuilder {
let addressType: number;
let isBech32: boolean = false;

const q = this.queryLower;
let q = this.queryLower;
const hrp = this.networkBechHrp;

const did = this.isDIDString(this.queryLower) ? this.query : undefined;
if (did) {
q = this.extractHexFromDID(did);
}

if (Bech32Helper.matches(q, hrp)) {
isBech32 = true;

Expand Down Expand Up @@ -243,5 +248,14 @@ export class SearchQueryBuilder {
return "NFT";
}
}

private isDIDString(searchString: string): boolean {
return searchString.startsWith("did:iota:");
}

private extractHexFromDID(did: string): string {
// cut off the first two chars
return did.slice(Math.max(0, did.lastIndexOf(":") + 3));
}
}

134 changes: 130 additions & 4 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@fontsource/ibm-plex-mono": "^4.5.12",
"@fontsource/material-icons": "^4.5.4",
"@iota/crypto.js": "^1.8.6",
"@iota/identity-wasm": "^1.0.0",
"@iota/iota.js": "^1.8.6",
"@iota/mam-legacy": "github:iotaledger/mam.js#fddc95f60539b9a31a4db1b5b56e0dedb8994883",
"@iota/mam.js": "^1.6.2",
Expand Down
3 changes: 3 additions & 0 deletions client/script/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ mkdir -p "$TARGET"
# stardust
cp "$NODE_MODULES/@iota/sdk-wasm/web/wasm/iota_sdk_wasm_bg.wasm" "$TARGET/iota_sdk_stardust_wasm_bg.wasm"

# identity
cp "$NODE_MODULES/@iota/identity-wasm/web/identity_wasm_bg.wasm" "$TARGET/identity_wasm_bg.wasm"

Loading

0 comments on commit c22ebdf

Please sign in to comment.