{"_id":"@ar-packages-changeit/abstract-box-selection","_rev":"2-bf18a8c06bc71a52eb1110dbb9a0b4ca","name":"@ar-packages-changeit/abstract-box-selection","dist-tags":{"develop":"1.0.2-7bc25721","latest":"1.0.2"},"versions":{"1.0.2-7bc25721":{"name":"@ar-packages-changeit/abstract-box-selection","version":"1.0.2-7bc25721","author":{"name":"Rosen Team"},"license":"MIT","_id":"@ar-packages-changeit/abstract-box-selection@1.0.2-7bc25721","maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"homepage":"https://github.com/rosen-bridge/selection#readme","bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"dist":{"shasum":"c2fa2e4fcf715c256581588fcc9dbbe1e342f890","tarball":"https://registry.npmjs.org/@ar-packages-changeit/abstract-box-selection/-/abstract-box-selection-1.0.2-7bc25721.tgz","fileCount":9,"integrity":"sha512-VKkiq8Kg+IPjMu5BqS4Gw/lmIWLijEuz2ITDsgA7gpSuda6vulGi5Dk1KxRqRhGpEOAeLukbGbY9r7gmR+wfcQ==","signatures":[{"sig":"MEYCIQC+hZZrPh6hqHTAK9nEizs/vl3WFTmvIDHFe/ObzsfkBQIhAOGWmv7goHbFATjRIylEcVRVJ1drvIpycfvOFfhqcoWV","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37751},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=22.18.0"},"gitHead":"7bc25721f554f9b4be8b1c1599b621955c6dbb6c","scripts":{"lint":"eslint --fix . && npm run prettify","test":"NODE_OPTIONS='--import tsx' vitest","build":"tsc --build tsconfig.build.json","clean":"rimraf dist && rimraf tsconfig.build.tsbuildinfo","release":"npm run clean && npm run build && npm run test -- --run && npm publish --access public","coverage":"npm run test -- --run --coverage","prettify":"prettier --write . --ignore-path ../../.gitignore","lint:check":"eslint . && npm run prettify:check","type-check":"tsc --noEmit","prettify:check":"prettier --check . --ignore-path ../../.gitignore"},"_npmUser":{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"},"repository":{"url":"git+https://github.com/rosen-bridge/selection.git","type":"git"},"_npmVersion":"11.6.2","description":"A Typescript package for general UTxO selection","directories":{},"_nodeVersion":"22.18.0","dependencies":{"@rosen-bridge/abstract-logger":"^3.0.1","@rosen-bridge/selection-types":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.5","vitest":"^3.1.4","@vitest/coverage-istanbul":"^3.1.4"},"_npmOperationalInternal":{"tmp":"tmp/abstract-box-selection_1.0.2-7bc25721_1763557932950_0.2629576006948222","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@ar-packages-changeit/abstract-box-selection","version":"1.0.2","description":"A Typescript package for general UTxO selection","repository":{"type":"git","url":"git+https://github.com/rosen-bridge/selection.git"},"license":"MIT","author":{"name":"Rosen Team"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc --build tsconfig.build.json","clean":"rimraf dist && rimraf tsconfig.build.tsbuildinfo","coverage":"npm run test -- --run --coverage","lint":"eslint --fix . && npm run prettify","lint:check":"eslint . && npm run prettify:check","prettify":"prettier --write . --ignore-path ../../.gitignore","prettify:check":"prettier --check . --ignore-path ../../.gitignore","release":"npm run clean && npm run build && npm run test -- --run && npm publish --access public","test":"NODE_OPTIONS='--import tsx' vitest","type-check":"tsc --noEmit"},"dependencies":{"@rosen-bridge/abstract-logger":"^3.0.1","@rosen-bridge/selection-types":"^1.0.1"},"devDependencies":{"@vitest/coverage-istanbul":"^3.1.4","tsx":"^4.20.5","vitest":"^3.1.4"},"engines":{"node":">=22.18.0"},"gitHead":"fc55a043c8019b3f18d0c1a033f12d43a4693458","_id":"@ar-packages-changeit/abstract-box-selection@1.0.2","bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"homepage":"https://github.com/rosen-bridge/selection#readme","_nodeVersion":"22.18.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-xxzoxhLzxavDbIDFtgAdQorHdW4sUCgH8N5SiR2SYwRT2h/7aVVQVHl8Uss9YSV3B307t9qj+y8dBJbsJzVMFw==","shasum":"ab67b10135f3417bc38aaf6f4b73074e4b82ebef","tarball":"https://registry.npmjs.org/@ar-packages-changeit/abstract-box-selection/-/abstract-box-selection-1.0.2.tgz","fileCount":10,"unpackedSize":90663,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDLaFpbopBIoXUG7/GtNSKUbTRvRGbCtOScf7IqLiuD7AIgRv5qmknSLPSW2i+ylBPnXZLqQQvRpQ0G0LmkAMZ2e/w="}]},"_npmUser":{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"},"directories":{},"maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/abstract-box-selection_1.0.2_1763558449311_0.454438685761811"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-19T13:12:12.813Z","modified":"2025-11-19T13:20:49.705Z","1.0.2-7bc25721":"2025-11-19T13:12:13.137Z","1.0.2":"2025-11-19T13:20:49.504Z"},"bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"author":{"name":"Rosen Team"},"license":"MIT","homepage":"https://github.com/rosen-bridge/selection#readme","repository":{"type":"git","url":"git+https://github.com/rosen-bridge/selection.git"},"description":"A Typescript package for general UTxO selection","maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"readme":"# @rosen-bridge/abstract-box-selection\n\n## Table of contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n\n## Introduction\n\nA Typescript package for general UTxO selection, providing an abstract base class for implementing box selection algorithms in blockchain systems.\n\n## Installation\n\nnpm:\n\n```sh\nnpm i @rosen-bridge/abstract-box-selection\n```\n\nyarn:\n\n```sh\nyarn add @rosen-bridge/abstract-box-selection\n```\n\n## Usage\n\nHere's a basic example of how to use this package:\n\n```typescript\nimport {\n  AbstractBoxSelection,\n  AssetBalance,\n  TokenInfo,\n} from '@rosen-bridge/abstract-box-selection';\nimport { DummyLogger } from '@rosen-bridge/abstract-logger';\n\n// Define your box type\ninterface MyBox {\n  id: string;\n  value: bigint;\n  tokens: Array<TokenInfo>;\n}\n\n// Implement the abstract class\nexport class MyBoxSelection extends AbstractBoxSelection<MyBox> {\n  constructor() {\n    super(new DummyLogger());\n  }\n\n  getBoxInfo(box: MyBox): BoxInfo {\n    return {\n      id: box.id,\n      assets: {\n        nativeToken: box.value,\n        tokens: box.tokens,\n      },\n    };\n  }\n}\n\n// Usage example\nconst selector = new MyBoxSelection();\n\nconst requiredAssets: AssetBalance = {\n  nativeToken: 1000000n,\n  tokens: [\n    { id: 'token1', value: 100n },\n    { id: 'token2', value: 200n },\n  ],\n};\n\nconst forbiddenBoxIds = ['box1', 'box2'];\nconst trackMap = new Map<string, MyBox>();\nconst boxes: MyBox[] = [\n  // ... your boxes\n];\n\nconst result = await selector.getCoveringBoxes(\n  requiredAssets,\n  forbiddenBoxIds,\n  trackMap,\n  boxes.values(),\n);\n\nif (result.covered) {\n  console.log('Selected boxes:', result.boxes);\n  console.log('Additional assets:', result.additionalAssets);\n} else {\n  console.log('Could not cover requirements');\n}\n```\n\nThe package provides a flexible foundation for implementing specific selection strategies while handling common concerns like:\n\n- Asset balance tracking\n- Box selection with constraints\n- Fee estimation\n- Token aggregation\n- Change box creation\n- Logger integration\n\nYou can extend the `AbstractBoxSelection` class to implement your specific selection strategy while leveraging the built-in functionality for common operations.\n","readmeFilename":"README.md"}