-
Notifications
You must be signed in to change notification settings - Fork 1
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
3 changed files
with
63 additions
and
1 deletion.
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,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); | ||
} | ||
} |
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