Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Challenge Task
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OST
BlCh
Challenge Task
Commits
985bd37e
Commit
985bd37e
authored
4 months ago
by
Andri Joos
Browse files
Options
Downloads
Patches
Plain Diff
marketplace sell
parent
a0ef1d88
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Frontend/Marketplaces/Interfaces/IPotatoMarketplace.cs
+1
-1
1 addition, 1 deletion
Frontend/Marketplaces/Interfaces/IPotatoMarketplace.cs
Frontend/Marketplaces/PotatoMarketplaceMock.cs
+15
-0
15 additions, 0 deletions
Frontend/Marketplaces/PotatoMarketplaceMock.cs
with
16 additions
and
1 deletion
Frontend/Marketplaces/Interfaces/IPotatoMarketplace.cs
+
1
−
1
View file @
985bd37e
...
@@ -11,6 +11,6 @@ namespace Frontend.Marketplaces.Interfaces
...
@@ -11,6 +11,6 @@ namespace Frontend.Marketplaces.Interfaces
public
Task
<
double
>
PotatoKgPriceInEth
{
get
;
}
public
Task
<
double
>
PotatoKgPriceInEth
{
get
;
}
public
Task
<
bool
>
Approve
(
Web3
approverClient
,
BigInteger
amount
);
public
Task
<
bool
>
Approve
(
Web3
approverClient
,
BigInteger
amount
);
public
Task
<
PotatoTransaction
?>
Buy
(
string
ownerAddress
);
public
Task
<
PotatoTransaction
?>
Buy
(
string
ownerAddress
);
//
public
double
Sell(PotatoTransaction transaction);
public
Task
<
bool
>
Sell
(
PotatoTransaction
transaction
,
string
receiverAddress
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Frontend/Marketplaces/PotatoMarketplaceMock.cs
+
15
−
0
View file @
985bd37e
...
@@ -69,6 +69,21 @@ public class PotatoMarketplaceMock(
...
@@ -69,6 +69,21 @@ public class PotatoMarketplaceMock(
};
};
}
}
public
async
Task
<
bool
>
Sell
(
PotatoTransaction
transaction
,
string
receiverAddress
)
{
var
amount
=
(
double
)
await
PotatoKgWeiPrice
()
*
transaction
.
Weight
;
var
transferHandler
=
web3
.
Eth
.
GetContractTransactionHandler
<
TransferFunction
>();
var
transferFunction
=
new
TransferFunction
{
To
=
receiverAddress
,
Value
=
new
BigInteger
(
amount
),
};
var
receipt
=
await
transferHandler
.
SendRequestAndWaitForReceiptAsync
(
wethAddress
,
transferFunction
);
return
receipt
.
Status
.
Value
==
1
;
}
private
static
async
Task
<
double
>
EthChfPrice
()
private
static
async
Task
<
double
>
EthChfPrice
()
{
{
string
url
=
"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=CHF"
;
string
url
=
"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=CHF"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment