Skip to content

Commit

Permalink
can pin when packing (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
stobiewan authored Aug 12, 2022
1 parent 354623b commit 830ce46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions dist/src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ var PackBuilder = /** @class */ (function () {
this._pack = (0, pure_1.blank)(network);
(0, pure_1.assertValidPack)(this._pack);
}
PackBuilder.prototype.packType = function (t) {
PackBuilder.prototype.packType = function (t, pin) {
if (pin === void 0) { pin = false; }
return __awaiter(this, void 0, void 0, function () {
var cid, info;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, ipfs_util_1.putIpfsJson)(t.artifact)];
case 0: return [4 /*yield*/, (0, ipfs_util_1.putIpfsJson)(t.artifact, pin)];
case 1:
cid = (_a.sent()).toString();
info = (0, util_1.copy)(t);
Expand All @@ -80,13 +81,14 @@ var PackBuilder = /** @class */ (function () {
this._pack = (0, pure_1.addType)(this._pack, t);
return this;
};
PackBuilder.prototype.packObject = function (o, alsoPackType) {
PackBuilder.prototype.packObject = function (o, alsoPackType, pin) {
if (alsoPackType === void 0) { alsoPackType = true; }
if (pin === void 0) { pin = false; }
return __awaiter(this, void 0, void 0, function () {
var cid, info, pack;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, ipfs_util_1.putIpfsJson)(o.artifact)];
case 0: return [4 /*yield*/, (0, ipfs_util_1.putIpfsJson)(o.artifact, pin)];
case 1:
cid = (_a.sent()).toString();
info = (0, util_1.copy)(o);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etherpacks/dpack",
"version": "0.0.31",
"version": "0.0.32",
"author": "nikolai mushegian <[email protected]>",
"license": "GPL-3.0",
"main": "./dist/index.js",
Expand Down
8 changes: 4 additions & 4 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class PackBuilder {
assertValidPack(this._pack)
}

async packType (t: any): Promise<PackBuilder> {
const cid = (await putIpfsJson(t.artifact)).toString()
async packType (t: any, pin: boolean = false): Promise<PackBuilder> {
const cid = (await putIpfsJson(t.artifact, pin)).toString()
const info = copy(t)
info.artifact = { '/': cid }
this._pack = _addType(this._pack, info)
Expand All @@ -35,8 +35,8 @@ export class PackBuilder {
return this
}

async packObject (o: any, alsoPackType: boolean = true): Promise<PackBuilder> {
const cid = (await putIpfsJson(o.artifact)).toString()
async packObject (o: any, alsoPackType: boolean = true, pin: boolean = false): Promise<PackBuilder> {
const cid = (await putIpfsJson(o.artifact, pin)).toString()
const info = copy(o)
info.artifact = { '/': cid }

Expand Down

0 comments on commit 830ce46

Please sign in to comment.