Skip to content

Commit 9fdf575

Browse files
committed
added TransactionConverter to convert embedded- to ecosystem transactions
1 parent 16403d5 commit 9fdf575

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/SequenceEcosystemWallet.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"GUID:a35e3a53d4439435f8b36ed2c6158cd8",
66
"GUID:b4f9c0f8f363f439b9e337f79050f189",
77
"GUID:f7fd4ba36aabd1d499450c174865e70b",
8-
"GUID:94b67778c44684afdab21990eebf60aa"
8+
"GUID:94b67778c44684afdab21990eebf60aa",
9+
"GUID:4e0a798abbda240658187632ae443a67"
910
],
1011
"includePlatforms": [],
1112
"excludePlatforms": [],
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Numerics;
2+
using Sequence.Contracts;
3+
using Sequence.Transactions;
4+
using Sequence.Utils;
5+
6+
namespace Sequence.EcosystemWallet
7+
{
8+
public static class TransactionConverter
9+
{
10+
public static ITransaction[] ToEcosystemWalletTransactions(this EmbeddedWallet.RawTransaction[] transactions)
11+
{
12+
var newTransactions = new ITransaction[transactions.Length];
13+
for (var i = 0; i < transactions.Length; i++)
14+
newTransactions[i] = transactions[i].ToEcosystemWalletTransaction();
15+
16+
return newTransactions;
17+
}
18+
19+
public static ITransaction ToEcosystemWalletTransaction(this EmbeddedWallet.RawTransaction transaction)
20+
{
21+
return new RawTransaction(
22+
new Address(transaction.to),
23+
BigInteger.Parse(transaction.value),
24+
transaction.data.HexStringToByteArray());
25+
}
26+
27+
public static ITransaction ToEcosystemWalletTransaction(this CallContractFunction contract)
28+
{
29+
return new RawTransaction(
30+
new Address(contract.Address), 0,
31+
contract.CallData.HexStringToByteArray());
32+
}
33+
34+
public static ITransaction ToEcosystemWalletTransaction(this EthTransaction transaction)
35+
{
36+
return new RawTransaction(
37+
new Address(transaction.To),
38+
transaction.Value,
39+
transaction.Data.HexStringToByteArray());
40+
}
41+
}
42+
}

Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/Utils/TransactionConverter.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)