-
Notifications
You must be signed in to change notification settings - Fork 233
feat: MultiversX support #756
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
popenta
wants to merge
27
commits into
enkryptcom:develop
Choose a base branch
from
multiversx:multiversx-integration
base: develop
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.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a410cbc
wip: multiversx integration
popenta 9b4d6e8
add MultiversX Signer
popenta 2ad75f1
add tests for multiversx signer
popenta f174495
wip: integration
popenta ba30e5a
wip: mvx provider
popenta 288e59e
fix mvx icon
popenta 8d5b0b2
fix typo
popenta f0b5ea8
account state and token balance
popenta 2fd06be
fix display transaction age
popenta 8a7ceae
activity handler
popenta 0c66cc3
wip: send transaction flow
popenta 104935c
transaction timestamp fix
popenta 856300c
Merge branch 'main' into multiversx-integration
popenta 4e85dd0
update mvx sdk and fixes
popenta 0ed3504
small fixes
popenta 01d99e2
wip: nft/esdt integration
popenta 8bee4ad
add support for esdt & nft tokens
popenta a49a6aa
esdt token integration
popenta 1421b8b
Merge branch 'main' into multiversx-integration
popenta a9f9d4f
small fixes
popenta 85968fc
update readme
popenta e59c3e4
fix displaying incorrect transaction status after sending tx
popenta 37e6dc1
set token when sending from token details
popenta b4a2ada
Merge pull request #754 from enkryptcom/develop
kvhnuke 6cfc45f
Merge branch 'main' into multiversx-integration
popenta e9558d9
change api and explorer url for mainnet
popenta 3127bb2
small fixes
popenta 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import PublicKeyRing from '@/libs/keyring/public-keyring'; | ||
|
|
||
| import getUiPath from '@/libs/utils/get-ui-path'; | ||
| import { | ||
| BackgroundProviderInterface, | ||
| ProviderName, | ||
| ProviderRPCRequest, | ||
| } from '@/types/provider'; | ||
| import getRequestProvider from '@enkryptcom/request'; | ||
| import { MiddlewareFunction, OnMessageResponse } from '@enkryptcom/types'; | ||
| import EventEmitter from 'events'; | ||
| import Middlewares from './methods'; | ||
| import Networks from './networks/index'; | ||
| import { MultiversXNetwork } from './types/mvx-network'; | ||
| import UIRoutes from './ui/routes/names'; | ||
|
|
||
| class MultiversXProvider | ||
| extends EventEmitter | ||
| implements BackgroundProviderInterface | ||
| { | ||
| override listeners(event: string | symbol): ((...args: any[]) => void)[] { | ||
| // Cast each Function to the expected type | ||
| return super.listeners(event) as ((...args: any[]) => void)[]; | ||
| } | ||
|
|
||
| UIRoutes = UIRoutes; | ||
| toWindow: (message: string) => void; | ||
| network: MultiversXNetwork; | ||
| requestProvider: any; | ||
| middlewares: MiddlewareFunction[] = []; | ||
| namespace: ProviderName; | ||
| KeyRing: PublicKeyRing; | ||
|
|
||
| constructor( | ||
| toWindow: (message: string) => void, | ||
| network: MultiversXNetwork = Networks.multiversx, | ||
| ) { | ||
| super(); | ||
| this.network = network; | ||
| this.toWindow = toWindow; | ||
| this.setMiddleWares(); | ||
| this.requestProvider = getRequestProvider('', this.middlewares); | ||
| this.requestProvider.on('notification', (notif: any) => { | ||
| this.sendNotification(JSON.stringify(notif)); | ||
| }); | ||
| this.namespace = ProviderName.multiversx; | ||
| this.KeyRing = new PublicKeyRing(); | ||
| } | ||
|
|
||
| private setMiddleWares(): void { | ||
| this.middlewares = Middlewares.map(mw => mw.bind(this)); | ||
| } | ||
|
|
||
| setRequestProvider(network: MultiversXNetwork): void { | ||
| this.network = network; | ||
| this.requestProvider.changeNetwork(network.node); | ||
| } | ||
|
|
||
| request(request: ProviderRPCRequest): Promise<OnMessageResponse> { | ||
| return this.requestProvider | ||
| .request(request) | ||
| .then((res: any) => ({ | ||
| result: JSON.stringify(res), | ||
| })) | ||
| .catch((e: { message: any }) => ({ | ||
| error: JSON.stringify(e.message), | ||
| })); | ||
| } | ||
|
|
||
| async sendNotification(notif: string): Promise<void> { | ||
| return this.toWindow(notif); | ||
| } | ||
|
|
||
| async isPersistentEvent(): Promise<boolean> { | ||
| return false; | ||
| } | ||
|
|
||
| getUIPath(page: string): string { | ||
| return getUiPath(page, this.namespace); | ||
| } | ||
| } | ||
|
|
||
| export default MultiversXProvider; | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize RequestProvider with the active network node.
Creating it with an empty string may route requests incorrectly until a later network change. Initialize with
network.nodeup front.🤖 Prompt for AI Agents