diff --git a/package.json b/package.json index 06e08b2..e559a2e 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "typescript": "^4.5" }, "name": "@psychedelic/plug-controller", - "version": "0.24.8", + "version": "0.24.9", "description": "Internet Computer Plug wallet's controller", "main": "dist/index.js", "scripts": { diff --git a/src/PlugKeyRing/modules/NetworkModule/Network.ts b/src/PlugKeyRing/modules/NetworkModule/Network.ts index 3914e46..7d0beec 100644 --- a/src/PlugKeyRing/modules/NetworkModule/Network.ts +++ b/src/PlugKeyRing/modules/NetworkModule/Network.ts @@ -117,11 +117,15 @@ export class Network { if (!validateCanisterId(canisterId)) { throw new Error(ERRORS.INVALID_CANISTER_ID); } - const agent = this.createAgent({ defaultIdentity: identity }); - const nftActor = getNFTActor({ canisterId, agent, standard }); - const metadata = await nftActor.getMetadata(); - const nft = {...metadata, registeredBy: []}; - return nft + try { + const agent = this.createAgent({ defaultIdentity: identity }); + const nftActor = getNFTActor({ canisterId, agent, standard }); + const metadata = await nftActor.getMetadata(); + const nft = {...metadata, registeredBy: []}; + return nft + } catch(e) { + throw new Error(ERRORS.CANISTER_INTERFACE_ERROR); + } } public registerNFT = async ({ diff --git a/src/constants/version.ts b/src/constants/version.ts index d9dd0a7..613835e 100644 --- a/src/constants/version.ts +++ b/src/constants/version.ts @@ -1 +1 @@ -export const PLUG_CONTROLLER_VERSION = "0.24.8"; +export const PLUG_CONTROLLER_VERSION = "0.24.9"; diff --git a/src/errors.ts b/src/errors.ts index 0b99db7..695288d 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -28,6 +28,7 @@ export const ERRORS = { TOKEN_NOT_REGISTERED: 'Token not registered', INVALID_ACCOUNT: 'The imported account already exists', NFT_ALREADY_REGISTERED: 'The NFT is already registered', + CANISTER_INTERFACE_ERROR: 'Canister does not implement the selected standard interface', }; export const ERROR_CODES = {