Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9ada0c7

Browse files
committedJan 19, 2021
in app provider works, no redirect on ios
1 parent 10557df commit 9ada0c7

File tree

9 files changed

+24
-35
lines changed

9 files changed

+24
-35
lines changed
 

‎example/app/src/App.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ export default {
350350
};
351351
},
352352
mounted() {
353+
localStorage.debug = '*'
353354
console.log('LOADEDED'); // todo remove dev item
354355
// console.log(window.web3.currentProvider.isTrust); // todo remove dev item
355356
// this.thing = window.web3.currentProvider.isMewConnect;
@@ -664,16 +665,16 @@ export default {
664665
this.web3.eth.getTransactionCount(this.userAddress).then(nonce => {
665666
console.log('NONCE', nonce); // todo remove dev item
666667
this.web3.eth
667-
.sendTransaction({
668+
.signTransaction({
668669
from: this.userAddress,
669670
to: this.userAddress,
670671
nonce,
671672
value: 0,
672673
gasPrice: gasPrice,
673674
data: '0x',
674-
gas: 21000,
675-
gasLimit: 21000
676-
})
675+
gas: '0x5208',
676+
gasLimit: '0x5208'
677+
}, this.userAddress)
677678
.then(txhash => {
678679
console.log('THEN: ', txhash);
679680
this.signedTxNonStandard = txhash;

‎src/connectClient/constants/constants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ const lifeCycle = {
7070
Failed: 'failed',
7171
attemptedDisconnectedSend: 'attemptedDisconnectedSend',
7272
connected: 'connected',
73-
disconnected: 'disconnected'
73+
disconnected: 'disconnected',
74+
ShowReload: 'ShowReload'
7475
};
7576

7677
const communicationTypes = {

‎src/connectClient/initiator/MewConnectInitiator.js

+3
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ Keys
297297
this.V2.on('retryingViaTurn', () => {
298298
this.refreshCheck();
299299
});
300+
this.V2.on('ShowReload', () => {
301+
this.uiCommunicator('ShowReload');
302+
});
300303
} catch (e) {
301304
// eslint-disable-next-line
302305
console.error(e);

‎src/connectClient/initiator/MewConnectInitiatorV2.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,12 @@ export default class MewConnectInitiatorV2 extends MewConnectCommon {
505505
debug(err.code);
506506
debug('error', err);
507507
if (!this.connected && !this.tryingTurn && !this.turnDisabled) {
508+
console.log('USING FALLBACK'); // todo remove dev item
508509
this.useFallback();
509-
} else {
510+
} else if (!this.connected && this.tryingTurn && !this.turnDisabled) {
511+
this.emit('ShowReload');
512+
}
513+
else {
510514
if (!this.isAlive()) {
511515
this.uiCommunicator(this.lifeCycle.RtcErrorEvent);
512516
}

‎src/connectProvider/index.js

+2-26
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ export default class Integration extends EventEmitter {
4242
) {
4343
this.runningInApp = true;
4444
state.web3Provider = window.web3.currentProvider;
45-
// rpcCall; 1; [object Object]",
46-
// "ARGS rpcCall 4 {"jsonrpc":"2.0","id":4,"method":"eth_getBalance","params":["0x192627797720b7c5ec7b9faaeafa41ff49f866e3","latest"]}"
47-
// state.web3Provider.postMessage = (arg1, arg2, arg3) => {
48-
// console.log('ARGS', arg1, arg2, JSON.stringify(arg3)); // todo remove dev item
49-
// return window.web3.currentProvider.postMessage(arg1, arg2, arg3)
50-
// }
5145
} else {
5246
this.runningInApp = false;
5347
}
@@ -136,7 +130,7 @@ export default class Integration extends EventEmitter {
136130
MEWconnectWallet.setConnectionState(CONNECTED);
137131
resolve(address);
138132
})
139-
.catch(console.error); // todo remove dev item
133+
.catch(console.error);
140134
});
141135
}
142136

@@ -231,30 +225,12 @@ export default class Integration extends EventEmitter {
231225
let web3Provider;
232226
try {
233227
if (this.runningInApp) {
234-
console.log('not here'); // todo remove dev item
235-
console.log('not here'); // todo remove dev item
236228
if (state.web3Provider) {
237229
web3Provider = state.web3Provider;
238230
} else {
239231
web3Provider = window.web3.currentProvider;
240232
}
241-
// web3Provider = new MEWProvider(
242-
// window.web3.currentProvider,
243-
// {},
244-
// {
245-
// state: state
246-
// },
247-
// eventHub
248-
// );
249-
250-
// if (
251-
// (window.web3.currentProvider.isMewConnect ||
252-
// window.web3.currentProvider.isTrust) &&
253-
// this.runningInApp
254-
// ) {
255-
//
256-
// }
257-
// console.log('PROVIDER', web3Provider); // todo remove dev item
233+
258234
} else {
259235

260236
const chain = this.identifyChain(CHAIN_ID || 1);

‎src/connectProvider/platformDeepLinking.js

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export function nativeCheck() {
5555
let scheme = `${SCHEMA_BASE}?url=${url}`;
5656
window.location.replace(scheme);
5757
};
58+
if(iOS()){
59+
return resolve(true);
60+
}
5861
const triggerAppOpen = () => {
5962
openApp();
6063
setTimeout(fallbackToStore, 1000);

‎src/connectProvider/web3Provider/web3-provider/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import WSProvider from './providers/ws-provider';
2-
import InAppProvider from './providers/in-app-provider';
32
class MEWProvider {
43
constructor(host, options, store, eventHub) {
54
if (host && typeof host === 'string') {
65
return new WSProvider(host, options, store, eventHub);
76
}
8-
return new InAppProvider(host, options, store, eventHub);
97
}
108
}
119

‎src/connectProvider/web3Provider/web3-provider/providers/in-app-provider.js

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class InAppProvider {
1313
const values = ['eth_signTransaction', 'eth_sendTransaction'];
1414

1515
if (values.includes(argumentsList[0].method)) {
16+
if(argumentsList[0].method === values[0]){
17+
argumentsList[0].method = 'signTransaction'
18+
}
1619
const checks = async payloadInner => {
1720
// console.log('PAYLOAD_INNER send', JSON.stringify(payloadInner)); // todo remove dev item
1821
// console.log('PAYLOAD_INNER send2', payloadInner.method); // todo remove dev item

‎src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'core-js/stable';
1010
import 'regenerator-runtime/runtime';
1111
import MewConnectClient from './connectClient/index';
1212
import MewConnectProvider from './connectProvider/index';
13-
import icons from './Icon'
13+
import icons from './Icon';
1414

1515
export default {
1616
Initiator: MewConnectClient.Initiator,

0 commit comments

Comments
 (0)
Please sign in to comment.