Skip to content

Commit

Permalink
feat(payments): require eth payment amount be string
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip London committed Mar 7, 2020
1 parent 3eb88a8 commit f829b98
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ export default ({
): Generator<PaymentType | CallEffect, boolean, any> {
let paymentError
try {
payment = yield payment.amount(
parseInt(convertStandardToBase(coin, amount))
)
switch (payment.coin) {
case 'PAX':
case 'ETH':
payment = yield payment.amount(
parseInt(convertStandardToBase(coin, amount)).toString()
)
break
default:
payment = yield payment.amount(
parseInt(convertStandardToBase(coin, amount))
)
}
payment = yield payment.to(destination, ADDRESS_TYPES.ADDRESS)
payment = yield payment.build()
// ask for second password
Expand Down
2 changes: 2 additions & 0 deletions packages/blockchain-wallet-v4/src/redux/payment/bch/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ export default ({ api }) => {
// ///////////////////////////////////////////////////////////////////////////
function create ({ network, payment } = { network: undefined, payment: {} }) {
const makePayment = p => ({
coin: 'BCH',

value () {
return p
},
Expand Down
2 changes: 2 additions & 0 deletions packages/blockchain-wallet-v4/src/redux/payment/btc/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ export default ({ api }) => {

function create ({ network, payment } = { network: undefined, payment: {} }) {
const makePayment = p => ({
coin: 'BTC',

value () {
return p
},
Expand Down
2 changes: 2 additions & 0 deletions packages/blockchain-wallet-v4/src/redux/payment/eth/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export default ({ api }) => {

function create ({ network, payment } = { network: undefined, payment: {} }) {
const makePayment = p => ({
coin: 'ETH',

value () {
return p
},
Expand Down
31 changes: 29 additions & 2 deletions packages/blockchain-wallet-v4/src/redux/payment/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CoinType } from 'core/types'

export type UTXOType = {
address: string
change: boolean
Expand Down Expand Up @@ -45,11 +47,36 @@ export type PaymentValue = {
to?: Array<any>
}

export type PaymentType = {
amount: (n: number | string) => PaymentType
type IPaymentType = {
build: () => PaymentType
publish: () => PaymentType
sign: (pw: string) => PaymentType
to: (address: string, addressType?: FromType) => PaymentType
value: () => PaymentValue
}

type BchPaymentType = IPaymentType & {
amount: (n: number) => BchPaymentType
coin: 'BCH'
}

type BtcPaymentType = IPaymentType & {
amount: (n: number) => BtcPaymentType
coin: 'BTC'
}

type EthPaymentType = IPaymentType & {
amount: (n: string) => EthPaymentType
coin: 'ETH' | 'PAX'
}

type XlmPaymentType = IPaymentType & {
amount: (n: number) => XlmPaymentType
coin: 'XLM'
}

export type PaymentType =
| BchPaymentType
| BtcPaymentType
| EthPaymentType
| XlmPaymentType
2 changes: 2 additions & 0 deletions packages/blockchain-wallet-v4/src/redux/payment/xlm/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export default ({ api }) => {

function create ({ payment } = { payment: {} }) {
const makePayment = p => ({
coin: 'XLM',

value () {
return p
},
Expand Down

0 comments on commit f829b98

Please sign in to comment.