Skip to content

Commit

Permalink
Merge 2ce5272 into b19b834
Browse files Browse the repository at this point in the history
  • Loading branch information
wjisi committed Sep 26, 2019
2 parents b19b834 + 2ce5272 commit 7872974
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/deposit/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export default {
},
JFST: {
contract: "0x4c6007cea426e543551f2cb6392e6d6768f74706"
},
JPG: {
contract: "0x8bbea7dbb25e4f0006d77e00083808e7eb0d45e8"
}
},
ethTokens: {
Expand Down Expand Up @@ -274,7 +277,7 @@ export default {
depositEthereum(secret, address, amount, memo) {
return new Promise(async (resolve, reject) => {
const scAddress = "0x3907acb4c1818adf72d965c08e0a79af16e7ffb8";
const minLimit = 0.1;
const minLimit = 0.02;
this.changeLoadingState(this.$t("message.deposit.request_balance", { name: "ETH" }));
const instance = await fingateInstance.initWithContract("ethereum", this.getEthHost(), scAddress)
const { ethereumInstance, ethereumFingateInstance } = instance;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"transfering_gas": "燃料费扣取中"
},
"deposit": {
"eth_limit": "充币前请确保以太钱包保留0.1ETH(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)",
"eth_limit": "充币前请确保以太钱包保留0.02ETH(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)",
"failed": "充币失败,可能网络拥堵或余额不足,请稍后再试!",
"moac_limit": "充币前请确保墨客钱包保留0.1MOAC(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)",
"more_than_available_balance": "余额:{balance},请检查是否足够!",
Expand Down
27 changes: 15 additions & 12 deletions test/unit/specs/deposit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ describe('Deposit', () => {
},
JFST: {
contract: "0x4c6007cea426e543551f2cb6392e6d6768f74706"
},
JPG: {
contract: "0x8bbea7dbb25e4f0006d77e00083808e7eb0d45e8"
}
})
})
Expand Down Expand Up @@ -530,7 +533,7 @@ describe('Deposit', () => {

it("deposit eth: reject error if the balance is less than the sum of amount and limit", async function() {
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("1.0999999999999");
stub.resolves("1.01999999999999");
const spy = sandbox.spy(vm, "changeLoadingState");
const spy1 = sandbox.spy(Fingate.prototype, "depositState");
const spy2 = sandbox.spy(Fingate.prototype, "deposit");
Expand All @@ -544,13 +547,13 @@ describe('Deposit', () => {
expect(spy2.called).toBe(false);
expect(spy3.called).toBe(false);
expect(spy4.called).toBe(false);
expect(error.message).toBe("充币前请确保以太钱包保留0.1ETH(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)");
expect(error.message).toBe("充币前请确保以太钱包保留0.02ETH(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)");
}
});

it("deposit eth: reject error if has pending order", async function() {
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("1.1");
stub.resolves("1.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(pendingOrder);
const spy = sandbox.spy(vm, "changeLoadingState");
Expand All @@ -571,7 +574,7 @@ describe('Deposit', () => {

it("deposit eth: reject error if deposit failed", async function() {
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("1.1");
stub.resolves("1.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(notPendingState);
const stub2 = sandbox.stub(Fingate.prototype, "deposit");
Expand All @@ -590,7 +593,7 @@ describe('Deposit', () => {

it("deposit eth: resolve hash if deposit success", async function() {
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("1.1");
stub.resolves("1.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(notPendingState);
const stub2 = sandbox.stub(Fingate.prototype, "deposit");
Expand All @@ -613,7 +616,7 @@ describe('Deposit', () => {
wrapper.setData({ coin: "jjcc" })
wrapper.setProps({ coin: 'jjcc' });
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("0.0999999999999");
stub.resolves("0.0199999999999");
const spy = sandbox.spy(vm, "changeLoadingState");
const spy1 = sandbox.spy(Fingate.prototype, "depositState");
const spy2 = sandbox.spy(Fingate.prototype, "deposit");
Expand All @@ -630,7 +633,7 @@ describe('Deposit', () => {
expect(spy3.called).toBe(false);
expect(spy4.called).toBe(false);
expect(stub.calledOnceWithExactly(address)).toBe(true);
expect(error.message).toBe("充币前请确保以太钱包保留0.1ETH(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)");
expect(error.message).toBe("充币前请确保以太钱包保留0.02ETH(智能合约银关处理门槛,实际消耗gas会按照当前网络实况)");
}
});

Expand All @@ -642,7 +645,7 @@ describe('Deposit', () => {
const spy4 = sandbox.spy(Fingate.prototype, "deposit");
const spy5 = sandbox.spy(ERC20.prototype, "init");
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("0.1");
stub.resolves("0.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(pendingOrder);
try {
Expand All @@ -666,7 +669,7 @@ describe('Deposit', () => {
const spy2 = sandbox.spy(ERC20.prototype, "transfer");
const spy3 = sandbox.spy(Fingate.prototype, "deposit");
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("0.1");
stub.resolves("0.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(notPendingState);
const stub2 = sandbox.stub(ERC20.prototype, "balanceOf");
Expand All @@ -686,7 +689,7 @@ describe('Deposit', () => {
it("deposit erc20: reject error if transfer failed", async function() {
const spy = sandbox.spy(Fingate.prototype, "depositToken");
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("0.1");
stub.resolves("0.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(notPendingState);
const stub2 = sandbox.stub(ERC20.prototype, "decimals");
Expand All @@ -707,7 +710,7 @@ describe('Deposit', () => {

it("deposit erc20: resolve hash if depositToken first success and depositToken should be called only once", async function() {
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("0.1");
stub.resolves("0.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(notPendingState);
const stub2 = sandbox.stub(ERC20.prototype, "decimals");
Expand All @@ -729,7 +732,7 @@ describe('Deposit', () => {

it("deposit erc20: resolve hash if depositToken first failed and second success and depositToken should be called twice", async function() {
const stub = sandbox.stub(Ethereum.prototype, "getBalance");
stub.resolves("0.1");
stub.resolves("0.02");
const stub1 = sandbox.stub(Fingate.prototype, "depositState");
stub1.resolves(notPendingState);
const stub2 = sandbox.stub(ERC20.prototype, "decimals");
Expand Down

0 comments on commit 7872974

Please sign in to comment.