Last active
October 13, 2022 09:28
-
-
Save leomayleomay/555586f80c3848fce18a2e844d72e3dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
exports._getNetworkId = window.cardano.getNetworkId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
exports._getNetworkId = () => window.cardano.getNetworkId().then(networkId => { | |
return networkId; | |
}).catch(e => { | |
console.log("Something goes wrong with getNetworkId: ", e); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HelloWorld.NamiNetwork where | |
import Prelude | |
import Control.Promise (Promise, toAffE) | |
import Ctl.Internal.Serialization.Address (NetworkId(..)) | |
import Effect (Effect) | |
import Effect.Aff (Aff, error, throwError) | |
foreign import _getNetworkId :: Effect (Promise Int) | |
getNetworkId :: Aff NetworkId | |
getNetworkId = do | |
networkId <- toAffE _getNetworkId | |
case networkId of | |
0 -> pure TestnetId | |
1 -> pure MainnetId | |
_ -> throwError $ error "Unknown network ID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment