Skip to content

Commit

Permalink
refactor: replace error w/ 0 balance
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcrazycoder committed Oct 31, 2023
1 parent fabbd3c commit d2df96e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 3 additions & 6 deletions packages/sdk/src/brc20/BRC20TransferBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ export class BRC20TransferBase extends Inscriber {
address: address
})
const balance = balances.find((b) => b.tick === tick)
if (!balance) {
throw new Error("Owner does not have any balance for this token")
}

return {
total: balance.total,
available: balance.available,
transferable: balance.transferable
total: balance?.total || 0,
available: balance?.available || 0,
transferable: balance?.transferable || 0
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/src/brc20/BRC20TransferExecutor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { generateTxUniqueIdentifier, Inscription, processInput, PSBTBuilder } from ".."
import { generateTxUniqueIdentifier, Inscription, processInput } from ".."
import { PSBTBuilder } from "../transactions/PSBTBuilder"
import { BRC20TransferBase } from "./BRC20TransferBase"
import { BRC20TransferExecutorOptions, BRC20TransferPayloadAttributes } from "./types"

Expand Down Expand Up @@ -83,7 +84,7 @@ export class BRC20TransferExecutor extends PSBTBuilder {

if (!isBRC20TransferInscription) continue

if (content.amt === this.amount.toString()) {
if (content.amt >= this.amount.toString()) {
filterInscriptions.push({
...inscription,
content
Expand Down

0 comments on commit d2df96e

Please sign in to comment.