parent
37d539f061
commit
8f3a965a49
|
@ -1,27 +0,0 @@
|
|||
import NimQml, json, strutils, sequtils
|
||||
|
||||
import ./io_interface as minting_module_interface
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
mintingModule: minting_module_interface.AccessInterface
|
||||
|
||||
proc load*(self: View) =
|
||||
discard
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.QObject.delete
|
||||
|
||||
proc newView*(mintingModule: minting_module_interface.AccessInterface): View =
|
||||
new(result, delete)
|
||||
result.QObject.setup
|
||||
result.mintingModule = mintingModule
|
||||
|
||||
proc mintCollectible*(self: View, communityId: string, fromAddress: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, chainId: int, image: string) {.slot.} =
|
||||
self.mintingModule.mintCollectible(communityId, fromAddress, name, symbol, description, supply, infiniteSupply, transferable, selfDestruct, chainId, image)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ import ../../../../app_service/service/community/service as community_service
|
|||
import ../../../../app_service/service/contacts/service as contacts_service
|
||||
import ../../../../app_service/service/community_tokens/service as community_tokens_service
|
||||
import ../../../../app_service/service/chat/dto/chat
|
||||
import ./minting/module as minting_module
|
||||
import ./tokens/module as community_tokens_module
|
||||
|
||||
export io_interface
|
||||
|
||||
|
@ -41,7 +41,7 @@ type
|
|||
viewVariant: QVariant
|
||||
moduleLoaded: bool
|
||||
curatedCommunitiesLoaded: bool
|
||||
mintingModule: minting_module.AccessInterface
|
||||
communityTokensModule: community_tokens_module.AccessInterface
|
||||
|
||||
# Forward declaration
|
||||
method setCommunityTags*(self: Module, communityTags: string)
|
||||
|
@ -65,7 +65,7 @@ proc newModule*(
|
|||
contactsService,
|
||||
communityTokensService,
|
||||
)
|
||||
result.mintingModule = minting_module.newMintingModule(result, events, communityTokensService)
|
||||
result.communityTokensModule = community_tokens_module.newCommunityTokensModule(result, events, communityTokensService)
|
||||
result.moduleLoaded = false
|
||||
result.curatedCommunitiesLoaded = false
|
||||
|
||||
|
@ -73,12 +73,12 @@ method delete*(self: Module) =
|
|||
self.view.delete
|
||||
self.viewVariant.delete
|
||||
self.controller.delete
|
||||
self.mintingModule.delete
|
||||
self.communityTokensModule.delete
|
||||
|
||||
method load*(self: Module) =
|
||||
singletonInstance.engine.setRootContextProperty("communitiesModule", self.viewVariant)
|
||||
self.controller.init()
|
||||
self.mintingModule.load()
|
||||
self.communityTokensModule.load()
|
||||
self.view.load()
|
||||
|
||||
method isLoaded*(self: Module): bool =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import ./io_interface as minting_module_interface
|
||||
import ./io_interface as community_tokens_module_interface
|
||||
|
||||
import ../../../../../app_service/service/community_tokens/service as community_tokens_service
|
||||
import ../../../../../app_service/service/community/dto/community
|
||||
|
@ -7,21 +7,21 @@ import ../../../../core/eventemitter
|
|||
import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
|
||||
|
||||
const UNIQUE_MINT_COLLECTIBLES_MINTING_MODULE_IDENTIFIER* = "MintingModule-MintCollectibles"
|
||||
const UNIQUE_DEPLOY_COLLECTIBLES_COMMUNITY_TOKENS_MODULE_IDENTIFIER* = "communityTokensModule-DeployCollectibles"
|
||||
|
||||
type
|
||||
Controller* = ref object of RootObj
|
||||
mintingModule: minting_module_interface.AccessInterface
|
||||
communityTokensModule: community_tokens_module_interface.AccessInterface
|
||||
events: EventEmitter
|
||||
communityTokensService: community_tokens_service.Service
|
||||
|
||||
proc newMintingController*(
|
||||
mintingModule: minting_module_interface.AccessInterface,
|
||||
proc newCommunityTokensController*(
|
||||
communityTokensModule: community_tokens_module_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
communityTokensService: community_tokens_service.Service
|
||||
): Controller =
|
||||
result = Controller()
|
||||
result.mintingModule = mintingModule
|
||||
result.communityTokensModule = communityTokensModule
|
||||
result.events = events
|
||||
result.communityTokensService = communityTokensService
|
||||
|
||||
|
@ -31,15 +31,15 @@ proc delete*(self: Controller) =
|
|||
proc init*(self: Controller) =
|
||||
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED) do(e: Args):
|
||||
let args = SharedKeycarModuleArgs(e)
|
||||
if args.uniqueIdentifier != UNIQUE_MINT_COLLECTIBLES_MINTING_MODULE_IDENTIFIER:
|
||||
if args.uniqueIdentifier != UNIQUE_DEPLOY_COLLECTIBLES_COMMUNITY_TOKENS_MODULE_IDENTIFIER:
|
||||
return
|
||||
self.mintingModule.onUserAuthenticated(args.password)
|
||||
self.communityTokensModule.onUserAuthenticated(args.password)
|
||||
|
||||
proc mintCollectibles*(self: Controller, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, tokenMetadata: CommunityTokensMetadataDto, chainId: int) =
|
||||
self.communityTokensService.mintCollectibles(communityId, addressFrom, password, deploymentParams, tokenMetadata, chainId)
|
||||
proc deployCollectibles*(self: Controller, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, tokenMetadata: CommunityTokensMetadataDto, chainId: int) =
|
||||
self.communityTokensService.deployCollectibles(communityId, addressFrom, password, deploymentParams, tokenMetadata, chainId)
|
||||
|
||||
proc authenticateUser*(self: Controller, keyUid = "") =
|
||||
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_MINT_COLLECTIBLES_MINTING_MODULE_IDENTIFIER, keyUid: keyUid)
|
||||
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_DEPLOY_COLLECTIBLES_COMMUNITY_TOKENS_MODULE_IDENTIFIER, keyUid: keyUid)
|
||||
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
|
||||
|
||||
proc getCommunityTokens*(self: Controller, communityId: string): seq[CommunityTokenDto] =
|
|
@ -9,7 +9,7 @@ method delete*(self: AccessInterface) {.base.} =
|
|||
method load*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method mintCollectible*(self: AccessInterface, communityId: string, address: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool,
|
||||
method deployCollectible*(self: AccessInterface, communityId: string, address: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool,
|
||||
selfDestruct: bool, chainId: int, image: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
@ -21,7 +21,7 @@ type
|
|||
tempDeploymentParams: DeploymentParameters
|
||||
tempTokenMetadata: CommunityTokensMetadataDto
|
||||
|
||||
proc newMintingModule*(
|
||||
proc newCommunityTokensModule*(
|
||||
parent: parent_interface.AccessInterface,
|
||||
events: EventEmitter,
|
||||
communityTokensService: community_tokens_service.Service): Module =
|
||||
|
@ -29,7 +29,7 @@ proc newMintingModule*(
|
|||
result.parent = parent
|
||||
result.view = newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newMintingController(result, events, communityTokensService)
|
||||
result.controller = controller.newCommunityTokensController(result, events, communityTokensService)
|
||||
|
||||
method delete*(self: Module) =
|
||||
self.view.delete
|
||||
|
@ -44,11 +44,11 @@ method resetTempValues(self:Module) =
|
|||
self.tempChainId = 0
|
||||
|
||||
method load*(self: Module) =
|
||||
singletonInstance.engine.setRootContextProperty("mintingModule", self.viewVariant)
|
||||
singletonInstance.engine.setRootContextProperty("communityTokensModule", self.viewVariant)
|
||||
self.controller.init()
|
||||
self.view.load()
|
||||
|
||||
method mintCollectible*(self: Module, communityId: string, fromAddress: string, name: string, symbol: string, description: string,
|
||||
method deployCollectible*(self: Module, communityId: string, fromAddress: string, name: string, symbol: string, description: string,
|
||||
supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, chainId: int, image: string) =
|
||||
self.tempAddressFrom = fromAddress
|
||||
self.tempCommunityId = communityId
|
||||
|
@ -73,4 +73,4 @@ method onUserAuthenticated*(self: Module, password: string) =
|
|||
discard
|
||||
#TODO signalize somehow
|
||||
else:
|
||||
self.controller.mintCollectibles(self.tempCommunityId, self.tempAddressFrom, password, self.tempDeploymentParams, self.tempTokenMetadata, self.tempChainId)
|
||||
self.controller.deployCollectibles(self.tempCommunityId, self.tempAddressFrom, password, self.tempDeploymentParams, self.tempTokenMetadata, self.tempChainId)
|
|
@ -0,0 +1,27 @@
|
|||
import NimQml, json, strutils, sequtils
|
||||
|
||||
import ./io_interface as community_tokens_module_interface
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
communityTokensModule: community_tokens_module_interface.AccessInterface
|
||||
|
||||
proc load*(self: View) =
|
||||
discard
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.QObject.delete
|
||||
|
||||
proc newView*(communityTokensModule: community_tokens_module_interface.AccessInterface): View =
|
||||
new(result, delete)
|
||||
result.QObject.setup
|
||||
result.communityTokensModule = communityTokensModule
|
||||
|
||||
proc deployCollectible*(self: View, communityId: string, fromAddress: string, name: string, symbol: string, description: string, supply: int, infiniteSupply: bool, transferable: bool, selfDestruct: bool, chainId: int, image: string) {.slot.} =
|
||||
self.communityTokensModule.deployCollectible(communityId, fromAddress, name, symbol, description, supply, infiniteSupply, transferable, selfDestruct, chainId, image)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import strformat
|
||||
import ./member_model, ./member_item
|
||||
import ../main/communities/models/[pending_request_item, pending_request_model]
|
||||
import ../main/communities/minting/models/token_model as community_tokens_model
|
||||
import ../main/communities/tokens/models/token_model as community_tokens_model
|
||||
import ../../global/global_singleton
|
||||
|
||||
import ../../../app_service/common/types
|
||||
|
|
|
@ -70,12 +70,16 @@ QtObject:
|
|||
let data = CommunityTokenDeployedStatusArgs(communityId: tokenDto.communityId, contractAddress: tokenDto.address, deployState: deployState)
|
||||
self.events.emit(SIGNAL_COMMUNITY_TOKEN_DEPLOY_STATUS, data)
|
||||
|
||||
proc mintCollectibles*(self: Service, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, tokenMetadata: CommunityTokensMetadataDto, chainId: int) =
|
||||
proc deployCollectibles*(self: Service, communityId: string, addressFrom: string, password: string, deploymentParams: DeploymentParameters, tokenMetadata: CommunityTokensMetadataDto, chainId: int) =
|
||||
try:
|
||||
# TODO this will come from SendModal
|
||||
let suggestedFees = self.transactionService.suggestedFees(chainId)
|
||||
let contractGasUnits = "3702411"
|
||||
|
||||
if suggestedFees == nil:
|
||||
error "Error deploying collectibles", message = "Can't get suggested fees"
|
||||
return
|
||||
|
||||
let txData = ens_utils.buildTransaction(parseAddress(addressFrom), 0.u256, contractGasUnits,
|
||||
if suggestedFees.eip1559Enabled: "" else: $suggestedFees.gasPrice, suggestedFees.eip1559Enabled,
|
||||
if suggestedFees.eip1559Enabled: $suggestedFees.maxPriorityFeePerGas else: "",
|
||||
|
@ -119,7 +123,7 @@ QtObject:
|
|||
)
|
||||
|
||||
except RpcException:
|
||||
error "Error minting collectibles", message = getCurrentExceptionMsg()
|
||||
error "Error deploying collectibles", message = getCurrentExceptionMsg()
|
||||
|
||||
proc getCommunityTokens*(self: Service, communityId: string): seq[CommunityTokenDto] =
|
||||
try:
|
||||
|
|
|
@ -222,8 +222,8 @@ SettingsPageLayout {
|
|||
chainName: collectibleItem.chainName
|
||||
chainIcon: collectibleItem.chainIcon
|
||||
|
||||
onMintCollectible: {
|
||||
root.communitiesStore.mintCollectible(root.communityId,
|
||||
onDeployCollectible: {
|
||||
root.communitiesStore.deployCollectible(root.communityId,
|
||||
root.transactionStore.currentAccount.address, /*TODO use address from SendModal*/
|
||||
name,
|
||||
symbol,
|
||||
|
|
|
@ -4,14 +4,14 @@ import QtQuick 2.15
|
|||
QtObject {
|
||||
id: root
|
||||
|
||||
property var mintingModuleInst: mintingModule ?? null
|
||||
property var communityTokensModuleInst: communityTokensModule ?? null
|
||||
|
||||
// Minting tokens:
|
||||
function mintCollectible(communityId, address, name, symbol, description, supply,
|
||||
function deployCollectible(communityId, address, name, symbol, description, supply,
|
||||
infiniteSupply, transferable, selfDestruct, chainId, artworkSource)
|
||||
{
|
||||
mintingModuleInst.mintCollectible(communityId, address, name, symbol, description, supply,
|
||||
infiniteSupply, transferable, selfDestruct, chainId, artworkSource)
|
||||
communityTokensModuleInst.deployCollectible(communityId, address, name, symbol, description, supply,
|
||||
infiniteSupply, transferable, selfDestruct, chainId, artworkSource)
|
||||
}
|
||||
|
||||
// Network selection properties:
|
||||
|
|
|
@ -32,7 +32,7 @@ StatusScrollView {
|
|||
property string chainIcon
|
||||
property int deployState
|
||||
|
||||
signal mintCollectible(url artworkSource,
|
||||
signal deployCollectible(url artworkSource,
|
||||
string name,
|
||||
string symbol,
|
||||
string description,
|
||||
|
@ -231,7 +231,7 @@ StatusScrollView {
|
|||
text: qsTr("Mint")
|
||||
|
||||
onClicked: {
|
||||
root.mintCollectible(root.artworkSource,
|
||||
root.deployCollectible(root.artworkSource,
|
||||
root.name,
|
||||
root.symbol,
|
||||
root.description,
|
||||
|
|
Loading…
Reference in New Issue