Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .changeset/plenty-ads-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ckb-ccc/ssri": minor
---

feat(ssri): `ExecutorResponse.mapAsync`

6 changes: 6 additions & 0 deletions .changeset/shy-horses-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ckb-ccc/udt": minor
---

feat(udt): `Udt.complete*` methods

12 changes: 12 additions & 0 deletions packages/core/src/ckb/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,12 @@ export class Transaction extends mol.Entity.Base<
);
}

/**
* @deprecated Use `Udt.getInputsBalance` from `@ckb-ccc/udt` instead
* @param client
* @param type
* @returns
*/
async getInputsUdtBalance(client: Client, type: ScriptLike): Promise<Num> {
return reduceAsync(
this.inputs,
Expand All @@ -1752,6 +1758,11 @@ export class Transaction extends mol.Entity.Base<
);
}

/**
* @deprecated Use `Udt.getOutputsBalance` from `@ckb-ccc/udt` instead
* @param type
* @returns
*/
getOutputsUdtBalance(type: ScriptLike): Num {
return this.outputs.reduce((acc, output, i) => {
if (!output.type?.eq(type)) {
Expand Down Expand Up @@ -1869,6 +1880,7 @@ export class Transaction extends mol.Entity.Base<
* This method succeeds only if enough balance is collected.
*
* It will try to collect at least two inputs, even when the first input already contains enough balance, to avoid extra occupation fees introduced by the change cell. An edge case: If the first cell has the same amount as the output, a new cell is not needed.
* @deprecated Use `Udt.completeInputsByBalance` from `@ckb-ccc/udt` instead
* @param from - The signer to complete the inputs.
* @param type - The type script of the UDT.
* @param balanceTweak - The tweak of the balance.
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/ckb/transactionErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export class ErrorTransactionInsufficientCapacity extends Error {
}
}

/**
* @deprecated Use `ErrorUdtInsufficientCoin` from `@ckb-ccc/udt` instead.
*/
export class ErrorTransactionInsufficientCoin extends Error {
public readonly amount: Num;
public readonly type: Script;
Expand Down
8 changes: 8 additions & 0 deletions packages/ssri/src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export class ExecutorResponse<T> {
throw new ExecutorErrorDecode(JSON.stringify(err));
}
}

async mapAsync<U>(fn: (res: T) => Promise<U>): Promise<ExecutorResponse<U>> {
try {
return new ExecutorResponse(await fn(this.res), this.cellDeps);
} catch (err) {
throw new ExecutorErrorDecode(JSON.stringify(err));
}
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/udt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
},
"scripts": {
"test": "jest",
"test": "vitest",
"build": "rimraf ./dist && rimraf ./dist.commonjs && tsc && tsc --project tsconfig.commonjs.json && copyfiles -u 2 misc/basedirs/**/* .",
"lint": "eslint ./src",
"format": "prettier --write . && eslint --fix ./src"
Expand Down
Loading