postchain-client
Version:
Client library for accessing a Postchain node through REST.
36 lines • 1.84 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as pc from "../../index";
import { BlockchainUrlUndefinedException } from "../blockchainClient/errors";
/**
* @deprecated Use the function createClient instead.
* Provides postchain clients that can be used to communicate with dapps within the chromia network
* @param chain0BRID brid of chain0
* @param rest rest client configured to node running chain0
*/
export function chromiaClientProvider(chain0BRID, rest) {
const chain0Client = pc.gtxClient.createClient(rest, chain0BRID, []);
return {
blockchainConnection: function (dappBRID) {
return __awaiter(this, void 0, void 0, function* () {
const queryObject = {
type: "cm_get_blockchain_api_urls",
blockchain_rid: dappBRID,
};
const baseUrls = yield chain0Client.query(queryObject);
if (!baseUrls.length) {
throw new BlockchainUrlUndefinedException(dappBRID);
}
return pc.restClient.createRestClient(baseUrls, dappBRID);
});
},
};
}
//# sourceMappingURL=chromiaClientProvider.js.map