Skip to content

Commit 7ab86a8

Browse files
committed
chore: getRelatedScripts adapts to all available scripts
1 parent f5dccd7 commit 7ab86a8

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

packages/core/src/signer/ckb/signerCkbMultisigReadonly.ts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -202,38 +202,40 @@ export class SignerCkbMultisigReadonly extends Signer {
202202
txLike: TransactionLike,
203203
): Promise<{ script: Script; cellDeps: CellDepInfo[] }[]> {
204204
const tx = Transaction.from(txLike);
205-
const multisig = await this.getAddressObjSecp256k1();
205+
const availableMultisigs = await this.getAddressObjs();
206206

207207
const scripts: { script: Script; cellDeps: CellDepInfo[] }[] = [];
208-
for (const input of tx.inputs) {
209-
const {
210-
cellOutput: { lock },
211-
} = await input.getCell(this.client);
212-
213-
if (scripts.some(({ script }) => script.eq(lock))) {
214-
continue;
215-
}
208+
for (const multisig of availableMultisigs) {
209+
for (const input of tx.inputs) {
210+
const {
211+
cellOutput: { lock },
212+
} = await input.getCell(this.client);
213+
214+
if (scripts.some(({ script }) => script.eq(lock))) {
215+
continue;
216+
}
216217

217-
if (lock.eq(multisig.script)) {
218-
const scriptInfo = await this.client.findKnownScript(lock);
219-
if (scriptInfo) {
220-
scripts.push({
221-
script: lock,
222-
cellDeps: scriptInfo.cellDeps,
223-
});
224-
} else {
225-
if (typeof this.multisigInfo.knownMultisigScript === "string") {
226-
// Generally, this branch could not be reached
227-
throw new Error(
228-
`Unsupported multisig script: ${this.multisigInfo.knownMultisigScript}`,
229-
);
218+
if (lock.eq(multisig.script)) {
219+
const scriptInfo = await this.client.findKnownScript(lock);
220+
if (scriptInfo) {
221+
scripts.push({
222+
script: lock,
223+
cellDeps: scriptInfo.cellDeps,
224+
});
225+
} else {
226+
if (typeof this.multisigInfo.knownMultisigScript === "string") {
227+
// Generally, this branch could not be reached
228+
throw new Error(
229+
`Unsupported multisig script: ${this.multisigInfo.knownMultisigScript}`,
230+
);
231+
}
232+
scripts.push({
233+
script: lock,
234+
cellDeps: this.multisigInfo.knownMultisigScript.cellDeps.map(
235+
(cellDep) => CellDepInfo.from(cellDep),
236+
),
237+
});
230238
}
231-
scripts.push({
232-
script: lock,
233-
cellDeps: this.multisigInfo.knownMultisigScript.cellDeps.map(
234-
(cellDep) => CellDepInfo.from(cellDep),
235-
),
236-
});
237239
}
238240
}
239241
}

0 commit comments

Comments
 (0)