Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add share simulation method #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/executors/Simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ export class Simulator {
return data;
}

private async executeSimulationShareRequest(simulationId: string): Promise<void> {
await this.apiV2.post<SimulationBundleRequest, SimulateBundleResponse>(
`
/account/${this.configuration.accountName}
/project/${this.configuration.projectName}
/simulations/${simulationId}/share
`,
);
}

/**
* Simulates a transaction by encoding overrides, building a request body, and executing a simulation request.
* @async
Expand Down Expand Up @@ -302,4 +312,19 @@ export class Simulator {
handleError(error);
}
}

/**
* Makes the dashboard page for a simulation that was created with `save` or `save_if_fails`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes the dashboard page for a simulation publicly viewable

Is a good enough comment, since we might change the exact name of the props used for this case.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1

* publicly viewable
* @async
* @function
* @param {string} simulationId - The ID of the simulation to be shared.
*/
async shareSimulation(simulationId: string) {
try {
await this.executeSimulationShareRequest(simulationId);
} catch (error) {
handleError(error);
}
}
}