Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Frontend
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
796
Issues
796
List
Boards
Labels
Service Desk
Milestones
Merge Requests
61
Merge Requests
61
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
14e92682
Commit
14e92682
authored
42 minutes ago
by
Emiliano Balbuena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): W2W payments for campaigns
parent
ec6a1ad8
goal/boost-campaigns-e24
1 merge request
!387
WIP: Boost Campaigns (&24)
Pipeline
#69470564
passed with stages
in 27 minutes and 34 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
33 deletions
+36
-33
token-contract.service.ts
...pp/modules/blockchain/contracts/token-contract.service.ts
+5
-2
campaign-payments.service.ts
src/app/modules/boost/campaigns/campaign-payments.service.ts
+31
-31
No files found.
src/app/modules/blockchain/contracts/token-contract.service.ts
View file @
14e92682
...
...
@@ -49,10 +49,13 @@ export class TokenContractService {
// Direct Minds payments
async
transfer
(
address
:
string
,
amount
:
number
)
{
return
(
await
this
.
token
()).
transfer
(
address
,
this
.
tokenToUnit
(
amount
));
}
async
payment
(
amount
:
number
)
{
return
(
await
this
.
token
()).
transfer
(
this
.
web3Wallet
.
config
.
wallet_address
,
this
.
tokenToUnit
(
amount
)
);
return
await
this
.
transfer
(
this
.
web3Wallet
.
config
.
wallet_address
,
amount
);
}
// Balances
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/boost/campaigns/campaign-payments.service.ts
View file @
14e92682
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Web3WalletService
}
from
'
../../blockchain/web3-wallet.service
'
;
import
{
BoostContractService
}
from
'
../../blockchain/contracts/boost-contract.service
'
;
import
{
OverlayModalService
}
from
'
../../../services/ux/overlay-modal
'
;
import
{
GetMetamaskComponent
}
from
'
../../blockchain/metamask/getmetamask.component
'
;
import
{
Campaign
,
CampaignPayment
}
from
'
./campaigns.type
'
;
import
{
TokenContractService
}
from
'
../../blockchain/contracts/token-contract.service
'
;
@
Injectable
()
export
class
CampaignPaymentsService
{
campaignWallet
:
string
;
constructor
(
protected
web3Wallet
:
Web3WalletService
,
protected
boostContract
:
Boost
ContractService
,
protected
tokenContract
:
Token
ContractService
,
protected
overlayModal
:
OverlayModalService
,
)
{
this
.
campaignWallet
=
window
.
Minds
.
blockchain
.
boost_campaigns_wallet_address
;
}
calculateAmountDue
(
campaign
:
Campaign
,
isEditing
:
boolean
):
number
{
...
...
@@ -31,36 +34,33 @@ export class CampaignPaymentsService {
}
async
pay
(
campaign
:
Campaign
,
amount
:
number
):
Promise
<
CampaignPayment
>
{
await
this
.
web3Wallet
.
ready
();
if
(
this
.
web3Wallet
.
isUnavailable
())
{
throw
new
Error
(
'
No Ethereum wallets available on your browser.
'
);
}
else
if
(
!
this
.
campaignWallet
)
{
throw
new
Error
(
'
Campaign Wallet is not setup.
'
);
}
if
(
await
this
.
web3Wallet
.
isLocal
())
{
const
action
=
await
this
.
web3Wallet
.
setupMetamask
();
switch
(
action
)
{
case
GetMetamaskComponent
.
ACTION_CREATE
:
// this.router.navigate(['/wallet']);
this
.
overlayModal
.
dismiss
();
break
;
case
GetMetamaskComponent
.
ACTION_CANCEL
:
return
;
}
}
if
(
!
(
await
this
.
web3Wallet
.
unlock
()))
{
throw
new
Error
(
'
Your Ethereum wallet is locked or connected to another network.
'
);
}
return
{
address
:
'
0x
'
,
txHash
:
''
,
address
:
await
this
.
web3Wallet
.
getCurrentWallet
(
true
)
as
string
,
txHash
:
await
this
.
tokenContract
.
transfer
(
this
.
campaignWallet
,
amount
)
,
};
// await this.web3Wallet.ready();
//
// if (this.web3Wallet.isUnavailable()) {
// throw new Error('No Ethereum wallets available on your browser.');
// }
//
// if (await this.web3Wallet.isLocal()) {
// const action = await this.web3Wallet.setupMetamask();
// switch (action) {
// case GetMetamaskComponent.ACTION_CREATE:
// // this.router.navigate(['/wallet']);
// this.overlayModal.dismiss();
// break;
// case GetMetamaskComponent.ACTION_CANCEL:
// return;
// }
// }
//
// if (!(await this.web3Wallet.unlock())) {
// throw new Error('Your Ethereum wallet is locked or connected to another network.');
// }
//
// return {
// address: await this.web3Wallet.getCurrentWallet(true) as string,
// txHash: await this.boostContract.create(campaign.client_guid, amount, campaign.checksum),
// };
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment