save
This commit is contained in:
parent
ba1aa39ac3
commit
073cef8f2f
|
|
@ -2,9 +2,21 @@ import { _decorator, Component, Node, native,sys } from "cc";
|
|||
const { ccclass, property } = _decorator;
|
||||
import { createRequestData } from "./WalletSdkUtils";
|
||||
|
||||
|
||||
|
||||
|
||||
@ccclass("btn_click")
|
||||
export class btn_click extends Component {
|
||||
start() { }
|
||||
public address: string;
|
||||
|
||||
start() {
|
||||
window["setAddress"] = this.setAddress.bind(this);
|
||||
native.bridge.onNative = (add: string): void => {
|
||||
console.log(`触发了回调!回调内容:${add}`)
|
||||
this.setAddress(add)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) { }
|
||||
/**
|
||||
|
|
@ -41,7 +53,7 @@ export class btn_click extends Component {
|
|||
public async btn_onclick2() {
|
||||
console.info("点击了按钮");
|
||||
var temp = createRequestData(
|
||||
"0x4eDE150f62dc21aDC0F39a2A02c95A5Cc1FD7B2C",
|
||||
this.address,
|
||||
"0x62cC9fd83d48eFCe313695bA6a3245bCCC7f196e",
|
||||
"Mint",
|
||||
"0x4eDE150f62dc21aDC0F39a2A02c95A5Cc1FD7B2C",
|
||||
|
|
@ -97,10 +109,18 @@ export class btn_click extends Component {
|
|||
var jsonStr = JSON.stringify(jsonObj);
|
||||
///0x2eB535d54382eA5CED9183899916A9d39e093877
|
||||
|
||||
|
||||
var ret = native.reflection.callStaticMethod(
|
||||
"JSHandleClass",
|
||||
"sendMessageFun:",
|
||||
jsonStr
|
||||
);
|
||||
}
|
||||
|
||||
public setAddress(add: string) {
|
||||
this.address = add;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -8,12 +8,15 @@
|
|||
#import "JSHandleClass.h"
|
||||
#import "cocos_demo_3_mobile-Swift.h"
|
||||
|
||||
|
||||
|
||||
MyWalletConnect* wc;
|
||||
@implementation JSHandleClass
|
||||
|
||||
+ (void) init{
|
||||
wc =[MyWalletConnect alloc];
|
||||
[wc initWalleConnect];
|
||||
|
||||
NSLog(@"调用到了init");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class WalletConnect {
|
|||
// gnosis wc bridge: https://safe-walletconnect.gnosis.io/
|
||||
// test bridge with latest protocol version: https://bridge.walletconnect.org
|
||||
let wcUrl = WCURL(topic: UUID().uuidString,
|
||||
bridgeURL: URL(string: "https://safe-walletconnect.gnosis.io/")!,
|
||||
bridgeURL: URL(string: "https://bridge.walletconnect.org")!,
|
||||
key: try! randomKey())
|
||||
let clientMeta = Session.ClientMeta(name: "ExampleDApp",
|
||||
description: "WalletConnectSwift",
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@
|
|||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "cocos/platform/apple/JsbBridge.h"
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import WalletConnectSwift
|
|||
///链接钱包
|
||||
func walleConnectFun(urlTypeStr:String)->Void{
|
||||
|
||||
let deepLinkUrl = "wc"+"://wc?uri=\(cr!)"
|
||||
let deepLinkUrl = urlTypeStr+"://wc?uri=\(cr!)"
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
|
|
@ -130,14 +130,18 @@ extension MyWalletConnect: WalletConnectDelegate {
|
|||
|
||||
func didConnect() {
|
||||
onMainThread { [unowned self] in
|
||||
print("session+++++==============\(walletConnect.session.url)")
|
||||
print("session+++++==============\(walletConnect.session.walletInfo?.accounts)")
|
||||
var aa = JsbBridge.sharedInstance();
|
||||
aa?.send(toScript:walletConnect.session.walletInfo?.accounts[0]);
|
||||
// JsbBridgeWrapper* m = [JsbBridgeWrapper sharedInstance]
|
||||
print("链接成功")
|
||||
NSLog("didConnect")
|
||||
}
|
||||
}
|
||||
|
||||
func didDisconnect() {
|
||||
onMainThread { [unowned self] in
|
||||
NSLog("didConnect")
|
||||
NSLog("didDisconnect")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue