From 80abff97c25779d5508fb1d20bf89a18a1b63227 Mon Sep 17 00:00:00 2001 From: chaitanyapotti Date: Wed, 11 Oct 2023 00:49:55 +0800 Subject: [PATCH 1/3] replace legacy sendAsync with request --- src/services/ProviderTransport.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/services/ProviderTransport.ts b/src/services/ProviderTransport.ts index 8087ab7b1..b5eff481c 100644 --- a/src/services/ProviderTransport.ts +++ b/src/services/ProviderTransport.ts @@ -27,10 +27,20 @@ export interface JRPCResponse extends JRPCBase { } export type SendCallBack = (err: any, providerRes: U) => void; +export type Maybe = T | Partial | null | undefined; + +export interface RequestArguments { + method: string; + params?: T; +} export interface SafeEventEmitterProvider { sendAsync: (req: JRPCRequest) => Promise; - send: (req: JRPCRequest, callback: SendCallBack) => void; + send: ( + req: JRPCRequest, + callback: SendCallBack> + ) => void; + request: (req: RequestArguments) => Promise>; } class ProviderTransport extends Transport { @@ -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 + const result = await this.provider.request( + (data.request as IJSONRPCRequest) as RequestArguments ); const jsonrpcResponse = { id: data.request.id, From 228aacf4b0202de9aafd77c924604bd500aa56b2 Mon Sep 17 00:00:00 2001 From: gyroflaw <83718263+gyroflaw@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:52:48 +0900 Subject: [PATCH 2/3] bump version and update changelog --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d802186d..a3f00c4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package-lock.json b/package-lock.json index c139e1e40..c42b25a74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "casper-js-sdk", - "version": "2.15.1", + "version": "2.15.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "casper-js-sdk", - "version": "2.15.1", + "version": "2.15.3", "license": "Apache 2.0", "dependencies": { "@ethersproject/bignumber": "^5.0.8", diff --git a/package.json b/package.json index 6eb5f83c6..dc7696979 100644 --- a/package.json +++ b/package.json @@ -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", From 93ed3a67d9d38bf486e391ed61c5b3a059b644f8 Mon Sep 17 00:00:00 2001 From: gyroflaw <83718263+gyroflaw@users.noreply.github.com> Date: Mon, 16 Oct 2023 22:02:11 +0900 Subject: [PATCH 3/3] fix mock provider --- e2e/nctl/Provider.setup.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e/nctl/Provider.setup.ts b/e2e/nctl/Provider.setup.ts index 2d24033c3..ceec70bcb 100644 --- a/e2e/nctl/Provider.setup.ts +++ b/e2e/nctl/Provider.setup.ts @@ -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'); }; @@ -107,7 +107,7 @@ export class MockProvider { this.client = new CasperClient(rpcTarget); } - async sendAsync(req: JRPCRequest): Promise { + async request(req: JRPCRequest): Promise { // 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. @@ -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): Promise { + return this.request(req); + } + // currently we only use sendAsync in provider transport, so we live it unimplemented here. send(_: JRPCRequest, __: SendCallBack): void { return;