Skip to content

Commit

Permalink
Merge pull request #14 from provenance-io/aj/perms-list
Browse files Browse the repository at this point in the history
Show permissiions list correctly
  • Loading branch information
webbushka authored Aug 1, 2022
2 parents 7618ee5 + 7f53cff commit c0096df
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
31 changes: 22 additions & 9 deletions src/services/grpc-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
} from '../proto/provenance/msgfees/v1/query_pb';
import { QueryClient as MsgFeeQueryClient } from '../proto/provenance/msgfees/v1/query_grpc_web_pb';
import { ServiceClient as TxServiceClient } from '../proto/cosmos/tx/v1beta1/service_grpc_web_pb';
import { BroadcastTxRequest, BroadcastTxResponse } from '../proto/cosmos/tx/v1beta1/service_pb';
import {
BroadcastTxRequest,
BroadcastTxResponse,
} from '../proto/cosmos/tx/v1beta1/service_pb';

export const calculateTxFees = (
serviceAddress: string,
Expand Down Expand Up @@ -81,17 +84,27 @@ export const getAccountInfo = (
});
};

export const broadcastTx = async (serviceAddress: string, request: BroadcastTxRequest): Promise<BroadcastTxResponse.AsObject> => {
export const broadcastTx = async (
serviceAddress: string,
request: BroadcastTxRequest
): Promise<BroadcastTxResponse.AsObject> => {
if (!serviceAddress) throw new Error('GrpcService requires serviceAddress');
console.log('Initiating broadcastTx');
const txClient = new TxServiceClient(serviceAddress, null);
return new Promise((resolve, reject) => {
txClient.broadcastTx(request, null, (error: ServerError, response: BroadcastTxResponse) => {
if (error) reject(new Error(`broadcastTx error: Code: ${error.code} Message: ${error.message}`));
else {
console.log(JSON.stringify(response.toObject()));
resolve(response.toObject());
txClient.broadcastTx(
request,
null,
(error: ServerError, response: BroadcastTxResponse) => {
if (error)
reject(
new Error(
`broadcastTx error: Code: ${error.code} Message: ${error.message}`
)
);
else {
resolve(response.toObject());
}
}
});
);
});
};
12 changes: 11 additions & 1 deletion src/services/message-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
} from '../proto/cosmos/tx/v1beta1/service_pb';
import { MsgAddMarkerRequest } from '../proto/provenance/marker/v1/tx_pb';
import { MarkerStatus, MarkerType } from '../proto/provenance/marker/v1/marker_pb';
import { Access } from '../proto/provenance/marker/v1/accessgrant_pb';

export type GenericDisplay = { [key: string]: any };

Expand Down Expand Up @@ -279,7 +280,6 @@ export const buildBroadcastTxRequest = ({
feeDenom = 'nhash',
gasEstimate,
}: buildBroadcastTxRequestProps): BroadcastTxRequest => {
console.log(`Building tx request for broadcast`);
const signerInfo = buildSignerInfo(account, wallet.publicKey);
const authInfo = buildAuthInfo(signerInfo, feeDenom, feeEstimate, gasEstimate);
const txBody = buildTxBody(msgAny, memo);
Expand Down Expand Up @@ -338,6 +338,16 @@ export const unpackDisplayObjectFromWalletMessage = (
(message as MsgAddMarkerRequest).getMarkerType()
),
status: getKey(MarkerStatus, (message as MsgAddMarkerRequest).getStatus()),
accessListList: (message as MsgAddMarkerRequest)
.getAccessListList()
.map((list) => {
return {
address: list.getAddress(),
permissionsList: list
.getPermissionsList()
.map((perm) => getKey(Access, perm)),
};
}),
};
default:
return {
Expand Down

0 comments on commit c0096df

Please sign in to comment.