Skip to content

Commit

Permalink
Merge pull request #137 from TanglePay/dev
Browse files Browse the repository at this point in the history
V1.6.4
  • Loading branch information
daihanqiao committed Apr 8, 2024
2 parents 335ae9d + a926191 commit 7734292
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 56 deletions.
16 changes: 8 additions & 8 deletions bin/template/iota-next-index-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3676,31 +3676,31 @@
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
if (expirationUnlockCondition && expirationUnlockCondition.returnAddress) {
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) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tangle-pay-chrome",
"version": "1.6.3",
"version": "1.6.4",
"private": true,
"homepage": "./",
"dependencies": {
Expand Down Expand Up @@ -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.4",
"web-vitals": "^1.0.1",
"web3": "^1.7.3",
"yup": "^0.32.11"
Expand Down
14 changes: 10 additions & 4 deletions public/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
}
Expand Down
10 changes: 8 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"],
Expand Down
62 changes: 32 additions & 30 deletions src/common/components/DappDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export const DappDialog = () => {
const ensureWalletStatus = () => {
checkWalletIsPasswordEnabled(curWallet.id).then((res) => {
setIsWalletPassowrdEnabled(res)
setPassword(context.state.pin)
if (!res) {
setPassword(context.state.pin)
} else {
setPassword('')
}
})
}
useEffect(() => {
Expand Down Expand Up @@ -236,7 +240,6 @@ export const DappDialog = () => {
break
case 'iota_im_authorize':
{

await Bridge.iota_im_authorized(curWallet, password, content, reqId)
}
break
Expand Down Expand Up @@ -479,16 +482,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'
Expand Down Expand Up @@ -525,8 +528,8 @@ export const DappDialog = () => {
.replace('#fee#', gasFee)
str = `${origin}<br/>` + 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,
Expand Down Expand Up @@ -650,25 +653,24 @@ export const DappDialog = () => {
show()
}
break
case 'iota_im_authorize':
{
let str = I18n.t('apps.ImAuthorize')
const texts = [
{
text: str.replace(/\n/g, '<br/>')
}
]
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, '<br/>')
}
]
setDappData({
texts,
return_url,
type,
content,
origin,
expires,
reqId
})
show()
}
default:
break
}
Expand All @@ -693,7 +695,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)
Expand All @@ -706,19 +708,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()
Expand Down
2 changes: 1 addition & 1 deletion src/panels/account/into/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const AccountIntoPin = () => {
</div>
)}
<Form.Item className={`mt10 pl0 ${errors.name && 'form-error'}`}>
<div className='fz16 mb10'>{I18n.t('account.intoName')}</div>
<div className='fz18 mb10'>{I18n.t('account.intoName')}</div>
<Input style={{ paddingTop: 3, paddingBottom: 3 }} placeholder={I18n.t('account.intoNameTips')} onChange={handleChange('name')} value={values.name} />
</Form.Item>
{shouldShowPin && (
Expand Down
9 changes: 8 additions & 1 deletion src/panels/assets/trading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -118,7 +119,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) {
Expand All @@ -132,6 +133,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 }
Expand All @@ -154,7 +157,11 @@ export const AssetsTrading = () => {
// }
Toast.hideLoading()
Toast.show(I18n.t('assets.acceptSucc'))
await sleep(500)
IotaSDK.refreshAssets()
if (info.nftId) {
refreshNftAssets()
}
setTimeout(() => {
IotaSDK.refreshAssets()
}, 3000)
Expand Down
4 changes: 2 additions & 2 deletions src/panels/main/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down Expand Up @@ -133,7 +133,7 @@ export const Assets = ({ tabKey }) => {
<div>
<div>
<CoinList />
{assetsTab.includes('stake') && <RewardsList />}
{/* {assetsTab.includes('stake') && <RewardsList />} */}
</div>
{!isRequestAssets ? (
<div className='ph30 pv24 flex c row'>
Expand Down
4 changes: 2 additions & 2 deletions src/panels/main/assets/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const CoinList = () => {
className='border-b flex flex1 row ac jsb'>
<div className='flex ac row'>
<div className='fz18 mr5'>{String(e.name).toLocaleUpperCase()}</div>
{!IotaSDK.isWeb3Node && statedAmount && e.realBalance > 0 && statedAmount > 0 && !needRestake ? (
{/* {!IotaSDK.isWeb3Node && statedAmount && e.realBalance > 0 && statedAmount > 0 && !needRestake ? (
<div
style={{
transform: 'scale(0.7)',
Expand All @@ -97,7 +97,7 @@ export const CoinList = () => {
className='fz12 border cS'>
{I18n.t('staking.title')}
</div>
) : null}
) : null} */}
</div>
{isShowAssets ? (
<div>
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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.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"
Expand Down

0 comments on commit 7734292

Please sign in to comment.