From aee73b2b422b9afd20f5fb9ab32c29d3e0a8b259 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:09:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=90=84=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/scripts/libs/native_bridge.js | 9 +++++++-- assets/scripts/run_sample.js | 9 --------- index.html | 3 ++- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/assets/scripts/libs/native_bridge.js b/assets/scripts/libs/native_bridge.js index e8569cd..9288778 100644 --- a/assets/scripts/libs/native_bridge.js +++ b/assets/scripts/libs/native_bridge.js @@ -3,6 +3,7 @@ import init, { hash_pass_svr, sign, sign_for_tran, + generate_sec_key, wgenerate_client_key, keccak256_hash, } from '../../wasm/rustwallet.js'; @@ -82,7 +83,7 @@ window.jsb = { let seed = keccak256_hash(args[0] + args[1] + args[3]); let address = wget_address(seed, args[2], localSKey); let key = generate_sec_key(seed, args[2], localSKey); - return { address, key }; + return JSON.stringify({ address, key }); }, hashSvrPass: function (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) { var methodName = args.shift(); let funid = ((Math.random() * 100000 + Math.random() * 1000) | 0) + ''; @@ -174,6 +175,10 @@ function callMethod(...args) { } window.callMethod = callMethod; +window.callProxyMethod = callProxyMethod; +window.proxyCallback = proxyCallback; +window.nativeCall = nativeCall; +window.callNative = callNative; (async () => { await initWasm(); diff --git a/assets/scripts/run_sample.js b/assets/scripts/run_sample.js index f7da86c..d663154 100644 --- a/assets/scripts/run_sample.js +++ b/assets/scripts/run_sample.js @@ -54,15 +54,6 @@ const pages = { 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 () { let res = await callMethod('getEthBalance', address); diff --git a/index.html b/index.html index e18009e..b157189 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,8 @@ var s = document.createElement('script'); s.async = true; 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 () { console.log(`<< finish load script: ${src}`); s.parentNode.removeChild(s);