How to use _resolveCall method in wpt

Best JavaScript code snippet using wpt

RechargeManager.ts

Source:RechargeManager.ts Github

copy

Full Screen

12namespace clientCore {3 /**4 * 充值相关5 */67 interface IBuyTimes {8 /**支付成功次数 */9 payOkTimes: number10 /**到账成功次数 */11 payFinTimes: number12 /**上次购买时间(到账时间) */13 lastTime: number14 }15 export class RechargeManager {16 private static _resolveCall: Function;//支付到账调用17 private static _rejectCall: Function;//支付取消/失败调用18 private static _buyTimesHash: util.HashMap<IBuyTimes>;1920 private static _waiting: boolean;21 static async setup(): Promise<void> {22 //到账通知23 net.listen(pb.sc_pay_finish_notify, this, this.onPayNotify);24 EventManager.on(globalEvent.PAY_OK, this, this.onPayOk);25 return this.getPayOrderInfo();26 }2728 /**查询某个商品的支付信息29 * @return xlsInfo 商品表信息30 * @return payOkTimes 支付成功次数31 * @return payFinTimes 到账成功次数32 * @return lastTime 上次购买时间33 */34 static checkBuyLimitInfo(id: number) {35 let xlsInfo = Laya.Browser.onIOS ? xls.get(xls.rechargeShopOffical).get(id) : xls.get(xls.rechargeShopChannel).get(id);36 let payTimesInfo = this._buyTimesHash.get(id);37 return {38 xlsInfo: xlsInfo,39 /**支付成功次数 */40 payOkTimes: payTimesInfo ? payTimesInfo.payOkTimes : 0,41 /**支付到账次数 */42 payFinTimes: payTimesInfo ? payTimesInfo.payFinTimes : 0,43 /**上次购买时间 */44 lastTime: payTimesInfo ? payTimesInfo.lastTime : 045 }46 }4748 /**打印所有商品支付信息 */49 static testAllBuyLimitInfo() {50 console.table(this._buyTimesHash.getValues());51 }5253 /**获取玩家所有支付订单信息 */54 private static getPayOrderInfo() {55 this._buyTimesHash = new util.HashMap();56 return net.sendAndWait(new pb.cs_get_user_product_info()).then((data: pb.sc_get_user_product_info) => {57 for (const o of data.infos) {58 this._buyTimesHash.add(o.productID, { payOkTimes: Math.max(o.payCount, o.finishCount), payFinTimes: o.finishCount, lastTime: o.payTimestamp });59 }60 })61 }6263 /**获取商品信息 */64 static getShopInfo(id: number | string) {65 return channel.ChannelControl.ins.isOfficial ? xls.get(xls.rechargeShopOffical).get(id) : xls.get(xls.rechargeShopChannel).get(id);66 }6768 /**获取所有商品信息 */69 static getAllShopInfo() {70 return channel.ChannelControl.ins.isOfficial ? xls.get(xls.rechargeShopOffical) : xls.get(xls.rechargeShopChannel);71 }7273 /**开始支付流程74 * @description 75 * 开始支付会打开转圈loading,支付失败/到账后才会关闭loading76 * @returns 本函数返回到账后的数据包,如果支付取消或失败,触发reject,需要在catch中处理,参数globalEvent.PAY_CANCLE/globalEvent.PAY_FAIL77 * 78 */79 static pay(id: number) {80 if (this._waiting) return new Promise<pb.Isc_pay_finish_notify>((ok, reject) => { });81 this._waiting = true;82 return new Promise<pb.Isc_pay_finish_notify>((ok, reject) => {83 //检查未成年人是否可以充值84 let xlsData: xls.rechargeShopChannel | xls.rechargeShopOffical = channel.ChannelControl.ins.isOfficial ? xls.get(xls.rechargeShopOffical).get(id) : xls.get(xls.rechargeShopChannel).get(id);85 if (xlsData && RealManager.ins.checkRecharge(xlsData.cost)) {86 this._resolveCall = ok;87 this._rejectCall = reject;88 EventManager.once(globalEvent.PAY_CANCLE, this, this.onPayFail, [globalEvent.PAY_CANCLE]);89 EventManager.once(globalEvent.PAY_FAIL, this, this.onPayFail, [globalEvent.PAY_FAIL]);90 this.sendPayData(id);91 }92 })93 }9495 /**开始正式支付(内网走测试协议,外网走sdk) */96 private static sendPayData(id: number) {97 // LoadingManager.showSmall('正在支付。。。');98 if (channel.ChannelControl.ins.isInterior) { //是内部么?99 //内网 支付成功需要手动调用100 this.onPayOk(id);101 let testChannelId = window['testChannelId'] ?? 999;102 net.send(new pb.cs_online_test_pay({ prodcutID: id, channelID: testChannelId }))103 } else {104 let xlsData: xls.rechargeShopChannel | xls.rechargeShopOffical = Laya.Render.isConchApp && Laya.Browser.onIOS ? xls.get(xls.rechargeShopOffical).get(id) : xls.get(xls.rechargeShopChannel).get(id);105 channel.ChannelControl.ins.payToServer(xlsData);106 }107 }108109 /**支付到账 */110 private static onPayNotify(data: pb.Isc_pay_finish_notify) {111 if (this._buyTimesHash.has(data.productID)) {112 this._buyTimesHash.get(data.productID).payFinTimes += 1;113 this._buyTimesHash.get(data.productID).lastTime = clientCore.ServerManager.curServerTime;114 }115 else {116 this._buyTimesHash.add(data.productID, { payFinTimes: 1, payOkTimes: 1, lastTime: clientCore.ServerManager.curServerTime })117 }118 if (this._buyTimesHash.get(data.productID).payOkTimes < this._buyTimesHash.get(data.productID).payFinTimes) {119 this._buyTimesHash.get(data.productID).payOkTimes = this._buyTimesHash.get(data.productID).payFinTimes;120 }121 let xlsData: xls.rechargeShopChannel | xls.rechargeShopOffical = channel.ChannelControl.ins.isOfficial ? xls.get(xls.rechargeShopOffical).get(data.productID) : xls.get(xls.rechargeShopChannel).get(data.productID);122 RealManager.ins.rechargeCnt += xlsData.cost;123 LoadingManager.hideSmall(true);124 //如果有回调,在回调中打开奖励面板125 console.log(`[IAP] JS 到账通知 ` + data.productID)126 if (this._resolveCall) {127 this._resolveCall.call(this, data);128 }129 else {130 //没有回调,直接弹出奖励(主要是ios补单会出现这种情况)131 console.log(`[IAP] JS 补单通知 ` + data.productID)132 let info = RechargeManager.getShopInfo(data.productID);133 if (info) {134 alert.showSmall(`${info.name.replace('(小花仙手游)', '')}\n已到账,请注意查收!`, { btnType: alert.Btn_Type.ONLY_SURE });135 }136 }137 }138139 /**支付成功 */140 private static onPayOk(id: number) {141 this._waiting = false;142 console.log(`[IAP] JS 支付成功 productId:${id}`)143 // net.send(new pb.cs_add_product_pay_times({ productID: id }));144 if (this._buyTimesHash.has(id)) {145 this._buyTimesHash.get(id).payOkTimes += 1;146 }147 else {148 this._buyTimesHash.add(id, { payFinTimes: 0, payOkTimes: 1, lastTime: 0 })149 }150 }151152 /**支付失败 */153 private static onPayFail(reason: string) {154 this._waiting = false;155 if (this._rejectCall) {156 this._rejectCall.call(this, reason);157 LoadingManager.hideSmall(true);158 }159 }160 } ...

Full Screen

Full Screen

EvmTransactionResponse.ts

Source:EvmTransactionResponse.ts Github

copy

Full Screen

...97 message: 'Cannot send transaction, no supported call method provided',98 });99 }100 try {101 const receipt = await this._resolveCall(this, confirmations);102 this.receipt = receipt;103 return receipt;104 } catch (error: unknown) {105 let message = `Failed waiting for transaction confirmation.`;106 if (error instanceof Error) {107 // TODO: better error casting108 // eslint-disable-next-line @typescript-eslint/no-explicit-any109 const ethError: any = error;110 const details: Record<string, unknown> = {};111 if (ethError.reason) {112 message += ` Reason: ${ethError.reason}`;113 details.reason = ethError.reason;114 }115 if (ethError.cancelled) {...

Full Screen

Full Screen

opStack.ts

Source:opStack.ts Github

copy

Full Screen

...33 if (top === null) return null;34 const { op } = top;35 36 if (op.type === RobozzleOpTypes.call) {37 this._resolveCall(op);38 return null;39 }40 if (op.type === RobozzleOpTypes.empty)41 return this.popOp();42 return op;43 }44 /**45 * Count the number of nodes which has ids greater than `lastId`46 * @param lastId47 * @returns the number of new nodes48 */49 countNewNodes(lastId: number): number {50 let count = 0;51 let cur = this.head;52 while (cur !== null) {53 if (cur.item.id <= lastId) break;54 count += 1;55 cur = cur.next;56 }57 return count;58 }59 /**60 * Increment lastId, and return it61 * @returns next id for stack item62 */63 private _getNextId(): number {64 this.lastId += 1;65 return this.lastId;66 }67 private _resolveCall(call: RobozzleCallOperation): void {68 const { callee } = call;69 callee.seq70 .filter((el) => el.type !== RobozzleOpTypes.empty)71 .reverse()72 .forEach(this.pushOp.bind(this));73 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3wp._resolveCall('wp.getPosts', { 'post_type': 'post', 'post_status': 'publish' }, function (err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3wp._resolveCall('get', 'posts', function(data) {4 console.log(data);5});6var wptoolkit = require('wptoolkit');7var wp = new wptoolkit();8wp._resolveCall('get', 'posts', function(data) {9 console.log(data);10});11var wptoolkit = require('wptoolkit');12var wp = new wptoolkit();13wp._resolveCall('get', 'posts', function(data) {14 console.log(data);15});16var wptoolkit = require('wptoolkit');17var wp = new wptoolkit();18wp._resolveCall('get', 'posts', function(data) {19 console.log(data);20});21var wptoolkit = require('wptoolkit');22var wp = new wptoolkit();23wp._resolveCall('get', 'posts', function(data) {24 console.log(data);25});26var wptoolkit = require('wptoolkit');27var wp = new wptoolkit();28wp._resolveCall('get', 'posts', function(data) {29 console.log(data);30});31var wptoolkit = require('wptoolkit');32var wp = new wptoolkit();33wp._resolveCall('get', 'posts', function(data) {34 console.log(data);35});36var wptoolkit = require('wptoolkit');37var wp = new wptoolkit();38wp._resolveCall('get', 'posts', function(data) {39 console.log(data);40});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2wp.post.get({id: 1}, function(err, data) {3 if (err) {4 console.log(err);5 return;6 }7 console.log(data);8});9var wptoolkit = require('wptoolkit');10wp._resolveCall('post.get', {id: 1}, function(err, data) {11 if (err) {12 console.log(err);13 return;14 }15 console.log(data);16});17wp._resolveCall(['post.get', {context: 'edit'}], {id: 1}, function(err, data) {18 if (err) {19 console.log(err);20 return;21 }22 console.log(data);23});24wp._resolveCall(['post.get', {context: 'edit'}, {filter: 'raw'}], {id: 1}, function(err, data) {25 if (err) {26 console.log(err);27 return;28 }29 console.log(data);30});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var page = wptools.page('Barack Obama');3page.resolveCall('getCoordinates', function(err, result) {4 console.log(result);5});6{ [Error: No response from API] statusCode: 404 }7var wptools = require('wptools');8var page = wptools.page('Barack Obama');9page.getCoordinates(function(err, result) {10 console.log(result);11});12{ [Error: No response from API] statusCode: 404 }13var wptools = require('wptools');14var page = wptools.page('Barack Obama');15page.getCoordinates(function(err, result) {16 console.log(result);17});18{ [Error: No response from API] statusCode: 404 }19var wptools = require('wptools');20var page = wptools.page('Barack Obama');21page.getCoordinates(function(err, result) {22 console.log(result);23});24{ [Error: No response from API] statusCode: 404 }25var wptools = require('wptools');26var page = wptools.page('Barack Obama');27page.getCoordinates(function(err, result) {28 console.log(result);29});30{ [Error: No response from API] statusCode: 404 }31var wptools = require('wptools');32var page = wptools.page('Barack Obama');33page.getCoordinates(function(err, result) {34 console.log(result);35});36{ [Error: No response from API] statusCode

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 if (err) return console.error(err);5 var location = data.data[0].location;6 wpt.getTestResults('140809_7K_1d4d', function(err, data) {7 if (err) return console.error(err);8 console.log(data);9 });10});11var WebPageTest = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13wpt.getLocations(function(err, data) {14 if (err) return console.error(err);15 var location = data.data[0].location;16 wpt.getTestResults('140809_7K_1d4d', function(err, data) {17 if (err) return console.error(err);18 console.log(data);19 });20});21Error: Invalid API response: {"statusCode":200,"data":{"statusCode":200,"statusText":"Ok","data":{"testId":"140809_7K_1d4d","ownerKey":"1d4d4e4b6e5d6f2c6b5c7f5d5f5d7d5b5b5e7f5f5d5f7f5b5f5f7f5b5

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./lib/wpt');2var config = require('./config.json');3var wptClient = new wpt(config);4wptClient._resolveCall('CAbca1b5f5c7f4d4c8b7b1c1b1b7b2d2d2', function (err, response) {5 if (err) {6 console.log('error while resolving call: ' + err);7 }8 else {9 console.log('call resolved: ' + response);10 }11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var Wpt = new wpt();3Wpt._resolveCall('test', function(err, data) {4 console.log(data);5});6{data: "test"}7var wpt = require('wpt');8var Wpt = new wpt();9Wpt._resolveCall('test', function(err, data) {10 console.log(data);11});12{data: "test"}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful