Skip to content

Commit

Permalink
Fxed react demo. Changed package.
Browse files Browse the repository at this point in the history
  • Loading branch information
oable committed Aug 28, 2024
1 parent 21a6f33 commit 5a0a8c1
Show file tree
Hide file tree
Showing 19 changed files with 177 additions and 223 deletions.
1 change: 0 additions & 1 deletion __tests__/e2e/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
export async function itSolanaTokenSPL(provider: Web3 | JsonRpcProvider, connection: Connection, proxyUrl: string, neonProxyRpcApi: NeonProxyRpcApi, token: SPLToken, neonEvmProgram: PublicKey, solanaWallet: Keypair, neonWallet: Web3Account | Wallet, chainId: number, solanaUrl: string, skipPreflight = true) {
const amount = 0.1;
const balanceBefore = await splTokenBalance(connection, solanaWallet.publicKey, token);
if(!balanceBefore) return;
console.log(`Balance: ${balanceBefore?.uiAmount ?? 0} ${token.symbol}`);
try {
let transaction: Transaction;
Expand Down
15 changes: 4 additions & 11 deletions __tests__/e2e/transfers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { afterEach, beforeAll, describe, expect, it, jest } from '@jest/globals';
import {
Connection,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
Signer,
TokenAmount
} from '@solana/web3.js';
import { Connection, Keypair, LAMPORTS_PER_SOL, PublicKey, Signer } from '@solana/web3.js';
import { getAssociatedTokenAddressSync } from '@solana/spl-token';
import { Web3 } from 'web3';
import { Web3Account } from 'web3-eth-accounts';
Expand Down Expand Up @@ -368,17 +361,17 @@ describe('NEON token transfer tests', () => {
factoryAddress = process.env.FACTORY_ADDRESS || await deployFactory(NEON_PROXY_URL!);
console.log('Factory address:', factoryAddress);

if(factoryAddress) {
if (factoryAddress) {
customToken = await setupResourceForSpl(CHAIN_ID, NEON_PROXY_URL!, factoryAddress);
console.log('Resource setup complete. SPLToken:', customToken);
}
});

it('Should transfer 0.1 new custom SPL token from Solana to NeonEVM', async() => {
it('Should transfer 0.1 new custom SPL token from Solana to NeonEVM', async () => {
customToken.address_spl && await itSolanaTokenSPL(web3, connection, NEON_PROXY_URL!, neonProxyRpcApi, customToken, neonEvmProgram, solanaWallet, neonWallet, CHAIN_ID, SOLANA_URL!);
});

it('Should transfer 0.1 new custom token from NeonEVM to Solana', async() => {
it('Should transfer 0.1 new custom token from NeonEVM to Solana', async () => {
customToken.address_spl && await itNeonTokenMint(connection, web3, NEON_PROXY_URL!, faucet, customToken, solanaWallet, neonWallet);
});
});
Expand Down
4 changes: 2 additions & 2 deletions examples/neon-transfer-ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@ethersproject/providers": "~5.7.0",
"@ethersproject/units": "~5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@neonevm/token-transfer-core": "4.0.0-a2",
"@neonevm/token-transfer-ethers": "4.0.0-a2",
"@neonevm/token-transfer-core": "4.2.0",
"@neonevm/token-transfer-ethers": "4.2.0",
"big.js": "^6.2.1",
"bn.js": "^5.2.1"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/neon-transfer-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@neonevm/neon-transfer-demo-react",
"description": "NeonEVM token transfer library demo with multi-token support",
"version": "0.4.0",
"version": "0.4.1",
"private": true,
"scripts": {
"start": "react-app-rewired start",
Expand All @@ -28,8 +28,8 @@
]
},
"dependencies": {
"@neonevm/token-transfer-core": "4.0.0-a2",
"@neonevm/token-transfer-web3": "4.0.0-a2",
"@neonevm/token-transfer-core": "4.2.0",
"@neonevm/token-transfer-web3": "4.2.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
Expand Down
9 changes: 5 additions & 4 deletions examples/neon-transfer-react/src/neon-transfer-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ function NeonTransferApp() {

const neonProgram = useMemo(() => {
if (proxyStatus) {
return new PublicKey(proxyStatus?.NEON_EVM_ID!);
return new PublicKey(proxyStatus?.neonEvmProgramId!);
}
return new PublicKey(NEON_STATUS_DEVNET_SNAPSHOT.NEON_EVM_ID);
return new PublicKey(NEON_STATUS_DEVNET_SNAPSHOT.neonEvmProgramId);
}, [proxyStatus]);

const networkTokenMint = useMemo(() => {
const id = gasTokens.findIndex(i => parseInt(i.token_chain_id, 16) === chainId);
const id = gasTokens.findIndex(i => parseInt(i.tokenChainId, 16) === chainId);
if (id > -1) {
return new PublicKey(gasTokens[id].token_mint);
return new PublicKey(gasTokens[id].tokenMint);
}
return new PublicKey(NEON_TOKEN_MINT_DEVNET);
}, [gasTokens, chainId]);
Expand Down Expand Up @@ -200,6 +200,7 @@ function NeonTransferApp() {
const getProxyStatus = useCallback(async () => {
const proxyStatus = await proxyApi.evmParams();
const gasTokens = await proxyApi.nativeTokenList();
// @ts-ignore
setProxyStatus(proxyStatus);
setGasTokens(gasTokens);
}, [proxyApi]);
Expand Down
4 changes: 2 additions & 2 deletions examples/neon-transfer-web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"license": "ISC",
"dependencies": {
"@neonevm/token-transfer-core": "4.0.0-a2",
"@neonevm/token-transfer-web3": "4.0.0-a2",
"@neonevm/token-transfer-core": "4.2.0",
"@neonevm/token-transfer-web3": "4.2.0",
"big.js": "^6.2.1",
"bn.js": "^5.2.1",
"web3": "^4.5.0"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"@metaplex-foundation/mpl-token-metadata": "^3.2.0",
"@metaplex-foundation/umi": "^0.9.1",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.1",
"@neonevm/token-transfer-core": "4.1.1",
"@neonevm/token-transfer-ethers": "4.0.1",
"@neonevm/token-transfer-web3": "4.0.1",
"@neonevm/token-transfer-core": "4.2.0",
"@neonevm/token-transfer-ethers": "4.2.0",
"@neonevm/token-transfer-web3": "4.2.0",
"@solana/spl-token": "^0.3.8",
"@solana/web3.js": "^1.77.3",
"@types/big.js": "^6.1.6",
Expand Down
38 changes: 4 additions & 34 deletions packages/core/src/api/neon-proxy-rpc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GasToken, GasTokenV2, NeonEmulate, NeonProgramStatusV2, NeonProgramStatus, RPCResponse } from '../models';
import { GasToken, GasTokenV2, NeonEmulate, NeonProgramStatus, RPCResponse } from '../models';

export class NeonProxyRpcApi {
neonProxyRpcUrl = '';
Expand Down Expand Up @@ -28,44 +28,14 @@ export class NeonProxyRpcApi {
}

async evmParams(): Promise<Partial<NeonProgramStatus>> {
return this.proxy<NeonProgramStatusV2>('neon_getEvmParams', []).then(d => {
//Use data mapper
return {
NEON_ACCOUNT_SEED_VERSION: d.result.neonAccountSeedVersion,
NEON_EVM_ID: d.result.neonEvmProgramId,
NEON_EVM_STEPS_LAST_ITERATION_MAX: d.result.neonMaxEvmStepsInLastIteration,
NEON_EVM_STEPS_MIN: d.result.neonMinEvmStepsInIteration,
NEON_GAS_LIMIT_MULTIPLIER_NO_CHAINID: d.result.neonGasLimitMultiplierWithoutChainId,
NEON_HOLDER_MSG_SIZE: d.result.neonHolderMessageSize,
NEON_PAYMENT_TO_TREASURE: d.result.neonPaymentToTreasury,
NEON_STORAGE_ENTRIES_IN_CONTRACT_ACCOUNT: d.result.neonStorageEntriesInContractAccount,
NEON_TREASURY_POOL_COUNT: d.result.neonTreasuryPoolCount,
NEON_TREASURY_POOL_SEED: d.result.neonTreasuryPoolSeed,
}
});
return this.proxy<NeonProgramStatus>('neon_getEvmParams', []).then(({ result }) => result);
}

async gasTokenList(): Promise<GasToken[]> {
return this.proxy<GasTokenV2[]>('neon_getGasTokenList', []).then(d => {
return d.result.map((d) => {
return {
tokenName: d.tokenName,
tokenMint: d.tokenMint,
tokenChainId: d.tokenChainId,
};
});
});
return this.proxy<GasTokenV2[]>('neon_getGasTokenList', []).then(({ result }) => result);
}

async nativeTokenList(): Promise<GasToken[]> {
return this.proxy<GasTokenV2[]>('neon_getNativeTokenList', []).then(d => {
return d.result.map((d) => {
return {
tokenName: d.tokenName,
tokenMint: d.tokenMint,
tokenChainId: d.tokenChainId,
};
});
});
return this.proxy<GasTokenV2[]>('neon_getNativeTokenList', []).then(({ result }) => result);
}
}
2 changes: 2 additions & 0 deletions packages/core/src/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export const NEON_TOKEN_MINT_DEVNET = '89dre8rZjLNft7HoupGiyxu3MNftR577ZYu8bHe2k
export const SOL_TOKEN_MINT_DEVNET = '89dre8rZjLNft7HoupGiyxu3MNftR577ZYu8bHe2kK7g';
export const NEON_TOKEN_MINT_MAINNET = 'NeonTjSjsuo3rexg9o6vHuMXw62f9V7zvmu8M8Zut44';
export const SOL_TOKEN_MINT_MAINNET = 'NeonTjSjsuo3rexg9o6vHuMXw62f9V7zvmu8M8Zut44';

export const RENT_EPOCH_ZERO = 0;
60 changes: 21 additions & 39 deletions packages/core/src/data/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
import { GasToken, NeonProgramStatus } from '../models';

export const NEON_STATUS_MAINNET_SNAPSHOT: NeonProgramStatus = {
NEON_ACCOUNT_SEED_VERSION: 3,
NEON_ADDITIONAL_FEE: '0',
NEON_CHAIN_ID: '245022934',
NEON_COMPUTE_BUDGET_HEAP_FRAME: '262144',
NEON_COMPUTE_BUDGET_UNITS: '500000',
NEON_COMPUTE_UNITS: '500000',
NEON_EVM_STEPS_LAST_ITERATION_MAX: 1,
NEON_EVM_STEPS_MIN: 500,
NEON_GAS_LIMIT_MULTIPLIER_NO_CHAINID: 1000,
NEON_HEAP_FRAME: '262144',
NEON_HOLDER_MSG_SIZE: 950,
NEON_OPERATOR_PRIORITY_SLOTS: '16',
NEON_PAYMENT_TO_DEPOSIT: '5000',
NEON_PAYMENT_TO_TREASURE: 5000,
NEON_PKG_VERSION: '1.0.0',
NEON_POOL_COUNT: '128',
NEON_POOL_SEED: 'treasury_pool',
NEON_REQUEST_UNITS_ADDITIONAL_FEE: '0',
NEON_REVISION: '3cece008d1520c1183fbd59370a90b5e5350b9e7',
NEON_SEED_VERSION: '3',
NEON_STATUS_NAME: 'WORK',
NEON_STORAGE_ENTRIES_IN_CONTRACT_ACCOUNT: 64,
NEON_TOKEN_MINT: 'NeonTjSjsuo3rexg9o6vHuMXw62f9V7zvmu8M8Zut44',
NEON_TOKEN_MINT_DECIMALS: '9',
NEON_TREASURY_POOL_COUNT: 128,
NEON_TREASURY_POOL_SEED: 'treasury_pool',
NEON_EVM_ID: 'NeonVMyRX5GbCrsAHnUwx1nYYoJAtskU1bWUo6JGNyG'
neonAccountSeedVersion: 3,
neonEvmProgramId: 'NeonVMyRX5GbCrsAHnUwx1nYYoJAtskU1bWUo6JGNyG',
neonGasLimitMultiplierWithoutChainId: 1000,
neonHolderMessageSize: 950,
neonMaxEvmStepsInLastIteration: 0,
neonMinEvmStepsInIteration: 500,
neonPaymentToTreasury: 5000,
neonStorageEntriesInContractAccount: 64,
neonTreasuryPoolCount: 128,
neonTreasuryPoolSeed: 'treasury_pool'
};

export const NEON_STATUS_DEVNET_SNAPSHOT: Partial<NeonProgramStatus> = {
NEON_ACCOUNT_SEED_VERSION: 3,
NEON_EVM_ID: 'eeLSJgWzzxrqKv1UxtRVVH8FX3qCQWUs9QuAjJpETGU',
NEON_EVM_STEPS_LAST_ITERATION_MAX: 1,
NEON_EVM_STEPS_MIN: 500,
NEON_GAS_LIMIT_MULTIPLIER_NO_CHAINID: 1000,
NEON_HOLDER_MSG_SIZE: 950,
NEON_OPERATOR_PRIORITY_SLOTS: '16',
NEON_PAYMENT_TO_TREASURE: 5000,
NEON_STORAGE_ENTRIES_IN_CONTRACT_ACCOUNT: 64,
NEON_TREASURY_POOL_COUNT: 128,
NEON_TREASURY_POOL_SEED: 'treasury_pool'
export const NEON_STATUS_DEVNET_SNAPSHOT: NeonProgramStatus = {
neonAccountSeedVersion: 3,
neonEvmProgramId: 'eeLSJgWzzxrqKv1UxtRVVH8FX3qCQWUs9QuAjJpETGU',
neonGasLimitMultiplierWithoutChainId: 1000,
neonHolderMessageSize: 950,
neonMaxEvmStepsInLastIteration: 0,
neonMinEvmStepsInIteration: 500,
neonPaymentToTreasury: 5000,
neonStorageEntriesInContractAccount: 64,
neonTreasuryPoolCount: 128,
neonTreasuryPoolSeed: 'treasury_pool'
};

export const TOKEN_LIST_DEVNET_SNAPSHOT: GasToken[] = [{
Expand Down
Loading

0 comments on commit 5a0a8c1

Please sign in to comment.