diff --git a/apps/desktop/src/components/AddressPill/AddressPill.tsx b/apps/desktop/src/components/AddressPill/AddressPill.tsx index f5310e4ab0..324261e904 100644 --- a/apps/desktop/src/components/AddressPill/AddressPill.tsx +++ b/apps/desktop/src/components/AddressPill/AddressPill.tsx @@ -35,6 +35,7 @@ export const AddressPill = memo( showIcons, addressKind, addressAlias, + address, onClick, elementRef, isMouseHover, @@ -109,7 +110,7 @@ export const AddressPill = memo( - {showIcons && ( + {showIcons && address.type !== "smart_rollup" && ( { operation.recipient.pkh, Number(operation.amount) ); + default: + throw new Error(`${operation.recipient.type} is not supported yet`); } // eslint-disable-next-line no-fallthrough case "fa1.2": diff --git a/packages/tezos/src/Address.ts b/packages/tezos/src/Address.ts index 103c5560ab..ffafb547ff 100644 --- a/packages/tezos/src/Address.ts +++ b/packages/tezos/src/Address.ts @@ -1,6 +1,11 @@ import { ValidationResult, validateAddress } from "@taquito/utils"; -import { type Address, type ContractAddress, type ImplicitAddress } from "./types"; +import { + type Address, + type ContractAddress, + type ImplicitAddress, + type SmartRollupAddress, +} from "./types"; export const parsePkh = (pkh: string): Address => { if (isValidContractPkh(pkh)) { @@ -9,6 +14,9 @@ export const parsePkh = (pkh: string): Address => { if (isValidImplicitPkh(pkh)) { return parseImplicitPkh(pkh); } + if (isValidSmartRollupPkh(pkh)) { + return parseSmartRollupPkh(pkh); + } throw new Error(`Cannot parse address type: ${pkh}`); }; @@ -18,6 +26,8 @@ export const isValidContractPkh = (pkh: string) => isAddressValid(pkh) && pkh.ma export const isValidImplicitPkh = (pkh: string) => isAddressValid(pkh) && pkh.match(/^tz[1234]\w+/); +export const isValidSmartRollupPkh = (pkh: string) => isAddressValid(pkh) && pkh.match(/^sr1\w+/); + export const parseContractPkh = (pkh: string): ContractAddress => { if (isValidContractPkh(pkh)) { return { type: "contract", pkh }; @@ -31,3 +41,10 @@ export const parseImplicitPkh = (pkh: string): ImplicitAddress => { } throw new Error(`Invalid implicit address: ${pkh}`); }; + +export const parseSmartRollupPkh = (pkh: string): SmartRollupAddress => { + if (isValidSmartRollupPkh(pkh)) { + return { type: "smart_rollup", pkh }; + } + throw new Error(`Invalid smart rollup address: ${pkh}`); +}; diff --git a/packages/tezos/src/types.ts b/packages/tezos/src/types.ts index 6840681423..863ae3d575 100644 --- a/packages/tezos/src/types.ts +++ b/packages/tezos/src/types.ts @@ -29,7 +29,12 @@ export type ImplicitAddress = { pkh: RawPkh; }; -export type Address = ContractAddress | ImplicitAddress; +export type SmartRollupAddress = { + type: "smart_rollup"; + pkh: RawPkh; +}; + +export type Address = ContractAddress | ImplicitAddress | SmartRollupAddress; export type Estimation = { storageLimit: number;