Skip to content

Commit

Permalink
Feat/kukai embed (#71)
Browse files Browse the repository at this point in the history
* Added walletProviders;

* Added WebGLFrontend;

* kukai-embed rollback to 0.8.4

* Fix type window;

* Fix imports

* JS bundle to StreamingAssets

* Removed unnecessary tsx resolve;

* Added output directory with folders needed for WebGL build;

* Update readme; drop unitypackage file;

* Implemented InitWalletProvider and configuring network type for web wallet providers;

* Changelog updated;

* WebGLCopyAndPaste to unitypackage; Update readme;

* Added WebGLCopyAndPaste.unitypackage

* Improve readme;

* Removed unnecessary WebGLCopyAndPaste.unitypackage

---------

Co-authored-by: mismirnov <[email protected]>
  • Loading branch information
k-karuna and mismirnov authored Jun 1, 2023
1 parent 9024364 commit 4be4f8a
Show file tree
Hide file tree
Showing 40 changed files with 7,374 additions and 375 deletions.
137 changes: 137 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,140 @@ sysinfo.txt
*.usertasks
*.resources
/BUILD/


# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

WebGLFrontend/*.meta
WebGLFrontend/**/*.meta
WebGLFrontend/node_modules/
WebGLFrontend/dist/
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Bug](https://github.com/trilitech/tezos-unity-sdk/issues/68) with UnityBeacon gameobject
- [Bug](https://github.com/trilitech/tezos-unity-sdk/issues/61) fix contracts compilation on Ligo `0.65.0`

### Added
- Kukai embed login option for WebGL builds
- Ability to build WebGL frontend bundle with Webpack, refactored WebGL fronted app structure

### Changed
- [Updated](https://github.com/trilitech/tezos-unity-sdk/issues/70) Beacon TypeScript dependency


## [1.4.0] - 2023-05-18
### Fixed
- [Bug](https://github.com/trilitech/tezos-unity-sdk/issues/57) with BeaconConnectorWebGl
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ currently [![NPM Package](https://img.shields.io/npm/v/com.trilitech.tezos-unity
### WebGL Support

* Open Unity Editor.
* Navigate to Project -> Packages and find the Tezos Unity SDK.
* Double-click the package file WebGLSupport.unitypackage.
![Project->Packages->Tezos-Unity-SDK](https://github.com/mismirnov/tezos-unity-sdk/blob/master/packages-tezos-unity-sdk.png?raw=true)
* The Import Unity Package dialog box displays, with all the items in the package pre-checked, ready to install.
![Import unity package](https://github.com/mismirnov/tezos-unity-sdk/blob/master/import-unity-package.png?raw=true)

* This action create WebGL templates folders to your Project. Each template is a subfolder within the WebGLTemplates
folder. Each template subfolder contains an index.html file along with any other resources the page needs, such as
images or stylesheets.
* Navigate to `Packages` and find the `Tezos Unity SDK`.
* Go to `WebGLFrontend/output` and copy the `StreamingAssets` and `WebGLTemplates` folders.
* Navigate to the `Assets` folder of your project and paste copied folders.
* This action will create WebGL templates folders to your Project. Each template is a subfolder within the
`WebGLTemplates` folder. Each template subfolder contains an `index.html` file along with any other resources the page
needs, such as images or stylesheets. You can choose appropriate template to use in WebGL build in
`Project settings/Player/Web tab/Resolution and Presentation`
* By default unfortunately Web builds didn't support copy and paste operations, to be able handle them install with
double-clicking `WebGLFrontend/output/WebGLCopyAndPaste.unitypackage`, this action will create `WebGLCopyAndPaste`
alongside with `StreamingAssets` and `WebGLTemplates` folders inside your project Assets directory.


### 📝 Read the [documentation.](https://opentezos.com/gaming/unity-sdk/)
30 changes: 9 additions & 21 deletions Runtime/Scripts/BeaconSDK/BeaconConnection.jslib
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
mergeInto(LibraryManager.library, {
JsSetNetwork: function(network, rpc){
SetNetwork(UTF8ToString(network), UTF8ToString(rpc));
JsInitWallet: function(network, rpc, walletProvider){
InitWalletProvider(UTF8ToString(network), UTF8ToString(rpc), UTF8ToString(walletProvider))
},

JsConnectAccount: function(){
ConnectAccount();
WalletProvider.ConnectAccount();
},

JsGetActiveAccountAddress: function(){
var returnStr = GetActiveAccountAddress();
var returnStr = WalletProvider.GetActiveAccountAddress();
var bufferSize = lengthBytesUTF8(returnStr) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(returnStr, buffer, bufferSize);
return buffer;
},

JsSwitchAccounts: function (){
SwitchAccounts();
},

JsRemovePeer: function (){
RemovePeer();
},

JsSendMutezAsString: function (amount, address){
SendMutez(UTF8ToString(amount), UTF8ToString(address));
JsDisconnectAccount: function (){
WalletProvider.DisconnectAccount();
},

JsSendContractCall: function (destination, amount, entryPoint, parameter){
SendContract(UTF8ToString(destination), UTF8ToString(amount), UTF8ToString(entryPoint), UTF8ToString(parameter));
},

JsReset: function (){
Reset();
WalletProvider.SendContract(UTF8ToString(destination), UTF8ToString(amount), UTF8ToString(entryPoint), UTF8ToString(parameter));
},

JsSignPayload: function (signingType, payload){
SignPayload(signingType, UTF8ToString(payload));
WalletProvider.SignPayload(signingType, UTF8ToString(payload));
}
});
17 changes: 5 additions & 12 deletions Runtime/Scripts/BeaconSDK/BeaconConnectorDotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Scripts.BeaconSDK;
using Scripts.Helpers;
using Scripts.Tezos;
using Scripts.Tezos.Wallet;
using UnityEngine;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using Logger = Scripts.Helpers.Logger;
Expand Down Expand Up @@ -67,7 +68,7 @@ public async void ConnectAccount()
_walletMessageReceiver.OnAccountConnected,
new JObject
{
["account"] = new JObject
["accountInfo"] = new JObject
{
["address"] = activeAccountPermissions.Address,
["publicKey"] = activeAccountPermissions.PublicKey
Expand All @@ -82,19 +83,15 @@ public async void ConnectAccount()

public string GetActiveAccountAddress() => BeaconDappClient?.GetActiveAccount()?.Address ?? string.Empty;

public void RequestHandshake()
{
}

public void DisconnectAccount()
{
BeaconDappClient.RemoveActiveAccounts();
var pairingRequestQrData = BeaconDappClient.GetPairingRequestInfo();
_walletMessageReceiver.OnHandshakeReceived(pairingRequestQrData);
UnityMainThreadDispatcher.Enqueue(_walletMessageReceiver.OnAccountDisconnected, string.Empty);
}

public void SetNetwork(string network, string rpc)
public void InitWalletProvider(string network, string rpc, WalletProviderType walletProviderType)
{
_network = network;
_rpc = rpc;
Expand Down Expand Up @@ -192,10 +189,6 @@ public void RequestTezosSignPayload(SignPayloadType signingType, string payload)
{
BeaconDappClient.RequestSign(NetezosExtensions.GetPayloadString(signingType, payload), signingType);
}

public void RequestTezosBroadcast(string signedTransaction, string networkName = "", string networkRPC = "")
{
}

#endregion

Expand Down Expand Up @@ -226,7 +219,7 @@ private async void OnBeaconDappClientMessageReceived(object sender, BeaconMessag
_walletMessageReceiver.OnAccountConnected, //permissionResponse.PublicKey);
new JObject
{
["account"] = new JObject
["accountInfo"] = new JObject
{
["address"] = PubKey.FromBase58(permissionResponse.PublicKey).Address,
["publicKey"] = permissionResponse.PublicKey
Expand Down
Loading

0 comments on commit 4be4f8a

Please sign in to comment.