Skip to content

Commit

Permalink
Remove restricted and multi addresses and unlocks (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder authored Feb 16, 2024
1 parent 0dbc932 commit c4667fb
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 49 deletions.
1 change: 0 additions & 1 deletion api/src/models/api/nova/IAddressDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export interface IAddressDetails {
hex?: string;
type?: AddressType;
label?: string;
restricted: boolean;
capabilities?: number[];
}
20 changes: 1 addition & 19 deletions api/src/utils/nova/addressHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 = "";

Expand All @@ -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<number>),
);
}

bech32 = this.computeBech32FromHexAndType(hex, address.type, hrp);
Expand All @@ -103,7 +86,6 @@ export class AddressHelper {
hex,
type: address.type,
label: AddressHelper.typeLabel(address.type),
restricted,
capabilities,
};
}
Expand Down
8 changes: 2 additions & 6 deletions client/src/app/components/nova/Unlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
AccountUnlock,
AnchorUnlock,
EmptyUnlock,
MultiUnlock,
NftUnlock,
ReferenceUnlock,
SignatureUnlock,
Expand All @@ -25,7 +24,6 @@ interface UnlockTypeMap {
[UnlockType.Account]: AccountUnlock;
[UnlockType.Anchor]: AnchorUnlock;
[UnlockType.Nft]: NftUnlock;
[UnlockType.Multi]: MultiUnlock;
[UnlockType.Empty]: EmptyUnlock;
}

Expand Down Expand Up @@ -80,17 +78,15 @@ const Unlocks: React.FC<IUnlocksProps> = ({ unlocks }) => {
</div>
</div>
);
} else if (unlock.type === UnlockType.Multi) {
const multiUnlock = unlock as MultiUnlock;

return <Unlocks unlocks={multiUnlock.unlocks} key={idx} />;
} else if (unlock.type === UnlockType.Empty) {
return (
<div key={idx} className="unlocks-card margin-l-t">
{displayUnlocksTypeAndIndex(unlock.type, idx)}
</div>
);
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const referencedUnlock = unlock as UnlockTypeMap[typeof unlock.type];

return (
Expand Down
6 changes: 2 additions & 4 deletions client/src/app/components/nova/address/AddressView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand Down
15 changes: 1 addition & 14 deletions client/src/helpers/nova/addressHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 = "";

Expand All @@ -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);
Expand All @@ -93,7 +81,6 @@ export class AddressHelper {
hex,
type: address.type,
label: AddressHelper.typeLabel(address.type),
restricted,
capabilities,
};
}
Expand Down
3 changes: 0 additions & 3 deletions client/src/helpers/nova/nameHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/helpers/nova/transactionsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion client/src/models/api/nova/IAddressDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export interface IAddressDetails {
hex?: string;
type?: AddressType;
label?: string;
restricted?: boolean;
capabilities?: number[];
}

0 comments on commit c4667fb

Please sign in to comment.