Skip to content

Commit 9c4dc25

Browse files
Support for Coinbase Wallet and WalletConnect connections
1 parent 6874125 commit 9c4dc25

File tree

7 files changed

+1003
-98
lines changed

7 files changed

+1003
-98
lines changed

Assets/Plugin/thirdweb.jslib

+22-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ var plugin = {
2727
ThirdwebInitialize: function (chain, options) {
2828
window.bridge.initialize(UTF8ToString(chain), UTF8ToString(options));
2929
},
30-
ThirdwebConnect: function (taskId, cb) {
30+
ThirdwebConnect: function (taskId, wallet, chainId, cb) {
3131
// convert taskId from pointer to str and allocate it to keep in memory
3232
var id = UTF8ToString(taskId);
3333
var idSize = lengthBytesUTF8(id) + 1;
3434
var idPtr = _malloc(idSize);
3535
stringToUTF8(id, idPtr, idSize);
3636
// execute bridge call
3737
window.bridge
38-
.connect()
38+
.connect(UTF8ToString(wallet), chainId)
3939
.then((address) => {
4040
if (address) {
4141
var bufferSize = lengthBytesUTF8(address) + 1;
@@ -74,6 +74,26 @@ var plugin = {
7474
dynCall_viii(cb, idPtr, null, buffer);
7575
});
7676
},
77+
ThirdwebDisconnect: async function (taskId, cb) {
78+
// convert taskId from pointer to str and allocate it to keep in memory
79+
var id = UTF8ToString(taskId);
80+
var idSize = lengthBytesUTF8(id) + 1;
81+
var idPtr = _malloc(idSize);
82+
stringToUTF8(id, idPtr, idSize);
83+
// execute bridge call
84+
window.bridge
85+
.disconnect()
86+
.then(() => {
87+
dynCall_viii(cb, idPtr, idPtr, null);
88+
})
89+
.catch((err) => {
90+
var msg = err.message;
91+
var bufferSize = lengthBytesUTF8(msg) + 1;
92+
var buffer = _malloc(bufferSize);
93+
stringToUTF8(msg, buffer, bufferSize);
94+
dynCall_viii(cb, idPtr, null, buffer);
95+
});
96+
},
7797
};
7898

7999
mergeInto(LibraryManager.library, plugin);

0 commit comments

Comments
 (0)