Skip to content

Commit

Permalink
WebGL SDK add setERC4337 method
Browse files Browse the repository at this point in the history
Mobile SDK update demo
  • Loading branch information
Zhichao Link committed Dec 19, 2023
1 parent 5e56656 commit 4ae278f
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Assets/ParticleNetwork/Mobile/Demo/AuthCoreDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Init()
ParticleNetwork.Init(this._chainInfo);
ParticleAuthCoreInteraction.Init();
// control how to show set master password and payment password.
ParticleNetwork.SetSecurityAccountConfig(new SecurityAccountConfig(0, 0));
ParticleNetwork.SetSecurityAccountConfig(new SecurityAccountConfig(1, 0));
}

public async void Connect()
Expand Down
2 changes: 1 addition & 1 deletion Assets/ParticleNetwork/Mobile/Demo/AuthDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Init()
{
ParticleNetwork.Init(this._chainInfo);
// control how to show set master password and payment password.
ParticleNetwork.SetSecurityAccountConfig(new SecurityAccountConfig(0, 0));
ParticleNetwork.SetSecurityAccountConfig(new SecurityAccountConfig(1, 0));
}

public async void Login()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class ParticleAuth : MonoBehaviour {

[DllImport("__Internal")]
private static extern void SetParticleAuthTheme(string options);

[DllImport("__Internal")]
private static extern void SetParticleERC4337(bool enable);

[DllImport("__Internal")]
private static extern void LoginWithParticle(string options);
Expand Down Expand Up @@ -110,6 +113,11 @@ public void SetAuthTheme(string options) {
SetParticleAuthTheme(options);
}

public void SetERC4337(bool enable)
{
SetParticleERC4337(enable);
}

public Task<string> Login(string options) {
loginTask = new TaskCompletionSource<string>();
LoginWithParticle(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ mergeInto(LibraryManager.library, {
const config = UTF8ToString(options);
window.particle.setAuthTheme(JSON.parse(config));
},

SetParticleERC4337: function (enable) {
window.particle.setERC4337(enable);
},

LoginWithParticle: async function (options) {
const config = UTF8ToString(options);
Expand Down
215 changes: 215 additions & 0 deletions ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ RectTransform:
m_Children:
- {fileID: 1114040581}
- {fileID: 40919615}
- {fileID: 1541632212}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand All @@ -452,6 +453,86 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &531653425
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 531653426}
- component: {fileID: 531653428}
- component: {fileID: 531653427}
m_Layer: 5
m_Name: Text (Legacy)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &531653426
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 531653425}
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: 1541632212}
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 &531653427
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 531653425}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 80
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 8
m_MaxSize: 80
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: OpenWallet
--- !u!222 &531653428
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 531653425}
m_CullTransparentMesh: 1
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -831,6 +912,140 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1114040580}
m_CullTransparentMesh: 1
--- !u!1 &1541632211
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1541632212}
- component: {fileID: 1541632215}
- component: {fileID: 1541632214}
- component: {fileID: 1541632213}
m_Layer: 5
m_Name: OpenWallet
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1541632212
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1541632211}
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: 531653426}
m_Father: {fileID: 223974231}
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: 0, y: -154}
m_SizeDelta: {x: 500, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1541632213
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1541632211}
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: 1541632214}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 223974227}
m_TargetAssemblyTypeName: DefaultNamespace.Demo, Assembly-CSharp
m_MethodName: OpenWallet
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 &1541632214
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1541632211}
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 &1541632215
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1541632211}
m_CullTransparentMesh: 1
--- !u!1 &1600812346
GameObject:
m_ObjectHideFlags: 0
Expand Down
9 changes: 9 additions & 0 deletions ParticleWebGLDemo/ParticleWebGLDemo/Assets/Scripts/Demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public async void Login()

var address = ParticleAuth.Instance.GetWalletAddress();
Debug.Log($"address {address}");

ParticleAuth.Instance.SetERC4337(true);
}

public async void SignMessage()
Expand All @@ -24,5 +26,12 @@ public async void SignMessage()
Debug.Log($"signature {signature}");
}



public async void OpenWallet()
{
ParticleAuth.Instance.OpenWallet();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ MonoBehaviour:
m_Script: {fileID: 0}
m_Name:
m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState
lastWriteTicks: -8584987401728053092
lastWriteTicks: -8584987359769327757
Loading

0 comments on commit 4ae278f

Please sign in to comment.