-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: Missing SendEip155Transaction on Metaverse demo (fix cronos-…
- Loading branch information
Showing
13 changed files
with
234 additions
and
40 deletions.
There are no files selected for viewing
Binary file not shown.
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
55 changes: 55 additions & 0 deletions
55
Metaverse/Source/Metaverse/Private/NPC/SendEthTransaction.cpp
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,55 @@ | ||
// Copyright 2022, Cronos Labs. All Rights Reserved | ||
|
||
#include "NPC/SendEthTransaction.h" | ||
|
||
#include "Components/PrimitiveComponent.h" | ||
#include "Components/WalletConnectTriggerComponent.h" | ||
#include "../../MetaverseCharacter.h" | ||
#include "PlayCppSdkActor.h" | ||
#include "Utlis.h" | ||
|
||
// Called when the game starts or when spawned | ||
void ASendEthTransaction::BeginPlay() { | ||
Super::BeginPlay(); | ||
GetWalletConnectTriggerComponent()->OnComponentBeginOverlap.AddDynamic( | ||
this, &ASendEthTransaction::OnSendEthTransactionBeginOverlap); | ||
} | ||
|
||
void ASendEthTransaction::OnSendEthTransactionBeginOverlap( | ||
UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, | ||
UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, | ||
const FHitResult &SweepResult) { | ||
MetaverseCharacter = Cast<AMetaverseCharacter>(OtherActor); | ||
if (MetaverseCharacter->GetAccount().IsEmpty()) { | ||
MetaverseCharacter->SetAccount( | ||
FText::FromString(FString::Printf(TEXT("Plase scan QR Code")))); | ||
} else { | ||
MetaverseCharacter->SetAccount(MetaverseCharacter->GetAccount()); | ||
} | ||
|
||
UWalletConnectTriggerComponent *WalletConnectTriggerComponent = | ||
GetWalletConnectTriggerComponent(); | ||
|
||
WalletConnectTriggerComponent->OnWalletconnectSendEip155TransactionDelegate | ||
.BindDynamic( | ||
this, | ||
&ASendEthTransaction::OnWalletconnectSendEip155TransactionFinished); | ||
|
||
FWalletConnectTxEip155 tx; | ||
tx.to = FString("0xA914161b1b8d9dbC9c5310Fc7EBee5A5B18044b7"); | ||
tx.value = FString("1000000000000000000"); | ||
WalletConnectTriggerComponent->SendEip155Transaction(tx); | ||
|
||
WalletConnectTriggerComponent->OnShowQR.BindDynamic(this, &Super::ShowQR); | ||
} | ||
|
||
void ASendEthTransaction::OnWalletconnectSendEip155TransactionFinished( | ||
FWalletSendTXEip155Result SendResult) { | ||
UE_LOG(LogTemp, Log, TEXT("Transaction Hash: %s, Result: %s"), | ||
*UUtlis::ToHex(SendResult.tx_hash), *SendResult.result); | ||
// Update new balance | ||
// TODO Check transaction receipt before querying the balance | ||
if (MetaverseCharacter) { | ||
MetaverseCharacter->SetBalance(MetaverseCharacter->GetAccount()); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
Metaverse/Source/Metaverse/Public/NPC/SendEthTransaction.h
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,34 @@ | ||
// Copyright 2022, Cronos Labs. All Rights Reserved | ||
|
||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "NPC/Help.h" | ||
#include "SendEthTransaction.generated.h" | ||
|
||
struct FWalletSendTXEip155Result; | ||
class AMetaverseCharacter; | ||
|
||
/** | ||
* | ||
*/ | ||
UCLASS() | ||
class METAVERSE_API ASendEthTransaction : public AHelp { | ||
GENERATED_BODY() | ||
|
||
protected: | ||
// Called when the game starts or when spawned | ||
virtual void BeginPlay() override; | ||
|
||
UFUNCTION() | ||
void OnSendEthTransactionBeginOverlap( | ||
UPrimitiveComponent *OverlappedComponent, AActor *OtherActor, | ||
UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, | ||
const FHitResult &SweepResult); | ||
|
||
private: | ||
UFUNCTION() | ||
void OnWalletconnectSendEip155TransactionFinished( | ||
FWalletSendTXEip155Result SendResult); | ||
AMetaverseCharacter *MetaverseCharacter; | ||
}; |
Oops, something went wrong.