-
Notifications
You must be signed in to change notification settings - Fork 35
feat: migrate Safepal to use Hub #986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arlert-armin
wants to merge
8
commits into
next
Choose a base branch
from
feat/rf-2139-migrate-safepal-to-hub
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+295
−69
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2e86e8b
feat: migrate safepal to hub
arlert-armin 27cdee2
feat: add eager connect
arlert-armin fbbbd28
feat: move conect to actions
arlert-armin c89e906
feat: remove eager connect
arlert-armin 6674d20
feat: make compatible with supported chains
arlert-armin 7eb0885
feat: update safepal readme
arlert-armin 6c1796f
feat: update readmes
arlert-armin b6cffe5
fix: don't rethrow error on switch network succeeded
arlert-armin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 +1,31 @@ | ||
# @rango-dev/provider-safepal | ||
# SafePal | ||
SafePal Wallet integration for hub. | ||
[Homepage](https://www.safepal.com/) | [Docs](http://devdocs.safepal.com/Connect-wallet/Web/introduction.html) | ||
|
||
More about implementation status can be found [here](../readme.md). | ||
|
||
## Implementation notes/limitations | ||
|
||
### Group | ||
|
||
#### EVM & Solana | ||
SafePal supports both EVM and Solana, which are implemented in this integration. | ||
The wallet also supports **TON, Sui, Tron, and Aptos**, but these namespaces are **not yet supported**. | ||
|
||
### Feature | ||
|
||
#### ⚠️ Switch Account | ||
- On **Solana**, switching accounts triggers a **full page reload**. | ||
- Since **auto-connect is not supported**, the wallet **does not reconnect automatically** after reload. | ||
- This results in both EVM and Solana **becoming disconnected** after switching accounts. | ||
|
||
#### ❌ Auto Connect | ||
- **Auto-connect is not supported**, as the wallet does **not support silent eager connection** on either EVM or Solana. | ||
- A **popup is always triggered** when attempting to connect. | ||
- Due to this limitation, **eager connect has been removed** from this integration. | ||
|
||
|
||
|
||
--- | ||
|
||
More wallet information can be found in [readme.md](../readme.md). |
This file contains hidden or 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,45 @@ | ||
import { type ProviderInfo } from '@rango-dev/wallets-core'; | ||
import { | ||
type BlockchainMeta, | ||
evmBlockchains, | ||
solanaBlockchain, | ||
} from 'rango-types'; | ||
|
||
export const WALLET_ID = 'safepal'; | ||
export const info: ProviderInfo = { | ||
name: 'SafePal', | ||
icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/safepal/icon.svg', | ||
extensions: { | ||
chrome: | ||
'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa', | ||
brave: | ||
'https://chrome.google.com/webstore/detail/safepal-extension-wallet/lgmpcpglpngdoalbgeoldeajfclnhafa', | ||
firefox: | ||
'https://addons.mozilla.org/en-US/firefox/addon/safepal-extension-wallet', | ||
homepage: 'https://www.safepal.com/download', | ||
}, | ||
properties: [ | ||
{ | ||
name: 'namespaces', | ||
value: { | ||
selection: 'multiple', | ||
data: [ | ||
{ | ||
label: 'EVM', | ||
value: 'EVM', | ||
id: 'ETH', | ||
getSupportedChains: (allBlockchains: BlockchainMeta[]) => | ||
evmBlockchains(allBlockchains), | ||
}, | ||
{ | ||
label: 'Solana', | ||
value: 'Solana', | ||
id: 'SOLANA', | ||
getSupportedChains: (allBlockchains: BlockchainMeta[]) => | ||
solanaBlockchain(allBlockchains), | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
6 changes: 4 additions & 2 deletions
6
wallets/provider-safepal/src/signer.ts → ...ets/provider-safepal/src/legacy/signer.ts
This file contains hidden or 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 hidden or 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,12 @@ | ||
import { defineVersions } from '@rango-dev/wallets-core/utils'; | ||
|
||
import { buildLegacyProvider } from './legacy/index.js'; | ||
import { buildProvider } from './provider.js'; | ||
|
||
const versions = () => | ||
defineVersions() | ||
.version('0.0.0', buildLegacyProvider()) | ||
.version('1.0.0', buildProvider()) | ||
.build(); | ||
|
||
export { versions }; |
This file contains hidden or 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,27 @@ | ||
import type { EvmActions } from '@rango-dev/wallets-core/namespaces/evm'; | ||
|
||
import { NamespaceBuilder } from '@rango-dev/wallets-core'; | ||
import { builders as commonBuilders } from '@rango-dev/wallets-core/namespaces/common'; | ||
import { actions, builders } from '@rango-dev/wallets-core/namespaces/evm'; | ||
|
||
import { WALLET_ID } from '../constants.js'; | ||
import { evmSafepal } from '../utils.js'; | ||
|
||
const [changeAccountSubscriber, changeAccountCleanup] = | ||
actions.changeAccountSubscriber(evmSafepal); | ||
const connect = builders | ||
.connect() | ||
.action(actions.connect(evmSafepal)) | ||
.before(changeAccountSubscriber) | ||
.or(changeAccountCleanup) | ||
.build(); | ||
const disconnect = commonBuilders | ||
.disconnect<EvmActions>() | ||
.after(changeAccountCleanup) | ||
.build(); | ||
|
||
const evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID) | ||
.action(connect) | ||
.action(disconnect) | ||
.build(); | ||
export { evm }; |
This file contains hidden or 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,28 @@ | ||
import type { SolanaActions } from '@rango-dev/wallets-core/namespaces/solana'; | ||
|
||
import { NamespaceBuilder } from '@rango-dev/wallets-core'; | ||
import { builders as commonBuilders } from '@rango-dev/wallets-core/namespaces/common'; | ||
import { actions, builders } from '@rango-dev/wallets-core/namespaces/solana'; | ||
|
||
import { WALLET_ID } from '../constants.js'; | ||
import { solanaSafepal } from '../utils.js'; | ||
|
||
const [changeAccountSubscriber, changeAccountCleanup] = | ||
actions.changeAccountSubscriber(solanaSafepal); | ||
const connect = builders | ||
.connect() | ||
.action(actions.connect(solanaSafepal)) | ||
.before(changeAccountSubscriber) | ||
.or(changeAccountCleanup) | ||
.build(); | ||
const disconnect = commonBuilders | ||
.disconnect<SolanaActions>() | ||
.after(changeAccountCleanup) | ||
.build(); | ||
|
||
const solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID) | ||
.action(connect) | ||
.action(disconnect) | ||
.build(); | ||
|
||
export { solana }; |
This file contains hidden or 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,26 @@ | ||
import { ProviderBuilder } from '@rango-dev/wallets-core'; | ||
|
||
import { info, WALLET_ID } from './constants.js'; | ||
import { evm } from './namespaces/evm.js'; | ||
import { solana } from './namespaces/solana.js'; | ||
import { safepal as safepalInstance } from './utils.js'; | ||
|
||
const buildProvider = () => | ||
new ProviderBuilder(WALLET_ID) | ||
.init(function (context) { | ||
// TODO: Remember to remove it. | ||
setTimeout(() => { | ||
const [, setState] = context.state(); | ||
if (safepalInstance()) { | ||
setState('installed', true); | ||
console.debug('[safepal] instance detected.', context); | ||
} | ||
}); | ||
}) | ||
|
||
.config('info', info) | ||
.add('solana', solana) | ||
.add('evm', evm) | ||
.build(); | ||
|
||
export { buildProvider }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.