Skip to content

Commit

Permalink
fix(dapi): getTotalCreditsOnPlatform missing parts (#2059)
Browse files Browse the repository at this point in the history
Co-authored-by: owl352 <[email protected]>
  • Loading branch information
pshenmic and owl352 authored Aug 14, 2024
1 parent e8fc49e commit 7accd40
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const {
GetIdentityNonceResponse: PBJSGetIdentityNonceResponse,
GetIdentityKeysRequest: PBJSGetIdentityKeysRequest,
GetIdentityKeysResponse: PBJSGetIdentityKeysResponse,
GetTotalCreditsInPlatformRequest: PBJSGetTotalCreditsInPlatformRequest,
GetTotalCreditsInPlatformResponse: PBJSGetTotalCreditsInPlatformResponse,
},
},
},
Expand All @@ -82,6 +84,7 @@ const {
GetIdentityContractNonceResponse: ProtocGetIdentityContractNonceResponse,
GetIdentityNonceResponse: ProtocGetIdentityNonceResponse,
GetIdentityKeysResponse: ProtocGetIdentityKeysResponse,
GetTotalCreditsInPlatformResponse: ProtocGetTotalCreditsInPlatformResponse,
} = require('./platform_protoc');

const getPlatformDefinition = require('../../../../lib/getPlatformDefinition');
Expand Down Expand Up @@ -172,6 +175,10 @@ class PlatformPromiseClient {
this.client.getIdentityKeys.bind(this.client),
);

this.client.getTotalCreditsInPlatform = promisify(
this.client.getTotalCreditsInPlatform.bind(this.client),
);

this.protocolVersion = undefined;
}

Expand Down Expand Up @@ -690,6 +697,35 @@ class PlatformPromiseClient {
);
}

getTotalCreditsInPlatform(
getTotalCreditsInPlatformRequest,
metadata = {},
options = {},
) {
if (!isObject(metadata)) {
throw new Error('metadata must be an object');
}

return this.client.getTotalCreditsInPlatform(
getTotalCreditsInPlatformRequest,
convertObjectToMetadata(metadata),
{
interceptors: [
jsonToProtobufInterceptorFactory(
jsonToProtobufFactory(
ProtocGetTotalCreditsInPlatformResponse,
PBJSGetTotalCreditsInPlatformResponse,
),
protobufToJsonFactory(
PBJSGetTotalCreditsInPlatformRequest,
),
),
],
...options,
},
);
}

/**
* @param {string} protocolVersion
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgra
const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getIdentityContractNonceFactory');
const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory');
const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory');
const getTotalCreditsInPlatformFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory');

class PlatformMethodsFacade {
/**
Expand All @@ -36,6 +37,7 @@ class PlatformMethodsFacade {
this.getIdentityContractNonce = getIdentityContractNonceFactory(grpcTransport);
this.getIdentityNonce = getIdentityNonceFactory(grpcTransport);
this.getIdentityKeys = getIdentityKeysFactory(grpcTransport);
this.getTotalCreditsInPlatform = getTotalCreditsInPlatformFactory(grpcTransport);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GetTotalCreditsInPlatformResponse extends AbstractResponse {
*/
static createFromProto(proto) {
// eslint-disable-next-line
const totalCreditsInPlatform = proto.getV0().getTotalCreditsInPlatform();
const totalCreditsInPlatform = proto.getV0().getCredits();
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(
proto,
);
Expand Down

0 comments on commit 7accd40

Please sign in to comment.