Skip to content
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

Update sdk-core #1283

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[v3.0.1](https://github.com/multiversx/mx-sdk-dapp/pull/1284)] - 2024-10-22
- [Upgrade sdk-core to v.13.12.0](https://github.com/multiversx/mx-sdk-dapp/pull/1283)

## [⚠️ Breaking ⚠️[v3.0.0](https://github.com/multiversx/mx-sdk-dapp/pull/1282)] - 2024-10-21
- [Upgrade providers login methods & signMessage. Upgrade sdk-core to v.13](https://github.com/multiversx/mx-sdk-dapp/pull/1279)

Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "3.0.0",
"version": "3.0.1",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down Expand Up @@ -38,7 +38,7 @@
"@babel/preset-react": "7.23.3",
"@babel/preset-typescript": "7.23.3",
"@ledgerhq/hw-transport-mocker": "6.27.17",
"@multiversx/sdk-core": ">= 13.5.0",
"@multiversx/sdk-core": ">= 13.12.0",
"@octokit/rest": "19.0.5",
"@storybook/addon-actions": "6.5.14",
"@storybook/addon-essentials": "6.5.14",
Expand Down Expand Up @@ -124,7 +124,7 @@
"transaction"
],
"peerDependencies": {
"@multiversx/sdk-core": ">= 13.5.0",
"@multiversx/sdk-core": ">= 13.12.0",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"axios": ">=1.7.4",
Expand Down Expand Up @@ -166,7 +166,6 @@
"@multiversx/sdk-native-auth-client": "1.0.9",
"@multiversx/sdk-opera-provider": "1.0.0-alpha.1",
"@multiversx/sdk-passkey-provider": "1.0.9",
"@multiversx/sdk-wallet": "4.6.0",
"@multiversx/sdk-wallet-connect-provider": "5.0.0",
"@multiversx/sdk-web-wallet-cross-window-provider": "2.0.1",
"@multiversx/sdk-web-wallet-iframe-provider": "2.0.1",
Expand Down
19 changes: 13 additions & 6 deletions src/hooks/login/useLoginService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRef } from 'react';
import { Address, SignableMessage } from '@multiversx/sdk-core';
import { Address, Message } from '@multiversx/sdk-core';
import { useGetAccount } from 'hooks/account';
import { useDispatch, useSelector } from 'reduxStore/DappProviderContext';
import { networkSelector, tokenLoginSelector } from 'reduxStore/selectors';
Expand Down Expand Up @@ -105,9 +105,9 @@ export const useLoginService = (config?: OnProviderLoginType['nativeAuth']) => {
nativeAuthClientConfig
}: {
signMessageCallback: (
messageToSign: SignableMessage,
messageToSign: Message,
options: Record<any, any>
) => Promise<SignableMessage>;
) => Promise<Message>;
nativeAuthClientConfig?: NativeAuthConfigType;
}) => {
const nativeAuthClient = nativeAuth(
Expand All @@ -122,14 +122,21 @@ export const useLoginService = (config?: OnProviderLoginType['nativeAuth']) => {
if (!loginToken) {
return;
}
const messageToSign = new SignableMessage({

const messageToSign = new Message({
address: new Address(address),
message: Buffer.from(`${address}${loginToken}`)
data: Buffer.from(`${address}${loginToken}`)
});

const signedMessage = await signMessageCallback(messageToSign, {});

if (!signedMessage?.signature) {
throw 'Message not signed';
}

const nativeAuthToken = setTokenLoginInfo({
address,
signature: signedMessage.getSignature().toString('hex')
signature: Buffer.from(signedMessage.signature).toString('hex')
});

return nativeAuthToken;
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/signMessage/getVerifier.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Address } from '@multiversx/sdk-core/out';
import { UserPublicKey, UserVerifier } from '@multiversx/sdk-wallet';
import { Address, UserPublicKey, UserVerifier } from '@multiversx/sdk-core';

export const getVerifier = (address: string) => {
const publicKey = new UserPublicKey(Address.fromString(address).pubkey());
const publicKey = new UserPublicKey(new Address(address).pubkey());

return new UserVerifier(publicKey);
};
Loading