aboutsummaryrefslogtreecommitdiffstats
path: root/net-p2p/libbt/Makefile
blob: e96c46a3a32d0024f36d81b096121dfbcd403ab2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# New ports collection makefile for:    libbt
# Date created:             Feb 26 2004
# Whom:                 Florent Thoumie <flz@xbsd.org>
#
# $FreeBSD$
#

PORTNAME=   libbt
PORTVERSION=    0.03
CATEGORIES= net devel
MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}
DISTNAME=   ${PORTNAME}.${PORTVERSION}

MAINTAINER= flz@xbsd.org
COMMENT=    C library implementing the core BitTorrent protocol

LIB_DEPENDS=    uuid.1:${PORTSDIR}/sysutils/e2fsprogs \
        curl.2:${PORTSDIR}/ftp/curl

WRKSRC=     ${WRKDIR}/${PORTNAME}

GNU_CONFIGURE=  yes
USE_GMAKE=  yes
USE_REINPLACE=  yes

CONFIGURE_ENV=  CPPFLAGS="-I${LOCALBASE}/include" LDFLAGS="-L${LOCALBASE}/lib"

post-patch:
    @${REINPLACE_CMD} -e 's|\(makedepend --\)|\1 \@CPPFLAGS\@|' ${WRKSRC}/src/Makefile.in
    @${REINPLACE_CMD} -e 's|\(CFLAGS:=\)|\1\@CFLAGS\@|' ${WRKSRC}/src/Makefile.in

do-install:
    ${INSTALL_DATA} ${WRKSRC}/src/libbt.a ${PREFIX}/lib
    ${MKDIR} ${PREFIX}/include/libbt
.for i in btcheck btget btlist
    ${INSTALL_PROGRAM} ${WRKSRC}/src/${i} ${PREFIX}/bin
.endfor
.for i in benc.h bitset.h bterror.h bts.h context.h peer.h random.h segmenter.h strbuf.h stream.h types.h util.h
    ${INSTALL_DATA} ${WRKSRC}/include/${i} ${PREFIX}/include/libbt
.endfor

post-install:
.if !defined(NOPORTDOCS)
    ${MKDIR} ${DOCSDIR}
    ${INSTALL_MAN} ${WRKSRC}/docs/protocol.txt ${DOCSDIR}
.endif

.include <bsd.port.mk>
a title='author Brandon Millman <brandon.millman@gmail.com> 2018-11-07 12:25:30 +0800 committer Brandon Millman <brandon.millman@gmail.com> 2018-11-08 01:32:49 +0800 feat(instant): fallback to an empty wallet provider when none is injected' href='/~lantw44/cgit/dexon-0x-contracts/commit/packages/instant/src/components/zero_ex_instant_provider.tsx?id=dfbf10c94bfbbdbca353531c5cae6707e05981f0'>dfbf10c94
28df5bfd9




dfbf10c94
c2645b26b

dfbf10c94
c2645b26b
dfbf10c94
c2645b26b
dfbf10c94

c2645b26b
f4e0f74a6
695d1453a






5527de62f
dfbf10c94
a2e1bf0e6
695d1453a


c2645b26b
5e66cc8a4
c2645b26b




921d9d7ed
6de499459
dfbf10c94
c2645b26b

c2645b26b
695d1453a
79f0324ab
c2645b26b
79f0324ab
695d1453a


79f0324ab
695d1453a
407207696






7acaae37a
cc8debe53



1e39d56cf
447b0f91f
cc8debe53
208ee935c
c5d6b925e
c5d6b925e
c2645b26b


e7e9c2a2e
c2645b26b

ca9bb4532

2bfd03e64
d75022555





7610130f7
d75022555


e8be70da1
c2645b26b
7acaae37a



1e39d56cf


7acaae37a
c2645b26b

5fc2483be
c2645b26b
5fc2483be
c2645b26b

c2645b26b

dfbf10c94






c2645b26b


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
                                      
                                      
                                          

                               
                                                        
 
                                                                                                  

                                                                                         
                                                                      

                                              







                            
                                                                
                                           
                                                     
                                                      
                                                                

                                                                                                      
                                                                      
 
                                                                 


                                                                                        
                                                  

                                             
                                                                            






                                                                                                                  




                                                                           
                                                                               

                                                
                                             
          
                                    
                                            

                            
                               
                                                       






                                                                        
                                                                               
                           
                                                             


                                                                                                                        
                                                       
                                               




                                                    
                       
                        
                                                                                              

                                                    
                                      
                                             
                                              
                                                        
                                                            


                                                            
                                                                                  
         






                                                                                
 



                                                               
                                                                         
                                       
                                                        
                                                                                                    
                                  
           


                                                                      
                                            

                                                        

                    
                                                                             





                                              
                                    


                                         
                                       
     



                                                


                                           
     

                                      
                                               
                                                                                              
                            

          

                                                                             






                                                                                                 


         
import { ObjectMap } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
import * as React from 'react';
import { Provider as ReduxProvider } from 'react-redux';

import { ACCOUNT_UPDATE_INTERVAL_TIME_MS, BUY_QUOTE_UPDATE_INTERVAL_TIME_MS } from '../constants';
import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
import { asyncData } from '../redux/async_data';
import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
import { store, Store } from '../redux/store';
import { fonts } from '../style/fonts';
import {
    AccountState,
    AffiliateInfo,
    AssetMetaData,
    Network,
    QuoteFetchOrigin,
    ZeroExInstantBaseConfig,
} from '../types';
import { analytics, disableAnalytics } from '../util/analytics';
import { assetUtils } from '../util/asset';
import { errorFlasher } from '../util/error_flasher';
import { setupRollbar } from '../util/error_reporter';
import { gasPriceEstimator } from '../util/gas_price_estimator';
import { Heartbeater } from '../util/heartbeater';
import { generateAccountHeartbeater, generateBuyQuoteHeartbeater } from '../util/heartbeater_factory';
import { providerStateFactory } from '../util/provider_state_factory';

export type ZeroExInstantProviderProps = ZeroExInstantBaseConfig;

export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
    private readonly _store: Store;
    private _accountUpdateHeartbeat?: Heartbeater;
    private _buyQuoteHeartbeat?: Heartbeater;

    // TODO(fragosti): Write tests for this beast once we inject a provider.
    private static _mergeDefaultStateWithProps(
        props: ZeroExInstantProviderProps,
        defaultState: DefaultState = DEFAULT_STATE,
    ): State {
        // use the networkId passed in with the props, otherwise default to that of the default state (1, mainnet)
        const networkId = props.networkId || defaultState.network;
        // construct the ProviderState
        const providerState = providerStateFactory.getInitialProviderState(
            props.orderSource,
            networkId,
            props.provider,
        );
        // merge the additional additionalAssetMetaDataMap with our default map
        const completeAssetMetaDataMap = {
            ...props.additionalAssetMetaDataMap,
            ...defaultState.assetMetaDataMap,
        };
        // construct the final state
        const storeStateFromProps: State = {
            ...defaultState,
            providerState,
            network: networkId,
            walletDisplayName: props.walletDisplayName,
            selectedAsset: _.isUndefined(props.defaultSelectedAssetData)
                ? undefined
                : assetUtils.createAssetFromAssetDataOrThrow(
                      props.defaultSelectedAssetData,
                      completeAssetMetaDataMap,
                      networkId,
                  ),
            selectedAssetUnitAmount: _.isUndefined(props.defaultAssetBuyAmount)
                ? undefined
                : new BigNumber(props.defaultAssetBuyAmount),
            availableAssets: _.isUndefined(props.availableAssetDatas)
                ? undefined
                : assetUtils.createAssetsFromAssetDatas(props.availableAssetDatas, completeAssetMetaDataMap, networkId),
            assetMetaDataMap: completeAssetMetaDataMap,
            affiliateInfo: props.affiliateInfo,
        };
        return storeStateFromProps;
    }
    constructor(props: ZeroExInstantProviderProps) {
        super(props);
        setupRollbar();
        fonts.include();
        const initialAppState = ZeroExInstantProvider._mergeDefaultStateWithProps(this.props);
        this._store = store.create(initialAppState);
    }
    public componentDidMount(): void {
        const state = this._store.getState();
        const dispatch = this._store.dispatch;
        // tslint:disable-next-line:no-floating-promises
        asyncData.fetchEthPriceAndDispatchToStore(dispatch);
        // fetch available assets if none are specified
        if (_.isUndefined(state.availableAssets)) {
            // tslint:disable-next-line:no-floating-promises
            asyncData.fetchAvailableAssetDatasAndDispatchToStore(state, dispatch);
        }
        if (state.providerState.account.state !== AccountState.None) {
            this._accountUpdateHeartbeat = generateAccountHeartbeater({
                store: this._store,
                shouldPerformImmediatelyOnStart: true,
            });
            this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
        }

        this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({
            store: this._store,
            shouldPerformImmediatelyOnStart: false,
        });
        this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
        // Trigger first buyquote fetch
        // tslint:disable-next-line:no-floating-promises
        asyncData.fetchCurrentBuyQuoteAndDispatchToStore(state, dispatch, QuoteFetchOrigin.Manual, {
            updateSilently: false,
        });
        // warm up the gas price estimator cache just in case we can't
        // grab the gas price estimate when submitting the transaction
        // tslint:disable-next-line:no-floating-promises
        gasPriceEstimator.getGasInfoAsync();
        // tslint:disable-next-line:no-floating-promises
        this._flashErrorIfWrongNetwork();

        // Analytics
        disableAnalytics(this.props.shouldDisableAnalyticsTracking || false);
        analytics.addEventProperties(
            analytics.generateEventProperties(
                state.network,
                this.props.orderSource,
                state.providerState,
                window,
                state.selectedAsset,
                this.props.affiliateInfo,
            ),
        );
        analytics.trackInstantOpened();
    }
    public componentWillUnmount(): void {
        if (this._accountUpdateHeartbeat) {
            this._accountUpdateHeartbeat.stop();
        }
        if (this._buyQuoteHeartbeat) {
            this._buyQuoteHeartbeat.stop();
        }
    }
    public render(): React.ReactNode {
        return (
            <ReduxProvider store={this._store}>
                <SelectedAssetThemeProvider>{this.props.children}</SelectedAssetThemeProvider>
            </ReduxProvider>
        );
    }
    private readonly _flashErrorIfWrongNetwork = async (): Promise<void> => {
        const msToShowError = 30000; // 30 seconds
        const state = this._store.getState();
        const network = state.network;
        const web3Wrapper = state.providerState.web3Wrapper;
        const networkOfProvider = await web3Wrapper.getNetworkIdAsync();
        if (network !== networkOfProvider) {
            const errorMessage = `Wrong network detected. Try switching to ${Network[network]}.`;
            errorFlasher.flashNewErrorMessage(this._store.dispatch, errorMessage, msToShowError);
        }
    };
}