-
Notifications
You must be signed in to change notification settings - Fork 148
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
Expo Version ([email protected]) #2361
Comments
After some discussion with @rubixvi , we found out that bumping the expo version might not solve their issue. The following text and code is a followup from them. Code snippetsimport { AccountId, Client, TransferTransaction, Hbar } from '@hashgraph/sdk';
const client = Client.forTestnet().setOperator(
process.env.EXPO_PUBLIC_ACCOUNT_ID ?? '',
process.env.EXPO_PUBLIC_PRIVATE_KEY ?? ''
);
const confirmTransaction = async () => {
setModalVisible(false);
try {
const sanitizedRecipientId = sanitizeRecipientId(recipientId);
const sanitizedAmount = sanitizeAmount(amount);
const sanitizedMemo = sanitizeMemo(memo);
const hbarAmount = Number(sanitizedAmount);
if (isNaN(hbarAmount) || hbarAmount <= 0) {
setAlertType('error');
setAlertMessage('Invalid amount. Please enter a valid number.');
return;
}
if (sanitizedRecipientId === accountId) {
setAlertType('error');
setAlertMessage('Please check the payment address.');
return;
}
const transaction = await new TransferTransaction()
.addHbarTransfer(accountId, Hbar.fromTinybars(-hbarAmount * 100000000)) // Convert HBAR to tinybars
.addHbarTransfer(sanitizedRecipientId, Hbar.fromTinybars(hbarAmount * 100000000))
.setTransactionMemo(sanitizedMemo)
.execute(client);
const receipt = await transaction.getReceipt(client);
const status = receipt.status;
if (status.toString() === 'SUCCESS') {
setAlertType('success');
setAlertMessage('Sending Complete');
setReceiptNumber(transaction.transactionId.toString());
clearInputs();
} else {
setAlertType('error');
setAlertMessage('Sending Failed');
}
} catch (error) {
setAlertType('error');
setAlertMessage('Sending Failed');
console.error('Error during transaction:', error);
}
}; package.json:
Running a buffer: import { Buffer } from "buffer";
globalThis.Buffer = Buffer; Layout: import "react-native-get-random-values"
import "./shims-buffer";
import '@ethersproject/shims'; Error
|
Hello @rubixvi, Can I please have the code for |
const sanitizeRecipientId = (input: string): string => { const sanitizeAmount = (input: string): string => { const sanitizeMemo = (input: string): string => { Just a simple script to prevent the wrong inputs. |
Hello, @rubixvi. We managed to reproduce your issue on Android using Android Studio's emulator by following these steps.
In iOS this was working fine. As you said the web version does not have this problem neither. After some investigation we found out that altho expo shows an error with or by running this code: const response = await new AccountCreateTransaction()
.setKey(privateKey)
.execute(client);
const receipt = await response.getReceipt(client);
console.log(receipt); Thank you for your code snippets for the sanitisation methods you useI asked you for the sanitisation methods because I wanted to be sure that there isn't some base64 encoding that you were doing to the memo. I tested that but this wasn't the issue as I tried running the script without any sanitisation and it was still throwing an error in Android environment. We also tried to deserialise and serialise it back. For two reasons:
const response = await new AccountCreateTransaction()
.setKey(privateKey)
.toBytes();
Transaction.fromBytes(response).execute(client); The following code didn't throw an error and correctly deserialised the transaction with expected data. Our current theory is that there is some issue with Thank you for raising this issue. Will keep you updated if there's some response from Expo related issue that I have created: expo/expo#30503 |
Thanks, glad that's all cleared up, Atleast it wasn't my coding. |
Description
The current Expo Version in the SDK is ^49.0.16 within the script.
However, the latest Expo Version is [email protected]
Can we get this updated?
Currently, by passing it with npm install --save @hashgraph/sdk --legacy-peer-deps
Steps to reproduce
Additional context
PS F:\XRL Wallet\dev> npm install --save @hashgraph/sdk
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @hashgraph/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/expo
npm WARN peer expo@"" from [email protected]
npm WARN node_modules/expo-application
npm WARN expo-application@"~5.9.0" from [email protected]
npm WARN node_modules/expo-auth-session
npm WARN 15 more (expo-asset, expo-camera, expo-constants, expo-contacts, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peerOptional expo@"^49.0.16" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/cryptography
npm WARN @hashgraph/cryptography@"1.4.8-beta.5" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/sdk
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/expo
npm WARN peerOptional expo@"^49.0.16" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/cryptography
npm WARN @hashgraph/cryptography@"1.4.8-beta.5" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/sdk
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @hashgraph/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/expo-crypto
npm WARN expo-crypto@"~13.0.0" from [email protected]
npm WARN node_modules/expo-auth-session
npm WARN expo-auth-session@"~5.5.2" from the root project
npm WARN 1 more (the root project)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peerOptional expo-crypto@"^10.1.2" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/cryptography
npm WARN @hashgraph/cryptography@"1.4.8-beta.5" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/sdk
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/expo-crypto
npm WARN peerOptional expo-crypto@"^10.1.2" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/cryptography
npm WARN @hashgraph/cryptography@"1.4.8-beta.5" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/sdk
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @hashgraph/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/expo-random
npm WARN expo-random@"~14.0.1" from the root project
npm WARN
npm WARN Could not resolve dependency:
npm WARN peerOptional expo-random@"^12.1.2" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/cryptography
npm WARN @hashgraph/cryptography@"1.4.8-beta.5" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/sdk
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/expo-random
npm WARN peerOptional expo-random@"^12.1.2" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/cryptography
npm WARN @hashgraph/cryptography@"1.4.8-beta.5" from @hashgraph/[email protected]
npm WARN node_modules/@hashgraph/sdk
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @hashgraph/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/expo
npm ERR! peer expo@"" from [email protected]
npm ERR! node_modules/expo-application
npm ERR! expo-application@"~5.9.0" from [email protected]
npm ERR! node_modules/expo-auth-session
npm ERR! expo-auth-session@"~5.5.2" from the root project
npm ERR! peer expo@"*" from [email protected]
npm ERR! node_modules/expo-asset
npm ERR! expo-asset@"~10.0.9" from [email protected]
npm ERR! 14 more (expo-camera, expo-constants, expo-contacts, expo-crypto, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional expo@"^49.0.16" from @hashgraph/[email protected]
npm ERR! node_modules/@hashgraph/sdk
npm ERR! @hashgraph/sdk@"^2.47.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/expo
npm ERR! peerOptional expo@"^49.0.16" from @hashgraph/[email protected]
npm ERR! node_modules/@hashgraph/sdk
npm ERR! @hashgraph/sdk@"^2.47.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Hedera network
other
Version
v2.47.0
Operating system
Windows
The text was updated successfully, but these errors were encountered: