Skip to content

Commit

Permalink
Merge branch 'develop' into revamp-wallet-screen
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed Sep 23, 2021
2 parents 083b20e + 591c9b1 commit 7adba52
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -54,7 +54,7 @@
"@cardano-foundation/ledgerjs-hw-app-cardano": "3.2.0",
"@emurgo/cip14-js": "2.0.0",
"@emurgo/cip4-js": "1.0.5",
"@emurgo/react-native-haskell-shelley": "2.0.0",
"@emurgo/react-native-haskell-shelley": "3.0.0",
"@formatjs/intl": "^1.14.1",
"@formatjs/intl-datetimeformat": "^4.2.3",
"@formatjs/intl-getcanonicallocales": "^1.7.3",
Expand Down
4 changes: 4 additions & 0 deletions src/config/networks.js
Expand Up @@ -306,3 +306,7 @@ export const DEFAULT_ASSETS: Array<Object> = flatten(
throw new Error(`Missing default asset for network type ${JSON.stringify(network)}`)
}),
)

// Same as serialization-lib
export const MAX_OUTPUT_SIZE = 4000
export const MAX_TX_SIZE = 8000
31 changes: 13 additions & 18 deletions src/crypto/shelley/transactions.js
Expand Up @@ -37,11 +37,13 @@ import {BigNumber} from 'bignumber.js'
import type {RawUtxo} from '../../api/types'
/* eslint-enable camelcase */
import {CONFIG} from '../../config/config'
import {MAX_OUTPUT_SIZE, MAX_TX_SIZE} from '../../config/networks'
import {AssetOverflowError, InsufficientFunds, NoOutputsError} from '../errors'
import type {
Address,
AddressedUtxo,
Addressing,
ProtocolParameters,
TxOutput,
V4UnsignedTxAddressedUtxoResponse,
V4UnsignedTxUtxoResponse,
Expand Down Expand Up @@ -76,13 +78,7 @@ export const sendAllUnsignedTxFromUtxo = async (
receiver: {|...Address, ...InexactSubset<Addressing>|},
allUtxos: Array<RawUtxo>,
absSlotNumber: BigNumber,
protocolParams: {|
linearFee: LinearFee,
minimumUtxoVal: BigNum,
poolDeposit: BigNum,
keyDeposit: BigNum,
networkId: number,
|},
protocolParams: ProtocolParameters,
auxiliaryData: AuxiliaryData | void,
): Promise<V4UnsignedTxUtxoResponse> => {
const totalBalance = allUtxos
Expand All @@ -97,6 +93,10 @@ export const sendAllUnsignedTxFromUtxo = async (
protocolParams.minimumUtxoVal,
protocolParams.poolDeposit,
protocolParams.keyDeposit,
// $FlowFixMe sketchy-null-number
protocolParams.maxOutputSize || MAX_OUTPUT_SIZE,
// $FlowFixMe sketchy-null-number
protocolParams.maxTxSize || MAX_TX_SIZE,
)
await txBuilder.set_ttl(absSlotNumber.plus(defaultTtlOffset).toNumber())
for (const input of allUtxos) {
Expand Down Expand Up @@ -308,13 +308,7 @@ export const newAdaUnsignedTxFromUtxo = async (
changeAdaAddr: void | {|...Address, ...Addressing|},
utxos: Array<RawUtxo>,
absSlotNumber: BigNumber,
protocolParams: {|
linearFee: LinearFee,
minimumUtxoVal: BigNum,
poolDeposit: BigNum,
keyDeposit: BigNum,
networkId: number,
|},
protocolParams: ProtocolParameters,
certificates: $ReadOnlyArray<Certificate>,
withdrawals: $ReadOnlyArray<{|
address: RewardAddress,
Expand Down Expand Up @@ -354,6 +348,10 @@ export const newAdaUnsignedTxFromUtxo = async (
protocolParams.minimumUtxoVal,
protocolParams.poolDeposit,
protocolParams.keyDeposit,
// $FlowFixMe sketchy-null-number
protocolParams.maxOutputSize || MAX_OUTPUT_SIZE,
// $FlowFixMe sketchy-null-number
protocolParams.maxTxSize || MAX_TX_SIZE,
)
if (certificates.length > 0) {
const certsNative = await Certificates.new()
Expand Down Expand Up @@ -603,10 +601,7 @@ async function minRequiredForChange(
txBuilder: TransactionBuilder,
changeAdaAddr: {|...Address, ...Addressing|},
value: Value,
protocolParams: {
linearFee: LinearFee,
minimumUtxoVal: BigNum,
},
protocolParams: $Shape<ProtocolParameters>,
): Promise<BigNum> {
if (changeAdaAddr == null) throw new NoOutputsError()
const wasmChange = await normalizeToAddress(changeAdaAddr.address)
Expand Down
11 changes: 11 additions & 0 deletions src/crypto/types.js
Expand Up @@ -5,6 +5,7 @@ import {
Certificate as V4Certificate,
TransactionBuilder as V4TransactionBuilder,
} from '@emurgo/react-native-haskell-shelley'
import {LinearFee} from '@emurgo/react-native-haskell-shelley'
import {BigNumber} from 'bignumber.js'

import type {RawUtxo} from '../api/types'
Expand Down Expand Up @@ -158,3 +159,13 @@ export type PlateResponse = {|
addresses: Array<string>,
accountPlate: WalletChecksum,
|}

export type ProtocolParameters = {|
+linearFee: LinearFee,
+minimumUtxoVal: BigNumber,
+poolDeposit: BigNumber,
+keyDeposit: BigNumber,
+networkId: number,
+maxOutputSize?: number,
+maxTxSize?: number,
|}
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -2267,10 +2267,10 @@
buffer-crc32 "0.2.13"
fnv-plus "1.3.1"

"@emurgo/react-native-haskell-shelley@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@emurgo/react-native-haskell-shelley/-/react-native-haskell-shelley-2.0.0.tgz#7d1591c6ca9d904a68e7e7edcb700ac6660c5864"
integrity sha512-vs5TX6Bv4cPxtyXQlxxoA8oThouaBNzqamJ34Tog5Gy3rtf24g4xCWxhdD2coIGid80Mi9qfV5NE38NYIOOlag==
"@emurgo/react-native-haskell-shelley@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@emurgo/react-native-haskell-shelley/-/react-native-haskell-shelley-3.0.0.tgz#3a545b83edd3a1e2582553c4217fc82ceafd3ec9"
integrity sha512-p/AQSHASu2+GlXVI2wq7A54HF7p4boprIVLB9NDM2an7EAaRyDixJYLyxnlsdVykf9dHWXijBLuqLMZPVGHSUg==
dependencies:
base-64 "0.1.0"

Expand Down

0 comments on commit 7adba52

Please sign in to comment.