-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
833 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./metadata"; | ||
export * from "./socials"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export class Metadata { | ||
constructor( | ||
public color: string, | ||
public name: string, | ||
public description: string, | ||
public image: string, | ||
public banner: string, | ||
) { | ||
this.color = color; | ||
this.name = name; | ||
this.description = description; | ||
this.image = image; | ||
this.banner = banner; | ||
} | ||
|
||
static from(value: string) { | ||
try { | ||
const json = JSON.parse(value); | ||
return new Metadata(json.color, json.name, json.description, json.image, json.banner); | ||
} catch (error: unknown) { | ||
console.error("Error parsing metadata:", error); | ||
return new Metadata("", "", "", "", ""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export class Socials { | ||
constructor( | ||
public discord: string, | ||
public telegram: string, | ||
public twitter: string, | ||
public youtube: string, | ||
public website: string, | ||
) { | ||
this.discord = discord; | ||
this.telegram = telegram; | ||
this.twitter = twitter; | ||
this.youtube = youtube; | ||
this.website = website; | ||
} | ||
|
||
static from(value: string) { | ||
try { | ||
const json = JSON.parse(value); | ||
return new Socials(json.discord, json.telegram, json.twitter, json.youtube, json.website); | ||
} catch (error: unknown) { | ||
console.error("Error parsing socials:", error); | ||
return new Socials("", "", "", "", ""); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
import { Pinning, PinningEvent } from "./pinning"; | ||
import { Game, GameModel, Metadata, Socials } from "./game"; | ||
import { Game, GameModel } from "./game"; | ||
import { initSDK } from ".."; | ||
import { constants } from "starknet"; | ||
export type { PinningEvent, GameModel, Metadata, Socials }; | ||
import { Achievement } from "./achievement"; | ||
import { configs } from "../../configs"; | ||
import { getContractByName } from "../../provider/helpers"; | ||
|
||
export type { GameModel }; | ||
|
||
export const Registry = { | ||
Pinning: Pinning, | ||
address: undefined as string | undefined, | ||
Game: Game, | ||
Achievement: Achievement, | ||
|
||
init: async (chainId: constants.StarknetChainId) => { | ||
const config = configs[chainId]; | ||
const address = getContractByName(config.manifest, "Registry"); | ||
const sdk = await initSDK(chainId); | ||
Pinning.init(sdk); | ||
Game.init(sdk); | ||
Registry.address = address; | ||
Game.init(sdk, address); | ||
Achievement.init(sdk, address); | ||
}, | ||
|
||
policies: () => { | ||
if (!Registry.address) { | ||
throw new Error("Registry module is not initialized"); | ||
} | ||
return { | ||
contracts: { | ||
[Registry.address]: { | ||
name: "Registry", | ||
description: "Registry contract for games and achievements", | ||
methods: [...Game.methods(), ...Achievement.methods()], | ||
}, | ||
}, | ||
}; | ||
}, | ||
}; |
Oops, something went wrong.