From 768e429ccbd118c032d374bd1228bca9c71c873c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=BB=B4?= Date: Mon, 19 Feb 2024 11:31:42 +0800 Subject: [PATCH 01/11] improve: im authorize process --- public/js/background.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/js/background.js b/public/js/background.js index 89ea7a4..d184973 100644 --- a/public/js/background.js +++ b/public/js/background.js @@ -1087,12 +1087,18 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { reqId, dappOrigin: dappOrigin, method - }) + }) + if (pendingImRequests[key].isAuthorizing && pendingImRequests[key].lastAuthroizingTimestamp && (Date.now() - pendingImRequests[key].lastAuthroizingTimestamp > 15 * 1000)) { + pendingImRequests[key].isAuthorizing = false + } if (!pendingImRequests[key].isAuthorizing) { pendingImRequests[key].isAuthorizing = true - setTimeout(() => { - pendingImRequests[key].isAuthorizing = false - }, 15 * 1000) + pendingImRequests[key].lastAuthroizingTimestamp = Date.now() + + // Sometimes it does not execute. + // setTimeout(() => { + // pendingImRequests[key].isAuthorizing = false + // }, 15 * 1000) const url = `tanglepay://iota_im_authorize?origin=${origin}&content=${dappOrigin}&expires=${expires}&reqId=${reqId}&isSilent=1` params.url = chrome.runtime.getURL('index.html') + `?url=${encodeURIComponent(url)}` } From 88caa524e4d68b0ddcaddb269030c340300010f9 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Mon, 4 Mar 2024 21:20:09 +0800 Subject: [PATCH 02/11] fix stake --- src/panels/main/assets/index.js | 4 ++-- src/panels/main/assets/list.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/panels/main/assets/index.js b/src/panels/main/assets/index.js index cac3bde..4af6c21 100644 --- a/src/panels/main/assets/index.js +++ b/src/panels/main/assets/index.js @@ -34,7 +34,7 @@ export const Assets = ({ tabKey }) => { const checkPush = (path) => { if (!curWallet.address) { if (isNewWalletFlow()) { - Base.push('/account/registerPin') + Base.push('/account/registerPin') } else { Base.push('/account/register') } @@ -133,7 +133,7 @@ export const Assets = ({ tabKey }) => {
- {assetsTab.includes('stake') && } + {/* {assetsTab.includes('stake') && } */}
{!isRequestAssets ? (
diff --git a/src/panels/main/assets/list.js b/src/panels/main/assets/list.js index bb0cbeb..35a889c 100644 --- a/src/panels/main/assets/list.js +++ b/src/panels/main/assets/list.js @@ -85,7 +85,7 @@ export const CoinList = () => { className='border-b flex flex1 row ac jsb'>
{String(e.name).toLocaleUpperCase()}
- {!IotaSDK.isWeb3Node && statedAmount && e.realBalance > 0 && statedAmount > 0 && !needRestake ? ( + {/* {!IotaSDK.isWeb3Node && statedAmount && e.realBalance > 0 && statedAmount > 0 && !needRestake ? (
{ className='fz12 border cS'> {I18n.t('staking.title')}
- ) : null} + ) : null} */}
{isShowAssets ? (
From f0d8b6e95211732589b3d4cf6416919197eaff47 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Thu, 14 Mar 2024 22:13:13 +0800 Subject: [PATCH 03/11] fix onAcceptNft --- src/panels/assets/trading/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/panels/assets/trading/index.js b/src/panels/assets/trading/index.js index 1a9c985..c288a59 100644 --- a/src/panels/assets/trading/index.js +++ b/src/panels/assets/trading/index.js @@ -118,7 +118,7 @@ export const AssetsTrading = () => { validateOnBlur={false} validateOnChange={false} validateOnMount={false} - validationSchema={(isLedger || !isWalletPasswordEnabled) ? schemaNopassword : schema} + validationSchema={isLedger || !isWalletPasswordEnabled ? schemaNopassword : schema} onSubmit={async (values) => { let { password } = values if (!isWalletPasswordEnabled) { @@ -132,6 +132,8 @@ export const AssetsTrading = () => { } try { Toast.showLoading() + const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) + await sleep(300) const info = { ...curInfo, curWallet: { ...curWallet, password } @@ -153,16 +155,17 @@ export const AssetsTrading = () => { // onDismiss(curInfo.blockId) // } Toast.hideLoading() - Toast.show(I18n.t('assets.acceptSucc')) - IotaSDK.refreshAssets() - setTimeout(() => { - IotaSDK.refreshAssets() - }, 3000) if (isLedger) { Base.replace('/main') } else { Base.goBack() } + Toast.show(I18n.t('assets.acceptSucc')) + await sleep(500) + IotaSDK.refreshAssets() + setTimeout(() => { + IotaSDK.refreshAssets() + }, 3000) } catch (error) { Toast.hideLoading() error = String(error) From dd072c547ee2fb4497fb16f629bf278a8227a6b6 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Fri, 15 Mar 2024 21:12:30 +0800 Subject: [PATCH 04/11] fix checkWalletIsPasswordEnabled --- src/common/components/DappDialog.js | 60 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/common/components/DappDialog.js b/src/common/components/DappDialog.js index 90cf039..c584f2a 100644 --- a/src/common/components/DappDialog.js +++ b/src/common/components/DappDialog.js @@ -38,7 +38,9 @@ export const DappDialog = () => { const ensureWalletStatus = () => { checkWalletIsPasswordEnabled(curWallet.id).then((res) => { setIsWalletPassowrdEnabled(res) - setPassword(context.state.pin) + if (!res) { + setPassword(context.state.pin) + } }) } useEffect(() => { @@ -236,7 +238,6 @@ export const DappDialog = () => { break case 'iota_im_authorize': { - await Bridge.iota_im_authorized(curWallet, password, content, reqId) } break @@ -479,16 +480,16 @@ export const DappDialog = () => { showValue = value / Math.pow(10, foundryData.decimals || 0) sendAmount = value showUnit = unit - } else if (IotaSDK.isIotaStardust(curNodeId)){ + } else if (IotaSDK.isIotaStardust(curNodeId)) { const iotaDecimal = IotaSDK.curNode?.decimal || 6 unit = 'IOTA' showValue = Base.formatNum(BigNumber(value).div(Math.pow(10, iotaDecimal)).valueOf(), iotaDecimal) - if(parseFloat(showValue) < Math.pow(10, -iotaDecimal)) { + if (parseFloat(showValue) < Math.pow(10, -iotaDecimal)) { showValue = Math.pow(10, -iotaDecimal) } sendAmount = BigNumber(showValue).times(Math.pow(10, iotaDecimal)).valueOf() showUnit = unit - }else { + } else { unit = unit || 'SMR' if (!['SMR', 'Glow', 'IOTA'].includes(unit)) { unit = 'SMR' @@ -525,8 +526,8 @@ export const DappDialog = () => { .replace('#fee#', gasFee) str = `${origin}
` + str - const dataFromLink = res.metadata ? {metadata: res.metadata} : null - const dataPerRequest = await Bridge.sendToContentScriptGetData('data_per_request_prefix_' + reqId) || dataFromLink + const dataFromLink = res.metadata ? { metadata: res.metadata } : null + const dataPerRequest = (await Bridge.sendToContentScriptGetData('data_per_request_prefix_' + reqId)) || dataFromLink setDappData({ texts: [{ text: str }], return_url, @@ -650,25 +651,24 @@ export const DappDialog = () => { show() } break - case 'iota_im_authorize': - { - let str = I18n.t('apps.ImAuthorize') - const texts = [ - { - text: str.replace(/\n/g, '
') - } - ] - setDappData({ - texts, - return_url, - type, - content, - origin, - expires, - reqId - }) - show() - } + case 'iota_im_authorize': { + let str = I18n.t('apps.ImAuthorize') + const texts = [ + { + text: str.replace(/\n/g, '
') + } + ] + setDappData({ + texts, + return_url, + type, + content, + origin, + expires, + reqId + }) + show() + } default: break } @@ -693,7 +693,7 @@ export const DappDialog = () => { if (canShowDappDialog) { const params = Base.handlerParams(window.location.search) const url = params.url - console.log('deeplinkurl',url) + console.log('deeplinkurl', url) if (checkDeepLink(url)) { // handle silent case let res = Base.handlerParams(url) @@ -706,19 +706,19 @@ export const DappDialog = () => { let [type, address] = path.split('/') res = Object.assign(res, { type, address }) } - console.log('dapp data',res) + console.log('dapp data', res) let { isSilent = '' } = res if (isSilent) { const isPasswordEnabled = await checkWalletIsPasswordEnabled(curWallet.id) if (!isPasswordEnabled) { console.log('entering silent ') - const {type, content, reqId} = res + const { type, content, reqId } = res let isSilentProcessed = false switch (type) { case 'iota_im_authorize': await Bridge.iota_im_authorized(curWallet, context.state.pin, content, reqId) isSilentProcessed = true - break; + break } if (isSilentProcessed) { Bridge.closeWindow() From 2ba24810243dcabdefbc6a63faa25b5a55a435ab Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Fri, 15 Mar 2024 22:03:17 +0800 Subject: [PATCH 05/11] fix checkWalletIsPasswordEnabled --- src/common/components/DappDialog.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/components/DappDialog.js b/src/common/components/DappDialog.js index c584f2a..8bc9105 100644 --- a/src/common/components/DappDialog.js +++ b/src/common/components/DappDialog.js @@ -40,6 +40,8 @@ export const DappDialog = () => { setIsWalletPassowrdEnabled(res) if (!res) { setPassword(context.state.pin) + } else { + setPassword('') } }) } From b754ed3023249ef9964cb7d84cf7441cc6c565ca Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Fri, 15 Mar 2024 22:32:41 +0800 Subject: [PATCH 06/11] fix refreshNftAssets --- src/panels/assets/trading/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/panels/assets/trading/index.js b/src/panels/assets/trading/index.js index c288a59..f0eb59c 100644 --- a/src/panels/assets/trading/index.js +++ b/src/panels/assets/trading/index.js @@ -26,6 +26,7 @@ export const AssetsTrading = () => { const id = params.id const [unlockConditions] = useStore('common.unlockConditions') const [nftUnlockList] = useStore('nft.unlockList') + const [, refreshNftAssets] = useStore('nft.forceRequest') useGetNftList() useGetAssetsList(curWallet) const [isWalletPasswordEnabled, setIsWalletPasswordEnabled] = useState(false) @@ -163,6 +164,9 @@ export const AssetsTrading = () => { Toast.show(I18n.t('assets.acceptSucc')) await sleep(500) IotaSDK.refreshAssets() + if (info.nftId) { + refreshNftAssets() + } setTimeout(() => { IotaSDK.refreshAssets() }, 3000) From 958d84ca62cd4f839be62ef020fa73be0adb4958 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Wed, 20 Mar 2024 22:57:24 +0800 Subject: [PATCH 07/11] fix hisList --- bin/template/iota-next-index-browser.js | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/bin/template/iota-next-index-browser.js b/bin/template/iota-next-index-browser.js index fed1726..7257b9f 100644 --- a/bin/template/iota-next-index-browser.js +++ b/bin/template/iota-next-index-browser.js @@ -2809,7 +2809,15 @@ const nonce = await this._powProvider.pow(blockBytes, minPowScore) block.nonce = nonce.toString() } - const response = await this.fetchJson(this._coreApiPath, 'post', 'blocks', block) + let response = {} + try { + response = await this.fetchJson(this._coreApiPath, 'post', 'blocks', block) + if (!response.blockId) { + throw new Error('route=/api/core/v2/blocks: failed to fetch') + } + } catch (error) { + throw new Error(error) + } return response.blockId } /** @@ -3676,16 +3684,16 @@ let unlockConditions = output?.output?.unlockConditions || [] // TIMELOCK_UNLOCK_CONDITION_TYPE - let timelockUnlockCondition = unlockConditions.find(e => e.type === TIMELOCK_UNLOCK_CONDITION_TYPE) - if(timelockUnlockCondition && nowTime > timelockUnlockCondition.unixTime) { + let timelockUnlockCondition = unlockConditions.find((e) => e.type === TIMELOCK_UNLOCK_CONDITION_TYPE) + if (timelockUnlockCondition && nowTime > timelockUnlockCondition.unixTime) { timelockUnlockCondition = null } - // Storage Deposit Return Unlock - let storageDepositReturnUnlockCondition = unlockConditions.find(e => e.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE) + // Storage Deposit Return Unlock + let storageDepositReturnUnlockCondition = unlockConditions.find((e) => e.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE) // Expiration Unlock Condition - let expirationUnlockCondition = unlockConditions.find(e => e.type === EXPIRATION_UNLOCK_CONDITION_TYPE) + let expirationUnlockCondition = unlockConditions.find((e) => e.type === EXPIRATION_UNLOCK_CONDITION_TYPE) let addressInExpirationUnlockCondition let unixTimeInExpirationUnlockCondition @@ -3693,14 +3701,14 @@ addressInExpirationUnlockCondition = hexToBech32(expirationUnlockCondition.returnAddress.pubKeyHash) unixTimeInExpirationUnlockCondition = expirationUnlockCondition.unixTime } - + if (addressInExpirationUnlockCondition && shimmerAddressList.includes(addressInExpirationUnlockCondition)) { - if(unixTimeInExpirationUnlockCondition < nowTime) { + if (unixTimeInExpirationUnlockCondition < nowTime) { expirationUnlockCondition = null storageDepositReturnUnlockCondition = null } } - + const features = output?.output?.features || [] let featuresLock = false if (features.length > 0) { From 2180cf7258f5491e4cb95c9a426122c9be906d47 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Fri, 22 Mar 2024 17:51:51 +0800 Subject: [PATCH 08/11] fix hisList --- bin/template/iota-next-index-browser.js | 10 +--------- src/panels/assets/trading/index.js | 10 +++++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/bin/template/iota-next-index-browser.js b/bin/template/iota-next-index-browser.js index 7257b9f..29188fd 100644 --- a/bin/template/iota-next-index-browser.js +++ b/bin/template/iota-next-index-browser.js @@ -2809,15 +2809,7 @@ const nonce = await this._powProvider.pow(blockBytes, minPowScore) block.nonce = nonce.toString() } - let response = {} - try { - response = await this.fetchJson(this._coreApiPath, 'post', 'blocks', block) - if (!response.blockId) { - throw new Error('route=/api/core/v2/blocks: failed to fetch') - } - } catch (error) { - throw new Error(error) - } + const response = await this.fetchJson(this._coreApiPath, 'post', 'blocks', block) return response.blockId } /** diff --git a/src/panels/assets/trading/index.js b/src/panels/assets/trading/index.js index f0eb59c..4491436 100644 --- a/src/panels/assets/trading/index.js +++ b/src/panels/assets/trading/index.js @@ -156,11 +156,6 @@ export const AssetsTrading = () => { // onDismiss(curInfo.blockId) // } Toast.hideLoading() - if (isLedger) { - Base.replace('/main') - } else { - Base.goBack() - } Toast.show(I18n.t('assets.acceptSucc')) await sleep(500) IotaSDK.refreshAssets() @@ -170,6 +165,11 @@ export const AssetsTrading = () => { setTimeout(() => { IotaSDK.refreshAssets() }, 3000) + if (isLedger) { + Base.replace('/main') + } else { + Base.goBack() + } } catch (error) { Toast.hideLoading() error = String(error) From 44e429cc0eb40cd637f4717bd24b24cf13ad5b5c Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Tue, 2 Apr 2024 17:37:49 +0800 Subject: [PATCH 09/11] V1.6.4 --- package.json | 4 ++-- public/manifest.json | 10 ++++++++-- src/panels/account/into/pin.js | 2 +- yarn.lock | 8 ++++---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 9970b6a..2db6c99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tangle-pay-chrome", - "version": "1.6.3", + "version": "1.6.4", "private": true, "homepage": "./", "dependencies": { @@ -47,7 +47,7 @@ "react-transition-group": "^4.4.2", "rimraf": "^5.0.1", "struct": "^0.0.12", - "tanglepay": "^2.7.1", + "tanglepay": "^2.7.2", "web-vitals": "^1.0.1", "web3": "^1.7.3", "yup": "^0.32.11" diff --git a/public/manifest.json b/public/manifest.json index e56e387..b82b1ce 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "TanglePay IOTA Wallet", - "version": "1.6.3", + "version": "1.6.4", "description": "TanglePay is your IOTA wallet available on Chrome to explore Defi, NFT and more.", "icons": { "16": "images/16.png", @@ -18,7 +18,13 @@ "service_worker": "./js/background.js" }, "permissions": ["storage", "unlimitedStorage"], - "host_permissions": ["https://test.api.iotacat.com/","https://test2.api.iotacat.com/","https://explorer-api.iota.org/", "https://node.iotaichi.com/", "https://api.lb-0.h.chrysalis-devnet.iota.cafe/"], + "host_permissions": [ + "https://test.api.iotacat.com/", + "https://test2.api.iotacat.com/", + "https://explorer-api.iota.org/", + "https://node.iotaichi.com/", + "https://api.lb-0.h.chrysalis-devnet.iota.cafe/" + ], "web_accessible_resources": [ { "resources": ["js/inject.js", "font/OpenSans-Regular.ttf", "font/OpenSans-Semibold.ttf"], diff --git a/src/panels/account/into/pin.js b/src/panels/account/into/pin.js index 66e89c9..3a63170 100644 --- a/src/panels/account/into/pin.js +++ b/src/panels/account/into/pin.js @@ -139,7 +139,7 @@ export const AccountIntoPin = () => {
)} -
{I18n.t('account.intoName')}
+
{I18n.t('account.intoName')}
{shouldShowPin && ( diff --git a/yarn.lock b/yarn.lock index 4bb9a74..1003686 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12123,10 +12123,10 @@ tailwindcss@^3.0.2: resolve "^1.22.2" sucrase "^3.32.0" -tanglepay@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/tanglepay/-/tanglepay-2.7.1.tgz#b396cc6f8d7c7e530c7759401b260bb815bb5703" - integrity sha512-UDlQ+3dGOdAK8KsB324kEzKenrJfq8HU7p3T8K7wel65jZxeD6LX2NDM6c0/hDySvD8lVnNWOajB+Br44JPeRw== +tanglepay@^2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/tanglepay/-/tanglepay-2.7.2.tgz#ec21a3f27e08826a9fd787d1b4a15485555e4a99" + integrity sha512-dQ0E30L3YnvOsevU6yFnnr9TxQIyql/2MasrIs7kxbBVKdg1YkubReRxbSTr7f59eAp5qkcsuFyZswGZxtBTlQ== tapable@^1.0.0: version "1.1.3" From ceeeed557f7391c815c020e93a337f5b92b8a279 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Tue, 2 Apr 2024 18:49:00 +0800 Subject: [PATCH 10/11] V1.6.4 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2db6c99..343212c 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "react-transition-group": "^4.4.2", "rimraf": "^5.0.1", "struct": "^0.0.12", - "tanglepay": "^2.7.2", + "tanglepay": "^2.7.3", "web-vitals": "^1.0.1", "web3": "^1.7.3", "yup": "^0.32.11" diff --git a/yarn.lock b/yarn.lock index 1003686..fad0988 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12123,10 +12123,10 @@ tailwindcss@^3.0.2: resolve "^1.22.2" sucrase "^3.32.0" -tanglepay@^2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/tanglepay/-/tanglepay-2.7.2.tgz#ec21a3f27e08826a9fd787d1b4a15485555e4a99" - integrity sha512-dQ0E30L3YnvOsevU6yFnnr9TxQIyql/2MasrIs7kxbBVKdg1YkubReRxbSTr7f59eAp5qkcsuFyZswGZxtBTlQ== +tanglepay@^2.7.3: + version "2.7.3" + resolved "https://registry.yarnpkg.com/tanglepay/-/tanglepay-2.7.3.tgz#bed221f7649ac63e227a1b3fffbcab2787c7e2d4" + integrity sha512-z7qp44pXMMI6fUT0XkDVsiu/94uwWPagASJwWw+SGz9DrEhf0oRklUk8kxGu3GE+jDpgIz4HYZvVwZs5XmsVCw== tapable@^1.0.0: version "1.1.3" From a9261912d4fed4e8c80f6e9e25b2811e8629f814 Mon Sep 17 00:00:00 2001 From: daihanqiao Date: Tue, 2 Apr 2024 19:16:01 +0800 Subject: [PATCH 11/11] V1.6.4 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 343212c..d5b8281 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "react-transition-group": "^4.4.2", "rimraf": "^5.0.1", "struct": "^0.0.12", - "tanglepay": "^2.7.3", + "tanglepay": "^2.7.4", "web-vitals": "^1.0.1", "web3": "^1.7.3", "yup": "^0.32.11" diff --git a/yarn.lock b/yarn.lock index fad0988..f42f9b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12123,10 +12123,10 @@ tailwindcss@^3.0.2: resolve "^1.22.2" sucrase "^3.32.0" -tanglepay@^2.7.3: - version "2.7.3" - resolved "https://registry.yarnpkg.com/tanglepay/-/tanglepay-2.7.3.tgz#bed221f7649ac63e227a1b3fffbcab2787c7e2d4" - integrity sha512-z7qp44pXMMI6fUT0XkDVsiu/94uwWPagASJwWw+SGz9DrEhf0oRklUk8kxGu3GE+jDpgIz4HYZvVwZs5XmsVCw== +tanglepay@^2.7.4: + version "2.7.4" + resolved "https://registry.yarnpkg.com/tanglepay/-/tanglepay-2.7.4.tgz#5edf2f081f7d1f749d0589e712eadce1616e0620" + integrity sha512-7jlg5Jmbm63srfQXtKD+qL3VD5LUxzOPwyoxC3rofEcF2MbWGnLb10SJf/YC0/VjYB5YrIRzLlqdh60eUiG2WA== tapable@^1.0.0: version "1.1.3"