-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from OneKeyHQ/support/lido
chore: modify readme & adapter lido icon
- Loading branch information
Showing
11 changed files
with
181 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
# - macOS-latest | ||
node_version: | ||
# - 14 | ||
- 16 | ||
- 18 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
const version = '1.1.53'; | ||
const version = '1.1.55'; | ||
const versionBuild = '2020-0101-1'; | ||
|
||
export default { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/providers/inpage-providers-hub/src/connectButtonHack/sites/_template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { createNewImageToContainer, hackConnectButton } from '../hackConnectButton'; | ||
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types'; | ||
import { WALLET_CONNECT_INFO } from '../consts'; | ||
|
||
hackConnectButton({ | ||
urls: ['stake.lido.fi'], // adapter to the site url, can have multiple urls. | ||
providers: [IInjectedProviderNames.ethereum], // provider class, example: IInjectedProviderNames.ethereum、IInjectedProviderNames.btc | ||
replaceMethod(options) { | ||
const replaceFunc = ({ | ||
findName, | ||
icon, | ||
text, | ||
}: { | ||
findName: string; | ||
icon: string; | ||
text: string; | ||
}) => { | ||
// find connect wallet button | ||
document.querySelector('div'); | ||
document.querySelectorAll('div'); | ||
|
||
// change button text | ||
// #1 nodeValue | ||
// element.nodeValue = text; | ||
|
||
// # 2 innerHTML | ||
// element.innerHTML = text; | ||
|
||
// change icon | ||
// #1 img element | ||
// element.src = icon; | ||
|
||
// #2 svg element | ||
// create new image | ||
// const imgContainer = findButton.querySelector('container') as HTMLElement | undefined; | ||
// if (imgContainer) { | ||
// createNewImageToContainer({ | ||
// container: imgContainer, | ||
// icon: icon, | ||
// removeSvg: true, | ||
// onCreated(img) { | ||
// img.style.maxWidth = '48px'; | ||
// img.style.maxHeight = '48px'; | ||
// }, | ||
// }); | ||
// } | ||
}; | ||
|
||
// Check whether the provider is enabled in the app. | ||
if (options?.providers?.includes(IInjectedProviderNames.ethereum)) { | ||
// Replace the button text and icon. | ||
replaceFunc({ | ||
findName: 'MetaMask', | ||
icon: WALLET_CONNECT_INFO.metamask.icon, | ||
text: WALLET_CONNECT_INFO.metamask.text, | ||
}); | ||
replaceFunc({ | ||
findName: 'WalletConnect', | ||
icon: WALLET_CONNECT_INFO.walletconnect.icon, | ||
text: WALLET_CONNECT_INFO.walletconnect.text, | ||
}); | ||
} | ||
}, | ||
}); |
71 changes: 71 additions & 0 deletions
71
packages/providers/inpage-providers-hub/src/connectButtonHack/sites/lidofi.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { createNewImageToContainer, hackConnectButton } from '../hackConnectButton'; | ||
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types'; | ||
import { WALLET_CONNECT_INFO } from '../consts'; | ||
|
||
hackConnectButton({ | ||
urls: ['stake.lido.fi'], | ||
providers: [IInjectedProviderNames.ethereum], | ||
replaceMethod(options) { | ||
const replaceFunc = ({ | ||
findName, | ||
icon, | ||
text, | ||
}: { | ||
findName: string; | ||
icon: string; | ||
text: string; | ||
}) => { | ||
const buttons = Array.from( | ||
document.querySelector('div.idjqeC')?.querySelectorAll('button') ?? [], | ||
); | ||
|
||
const findButton = buttons.find((button) => { | ||
const span = button.querySelector('span > span > div') as HTMLElement | undefined; | ||
if (span && span.innerText === findName) { | ||
return button; | ||
} | ||
return undefined; | ||
}); | ||
|
||
console.log('====findButton', findButton); | ||
|
||
|
||
if (findButton) { | ||
// change button text | ||
const span = findButton.querySelector('div') as HTMLElement | undefined; | ||
if (span) { | ||
span.innerText = text; | ||
} | ||
|
||
// change icon | ||
const imgContainer = findButton.querySelector('span > span >span') as | ||
| HTMLElement | ||
| undefined; | ||
if (imgContainer) { | ||
createNewImageToContainer({ | ||
container: imgContainer, | ||
icon: icon, | ||
removeSvg: true, | ||
onCreated(img) { | ||
img.style.maxWidth = '48px'; | ||
img.style.maxHeight = '48px'; | ||
}, | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
if (options?.providers?.includes(IInjectedProviderNames.ethereum)) { | ||
replaceFunc({ | ||
findName: 'MetaMask', | ||
icon: WALLET_CONNECT_INFO.metamask.icon, | ||
text: WALLET_CONNECT_INFO.metamask.text, | ||
}); | ||
replaceFunc({ | ||
findName: 'WalletConnect', | ||
icon: WALLET_CONNECT_INFO.walletconnect.icon, | ||
text: WALLET_CONNECT_INFO.walletconnect.text, | ||
}); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters