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;
|
const { ccclass, property } = _decorator;
|
||||||
import { createRequestData } from "./WalletSdkUtils";
|
import { createRequestData } from "./WalletSdkUtils";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ccclass("btn_click")
|
@ccclass("btn_click")
|
||||||
export class btn_click extends Component {
|
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) { }
|
update(deltaTime: number) { }
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,7 +53,7 @@ export class btn_click extends Component {
|
||||||
public async btn_onclick2() {
|
public async btn_onclick2() {
|
||||||
console.info("点击了按钮");
|
console.info("点击了按钮");
|
||||||
var temp = createRequestData(
|
var temp = createRequestData(
|
||||||
"0x4eDE150f62dc21aDC0F39a2A02c95A5Cc1FD7B2C",
|
this.address,
|
||||||
"0x62cC9fd83d48eFCe313695bA6a3245bCCC7f196e",
|
"0x62cC9fd83d48eFCe313695bA6a3245bCCC7f196e",
|
||||||
"Mint",
|
"Mint",
|
||||||
"0x4eDE150f62dc21aDC0F39a2A02c95A5Cc1FD7B2C",
|
"0x4eDE150f62dc21aDC0F39a2A02c95A5Cc1FD7B2C",
|
||||||
|
|
@ -97,10 +109,18 @@ export class btn_click extends Component {
|
||||||
var jsonStr = JSON.stringify(jsonObj);
|
var jsonStr = JSON.stringify(jsonObj);
|
||||||
///0x2eB535d54382eA5CED9183899916A9d39e093877
|
///0x2eB535d54382eA5CED9183899916A9d39e093877
|
||||||
|
|
||||||
|
|
||||||
var ret = native.reflection.callStaticMethod(
|
var ret = native.reflection.callStaticMethod(
|
||||||
"JSHandleClass",
|
"JSHandleClass",
|
||||||
"sendMessageFun:",
|
"sendMessageFun:",
|
||||||
jsonStr
|
jsonStr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setAddress(add: string) {
|
||||||
|
this.address = add;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -8,12 +8,15 @@
|
||||||
#import "JSHandleClass.h"
|
#import "JSHandleClass.h"
|
||||||
#import "cocos_demo_3_mobile-Swift.h"
|
#import "cocos_demo_3_mobile-Swift.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MyWalletConnect* wc;
|
MyWalletConnect* wc;
|
||||||
@implementation JSHandleClass
|
@implementation JSHandleClass
|
||||||
|
|
||||||
+ (void) init{
|
+ (void) init{
|
||||||
wc =[MyWalletConnect alloc];
|
wc =[MyWalletConnect alloc];
|
||||||
[wc initWalleConnect];
|
[wc initWalleConnect];
|
||||||
|
|
||||||
NSLog(@"调用到了init");
|
NSLog(@"调用到了init");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class WalletConnect {
|
||||||
// gnosis wc bridge: https://safe-walletconnect.gnosis.io/
|
// gnosis wc bridge: https://safe-walletconnect.gnosis.io/
|
||||||
// test bridge with latest protocol version: https://bridge.walletconnect.org
|
// test bridge with latest protocol version: https://bridge.walletconnect.org
|
||||||
let wcUrl = WCURL(topic: UUID().uuidString,
|
let wcUrl = WCURL(topic: UUID().uuidString,
|
||||||
bridgeURL: URL(string: "https://safe-walletconnect.gnosis.io/")!,
|
bridgeURL: URL(string: "https://bridge.walletconnect.org")!,
|
||||||
key: try! randomKey())
|
key: try! randomKey())
|
||||||
let clientMeta = Session.ClientMeta(name: "ExampleDApp",
|
let clientMeta = Session.ClientMeta(name: "ExampleDApp",
|
||||||
description: "WalletConnectSwift",
|
description: "WalletConnectSwift",
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@
|
||||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
// 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{
|
func walleConnectFun(urlTypeStr:String)->Void{
|
||||||
|
|
||||||
let deepLinkUrl = "wc"+"://wc?uri=\(cr!)"
|
let deepLinkUrl = urlTypeStr+"://wc?uri=\(cr!)"
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||||
if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
|
if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
|
||||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||||
|
|
@ -130,14 +130,18 @@ extension MyWalletConnect: WalletConnectDelegate {
|
||||||
|
|
||||||
func didConnect() {
|
func didConnect() {
|
||||||
onMainThread { [unowned self] in
|
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")
|
NSLog("didConnect")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func didDisconnect() {
|
func didDisconnect() {
|
||||||
onMainThread { [unowned self] in
|
onMainThread { [unowned self] in
|
||||||
NSLog("didConnect")
|
NSLog("didDisconnect")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue