mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-02 12:53:24 +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 withdraw, { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/withdraw'
|
||||||
import { type Safe } from '~/routes/safe/store/model/safe'
|
import { type Safe } from '~/routes/safe/store/model/safe'
|
||||||
import Token from '#/test/Token.json'
|
import Token from '#/test/Token.json'
|
||||||
|
import { ensureOnce } from '~/utils/singleton'
|
||||||
|
|
||||||
export const addEtherTo = async (address: string, eth: string) => {
|
export const addEtherTo = async (address: string, eth: string) => {
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
@ -30,12 +31,20 @@ export const checkBalanceOf = async (addressToTest: string, value: string) => {
|
|||||||
expect(safeBalance).toBe(value)
|
expect(safeBalance).toBe(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addTknTo = async (safe: string, value: number) => {
|
const createTokenContract = async (web3: any, executor: string) => {
|
||||||
const web3 = getWeb3()
|
|
||||||
const token = contract(Token)
|
const token = contract(Token)
|
||||||
token.setProvider(web3.currentProvider)
|
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 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' })
|
await myToken.transfer(safe, value, { from: accounts[0], gas: '5000000' })
|
||||||
|
|
||||||
return myToken.address
|
return myToken.address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user