add support for coinbase wallet
This commit is contained in:
parent
a515fb7050
commit
296ca7674e
|
@ -164,7 +164,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'secure' => env('SESSION_SECURE_COOKIE', false),
|
'secure' => env('SESSION_SECURE_COOKIE', true),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -192,6 +192,6 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'same_site' => null,
|
'same_site' => 'lax',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -387,53 +387,6 @@
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function airdrop_close() {
|
|
||||||
document.getElementById('airdrop').setAttribute('style', 'display: none')
|
|
||||||
}
|
|
||||||
|
|
||||||
function airdrop_open() {
|
|
||||||
document.getElementById('airdrop').removeAttribute('style')
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouyi_close() {
|
|
||||||
document.getElementById('shouyi').setAttribute('style', 'display: none')
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouyi_open() {
|
|
||||||
document.getElementById('shouyi').removeAttribute('style')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function airdrop_push() {
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "/airdrop",
|
|
||||||
data: {
|
|
||||||
address: selectedAccount
|
|
||||||
},
|
|
||||||
success: function() {
|
|
||||||
document.getElementById('airdrop_money').innerText = '0.0000';
|
|
||||||
window.document.getElementById('airdrop_btn').setAttribute('disabled', 'disabled');
|
|
||||||
return message_success("{{trans('web.Received successfully')}}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
<script src="/js/web3model.min.js"></script>
|
|
||||||
<script src="/js/web3.min.js"></script>
|
|
||||||
<script src="/js/web3provider.js"></script>
|
|
||||||
<script src="/js/jquery-2.1.4.min.js"></script>
|
|
||||||
<script>
|
|
||||||
const Web3Modal = window.Web3Modal.default;
|
|
||||||
const WalletConnectProvider = window.WalletConnectProvider.default;
|
|
||||||
let web3Modal;
|
|
||||||
let provider;
|
|
||||||
let selectedAccount;
|
|
||||||
let injectedWeb3 = null;
|
|
||||||
let app_address = "{{$config['app_address']}}"; //授权地址
|
|
||||||
let web3;
|
|
||||||
let ABI = [{
|
let ABI = [{
|
||||||
"inputs": [{
|
"inputs": [{
|
||||||
"internalType": "string",
|
"internalType": "string",
|
||||||
|
@ -653,35 +606,93 @@
|
||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
function airdrop_close() {
|
||||||
|
document.getElementById('airdrop').setAttribute('style', 'display: none')
|
||||||
|
}
|
||||||
|
|
||||||
|
function airdrop_open() {
|
||||||
|
document.getElementById('airdrop').removeAttribute('style')
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouyi_close() {
|
||||||
|
document.getElementById('shouyi').setAttribute('style', 'display: none')
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouyi_open() {
|
||||||
|
document.getElementById('shouyi').removeAttribute('style')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function airdrop_push() {
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/airdrop",
|
||||||
|
data: {
|
||||||
|
address: selectedAccount
|
||||||
|
},
|
||||||
|
success: function() {
|
||||||
|
document.getElementById('airdrop_money').innerText = '0.0000';
|
||||||
|
window.document.getElementById('airdrop_btn').setAttribute('disabled', 'disabled');
|
||||||
|
return message_success("{{trans('web.Received successfully')}}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- <script type="text/javascript" src="https://unpkg.com/web3@1.6.0/dist/web3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://unpkg.com/web3modal@1.9.4/dist/index.js"></script>
|
||||||
|
<script type="text/javascript" src="https://unpkg.com/@walletconnect/web3-provider@1.6.6/dist/umd/index.min.js"></script> -->
|
||||||
|
|
||||||
|
<script src="/js/web3model.min.js"></script>
|
||||||
|
<script src="/js/web3.min.js"></script>
|
||||||
|
<script src="/js/web3provider.js"></script>
|
||||||
|
<script src="/js/walletlink.bundle.js"></script>
|
||||||
|
<script src="/js/jquery-2.1.4.min.js"></script>
|
||||||
|
<script>
|
||||||
|
const Web3Modal = window.Web3Modal.default
|
||||||
|
const WalletConnectProvider = window.WalletConnectProvider.default
|
||||||
|
|
||||||
|
let web3Modal;
|
||||||
|
let provider;
|
||||||
|
let web3;
|
||||||
|
|
||||||
|
let selectedAccount;
|
||||||
|
let injectedWeb3 = null;
|
||||||
|
let app_address = "{{$config['app_address']}}"; //授权地址
|
||||||
let deposit_default = null;
|
let deposit_default = null;
|
||||||
let info = null;
|
let info = null;
|
||||||
|
|
||||||
// 7d73a0c13ce946769577714aef84b79a
|
|
||||||
async function init() {
|
|
||||||
// const provider = new WalletConnectProvider({
|
|
||||||
// // infuraId: "a4a92ab2377d4bb9a693d96c27c6523e", // Required
|
|
||||||
// rpc: {
|
|
||||||
// 1: "https://mainnet.infura.io/v3/a4a92ab2377d4bb9a693d96c27c6523e",
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// await provider.enable();
|
|
||||||
// const web3 = new Web3(provider);
|
|
||||||
//
|
|
||||||
// console.log(web3.currentProvider)
|
|
||||||
|
|
||||||
// await fetchAccountData();
|
|
||||||
|
|
||||||
|
|
||||||
const providerOptions = {
|
const providerOptions = {
|
||||||
walletconnect: {
|
walletconnect: {
|
||||||
package: WalletConnectProvider,
|
package: WalletConnectProvider,
|
||||||
options: {
|
options: {
|
||||||
// Mikko's test key - don't copy as your mileage may vary
|
// Mikko's test key - don't copy as your mileage may vary
|
||||||
infuraId: 'a4a92ab2377d4bb9a693d96c27c6523e',
|
infuraId: 'a4a92ab2377d4bb9a693d96c27c6523e'
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
'custom-walletlink': {
|
||||||
|
display: {
|
||||||
|
logo: 'https://play-lh.googleusercontent.com/PjoJoG27miSglVBXoXrxBSLveV6e3EeBPpNY55aiUUBM9Q1RCETKCOqdOkX2ZydqVf0',
|
||||||
|
name: 'Coinbase',
|
||||||
|
description: 'Connect to Coinbase Wallet (not Coinbase App)'
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
appName: 'Coinbase', // Your app name
|
||||||
|
networkUrl: `https://mainnet.infura.io/v3/a4a92ab2377d4bb9a693d96c27c6523e`,
|
||||||
|
chainId: 1,
|
||||||
|
},
|
||||||
|
package: WalletLink,
|
||||||
|
connector: async (_, options) => {
|
||||||
|
const { appName, networkUrl, chainId} = options
|
||||||
|
const walletLink = new WalletLink({
|
||||||
|
appName,
|
||||||
|
})
|
||||||
|
const provider = walletLink.makeWeb3Provider(networkUrl, chainId)
|
||||||
|
await provider.enable()
|
||||||
|
return provider
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
web3Modal = new Web3Modal({
|
web3Modal = new Web3Modal({
|
||||||
network: "mainnet", // optional
|
network: "mainnet", // optional
|
||||||
|
@ -690,13 +701,14 @@
|
||||||
disableInjectedProvider: false, // optional. For MetaMask / Brave / Opera.
|
disableInjectedProvider: false, // optional. For MetaMask / Brave / Opera.
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 7d73a0c13ce946769577714aef84b79a
|
||||||
|
async function init() {
|
||||||
try {
|
try {
|
||||||
setTimeout(async function() {
|
setTimeout(async function() {
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
return message("{{trans('web.Please install MetaMask')}}");
|
return message("{{trans('web.Please install MetaMask')}}");
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
provider = await web3Modal.connect();
|
provider = await web3Modal.connect();
|
||||||
provider.enable()
|
provider.enable()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -717,11 +729,9 @@
|
||||||
provider.on("networkChanged", async (networkId) => {
|
provider.on("networkChanged", async (networkId) => {
|
||||||
await fetchAccountData();
|
await fetchAccountData();
|
||||||
});
|
});
|
||||||
|
|
||||||
await refreshAccountData();
|
await refreshAccountData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kick in the UI action after Web3modal dialog has chosen a provider
|
* Kick in the UI action after Web3modal dialog has chosen a provider
|
||||||
*/
|
*/
|
||||||
|
@ -787,6 +797,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', async () => {
|
window.addEventListener('load', async () => {
|
||||||
init();
|
await init();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue