From caa3316f40c5c412bb1d6dc7544e6483eac4154c Mon Sep 17 00:00:00 2001 From: Branko Bosnic Date: Thu, 15 Feb 2024 15:21:01 +0100 Subject: [PATCH] Remove restricted and multi addresses and unlocks --- api/src/models/api/nova/IAddressDetails.ts | 1 - api/src/utils/nova/addressHelper.ts | 20 +------------------ client/src/app/components/nova/Unlocks.tsx | 8 ++------ .../components/nova/address/AddressView.tsx | 6 ++---- client/src/helpers/nova/addressHelper.ts | 15 +------------- client/src/helpers/nova/nameHelper.ts | 3 --- client/src/helpers/nova/transactionsHelper.ts | 2 +- client/src/models/api/nova/IAddressDetails.ts | 1 - 8 files changed, 7 insertions(+), 49 deletions(-) diff --git a/api/src/models/api/nova/IAddressDetails.ts b/api/src/models/api/nova/IAddressDetails.ts index 86034e72d..8dd8a13ec 100644 --- a/api/src/models/api/nova/IAddressDetails.ts +++ b/api/src/models/api/nova/IAddressDetails.ts @@ -7,6 +7,5 @@ export interface IAddressDetails { hex?: string; type?: AddressType; label?: string; - restricted: boolean; capabilities?: number[]; } diff --git a/api/src/utils/nova/addressHelper.ts b/api/src/utils/nova/addressHelper.ts index 6a0c5e023..b34d59066 100644 --- a/api/src/utils/nova/addressHelper.ts +++ b/api/src/utils/nova/addressHelper.ts @@ -10,7 +10,6 @@ import { AnchorAddress, Utils, ImplicitAccountCreationAddress, - RestrictedAddress, } from "@iota/sdk-nova"; import { plainToInstance } from "class-transformer"; import { IAddressDetails } from "../../models/api/nova/IAddressDetails"; @@ -59,16 +58,10 @@ export class AddressHelper { hex: hex ? HexHelper.addPrefix(hex) : hex, type, label: AddressHelper.typeLabel(type), - restricted: false, }; } - private static buildAddressFromTypes( - address: Address, - hrp: string, - restricted: boolean = false, - capabilities?: number[], - ): IAddressDetails { + private static buildAddressFromTypes(address: Address, hrp: string, capabilities?: number[]): IAddressDetails { let hex: string = ""; let bech32: string = ""; @@ -84,16 +77,6 @@ export class AddressHelper { const implicitAccountCreationAddress = plainToInstance(ImplicitAccountCreationAddress, address); const innerAddress = implicitAccountCreationAddress.address(); hex = innerAddress.pubKeyHash; - } else if (address.type === AddressType.Restricted) { - const restrictedAddress = plainToInstance(RestrictedAddress, address); - const innerAddress = restrictedAddress.address; - - return this.buildAddressFromTypes( - innerAddress, - hrp, - true, - Array.from(restrictedAddress.getAllowedCapabilities() as ArrayLike), - ); } bech32 = this.computeBech32FromHexAndType(hex, address.type, hrp); @@ -103,7 +86,6 @@ export class AddressHelper { hex, type: address.type, label: AddressHelper.typeLabel(address.type), - restricted, capabilities, }; } diff --git a/client/src/app/components/nova/Unlocks.tsx b/client/src/app/components/nova/Unlocks.tsx index 38161f2c2..3868f7b33 100644 --- a/client/src/app/components/nova/Unlocks.tsx +++ b/client/src/app/components/nova/Unlocks.tsx @@ -2,7 +2,6 @@ import { AccountUnlock, AnchorUnlock, EmptyUnlock, - MultiUnlock, NftUnlock, ReferenceUnlock, SignatureUnlock, @@ -25,7 +24,6 @@ interface UnlockTypeMap { [UnlockType.Account]: AccountUnlock; [UnlockType.Anchor]: AnchorUnlock; [UnlockType.Nft]: NftUnlock; - [UnlockType.Multi]: MultiUnlock; [UnlockType.Empty]: EmptyUnlock; } @@ -80,10 +78,6 @@ const Unlocks: React.FC = ({ unlocks }) => { ); - } else if (unlock.type === UnlockType.Multi) { - const multiUnlock = unlock as MultiUnlock; - - return ; } else if (unlock.type === UnlockType.Empty) { return (
@@ -91,6 +85,8 @@ const Unlocks: React.FC = ({ unlocks }) => {
); } else { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore const referencedUnlock = unlock as UnlockTypeMap[typeof unlock.type]; return ( diff --git a/client/src/app/components/nova/address/AddressView.tsx b/client/src/app/components/nova/address/AddressView.tsx index 9b479d660..70823f26f 100644 --- a/client/src/app/components/nova/address/AddressView.tsx +++ b/client/src/app/components/nova/address/AddressView.tsx @@ -35,10 +35,8 @@ function getAddressTypeName(type: AddressType): string { return "Anchor"; case AddressType.ImplicitAccountCreation: return "ImplicitAccountCreation"; - case AddressType.Multi: - return "Multi"; - case AddressType.Restricted: - return "Restricted"; + default: + return "Unknown"; } } diff --git a/client/src/helpers/nova/addressHelper.ts b/client/src/helpers/nova/addressHelper.ts index 55baf3641..c1d21b217 100644 --- a/client/src/helpers/nova/addressHelper.ts +++ b/client/src/helpers/nova/addressHelper.ts @@ -7,7 +7,6 @@ import { AnchorAddress, Utils, ImplicitAccountCreationAddress, - RestrictedAddress, } from "@iota/sdk-wasm-nova/web"; import { HexHelper } from "../stardust/hexHelper"; import { IAddressDetails } from "~models/api/nova/IAddressDetails"; @@ -54,16 +53,10 @@ export class AddressHelper { hex: hex ? HexHelper.addPrefix(hex) : hex, type, label: AddressHelper.typeLabel(type), - restricted: false, }; } - private static buildAddressFromTypes( - address: Address, - hrp: string, - restricted: boolean = false, - capabilities?: number[], - ): IAddressDetails { + private static buildAddressFromTypes(address: Address, hrp: string, capabilities?: number[]): IAddressDetails { let hex: string = ""; let bech32: string = ""; @@ -79,11 +72,6 @@ export class AddressHelper { const implicitAccountCreationAddress = plainToInstance(ImplicitAccountCreationAddress, address); const innerAddress = implicitAccountCreationAddress.address(); hex = (innerAddress as Ed25519Address).pubKeyHash; - } else if (address.type === AddressType.Restricted) { - const restrictedAddress = plainToInstance(RestrictedAddress, address); - const innerAddress = restrictedAddress.address; - - return this.buildAddressFromTypes(innerAddress, hrp, true, Array.from(restrictedAddress.getAllowedCapabilities())); } bech32 = this.computeBech32FromHexAndType(hex, address.type, hrp); @@ -93,7 +81,6 @@ export class AddressHelper { hex, type: address.type, label: AddressHelper.typeLabel(address.type), - restricted, capabilities, }; } diff --git a/client/src/helpers/nova/nameHelper.ts b/client/src/helpers/nova/nameHelper.ts index a9f294558..03cd36319 100644 --- a/client/src/helpers/nova/nameHelper.ts +++ b/client/src/helpers/nova/nameHelper.ts @@ -23,9 +23,6 @@ export class NameHelper { case UnlockType.Nft: { return "NFT Unlock"; } - case UnlockType.Multi: { - return "Multi Unlock"; - } case UnlockType.Empty: { return "Empty Unlock"; } diff --git a/client/src/helpers/nova/transactionsHelper.ts b/client/src/helpers/nova/transactionsHelper.ts index 57d06733d..a173f3046 100644 --- a/client/src/helpers/nova/transactionsHelper.ts +++ b/client/src/helpers/nova/transactionsHelper.ts @@ -71,7 +71,7 @@ export class TransactionsHelper { if (referencedUnlock.type === UnlockType.Signature) { signatureUnlock = referencedUnlock as SignatureUnlock; - } else if (referencedUnlock.type === UnlockType.Multi || referencedUnlock.type === UnlockType.Empty) { + } else if (referencedUnlock.type === UnlockType.Empty) { break; } else { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/client/src/models/api/nova/IAddressDetails.ts b/client/src/models/api/nova/IAddressDetails.ts index 328a95899..a9e238c56 100644 --- a/client/src/models/api/nova/IAddressDetails.ts +++ b/client/src/models/api/nova/IAddressDetails.ts @@ -5,6 +5,5 @@ export interface IAddressDetails { hex?: string; type?: AddressType; label?: string; - restricted?: boolean; capabilities?: number[]; }