@atomichub/atomicassets 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-present pink.network and other contributors
4
+ Copyright (c) 2025-present AtomicHub (fork: @atomichub/atomicassets)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,12 @@
1
+ This package bundles a vendored IEEE 754 float parsing routine (used for
2
+ serializing float32/float64 values) derived from float.js by Andras Radics,
3
+ Copyright (C) 2017-2019 Andras Radics.
4
+
5
+ That code is licensed under the Apache License, Version 2.0. The full license
6
+ text ships with this package at licenses/Apache-2.0.txt and is also available
7
+ at http://www.apache.org/licenses/LICENSE-2.0.
8
+
9
+ The original source and its license header are available in this repository
10
+ at lib/float.js. The build step bundles that file into the published output
11
+ and strips source comments in the process, so this NOTICE preserves the
12
+ required attribution.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # @atomichub/atomicassets
2
+
3
+ JavaScript/TypeScript SDK for the [AtomicAssets](https://github.com/pinknetworkx/atomicassets-contract) NFT standard on Antelope (EOSIO) chains such as WAX. It reads NFT data through the AtomicAssets Explorer API or plain nodeos RPC, serializes and deserializes on-chain attribute data, and builds contract actions for signing with any transaction library. This is a maintained fork of the dormant `atomicassets` package by pink.network, updated for the v2 AtomicAssets contract.
4
+
5
+ The market-side companion package is [@atomichub/atomicmarket](https://github.com/atomicassets/atomicmarket-sdk).
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @atomichub/atomicassets
11
+ ```
12
+
13
+ Requires Node.js >= 20, or any modern browser or bundler. The package has zero runtime dependencies and ships CJS, ESM, and a browser IIFE bundle (`build/atomicassets.global.js`, global `atomicassets`).
14
+
15
+ ```ts
16
+ // ESM / TypeScript
17
+ import { ExplorerApi, RpcApi } from '@atomichub/atomicassets';
18
+
19
+ // CommonJS
20
+ const { ExplorerApi, RpcApi } = require('@atomichub/atomicassets');
21
+ ```
22
+
23
+ ## Quickstart
24
+
25
+ ### Read NFT data (Explorer API)
26
+
27
+ The Explorer API queries a hosted [eosio-contract-api](https://github.com/pinknetworkx/eosio-contract-api) instance. The built-in `fetch` is used unless you pass your own.
28
+
29
+ ```ts
30
+ import { ExplorerApi } from '@atomichub/atomicassets';
31
+
32
+ const api = new ExplorerApi('https://wax.api.atomicassets.io', 'atomicassets', {});
33
+
34
+ const asset = await api.getAsset('1099511627786');
35
+
36
+ const assets = await api.getAssets({ owner: 'someaccount1' }, 1, 20);
37
+ ```
38
+
39
+ `RpcApi` provides the same data through plain nodeos `get_table_rows` calls when no indexer is available.
40
+
41
+ ### Network endpoints
42
+
43
+ AtomicHub's public endpoints ship as presets, so a client for a supported network needs one call:
44
+
45
+ ```ts
46
+ import { explorerApiForNetwork, rpcApiForNetwork } from '@atomichub/atomicassets';
47
+
48
+ const api = explorerApiForNetwork('wax');
49
+ const rpc = rpcApiForNetwork('wax-testnet');
50
+ ```
51
+
52
+ Custom or self-hosted deployments still work through the plain constructors shown above.
53
+
54
+ ### Serialize and deserialize attribute data
55
+
56
+ AtomicAssets stores attribute data in a compact binary encoding. The API classes decode it for you; for manual work the codec is exported directly.
57
+
58
+ ```ts
59
+ import { ObjectSchema, serialize, deserialize } from '@atomichub/atomicassets';
60
+
61
+ const schema = ObjectSchema([
62
+ { name: 'name', type: 'string' },
63
+ { name: 'level', type: 'uint16' },
64
+ { name: 'tags', type: 'string[]' }
65
+ ]);
66
+
67
+ const encoded = serialize({ name: 'Dragon', level: 12, tags: ['fire'] }, schema);
68
+ const decoded = deserialize(encoded, schema);
69
+ // decoded deep-equals the input object
70
+ ```
71
+
72
+ ### Build contract actions
73
+
74
+ `ActionBuilder` is synchronous and returns authorization-free `{account, name, data}` objects, one method per contract action. Attach authorization yourself, or use `ActionGenerator`, which wraps the same builders and returns fully-authorized `EosioActionObject` arrays.
75
+
76
+ ```ts
77
+ import { ActionBuilder, createAttributeMap } from '@atomichub/atomicassets';
78
+
79
+ const builder = new ActionBuilder('atomicassets');
80
+
81
+ const immutableData = createAttributeMap(
82
+ { name: 'Dragon', level: 12 },
83
+ { name: 'string', level: 'uint16' }
84
+ );
85
+
86
+ const mint = builder.mintasset(
87
+ 'creatoracct1', // authorized_minter
88
+ 'mycollection', // collection_name
89
+ 'myschema', // schema_name
90
+ -1, // template_id (-1 for none)
91
+ 'receiveracct', // new_asset_owner
92
+ immutableData, // immutable_data
93
+ [], // mutable_data
94
+ [] // tokens_to_back
95
+ );
96
+ ```
97
+
98
+ The output plugs straight into signing libraries such as [WharfKit](https://wharfkit.com/):
99
+
100
+ ```ts
101
+ await session.transact({
102
+ actions: [{
103
+ ...mint,
104
+ authorization: [{ actor: 'creatoracct1', permission: 'active' }]
105
+ }]
106
+ });
107
+ ```
108
+
109
+ ## What's new in 2.0.0
110
+
111
+ - Zero runtime dependencies: native `BigInt` replaces bn.js and the built-in `fetch` replaces node-fetch (a custom `fetch` can still be injected).
112
+ - Dual CJS/ESM output with bundled type declarations, plus a browser IIFE build.
113
+ - v2 contract surface: schema-field media types (`setschematyp`), mutable template data (`createtempl2`, `settempldata`), the sync `ActionBuilder` alongside the authorized `ActionGenerator`, and typed table rows, action data payloads, and action names exported from the package root.
114
+ - Serialization codec with strict bounds checking and explicit error classes.
115
+ - Explorer query-parameter, enum, and response-object types are exported from the root; no deep `build/` imports needed.
116
+
117
+ ## Migrating from atomicassets 1.x
118
+
119
+ - Package name: `npm install @atomichub/atomicassets` and change imports from `'atomicassets'` to `'@atomichub/atomicassets'`.
120
+ - Deep imports such as `atomicassets/build/API/Explorer/Params` are replaced by root exports: `import { AssetsApiParams } from '@atomichub/atomicassets'`.
121
+ - `max_supply` and `template_id` are numbers where the contract ABI defines them as numeric; 64-bit id fields (asset ids, offer ids) remain strings.
122
+ - `AttributeMap` entries are strictly typed as `{ key, value: [type, value] }`; use `createAttributeMap` or `toAttributeMap` instead of hand-building entries. Decoding accepts both `{key, value}` and v2 `{first, second}` pairs.
123
+ - Node.js >= 20 is required.
124
+
125
+ ## Credits and license
126
+
127
+ Fork of [atomicassets-js](https://github.com/pinknetworkx/atomicassets-js) by pink.network. Maintained by AtomicHub.
128
+
129
+ MIT licensed; see [LICENSE](LICENSE) for the full text including the original pink.network copyright.