@depay/web3-wallets-evm 18.0.8 → 18.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.evm.js +555 -194
- package/dist/esm/index.js +588 -227
- package/dist/umd/index.evm.js +563 -201
- package/dist/umd/index.js +596 -234
- package/package.json +2 -3
package/dist/esm/index.evm.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { request, estimate, getProvider } from '@depay/web3-client-evm';
|
|
1
|
+
import { request, estimate, getProvider, rpcRequest } from '@depay/web3-client-evm';
|
|
2
2
|
import Blockchains from '@depay/web3-blockchains';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import { SignClient } from '@depay/walletconnect-v2';
|
|
5
5
|
import { CoinbaseWalletSDK } from '@depay/coinbase-wallet-sdk';
|
|
6
|
-
import { MiniKit, ResponseEvent } from '@depay/worldcoin-precompiled';
|
|
7
6
|
|
|
8
7
|
let supported$1 = ['ethereum', 'bsc', 'polygon', 'fantom', 'arbitrum', 'avalanche', 'gnosis', 'optimism', 'base', 'worldchain'];
|
|
9
8
|
supported$1.evm = ['ethereum', 'bsc', 'polygon', 'fantom', 'arbitrum', 'avalanche', 'gnosis', 'optimism', 'base', 'worldchain'];
|
|
10
9
|
supported$1.svm = [];
|
|
11
10
|
|
|
12
|
-
function _optionalChain$
|
|
11
|
+
function _optionalChain$q(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
13
12
|
class Transaction {
|
|
14
13
|
|
|
15
14
|
constructor({
|
|
@@ -35,7 +34,7 @@ class Transaction {
|
|
|
35
34
|
this.to = (to && to.match('0x')) ? ethers.utils.getAddress(to) : to;
|
|
36
35
|
|
|
37
36
|
// optional
|
|
38
|
-
this.value = _optionalChain$
|
|
37
|
+
this.value = _optionalChain$q([Transaction, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
39
38
|
this.api = api;
|
|
40
39
|
this.method = method;
|
|
41
40
|
this.params = params;
|
|
@@ -76,7 +75,7 @@ class Transaction {
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
getParamType(param) {
|
|
79
|
-
if(_optionalChain$
|
|
78
|
+
if(_optionalChain$q([param, 'optionalAccess', _5 => _5.components, 'optionalAccess', _6 => _6.length])) {
|
|
80
79
|
return `(${param.components.map((param)=>this.getParamType(param)).join(',')})`
|
|
81
80
|
} else {
|
|
82
81
|
return param.type
|
|
@@ -149,7 +148,7 @@ class Transaction {
|
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
|
|
152
|
-
function _optionalChain$
|
|
151
|
+
function _optionalChain$p(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
153
152
|
|
|
154
153
|
const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
155
154
|
transaction = new Transaction(transaction);
|
|
@@ -203,7 +202,7 @@ const retrieveConfirmedTransaction$2 = (sentTransaction)=>{
|
|
|
203
202
|
try {
|
|
204
203
|
sentTransaction.wait(1).then(resolve).catch((error)=>{
|
|
205
204
|
if(
|
|
206
|
-
(error && _optionalChain$
|
|
205
|
+
(error && _optionalChain$p([error, 'optionalAccess', _ => _.stack, 'optionalAccess', _2 => _2.match, 'call', _3 => _3('JSON-RPC error')])) ||
|
|
207
206
|
(error && error.toString().match('undefined'))
|
|
208
207
|
) {
|
|
209
208
|
setTimeout(()=>{
|
|
@@ -217,7 +216,7 @@ const retrieveConfirmedTransaction$2 = (sentTransaction)=>{
|
|
|
217
216
|
});
|
|
218
217
|
} catch(error) {
|
|
219
218
|
if(
|
|
220
|
-
(error && _optionalChain$
|
|
219
|
+
(error && _optionalChain$p([error, 'optionalAccess', _4 => _4.stack, 'optionalAccess', _5 => _5.match, 'call', _6 => _6('JSON-RPC error')])) ||
|
|
221
220
|
(error && error.toString().match('undefined'))
|
|
222
221
|
) {
|
|
223
222
|
setTimeout(()=>{
|
|
@@ -252,12 +251,12 @@ const submitContractInteraction$2 = async ({ transaction, signer, provider })=>{
|
|
|
252
251
|
if(contractArguments) {
|
|
253
252
|
return await method(...contractArguments, {
|
|
254
253
|
value: Transaction.bigNumberify(transaction.value, transaction.blockchain),
|
|
255
|
-
gasLimit: _optionalChain$
|
|
254
|
+
gasLimit: _optionalChain$p([gas, 'optionalAccess', _7 => _7.toHexString, 'call', _8 => _8()])
|
|
256
255
|
})
|
|
257
256
|
} else {
|
|
258
257
|
return await method({
|
|
259
258
|
value: Transaction.bigNumberify(transaction.value, transaction.blockchain),
|
|
260
|
-
gasLimit: _optionalChain$
|
|
259
|
+
gasLimit: _optionalChain$p([gas, 'optionalAccess', _9 => _9.toHexString, 'call', _10 => _10()])
|
|
261
260
|
})
|
|
262
261
|
}
|
|
263
262
|
};
|
|
@@ -269,7 +268,7 @@ const submitSimpleTransfer$2 = ({ transaction, signer })=>{
|
|
|
269
268
|
})
|
|
270
269
|
};
|
|
271
270
|
|
|
272
|
-
function _optionalChain$
|
|
271
|
+
function _optionalChain$o(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
273
272
|
|
|
274
273
|
class WindowEthereum {
|
|
275
274
|
|
|
@@ -281,39 +280,39 @@ class WindowEthereum {
|
|
|
281
280
|
|
|
282
281
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
283
282
|
return (
|
|
284
|
-
_optionalChain$
|
|
283
|
+
_optionalChain$o([window, 'optionalAccess', _38 => _38.ethereum]) &&
|
|
285
284
|
// not MetaMask
|
|
286
|
-
!(_optionalChain$
|
|
285
|
+
!(_optionalChain$o([window, 'optionalAccess', _39 => _39.ethereum, 'optionalAccess', _40 => _40.isMetaMask]) && Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)(?!PocketUniverse)(?!RevokeCash)/)).length == 1) &&
|
|
287
286
|
// not Coin98
|
|
288
|
-
!_optionalChain$
|
|
287
|
+
!_optionalChain$o([window, 'optionalAccess', _41 => _41.coin98]) &&
|
|
289
288
|
// not Trust Wallet
|
|
290
|
-
!(_optionalChain$
|
|
289
|
+
!(_optionalChain$o([window, 'optionalAccess', _42 => _42.ethereum, 'optionalAccess', _43 => _43.isTrust]) || _optionalChain$o([window, 'optionalAccess', _44 => _44.ethereum, 'optionalAccess', _45 => _45.isTrustWallet])) &&
|
|
291
290
|
// not crypto.com
|
|
292
|
-
!_optionalChain$
|
|
291
|
+
!_optionalChain$o([window, 'optionalAccess', _46 => _46.ethereum, 'optionalAccess', _47 => _47.isDeficonnectProvider]) &&
|
|
293
292
|
// not HyperPay
|
|
294
|
-
!_optionalChain$
|
|
293
|
+
!_optionalChain$o([window, 'optionalAccess', _48 => _48.ethereum, 'optionalAccess', _49 => _49.isHyperPay]) &&
|
|
295
294
|
// not Phantom
|
|
296
|
-
!(window.phantom && !window.glow && !_optionalChain$
|
|
295
|
+
!(window.phantom && !window.glow && !_optionalChain$o([window, 'optionalAccess', _50 => _50.solana, 'optionalAccess', _51 => _51.isGlow]) && !['isBitKeep'].some((identifier)=>window.solana && window.solana[identifier])) &&
|
|
297
296
|
// not Rabby
|
|
298
|
-
!_optionalChain$
|
|
297
|
+
!_optionalChain$o([window, 'optionalAccess', _52 => _52.ethereum, 'optionalAccess', _53 => _53.isRabby]) &&
|
|
299
298
|
// not Backpack
|
|
300
|
-
!_optionalChain$
|
|
299
|
+
!_optionalChain$o([window, 'optionalAccess', _54 => _54.backpack, 'optionalAccess', _55 => _55.isBackpack]) &&
|
|
301
300
|
// not TokenPocket
|
|
302
|
-
!_optionalChain$
|
|
301
|
+
!_optionalChain$o([window, 'optionalAccess', _56 => _56.ethereum, 'optionalAccess', _57 => _57.isTokenPocket]) &&
|
|
303
302
|
// not BitKeep
|
|
304
|
-
!_optionalChain$
|
|
303
|
+
!_optionalChain$o([window, 'optionalAccess', _58 => _58.ethereum, 'optionalAccess', _59 => _59.isBitKeep]) &&
|
|
305
304
|
// not Coinbase
|
|
306
|
-
!(_optionalChain$
|
|
305
|
+
!(_optionalChain$o([window, 'optionalAccess', _60 => _60.ethereum, 'optionalAccess', _61 => _61.isCoinbaseWallet]) || _optionalChain$o([window, 'optionalAccess', _62 => _62.ethereum, 'optionalAccess', _63 => _63.isWalletLink])) &&
|
|
307
306
|
// MetaMask through ProviderMap
|
|
308
|
-
!_optionalChain$
|
|
307
|
+
!_optionalChain$o([window, 'optionalAccess', _64 => _64.ethereum, 'optionalAccess', _65 => _65.providerMap, 'optionalAccess', _66 => _66.has, 'call', _67 => _67('MetaMask')]) &&
|
|
309
308
|
// Brave Wallet
|
|
310
|
-
!_optionalChain$
|
|
309
|
+
!_optionalChain$o([window, 'optionalAccess', _68 => _68.ethereum, 'optionalAccess', _69 => _69.isBraveWallet]) &&
|
|
311
310
|
// Uniswap Wallet
|
|
312
|
-
!_optionalChain$
|
|
311
|
+
!_optionalChain$o([window, 'optionalAccess', _70 => _70.ethereum, 'optionalAccess', _71 => _71.isUniswapWallet]) &&
|
|
313
312
|
// Rainbow
|
|
314
|
-
!_optionalChain$
|
|
313
|
+
!_optionalChain$o([window, 'optionalAccess', _72 => _72.ethereum, 'optionalAccess', _73 => _73.isRainbow]) &&
|
|
315
314
|
// OKX Wallet
|
|
316
|
-
!_optionalChain$
|
|
315
|
+
!_optionalChain$o([window, 'optionalAccess', _74 => _74.okxwallet])
|
|
317
316
|
)
|
|
318
317
|
};}
|
|
319
318
|
|
|
@@ -426,9 +425,6 @@ class WindowEthereum {
|
|
|
426
425
|
if(typeof message === 'object') {
|
|
427
426
|
let provider = this.getProvider();
|
|
428
427
|
let account = await this.account();
|
|
429
|
-
if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
|
|
430
|
-
throw({ code: 'WRONG_NETWORK' })
|
|
431
|
-
}
|
|
432
428
|
let signature = await provider.request({
|
|
433
429
|
method: 'eth_signTypedData_v4',
|
|
434
430
|
params: [account, message],
|
|
@@ -445,7 +441,7 @@ class WindowEthereum {
|
|
|
445
441
|
}
|
|
446
442
|
} WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
|
|
447
443
|
|
|
448
|
-
function _optionalChain$
|
|
444
|
+
function _optionalChain$n(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
449
445
|
class Binance extends WindowEthereum {
|
|
450
446
|
|
|
451
447
|
static __initStatic() {this.info = {
|
|
@@ -455,7 +451,7 @@ class Binance extends WindowEthereum {
|
|
|
455
451
|
};}
|
|
456
452
|
|
|
457
453
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
458
|
-
return _optionalChain$
|
|
454
|
+
return _optionalChain$n([window, 'optionalAccess', _2 => _2.BinanceChain]) &&
|
|
459
455
|
!window.coin98 &&
|
|
460
456
|
!window.trustwallet
|
|
461
457
|
};}
|
|
@@ -475,7 +471,7 @@ var logos = {
|
|
|
475
471
|
okx: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI4LjIuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMzYuMSAzMzYuMSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMzM2LjEgMzM2LjE7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7ZmlsbDojRkZGRkZGO30KPC9zdHlsZT4KPHBhdGggZD0iTTMxMy43LDBIMjIuNEMxMCwwLDAsMTAsMCwyMi40djI5MS4zYzAsMTIuNCwxMCwyMi40LDIyLjQsMjIuNGgyOTEuM2MxMi40LDAsMjIuNC0xMCwyMi40LTIyLjRWMjIuNAoJQzMzNi4xLDEwLDMyNi4xLDAsMzEzLjcsMHoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTIwNC41LDEzMC43aC02NC43Yy0yLjcsMC01LDIuMi01LDV2NjQuN2MwLDIuNywyLjIsNSw1LDVoNjQuN2MyLjcsMCw1LTIuMiw1LTV2LTY0LjcKCUMyMDkuNSwxMzIuOSwyMDcuMiwxMzAuNywyMDQuNSwxMzAuN3oiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTEyOS44LDU2LjFINjUuMWMtMi43LDAtNSwyLjItNSw1djY0LjdjMCwyLjcsMi4yLDUsNSw1aDY0LjdjMi44LDAsNS0yLjIsNS01VjYxCglDMTM0LjgsNTguMywxMzIuNSw1Ni4xLDEyOS44LDU2LjF6Ii8+CjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik0yNzkuMSw1Ni4xaC02NC43Yy0yLjcsMC01LDIuMi01LDV2NjQuN2MwLDIuNywyLjIsNSw1LDVoNjQuN2MyLjcsMCw1LTIuMiw1LTVWNjEKCUMyODQuMSw1OC4zLDI4MS45LDU2LjEsMjc5LjEsNTYuMXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTEyOS44LDIwNS40SDY1LjFjLTIuNywwLTUsMi4yLTUsNXY2NC43YzAsMi43LDIuMiw1LDUsNWg2NC43YzIuOCwwLDUtMi4yLDUtNXYtNjQuNwoJQzEzNC44LDIwNy42LDEzMi41LDIwNS40LDEyOS44LDIwNS40eiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMjc5LjEsMjA1LjRoLTY0LjdjLTIuNywwLTUsMi4yLTUsNXY2NC43YzAsMi43LDIuMiw1LDUsNWg2NC43YzIuNywwLDUtMi4yLDUtNXYtNjQuNwoJQzI4NC4xLDIwNy42LDI4MS45LDIwNS40LDI3OS4xLDIwNS40eiIvPgo8L3N2Zz4K",
|
|
476
472
|
};
|
|
477
473
|
|
|
478
|
-
function _optionalChain$
|
|
474
|
+
function _optionalChain$m(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
479
475
|
class BraveEVM extends WindowEthereum {
|
|
480
476
|
|
|
481
477
|
static __initStatic() {this.info = {
|
|
@@ -485,14 +481,14 @@ class BraveEVM extends WindowEthereum {
|
|
|
485
481
|
platform: 'evm',
|
|
486
482
|
};}
|
|
487
483
|
|
|
488
|
-
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$
|
|
484
|
+
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$m([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isBraveWallet]) };}
|
|
489
485
|
|
|
490
486
|
getProvider() {
|
|
491
487
|
return window.ethereum
|
|
492
488
|
}
|
|
493
489
|
} BraveEVM.__initStatic(); BraveEVM.__initStatic2();
|
|
494
490
|
|
|
495
|
-
function _optionalChain$
|
|
491
|
+
function _optionalChain$l(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
496
492
|
class Coin98EVM extends WindowEthereum {
|
|
497
493
|
|
|
498
494
|
static __initStatic() {this.info = {
|
|
@@ -502,13 +498,13 @@ class Coin98EVM extends WindowEthereum {
|
|
|
502
498
|
platform: 'evm',
|
|
503
499
|
};}
|
|
504
500
|
|
|
505
|
-
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$
|
|
501
|
+
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$l([window, 'optionalAccess', _2 => _2.coin98]) };}
|
|
506
502
|
|
|
507
503
|
getProvider() { return window.coin98.provider }
|
|
508
504
|
|
|
509
505
|
} Coin98EVM.__initStatic(); Coin98EVM.__initStatic2();
|
|
510
506
|
|
|
511
|
-
function _optionalChain$
|
|
507
|
+
function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
512
508
|
class CoinbaseEVM extends WindowEthereum {
|
|
513
509
|
|
|
514
510
|
static __initStatic() {this.info = {
|
|
@@ -519,8 +515,8 @@ class CoinbaseEVM extends WindowEthereum {
|
|
|
519
515
|
};}
|
|
520
516
|
|
|
521
517
|
getProvider() {
|
|
522
|
-
if(_optionalChain$
|
|
523
|
-
return _optionalChain$
|
|
518
|
+
if(_optionalChain$k([window, 'optionalAccess', _9 => _9.ethereum, 'optionalAccess', _10 => _10.providerMap, 'optionalAccess', _11 => _11.has, 'call', _12 => _12('CoinbaseWallet')])) {
|
|
519
|
+
return _optionalChain$k([window, 'optionalAccess', _13 => _13.ethereum, 'optionalAccess', _14 => _14.providerMap, 'optionalAccess', _15 => _15.get, 'call', _16 => _16('CoinbaseWallet')])
|
|
524
520
|
} else {
|
|
525
521
|
return window.ethereum
|
|
526
522
|
}
|
|
@@ -529,15 +525,15 @@ class CoinbaseEVM extends WindowEthereum {
|
|
|
529
525
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
530
526
|
return(
|
|
531
527
|
(
|
|
532
|
-
_optionalChain$
|
|
528
|
+
_optionalChain$k([window, 'optionalAccess', _17 => _17.ethereum, 'optionalAccess', _18 => _18.isCoinbaseWallet]) || _optionalChain$k([window, 'optionalAccess', _19 => _19.ethereum, 'optionalAccess', _20 => _20.isWalletLink])
|
|
533
529
|
) || (
|
|
534
|
-
_optionalChain$
|
|
530
|
+
_optionalChain$k([window, 'optionalAccess', _21 => _21.ethereum, 'optionalAccess', _22 => _22.providerMap, 'optionalAccess', _23 => _23.has, 'call', _24 => _24('CoinbaseWallet')])
|
|
535
531
|
)
|
|
536
532
|
)
|
|
537
533
|
};}
|
|
538
534
|
} CoinbaseEVM.__initStatic(); CoinbaseEVM.__initStatic2();
|
|
539
535
|
|
|
540
|
-
function _optionalChain$
|
|
536
|
+
function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
541
537
|
class CryptoCom extends WindowEthereum {
|
|
542
538
|
|
|
543
539
|
static __initStatic() {this.info = {
|
|
@@ -546,10 +542,10 @@ class CryptoCom extends WindowEthereum {
|
|
|
546
542
|
blockchains: supported$1.evm
|
|
547
543
|
};}
|
|
548
544
|
|
|
549
|
-
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$
|
|
545
|
+
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$j([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isDeficonnectProvider]) };}
|
|
550
546
|
} CryptoCom.__initStatic(); CryptoCom.__initStatic2();
|
|
551
547
|
|
|
552
|
-
function _optionalChain$
|
|
548
|
+
function _optionalChain$i(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
553
549
|
class ExodusEVM extends WindowEthereum {
|
|
554
550
|
|
|
555
551
|
static __initStatic() {this.info = {
|
|
@@ -559,10 +555,10 @@ class ExodusEVM extends WindowEthereum {
|
|
|
559
555
|
platform: 'evm',
|
|
560
556
|
};}
|
|
561
557
|
|
|
562
|
-
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$
|
|
558
|
+
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$i([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isExodus]) };}
|
|
563
559
|
} ExodusEVM.__initStatic(); ExodusEVM.__initStatic2();
|
|
564
560
|
|
|
565
|
-
function _optionalChain$
|
|
561
|
+
function _optionalChain$h(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
566
562
|
class HyperPay extends WindowEthereum {
|
|
567
563
|
|
|
568
564
|
static __initStatic() {this.info = {
|
|
@@ -571,10 +567,10 @@ class HyperPay extends WindowEthereum {
|
|
|
571
567
|
blockchains: supported$1.evm
|
|
572
568
|
};}
|
|
573
569
|
|
|
574
|
-
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$
|
|
570
|
+
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$h([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isHyperPay]) };}
|
|
575
571
|
} HyperPay.__initStatic(); HyperPay.__initStatic2();
|
|
576
572
|
|
|
577
|
-
function _optionalChain$
|
|
573
|
+
function _optionalChain$g(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
578
574
|
class MagicEdenEVM extends WindowEthereum {
|
|
579
575
|
|
|
580
576
|
static __initStatic() {this.info = {
|
|
@@ -586,12 +582,12 @@ class MagicEdenEVM extends WindowEthereum {
|
|
|
586
582
|
|
|
587
583
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
588
584
|
return (
|
|
589
|
-
_optionalChain$
|
|
585
|
+
_optionalChain$g([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMagicEden])
|
|
590
586
|
)
|
|
591
587
|
};}
|
|
592
588
|
} MagicEdenEVM.__initStatic(); MagicEdenEVM.__initStatic2();
|
|
593
589
|
|
|
594
|
-
function _optionalChain$
|
|
590
|
+
function _optionalChain$f(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
595
591
|
class MetaMask extends WindowEthereum {
|
|
596
592
|
|
|
597
593
|
static __initStatic() {this.info = {
|
|
@@ -602,7 +598,7 @@ class MetaMask extends WindowEthereum {
|
|
|
602
598
|
|
|
603
599
|
static __initStatic2() {this.isMetaMask = (provider)=> {
|
|
604
600
|
return(
|
|
605
|
-
_optionalChain$
|
|
601
|
+
_optionalChain$f([provider, 'optionalAccess', _3 => _3.isMetaMask]) &&
|
|
606
602
|
Object.keys(provider).filter((key)=>key.match(/^is(?!Connected)(?!PocketUniverse)(?!WalletGuard)(?!RevokeCash)/)).length == 1
|
|
607
603
|
)
|
|
608
604
|
};}
|
|
@@ -616,16 +612,16 @@ class MetaMask extends WindowEthereum {
|
|
|
616
612
|
static __initStatic4() {this.isAvailable = async()=>{
|
|
617
613
|
return(
|
|
618
614
|
MetaMask.getEip6963Provider() ||
|
|
619
|
-
MetaMask.isMetaMask(_optionalChain$
|
|
615
|
+
MetaMask.isMetaMask(_optionalChain$f([window, 'optionalAccess', _4 => _4.ethereum]))
|
|
620
616
|
)
|
|
621
617
|
};}
|
|
622
618
|
|
|
623
619
|
getProvider() {
|
|
624
|
-
return MetaMask.getEip6963Provider() || (MetaMask.isMetaMask(_optionalChain$
|
|
620
|
+
return MetaMask.getEip6963Provider() || (MetaMask.isMetaMask(_optionalChain$f([window, 'optionalAccess', _5 => _5.ethereum])) && _optionalChain$f([window, 'optionalAccess', _6 => _6.ethereum]))
|
|
625
621
|
}
|
|
626
622
|
} MetaMask.__initStatic(); MetaMask.__initStatic2(); MetaMask.__initStatic3(); MetaMask.__initStatic4();
|
|
627
623
|
|
|
628
|
-
function _optionalChain$
|
|
624
|
+
function _optionalChain$e(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
629
625
|
class OKXEVM extends WindowEthereum {
|
|
630
626
|
|
|
631
627
|
static __initStatic() {this.info = {
|
|
@@ -637,12 +633,12 @@ class OKXEVM extends WindowEthereum {
|
|
|
637
633
|
|
|
638
634
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
639
635
|
return (
|
|
640
|
-
_optionalChain$
|
|
636
|
+
_optionalChain$e([window, 'optionalAccess', _2 => _2.okxwallet])
|
|
641
637
|
)
|
|
642
638
|
};}
|
|
643
639
|
} OKXEVM.__initStatic(); OKXEVM.__initStatic2();
|
|
644
640
|
|
|
645
|
-
function _optionalChain$
|
|
641
|
+
function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
646
642
|
class Opera extends WindowEthereum {
|
|
647
643
|
|
|
648
644
|
static __initStatic() {this.info = {
|
|
@@ -651,10 +647,10 @@ class Opera extends WindowEthereum {
|
|
|
651
647
|
blockchains: supported$1.evm
|
|
652
648
|
};}
|
|
653
649
|
|
|
654
|
-
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$
|
|
650
|
+
static __initStatic2() {this.isAvailable = async()=>{ return _optionalChain$d([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isOpera]) };}
|
|
655
651
|
} Opera.__initStatic(); Opera.__initStatic2();
|
|
656
652
|
|
|
657
|
-
function _optionalChain$
|
|
653
|
+
function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
658
654
|
class PhantomEVM extends WindowEthereum {
|
|
659
655
|
|
|
660
656
|
static __initStatic() {this.info = {
|
|
@@ -668,17 +664,17 @@ class PhantomEVM extends WindowEthereum {
|
|
|
668
664
|
return (
|
|
669
665
|
window.phantom &&
|
|
670
666
|
window.phantom.ethereum &&
|
|
671
|
-
! _optionalChain$
|
|
672
|
-
! _optionalChain$
|
|
667
|
+
! _optionalChain$c([window, 'optionalAccess', _4 => _4.ethereum, 'optionalAccess', _5 => _5.isMagicEden]) &&
|
|
668
|
+
! _optionalChain$c([window, 'optionalAccess', _6 => _6.okxwallet])
|
|
673
669
|
)
|
|
674
670
|
};}
|
|
675
671
|
|
|
676
672
|
getProvider() {
|
|
677
|
-
return _optionalChain$
|
|
673
|
+
return _optionalChain$c([window, 'optionalAccess', _7 => _7.phantom, 'optionalAccess', _8 => _8.ethereum]) || window.ethereum
|
|
678
674
|
}
|
|
679
675
|
} PhantomEVM.__initStatic(); PhantomEVM.__initStatic2();
|
|
680
676
|
|
|
681
|
-
function _optionalChain$
|
|
677
|
+
function _optionalChain$b(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
682
678
|
class Rabby extends WindowEthereum {
|
|
683
679
|
|
|
684
680
|
static __initStatic() {this.info = {
|
|
@@ -689,12 +685,12 @@ class Rabby extends WindowEthereum {
|
|
|
689
685
|
|
|
690
686
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
691
687
|
return(
|
|
692
|
-
_optionalChain$
|
|
688
|
+
_optionalChain$b([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isRabby])
|
|
693
689
|
)
|
|
694
690
|
};}
|
|
695
691
|
} Rabby.__initStatic(); Rabby.__initStatic2();
|
|
696
692
|
|
|
697
|
-
function _optionalChain$
|
|
693
|
+
function _optionalChain$a(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
698
694
|
class Rainbow extends WindowEthereum {
|
|
699
695
|
|
|
700
696
|
static __initStatic() {this.info = {
|
|
@@ -705,24 +701,24 @@ class Rainbow extends WindowEthereum {
|
|
|
705
701
|
|
|
706
702
|
static __initStatic2() {this.getEip6963Provider = ()=>{
|
|
707
703
|
return window['_eip6963Providers'] ? Object.values(window['_eip6963Providers']).find((provider)=>{
|
|
708
|
-
return _optionalChain$
|
|
704
|
+
return _optionalChain$a([provider, 'optionalAccess', _4 => _4.isRainbow])
|
|
709
705
|
}) : undefined
|
|
710
706
|
};}
|
|
711
707
|
|
|
712
708
|
static __initStatic3() {this.isAvailable = async()=>{
|
|
713
709
|
return(
|
|
714
710
|
Rainbow.getEip6963Provider() ||
|
|
715
|
-
_optionalChain$
|
|
711
|
+
_optionalChain$a([window, 'optionalAccess', _5 => _5.rainbow, 'optionalAccess', _6 => _6.isRainbow])
|
|
716
712
|
)
|
|
717
713
|
};}
|
|
718
714
|
|
|
719
715
|
getProvider() {
|
|
720
|
-
return Rainbow.getEip6963Provider() || _optionalChain$
|
|
716
|
+
return Rainbow.getEip6963Provider() || _optionalChain$a([window, 'optionalAccess', _7 => _7.rainbow])
|
|
721
717
|
}
|
|
722
718
|
|
|
723
719
|
} Rainbow.__initStatic(); Rainbow.__initStatic2(); Rainbow.__initStatic3();
|
|
724
720
|
|
|
725
|
-
function _optionalChain$
|
|
721
|
+
function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
726
722
|
class TokenPocket extends WindowEthereum {
|
|
727
723
|
|
|
728
724
|
static __initStatic() {this.info = {
|
|
@@ -733,12 +729,12 @@ class TokenPocket extends WindowEthereum {
|
|
|
733
729
|
|
|
734
730
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
735
731
|
return (
|
|
736
|
-
_optionalChain$
|
|
732
|
+
_optionalChain$9([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isTokenPocket])
|
|
737
733
|
)
|
|
738
734
|
};}
|
|
739
735
|
} TokenPocket.__initStatic(); TokenPocket.__initStatic2();
|
|
740
736
|
|
|
741
|
-
function _optionalChain$
|
|
737
|
+
function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
742
738
|
class TrustEVM extends WindowEthereum {
|
|
743
739
|
|
|
744
740
|
static __initStatic() {this.info = {
|
|
@@ -750,13 +746,13 @@ class TrustEVM extends WindowEthereum {
|
|
|
750
746
|
|
|
751
747
|
static __initStatic2() {this.isAvailable = async()=>{
|
|
752
748
|
return (
|
|
753
|
-
(_optionalChain$
|
|
749
|
+
(_optionalChain$8([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isTrust]) || _optionalChain$8([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isTrustWallet])) &&
|
|
754
750
|
Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)(?!Debug)(?!TrustWallet)(?!MetaMask)(?!PocketUniverse)(?!RevokeCash)/)).length == 1
|
|
755
751
|
)
|
|
756
752
|
};}
|
|
757
753
|
} TrustEVM.__initStatic(); TrustEVM.__initStatic2();
|
|
758
754
|
|
|
759
|
-
function _optionalChain$
|
|
755
|
+
function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
760
756
|
class Uniswap extends WindowEthereum {
|
|
761
757
|
|
|
762
758
|
static __initStatic() {this.info = {
|
|
@@ -767,19 +763,19 @@ class Uniswap extends WindowEthereum {
|
|
|
767
763
|
|
|
768
764
|
static __initStatic2() {this.getEip6963Provider = ()=>{
|
|
769
765
|
return window['_eip6963Providers'] ? Object.values(window['_eip6963Providers']).find((provider)=>{
|
|
770
|
-
return _optionalChain$
|
|
766
|
+
return _optionalChain$7([provider, 'optionalAccess', _4 => _4.isUniswapWallet])
|
|
771
767
|
}) : undefined
|
|
772
768
|
};}
|
|
773
769
|
|
|
774
770
|
static __initStatic3() {this.isAvailable = async()=>{
|
|
775
771
|
return(
|
|
776
772
|
Uniswap.getEip6963Provider() ||
|
|
777
|
-
_optionalChain$
|
|
773
|
+
_optionalChain$7([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isUniswapWallet])
|
|
778
774
|
)
|
|
779
775
|
};}
|
|
780
776
|
|
|
781
777
|
getProvider() {
|
|
782
|
-
return Uniswap.getEip6963Provider() || (_optionalChain$
|
|
778
|
+
return Uniswap.getEip6963Provider() || (_optionalChain$7([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isUniswapWallet]) && _optionalChain$7([window, 'optionalAccess', _9 => _9.ethereum]))
|
|
783
779
|
}
|
|
784
780
|
} Uniswap.__initStatic(); Uniswap.__initStatic2(); Uniswap.__initStatic3();
|
|
785
781
|
|
|
@@ -884,7 +880,7 @@ const getSmartContractWallet = async(blockchain, address)=> {
|
|
|
884
880
|
}
|
|
885
881
|
};
|
|
886
882
|
|
|
887
|
-
function _optionalChain$
|
|
883
|
+
function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
888
884
|
|
|
889
885
|
const sendTransaction$1 = async ({ transaction, wallet })=> {
|
|
890
886
|
transaction = new Transaction(transaction);
|
|
@@ -935,7 +931,7 @@ const retrieveConfirmedTransaction$1 = (sentTransaction)=>{
|
|
|
935
931
|
try {
|
|
936
932
|
sentTransaction.wait(1).then(resolve).catch((error)=>{
|
|
937
933
|
if(
|
|
938
|
-
(error && _optionalChain$
|
|
934
|
+
(error && _optionalChain$6([error, 'optionalAccess', _ => _.stack, 'optionalAccess', _2 => _2.match, 'call', _3 => _3('JSON-RPC error')])) ||
|
|
939
935
|
(error && error.toString().match('undefined'))
|
|
940
936
|
) {
|
|
941
937
|
setTimeout(()=>{
|
|
@@ -949,7 +945,7 @@ const retrieveConfirmedTransaction$1 = (sentTransaction)=>{
|
|
|
949
945
|
});
|
|
950
946
|
} catch (error) {
|
|
951
947
|
if(
|
|
952
|
-
(error && _optionalChain$
|
|
948
|
+
(error && _optionalChain$6([error, 'optionalAccess', _4 => _4.stack, 'optionalAccess', _5 => _5.match, 'call', _6 => _6('JSON-RPC error')])) ||
|
|
953
949
|
(error && error.toString().match('undefined'))
|
|
954
950
|
) {
|
|
955
951
|
setTimeout(()=>{
|
|
@@ -980,7 +976,7 @@ const retrieveTransaction = (tx, blockchain)=>{
|
|
|
980
976
|
resolve(sentTransaction);
|
|
981
977
|
} catch (error) {
|
|
982
978
|
if(
|
|
983
|
-
(error && _optionalChain$
|
|
979
|
+
(error && _optionalChain$6([error, 'optionalAccess', _7 => _7.stack, 'optionalAccess', _8 => _8.match, 'call', _9 => _9('JSON-RPC error')])) ||
|
|
984
980
|
(error && error.toString().match('undefined'))
|
|
985
981
|
) {
|
|
986
982
|
setTimeout(()=>{
|
|
@@ -1022,8 +1018,8 @@ const submitContractInteraction$1 = async ({ transaction, wallet })=>{
|
|
|
1022
1018
|
to: transaction.to,
|
|
1023
1019
|
value: transaction.value ? ethers.BigNumber.from(transaction.value.toString()).toHexString() : undefined,
|
|
1024
1020
|
data: await transaction.getData(),
|
|
1025
|
-
gas: _optionalChain$
|
|
1026
|
-
gasLimit: _optionalChain$
|
|
1021
|
+
gas: _optionalChain$6([gas, 'optionalAccess', _10 => _10.toHexString, 'call', _11 => _11()]),
|
|
1022
|
+
gasLimit: _optionalChain$6([gas, 'optionalAccess', _12 => _12.toHexString, 'call', _13 => _13()]),
|
|
1027
1023
|
gasPrice: gasPrice.toHexString(),
|
|
1028
1024
|
nonce: ethers.utils.hexlify(transaction.nonce),
|
|
1029
1025
|
}]
|
|
@@ -1050,16 +1046,16 @@ const submitSimpleTransfer$1 = async ({ transaction, wallet })=>{
|
|
|
1050
1046
|
to: transaction.to,
|
|
1051
1047
|
value: transaction.value ? ethers.BigNumber.from(transaction.value.toString()).toHexString() : undefined,
|
|
1052
1048
|
data: '0x0',
|
|
1053
|
-
gas: _optionalChain$
|
|
1054
|
-
gasLimit: _optionalChain$
|
|
1055
|
-
gasPrice: _optionalChain$
|
|
1049
|
+
gas: _optionalChain$6([gas, 'optionalAccess', _14 => _14.toHexString, 'call', _15 => _15()]),
|
|
1050
|
+
gasLimit: _optionalChain$6([gas, 'optionalAccess', _16 => _16.toHexString, 'call', _17 => _17()]),
|
|
1051
|
+
gasPrice: _optionalChain$6([gasPrice, 'optionalAccess', _18 => _18.toHexString, 'call', _19 => _19()]),
|
|
1056
1052
|
nonce: ethers.utils.hexlify(transaction.nonce)
|
|
1057
1053
|
}]
|
|
1058
1054
|
}
|
|
1059
1055
|
}).catch((e)=>{console.log('ERROR', e);})
|
|
1060
1056
|
};
|
|
1061
1057
|
|
|
1062
|
-
function _optionalChain$
|
|
1058
|
+
function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1063
1059
|
|
|
1064
1060
|
const KEY = 'depay:wallets:wc2';
|
|
1065
1061
|
|
|
@@ -1112,7 +1108,7 @@ const getWalletConnectV2Config = (walletName)=>{
|
|
|
1112
1108
|
optionalNamespaces['eip155'] = {
|
|
1113
1109
|
chains: supported$1.evm.map((blockchain)=>`${Blockchains[blockchain].namespace}:${Blockchains[blockchain].networkId}`),
|
|
1114
1110
|
};
|
|
1115
|
-
if(_optionalChain$
|
|
1111
|
+
if(_optionalChain$5([optionalNamespaces, 'optionalAccess', _ => _.eip155]) && _optionalChain$5([optionalNamespaces, 'optionalAccess', _2 => _2.eip155, 'optionalAccess', _3 => _3.chains, 'optionalAccess', _4 => _4.length])) {
|
|
1116
1112
|
optionalNamespaces['eip155'].methods = methods;
|
|
1117
1113
|
optionalNamespaces['eip155'].events = events;
|
|
1118
1114
|
}
|
|
@@ -1127,9 +1123,9 @@ const getSignClient = ()=>{
|
|
|
1127
1123
|
projectId: localStorage[KEY+":projectId"],
|
|
1128
1124
|
metadata: {
|
|
1129
1125
|
name: document.title || 'dApp',
|
|
1130
|
-
description: _optionalChain$
|
|
1126
|
+
description: _optionalChain$5([document, 'access', _5 => _5.querySelector, 'call', _6 => _6('meta[name="description"]'), 'optionalAccess', _7 => _7.getAttribute, 'call', _8 => _8('content')]) || document.title || 'dApp',
|
|
1131
1127
|
url: location.href,
|
|
1132
|
-
icons: [_optionalChain$
|
|
1128
|
+
icons: [_optionalChain$5([document, 'access', _9 => _9.querySelector, 'call', _10 => _10("link[rel~='icon'], link[rel~='shortcut icon']"), 'optionalAccess', _11 => _11.href]) || `${location.origin}/favicon.ico`]
|
|
1133
1129
|
}
|
|
1134
1130
|
});
|
|
1135
1131
|
resolve(signClient);
|
|
@@ -1147,7 +1143,7 @@ class WalletConnectV2 {
|
|
|
1147
1143
|
};}
|
|
1148
1144
|
|
|
1149
1145
|
static __initStatic2() {this.isAvailable = async(options)=>{
|
|
1150
|
-
return !! await getLastSession(_optionalChain$
|
|
1146
|
+
return !! await getLastSession(_optionalChain$5([options, 'optionalAccess', _13 => _13.walletName]))
|
|
1151
1147
|
};}
|
|
1152
1148
|
|
|
1153
1149
|
constructor() {
|
|
@@ -1162,17 +1158,17 @@ class WalletConnectV2 {
|
|
|
1162
1158
|
}
|
|
1163
1159
|
|
|
1164
1160
|
async account() {
|
|
1165
|
-
if(_optionalChain$
|
|
1161
|
+
if(_optionalChain$5([this, 'access', _14 => _14.session, 'optionalAccess', _15 => _15.namespaces, 'optionalAccess', _16 => _16.eip155, 'optionalAccess', _17 => _17.accounts, 'optionalAccess', _18 => _18.length])) {
|
|
1166
1162
|
return this.session.namespaces.eip155.accounts[0].split(':')[2]
|
|
1167
1163
|
}
|
|
1168
1164
|
}
|
|
1169
1165
|
|
|
1170
1166
|
async setSessionBlockchains() {
|
|
1171
|
-
if(!this.session || (!_optionalChain$
|
|
1167
|
+
if(!this.session || (!_optionalChain$5([this, 'access', _19 => _19.session, 'optionalAccess', _20 => _20.namespaces, 'optionalAccess', _21 => _21.eip155]) && !_optionalChain$5([this, 'access', _22 => _22.session, 'optionalAccess', _23 => _23.optionalNamespaces, 'optionalAccess', _24 => _24.eip155]))) { return }
|
|
1172
1168
|
if(this.session.namespaces.eip155.chains) {
|
|
1173
|
-
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$
|
|
1169
|
+
this.blockchains = this.session.namespaces.eip155.chains.map((chainIdentifier)=>_optionalChain$5([Blockchains, 'access', _25 => _25.findByNetworkId, 'call', _26 => _26(chainIdentifier.split(':')[1]), 'optionalAccess', _27 => _27.name])).filter(Boolean);
|
|
1174
1170
|
} else if(this.session.namespaces.eip155.accounts) {
|
|
1175
|
-
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$
|
|
1171
|
+
this.blockchains = this.session.namespaces.eip155.accounts.map((accountIdentifier)=>_optionalChain$5([Blockchains, 'access', _28 => _28.findByNetworkId, 'call', _29 => _29(accountIdentifier.split(':')[1]), 'optionalAccess', _30 => _30.name])).filter(Boolean);
|
|
1176
1172
|
}
|
|
1177
1173
|
}
|
|
1178
1174
|
|
|
@@ -1182,13 +1178,13 @@ class WalletConnectV2 {
|
|
|
1182
1178
|
|
|
1183
1179
|
try {
|
|
1184
1180
|
|
|
1185
|
-
this.walletName = _optionalChain$
|
|
1181
|
+
this.walletName = _optionalChain$5([options, 'optionalAccess', _31 => _31.name]);
|
|
1186
1182
|
|
|
1187
1183
|
// delete localStorage[`wc@2:client:0.3//session`] // DELETE WC SESSIONS
|
|
1188
1184
|
this.signClient = await getSignClient();
|
|
1189
1185
|
|
|
1190
1186
|
this.signClient.on("session_delete", (session)=> {
|
|
1191
|
-
if(_optionalChain$
|
|
1187
|
+
if(_optionalChain$5([session, 'optionalAccess', _32 => _32.topic]) === _optionalChain$5([this, 'access', _33 => _33.session, 'optionalAccess', _34 => _34.topic])) {
|
|
1192
1188
|
localStorage[KEY+':name'] = undefined;
|
|
1193
1189
|
localStorage[KEY+':logo'] = undefined;
|
|
1194
1190
|
this.signClient = undefined;
|
|
@@ -1197,14 +1193,14 @@ class WalletConnectV2 {
|
|
|
1197
1193
|
});
|
|
1198
1194
|
|
|
1199
1195
|
this.signClient.on("session_update", async(session)=> {
|
|
1200
|
-
if(_optionalChain$
|
|
1196
|
+
if(_optionalChain$5([session, 'optionalAccess', _35 => _35.topic]) === _optionalChain$5([this, 'access', _36 => _36.session, 'optionalAccess', _37 => _37.topic])) {
|
|
1201
1197
|
this.session = this.signClient.session.get(session.topic);
|
|
1202
1198
|
await this.setSessionBlockchains();
|
|
1203
1199
|
}
|
|
1204
1200
|
});
|
|
1205
1201
|
|
|
1206
1202
|
this.signClient.on("session_event", (event)=> {
|
|
1207
|
-
if(_optionalChain$
|
|
1203
|
+
if(_optionalChain$5([event, 'optionalAccess', _38 => _38.topic]) === _optionalChain$5([this, 'access', _39 => _39.session, 'optionalAccess', _40 => _40.topic])) {}
|
|
1208
1204
|
});
|
|
1209
1205
|
|
|
1210
1206
|
const connectWallet = async()=>{
|
|
@@ -1215,24 +1211,24 @@ class WalletConnectV2 {
|
|
|
1215
1211
|
await new Promise(resolve=>setTimeout(resolve, 500)); // to prevent race condition within WalletConnect
|
|
1216
1212
|
};
|
|
1217
1213
|
|
|
1218
|
-
const lastSession = _optionalChain$
|
|
1214
|
+
const lastSession = _optionalChain$5([this, 'optionalAccess', _41 => _41.walletName, 'optionalAccess', _42 => _42.length]) ? await getLastSession(this.walletName) : undefined;
|
|
1219
1215
|
if(lastSession) {
|
|
1220
1216
|
this.session = lastSession;
|
|
1221
1217
|
} else {
|
|
1222
1218
|
await connectWallet();
|
|
1223
1219
|
}
|
|
1224
1220
|
|
|
1225
|
-
let meta = _optionalChain$
|
|
1221
|
+
let meta = _optionalChain$5([this, 'access', _43 => _43.session, 'optionalAccess', _44 => _44.peer, 'optionalAccess', _45 => _45.metadata]);
|
|
1226
1222
|
if(meta && meta.name) {
|
|
1227
1223
|
this.name = meta.name;
|
|
1228
1224
|
localStorage[KEY+':name'] = meta.name;
|
|
1229
|
-
if(_optionalChain$
|
|
1225
|
+
if(_optionalChain$5([meta, 'optionalAccess', _46 => _46.icons]) && meta.icons.length) {
|
|
1230
1226
|
this.logo = meta.icons[0];
|
|
1231
1227
|
localStorage[KEY+':logo'] = this.logo;
|
|
1232
1228
|
}
|
|
1233
1229
|
}
|
|
1234
|
-
if(_optionalChain$
|
|
1235
|
-
if(_optionalChain$
|
|
1230
|
+
if(_optionalChain$5([options, 'optionalAccess', _47 => _47.name])) { localStorage[KEY+':name'] = this.name = options.name; }
|
|
1231
|
+
if(_optionalChain$5([options, 'optionalAccess', _48 => _48.logo])) { localStorage[KEY+':logo'] = this.logo = options.logo; }
|
|
1236
1232
|
|
|
1237
1233
|
await this.setSessionBlockchains();
|
|
1238
1234
|
|
|
@@ -1272,7 +1268,7 @@ class WalletConnectV2 {
|
|
|
1272
1268
|
switch (event) {
|
|
1273
1269
|
case 'account':
|
|
1274
1270
|
internalCallback = async(event)=> {
|
|
1275
|
-
if(_optionalChain$
|
|
1271
|
+
if(_optionalChain$5([event, 'optionalAccess', _49 => _49.topic]) === _optionalChain$5([this, 'access', _50 => _50.session, 'optionalAccess', _51 => _51.topic]) && event.params.event.name === 'accountsChanged') {
|
|
1276
1272
|
callback(await this.account());
|
|
1277
1273
|
}
|
|
1278
1274
|
};
|
|
@@ -1332,7 +1328,7 @@ class WalletConnectV2 {
|
|
|
1332
1328
|
|
|
1333
1329
|
WalletConnectV2.getConnectedInstance = getConnectedInstance$1;
|
|
1334
1330
|
|
|
1335
|
-
function _optionalChain$
|
|
1331
|
+
function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1336
1332
|
const sendTransaction = async ({ transaction, wallet })=> {
|
|
1337
1333
|
transaction = new Transaction(transaction);
|
|
1338
1334
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
@@ -1384,7 +1380,7 @@ const retrieveConfirmedTransaction = (sentTransaction)=>{
|
|
|
1384
1380
|
|
|
1385
1381
|
sentTransaction.wait(1).then(resolve).catch((error)=>{
|
|
1386
1382
|
if(
|
|
1387
|
-
(error && _optionalChain$
|
|
1383
|
+
(error && _optionalChain$4([error, 'optionalAccess', _ => _.stack, 'optionalAccess', _2 => _2.match, 'call', _3 => _3('JSON-RPC error')])) ||
|
|
1388
1384
|
(error && error.toString().match('undefined'))
|
|
1389
1385
|
) {
|
|
1390
1386
|
setTimeout(()=>{
|
|
@@ -1398,7 +1394,7 @@ const retrieveConfirmedTransaction = (sentTransaction)=>{
|
|
|
1398
1394
|
});
|
|
1399
1395
|
} catch(error) {
|
|
1400
1396
|
if(
|
|
1401
|
-
(error && _optionalChain$
|
|
1397
|
+
(error && _optionalChain$4([error, 'optionalAccess', _4 => _4.stack, 'optionalAccess', _5 => _5.match, 'call', _6 => _6('JSON-RPC error')])) ||
|
|
1402
1398
|
(error && error.toString().match('undefined'))
|
|
1403
1399
|
) {
|
|
1404
1400
|
setTimeout(()=>{
|
|
@@ -1443,7 +1439,7 @@ const submitSimpleTransfer = ({ transaction, signer })=>{
|
|
|
1443
1439
|
})
|
|
1444
1440
|
};
|
|
1445
1441
|
|
|
1446
|
-
function _optionalChain$
|
|
1442
|
+
function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1447
1443
|
|
|
1448
1444
|
const getConnectedInstance = ()=>{
|
|
1449
1445
|
return window._connectedWalletLinkInstance
|
|
@@ -1497,10 +1493,10 @@ class WalletLink {
|
|
|
1497
1493
|
let connect = (options && options.connect) ? options.connect : ({uri})=>{};
|
|
1498
1494
|
await connect({ uri: this.connector.qrUrl });
|
|
1499
1495
|
|
|
1500
|
-
_optionalChain$
|
|
1501
|
-
_optionalChain$
|
|
1496
|
+
_optionalChain$3([document, 'access', _ => _.querySelector, 'call', _2 => _2('.-cbwsdk-css-reset'), 'optionalAccess', _3 => _3.setAttribute, 'call', _4 => _4('style', 'display: none;')]);
|
|
1497
|
+
_optionalChain$3([document, 'access', _5 => _5.querySelector, 'call', _6 => _6('.-cbwsdk-extension-dialog-container'), 'optionalAccess', _7 => _7.setAttribute, 'call', _8 => _8('style', 'display: none;')]);
|
|
1502
1498
|
setTimeout(()=>{
|
|
1503
|
-
if(_optionalChain$
|
|
1499
|
+
if(_optionalChain$3([this, 'optionalAccess', _9 => _9.connector, 'optionalAccess', _10 => _10._relay, 'optionalAccess', _11 => _11.ui, 'optionalAccess', _12 => _12.linkFlow, 'optionalAccess', _13 => _13.isOpen])){
|
|
1504
1500
|
this.connector._relay.ui.linkFlow.isOpen = false;
|
|
1505
1501
|
}
|
|
1506
1502
|
}, 10);
|
|
@@ -1602,9 +1598,6 @@ class WalletLink {
|
|
|
1602
1598
|
if(typeof message === 'object') {
|
|
1603
1599
|
let provider = this.connector;
|
|
1604
1600
|
let account = await this.account();
|
|
1605
|
-
if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
|
|
1606
|
-
throw({ code: 'WRONG_NETWORK' })
|
|
1607
|
-
}
|
|
1608
1601
|
let signature = await provider.request({
|
|
1609
1602
|
method: 'eth_signTypedData_v4',
|
|
1610
1603
|
params: [account, message],
|
|
@@ -1624,17 +1617,363 @@ class WalletLink {
|
|
|
1624
1617
|
WalletLink.getConnectedInstance = getConnectedInstance;
|
|
1625
1618
|
WalletLink.setConnectedInstance = setConnectedInstance;
|
|
1626
1619
|
|
|
1620
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// https://github.com/worldcoin/minikit-js/blob/main/packages/core/helpers/siwe/siwe.ts
|
|
1621
|
+
const generateSiweMessage = (siweMessageData) => {
|
|
1622
|
+
let siweMessage = '';
|
|
1623
|
+
|
|
1624
|
+
if (siweMessageData.scheme) {
|
|
1625
|
+
siweMessage += `${siweMessageData.scheme}://${siweMessageData.domain} wants you to sign in with your Ethereum account:\n`;
|
|
1626
|
+
} else {
|
|
1627
|
+
siweMessage += `${siweMessageData.domain} wants you to sign in with your Ethereum account:\n`;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// NOTE: This differs from the ERC-4361 spec where the address is required
|
|
1631
|
+
if (siweMessageData.address) {
|
|
1632
|
+
siweMessage += `${siweMessageData.address}\n`;
|
|
1633
|
+
} else {
|
|
1634
|
+
siweMessage += '{address}\n';
|
|
1635
|
+
}
|
|
1636
|
+
siweMessage += '\n';
|
|
1637
|
+
|
|
1638
|
+
if (siweMessageData.statement) {
|
|
1639
|
+
siweMessage += `${siweMessageData.statement}\n`;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
siweMessage += '\n';
|
|
1643
|
+
|
|
1644
|
+
siweMessage += `URI: ${siweMessageData.uri}\n`;
|
|
1645
|
+
siweMessage += `Version: ${siweMessageData.version}\n`;
|
|
1646
|
+
siweMessage += `Chain ID: ${siweMessageData.chain_id}\n`;
|
|
1647
|
+
siweMessage += `Nonce: ${siweMessageData.nonce}\n`;
|
|
1648
|
+
siweMessage += `Issued At: ${siweMessageData.issued_at}\n`;
|
|
1649
|
+
|
|
1650
|
+
if (siweMessageData.expiration_time) {
|
|
1651
|
+
siweMessage += `Expiration Time: ${siweMessageData.expiration_time}\n`;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
if (siweMessageData.not_before) {
|
|
1655
|
+
siweMessage += `Not Before: ${siweMessageData.not_before}\n`;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
if (siweMessageData.request_id) {
|
|
1659
|
+
siweMessage += `Request ID: ${siweMessageData.request_id}\n`;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
return siweMessage
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1665
|
+
// https://github.com/worldcoin/minikit-js/blob/main/packages/core/helpers/transaction/validate-payload.ts
|
|
1666
|
+
const isValidHex = (str) => {
|
|
1667
|
+
return /^0x[0-9A-Fa-f]+$/.test(str)
|
|
1668
|
+
};
|
|
1669
|
+
const processTransactionPayload = (payload) => {
|
|
1670
|
+
// Handle primitives directly
|
|
1671
|
+
if (
|
|
1672
|
+
typeof payload === 'boolean' ||
|
|
1673
|
+
typeof payload === 'string' ||
|
|
1674
|
+
payload === null ||
|
|
1675
|
+
payload === undefined
|
|
1676
|
+
) {
|
|
1677
|
+
return payload
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
// Convert numbers to strings to prevent overflow issues
|
|
1681
|
+
if (typeof payload === 'number' || typeof payload === 'bigint') {
|
|
1682
|
+
return String(payload)
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
// Handle arrays by processing each element
|
|
1686
|
+
if (Array.isArray(payload)) {
|
|
1687
|
+
return payload.map((value) => processTransactionPayload(value))
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
// Handle objects
|
|
1691
|
+
if (typeof payload === 'object') {
|
|
1692
|
+
const result = { ...payload };
|
|
1693
|
+
|
|
1694
|
+
// Special handling for transaction value fields
|
|
1695
|
+
if ('value' in result && result.value !== undefined) {
|
|
1696
|
+
// Ensure it's a string
|
|
1697
|
+
if (typeof result.value !== 'string') {
|
|
1698
|
+
result.value = String(result.value);
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
if (!isValidHex(result.value)) {
|
|
1702
|
+
console.error(
|
|
1703
|
+
'Transaction value must be a valid hex string',
|
|
1704
|
+
result.value,
|
|
1705
|
+
);
|
|
1706
|
+
throw new Error(
|
|
1707
|
+
`Transaction value must be a valid hex string: ${result.value}`,
|
|
1708
|
+
)
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
// Process all object properties recursively
|
|
1713
|
+
for (const key in result) {
|
|
1714
|
+
if (Object.prototype.hasOwnProperty.call(result, key)) {
|
|
1715
|
+
result[key] = processTransactionPayload(result[key]);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
return result
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// Fallback for any other types
|
|
1723
|
+
return payload
|
|
1724
|
+
};
|
|
1725
|
+
|
|
1726
|
+
// https://github.com/worldcoin/minikit-js/blob/main/packages/core/helpers/send-webview-event.ts
|
|
1727
|
+
const sendMiniKitEvent = function(payload) {
|
|
1728
|
+
if (window.webkit) {
|
|
1729
|
+
if (
|
|
1730
|
+
window.webkit.messageHandlers &&
|
|
1731
|
+
window.webkit.messageHandlers.minikit &&
|
|
1732
|
+
window.webkit.messageHandlers.minikit.postMessage
|
|
1733
|
+
) {
|
|
1734
|
+
window.webkit.messageHandlers.minikit.postMessage(payload);
|
|
1735
|
+
}
|
|
1736
|
+
} else if (window.Android && window.Android.postMessage) {
|
|
1737
|
+
window.Android.postMessage(JSON.stringify(payload));
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
// https://github.com/worldcoin/minikit-js/blob/main/packages/core/types/commands.ts
|
|
1742
|
+
let Command = {
|
|
1743
|
+
"Verify": 'verify',
|
|
1744
|
+
"Pay": 'pay',
|
|
1745
|
+
"WalletAuth": 'wallet-auth',
|
|
1746
|
+
"SendTransaction": 'send-transaction',
|
|
1747
|
+
"SignMessage": 'sign-message',
|
|
1748
|
+
"SignTypedData": 'sign-typed-data',
|
|
1749
|
+
"ShareContacts": 'share-contacts',
|
|
1750
|
+
"RequestPermission": 'request-permission',
|
|
1751
|
+
"GetPermissions": 'get-permissions',
|
|
1752
|
+
"SendHapticFeedback": 'send-haptic-feedback',
|
|
1753
|
+
"ShareFiles": 'share-files',
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
// https://github.com/worldcoin/minikit-js/blob/main/packages/core/types/responses.ts
|
|
1757
|
+
let ResponseEvent = {
|
|
1758
|
+
"MiniAppVerifyAction": "miniapp-verify-action",
|
|
1759
|
+
"MiniAppPayment": "miniapp-payment",
|
|
1760
|
+
"MiniAppWalletAuth": "miniapp-wallet-auth",
|
|
1761
|
+
"MiniAppSendTransaction": "miniapp-send-transaction",
|
|
1762
|
+
"MiniAppSignMessage": "miniapp-sign-message",
|
|
1763
|
+
"MiniAppSignTypedData": "miniapp-sign-typed-data",
|
|
1764
|
+
"MiniAppShareContacts": "miniapp-share-contacts",
|
|
1765
|
+
"MiniAppRequestPermission": "miniapp-request-permission",
|
|
1766
|
+
"MiniAppGetPermissions": "miniapp-get-permissions",
|
|
1767
|
+
"MiniAppSendHapticFeedback": "miniapp-send-haptic-feedback",
|
|
1768
|
+
"MiniAppShareFiles": "miniapp-share-files",
|
|
1769
|
+
};
|
|
1770
|
+
|
|
1771
|
+
// https://github.com/worldcoin/minikit-js/blob/main/packages/core/index.ts
|
|
1772
|
+
// https://github.com/worldcoin/minikit-js/blob/main/packages/core/minikit.ts
|
|
1773
|
+
|
|
1774
|
+
class MiniKit {
|
|
1775
|
+
|
|
1776
|
+
static __initStatic() {this.MINIKIT_VERSION = 1;}
|
|
1777
|
+
|
|
1778
|
+
static __initStatic2() {this.miniKitCommandVersion = {
|
|
1779
|
+
[Command.Verify]: 1,
|
|
1780
|
+
[Command.Pay]: 1,
|
|
1781
|
+
[Command.WalletAuth]: 1,
|
|
1782
|
+
[Command.SendTransaction]: 1,
|
|
1783
|
+
[Command.SignMessage]: 1,
|
|
1784
|
+
[Command.SignTypedData]: 1,
|
|
1785
|
+
[Command.ShareContacts]: 1,
|
|
1786
|
+
[Command.RequestPermission]: 1,
|
|
1787
|
+
[Command.GetPermissions]: 1,
|
|
1788
|
+
[Command.SendHapticFeedback]: 1,
|
|
1789
|
+
[Command.ShareFiles]: 1,
|
|
1790
|
+
};}
|
|
1791
|
+
|
|
1792
|
+
static __initStatic3() {this.listeners = {
|
|
1793
|
+
[ResponseEvent.MiniAppVerifyAction]: () => {},
|
|
1794
|
+
[ResponseEvent.MiniAppPayment]: () => {},
|
|
1795
|
+
[ResponseEvent.MiniAppWalletAuth]: () => {},
|
|
1796
|
+
[ResponseEvent.MiniAppSendTransaction]: () => {},
|
|
1797
|
+
[ResponseEvent.MiniAppSignMessage]: () => {},
|
|
1798
|
+
[ResponseEvent.MiniAppSignTypedData]: () => {},
|
|
1799
|
+
[ResponseEvent.MiniAppShareContacts]: () => {},
|
|
1800
|
+
[ResponseEvent.MiniAppRequestPermission]: () => {},
|
|
1801
|
+
[ResponseEvent.MiniAppGetPermissions]: () => {},
|
|
1802
|
+
[ResponseEvent.MiniAppSendHapticFeedback]: () => {},
|
|
1803
|
+
[ResponseEvent.MiniAppShareFiles]: () => {},
|
|
1804
|
+
};}
|
|
1805
|
+
|
|
1806
|
+
static __initStatic4() {this.appId = null;}
|
|
1807
|
+
static __initStatic5() {this.user = {};}
|
|
1808
|
+
static __initStatic6() {this.isReady = false;}
|
|
1809
|
+
|
|
1810
|
+
static install(appId) {
|
|
1811
|
+
|
|
1812
|
+
if (typeof window === "undefined" || Boolean(window.MiniKit)) {
|
|
1813
|
+
return {
|
|
1814
|
+
success: false,
|
|
1815
|
+
errorCode: 'already_installed',
|
|
1816
|
+
errorMessage: 'MiniKit is already installed.'
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
if (!appId) {
|
|
1821
|
+
console.warn("App ID not provided during install");
|
|
1822
|
+
} else {
|
|
1823
|
+
MiniKit.appId = appId;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
if (!window.WorldApp) {
|
|
1827
|
+
return {
|
|
1828
|
+
success: false,
|
|
1829
|
+
errorCode: 'outside_of_worldapp',
|
|
1830
|
+
errorMessage: 'MiniApp launched outside of WorldApp.'
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
// Set user properties
|
|
1835
|
+
MiniKit.user.optedIntoOptionalAnalytics = window.WorldApp.is_optional_analytics;
|
|
1836
|
+
MiniKit.user.deviceOS = window.WorldApp.device_os;
|
|
1837
|
+
MiniKit.user.worldAppVersion = window.WorldApp.world_app_version;
|
|
1838
|
+
|
|
1839
|
+
try {
|
|
1840
|
+
window.MiniKit = MiniKit;
|
|
1841
|
+
this.sendInit();
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
console.error(
|
|
1844
|
+
'Failed to install MiniKit.',
|
|
1845
|
+
error
|
|
1846
|
+
);
|
|
1847
|
+
|
|
1848
|
+
return {
|
|
1849
|
+
success: false,
|
|
1850
|
+
errorCode: 'unknown',
|
|
1851
|
+
errorMessage: 'Failed to install MiniKit.'
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
MiniKit.isReady = true;
|
|
1856
|
+
return { success: true }
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
static sendInit() {
|
|
1860
|
+
sendWebviewEvent({
|
|
1861
|
+
command: 'init',
|
|
1862
|
+
payload: { version: this.MINIKIT_VERSION },
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
static subscribe(event, handler) {
|
|
1867
|
+
if (event === ResponseEvent.MiniAppWalletAuth) {
|
|
1868
|
+
const originalHandler = handler;
|
|
1869
|
+
const wrappedHandler = async (payload) => {
|
|
1870
|
+
if (payload.status === 'success') {
|
|
1871
|
+
MiniKit.user.walletAddress = payload.address;
|
|
1872
|
+
}
|
|
1873
|
+
originalHandler(payload);
|
|
1874
|
+
};
|
|
1875
|
+
this.listeners[event] = wrappedHandler;
|
|
1876
|
+
} else if (event === ResponseEvent.MiniAppVerifyAction) {
|
|
1877
|
+
const originalHandler = handler;
|
|
1878
|
+
const wrappedHandler = (payload) => {
|
|
1879
|
+
originalHandler(payload);
|
|
1880
|
+
};
|
|
1881
|
+
this.listeners[event] = wrappedHandler;
|
|
1882
|
+
} else {
|
|
1883
|
+
this.listeners[event] = handler;
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
static unsubscribe(event) {
|
|
1888
|
+
delete this.listeners[event];
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
static trigger(event, payload) {
|
|
1892
|
+
if (!this.listeners[event]) {
|
|
1893
|
+
console.error(
|
|
1894
|
+
`No handler for event ${event}, payload: ${JSON.stringify(payload)}`
|
|
1895
|
+
);
|
|
1896
|
+
return
|
|
1897
|
+
}
|
|
1898
|
+
this.listeners[event](payload);
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
static __initStatic7() {this.commands = {
|
|
1902
|
+
|
|
1903
|
+
walletAuth: (payload) => {
|
|
1904
|
+
|
|
1905
|
+
let protocol = null;
|
|
1906
|
+
try {
|
|
1907
|
+
const currentUrl = new URL(window.location.href);
|
|
1908
|
+
protocol = currentUrl.protocol.split(':')[0];
|
|
1909
|
+
} catch (error) {
|
|
1910
|
+
console.error('Failed to get current URL', error);
|
|
1911
|
+
return null
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
const siweMessage = generateSiweMessage({
|
|
1915
|
+
scheme: protocol,
|
|
1916
|
+
domain: window.location.host,
|
|
1917
|
+
statement: _nullishCoalesce(payload.statement, () => ( undefined)),
|
|
1918
|
+
uri: window.location.href,
|
|
1919
|
+
version: '1',
|
|
1920
|
+
chain_id: 480,
|
|
1921
|
+
nonce: payload.nonce,
|
|
1922
|
+
issued_at: new Date().toISOString(),
|
|
1923
|
+
expiration_time: _optionalChain$2([payload, 'access', _7 => _7.expirationTime, 'optionalAccess', _8 => _8.toISOString, 'call', _9 => _9()]),
|
|
1924
|
+
not_before: _optionalChain$2([payload, 'access', _10 => _10.notBefore, 'optionalAccess', _11 => _11.toISOString, 'call', _12 => _12()]),
|
|
1925
|
+
request_id: _nullishCoalesce(payload.requestId, () => ( undefined)),
|
|
1926
|
+
});
|
|
1927
|
+
|
|
1928
|
+
const walletAuthPayload = { siweMessage };
|
|
1929
|
+
sendMiniKitEvent({
|
|
1930
|
+
command: Command.WalletAuth,
|
|
1931
|
+
version: this.miniKitCommandVersion[Command.WalletAuth],
|
|
1932
|
+
payload: walletAuthPayload,
|
|
1933
|
+
});
|
|
1934
|
+
|
|
1935
|
+
return walletAuthPayload
|
|
1936
|
+
},
|
|
1937
|
+
|
|
1938
|
+
sendTransaction: (payload) => {
|
|
1939
|
+
|
|
1940
|
+
const validatedPayload = processTransactionPayload(payload);
|
|
1941
|
+
|
|
1942
|
+
sendMiniKitEvent({
|
|
1943
|
+
command: Command.SendTransaction,
|
|
1944
|
+
version: this.miniKitCommandVersion[Command.SendTransaction],
|
|
1945
|
+
payload: validatedPayload,
|
|
1946
|
+
});
|
|
1947
|
+
|
|
1948
|
+
return validatedPayload
|
|
1949
|
+
},
|
|
1950
|
+
|
|
1951
|
+
signMessage: (payload) => {
|
|
1952
|
+
|
|
1953
|
+
sendMiniKitEvent({
|
|
1954
|
+
command: Command.SignMessage,
|
|
1955
|
+
version: this.miniKitCommandVersion[Command.SignMessage],
|
|
1956
|
+
payload,
|
|
1957
|
+
});
|
|
1958
|
+
|
|
1959
|
+
return payload
|
|
1960
|
+
},
|
|
1961
|
+
};}
|
|
1962
|
+
} MiniKit.__initStatic(); MiniKit.__initStatic2(); MiniKit.__initStatic3(); MiniKit.__initStatic4(); MiniKit.__initStatic5(); MiniKit.__initStatic6(); MiniKit.__initStatic7();
|
|
1963
|
+
|
|
1627
1964
|
function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1628
1965
|
|
|
1629
1966
|
class WorldApp {
|
|
1630
1967
|
|
|
1631
|
-
static __initStatic() {this.
|
|
1968
|
+
static __initStatic() {this.MiniKit = MiniKit;}
|
|
1969
|
+
|
|
1970
|
+
static __initStatic2() {this.info = {
|
|
1632
1971
|
name: 'World App',
|
|
1633
1972
|
logo: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMzIDMyIj4KICA8Zz4KICAgIDxnPgogICAgICA8cmVjdCBmaWxsPSIjMDAwMDAwIiB3aWR0aD0iMzMiIGhlaWdodD0iMzIiLz4KICAgIDwvZz4KICAgIDxnPgogICAgICA8cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNMjQuNywxMi41Yy0uNS0xLjEtMS4xLTItMS45LTIuOHMtMS44LTEuNS0yLjgtMS45Yy0xLjEtLjUtMi4zLS43LTMuNS0uN3MtMi40LjItMy41LjdjLTEuMS41LTIsMS4xLTIuOCwxLjlzLTEuNSwxLjgtMS45LDIuOGMtLjUsMS4xLS43LDIuMy0uNywzLjVzLjIsMi40LjcsMy41LDEuMSwyLDEuOSwyLjhjLjguOCwxLjgsMS41LDIuOCwxLjksMS4xLjUsMi4zLjcsMy41LjdzMi40LS4yLDMuNS0uNywyLTEuMSwyLjgtMS45LDEuNS0xLjgsMS45LTIuOGMuNS0xLjEuNy0yLjMuNy0zLjVzLS4yLTIuNC0uNy0zLjVaTTEzLjUsMTUuMmMuNC0xLjQsMS43LTIuNSwzLjItMi41aDYuMmMuNC44LjcsMS42LjcsMi41aC0xMC4xWk0yMy43LDE2LjhjMCwuOS0uNCwxLjctLjcsMi41aC02LjJjLTEuNSwwLTIuOC0xLjEtMy4yLTIuNWgxMC4xWk0xMS40LDEwLjljMS40LTEuNCwzLjItMi4xLDUuMS0yLjFzMy44LjcsNS4xLDIuMWguMWMwLC4xLTUsLjEtNSwuMS0xLjMsMC0yLjYuNS0zLjUsMS41LS43LjctMS4yLDEuNy0xLjQsMi43aC0yLjVjLjItMS42LjktMy4xLDIuMS00LjNaTTE2LjUsMjMuMmMtMS45LDAtMy44LS43LTUuMS0yLjEtMS4yLTEuMi0xLjktMi43LTIuMS00LjNoMi41Yy4yLDEsLjcsMS45LDEuNCwyLjcuOS45LDIuMiwxLjUsMy41LDEuNWg1LS4xYy0xLjQsMS41LTMuMiwyLjItNS4xLDIuMloiLz4KICAgIDwvZz4KICA8L2c+Cjwvc3ZnPgo=",
|
|
1634
1973
|
blockchains: ["worldchain"]
|
|
1635
1974
|
};}
|
|
1636
1975
|
|
|
1637
|
-
static
|
|
1976
|
+
static __initStatic3() {this.isAvailable = async()=>{
|
|
1638
1977
|
return Boolean(
|
|
1639
1978
|
_optionalChain$1([window, 'optionalAccess', _2 => _2.WorldApp])
|
|
1640
1979
|
)
|
|
@@ -1649,25 +1988,17 @@ class WorldApp {
|
|
|
1649
1988
|
}
|
|
1650
1989
|
|
|
1651
1990
|
sendTransaction(transaction) {
|
|
1652
|
-
console.log('sendTransaction', transaction);
|
|
1653
1991
|
transaction = new Transaction(transaction);
|
|
1654
|
-
console.log('after transaction wrapping transaction.sent', transaction.sent);
|
|
1655
|
-
console.log('after transaction wrapping transaction.succeeded', transaction.succeeded);
|
|
1656
|
-
console.log('after transaction wrapping transaction.failed', transaction.failed);
|
|
1657
1992
|
|
|
1658
1993
|
return new Promise(async(resolve, reject)=>{
|
|
1659
1994
|
await transaction.prepare({ wallet: this });
|
|
1660
|
-
console.log('after prepare transaction', transaction);
|
|
1661
1995
|
transaction.nonce = (await this.transactionCount({ blockchain: 'worldchain', address: transaction.from })).toString();
|
|
1662
|
-
|
|
1996
|
+
transaction.fromBlock = await request('worldchain://latestBlockNumber');
|
|
1663
1997
|
|
|
1664
|
-
console.log('before MiniKit.subscribe');
|
|
1665
1998
|
MiniKit.subscribe(ResponseEvent.MiniAppSendTransaction, (payload)=> {
|
|
1666
|
-
|
|
1999
|
+
MiniKit.unsubscribe(ResponseEvent.MiniAppSendTransaction);
|
|
1667
2000
|
if (payload.status == "success") {
|
|
1668
|
-
console.log('before transaction.accepted', transaction);
|
|
1669
2001
|
if (transaction.accepted) { transaction.accepted(); }
|
|
1670
|
-
console.log('after transaction.accepted', transaction);
|
|
1671
2002
|
this.fetchTransaction(transaction, payload).then((transactionHash)=>{
|
|
1672
2003
|
if(transactionHash) {
|
|
1673
2004
|
resolve(transaction);
|
|
@@ -1679,9 +2010,7 @@ class WorldApp {
|
|
|
1679
2010
|
reject('Submitting transaction failed!');
|
|
1680
2011
|
}
|
|
1681
2012
|
});
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
console.log('before MiniKit.commands.sendTransaction', {
|
|
2013
|
+
MiniKit.commands.sendTransaction({
|
|
1685
2014
|
transaction: [
|
|
1686
2015
|
{
|
|
1687
2016
|
address: transaction.to,
|
|
@@ -1692,70 +2021,107 @@ class WorldApp {
|
|
|
1692
2021
|
],
|
|
1693
2022
|
permit2: [_optionalChain$1([transaction, 'access', _13 => _13.params, 'optionalAccess', _14 => _14.permit2])]
|
|
1694
2023
|
});
|
|
1695
|
-
MiniKit.commands.sendTransaction({
|
|
1696
|
-
transaction: [
|
|
1697
|
-
{
|
|
1698
|
-
address: transaction.to,
|
|
1699
|
-
abi: _optionalChain$1([transaction, 'access', _15 => _15.api, 'optionalAccess', _16 => _16.filter, 'call', _17 => _17((fragment)=>fragment.name === transaction.method && _optionalChain$1([fragment, 'optionalAccess', _18 => _18.inputs, 'optionalAccess', _19 => _19.length]) === _optionalChain$1([transaction, 'access', _20 => _20.params, 'optionalAccess', _21 => _21.args, 'optionalAccess', _22 => _22.length]))]),
|
|
1700
|
-
functionName: transaction.method,
|
|
1701
|
-
args: _optionalChain$1([transaction, 'access', _23 => _23.params, 'optionalAccess', _24 => _24.args])
|
|
1702
|
-
},
|
|
1703
|
-
],
|
|
1704
|
-
permit2: [_optionalChain$1([transaction, 'access', _25 => _25.params, 'optionalAccess', _26 => _26.permit2])]
|
|
1705
|
-
});
|
|
1706
|
-
console.log('after MiniKit.commands.sendTransaction');
|
|
1707
2024
|
})
|
|
1708
2025
|
}
|
|
1709
2026
|
|
|
1710
2027
|
retryFetchTransaction(transaction, payload, attempt) {
|
|
1711
|
-
console.log('Retry Fetch transaction', attempt);
|
|
1712
2028
|
return new Promise((resolve, reject)=>{
|
|
1713
2029
|
setTimeout(()=>{
|
|
1714
2030
|
this.fetchTransaction(transaction, payload, attempt+1).then(resolve).catch(reject);
|
|
1715
|
-
}, (attempt < 30 ? 500 :
|
|
2031
|
+
}, (attempt < 30 ? 500 : 2000));
|
|
1716
2032
|
})
|
|
1717
2033
|
}
|
|
1718
2034
|
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
2035
|
+
pollTransactionIdFromWorldchain(payload) {
|
|
2036
|
+
|
|
2037
|
+
return new Promise((resolve)=>{
|
|
2038
|
+
|
|
2039
|
+
fetch(`https://public.depay.com/transactions/worldchain/${payload.transaction_id}?app_id=${payload.mini_app_id}`, {
|
|
1723
2040
|
headers: { "Content-Type": "application/json" },
|
|
1724
2041
|
}).then((response)=>{
|
|
1725
|
-
console.log('After fetch', response);
|
|
1726
2042
|
if(response.ok) {
|
|
1727
|
-
console.log('Before json');
|
|
1728
2043
|
response.json().then((transactionJSON)=>{
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
transaction.id = _optionalChain$1([transactionJSON, 'optionalAccess', _28 => _28.external_id]);
|
|
1732
|
-
transaction.url = Blockchains['worldchain'].explorerUrlFor({ transaction });
|
|
1733
|
-
console.log('before transaction.sent', transaction.sent);
|
|
1734
|
-
if (transaction.sent) { transaction.sent(transaction); }
|
|
1735
|
-
console.log('Before provider');
|
|
1736
|
-
getProvider('worldchain').then((provider)=>{
|
|
1737
|
-
console.log('After provider', provider);
|
|
1738
|
-
console.log('Before wait transaction', transactionJSON.external_id);
|
|
1739
|
-
provider.waitForTransaction(transactionJSON.external_id).then((receipt)=>{
|
|
1740
|
-
console.log('After receipt', receipt);
|
|
1741
|
-
if(receipt && receipt.status == 1) {
|
|
1742
|
-
transaction._succeeded = true;
|
|
1743
|
-
console.log('before transaction.succeeded', transaction.succeeded);
|
|
1744
|
-
if (transaction.succeeded) { transaction.succeeded(transaction); }
|
|
1745
|
-
resolve(transaction);
|
|
1746
|
-
} else {
|
|
1747
|
-
if (transaction.failed) { transaction.failed(transaction, 'Transaction failed'); }
|
|
1748
|
-
}
|
|
1749
|
-
}).catch(reject);
|
|
1750
|
-
}).catch(reject);
|
|
2044
|
+
if(_optionalChain$1([transactionJSON, 'optionalAccess', _15 => _15.external_id])) {
|
|
2045
|
+
resolve(_optionalChain$1([transactionJSON, 'optionalAccess', _16 => _16.external_id]));
|
|
1751
2046
|
} else {
|
|
1752
|
-
|
|
2047
|
+
resolve();
|
|
1753
2048
|
}
|
|
1754
|
-
}).catch(()=>
|
|
2049
|
+
}).catch(()=>resolve());
|
|
2050
|
+
} else {
|
|
2051
|
+
resolve();
|
|
2052
|
+
}
|
|
2053
|
+
}).catch((error)=>{
|
|
2054
|
+
console.log('CATCH ERROR', error);
|
|
2055
|
+
resolve();
|
|
2056
|
+
});
|
|
2057
|
+
})
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
pollEventForUserOp(transaction, payload) {
|
|
2061
|
+
|
|
2062
|
+
return new Promise((resolve)=>{
|
|
2063
|
+
|
|
2064
|
+
rpcRequest({
|
|
2065
|
+
blockchain: 'worldchain',
|
|
2066
|
+
method: "eth_getLogs",
|
|
2067
|
+
params: [
|
|
2068
|
+
{
|
|
2069
|
+
"fromBlock": ethers.utils.hexValue(transaction.fromBlock),
|
|
2070
|
+
"toBlock": "latest",
|
|
2071
|
+
"address": "0x0000000071727De22E5E9d8BAf0edAc6f37da032", // entry point
|
|
2072
|
+
"topics": [
|
|
2073
|
+
"0x49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f",
|
|
2074
|
+
payload.userOpHash
|
|
2075
|
+
]
|
|
2076
|
+
}
|
|
2077
|
+
]
|
|
2078
|
+
}).then((responseData)=>{
|
|
2079
|
+
if(responseData && responseData instanceof Array) {
|
|
2080
|
+
let event = responseData.find((event)=>{
|
|
2081
|
+
return(!event.removed)
|
|
2082
|
+
});
|
|
2083
|
+
if(event && event.transactionHash) {
|
|
2084
|
+
return resolve(event.transactionHash)
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
resolve();
|
|
2088
|
+
}).catch(()=>resolve());
|
|
2089
|
+
})
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
|
|
2093
|
+
|
|
2094
|
+
fetchTransaction(transaction, payload, attempt = 1) {
|
|
2095
|
+
return new Promise((resolve, reject)=>{
|
|
2096
|
+
|
|
2097
|
+
Promise.all([
|
|
2098
|
+
this.pollTransactionIdFromWorldchain(payload),
|
|
2099
|
+
this.pollEventForUserOp(transaction, payload),
|
|
2100
|
+
]).then((results)=>{
|
|
2101
|
+
let transactionHash = results ? results.filter(Boolean)[0] : undefined;
|
|
2102
|
+
if(transactionHash) {
|
|
2103
|
+
transaction.id = transactionHash;
|
|
2104
|
+
transaction.url = Blockchains['worldchain'].explorerUrlFor({ transaction });
|
|
2105
|
+
if (transaction.sent) { transaction.sent(transaction); }
|
|
2106
|
+
getProvider('worldchain').then((provider)=>{
|
|
2107
|
+
provider.waitForTransaction(transactionHash).then((receipt)=>{
|
|
2108
|
+
if(receipt && receipt.status == 1) {
|
|
2109
|
+
transaction._succeeded = true;
|
|
2110
|
+
if (transaction.succeeded) { transaction.succeeded(transaction); }
|
|
2111
|
+
resolve(transaction);
|
|
2112
|
+
} else {
|
|
2113
|
+
if (transaction.failed) { transaction.failed(transaction, 'Transaction failed'); }
|
|
2114
|
+
reject(transaction);
|
|
2115
|
+
}
|
|
2116
|
+
}).catch(reject);
|
|
2117
|
+
}).catch(reject);
|
|
1755
2118
|
} else {
|
|
1756
2119
|
this.retryFetchTransaction(transaction, payload, attempt).then(resolve).catch(reject);
|
|
1757
2120
|
}
|
|
1758
|
-
}).catch(()=>
|
|
2121
|
+
}).catch((error)=>{
|
|
2122
|
+
console.log('CATCH ERROR!', error);
|
|
2123
|
+
this.retryFetchTransaction(transaction, payload, attempt).then(resolve).catch(reject);
|
|
2124
|
+
});
|
|
1759
2125
|
})
|
|
1760
2126
|
}
|
|
1761
2127
|
|
|
@@ -1765,37 +2131,33 @@ class WorldApp {
|
|
|
1765
2131
|
|
|
1766
2132
|
async account() {
|
|
1767
2133
|
if(!this.getProvider()) { return undefined }
|
|
1768
|
-
return
|
|
2134
|
+
return this.walletAddress()
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
walletAddress() {
|
|
2138
|
+
return (_optionalChain$1([window, 'access', _17 => _17.MiniKit, 'access', _18 => _18.user, 'optionalAccess', _19 => _19.walletAddress]) || _optionalChain$1([MiniKit, 'access', _20 => _20.user, 'optionalAccess', _21 => _21.walletAddress]))
|
|
1769
2139
|
}
|
|
1770
2140
|
|
|
1771
2141
|
connect() {
|
|
1772
2142
|
|
|
1773
2143
|
return new Promise( async(resolve, reject)=>{
|
|
1774
2144
|
|
|
1775
|
-
if(
|
|
1776
|
-
return resolve(
|
|
2145
|
+
if(this.walletAddress()) {
|
|
2146
|
+
return resolve(this.walletAddress())
|
|
1777
2147
|
}
|
|
1778
2148
|
|
|
1779
2149
|
MiniKit.subscribe(ResponseEvent.MiniAppWalletAuth, async (payload) => {
|
|
2150
|
+
MiniKit.unsubscribe(ResponseEvent.MiniAppWalletAuth);
|
|
1780
2151
|
if (payload.status === "error") {
|
|
1781
2152
|
return reject(payload.message)
|
|
1782
2153
|
} else {
|
|
1783
|
-
return resolve(
|
|
2154
|
+
return resolve(this.walletAddress())
|
|
1784
2155
|
}
|
|
1785
2156
|
});
|
|
1786
2157
|
|
|
1787
|
-
|
|
1788
|
-
nonce: crypto.randomUUID().replace(/-/g, "")
|
|
1789
|
-
expirationTime: new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000),
|
|
1790
|
-
notBefore: new Date(new Date().getTime() - 24 * 60 * 60 * 1000),
|
|
1791
|
-
statement: "Connect World App (v17.6.2)"
|
|
2158
|
+
MiniKit.commands.walletAuth({
|
|
2159
|
+
nonce: crypto.randomUUID().replace(/-/g, "")
|
|
1792
2160
|
});
|
|
1793
|
-
|
|
1794
|
-
if(finalPayload.status == 'error') {
|
|
1795
|
-
return reject(finalPayload.message)
|
|
1796
|
-
} else {
|
|
1797
|
-
return resolve(MiniKit.walletAddress || _optionalChain$1([window, 'access', _31 => _31.MiniKit, 'optionalAccess', _32 => _32.walletAddress]))
|
|
1798
|
-
}
|
|
1799
2161
|
})
|
|
1800
2162
|
}
|
|
1801
2163
|
|
|
@@ -1824,12 +2186,12 @@ class WorldApp {
|
|
|
1824
2186
|
}
|
|
1825
2187
|
|
|
1826
2188
|
async transactionCount({ blockchain, address }) {
|
|
1827
|
-
if(!
|
|
2189
|
+
if(!this.walletAddress()) {
|
|
1828
2190
|
return 0
|
|
1829
2191
|
} else {
|
|
1830
2192
|
return request({
|
|
1831
2193
|
blockchain: 'worldchain',
|
|
1832
|
-
address:
|
|
2194
|
+
address: this.walletAddress(),
|
|
1833
2195
|
api: [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"AddedOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"approvedHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"ApproveHash","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"handler","type":"address"}],"name":"ChangedFallbackHandler","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"guard","type":"address"}],"name":"ChangedGuard","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"ChangedThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"DisabledModule","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"EnabledModule","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"txHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"payment","type":"uint256"}],"name":"ExecutionFailure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"ExecutionFromModuleFailure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"ExecutionFromModuleSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"txHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"payment","type":"uint256"}],"name":"ExecutionSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"RemovedOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"address[]","name":"owners","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"},{"indexed":false,"internalType":"address","name":"initializer","type":"address"},{"indexed":false,"internalType":"address","name":"fallbackHandler","type":"address"}],"name":"SafeSetup","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"}],"name":"SignMsg","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"addOwnerWithThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hashToApprove","type":"bytes32"}],"name":"approveHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"approvedHashes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"changeThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signatures","type":"bytes"},{"internalType":"uint256","name":"requiredSignatures","type":"uint256"}],"name":"checkNSignatures","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signatures","type":"bytes"}],"name":"checkSignatures","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"prevModule","type":"address"},{"internalType":"address","name":"module","type":"address"}],"name":"disableModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"enableModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enumEnum.Operation","name":"operation","type":"uint8"},{"internalType":"uint256","name":"safeTxGas","type":"uint256"},{"internalType":"uint256","name":"baseGas","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"address","name":"gasToken","type":"address"},{"internalType":"address","name":"refundReceiver","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"encodeTransactionData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enumEnum.Operation","name":"operation","type":"uint8"},{"internalType":"uint256","name":"safeTxGas","type":"uint256"},{"internalType":"uint256","name":"baseGas","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"address","name":"gasToken","type":"address"},{"internalType":"addresspayable","name":"refundReceiver","type":"address"},{"internalType":"bytes","name":"signatures","type":"bytes"}],"name":"execTransaction","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enumEnum.Operation","name":"operation","type":"uint8"}],"name":"execTransactionFromModule","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enumEnum.Operation","name":"operation","type":"uint8"}],"name":"execTransactionFromModuleReturnData","outputs":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"start","type":"address"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getModulesPaginated","outputs":[{"internalType":"address[]","name":"array","type":"address[]"},{"internalType":"address","name":"next","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"getStorageAt","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enumEnum.Operation","name":"operation","type":"uint8"},{"internalType":"uint256","name":"safeTxGas","type":"uint256"},{"internalType":"uint256","name":"baseGas","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"address","name":"gasToken","type":"address"},{"internalType":"address","name":"refundReceiver","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"getTransactionHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"isModuleEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"prevOwner","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"removeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enumEnum.Operation","name":"operation","type":"uint8"}],"name":"requiredTxGas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"handler","type":"address"}],"name":"setFallbackHandler","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guard","type":"address"}],"name":"setGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_owners","type":"address[]"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"address","name":"fallbackHandler","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"payment","type":"uint256"},{"internalType":"addresspayable","name":"paymentReceiver","type":"address"}],"name":"setup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"signedMessages","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"bytes","name":"calldataPayload","type":"bytes"}],"name":"simulateAndRevert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"prevOwner","type":"address"},{"internalType":"address","name":"oldOwner","type":"address"},{"internalType":"address","name":"newOwner","type":"address"}],"name":"swapOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}],
|
|
1834
2196
|
method: 'nonce'
|
|
1835
2197
|
})
|
|
@@ -1841,18 +2203,17 @@ class WorldApp {
|
|
|
1841
2203
|
return new Promise((resolve, reject)=>{
|
|
1842
2204
|
|
|
1843
2205
|
MiniKit.subscribe(ResponseEvent.MiniAppSignMessage, async (payload) => {
|
|
2206
|
+
MiniKit.unsubscribe(ResponseEvent.MiniAppSignMessage);
|
|
1844
2207
|
if (payload.status === "error") {
|
|
1845
2208
|
return reject()
|
|
1846
2209
|
} else {
|
|
1847
2210
|
return resolve(payload.signature)
|
|
1848
2211
|
}
|
|
1849
2212
|
});
|
|
1850
|
-
|
|
1851
2213
|
MiniKit.commands.signMessage({ message });
|
|
1852
|
-
|
|
1853
2214
|
})
|
|
1854
2215
|
}
|
|
1855
|
-
} WorldApp.__initStatic(); WorldApp.__initStatic2();
|
|
2216
|
+
} WorldApp.__initStatic(); WorldApp.__initStatic2(); WorldApp.__initStatic3();
|
|
1856
2217
|
|
|
1857
2218
|
var wallets = {
|
|
1858
2219
|
MetaMask,
|