diff --git a/Assets/SequenceExamples/Scenes/Demo.unity b/Assets/SequenceExamples/Scenes/Demo.unity index 2433bd1c..d3e511fc 100644 --- a/Assets/SequenceExamples/Scenes/Demo.unity +++ b/Assets/SequenceExamples/Scenes/Demo.unity @@ -3909,6 +3909,7 @@ RectTransform: m_Children: - {fileID: 1767168144} - {fileID: 1469989421} + - {fileID: 1482161628} m_Father: {fileID: 171231629} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -6075,6 +6076,140 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1469989420} m_CullTransparentMesh: 1 +--- !u!1 &1482161627 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1482161628} + - component: {fileID: 1482161631} + - component: {fileID: 1482161630} + - component: {fileID: 1482161629} + m_Layer: 5 + m_Name: SendTransferButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1482161628 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1482161627} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1683902208} + m_Father: {fileID: 853804994} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -306, y: 0} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1482161629 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1482161627} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1482161630} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 853804995} + m_TargetAssemblyTypeName: Sequence.Demo.WaaSDemoPage, SequenceExamples + m_MethodName: SendTransfer + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &1482161630 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1482161627} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1482161631 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1482161627} + m_CullTransparentMesh: 1 --- !u!1 &1490251406 GameObject: m_ObjectHideFlags: 0 @@ -6762,6 +6897,141 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1659753098} m_CullTransparentMesh: 1 +--- !u!1 &1683902207 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1683902208} + - component: {fileID: 1683902210} + - component: {fileID: 1683902209} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1683902208 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1683902207} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1482161628} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1683902209 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1683902207} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Send Transfer + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4281479730 + m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 25.35 + m_fontSizeBase: 24 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 13.68 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1683902210 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1683902207} + m_CullTransparentMesh: 1 --- !u!1 &1767168141 GameObject: m_ObjectHideFlags: 0 @@ -8341,6 +8611,10 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 2980900695817914343, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2980900695857846706, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -8397,6 +8671,10 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 2980900695939724626, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2980900695942656418, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -8501,6 +8779,10 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 2980900696194897349, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2980900696299840490, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} propertyPath: m_Pivot.x value: 0.5 @@ -8745,6 +9027,10 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 2980900697128280171, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2980900697159384570, guid: 7d8e311766e5c4b8693a216ca3708b52, type: 3} propertyPath: m_AnchorMax.y value: 0 diff --git a/Assets/SequenceExamples/Scripts/UI/WaaSDemoPage.cs b/Assets/SequenceExamples/Scripts/UI/WaaSDemoPage.cs index dd0fc40a..a1a63b73 100644 --- a/Assets/SequenceExamples/Scripts/UI/WaaSDemoPage.cs +++ b/Assets/SequenceExamples/Scripts/UI/WaaSDemoPage.cs @@ -29,6 +29,7 @@ public override void Open(params object[] args) SetAddress(); _wallet.OnSignMessageComplete += OnSignMessageComplete; + _wallet.OnSendTransactionComplete += OnSuccessfulTransaction; } private async Task SetAddress() @@ -46,5 +47,27 @@ private void OnSignMessageComplete(SignMessageReturn result) { _resultText.text = result.signature; } + + public void SendTransfer() + { + _wallet.SendTransaction(new SendTransactionArgs( + _address, + Chain.Polygon, + new SequenceSDK.WaaS.Transaction[] + { + new RawTransaction("0x9766bf76b2E3e7BCB8c61410A3fC873f1e89b43f", "1") + })); + } + + private void OnSuccessfulTransaction(SuccessfulTransactionReturn result) + { + _resultText.text = $"https://polygonscan.com/tx/{result.txHash}"; + Application.OpenURL($"https://polygonscan.com/tx/{result.txHash}"); + } + + private void OnFailedTransaction(FailedTransactionReturn result) + { + _resultText.text = result.error; + } } } \ No newline at end of file diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/DelayedEncode.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/DelayedEncode.cs index 05d6e966..04072f95 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/DelayedEncode.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/DelayedEncode.cs @@ -3,8 +3,9 @@ namespace SequenceSDK.WaaS [System.Serializable] public class DelayedEncode : SequenceSDK.WaaS.Transaction { + public const string TypeIdentifier = "delayedEncode"; public DelayedEncodeData data { get; private set; } - public string type { get; private set; } = "delayedEncode"; + public string type { get; private set; } = TypeIdentifier; public string to { get; private set; } public string value { get; private set; } diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/RawTransaction.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/RawTransaction.cs index 74f61559..f2cf5996 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/RawTransaction.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/RawTransaction.cs @@ -1,3 +1,5 @@ +using System.Numerics; +using Newtonsoft.Json; using StringExtensions = Sequence.Utils.StringExtensions; namespace Sequence.WaaS @@ -5,9 +7,10 @@ namespace Sequence.WaaS [System.Serializable] public class RawTransaction : SequenceSDK.WaaS.Transaction { + public const string TypeIdentifier = "transaction"; public string data { get; private set; } public string to { get; private set; } - public string type { get; private set; } = "transaction"; + public string type { get; private set; } = TypeIdentifier; public string value { get; private set; } public RawTransaction(string to, string value = null, string calldata = null) @@ -20,5 +23,14 @@ public RawTransaction(string to, string value = null, string calldata = null) this.value = value; this.data = calldata; } + + [JsonConstructor] + public RawTransaction(string data, string to, string type, string value) + { + this.data = data; + this.to = to; + this.type = type; + this.value = value; + } } } diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC1155.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC1155.cs index 2b78af81..6e313a3c 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC1155.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC1155.cs @@ -1,4 +1,5 @@ using System; +using Newtonsoft.Json; using SequenceSDK.WaaS; namespace Sequence.WaaS @@ -6,10 +7,11 @@ namespace Sequence.WaaS [Serializable] public class SendERC1155 : SequenceSDK.WaaS.Transaction { + public const string TypeIdentifier = "erc1155send"; public string data { get; private set; } public string to { get; private set; } public string token { get; private set; } - public string type { get; private set; } = "erc1155send"; + public string type { get; private set; } = TypeIdentifier; public SendERC1155Values[] vals { get; private set; } public SendERC1155(string tokenAddress, string to, SendERC1155Values[] sendErc1155Values, string data) @@ -19,5 +21,15 @@ public SendERC1155(string tokenAddress, string to, SendERC1155Values[] sendErc11 this.vals = sendErc1155Values; this.data = data; } + + [JsonConstructor] + public SendERC1155(string data, string to, string token, string type, SendERC1155Values[] vals) + { + this.data = data; + this.to = to; + this.token = token; + this.type = type; + this.vals = vals; + } } } \ No newline at end of file diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC20.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC20.cs index ce277d25..d69e4e25 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC20.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC20.cs @@ -1,11 +1,14 @@ +using Newtonsoft.Json; + namespace SequenceSDK.WaaS { [System.Serializable] public class SendERC20 : SequenceSDK.WaaS.Transaction { + public const string TypeIdentifier = "erc20send"; public string to { get; private set; } public string token { get; private set; } - public string type { get; private set; } = "erc20send"; + public string type { get; private set; } = TypeIdentifier; public string value { get; private set; } public SendERC20(string tokenAddress, string to, string value) @@ -14,5 +17,15 @@ public SendERC20(string tokenAddress, string to, string value) this.to = to; this.value = value; } + + + [JsonConstructor] + public SendERC20(string to, string token, string type, string value) + { + this.to = to; + this.token = token; + this.type = type; + this.value = value; + } } } \ No newline at end of file diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC721.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC721.cs index 6fede953..4549709a 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC721.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendERC721.cs @@ -1,4 +1,5 @@ using System; +using Newtonsoft.Json; using UnityEngine; namespace SequenceSDK.WaaS @@ -6,12 +7,13 @@ namespace SequenceSDK.WaaS [Serializable] public class SendERC721 : SequenceSDK.WaaS.Transaction { + public const string TypeIdentifier = "erc721send"; public string data { get; private set; } public string id { get; private set; } public bool safe { get; private set; } public string to { get; private set; } public string token { get; private set; } - public string type { get; private set; } = "erc721send"; + public string type { get; private set; } = TypeIdentifier; public SendERC721(string tokenAddress, string to, string tokenId, bool safe = true, string data = null) { @@ -26,5 +28,16 @@ public SendERC721(string tokenAddress, string to, string tokenId, bool safe = tr } this.data = data; } + + [JsonConstructor] + public SendERC721(string data, string id, bool safe, string to, string token, string type) + { + this.data = data; + this.id = id; + this.safe = safe; + this.to = to; + this.token = token; + this.type = type; + } } } \ No newline at end of file diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendTransactionArgs.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendTransactionArgs.cs index 27ed5089..6855d366 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendTransactionArgs.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SendTransactionArgs.cs @@ -1,4 +1,7 @@ using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using SequenceSDK.WaaS; using UnityEditor; namespace Sequence.WaaS @@ -7,16 +10,76 @@ namespace Sequence.WaaS public class SendTransactionArgs { public string code { get; private set; } = "sendTransaction"; + public uint expires { get; private set; } public string identifier { get; private set; } = Guid.NewGuid().ToString(); + public uint issued { get; private set; } public string network { get; private set; } public SequenceSDK.WaaS.Transaction[] transactions { get; private set; } public string wallet { get; private set; } - public SendTransactionArgs(string walletAddress, string network, SequenceSDK.WaaS.Transaction[] transactions) + public static readonly string transactionTypeIdentifier = "type"; + + public SendTransactionArgs(string walletAddress, string network, SequenceSDK.WaaS.Transaction[] transactions, uint timeBeforeExpiry = 30) { this.wallet = walletAddress; this.network = network; this.transactions = transactions; + this.issued = (uint)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + this.expires = this.issued + timeBeforeExpiry; + } + + public SendTransactionArgs(string walletAddress, Chain network, SequenceSDK.WaaS.Transaction[] transactions, uint timeBeforeExpiry = 30) + { + uint networkId = (uint)network; + this.wallet = walletAddress; + this.network = networkId.ToString(); + this.transactions = transactions; + this.issued = (uint)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + this.expires = this.issued + timeBeforeExpiry; + } + + [JsonConstructor] + public SendTransactionArgs(string code, uint expires, uint issued, string network, JObject[] transactions, string wallet) + { + this.code = code; + this.expires = expires; + this.issued = issued; + this.network = network; + this.wallet = wallet; + int transactionCount = transactions.Length; + this.transactions = new SequenceSDK.WaaS.Transaction[transactionCount]; + for (int i = 0; i < transactionCount; i++) + { + if (transactions[i].TryGetValue(transactionTypeIdentifier, out var type)) + { + string typeName = type.Value(); + switch (typeName) + { + case RawTransaction.TypeIdentifier: + this.transactions[i] = transactions[i].ToObject(); + break; + case SendERC20.TypeIdentifier: + this.transactions[i] = transactions[i].ToObject(); + break; + case SendERC721.TypeIdentifier: + this.transactions[i] = transactions[i].ToObject(); + break; + case SendERC1155.TypeIdentifier: + this.transactions[i] = transactions[i].ToObject(); + break; + case DelayedEncode.TypeIdentifier: + this.transactions[i] = transactions[i].ToObject(); + break; + default: + throw new JsonSerializationException($"Unknown transaction type {typeName} in transaction {i}: {transactions[i]}"); + } + } + else + { + throw new JsonSerializationException( + $"No '{transactionTypeIdentifier}' found in transaction {i}: {transactions[i]}"); + } + } } } } \ No newline at end of file diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SignMessageArgs.cs b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SignMessageArgs.cs index 88cb124e..f15f09d6 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SignMessageArgs.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ParameterTypes/SignMessageArgs.cs @@ -13,7 +13,7 @@ public class SignMessageArgs public string network { get; private set; } public string wallet { get; private set; } - public SignMessageArgs(string wallet, Chain network, string message, uint timeBeforeExpiry = 3000) + public SignMessageArgs(string wallet, Chain network, string message, uint timeBeforeExpiry = 30) { int networkId = (int)network; this.wallet = wallet; @@ -23,7 +23,7 @@ public SignMessageArgs(string wallet, Chain network, string message, uint timeBe this.expires = this.issued + timeBeforeExpiry; } - public SignMessageArgs(string wallet, string networkId, string message, uint timeBeforeExpiry = 3000) + public SignMessageArgs(string wallet, string networkId, string message, uint timeBeforeExpiry = 30) { this.wallet = wallet; this.network = networkId; diff --git a/Assets/SequenceSDK/WaaS/DataTypes/ReturnTypes/MetaTxnReceipt.cs b/Assets/SequenceSDK/WaaS/DataTypes/ReturnTypes/MetaTxnReceipt.cs index 956d3f16..8f11f894 100644 --- a/Assets/SequenceSDK/WaaS/DataTypes/ReturnTypes/MetaTxnReceipt.cs +++ b/Assets/SequenceSDK/WaaS/DataTypes/ReturnTypes/MetaTxnReceipt.cs @@ -7,11 +7,11 @@ public class MetaTxnReceipt public string status { get; private set; } public string revertReason { get; private set; } public int index { get; private set; } - public MetaTxnReceiptLog logs { get; private set; } - public MetaTxnReceipt receipts { get; private set; } + public MetaTxnReceiptLog[] logs { get; private set; } + public MetaTxnReceipt[] receipts { get; private set; } public string txnReceipt { get; private set; } - public MetaTxnReceipt(string id, string status, int index, MetaTxnReceiptLog logs, MetaTxnReceipt receipts, string txnReceipt, string revertReason = null) + public MetaTxnReceipt(string id, string status, int index, MetaTxnReceiptLog[] logs, MetaTxnReceipt[] receipts, string txnReceipt, string revertReason = null) { this.id = id; this.status = status; diff --git a/Assets/SequenceSDK/WaaS/IWallet.cs b/Assets/SequenceSDK/WaaS/IWallet.cs index d365ec29..da16bd6d 100644 --- a/Assets/SequenceSDK/WaaS/IWallet.cs +++ b/Assets/SequenceSDK/WaaS/IWallet.cs @@ -47,7 +47,8 @@ public Task PartnerWallets(PartnerWalletsArgs args, public Task IsValidMessageSignature(IsValidMessageSignatureArgs args); - public event Action OnSendTransactionComplete; + public event Action OnSendTransactionComplete; + public event Action OnSendTransactionFailed; public Task SendTransaction(SendTransactionArgs args); } } \ No newline at end of file diff --git a/Assets/SequenceSDK/WaaS/WaaSWallet.cs b/Assets/SequenceSDK/WaaS/WaaSWallet.cs index 8e302d5c..633630c5 100644 --- a/Assets/SequenceSDK/WaaS/WaaSWallet.cs +++ b/Assets/SequenceSDK/WaaS/WaaSWallet.cs @@ -99,11 +99,14 @@ public Task IsValidMessageSignature(IsValidMessag return _intentSender.SendIntent(args); } - public event Action OnSendTransactionComplete; + public event Action OnSendTransactionComplete; + public event Action OnSendTransactionFailed; - public Task SendTransaction(SendTransactionArgs args) + public async Task SendTransaction(SendTransactionArgs args) { - return _intentSender.SendIntent(args); + var result = await _intentSender.SendIntent(args); + OnSendTransactionComplete?.Invoke(result); + return result; } } } \ No newline at end of file