Skip to content

Commit

Permalink
Add error handler for get nft info (#243)
Browse files Browse the repository at this point in the history
* Add error handler for getNFTInfo

Co-authored-by: Dante <[email protected]>
  • Loading branch information
dantefarias and Dante authored Nov 1, 2022
1 parent 74339e6 commit 71bb270
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 9 additions & 5 deletions src/PlugKeyRing/modules/NetworkModule/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ({
Expand Down
2 changes: 1 addition & 1 deletion src/constants/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PLUG_CONTROLLER_VERSION = "0.24.8";
export const PLUG_CONTROLLER_VERSION = "0.24.9";
1 change: 1 addition & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 71bb270

Please sign in to comment.