Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DogLooksGood committed Jan 12, 2024
1 parent f9229c2 commit d67cba0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Work in progress, not ready to accept contributions yet.
| Package | Version | Description |
|-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| @race-foundation/borsh | [![NPM](https://img.shields.io/npm/v/@race-foundation/borsh?logo=npm)](https://www.npmjs.com/package/@race-foundation/borsh) | A borsh implementation with decorators support |
| @race-fonudation/sdk-core | [![NPM](https://img.shields.io/npm/v/@race-foundation/sdk-core?logo=npm)](https://www.npmjs.com/package/@race-foundation/sdk-core) | SDK for RACE Protocol |
| @race-fonudation/sdk-solana | [![NPM](https://img.shields.io/npm/v/@race-foundation/sdk-core?logo=npm)](https://www.npmjs.com/package/@race-foundation/sdk-solana) | SDK integration for Solana blockchain |
| @race-fonudation/sdk-facade | [![NPM](https://img.shields.io/npm/v/@race-foundation/sdk-core?logo=npm)](https://www.npmjs.com/package/@race-foundation/sdk-facade) | SDK integration for local facade server |
| @race-foundation/sdk-core | [![NPM](https://img.shields.io/npm/v/@race-foundation/sdk-core?logo=npm)](https://www.npmjs.com/package/@race-foundation/sdk-core) | SDK for RACE Protocol |
| @race-foundation/sdk-solana | [![NPM](https://img.shields.io/npm/v/@race-foundation/sdk-core?logo=npm)](https://www.npmjs.com/package/@race-foundation/sdk-solana) | SDK integration for Solana blockchain |
| @race-foundation/sdk-facade | [![NPM](https://img.shields.io/npm/v/@race-foundation/sdk-core?logo=npm)](https://www.npmjs.com/package/@race-foundation/sdk-facade) | SDK integration for local facade server |

## Rust

Expand Down
30 changes: 19 additions & 11 deletions js/sdk-core/src/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SubscribeEventParams,
ConnectionSubscription,
BroadcastFrame,
SubmitMessageParams,
} from './connection';
import { GameContext } from './game-context';
import { GameContextSnapshot } from './game-context-snapshot';
Expand Down Expand Up @@ -154,6 +155,17 @@ export class BaseClient {
}
}

/**
* Submit a message.
*/
async submitMessage(content: string): Promise<void> {
const connState = await this.__connection.submitMessage(new SubmitMessageParams({
content
}));
if (connState !== undefined && this.__onConnectionState !== undefined) {
this.__onConnectionState(connState);
}
}
/**
* Connect to the transactor and retrieve the event stream.
*/
Expand Down Expand Up @@ -304,17 +316,13 @@ export class BaseClient {
if (this.__onConnectionState !== undefined) {
this.__onConnectionState('disconnected')
}
console.groupCollapsed('Disconnected, try reset state and context');
try {
const gameAccount = await this.__getGameAccount();
this.__gameContext = new GameContext(gameAccount);
const initAccount = InitAccount.createFromGameAccount(gameAccount, this.__gameContext.accessVersion, this.__gameContext.settleVersion);
this.__gameContext.applyCheckpoint(gameAccount.checkpointAccessVersion, this.__gameContext.settleVersion);
await this.__connection.connect(new SubscribeEventParams({ settleVersion: this.__gameContext.settleVersion }));
await this.__initializeState(initAccount);
} finally {
console.groupEnd();
}
console.log('Disconnected, try reset state and context');
const gameAccount = await this.__getGameAccount();
this.__gameContext = new GameContext(gameAccount);
const initAccount = InitAccount.createFromGameAccount(gameAccount, this.__gameContext.accessVersion, this.__gameContext.settleVersion);
this.__gameContext.applyCheckpoint(gameAccount.checkpointAccessVersion, this.__gameContext.settleVersion);
await this.__connection.connect(new SubscribeEventParams({ settleVersion: this.__gameContext.settleVersion }));
await this.__initializeState(initAccount);
} else if (state === 'connected') {
if (this.__onConnectionState !== undefined) {
this.__onConnectionState('connected')
Expand Down
1 change: 1 addition & 0 deletions transactor/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async fn submit_message(
let (game_addr, SubmitMessageParams { content }, sig) = parse_params(params, &context)?;

let sender = sig.signer;
info!("Player message, {}: {}", sender, content);
let message = Message { content, sender };

context
Expand Down

0 comments on commit d67cba0

Please sign in to comment.