Skip to content

Commit

Permalink
fixes #13121
Browse files Browse the repository at this point in the history
  • Loading branch information
qfrank committed Jul 26, 2022
1 parent 46e5def commit 4c5f455
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions resources/js/provider.js
Expand Up @@ -246,18 +246,48 @@
payload: payload});

return new Promise(function (resolve, reject) {
callbacks[messageId] = {beta: true,
method: method,
resolve: resolve,
reject: reject};
});
if(requestArguments.callback){
callbacks[messageId] = {
beta: true,
method: method,
resolve: function (result) {
requestArguments.callback(null, result);
},
reject: function (error) {
requestArguments.callback(error, null);
}
};
}else {
callbacks[messageId] = {beta: true,
method: method,
resolve: resolve,
reject: reject};
}
});
};

// (DEPRECATED) Support for legacy send method
EthereumProvider.prototype.send = function (method, params = [])
EthereumProvider.prototype.send = function (param1, param2)
{
if (window.statusAppDebug) { console.log("send (legacy): " + method);}
return this.request({method: method, params: params});
// reference: https://docs.metamask.io/guide/ethereum-provider.html#legacy-methods
if(typeof param1 == 'object'){
//maybe ways of:
//1.ethereum.send(payload: JsonRpcRequest, callback: JsonRpcCallback): void;
//2.ethereum.send(payload: JsonRpcRequest): unknown;
if (window.statusAppDebug) {
console.log("send (legacy), payload: " + JSON.stringify(param1) + ", callback: "+param2);
}
return this.request({method: param1.method, params: param1.params, callback: param2});
}else if(typeof param1 == 'string'){
var method = param1;
var params = param2;
if (window.statusAppDebug) {
console.log("send (legacy), method: " + method + ", params: " + JSON.stringify(params));
}
return this.request({method: method, params: params});
}else {
throw new Error("unsupported call to send, param1: " + param1 + ", param2: " + param2)
}
}

// (DEPRECATED) Support for legacy sendSync method
Expand Down

0 comments on commit 4c5f455

Please sign in to comment.