Skip to content

Commit

Permalink
RTBooth
Browse files Browse the repository at this point in the history
  • Loading branch information
tyzoo committed Jan 19, 2023
1 parent 61d2123 commit 93be9f7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zootools",
"version": "0.1.13",
"version": "0.1.14",
"description": "ZooTools Decentraland SDK Library",
"main": "./dist/index.js",
"scripts": {
Expand Down
61 changes: 61 additions & 0 deletions src/entities/Booth/RTBooth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { getCurrentRealm } from "@decentraland/EnvironmentAPI";
import { getUserData } from "@decentraland/Identity";
import { signedFetch } from "@decentraland/SignedFetch";
import { AlertSystem } from "src/index";
import { Booth, IBoothProps } from "./Booth";

export class RTBooth extends Entity {
booth: Booth;
constructor(
public props: Partial<IBoothProps>,
public rewardId: string,
public alertSystem: AlertSystem,
) {
super()
this.addComponent(new Transform({}));
this.booth = new Booth({
transformArgs: { position: new Vector3(8, 0, 8) },
buttonText: `Get Attendance Token`,
onButtonClick: () => {
void executeTask(async () => {
try {
log("POAP", { rewardId })
alertSystem.new("Attempting to claim POAP... Please wait...")
const userData = await getUserData();
const realm = await getCurrentRealm();
if (!userData?.hasConnectedWeb3) {
alertSystem.new(`Login with an Ethereum Wallet to claim this POAP`);
return;
}
const address = userData?.publicKey;
const displayName = userData?.displayName;
const callUrl = `https://api.reward.tools/v1/poap/claim`;
let response = await signedFetch(callUrl, {
headers: { "Content-Type": "application/json" },
method: "POST",
body: JSON.stringify({
address,
displayName,
rewardId,
realm,
timezone: new Date().toString(),
}),
})
let json = JSON.parse(response.text ?? "");
const { message } = json;
log(json)
alertSystem.new(message)

} catch (err: any) {
alertSystem.new(err?.message ?? `An error has occcured`)
}
})
},
wrapTexturePath: `poap_assets/images/wrap1.png`,
dispenserModelPath: `poap_assets/models/POAP_dispenser.glb`,
buttonModelPath: `poap_assets/models/POAP_button.glb`,
...props,
})
this.booth.setParent(this);
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export { Image } from './entities/Image'
export { Model, IModelProps } from './entities/Model'
export { ModelGroup, IModelGroupProps } from './entities/ModelGroup'
export { POAPBooth, IPOAPBoothProps } from './entities/Booth/POAPBooth'
export { RTBooth } from './entities/Booth/RTBooth'
export { Sound } from './entities/Sound'
export { WearableBooth, IWearableBoothProps } from './entities/Booth/WearableBooth'
export { ZooTools_Metronome } from './entities/Metronome/Metronome'
Expand Down

0 comments on commit 93be9f7

Please sign in to comment.