-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added NetworkParams to endpoints * fixed testing endpoints * updated dists
- Loading branch information
1 parent
c473ade
commit ac67d6e
Showing
19 changed files
with
203 additions
and
106 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*! | ||
* The buffer module from node.js, for the browser. | ||
* | ||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> | ||
* @license MIT | ||
*/ | ||
|
||
/*! | ||
* The buffer module from node.js, for the browser. | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
|
||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
|
||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
|
||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Shared.NetworkData where | ||
|
||
import Contract.Address (NetworkId(..)) | ||
import Contract.Prelude | ||
|
||
newtype NetworkParams = NetworkParams | ||
{ wallet :: String | ||
, isMainnet :: Boolean | ||
} | ||
|
||
derive newtype instance Show NetworkParams | ||
derive instance Generic NetworkParams _ | ||
|
||
data WalletType = Nami | Flint | Lode | Eternl | ||
|
||
derive instance Eq WalletType | ||
derive instance Generic WalletType _ | ||
|
||
instance Show WalletType where | ||
show = genericShow | ||
|
||
newtype NetworkWallet = NetworkWallet | ||
{ networkId :: NetworkId | ||
, walletType :: WalletType | ||
} | ||
|
||
derive newtype instance Show NetworkWallet | ||
derive newtype instance Eq NetworkWallet | ||
|
||
networkParamsToNetworkWallet :: NetworkParams -> Maybe NetworkWallet | ||
networkParamsToNetworkWallet (NetworkParams { wallet, isMainnet }) = | ||
case (wallet /\ isMainnet) of | ||
("Nami" /\ false) -> Just $ NetworkWallet { networkId: TestnetId, walletType: Nami } | ||
("Flint" /\ false) -> Just $ NetworkWallet { networkId: TestnetId, walletType: Flint } | ||
("Lode" /\ false) -> Just $ NetworkWallet { networkId: TestnetId, walletType: Lode } | ||
("Eternl" /\ false) -> Just $ NetworkWallet { networkId: TestnetId, walletType: Eternl } | ||
("Nami" /\ true) -> Just $ NetworkWallet { networkId: MainnetId, walletType: Nami } | ||
("Flint" /\ true) -> Just $ NetworkWallet { networkId: MainnetId, walletType: Flint } | ||
("Lode" /\ true) -> Just $ NetworkWallet { networkId: MainnetId, walletType: Lode } | ||
("Eternl" /\ true) -> Just $ NetworkWallet { networkId: MainnetId, walletType: Eternl } | ||
_ -> Nothing |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
module Shared.RunContract where | ||
|
||
import Contract.Prelude | ||
import Effect.Exception (Error, message) | ||
import Data.Maybe (maybe) | ||
import Effect.Aff (runAff_) | ||
import Shared.TestnetConfig (mkTestnetNamiConfig) | ||
import Effect.Exception (Error, message, throw) | ||
import Contract.Monad (Contract, runContract) | ||
import Shared.TestnetConfig (mkNetworkWalletConfig) | ||
import Shared.NetworkData (NetworkParams, networkParamsToNetworkWallet) | ||
|
||
runContractWithUnitResult :: (Unit -> Effect Unit) -> (String -> Effect Unit) -> Contract Unit -> Effect Unit | ||
runContractWithUnitResult onComplete onError contract = do | ||
testnetNamiConfig <- mkTestnetNamiConfig | ||
runAff_ handler $ runContract testnetNamiConfig contract | ||
runContractWithResult :: forall a. (a -> Effect Unit) -> (String -> Effect Unit) -> NetworkParams -> Contract a -> Effect Unit | ||
runContractWithResult onComplete onError networkParams contract = do | ||
networkWallet <- maybe (throw "Impossible to parse Wallet type") pure $ networkParamsToNetworkWallet networkParams | ||
networkWalletConfig <- mkNetworkWalletConfig networkWallet | ||
runAff_ handler $ runContract networkWalletConfig contract | ||
where | ||
handler :: Either Error Unit -> Effect Unit | ||
handler (Right _) = onComplete unit | ||
handler :: Either Error a -> Effect Unit | ||
handler (Right res) = onComplete res | ||
handler (Left err) = onError $ message err | ||
|
Oops, something went wrong.