完善各场景下的流程

This commit is contained in:
CounterFire2023 2023-09-13 19:09:25 +08:00
parent 5559ec1e43
commit aee73b2b42
3 changed files with 9 additions and 12 deletions

View File

@ -3,6 +3,7 @@ import init, {
hash_pass_svr, hash_pass_svr,
sign, sign,
sign_for_tran, sign_for_tran,
generate_sec_key,
wgenerate_client_key, wgenerate_client_key,
keccak256_hash, keccak256_hash,
} from '../../wasm/rustwallet.js'; } from '../../wasm/rustwallet.js';
@ -82,7 +83,7 @@ window.jsb = {
let seed = keccak256_hash(args[0] + args[1] + args[3]); let seed = keccak256_hash(args[0] + args[1] + args[3]);
let address = wget_address(seed, args[2], localSKey); let address = wget_address(seed, args[2], localSKey);
let key = generate_sec_key(seed, args[2], localSKey); let key = generate_sec_key(seed, args[2], localSKey);
return { address, key }; return JSON.stringify({ address, key });
}, },
hashSvrPass: function (msg) { hashSvrPass: function (msg) {
return hash_pass_svr(msg); return hash_pass_svr(msg);
@ -159,7 +160,7 @@ window.addEventListener('walletcb', (e) => {
} }
}); });
const directMethod = new Set(['chainList', 'currentChain']); const directMethod = new Set(['chainList', 'currentChain', 'exportWalletSecKey', 'formatPrice', 'tokenList']);
function callMethod(...args) { function callMethod(...args) {
var methodName = args.shift(); var methodName = args.shift();
let funid = ((Math.random() * 100000 + Math.random() * 1000) | 0) + ''; let funid = ((Math.random() * 100000 + Math.random() * 1000) | 0) + '';
@ -174,6 +175,10 @@ function callMethod(...args) {
} }
window.callMethod = callMethod; window.callMethod = callMethod;
window.callProxyMethod = callProxyMethod;
window.proxyCallback = proxyCallback;
window.nativeCall = nativeCall;
window.callNative = callNative;
(async () => { (async () => {
await initWasm(); await initWasm();

View File

@ -54,15 +54,6 @@ const pages = {
console.log(res); console.log(res);
}, },
loginSign: async function () {
let res = await callMethod('loginSign', '123455', 'login request');
console.log(res);
},
exportWalletSecKey: async function () {
let res = await callMethod('exportWalletSecKey', '111111');
console.log(res);
},
getEthBalance: async function () { getEthBalance: async function () {
let res = await callMethod('getEthBalance', address); let res = await callMethod('getEthBalance', address);

View File

@ -54,7 +54,8 @@
var s = document.createElement('script'); var s = document.createElement('script');
s.async = true; s.async = true;
if (sub[1] == 1)s.type = 'module'; if (sub[1] == 1)s.type = 'module';
s.src = src + (src.indexOf("?") == -1 ? "?" : "&") + "t=" + Date.now(); //s.src = src + (src.indexOf("?") == -1 ? "?" : "&") + "t=" + Date.now();
s.src =src;
s.addEventListener('load', function () { s.addEventListener('load', function () {
console.log(`<< finish load script: ${src}`); console.log(`<< finish load script: ${src}`);
s.parentNode.removeChild(s); s.parentNode.removeChild(s);