Skip to content

Commit

Permalink
fix(edit): throw if user tries to edit a remote sub
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinse12 committed Mar 22, 2024
1 parent 95501eb commit 2b4c245
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cli/commands/subplebbit/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export default class Edit extends BaseCommand {
const editOptions: SubplebbitEditOptions = DataObjectParser.transpose(lodash.omit(flags, ["plebbitRpcApiUrl"]))["_data"];
log("Edit options parsed:", editOptions);
const plebbit = await this._connectToPlebbitRpc(flags.plebbitRpcApiUrl.toString());
const localSubs = await plebbit.listSubplebbits();
if (!localSubs.includes(args.address)) this.error("Can't edit a remote subplebbit, make sure you're editing a local sub");

const sub = <RpcLocalSubplebbit>await plebbit.createSubplebbit({ address: args.address });
const mergedSubState = lodash.pick(sub.toJSONInternalRpc(), Object.keys(editOptions));
Expand Down
1 change: 1 addition & 0 deletions test/cli/edit.subplebbit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe("plebbit subplebbit edit", () => {
before(() => {
const plebbitInstanceFake = sandbox.fake.resolves({
createSubplebbit: sandbox.fake.resolves({ edit: editFake, ...currentSubProps, toJSONInternalRpc: () => currentSubProps }),
listSubplebbits: sandbox.fake.resolves(["plebbit.eth"]),
destroy: () => {}
});
//@ts-expect-error
Expand Down

0 comments on commit 2b4c245

Please sign in to comment.