Skip to content

Commit

Permalink
chore(jellyfish-transaction-builder): add interface on the same packa…
Browse files Browse the repository at this point in the history
…ge (#2158)

<!--  Thanks for sending a pull request! -->

#### What this PR does / why we need it:
Having package build issues, need to make the package agnostic
<img width="1170" alt="image"
src="https://github.com/BirthdayResearch/jellyfishsdk/assets/13292662/61b19d4f-22d6-44b3-8c1c-a24e3ec80645">


#### Which issue(s) does this PR fixes?:
<!--
(Optional) Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Additional comments?:
  • Loading branch information
pierregee authored Sep 26, 2023
1 parent 8baa393 commit 950b21c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import BigNumber from 'bignumber.js'
import { Bech32, EllipticPair, Eth, HASH160, WIF } from '@defichain/jellyfish-crypto'
import { EllipticPairProvider, FeeRateProvider, Prevout, PrevoutProvider } from '../src'
import { EllipticPairProvider, FeeRateProvider, ListUnspentQueryOptions, Prevout, PrevoutProvider } from '../src'
import { MasterNodeRegTestContainer } from '@defichain/testcontainers'
import { OP_CODES, Script } from '@defichain/jellyfish-transaction'
import { randomEllipticPair } from './test.utils'
import { ListUnspentQueryOptions } from '@defichain/jellyfish-api-core/src/category/wallet'

export class MockFeeRateProvider implements FeeRateProvider {
constructor (
Expand Down
9 changes: 8 additions & 1 deletion packages/jellyfish-transaction-builder/src/provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BigNumber from 'bignumber.js'
import { EllipticPair } from '@defichain/jellyfish-crypto'
import { Vout } from '@defichain/jellyfish-transaction'
import { ListUnspentQueryOptions } from '@defichain/jellyfish-api-core/src/category/wallet'

export interface FeeRateProvider {
/**
Expand All @@ -10,6 +9,14 @@ export interface FeeRateProvider {
estimate: () => Promise<BigNumber>
}

export interface ListUnspentQueryOptions {
minimumAmount?: number
maximumAmount?: number
maximumCount?: number
minimumSumAmount?: number
tokenId?: string
}

export interface PrevoutProvider {
/**
* @return {Prevout[]} all outputs to create transaction, aka to send all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import {
} from '@defichain/jellyfish-transaction'
import { SignInputOption, TransactionSigner } from '@defichain/jellyfish-transaction-signature'
import BigNumber from 'bignumber.js'
import { EllipticPairProvider, FeeRateProvider, Prevout, PrevoutProvider } from '../provider'
import { EllipticPairProvider, FeeRateProvider, ListUnspentQueryOptions, Prevout, PrevoutProvider } from '../provider'
import { calculateFeeP2WPKH } from './txn_fee'
import { TxnBuilderError, TxnBuilderErrorType } from './txn_builder_error'
import { EllipticPair } from '@defichain/jellyfish-crypto'
import { Network } from '@defichain/jellyfish-network'
import { ListUnspentQueryOptions } from '@defichain/jellyfish-api-core/src/category/wallet'

const MAX_FEE_RATE = new BigNumber('0.00100000')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@defichain/jellyfish-transaction'
import { P2WPKHTxnBuilder } from './txn_builder'
import { TxnBuilderError, TxnBuilderErrorType } from './txn_builder_error'
import { ListUnspentQueryOptions } from '@defichain/jellyfish-api-core/src/category/wallet'
import { ListUnspentQueryOptions } from '../provider'

export class TxnBuilderAccount extends P2WPKHTxnBuilder {
/**
Expand Down

0 comments on commit 950b21c

Please sign in to comment.