Skip to content

Commit

Permalink
move Collection model to common package
Browse files Browse the repository at this point in the history
  • Loading branch information
capt-nemo429 committed Jun 24, 2023
1 parent 3e1df5a commit 92d8477
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/bright-plums-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fleet-sdk/common": patch
"@fleet-sdk/core": patch
---

Move `Collection` model from core to common package.
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./utils";
export * from "./types";
export * from "./models";
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isDefined, OneOrMore } from "@fleet-sdk/common";
import { OneOrMore } from "../types";
import { isDefined } from "../utils";

export type CollectionAddOptions = { index?: number };

Expand Down
1 change: 1 addition & 0 deletions packages/common/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./collection";
3 changes: 1 addition & 2 deletions packages/core/src/models/collections/inputsCollection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Amount, Box, BoxId, OneOrMore } from "@fleet-sdk/common";
import { Amount, Box, BoxId, Collection, OneOrMore } from "@fleet-sdk/common";
import { isDefined } from "@fleet-sdk/common";
import { DuplicateInputError, NotFoundError } from "../../errors";
import { ErgoUnsignedInput } from "../ergoUnsignedInput";
import { Collection } from "./collection";

export class InputsCollection extends Collection<ErgoUnsignedInput, Box<Amount>> {
constructor();
Expand Down
11 changes: 9 additions & 2 deletions packages/core/src/models/collections/outputsCollection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { _0n, BoxSummary, isDefined, isUndefined, OneOrMore, some } from "@fleet-sdk/common";
import {
_0n,
BoxSummary,
Collection,
isDefined,
isUndefined,
OneOrMore,
some
} from "@fleet-sdk/common";
import { OutputBuilder } from "../../builder/outputBuilder";
import { SelectionTarget } from "../../builder/selector/boxSelector";
import { NotFoundError } from "../../errors";
import { Collection } from "./collection";

export class OutputsCollection extends Collection<OutputBuilder, OutputBuilder> {
constructor(outputs?: OneOrMore<OutputBuilder>) {
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/models/collections/tokensCollection.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Amount, isDefined, isUndefined, OneOrMore, TokenAmount, TokenId } from "@fleet-sdk/common";
import {
Amount,
Collection,
CollectionAddOptions,
isDefined,
isUndefined,
OneOrMore,
TokenAmount,
TokenId
} from "@fleet-sdk/common";
import { ensureBigInt } from "@fleet-sdk/common";
import { NotFoundError } from "../../errors";
import { InsufficientTokenAmount } from "../../errors/insufficientTokenAmount";
import { MaxTokensOverflow } from "../../errors/maxTokensOverflow";
import { Collection, CollectionAddOptions } from "./collection";

export const MAX_TOKENS_PER_BOX = 120;

Expand Down

0 comments on commit 92d8477

Please sign in to comment.