public void Can_load_contract(Type contractType)
        {
            var parser     = new AbiDefinitionParser();
            var json       = parser.LoadContract(contractType);
            var contract   = parser.Parse(json);
            var serialized = parser.Serialize(contract);

            JToken.Parse(serialized).Should().ContainSubtree(json);
        }
示例#2
0
            protected override BlockProcessor CreateBlockProcessor()
            {
                // Address.TryParse(_accountAbstractionConfig.EntryPointContractAddress, out Address? entryPointContractAddress);
                IList <Address> entryPointContractAddresses        = new List <Address>();
                IList <string>  _entryPointContractAddressesString = _accountAbstractionConfig.GetEntryPointAddresses().ToList();

                foreach (string _addressString in _entryPointContractAddressesString)
                {
                    bool parsed = Address.TryParse(
                        _addressString,
                        out Address? entryPointContractAddress);
                    entryPointContractAddresses.Add(entryPointContractAddress !);
                }

                EntryPointAddresses = entryPointContractAddresses.ToArray();
                Address.TryParse(_accountAbstractionConfig.Create2FactoryAddress, out Address? create2FactoryAddress);
                BlockValidator = CreateBlockValidator();
                BlockProcessor blockProcessor = new(
                    SpecProvider,
                    BlockValidator,
                    NoBlockRewards.Instance,
                    new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State),
                    State,
                    Storage,
                    ReceiptStorage,
                    NullWitnessCollector.Instance,
                    LogManager);

                var parser = new AbiDefinitionParser();

                parser.RegisterAbiTypeFactory(new AbiTuple <UserOperationAbi>());
                var json = parser.LoadContract(typeof(EntryPoint));

                EntryPointContractAbi = parser.Parse(json);

                foreach (Address entryPoint in entryPointContractAddresses)
                {
                    UserOperationTxBuilder[entryPoint] = new UserOperationTxBuilder(
                        EntryPointContractAbi,
                        Signer,
                        entryPoint !,
                        SpecProvider,
                        State);
                }

                foreach (Address entryPoint in entryPointContractAddresses)
                {
                    UserOperationSimulator[entryPoint] = new(
                        UserOperationTxBuilder[entryPoint],
                        State,
                        StateReader,
                        EntryPointContractAbi,
                        create2FactoryAddress !,
                        entryPoint !,
                        SpecProvider,
                        BlockTree,
                        DbProvider,
                        ReadOnlyTrieStore,
                        Timestamper,
                        LogManager);
                }

                IUserOperationBroadcaster broadcaster = new UserOperationBroadcaster(LogManager.GetClassLogger());

                foreach (Address entryPoint in entryPointContractAddresses)
                {
                    UserOperationPool[entryPoint] = new UserOperationPool(
                        _accountAbstractionConfig,
                        BlockTree,
                        entryPoint !,
                        LogManager.GetClassLogger(),
                        new PaymasterThrottler(),
                        LogFinder,
                        Signer,
                        State,
                        Timestamper,
                        UserOperationSimulator[entryPoint],
                        new UserOperationSortedPool(
                            _accountAbstractionConfig.UserOperationPoolSize,
                            new CompareUserOperationsByDecreasingGasPrice(),
                            LogManager,
                            _accountAbstractionConfig.MaximumUserOperationPerSender),
                        broadcaster,
                        SpecProvider.ChainId);
                }

                return(blockProcessor);
            }
示例#3
0
            protected override BlockProcessor CreateBlockProcessor()
            {
                Address.TryParse(_accountAbstractionConfig.EntryPointContractAddress, out Address? entryPointContractAddress);
                Address.TryParse(_accountAbstractionConfig.Create2FactoryAddress, out Address? create2FactoryAddress);
                EntryPointAddress = entryPointContractAddress !;

                BlockValidator = CreateBlockValidator();
                BlockProcessor blockProcessor = new(
                    SpecProvider,
                    BlockValidator,
                    NoBlockRewards.Instance,
                    new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State),
                    State,
                    Storage,
                    ReceiptStorage,
                    NullWitnessCollector.Instance,
                    LogManager);

                var parser = new AbiDefinitionParser();

                parser.RegisterAbiTypeFactory(new AbiTuple <UserOperationAbi>());
                var json = parser.LoadContract(typeof(EntryPoint));

                EntryPointContractAbi = parser.Parse(json);

                UserOperationTxBuilder = new UserOperationTxBuilder(
                    EntryPointContractAbi,
                    Signer,
                    entryPointContractAddress !,
                    SpecProvider,
                    State);

                UserOperationSimulator = new(
                    UserOperationTxBuilder,
                    State,
                    StateReader,
                    EntryPointContractAbi,
                    create2FactoryAddress !,
                    entryPointContractAddress !,
                    SpecProvider,
                    BlockTree,
                    DbProvider,
                    ReadOnlyTrieStore,
                    Timestamper,
                    LogManager);

                UserOperationPool = new UserOperationPool(
                    _accountAbstractionConfig,
                    BlockTree,
                    entryPointContractAddress !,
                    LogManager.GetClassLogger(),
                    new PaymasterThrottler(),
                    LogFinder,
                    Signer,
                    State,
                    Timestamper,
                    UserOperationSimulator,
                    new UserOperationSortedPool(
                        _accountAbstractionConfig.UserOperationPoolSize,
                        new CompareUserOperationsByDecreasingGasPrice(),
                        LogManager,
                        _accountAbstractionConfig.MaximumUserOperationPerSender),
                    SpecProvider.ChainId);

                return(blockProcessor);
            }