Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/kukai embed #71

Merged
merged 20 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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