diff --git a/contracts/ark_starknet/src/executor.cairo b/contracts/ark_starknet/src/executor.cairo index 5045797b9..9c06fec98 100644 --- a/contracts/ark_starknet/src/executor.cairo +++ b/contracts/ark_starknet/src/executor.cairo @@ -41,16 +41,14 @@ impl OrderV1IntoOrderInfo of Into { } } } -//! Executor contract on Starknet for arkchain. + +//! Executor contract on Starknet //! //! This contract is responsible of executing the orders //! and move the assets accordingly. //! Once done, an event is emitted to confirm at the arkchain //! that the order was executed correctly. //! -//! In order to communicate with the Arkchain, this contract -//! uses the `appchain_messaging` contract dispatcher to send -//! messages. #[starknet::contract] mod executor { @@ -69,9 +67,6 @@ mod executor { use ark_oz::erc2981::{FeesRatio, FeesRatioDefault, FeesImpl}; use ark_oz::erc2981::{IERC2981Dispatcher, IERC2981DispatcherTrait}; - use ark_starknet::appchain_messaging::{ - IAppchainMessagingDispatcher, IAppchainMessagingDispatcherTrait, - }; use ark_starknet::interfaces::FeesAmount; use ark_starknet::interfaces::{IExecutor, IUpgradable, IMaintenance}; @@ -103,7 +98,6 @@ mod executor { admin_address: ContractAddress, arkchain_orderbook_address: ContractAddress, eth_contract_address: ContractAddress, - messaging_address: ContractAddress, chain_id: felt252, broker_fees: Map, ark_fees: FeesRatio, @@ -168,12 +162,10 @@ mod executor { ref self: ContractState, admin_address: ContractAddress, eth_contract_address: ContractAddress, - messaging_address: ContractAddress, chain_id: felt252 ) { self.admin_address.write(admin_address); self.eth_contract_address.write(eth_contract_address); - self.messaging_address.write(messaging_address); self.chain_id.write(chain_id); self.ark_fees.write(Default::default()); self.default_receiver.write(admin_address); @@ -271,10 +263,6 @@ mod executor { } } - fn get_messaging_address(self: @ContractState) -> ContractAddress { - self.messaging_address.read() - } - fn get_orderbook_address(self: @ContractState) -> ContractAddress { self.arkchain_orderbook_address.read() } @@ -287,12 +275,6 @@ mod executor { self.arkchain_orderbook_address.write(orderbook_address); } - fn update_messaging_address(ref self: ContractState, msger_address: ContractAddress) { - _ensure_admin(@self); - - self.messaging_address.write(msger_address); - } - fn update_eth_address(ref self: ContractState, eth_address: ContractAddress) { _ensure_admin(@self); @@ -598,11 +580,6 @@ mod executor { } fn _execute_order(ref self: ContractState, execution_info: ExecutionInfo) { - // assert( - // starknet::get_caller_address() == self.messaging_address.read(), - // 'Invalid msg sender' - // ); - // Check if execution_info.currency_contract_address is whitelisted _ensure_is_not_in_maintenance(@self); assert( diff --git a/contracts/ark_starknet/src/interfaces.cairo b/contracts/ark_starknet/src/interfaces.cairo index 98fb2264e..e2b02f514 100644 --- a/contracts/ark_starknet/src/interfaces.cairo +++ b/contracts/ark_starknet/src/interfaces.cairo @@ -22,8 +22,6 @@ trait IExecutor { fn update_admin_address(ref self: T, admin_address: ContractAddress); fn update_orderbook_address(ref self: T, orderbook_address: ContractAddress); fn update_eth_address(ref self: T, eth_address: ContractAddress); - fn update_messaging_address(ref self: T, msger_address: ContractAddress); - fn get_messaging_address(self: @T) -> ContractAddress; fn get_orderbook_address(self: @T) -> ContractAddress; fn update_arkchain_orderbook_address(ref self: T, orderbook_address: ContractAddress); fn set_broker_fees(ref self: T, fees_ratio: FeesRatio); diff --git a/examples/core/config/index.ts b/examples/core/config/index.ts index 220d3f073..cd2bb0ae5 100644 --- a/examples/core/config/index.ts +++ b/examples/core/config/index.ts @@ -77,10 +77,6 @@ export const starknetExecutorContract = verifyContractAddress( contracts.executor, "Executor" ); -export const arkchainOrderbookContract = verifyContractAddress( - contracts.orderbook, - "Orderbook" -); export const starknetCurrencyContract = verifyContractAddress( isDev && isDevContracts(contracts) ? contracts.eth : starknetEthContract, "Currency" @@ -101,6 +97,5 @@ export const config = createConfig({ starknetNetwork: network, starknetExecutorContract, starknetCurrencyContract, - arkchainNetwork: network, - arkchainOrderbookContract + arkchainNetwork: network }); diff --git a/examples/core/utils/whitelistBroker.ts b/examples/core/utils/whitelistBroker.ts deleted file mode 100644 index 4134124db..000000000 --- a/examples/core/utils/whitelistBroker.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Account, CallData } from "starknet"; - -import { Config } from "@ark-project/core"; - -export const whitelistBroker = async ( - config: Config, - adminAccount: Account, - brokerId: string -) => { - const { abi: orderbookAbi } = await config.arkProvider.getClassAt( - config.arkchainOrderbookContract - ); - - if (orderbookAbi === undefined) { - throw new Error("no abi."); - } - - const whitelist_hash_calldata = CallData.compile({ - broker_id: brokerId - }); - - const result = await adminAccount.execute({ - contractAddress: config.arkchainOrderbookContract, - entrypoint: "whitelist_broker", - calldata: whitelist_hash_calldata - }); - - await config.arkProvider.waitForTransaction(result.transaction_hash, { - retryInterval: 1000 - }); - - return result; -}; diff --git a/packages/core/src/actions/order/createAuction.ts b/packages/core/src/actions/order/createAuction.ts index 163f32f8f..c6180a100 100644 --- a/packages/core/src/actions/order/createAuction.ts +++ b/packages/core/src/actions/order/createAuction.ts @@ -42,9 +42,11 @@ const createAuction = async ( ) => { const { starknetAccount, order: baseOrder, approveInfo } = parameters; const currentDate = new Date(); - currentDate.setDate(currentDate.getDate() + 30); + currentDate.setDate(currentDate.getDate()); const startDate = baseOrder.startDate || Math.floor(Date.now() / 1000); - const endDate = baseOrder.endDate || Math.floor(currentDate.getTime() / 1000); + const endDate = + baseOrder.endDate || + Math.floor(currentDate.getTime() / 1000) + 60 * 60 * 24 * 7; const chainId = await config.starknetProvider.getChainId(); if (startDate < Math.floor(Date.now() / 1000)) { diff --git a/packages/core/src/actions/order/createListing.ts b/packages/core/src/actions/order/createListing.ts index 76bf43461..727418e83 100644 --- a/packages/core/src/actions/order/createListing.ts +++ b/packages/core/src/actions/order/createListing.ts @@ -42,9 +42,11 @@ const createListing = async ( ) => { const { starknetAccount, order: baseOrder, approveInfo } = parameters; const currentDate = new Date(); - currentDate.setDate(currentDate.getDate() + 30); + currentDate.setDate(currentDate.getDate()); const startDate = baseOrder.startDate || Math.floor(Date.now() / 1000); - const endDate = baseOrder.endDate || Math.floor(currentDate.getTime() / 1000); + const endDate = + baseOrder.endDate || + Math.floor(currentDate.getTime() / 1000) + 60 * 60 * 24 * 7; const chainId = await config.starknetProvider.getChainId(); const order: OrderV1 = { diff --git a/packages/core/src/actions/order/createOffer.ts b/packages/core/src/actions/order/createOffer.ts index b5e248499..dfd5c9418 100644 --- a/packages/core/src/actions/order/createOffer.ts +++ b/packages/core/src/actions/order/createOffer.ts @@ -43,16 +43,16 @@ const createOffer = async ( ) => { const { starknetAccount, offer: baseOrder, approveInfo } = parameters; const currentDate = new Date(); - currentDate.setDate(currentDate.getDate() + 30); + currentDate.setDate(currentDate.getDate()); const startDate = baseOrder.startDate || Math.floor(Date.now() / 1000); - const endDate = baseOrder.endDate || Math.floor(currentDate.getTime() / 1000); const currencyAddress = baseOrder.currencyAddress || config.starknetCurrencyContract; + const endDate = + baseOrder.endDate || Math.floor(currentDate.getTime() / 1000) + 30; if (currencyAddress !== approveInfo.currencyAddress) { throw new Error("Invalid currency address, offer and approveInfo mismatch"); } - const chainId = await config.starknetProvider.getChainId(); const currentAllowance = await getAllowance( config, diff --git a/packages/core/src/actions/read/getOrder.ts b/packages/core/src/actions/read/getOrder.ts index ed9ea062e..1f67179d0 100644 --- a/packages/core/src/actions/read/getOrder.ts +++ b/packages/core/src/actions/read/getOrder.ts @@ -8,8 +8,8 @@ interface GetOrderParameters { const getOrder = async (config: Config, parameters: GetOrderParameters) => { const { orderHash } = parameters; - const { abi: orderbookAbi } = await config.arkProvider.getClassAt( - config.arkchainOrderbookContract + const { abi: orderbookAbi } = await config.starknetProvider.getClassAt( + config.starknetExecutorContract ); if (orderbookAbi === undefined) { throw new Error("no abi."); @@ -17,8 +17,8 @@ const getOrder = async (config: Config, parameters: GetOrderParameters) => { const orderbookContract = new Contract( orderbookAbi, - config.arkchainOrderbookContract, - config.arkProvider + config.starknetExecutorContract, + config.starknetProvider ); const order_hash_calldata = CallData.compile({ diff --git a/packages/core/src/actions/read/getOrderHash.ts b/packages/core/src/actions/read/getOrderHash.ts index 356f0aa89..830e795cd 100644 --- a/packages/core/src/actions/read/getOrderHash.ts +++ b/packages/core/src/actions/read/getOrderHash.ts @@ -29,17 +29,17 @@ const getOrderHash = async ( const tokenHashMessage = starknet.poseidonHashMany(tokenHashBigIntArray); - const { abi: orderbookAbi } = await config.arkProvider.getClassAt( - config.arkchainOrderbookContract + const { abi: executorAbi } = await config.starknetProvider.getClassAt( + config.starknetExecutorContract ); - if (orderbookAbi === undefined) { + if (executorAbi === undefined) { throw new Error("no abi."); } const orderbookContract = new Contract( - orderbookAbi, - config.arkchainOrderbookContract, - config.arkProvider + executorAbi, + config.starknetExecutorContract, + config.starknetProvider ); const order_hash_calldata = CallData.compile({ diff --git a/packages/core/src/actions/read/getOrderSigner.ts b/packages/core/src/actions/read/getOrderSigner.ts index 0c08005cf..2491ac92e 100644 --- a/packages/core/src/actions/read/getOrderSigner.ts +++ b/packages/core/src/actions/read/getOrderSigner.ts @@ -11,17 +11,17 @@ const getOrderSigner = async ( parameters: GetOrderSignerParameters ) => { const { orderHash } = parameters; - const { abi: orderbookAbi } = await config.arkProvider.getClassAt( - config.arkchainOrderbookContract + const { abi: executorAbi } = await config.starknetProvider.getClassAt( + config.starknetExecutorContract ); - if (orderbookAbi === undefined) { + if (executorAbi === undefined) { throw new Error("no abi."); } const orderbookContract = new Contract( - orderbookAbi, - config.arkchainOrderbookContract, - config.arkProvider + executorAbi, + config.starknetExecutorContract, + config.starknetProvider ); const order_hash_calldata = CallData.compile({ diff --git a/packages/core/src/actions/read/getOrderStatus.ts b/packages/core/src/actions/read/getOrderStatus.ts index d5c74f879..47c31224e 100644 --- a/packages/core/src/actions/read/getOrderStatus.ts +++ b/packages/core/src/actions/read/getOrderStatus.ts @@ -11,17 +11,17 @@ const getOrderStatus = async ( parameters: GetOrderStatusParameters ) => { const { orderHash } = parameters; - const { abi: orderbookAbi } = await config.arkProvider.getClassAt( - config.arkchainOrderbookContract + const { abi: executorAbi } = await config.starknetProvider.getClassAt( + config.starknetExecutorContract ); - if (orderbookAbi === undefined) { + if (executorAbi === undefined) { throw new Error("no abi."); } const orderbookContract = new Contract( - orderbookAbi, - config.arkchainOrderbookContract, - config.arkProvider + executorAbi, + config.starknetExecutorContract, + config.starknetProvider ); const order_hash_calldata = CallData.compile({ diff --git a/packages/core/src/actions/read/getOrderType.ts b/packages/core/src/actions/read/getOrderType.ts index 9d7175bd1..c7995f22e 100644 --- a/packages/core/src/actions/read/getOrderType.ts +++ b/packages/core/src/actions/read/getOrderType.ts @@ -11,17 +11,17 @@ const getOrderType = async ( parameters: GetOrderTypeParameters ) => { const { orderHash } = parameters; - const { abi: orderbookAbi } = await config.arkProvider.getClassAt( - config.arkchainOrderbookContract + const { abi: executorAbi } = await config.starknetProvider.getClassAt( + config.starknetExecutorContract ); - if (orderbookAbi === undefined) { + if (executorAbi === undefined) { throw new Error("no abi."); } const orderbookContract = new Contract( - orderbookAbi, - config.arkchainOrderbookContract, - config.arkProvider + executorAbi, + config.starknetExecutorContract, + config.starknetProvider ); const order_hash_calldata = CallData.compile({ diff --git a/packages/core/src/contracts.ts b/packages/core/src/contracts.ts index 03267bbe1..ee0f2ed19 100644 --- a/packages/core/src/contracts.ts +++ b/packages/core/src/contracts.ts @@ -1,14 +1,12 @@ // This file is auto-generated. Do not edit directly. export const SEPOLIA_CONTRACTS = { - messaging: - "0x74f13f1dffb5ad3c051d535ba03514e653b6dcac68e30b2db66a0aa0217c815", - executor: "0xb86ab357c15c12fb78f9b0a19fa974c730fcbab96f17881827dde871665f0b", - orderbook: "0x795b605fa3144afd6f11a4499f71b9cf373bcba3f1b2835d51f65ab59392261" + "messaging": "0x74f13f1dffb5ad3c051d535ba03514e653b6dcac68e30b2db66a0aa0217c815", + "executor": "0xb86ab357c15c12fb78f9b0a19fa974c730fcbab96f17881827dde871665f0b", + "orderbook": "0x795b605fa3144afd6f11a4499f71b9cf373bcba3f1b2835d51f65ab59392261" }; export const MAINNET_CONTRACTS = { - messaging: - "0x57d45cc46de463f7ae63b74ce9b6b6b496a1178b02e7ad04d7c307caa698b7b", - executor: "0x7b42945bc47001db92fe1b9739d753925263f2f1036c2ae1f87536c916ee6a", - orderbook: "0x5add3084bb8664eb2a641cf26a28f60588c3ccd63af0632aafefcbb2332c345" + "messaging": "0x57d45cc46de463f7ae63b74ce9b6b6b496a1178b02e7ad04d7c307caa698b7b", + "executor": "0x7b42945bc47001db92fe1b9739d753925263f2f1036c2ae1f87536c916ee6a", + "orderbook": "0x5add3084bb8664eb2a641cf26a28f60588c3ccd63af0632aafefcbb2332c345" }; diff --git a/packages/core/src/createConfig.ts b/packages/core/src/createConfig.ts index 4d42d93d6..9c26a76ba 100644 --- a/packages/core/src/createConfig.ts +++ b/packages/core/src/createConfig.ts @@ -1,8 +1,6 @@ import { RpcProvider, type ProviderInterface } from "starknet"; import { - arkchainOrderbookContracts, - arkchainRpcUrls, networks, starknetEthContract, starknetExecutorContracts, @@ -17,10 +15,6 @@ export interface Config { starknetRpcUrl: string; starknetExecutorContract: string; starknetCurrencyContract: string; - arkchainNetwork: Network; - arkProvider: ProviderInterface; - arkchainRpcUrl: string; - arkchainOrderbookContract: string; } export type CreateConfigParameters = { @@ -29,10 +23,6 @@ export type CreateConfigParameters = { starknetProvider?: ProviderInterface; starknetExecutorContract?: string; starknetCurrencyContract?: string; - arkchainNetwork: Network; - arkchainRpcUrl?: string; - arkProvider?: ProviderInterface; - arkchainOrderbookContract?: string; }; export function createConfig({ @@ -40,20 +30,12 @@ export function createConfig({ starknetRpcUrl, starknetProvider, starknetExecutorContract, - starknetCurrencyContract = starknetEthContract, - arkchainNetwork, - arkchainRpcUrl, - arkProvider, - arkchainOrderbookContract + starknetCurrencyContract = starknetEthContract }: CreateConfigParameters): Config { if (starknetNetwork === networks.dev && !starknetExecutorContract) { throw new Error("starknetExecutorContract is required for dev network"); } - if (arkchainNetwork === networks.dev && !arkchainOrderbookContract) { - throw new Error("arkchainOrderbookContract is required for dev network"); - } - return { starknetNetwork, starknetRpcUrl: starknetRpcUrl || starknetRpcUrls[starknetNetwork], @@ -64,15 +46,6 @@ export function createConfig({ }), starknetExecutorContract: starknetExecutorContract || starknetExecutorContracts[starknetNetwork], - starknetCurrencyContract, - arkchainNetwork, - arkchainRpcUrl: arkchainRpcUrl || arkchainRpcUrls[arkchainNetwork], - arkProvider: - arkProvider || - new RpcProvider({ - nodeUrl: arkchainRpcUrl || arkchainRpcUrls[arkchainNetwork] - }), - arkchainOrderbookContract: - arkchainOrderbookContract || arkchainOrderbookContracts[arkchainNetwork] + starknetCurrencyContract }; } diff --git a/packages/deployer/scripts/deploy-starknet-local.ts b/packages/deployer/scripts/deploy-starknet-local.ts index 3da57f62d..0617d0429 100644 --- a/packages/deployer/scripts/deploy-starknet-local.ts +++ b/packages/deployer/scripts/deploy-starknet-local.ts @@ -8,15 +8,12 @@ import { deployERC20 } from "../src/contracts/erc20"; import { deployERC721 } from "../src/contracts/erc721"; import { deployERC721Royalties } from "../src/contracts/erc721royalties"; import { deployExecutor } from "../src/contracts/executor"; -import { deployMessaging } from "../src/contracts/messaging"; import { getFeeAddress } from "../src/providers"; async function run() { if ( !process.env.STARKNET_ADMIN_ADDRESS_DEV || - !process.env.STARKNET_ADMIN_PRIVATE_KEY_DEV || - !process.env.SOLIS_ADMIN_ADDRESS_DEV || - !process.env.SOLIS_ADMIN_PRIVATE_KEY_DEV + !process.env.STARKNET_ADMIN_PRIVATE_KEY_DEV ) { console.error( "Missing environment variables, see README.md for more information" @@ -31,26 +28,12 @@ async function run() { process.env.STARKNET_ADMIN_PRIVATE_KEY_DEV, "1" ); - const starknetSolisAccount = new Account( - provider, - process.env.SOLIS_ADMIN_ADDRESS_DEV, - process.env.SOLIS_ADMIN_PRIVATE_KEY_DEV, - "1" - ); - - const messagingContract = await deployMessaging( - ARTIFACTS_PATH, - starknetAdminAccount, - provider, - starknetSolisAccount?.address || "" - ); const executorContract = await deployExecutor( ARTIFACTS_PATH, starknetAdminAccount, provider, - getFeeAddress("dev"), - messagingContract.address + getFeeAddress("dev") ); const ethContract = await deployERC20( @@ -84,24 +67,8 @@ async function run() { "0x29873c310fbefde666dc32a1554fea6bb45eecc84f680f8a2b0a8fbb8cb89af" ); - const messagingConfigFilePath = resolve( - __dirname, - "../../../crates/solis/messaging.local.json" - ); - const messagingConfigContent = JSON.stringify({ - chain: "starknet", - rpc_url: "http://0.0.0.0:5050", - contract_address: messagingContract.address, - sender_address: process.env.STARKNET_SOLIS_ACCOUNT_ADDRESS_DEV, - private_key: process.env.STARKNET_SOLIS_ACCOUNT_PRIVATE_KEY_DEV, - interval: 2, - from_block: 0 - }); - await fs.writeFile(messagingConfigFilePath, messagingConfigContent); - const contractsFilePath = resolve(__dirname, "../../../contracts.dev.json"); const contractsContent = JSON.stringify({ - messaging: messagingContract.address, executor: executorContract.address, nftContract: nftContract.address, nftContractFixedFees: nftContractFixedFees.address, diff --git a/packages/deployer/src/contracts/executor.ts b/packages/deployer/src/contracts/executor.ts index 8638bd349..aa9a4c919 100644 --- a/packages/deployer/src/contracts/executor.ts +++ b/packages/deployer/src/contracts/executor.ts @@ -63,8 +63,7 @@ export async function deployExecutor( artifactsPath: string, account: sn.Account, provider: sn.RpcProvider, - ethContractAddress: string, - messagingAddress: string + ethContractAddress: string ) { const artifacts = getArtifacts(artifactsPath); const chain_id = await provider.getChainId(); @@ -72,7 +71,6 @@ export async function deployExecutor( const contractConstructor = contractCallData.compile("constructor", { admin_address: account.address, eth_contract_address: ethContractAddress, - messaging_address: messagingAddress, chain_id: chain_id }); diff --git a/packages/deployer/src/deployStarknetContracts.ts b/packages/deployer/src/deployStarknetContracts.ts index deeacbfb1..68f5a0ed4 100644 --- a/packages/deployer/src/deployStarknetContracts.ts +++ b/packages/deployer/src/deployStarknetContracts.ts @@ -1,5 +1,4 @@ import { promises as fs } from "fs"; -import path from "path"; import { program } from "commander"; @@ -11,7 +10,6 @@ import loading from "loading-cli"; import { ARTIFACTS_PATH } from "./constants"; import { deployExecutor, upgradeExecutor } from "./contracts/executor"; -import { deployMessaging, upgradeMessaging } from "./contracts/messaging"; import { setArkFees, setDefaultCreatorFees } from "./contracts/setFees"; import { getFeeAddress, getStarknetProvider } from "./providers"; import { @@ -20,20 +18,13 @@ import { getStarknetAccounts } from "./utils"; -// Function to get the path for messaging.json -function getMessagingFilePath() { - return path.join(__dirname, "../../../messaging.json"); -} - async function deployStarknetContracts(starknetNetwork: ProviderNetwork) { console.log("\nSTARKNET NETWORK"); console.log("================\n"); console.log(`| Network | ${starknetNetwork}`); - const { provider: starknetProvider, nodeUrl: starknetNodeUrl } = - getStarknetProvider(starknetNetwork); - const { starknetAdminAccount, starknetSolisAccount } = - getStarknetAccounts(starknetNetwork); + const { provider: starknetProvider } = getStarknetProvider(starknetNetwork); + const { starknetAdminAccount } = getStarknetAccounts(starknetNetwork); const existingContracts = await getExistingContracts(); console.log("\nSTARKNET ACCOUNTS"); @@ -41,28 +32,6 @@ async function deployStarknetContracts(starknetNetwork: ProviderNetwork) { console.log(`| Admin account | ${starknetAdminAccount.address}`); const starknetSpinner = loading("💅 Deploying Starknet Contracts...").start(); - let messagingContract; - if (existingContracts[starknetNetwork].messaging) { - console.log("⚡ Upgrading Messaging Contract..."); - starknetSpinner.text = "⚡ Upgrading Messaging Contract..."; - messagingContract = await upgradeMessaging( - ARTIFACTS_PATH, - starknetAdminAccount, - starknetProvider, - existingContracts[starknetNetwork].messaging - ); - } else { - console.log("⚡ Deploying Messaging Contract..."); - starknetSpinner.text = "⚡ Deploying Messaging Contract..."; - messagingContract = await deployMessaging( - ARTIFACTS_PATH, - starknetAdminAccount, - starknetProvider, - starknetSolisAccount?.address || "" - ); - existingContracts[starknetNetwork].messaging = messagingContract.address; - } - starknetSpinner.text = "⚡ Deploying Executor Contract..."; let executorContract; if (existingContracts[starknetNetwork].executor) { @@ -80,50 +49,17 @@ async function deployStarknetContracts(starknetNetwork: ProviderNetwork) { ARTIFACTS_PATH, starknetAdminAccount, starknetProvider, - getFeeAddress(starknetNetwork), - messagingContract.address + getFeeAddress(starknetNetwork) ); existingContracts[starknetNetwork].executor = executorContract.address; } - // Determine from_block based on the network - let fromBlock; - if (starknetNetwork === "sepolia") { - fromBlock = 72242; - } else if (starknetNetwork === "mainnet") { - fromBlock = 644128; - } else { - fromBlock = 0; // default or handle other networks if any - } - - // Create the messaging file at the specified path - const messagingFilePath = getMessagingFilePath(); - const messagingFileContent = { - chain: "starknet", - rpc_url: starknetNodeUrl, - contract_address: messagingContract.address, - sender_address: starknetSolisAccount?.address, - private_key: starknetSolisAccount?.privateKey, - interval: 10, - from_block: fromBlock - }; - - console.log("\nMESSAGING FILE"); - console.log("==============\n"); - console.log(`| Contract | ${messagingFileContent}`); - - await fs.writeFile( - messagingFilePath, - JSON.stringify(messagingFileContent, null, 2) - ); - // Update the contracts.json file const contractsFilePath = getContractsFilePath(); const contractsContent = JSON.parse( await fs.readFile(contractsFilePath, "utf8") ); - contractsContent[starknetNetwork].messaging = messagingContract.address; contractsContent[starknetNetwork].executor = executorContract.address; await fs.writeFile( @@ -151,7 +87,6 @@ async function deployStarknetContracts(starknetNetwork: ProviderNetwork) { starknetSpinner.stop(); console.log("STARKNET CONTRACTS"); console.log("==================\n"); - console.log(`| Messaging contract | ${messagingContract.address}`); console.log(`| Executor contract | ${executorContract.address}`); } diff --git a/packages/react/src/components/ArkProvider.tsx b/packages/react/src/components/ArkProvider.tsx index a788a898d..c0df3a2af 100644 --- a/packages/react/src/components/ArkProvider.tsx +++ b/packages/react/src/components/ArkProvider.tsx @@ -17,7 +17,6 @@ import { } from "@ark-project/core"; import { getOwner } from "../lib/getOwner"; -import { RpcProviderProvider } from "./RpcContext"; const OwnerDataContext = createContext(undefined); const ConfigDataContext = createContext(undefined); @@ -34,16 +33,14 @@ function ArkProvider(props: PropsWithChildren) { const [config, setConfig] = useState( createConfig({ starknetProvider: starknetProvider, - starknetNetwork: baseConfig.starknetNetwork as Network, - arkchainNetwork: baseConfig.arkchainNetwork as Network + starknetNetwork: baseConfig.starknetNetwork as Network }) ); useEffect(() => { const newConfig = createConfig({ starknetProvider: starknetProvider, - starknetNetwork: baseConfig.starknetNetwork as Network, - arkchainNetwork: baseConfig.arkchainNetwork as Network + starknetNetwork: baseConfig.starknetNetwork as Network }); setConfig(newConfig); }, [starknetProvider, starknetChain, baseConfig]); @@ -71,7 +68,7 @@ function ArkProvider(props: PropsWithChildren) { return ( - {children} + {children} ); diff --git a/packages/react/src/components/RpcContext.tsx b/packages/react/src/components/RpcContext.tsx deleted file mode 100644 index e5eea7a02..000000000 --- a/packages/react/src/components/RpcContext.tsx +++ /dev/null @@ -1,36 +0,0 @@ -"use client"; - -import React, { createContext, useMemo, type PropsWithChildren } from "react"; - -import { RpcProvider } from "starknet"; - -import { Config } from "@ark-project/core"; - -type RpcContextValue = - | { - rpcProvider: RpcProvider; - } - | undefined; - -export type RpcProviderProviderProps = { - config: Config; -}; - -export const RpcContext = createContext(undefined); - -export function RpcProviderProvider( - props: PropsWithChildren -) { - const { children, config } = props; - - const arkChain = useMemo( - () => ({ - rpcProvider: new RpcProvider({ - nodeUrl: config.arkchainRpcUrl - }) - }), - [config.arkchainRpcUrl] - ); - - return {children}; -} diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index a234113be..007f69d09 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -1,2 +1 @@ -export * from "./components"; export * from "./hooks";