Skip to content

Commit

Permalink
adding networks and maps to ChainObject
Browse files Browse the repository at this point in the history
  • Loading branch information
pellicceama committed Nov 4, 2022
1 parent a821d73 commit 66d2b4d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/model/ChainObject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sortObjectKeys } from "../utils";
import { AssetMap } from "./AssetMap";
import { Logos } from "./Logos";
import { RepoObject } from "./RepoObject";
import { TagName } from "./Tag";
Expand All @@ -17,7 +18,13 @@ export abstract class ChainObject extends RepoObject {
description: Description | null;// foreign keys
links: Links | null; // foreign keys
logo: Logos | null; // foreign keys
maps: {
[type: string]: AssetMap[];
}
name: string;
networks: {
[networkCode: string]: string; // addresses array
}
spam: boolean;
symbol: string;
tags: TagName[]; // foreign keys
Expand All @@ -44,10 +51,23 @@ export abstract class ChainObject extends RepoObject {
this.links = info.links || getEmptyBaseLinks();
this.logo = info.logo || new Logos();

if(!info.maps && Object.keys(info.maps).length == 0) {
info.maps = {};
} else {
this.maps = info.maps;
}

if(!info.name) {
throw new Error('name is required to initialise an AssetsRepoObject Passed: ' + JSON.stringify(info));
}
this.name = info.name;

if(!info.networks && Object.keys(info.networks).length == 0) {
info.networks = {};
} else {
this.networks = info.networks;
}

this.spam = info.spam === undefined ? false : info.spam;

if(!info.symbol) {
Expand Down

0 comments on commit 66d2b4d

Please sign in to comment.