Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtycajunrice committed Dec 29, 2024
1 parent 57b74e8 commit 1c35262
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ void UAsyncTaskThirdwebCreateSessionKey::Activate()
);
}

UAsyncTaskThirdwebCreateSessionKey* UAsyncTaskThirdwebCreateSessionKey::CreateSessionKey(UObject* WorldContextObject,
const FSmartWalletHandle& Wallet,
const FString& Signer,
const TArray<FString>& ApprovedTargets,
const FString& NativeTokenLimitPerTransactionInWei,
const FDateTime& PermissionEnd)
UAsyncTaskThirdwebCreateSessionKey* UAsyncTaskThirdwebCreateSessionKey::CreateSessionKey(
UObject* WorldContextObject,
const FSmartWalletHandle& Wallet,
const FString& Signer,
const TArray<FString>& ApprovedTargets,
const FString& NativeTokenLimitPerTransactionInWei,
const FDateTime& PermissionEnd
)
{
if (!WorldContextObject)
{
Expand Down Expand Up @@ -54,7 +56,7 @@ void UAsyncTaskThirdwebCreateSessionKey::HandleResponse(const FString& TxHash)
}, TStatId(), nullptr, ENamedThreads::GameThread);
return;
}

Success.Broadcast(TxHash, TEXT(""));
SetReadyToDestroy();
}
Expand Down
38 changes: 21 additions & 17 deletions Source/Thirdweb/Private/Wallets/ThirdwebSmartWalletHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void FSmartWalletHandle::Create(const FInAppWalletHandle& InInAppWallet,
const FStringDelegate& ErrorDelegate)
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);

if (!InInAppWallet.IsValid())
{
if (ErrorDelegate.IsBound())
Expand All @@ -52,7 +52,7 @@ void FSmartWalletHandle::Create(const FInAppWalletHandle& InInAppWallet,
}
return;
}

UE::Tasks::Launch(UE_SOURCE_LOCATION, [InInAppWallet, ChainID, bGasless, Factory, AccountOverride, SuccessDelegate, ErrorDelegate]
{
if (FString Error; Thirdweb::create_smart_wallet(
Expand Down Expand Up @@ -84,7 +84,7 @@ void FSmartWalletHandle::IsDeployed(const FBoolDelegate& SuccessDelegate, const
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FSmartWalletHandle ThisCopy = *this;
UE::Tasks::Launch(UE_SOURCE_LOCATION, [ThisCopy, SuccessDelegate, ErrorDelegate]
{
Expand All @@ -99,16 +99,18 @@ void FSmartWalletHandle::IsDeployed(const FBoolDelegate& SuccessDelegate, const
});
}

void FSmartWalletHandle::CreateSessionKey(const FString& Signer,
const TArray<FString>& ApprovedTargets,
const FString& NativeTokenLimitPerTransactionInWei,
const FDateTime& PermissionEnd,
const FStringDelegate& SuccessDelegate,
const FStringDelegate& ErrorDelegate)
void FSmartWalletHandle::CreateSessionKey(
const FString& Signer,
const TArray<FString>& ApprovedTargets,
const FString& NativeTokenLimitPerTransactionInWei,
const FDateTime& PermissionEnd,
const FStringDelegate& SuccessDelegate,
const FStringDelegate& ErrorDelegate
)
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FDateTime TenYearsFromNow = FDateTime::UtcNow() + FTimespan::FromDays(10 * 365);
FDateTime EndTime = TenYearsFromNow;
TArray<const char*> ApprovedTargetsCArray;
Expand Down Expand Up @@ -167,7 +169,7 @@ void FSmartWalletHandle::RevokeSessionKey(const FString& Signer, const FSimpleDe
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FSmartWalletHandle ThisCopy = *this;
UE::Tasks::Launch(UE_SOURCE_LOCATION, [ThisCopy, Signer, SuccessDelegate, ErrorDelegate]
{
Expand All @@ -186,7 +188,7 @@ void FSmartWalletHandle::GetAdmins(const FStringArrayDelegate& SuccessDelegate,
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FSmartWalletHandle ThisCopy = *this;
UE::Tasks::Launch(UE_SOURCE_LOCATION, [ThisCopy, SuccessDelegate, ErrorDelegate]
{
Expand Down Expand Up @@ -219,14 +221,15 @@ void FSmartWalletHandle::AddAdmin(const FString& Signer, const FSimpleDelegate&
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FSmartWalletHandle ThisCopy = *this;
UE::Tasks::Launch(UE_SOURCE_LOCATION, [ThisCopy, Signer, SuccessDelegate, ErrorDelegate]
{
if (FString Error; Thirdweb::smart_wallet_add_admin(ThisCopy.GetID(), TO_RUST_STRING(Signer)).AssignResult(Error))
{
SuccessDelegate.Execute();
} else
}
else
{
ErrorDelegate.Execute(Error);
}
Expand All @@ -237,14 +240,15 @@ void FSmartWalletHandle::RemoveAdmin(const FString& Signer, const FSimpleDelegat
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FSmartWalletHandle ThisCopy = *this;
UE::Tasks::Launch(UE_SOURCE_LOCATION, [ThisCopy, Signer, SuccessDelegate, ErrorDelegate]
{
if (FString Error; Thirdweb::smart_wallet_remove_admin(ThisCopy.GetID(), TO_RUST_STRING(Signer)).AssignResult(Error))
{
SuccessDelegate.Execute();
} else
}
else
{
ErrorDelegate.Execute(Error);
}
Expand All @@ -255,7 +259,7 @@ void FSmartWalletHandle::GetActiveSigners(const FGetActiveSignersDelegate& Succe
{
CHECK_DELEGATES(SuccessDelegate, ErrorDelegate);
CHECK_VALIDITY(ErrorDelegate);

FSmartWalletHandle ThisCopy = *this;
UE::Tasks::Launch(UE_SOURCE_LOCATION, [ThisCopy, SuccessDelegate, ErrorDelegate]
{
Expand Down

0 comments on commit 1c35262

Please sign in to comment.