mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-23 08:08:56 +00:00
WA-232 getting ERC 20 Token as a singleton call
This commit is contained in:
parent
677e7649d6
commit
624b39717f
@ -5,6 +5,7 @@ import { promisify } from '~/utils/promisify'
|
||||
import withdraw, { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/withdraw'
|
||||
import { type Safe } from '~/routes/safe/store/model/safe'
|
||||
import Token from '#/test/Token.json'
|
||||
import { ensureOnce } from '~/utils/singleton'
|
||||
|
||||
export const addEtherTo = async (address: string, eth: string) => {
|
||||
const web3 = getWeb3()
|
||||
@ -30,12 +31,20 @@ export const checkBalanceOf = async (addressToTest: string, value: string) => {
|
||||
expect(safeBalance).toBe(value)
|
||||
}
|
||||
|
||||
export const addTknTo = async (safe: string, value: number) => {
|
||||
const web3 = getWeb3()
|
||||
const createTokenContract = async (web3: any, executor: string) => {
|
||||
const token = contract(Token)
|
||||
token.setProvider(web3.currentProvider)
|
||||
|
||||
return token.new({ from: executor, gas: '5000000' })
|
||||
}
|
||||
|
||||
export const getTokenContract = ensureOnce(createTokenContract)
|
||||
|
||||
export const addTknTo = async (safe: string, value: number) => {
|
||||
const web3 = getWeb3()
|
||||
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
|
||||
const myToken = await token.new({ from: accounts[0], gas: '5000000' })
|
||||
|
||||
const myToken = await getTokenContract(web3, accounts[0])
|
||||
await myToken.transfer(safe, value, { from: accounts[0], gas: '5000000' })
|
||||
|
||||
return myToken.address
|
||||
|
Loading…
x
Reference in New Issue
Block a user