Skip to content

Commit 3dc4241

Browse files
authored
Merge branch 'remove-old' into gen-manifests
2 parents f95d04e + a489763 commit 3dc4241

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

packages/cli/package/src/commands/provider/deal-exit.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -94,47 +94,49 @@ export default class DealExit extends BaseCommand<typeof DealExit> {
9494
}),
9595
)) as Awaited<ReturnType<ReturnType<Contracts["getDeal"]>["getWorkers"]>>[];
9696

97-
const workers = dealIds.flatMap((id, i) => {
97+
const dealWorkers = dealIds.map((id, i) => {
9898
const deal = contracts.getDeal(id);
9999
const workers = workersFromRPC[i];
100100

101-
if (workers === undefined) {
101+
return {
102+
dealId: id,
103+
workers: (workers ?? [])
104+
.filter((worker) => {
105+
return worker.provider.toLowerCase() === signerAddress;
106+
})
107+
.map((worker) => {
108+
return { worker, deal };
109+
}),
110+
};
111+
});
112+
113+
for (const { dealId, workers } of dealWorkers) {
114+
const [firstWorker, ...restWorkers] = workers;
115+
116+
if (firstWorker === undefined) {
102117
commandObj.warn(
103-
`Was not able to get workers for deal ${id} from chain. Skipping...`,
118+
`No workers found for address ${signerAddress} and deal id: ${dealId}`,
104119
);
105120

106-
return [];
121+
continue;
107122
}
108123

109-
return workers
110-
.filter((worker) => {
111-
return worker.provider.toLowerCase() === signerAddress;
112-
})
113-
.map((worker) => {
114-
return { worker, deal };
115-
});
116-
});
117-
118-
const [firstWorker, ...restWorkers] = workers;
119-
120-
if (firstWorker === undefined) {
121-
return commandObj.error(
122-
`No workers found for address ${signerAddress} and deal ids: ${dealIds.join(", ")}`,
124+
await signBatch(
125+
`Remove the following workers from deal ${dealId}:\n\n${workers
126+
.map(({ worker: { onchainId } }) => {
127+
return onchainId;
128+
})
129+
.join("\n")}`,
130+
[
131+
populateTx(
132+
firstWorker.deal.removeWorker,
133+
firstWorker.worker.onchainId,
134+
),
135+
...restWorkers.map(({ deal, worker: { onchainId } }) => {
136+
return populateTx(deal.removeWorker, onchainId);
137+
}),
138+
],
123139
);
124140
}
125-
126-
await signBatch(
127-
`Remove the following workers from deals:\n\n${workers
128-
.map(({ worker: { onchainId } }) => {
129-
return onchainId;
130-
})
131-
.join("\n")}`,
132-
[
133-
populateTx(firstWorker.deal.removeWorker, firstWorker.worker.onchainId),
134-
...restWorkers.map(({ deal, worker: { onchainId } }) => {
135-
return populateTx(deal.removeWorker, onchainId);
136-
}),
137-
],
138-
);
139141
}
140142
}

packages/cli/package/src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ declare namespace xbytes {
299299
add(bytes: HybridByte | HybridByte[]): ByteUnitObject;
300300
/**
301301
* Subtract byte(s) from the internal bytes, resulting in a new ByteUnitObject object with the value
302-
* @param bytes Byte(s) to subract from the root byte
302+
* @param bytes Byte(s) to subtract from the root byte
303303
*/
304304
subtract(bytes: HybridByte | HybridByte[]): ByteUnitObject;
305305
/**

0 commit comments

Comments
 (0)