Skip to content

Commit 4553e23

Browse files
sdk options
1 parent 35453d1 commit 4553e23

File tree

6 files changed

+47
-11
lines changed

6 files changed

+47
-11
lines changed

Assets/Plugin/thirdweb.jslib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ var plugin = {
2323
dynCall_viii(cb, idPtr, null, buffer);
2424
});
2525
},
26-
ThirdwebInitialize: function (chain) {
27-
window.bridge.initialize(UTF8ToString(chain));
26+
ThirdwebInitialize: function (chain, options) {
27+
window.bridge.initialize(UTF8ToString(chain), UTF8ToString(options));
2828
},
2929
ThirdwebConnect: function (taskId, cb) {
3030
// convert taskId from pointer to str and allocate it to keep in memory

Assets/SDKTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ public class SDKTest : MonoBehaviour
1111

1212
void Start()
1313
{
14-
sdk = new ThirdwebSDK("goerli");
14+
sdk = new ThirdwebSDK("goerli", new ThirdwebSDK.Options() {
15+
gasless = new ThirdwebSDK.GaslessOptions() {
16+
openzeppelin = new ThirdwebSDK.OZDefenderOptions() {
17+
relayerUrl = "https://api.defender.openzeppelin.com/autotasks/dad61716-3624-46c9-874f-0e73f15f04d5/runs/webhook/7d6a1834-dd33-4b7b-8af4-b6b4719a0b97/FdHMqyF3p6MGHw6K2nkLsv",
18+
relayerForwarderAddress = "0xEbc1977d1aC2fe1F6DAaF584E2957F7c436fcdEF"
19+
}
20+
}
21+
});
1522
}
1623

1724
void Update() {

Assets/Thirdweb/Scripts/Bridge.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ private static void jsCallback(string taskId, string result, string error)
4444
}
4545
}
4646

47-
public static void Initialize(string chainOrRPC) {
48-
ThirdwebInitialize(chainOrRPC);
47+
public static void Initialize(string chainOrRPC, ThirdwebSDK.Options options) {
48+
ThirdwebInitialize(chainOrRPC, JsonUtility.ToJson(options));
4949
}
5050

5151
public static async Task<string> Connect() {
@@ -72,7 +72,7 @@ public static async Task<T> InvokeRoute<T>(string route, string[] body)
7272
[DllImport("__Internal")]
7373
private static extern string ThirdwebInvoke(string taskId, string route, string payload, Action<string, string, string> cb);
7474
[DllImport("__Internal")]
75-
private static extern string ThirdwebInitialize(string chainOrRPC);
75+
private static extern string ThirdwebInitialize(string chainOrRPC, string options);
7676
[DllImport("__Internal")]
7777
private static extern string ThirdwebConnect(string taskId, Action<string, string, string> cb);
7878
}

Assets/Thirdweb/Scripts/ThirdwebSDK.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,39 @@ namespace Thirdweb
77
/// </summary>
88
public class ThirdwebSDK
99
{
10+
[System.Serializable]
11+
public struct Options
12+
{
13+
public GaslessOptions gasless;
14+
}
15+
16+
[System.Serializable]
17+
public struct GaslessOptions
18+
{
19+
public OZDefenderOptions openzeppelin;
20+
public BiconomyOptions biconomy;
21+
}
22+
23+
[System.Serializable]
24+
public struct OZDefenderOptions
25+
{
26+
public string relayerUrl;
27+
public string relayerForwarderAddress;
28+
}
29+
30+
[System.Serializable]
31+
public struct BiconomyOptions
32+
{
33+
public string apiId;
34+
public string apiKey;
35+
}
36+
1037
private string chainOrRPC;
11-
public ThirdwebSDK(string chainOrRPC)
38+
39+
public ThirdwebSDK(string chainOrRPC, Options options = new Options())
1240
{
1341
this.chainOrRPC = chainOrRPC;
14-
Bridge.Initialize(chainOrRPC);
42+
Bridge.Initialize(chainOrRPC, options);
1543
}
1644

1745
public Task<string> Connect()

Assets/WebGLTemplates/Better2020/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@
100100

101101
const w = window;
102102
w.bridge = {};
103-
w.bridge.initialize = (chain) => {
104-
const sdk = new ThirdwebSDK(chain);
103+
w.bridge.initialize = (chain, options) => {
104+
console.log("bridge.initialize", chain, options);
105+
const sdk = new ThirdwebSDK(chain, JSON.parse(options));
105106
w.thirdweb = sdk;
106107
}
107108

Packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
3+
"com.unity.nuget.newtonsoft-json": "2.0.0",
44
"com.unity.collab-proxy": "1.17.2",
55
"com.unity.ide.rider": "3.0.15",
66
"com.unity.ide.visualstudio": "2.0.16",

0 commit comments

Comments
 (0)