dingojs
Version:
A simple but feature filled interface between Filecoin's Lotus client and JS.
59 lines • 2.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = __importDefault(require("./core"));
const network_1 = require("./network");
/** @internal */
class DClient extends core_1.default {
constructor(rpc, tokenStr) {
super(rpc, tokenStr);
}
balance(path) {
return network_1.postJson('Filecoin.ClientImport', this.bundle, [{ Path: path, IsCAR: false }]);
}
listImports(path) {
return this.postSimpleJson('Filecoin.ClientListImports');
}
genCar(path) {
return network_1.postJson('Filecoin.ClientGenCar', this.bundle, [{ Path: path, IsCAR: true }, `${path}.car`]);
}
dealSize(CID) {
return network_1.postJson('Filecoin.ClientDealSize', this.bundle, [{ '/': CID }]);
}
dealPieceCID(CID) {
return network_1.postJson('Filecoin.ClientDealPieceCID', this.bundle, [{ '/': CID }]);
}
getDealStatus(id) {
return network_1.postJson('Filecoin.ClientGetDealStatus', this.bundle, [id]);
}
getDealUpdates(path) {
return this.postSimpleJson('Filecoin.ClientGetDealUpdates');
}
listDeals(path) {
return this.postSimpleJson('Filecoin.ClientListDeals');
}
startDeal(CID, wallet, miner, pieceCID, size, price, duration) {
const dealDetails = {
Data: {
TransferType: 'graphsync',
Root: { '/': CID },
PieceCid: null,
PieceSize: Number(size),
RawBlockSize: 0,
},
Wallet: wallet,
Miner: miner,
EpochPrice: String(price || 1000),
MinBlocksDuration: duration || 518400,
ProviderCollateral: '0',
DealStartEpoch: -1,
FastRetrieval: true,
VerifiedDeal: false
};
return network_1.postJson('Filecoin.ClientStartDeal', this.bundle, [dealDetails]);
}
}
exports.default = DClient;
//# sourceMappingURL=client.js.map