-
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.
Merge pull request #63 from fullstack-development/kupo-backend-integr…
…ation change FundraisingInfo
- Loading branch information
Showing
6 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
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 @@ | ||
{"address":"addr_test1xzyyxy9s609346ckm5eyv2qn3s56zc8spajw654yxsrwwkuggvgtp57trt43dhfjgc5p8rpf59s0qrmya4f2gdqxuads6zfmy0", "verTokenCurrency": "2ad1727329f49229089c470bcabc158a2344e149499614dba10cbfac", "verTokenName": "VerificationToken", "threadTokenName":"FundraisingThreadToken"} |
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,56 @@ | ||
module Config.Fundraising where | ||
|
||
import Contract.Prelude | ||
|
||
import Contract.Address (Bech32String, addressToBech32, getNetworkId, validatorHashBaseAddress) | ||
import Contract.Monad (Contract, liftContractM) | ||
import Data.Argonaut.Core (stringify) | ||
import Data.Argonaut.Encode (encodeJson) | ||
import Effect (Effect) | ||
import Ext.Contract.Value (currencySymbolToString, tokenNameToString, mkCurrencySymbol) | ||
import Fundraising.FundraisingScript (getFundraisingTokenName, getFundraisingValidatorHash) | ||
import Fundraising.Models (Fundraising(..)) | ||
import MintingPolicy.VerTokenMinting as VerToken | ||
import Node.Encoding (Encoding(..)) | ||
import Node.FS.Sync (writeTextFile) | ||
import Protocol.Models (Protocol) | ||
|
||
type FundraisingConfig = | ||
{ address :: Bech32String | ||
, verTokenCurrency :: Bech32String | ||
, verTokenName :: String | ||
, threadTokenName :: String | ||
} | ||
|
||
writeFundraisingConfig :: FundraisingConfig -> Effect Unit | ||
writeFundraisingConfig fundraisingConfig = do | ||
let jfundraisingConfig = stringify $ encodeJson fundraisingConfig | ||
liftEffect $ writeTextFile UTF8 "conf/fundraising.local.conf" jfundraisingConfig | ||
|
||
makeFundraisingConfig ∷ Protocol → Contract FundraisingConfig | ||
makeFundraisingConfig protocol = do | ||
_ /\ verTokenCs <- mkCurrencySymbol (VerToken.mintingPolicy protocol) | ||
let verTokenBech32 = currencySymbolToString verTokenCs | ||
verTn <- VerToken.verTokenName | ||
verTnString <- liftContractM "Impossible to decode fundraising ver token name" $ tokenNameToString verTn | ||
|
||
let | ||
fundraising = Fundraising | ||
{ protocol: protocol | ||
, verTokenCurrency: verTokenCs | ||
, verTokenName: verTn | ||
} | ||
networkId <- getNetworkId | ||
frValidatorHash <- getFundraisingValidatorHash fundraising | ||
frAddress <- liftContractM "Impossible to get Fundraising script address" $ validatorHashBaseAddress networkId frValidatorHash | ||
bech32Address <- addressToBech32 frAddress | ||
|
||
nftTn <- getFundraisingTokenName | ||
nftTnString <- liftContractM "Impossible to decode fundraising thread token name" $ tokenNameToString nftTn | ||
|
||
pure $ | ||
{ address: bech32Address | ||
, verTokenCurrency: verTokenBech32 | ||
, verTokenName: verTnString | ||
, threadTokenName: nftTnString | ||
} |
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