Skip to content

Commit

Permalink
Merge pull request #183 from dojoengine/burner_after_deploy
Browse files Browse the repository at this point in the history
feat: add afterDeploying callback to burnerManager
  • Loading branch information
ponderingdemocritus authored Apr 9, 2024
2 parents 25aba4d + 14da941 commit cdd5fea
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion packages/create-burner/src/manager/burnerManager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { KATANA_ETH_CONTRACT_ADDRESS } from "@dojoengine/core";
import {
Account,
CallData,
Expand All @@ -10,7 +11,6 @@ import {
import { Burner, BurnerManagerOptions, BurnerStorage } from "../types";
import Storage from "../utils/storage";
import { prefundAccount } from "./prefundAccount";
import { KATANA_ETH_CONTRACT_ADDRESS } from "@dojoengine/core";

/**
* A class to manage Burner accounts.
Expand Down Expand Up @@ -70,6 +70,13 @@ export class BurnerManager {
public isInitialized: boolean = false;

private setIsDeploying?: (isDeploying: boolean) => void;
private afterDeploying?: ({
account,
deployTx,
}: {
account: Account;
deployTx: string;
}) => Promise<void>;

constructor({
masterAccount,
Expand All @@ -89,6 +96,18 @@ export class BurnerManager {
this.setIsDeploying = callback;
}

public setAfterDeployingCallback(
callback: ({
account,
deployTx,
}: {
account: Account;
deployTx: string;
}) => Promise<void>
): void {
this.afterDeploying = callback;
}

private updateIsDeploying(status: boolean) {
this.isDeploying = status;
if (this.setIsDeploying) {
Expand Down Expand Up @@ -303,6 +322,14 @@ export class BurnerManager {
this.updateIsDeploying(false);
Storage.set(this.getBurnerKey(), storage);

if (this.afterDeploying) {
try {
await this.afterDeploying({ account: this.account, deployTx });
} catch (e: any) {
console.log("error on afterDeploying", e);
}
}

return burner;
}

Expand Down

0 comments on commit cdd5fea

Please sign in to comment.