Skip to content

Commit

Permalink
fix: wallet address
Browse files Browse the repository at this point in the history
  • Loading branch information
RSamaium committed Jan 28, 2024
1 parent e6a1237 commit 4f95fa5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 19 deletions.
7 changes: 7 additions & 0 deletions packages/plugins/web3/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PlayerWeb3Manager } from './src/server/web3manager'

declare module '@rpgjs/server' {
export interface RpgPlayer {
web3: PlayerWeb3Manager
}
}
1 change: 1 addition & 0 deletions packages/plugins/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "",
"main": "src/index.ts",
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
6 changes: 0 additions & 6 deletions packages/plugins/web3/src/server/mmorpg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { RpgServer, RpgModule, RpgPlayer } from '@rpgjs/server'
import AuthModule from '@rpgjs/auth'
import { PlayerWeb3Manager } from './web3manager'

declare module '@rpgjs/server' {
export interface RpgPlayer {
web3: PlayerWeb3Manager
}
}

// @ts-ignore
@RpgModule<RpgServer>({
imports: [AuthModule],
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/web3/src/server/web3manager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
interface PlayerWeb3Options {
walletAdress: string;
address: string;
}

export class PlayerWeb3Manager {
public readonly walletAdress: string;

constructor({ walletAdress }: PlayerWeb3Options) {
this.walletAdress = walletAdress;
constructor({ address }: PlayerWeb3Options) {
this.walletAdress = address;
}
}
29 changes: 29 additions & 0 deletions packages/plugins/web3/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "dist",
"strict": true,
"sourceMap": true,
"strictNullChecks": true,
"strictPropertyInitialization": false,
"moduleResolution": "node",
"esModuleInterop": true,
"removeComments": false,
"noUnusedParameters": false,
"noUnusedLocals": false,
"noImplicitThis": false,
"noImplicitAny": false,
"noImplicitReturns": false,
"declaration": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": ["node", "jest"]
},
"include": [
"src",
"index.d.ts",
"tests",
"node_modules/@rpgjs/compiler/types/*.d.ts"
]
}
2 changes: 1 addition & 1 deletion packages/sample3/rpg.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
modulesRoot = './src/game'

modules = [
'@rpgjs/web3',
'./main',
'@rpgjs/default-gui',
'@rpgjs/web3'
]

autostart = false
Expand Down
6 changes: 4 additions & 2 deletions packages/sample3/src/game/main/player.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Components, RpgPlayer } from '@rpgjs/server'

export default {
onConnected() {
console.log('ok')
onConnected(player: RpgPlayer) {
player.setComponentsTop(Components.text(player.web3.walletAdress))
}
}
23 changes: 16 additions & 7 deletions packages/sample3/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,36 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

"experimentalDecorators": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
"include": [
"src",
"node_modules/@rpgjs/**/*.d.ts",
"node_modules/@rpgjs/compiler/*.d.ts"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

0 comments on commit 4f95fa5

Please sign in to comment.