Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 15 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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,41 @@ defmodule AdminAPI.V1.BlockchainWalletControllerTest do
end)
end

test_with_auths "accepts string `amount` attribute" do
identifier = BlockchainHelper.rootchain_identifier()
hot_wallet = BlockchainWallet.get_primary_hot_wallet(identifier)

token =
insert(:external_blockchain_token,
blockchain_address: "0x0000000000000000000000000000000000000000"
)

adapter = BlockchainHelper.adapter()
{:ok, _adapter_pid} = adapter.server().start_link([])

attrs = %{
token_id: token.id,
amount: Integer.to_string(100),
address: hot_wallet.address,
idempotency_token: UUID.generate()
}

response = request("/blockchain_wallet.deposit_to_childchain", attrs)
assert response["success"]
assert response["data"]["from"]["amount"] == 100

transaction = Transaction.get(response["data"]["id"], preload: :blockchain_transaction)
{:ok, pid} = BlockchainTransactionTracker.lookup(transaction.blockchain_transaction_uuid)

{:ok, %{pid: blockchain_listener_pid}} =
adapter.lookup_listener(transaction.blockchain_transaction.hash)

on_exit(fn ->
:ok = GenServer.stop(pid)
:ok = GenServer.stop(blockchain_listener_pid)
end)
end

test_with_auths "fails to deposit with a missing address" do
token = insert(:token, blockchain_address: "0x0000000000000000000000000000000000000000")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ defmodule EWallet.TransactionGate.Childchain do

@eth BlockchainHelper.adapter().helper().default_token().address

def deposit(actor, %{"amount" => amount} = attrs) when is_integer(amount) do
def deposit(actor, %{"amount" => amount} = attrs)
when is_integer(amount) or is_binary(amount) do
case build_transaction_attrs(attrs) do
{:ok, attrs} ->
validation_tuple = address_validation_tuple(attrs)
Expand Down
4 changes: 2 additions & 2 deletions apps/ewallet_config/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ config :ewallet_config,
value: "http://localhost:9656",
type: "string",
position: 210,
description: "The url used by the eWallet to interact with the OmiseGO Network's node."
description: "The URL for the OMG Network child chain."
},
"omisego_watcher_url" => %{
key: "omisego_watcher_url",
value: "http://localhost:7534",
type: "string",
position: 211,
description: "The url used by the eWallet to interact with the OmiseGO Network's watcher."
description: "The URL for the OMG Network information service."
},
"omisego_plasma_framework_address" => %{
key: "omisego_plasma_framework_address",
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/assets/src/omg-blockchain-wallet/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export const selectBlockchainWalletById = state => id => state.blockchainWallets

export const selectBlockchainWalletsLoadingStatus = state => state.loadingStatus.blockchainWallets

export const selectPlasmaDepositByAddress = state => address => {
export const selectPlasmaDepositByAddress = address => state => {
return state.plasmaDeposits[address]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React from 'react'
import { useDispatch } from 'react-redux'
import styled from 'styled-components'

import PopperRenderer from 'omg-popper'
import withDropdownState from 'omg-uikit/dropdown/withDropdownState'
import { openModal } from 'omg-modal/action'
import { Icon, Button } from 'omg-uikit'
import { DropdownBox } from 'omg-uikit/dropdown'

const DropdownItem = styled.div`
padding: 7px 10px;
padding-right: 20px;
font-size: 12px;
color: ${props => props.theme.colors.B100};
cursor: pointer;
i,
span {
vertical-align: middle;
display: inline-block;
}
:hover {
color: ${props => props.theme.colors.B400};
}
i {
margin-right: 5px;
}
`
const ButtonStyle = styled(Button)`
margin-left: 10px;
i {
margin-left: 10px;
margin-right: 0 !important;
}
`

interface BlockchainActionSelectorProps {
name: string
onClickButton: React.MouseEventHandler
open: boolean
actions: Array<{
name: string
modal: { id: string; args: {} }
icon: string
}>
fromAddress: string
}

const BlockchainActionSelector = ({
name,
actions,
open,
onClickButton,
fromAddress
}: BlockchainActionSelectorProps) => {
const dispatch = useDispatch()

const renderDropdown = () => {
return (
<DropdownBox>
{actions.map((action, index) => {
const onClick = () =>
dispatch(
openModal({
id: action.modal.id,
fromAddress,
...action.modal.args
})
)
return (
<DropdownItem key={index} onClick={onClick}>
<Icon name={action.icon} />
<span>{action.name}</span>
</DropdownItem>
)
})}
</DropdownBox>
)
}

const renderButton = () => {
return (
<ButtonStyle size="small" styleType="primary" onClick={onClickButton}>
<span>{name}</span>
{open ? <Icon name="Chevron-Up" /> : <Icon name="Chevron-Down" />}
</ButtonStyle>
)
}

return (
<PopperRenderer
offset="0px, 5px"
modifiers={{
flip: { enabled: false },
preventOverflow: { enabled: false }
}}
renderReference={renderButton}
open={open}
renderPopper={renderDropdown}
/>
)
}

export default withDropdownState(BlockchainActionSelector)

This file was deleted.

Loading