Skip to content

Commit

Permalink
Merge pull request #374 from casper-ecosystem/chore/changelog-2.15.3
Browse files Browse the repository at this point in the history
Bump version and Update Changelog for 2.15.3 release
  • Loading branch information
bradjohnl authored Oct 16, 2023
2 parents 679fe77 + 93ed3a6 commit a6ddf98
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Removed
-->

## [2.15.3] - 2023-10-16

### Fixed

- replace legacy `sendAsync` with `request` ([#373](https://github.com/casper-ecosystem/casper-js-sdk/pull/373))

[2.15.3]: https://github.com/casper-ecosystem/casper-js-sdk/compare/2.15.2...2.15.3

## [2.15.2] - 2023-8-4

### Fixed
Expand Down
10 changes: 7 additions & 3 deletions e2e/nctl/Provider.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const processDeploy = async (
req.params = DeployUtil.deployToJson(signedDeploy);
// const jrpcResult = await sendRpcRequestToChain(req, rpcTarget);
const jrpcResult = { deploy_hash: '0x123', rpcTarget };
return jrpcResult
return jrpcResult;
}
throw new Error('Failed to parse deploy');
};
Expand All @@ -107,7 +107,7 @@ export class MockProvider {
this.client = new CasperClient(rpcTarget);
}

async sendAsync(req: JRPCRequest<unknown>): Promise<any> {
async request(req: JRPCRequest<unknown>): Promise<any> {
// we are intercepting 'account_put_deploy' (ie. signing the deploy and then submitting the signed deploy
// to blockchain)
// for rest of rpc calls we are simply sending rpc call to blockchain and returning the result.
Expand All @@ -116,13 +116,17 @@ export class MockProvider {
} else {
try {
const jrpcResult = await sendRpcRequestToChain(req, this.rpcTarget);
return jrpcResult
return jrpcResult;
} catch (error) {
throw error;
}
}
}

async sendAsync(req: JRPCRequest<unknown>): Promise<any> {
return this.request(req);
}

// currently we only use sendAsync in provider transport, so we live it unimplemented here.
send(_: JRPCRequest<unknown>, __: SendCallBack<any>): void {
return;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "casper-js-sdk",
"version": "2.15.2",
"version": "2.15.3",
"license": "Apache 2.0",
"description": "SDK to interact with the Casper blockchain",
"homepage": "https://github.com/casper-ecosystem/casper-js-sdk#README.md",
Expand Down
16 changes: 13 additions & 3 deletions src/services/ProviderTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ export interface JRPCResponse<T> extends JRPCBase {
}

export type SendCallBack<U> = (err: any, providerRes: U) => void;
export type Maybe<T> = T | Partial<T> | null | undefined;

export interface RequestArguments<T> {
method: string;
params?: T;
}

export interface SafeEventEmitterProvider {
sendAsync: <T, U>(req: JRPCRequest<T>) => Promise<U>;
send: <T, U>(req: JRPCRequest<T>, callback: SendCallBack<U>) => void;
send: <T, U>(
req: JRPCRequest<T>,
callback: SendCallBack<JRPCResponse<U>>
) => void;
request: <T, U>(req: RequestArguments<T>) => Promise<Maybe<U>>;
}

class ProviderTransport extends Transport {
Expand All @@ -50,8 +60,8 @@ class ProviderTransport extends Transport {
const notifications = getNotifications(data);
const batch = getBatchRequests(data);
try {
const result = await this.provider.sendAsync(
(data.request as IJSONRPCRequest) as JRPCRequest<any>
const result = await this.provider.request(
(data.request as IJSONRPCRequest) as RequestArguments<any>
);
const jsonrpcResponse = {
id: data.request.id,
Expand Down

0 comments on commit a6ddf98

Please sign in to comment.