Skip to content

Added Sequence wrapper as a Sequence.Adapter assembly #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Assets/SequenceSDK/Adapter.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/SequenceSDK/Adapter/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Assets/SequenceSDK/Adapter/Tests/AdapterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Threading.Tasks;
using NUnit.Framework;

namespace Sequence.Pay.Tests.Transak
{
public class AdapterTests
{
private const string TokenId = "0";

private static readonly Address TokenAddress = new ("");
private static readonly Address CurrencyAddress = new ("");
private static readonly Address SellCurrencyAddress = new ("");
private static readonly Address RecipientAddress = new ("");

[Test]
public async Task UnifiedEndToEndTest()
{
var sequenceUnified = new Adapter.Sequence(Chain.TestnetArbitrumSepolia);
await sequenceUnified.TryRecoverWalletFromStorage();

var recovered = await sequenceUnified.TryRecoverWalletFromStorage();
if (!recovered)
await sequenceUnified.GuestLogin();

await sequenceUnified.GetIdToken();

var nativeTokenBalance= await sequenceUnified.GetMyNativeTokenBalance();
var tokenBalance = await sequenceUnified.GetMyTokenBalance(TokenAddress);

await sequenceUnified.SendToken(TokenAddress, RecipientAddress, TokenId, 1);
await sequenceUnified.SwapToken(SellCurrencyAddress, CurrencyAddress, 1000);

await sequenceUnified.CreateListingOnMarketplace(TokenAddress, CurrencyAddress, TokenId,
1, 1000, DateTime.MaxValue);

var listings = await sequenceUnified.GetAllListingsFromMarketplace(TokenAddress);
await sequenceUnified.PurchaseOrderFromMarketplace(listings[0].order, 1);
}
}
}
3 changes: 3 additions & 0 deletions Assets/SequenceSDK/Adapter/Tests/AdapterTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/SequenceSDK/Adapter/Tests/SequenceAdapterTests.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "SequenceUnifiedTests",
"rootNamespace": "",
"references": ["GUID:03d0ed9c50cfd4cb28a56d2d06580ffa","GUID:f7fd4ba36aabd1d499450c174865e70b","GUID:19b9eb7db56cc47349571a4fbb0dd677","GUID:403077141e1554429a890cbc129df651","GUID:4e0a798abbda240658187632ae443a67","GUID:f78a27d6a73d94c4baf04337e0add4dc"],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/SequenceSDK/Authentication/Tests/MockLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void TryToRestoreSession()

}

public void GuestLogin()
public Task GuestLogin()
{
throw new System.NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void TryToRestoreSession()

}

public void GuestLogin()
public Task GuestLogin()
{
throw new System.NotImplementedException();
}
Expand Down
3 changes: 3 additions & 0 deletions Packages/Sequence-Unity/Sequence/SequenceSDK/Adapter.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 133 additions & 0 deletions Packages/Sequence-Unity/Sequence/SequenceSDK/Adapter/ISequence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using System;
using System.Numerics;
using System.Threading.Tasks;
using Sequence.EmbeddedWallet;
using Sequence.Marketplace;

namespace Sequence.Adapter
{
public interface ISequence
{
/// <summary>
/// The underlying Sequence Embedded Wallet reference. Use it for more control, such as transaction batches.
/// </summary>
public IWallet Wallet { get; }

// ONBOARDING

/// <summary>
/// Recover a wallet from secure storage.
/// </summary>
/// <returns>'true' if a stored wallet was found or 'false' if not or if session recovery is disabled in your SequenceConfig file.</returns>
Task<bool> TryRecoverWalletFromStorage();

/// <summary>
/// Login using Email OTP. You will receive a code to your email. Use it with the 'ConfirmEmailCode' function to finish the login process.
/// </summary>
/// <param name="email">Email of the given user.</param>
/// <returns></returns>
Task EmailLogin(string email);

/// <summary>
/// You receive a code after calling 'EmailLogin'. Use it with this function to complete the login process.
/// </summary>
/// <param name="email"></param>
/// <param name="code"></param>
/// <returns></returns>
Task ConfirmEmailCode(string email, string code);

/// <summary>
/// Login as a guest. When the user uninstall the application, they lose access to a guest wallet, unless they use our Account Federation feature to link the guest wallet to another login option.
/// </summary>
/// <returns></returns>
Task GuestLogin();

/// <summary>
/// Sign In with Google. The user is redirected to an external browser.
/// </summary>
void GoogleLogin();

/// <summary>
/// Sign In with Apple. The user is redirected to an external browser. On iOS, this function uses the native Sign In SDK.
/// </summary>
void AppleLogin();

/// <summary>
/// Get an id token as a JWT you can use to verify the user on your backend. Use any JWKS library to verify this token.
/// </summary>
/// <returns>JWT Id Token</returns>
Task<string> GetIdToken();

// POWER

/// <summary>
/// Get the native token balance for your local user. For example, the native token on the Ethereum Mainnet is the amount of 'ETH'
/// </summary>
/// <returns>Balance in wei.</returns>
Task<BigInteger> GetMyNativeTokenBalance();

/// <summary>
/// Get the token balance for your local user.
/// </summary>
/// <param name="tokenAddress">Address of your token contract. This could be an ERC20, ERC1155, or ERC721 contract you deployed on https//sequence.build/</param>
/// <returns>Balance in wei and the token metadata.</returns>
Task<(BigInteger Balance, TokenMetadata TokenMetadata)> GetMyTokenBalance(Address tokenAddress);

/// <summary>
///
/// </summary>
/// <param name="tokenAddress"></param>
/// <returns></returns>
Task<TokenSupply[]> GetTokenSupplies(Address tokenAddress);

/// <summary>
/// Send any ERC20, ERC1155 or ERC721 token to another wallet.
/// </summary>
/// <param name="recipientAddress">The address of the wallet you want to send the token to.</param>
/// <param name="tokenAddress">The address of your token. For example one you have deployed through https://sequence.build/</param>
/// <param name="tokenId">Leave it blank for ERC20 contracts.</param>
/// <param name="amount">Leave it blank for ERC721 contracts.</param>
/// <returns>Transaction receipt used to check transaction information onchain.</returns>
/// <exception cref="Exception"></exception>
Task<string> SendToken(Address recipientAddress, Address tokenAddress, string tokenId, BigInteger amount);

// MONETIZATION

/// <summary>
/// Swap one of your tokens to another one. Make sure you have configured enough liquidity on a DEX such as UniSwap.
/// </summary>
/// <param name="sellToken"></param>
/// <param name="buyToken"></param>
/// <param name="buyAmount"></param>
/// <returns></returns>
Task SwapToken(Address sellToken, Address buyToken, BigInteger buyAmount);

/// <summary>
/// Get all listings from your Marketplace on a given collection. Please make sure you have configured your Marketplace on https://sequence.build/
/// </summary>
/// <param name="collectionAddress"></param>
/// <returns></returns>
Task<CollectibleOrder[]> GetAllListingsFromMarketplace(Address collectionAddress);

/// <summary>
/// Create a listing for a given token you own. Please make sure you have configured your Marketplace on https://sequence.build/
/// </summary>
/// <param name="contractAddress"></param>
/// <param name="currencyAddress"></param>
/// <param name="tokenId"></param>
/// <param name="amount"></param>
/// <param name="pricePerToken"></param>
/// <param name="expiry"></param>
/// <returns></returns>
Task<string> CreateListingOnMarketplace(Address contractAddress, Address currencyAddress,
string tokenId, BigInteger amount, BigInteger pricePerToken, DateTime expiry);

/// <summary>
/// Purchase an order from your Marketplace. Please make sure you have configured your Marketplace on https://sequence.build/
/// </summary>
/// <param name="order">The order as returned from the 'GetAllListingsFromMarketplace' function.</param>
/// <param name="amount">The amount of orders you wish to purchase.</param>
/// <returns></returns>
Task<string> PurchaseOrderFromMarketplace(Order order, BigInteger amount);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading