init
89
Assets/WebGLTemplates/Cronos_Defi_Wallet/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Unity ^2020.1.0 Web3GL Template
|
||||
|
||||
## Methods in Browser
|
||||
|
||||

|
||||
|
||||
Dispay login modal:
|
||||
|
||||
```javascript
|
||||
window.web3gl.connect();
|
||||
```
|
||||
|
||||
Get Network:
|
||||
|
||||
```javascript
|
||||
window.web3gl.networkId;
|
||||
```
|
||||
|
||||
Get Connected Address:
|
||||
|
||||
```javascript
|
||||
window.web3gl.connectAccount;
|
||||
```
|
||||
|
||||
To Send Transaction:
|
||||
|
||||
```javascript
|
||||
const to = "0xdD4c825203f97984e7867F11eeCc813A036089D1";
|
||||
const value = "12300000000000000";
|
||||
const gasLimit = "21000"; // gas limit
|
||||
const gasPrice = "33333333333";
|
||||
window.web3gl.sendTransaction(to, value, gasLimit, gasPrice);
|
||||
```
|
||||
|
||||
To Interact with Contract:
|
||||
|
||||
```javascript
|
||||
const method = "increment";
|
||||
const abi = `[ { "inputs": [], "name": "increment", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "x", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" } ]`;
|
||||
const contract = "0xB6B8bB1e16A6F73f7078108538979336B9B7341C";
|
||||
const args = "[]";
|
||||
const value = "0";
|
||||
const gasLimit = "222222"; // gas limit
|
||||
const gasPrice = "333333333333";
|
||||
window.web3gl.sendContract(method, abi, contract, args, value, gasLimit, gasPrice);
|
||||
```
|
||||
|
||||
## Enable Torus
|
||||
|
||||
In `web3/index.js`
|
||||
|
||||
Uncomment
|
||||
|
||||
```javascript
|
||||
document.body.appendChild(Object.assign(document.createElement("script"), { type: "text/javascript", src: "https://unpkg.com/@toruslabs/torus-embed" }));
|
||||
```
|
||||
|
||||
```javascript
|
||||
const providerOptions = {
|
||||
torus: {
|
||||
package: Torus,
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Enable WalletConnect
|
||||
|
||||
In `web3/index.js`
|
||||
|
||||
Uncomment
|
||||
|
||||
```javascript
|
||||
document.body.appendChild(Object.assign(document.createElement("script"), { type: "text/javascript", src: "https://unpkg.com/@walletconnect/web3-provider@1.2.1/dist/umd/index.min.js" }));
|
||||
```
|
||||
|
||||
```javascript
|
||||
const providerOptions = {
|
||||
walletconnect: {
|
||||
package: window.WalletConnectProvider.default,
|
||||
options: {
|
||||
infuraId: "00000000000000000000000000000000",
|
||||
},
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Replace `infuraId: "00000000000000000000000000000000"`
|
||||
|
||||

|
||||
7
Assets/WebGLTemplates/Cronos_Defi_Wallet/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 462923b12be1bc246828df75d88ae80c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0344eab6c31920498df5c9eaaf2ad55
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4137ee136a0403048af218188e9c0939
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 175 B |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 376588a0ff7bc634eb690bab5134bc53
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 96 B |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34fe0d38edf77f94f9f3e2c47bb154ec
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 109 B |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acf249e7bf9966242bd686c6dc5cc5c3
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 74 B |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6339b6df07f90640b045e4020723063
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 84 B |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44a2f417cb63ae84fa1bc2f8a241d974
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
body { padding: 0; margin: 0 }
|
||||
#unity-container { position: absolute }
|
||||
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
|
||||
#unity-container.unity-mobile { width: 100%; height: 100% }
|
||||
#unity-canvas { background: {{{ BACKGROUND_COLOR }}} }
|
||||
.unity-mobile #unity-canvas { width: 100%; height: 100% }
|
||||
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
|
||||
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-{{{ SPLASH_SCREEN_STYLE.toLowerCase() }}}.png') no-repeat center }
|
||||
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; background: url('progress-bar-empty-{{{ SPLASH_SCREEN_STYLE.toLowerCase() }}}.png') no-repeat center }
|
||||
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-{{{ SPLASH_SCREEN_STYLE.toLowerCase() }}}.png') no-repeat center }
|
||||
#unity-footer { position: relative }
|
||||
.unity-mobile #unity-footer { display: none }
|
||||
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
|
||||
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
|
||||
#unity-fullscreen-button { float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
|
||||
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }
|
||||
.web3modal-modal-card { font-family: sans-serif}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5db486dc38d7a54c9b1ace35044ab6c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b3d15ba34de1354481693e65eec4ec3
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5eba1d9664fb8d84b8991e9a8a283a46
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e38abb20bc9c7be48b0002e37ecd89ce
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/WebGLTemplates/Cronos_Defi_Wallet/index.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Unity WebGL Player | {{{ PRODUCT_NAME }}}</title>
|
||||
<link rel="shortcut icon" href="TemplateData/favicon.ico">
|
||||
<link rel="stylesheet" href="TemplateData/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="unity-container" class="unity-desktop">
|
||||
<canvas id="unity-canvas" width={{{ WIDTH }}} height={{{ HEIGHT }}}></canvas>
|
||||
<div id="unity-loading-bar">
|
||||
<div id="unity-logo"></div>
|
||||
<div id="unity-progress-bar-empty">
|
||||
<div id="unity-progress-bar-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="unity-warning"> </div>
|
||||
<div id="unity-footer">
|
||||
<div id="unity-webgl-logo"></div>
|
||||
<div id="unity-fullscreen-button"></div>
|
||||
<div id="unity-build-title">{{{ PRODUCT_NAME }}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="web3/index.js"></script>
|
||||
<script>
|
||||
var container = document.querySelector("#unity-container");
|
||||
var canvas = document.querySelector("#unity-canvas");
|
||||
var loadingBar = document.querySelector("#unity-loading-bar");
|
||||
var progressBarFull = document.querySelector("#unity-progress-bar-full");
|
||||
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
|
||||
var warningBanner = document.querySelector("#unity-warning");
|
||||
|
||||
// Shows a temporary message banner/ribbon for a few seconds, or
|
||||
// a permanent error message on top of the canvas if type=='error'.
|
||||
// If type=='warning', a yellow highlight color is used.
|
||||
// Modify or remove this function to customize the visually presented
|
||||
// way that non-critical warnings and error messages are presented to the
|
||||
// user.
|
||||
function unityShowBanner(msg, type) {
|
||||
function updateBannerVisibility() {
|
||||
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
|
||||
}
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = msg;
|
||||
warningBanner.appendChild(div);
|
||||
if (type == 'error') div.style = 'background: red; padding: 10px;';
|
||||
else {
|
||||
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
|
||||
setTimeout(function() {
|
||||
warningBanner.removeChild(div);
|
||||
updateBannerVisibility();
|
||||
}, 5000);
|
||||
}
|
||||
updateBannerVisibility();
|
||||
}
|
||||
|
||||
var buildUrl = "Build";
|
||||
var loaderUrl = buildUrl + "/{{{ LOADER_FILENAME }}}";
|
||||
var config = {
|
||||
dataUrl: buildUrl + "/{{{ DATA_FILENAME }}}",
|
||||
frameworkUrl: buildUrl + "/{{{ FRAMEWORK_FILENAME }}}",
|
||||
codeUrl: buildUrl + "/{{{ CODE_FILENAME }}}",
|
||||
#if MEMORY_FILENAME
|
||||
memoryUrl: buildUrl + "/{{{ MEMORY_FILENAME }}}",
|
||||
#endif
|
||||
#if SYMBOLS_FILENAME
|
||||
symbolsUrl: buildUrl + "/{{{ SYMBOLS_FILENAME }}}",
|
||||
#endif
|
||||
streamingAssetsUrl: "StreamingAssets",
|
||||
companyName: "{{{ COMPANY_NAME }}}",
|
||||
productName: "{{{ PRODUCT_NAME }}}",
|
||||
productVersion: "{{{ PRODUCT_VERSION }}}",
|
||||
showBanner: unityShowBanner,
|
||||
};
|
||||
|
||||
// By default Unity keeps WebGL canvas render target size matched with
|
||||
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
|
||||
// Set this to false if you want to decouple this synchronization from
|
||||
// happening inside the engine, and you would instead like to size up
|
||||
// the canvas DOM size and WebGL render target sizes yourself.
|
||||
// config.matchWebGLToCanvasSize = false;
|
||||
|
||||
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
||||
container.className = "unity-mobile";
|
||||
// Avoid draining fillrate performance on mobile devices,
|
||||
// and default/override low DPI mode on mobile browsers.
|
||||
config.devicePixelRatio = 1;
|
||||
unityShowBanner('WebGL builds are not supported on mobile devices.');
|
||||
} else {
|
||||
canvas.style.width = "{{{ WIDTH }}}px";
|
||||
canvas.style.height = "{{{ HEIGHT }}}px";
|
||||
}
|
||||
#if BACKGROUND_FILENAME
|
||||
canvas.style.background = "url('" + buildUrl + "/{{{ BACKGROUND_FILENAME.replace(/'/g, '%27') }}}') center / cover";
|
||||
#endif
|
||||
loadingBar.style.display = "block";
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = loaderUrl;
|
||||
script.onload = () => {
|
||||
createUnityInstance(canvas, config, (progress) => {
|
||||
progressBarFull.style.width = 100 * progress + "%";
|
||||
}).then((unityInstance) => {
|
||||
loadingBar.style.display = "none";
|
||||
fullscreenButton.onclick = () => {
|
||||
unityInstance.SetFullscreen(1);
|
||||
};
|
||||
}).catch((message) => {
|
||||
alert(message);
|
||||
});
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
7
Assets/WebGLTemplates/Cronos_Defi_Wallet/index.html.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af795533b2381fd4d82a55922e6e8cae
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/WebGLTemplates/Cronos_Defi_Wallet/network.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
Used to set the network: https://chainlist.org/
|
||||
1 Mainnet
|
||||
3 Ropsten
|
||||
4 Rinkeby
|
||||
5 Goerli
|
||||
42 Kovan
|
||||
56 Binance Smart Chain Mainnet
|
||||
97 Binance Smart Chain Testnet
|
||||
100 xDai
|
||||
137 Matic
|
||||
1287 Moonbase Testnet
|
||||
80001 Matic Testnet
|
||||
43113 Avalanche Testnet
|
||||
43114 Avalanche Mainnet
|
||||
42220 Celo Mainnet
|
||||
44787 Celo Alfajores Testnet
|
||||
62320 Celo Baklava Testnet
|
||||
1666700000 Harmony Testnet Shard0
|
||||
1666600000 Harmony Mainnet Shard0
|
||||
25 Cronos Mainnet Beta
|
||||
338 Cronos Testnet
|
||||
*/
|
||||
|
||||
window.web3ChainId = 1;
|
||||
7
Assets/WebGLTemplates/Cronos_Defi_Wallet/network.js.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2da1890fc862094d9bc601c22ac0ede
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/WebGLTemplates/Cronos_Defi_Wallet/thumbnail.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82b3c535062d18344abe027de5734d79
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/WebGLTemplates/Cronos_Defi_Wallet/web3.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48a280fdc19dddd41accb79c15508141
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
275
Assets/WebGLTemplates/Cronos_Defi_Wallet/web3/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c27244ce0cbde34db841323bce1b140
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/WebGLTemplates/Cronos_Defi_Wallet/web3/lib.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 490050520cdc57f489ef9dfd7d611338
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
57
Assets/WebGLTemplates/Cronos_Defi_Wallet/web3/lib/web3.min.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0c33c2497db0f347bef648e99d81974
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bed197276704794585bd3ebb4b4b5c9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||