Skip to content

Commit

Permalink
Add pure JavaScript version of the lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
barinbritva committed Jul 15, 2024
1 parent 4581326 commit 600dde0
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- id: get-package
run: |
PACKAGE_NAME=$(echo ${GITHUB_REF#refs/tags/} | cut -d- -f1)
ALLOWED_PACKAGES=("phaser" "cocos")
ALLOWED_PACKAGES=("phaser" "cocos" "vanilla")
if [[ " ${ALLOWED_PACKAGES[@]} " =~ " ${PACKAGE_NAME} " ]]; then
echo "::set-output name=package::${PACKAGE_NAME}"
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TON blockchain bindings and utilities for game engines:
* [Phaser](https://phaser.io)
* [Cocos](https://www.cocos.com/en)
* Vanilla JavaScript

# Getting started
Installation:
Expand All @@ -12,6 +13,9 @@ npm install --save @ton/phaser-sdk@beta

# for Cocos
npm install --save @ton/cocos-sdk@beta

# for Cocos
npm install --save @ton/vanilla-sdk@beta
```

Creating GameFi instance:
Expand Down Expand Up @@ -43,6 +47,12 @@ This can be used for:
* Watch the wallet state and reflect it on the game UI
* Restore connection with previously connected user wallet after app reloads

# What SDK should I use?

Engine specific features can be included to related SDKs. For example, `phaser-sdk` has build-it UI for connecting wallet. There is almost no differences between SDKs features right now.

Start with SDK of related engine if you use one. Use `@ton/vanilla-sdk` otherwise.

# GameFi methods & props
`GameFi` static methods:

Expand Down
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"node": ">=18.0.0",
"npm": ">=9.0.0"
},
"workspaces": ["packages/phaser", "packages/cocos"],
"workspaces": ["packages/phaser", "packages/cocos", "packages/vanilla"],
"scripts": {
"check-types": "tsc --noEmit",
"typedoc": "typedoc --out docs packages/phaser/src/index.ts packages/cocos/src/index.ts",
"typedoc": "typedoc --out docs packages/phaser/src/index.ts packages/cocos/src/index.ts packages/vanilla/src/index.ts",
"lint": "prettier --check \"./**/*.{js,jsx,ts,tsx,json,yml}\""
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/vanilla/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# phaser-sdk

TON blockchain bindings and utilities for any JavaScript project.

# Documentation

Please read the documentation in the official [repository](https://github.com/ton-org/game-engines-sdk).
17 changes: 17 additions & 0 deletions packages/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@ton/vanilla-sdk",
"version": "0.0.1-beta.1",
"files": ["./dist"],
"main": "dist/vanilla/src/index.js",
"types": "dist/vanilla/src/index.d.ts",
"scripts": {
"dev": "tsc -p tsconfig.dev.json --watch",
"build": "tsc"
},
"dependencies": {
"@tonconnect/ui": "^2.0.6",
"@ton/ton": "^13.9.0",
"@orbs-network/ton-access": "^2.3.3",
"@ton-community/assets-sdk": "~0.0.4"
}
}
11 changes: 11 additions & 0 deletions packages/vanilla/src/game-fi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {GameFiBase, GameFiInitializationParams} from '../../common/game-fi';

export class GameFi extends GameFiBase {
/**
* Setups and creates GameFi instance.
* The instance provides all the needed functionality via various methods.
*/
public static async create(params: GameFiInitializationParams = {}): Promise<GameFi> {
return new GameFi(await GameFi.createDependencies(params));
}
}
5 changes: 5 additions & 0 deletions packages/vanilla/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from '../../common/content-resolver';
export * from '../../common/external';
export * from '../../common/game-fi';
export * from '../../common/interfaces';
export * from './game-fi';
3 changes: 3 additions & 0 deletions packages/vanilla/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["./tsconfig.json", "../../tsconfig.dev.json"]
}
7 changes: 7 additions & 0 deletions packages/vanilla/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["./src"]
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
// Optimizations
"skipLibCheck": true
},
"include": ["./packages"]
"include": ["./packages"],
"exclude": ["node_modules", "./packages/**/dist"]
}

0 comments on commit 600dde0

Please sign in to comment.