@obbyx/obyte 0.0.0-stage → 0.1.1
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 +21 -0
- package/README.md +15 -2
- package/dist/channel/definition.d.ts +38 -0
- package/dist/channel/definition.d.ts.map +1 -0
- package/dist/channel/definition.js +86 -0
- package/dist/channel/definition.js.map +1 -0
- package/dist/config/index.d.ts +31 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +33 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/amounts.d.ts +35 -0
- package/dist/core/amounts.d.ts.map +1 -0
- package/dist/core/amounts.js +94 -0
- package/dist/core/amounts.js.map +1 -0
- package/dist/core/errors.d.ts +16 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +18 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/networks.d.ts +34 -0
- package/dist/core/networks.d.ts.map +1 -0
- package/dist/core/networks.js +50 -0
- package/dist/core/networks.js.map +1 -0
- package/dist/core/result.d.ts +17 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/result.js +13 -0
- package/dist/core/result.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/index.d.ts +76 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +161 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/signing/signed-message.d.ts +47 -0
- package/dist/signing/signed-message.d.ts.map +1 -0
- package/dist/signing/signed-message.js +102 -0
- package/dist/signing/signed-message.js.map +1 -0
- package/dist/unit/exact-unit.d.ts +94 -0
- package/dist/unit/exact-unit.d.ts.map +1 -0
- package/dist/unit/exact-unit.js +387 -0
- package/dist/unit/exact-unit.js.map +1 -0
- package/dist/wallet/index.d.ts +29 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +106 -0
- package/dist/wallet/index.js.map +1 -0
- package/package.json +64 -3
- package/src/channel/definition.ts +114 -0
- package/src/config/index.ts +40 -0
- package/src/core/amounts.ts +116 -0
- package/src/core/errors.ts +22 -0
- package/src/core/networks.ts +81 -0
- package/src/core/result.ts +23 -0
- package/src/index.ts +58 -0
- package/src/logger/index.ts +234 -0
- package/src/signing/signed-message.ts +147 -0
- package/src/types/obyte-internal.d.ts +19 -0
- package/src/unit/exact-unit.ts +447 -0
- package/src/wallet/index.ts +130 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexander Ponomarev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @obbyx/obyte
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Obyte primitives used by the obbyx x402 packages.
|
|
4
|
+
|
|
5
|
+
| Entry | Contents |
|
|
6
|
+
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `@obbyx/obyte` | networks (`obyte:livenet`/`obyte:testnet`, v1 names), BigInt amounts, `validateExactUnit` (payment-unit profile), `verifySignedPackage`, channel AA definitions, `ObbyxError` |
|
|
8
|
+
| `@obbyx/obyte/wallet` | single-address wallet file (`$OBBYX_HOME/wallet-<network>.json`, mode 0600), validated on load |
|
|
9
|
+
| `@obbyx/obyte/logger` | structured logger (pino) with redaction of keys, units and vouchers |
|
|
10
|
+
| `@obbyx/obyte/config` | zod-based environment configuration |
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm i @obbyx/obyte obyte
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Part of [obbyx](https://github.com/Taump/obbyx). Node.js ≥ 24. MIT.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Verdict } from '../core/result.js';
|
|
2
|
+
/**
|
|
3
|
+
* AA payment channels (aa-channels-lib, base AA v1.1).
|
|
4
|
+
*
|
|
5
|
+
* Party A is the payee (seller, x402 `payTo`), party B the payer (client).
|
|
6
|
+
* A channel address is derived from its parameters, so binding a payment to a
|
|
7
|
+
* seller is a matter of recomputing the address (ADR-0003): parameters are
|
|
8
|
+
* taken from the on-chain definition, never trusted from a package alone.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHANNEL_BASE_AA = "4IRUGAUUCAQ6QRQLG4SNOLOE6VW2STWZ";
|
|
11
|
+
export interface ChannelParams {
|
|
12
|
+
readonly addressA: string;
|
|
13
|
+
readonly addressB: string;
|
|
14
|
+
/** `'base'` for bytes, otherwise a 44-char asset id. */
|
|
15
|
+
readonly asset: string;
|
|
16
|
+
readonly salt?: string;
|
|
17
|
+
/** Dispute window in seconds. */
|
|
18
|
+
readonly timeout: number;
|
|
19
|
+
}
|
|
20
|
+
export type ChannelDefinition = readonly [
|
|
21
|
+
'autonomous agent',
|
|
22
|
+
{
|
|
23
|
+
readonly base_aa: string;
|
|
24
|
+
readonly params: ChannelParams;
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
/** obyte.js `isValidAddress` as a type guard; it also rejects non-strings. */
|
|
28
|
+
export declare function isAddress(value: unknown): value is string;
|
|
29
|
+
export declare function isAssetId(value: unknown): value is string;
|
|
30
|
+
export declare function validateChannelParams(params: unknown): Verdict<ChannelParams>;
|
|
31
|
+
export declare function channelDefinition(params: ChannelParams): ChannelDefinition;
|
|
32
|
+
export declare function channelAddress(params: ChannelParams): string;
|
|
33
|
+
/**
|
|
34
|
+
* Parses an on-chain AA definition and returns its channel parameters if it
|
|
35
|
+
* is an instance of the supported base AA whose address matches `address`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseChannelDefinition(address: string, definition: unknown): Verdict<ChannelParams>;
|
|
38
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/channel/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,mBAAmB,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS;IACvC,kBAAkB;IAClB;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;KAAE;CAC7D,CAAC;AAEF,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAID,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CA0B7E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAW1E;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE5D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,aAAa,CAAC,CAsBxB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import obyte from 'obyte';
|
|
2
|
+
import { accept, isPlainObject, reject } from '../core/result.js';
|
|
3
|
+
/**
|
|
4
|
+
* AA payment channels (aa-channels-lib, base AA v1.1).
|
|
5
|
+
*
|
|
6
|
+
* Party A is the payee (seller, x402 `payTo`), party B the payer (client).
|
|
7
|
+
* A channel address is derived from its parameters, so binding a payment to a
|
|
8
|
+
* seller is a matter of recomputing the address (ADR-0003): parameters are
|
|
9
|
+
* taken from the on-chain definition, never trusted from a package alone.
|
|
10
|
+
*/
|
|
11
|
+
export const CHANNEL_BASE_AA = '4IRUGAUUCAQ6QRQLG4SNOLOE6VW2STWZ';
|
|
12
|
+
/** obyte.js `isValidAddress` as a type guard; it also rejects non-strings. */
|
|
13
|
+
export function isAddress(value) {
|
|
14
|
+
return typeof value === 'string' && obyte.utils.isValidAddress(value);
|
|
15
|
+
}
|
|
16
|
+
const ASSET_RE = /^[A-Za-z0-9+/]{43}=$/;
|
|
17
|
+
export function isAssetId(value) {
|
|
18
|
+
return value === 'base' || (typeof value === 'string' && ASSET_RE.test(value));
|
|
19
|
+
}
|
|
20
|
+
export function validateChannelParams(params) {
|
|
21
|
+
if (!isPlainObject(params))
|
|
22
|
+
return reject('invalid_channel_params', 'Params must be an object');
|
|
23
|
+
const { addressA, addressB, asset, salt, timeout } = params;
|
|
24
|
+
const extra = Object.keys(params).filter((k) => !['addressA', 'addressB', 'asset', 'salt', 'timeout'].includes(k));
|
|
25
|
+
if (extra.length > 0)
|
|
26
|
+
return reject('invalid_channel_params', `Unexpected params: ${extra.join(', ')}`);
|
|
27
|
+
if (!isAddress(addressA) || !isAddress(addressB)) {
|
|
28
|
+
return reject('invalid_channel_params', 'addressA and addressB must be valid addresses');
|
|
29
|
+
}
|
|
30
|
+
if (addressA === addressB)
|
|
31
|
+
return reject('invalid_channel_params', 'Parties must differ');
|
|
32
|
+
if (!isAssetId(asset))
|
|
33
|
+
return reject('invalid_channel_params', 'Invalid asset');
|
|
34
|
+
if (salt !== undefined && (typeof salt !== 'string' || salt.length === 0 || salt.length > 100)) {
|
|
35
|
+
return reject('invalid_channel_params', 'Invalid salt');
|
|
36
|
+
}
|
|
37
|
+
if (!Number.isSafeInteger(timeout) || timeout <= 0) {
|
|
38
|
+
return reject('invalid_channel_params', 'timeout must be a positive integer (seconds)');
|
|
39
|
+
}
|
|
40
|
+
return accept({
|
|
41
|
+
addressA,
|
|
42
|
+
addressB,
|
|
43
|
+
asset,
|
|
44
|
+
...(salt === undefined ? {} : { salt: salt }),
|
|
45
|
+
timeout: timeout,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function channelDefinition(params) {
|
|
49
|
+
// Key order matters for nothing (JSON source string sorts keys) but is kept
|
|
50
|
+
// identical to aa-channels-lib for readability.
|
|
51
|
+
const p = {
|
|
52
|
+
addressA: params.addressA,
|
|
53
|
+
addressB: params.addressB,
|
|
54
|
+
asset: params.asset,
|
|
55
|
+
...(params.salt === undefined ? {} : { salt: params.salt }),
|
|
56
|
+
timeout: params.timeout,
|
|
57
|
+
};
|
|
58
|
+
return ['autonomous agent', { base_aa: CHANNEL_BASE_AA, params: p }];
|
|
59
|
+
}
|
|
60
|
+
export function channelAddress(params) {
|
|
61
|
+
return obyte.utils.getChash160(channelDefinition(params));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parses an on-chain AA definition and returns its channel parameters if it
|
|
65
|
+
* is an instance of the supported base AA whose address matches `address`.
|
|
66
|
+
*/
|
|
67
|
+
export function parseChannelDefinition(address, definition) {
|
|
68
|
+
if (!Array.isArray(definition) ||
|
|
69
|
+
definition.length !== 2 ||
|
|
70
|
+
definition[0] !== 'autonomous agent' ||
|
|
71
|
+
!isPlainObject(definition[1])) {
|
|
72
|
+
return reject('invalid_channel_definition', 'Not a parameterized AA definition');
|
|
73
|
+
}
|
|
74
|
+
const body = definition[1];
|
|
75
|
+
if (body['base_aa'] !== CHANNEL_BASE_AA) {
|
|
76
|
+
return reject('invalid_channel_definition', 'AA is not an instance of the supported channel base AA');
|
|
77
|
+
}
|
|
78
|
+
const params = validateChannelParams(body['params']);
|
|
79
|
+
if (!params.ok)
|
|
80
|
+
return params;
|
|
81
|
+
if (channelAddress(params.value) !== address) {
|
|
82
|
+
return reject('invalid_channel_definition', 'Definition does not match the channel address');
|
|
83
|
+
}
|
|
84
|
+
return params;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/channel/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAgB,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAiBl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U,cAAc,CAAC,MAAqB;IAClD,OAAO,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAyB,CAAC,CAAC;AACpF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAe,EACf,UAAmB;IAEnB,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAC1B,UAAU,CAAC,MAAM,KAAK,CAAC;QACvB,UAAU,CAAC,CAAC,CAAC,KAAK,kBAAkB;QACpC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC7B,CAAC;QACD,OAAO,MAAM,CAAC,4BAA4B,EAAE,mCAAmC,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,eAAe,EAAE,CAAC;QACxC,OAAO,MAAM,CACX,4BAA4B,EAC5B,wDAAwD,CACzD,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC9B,IAAI,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC;QAC7C,OAAO,MAAM,CAAC,4BAA4B,EAAE,+CAA+C,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ObbyxError } from '../core/errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration is validated with zod at startup; an invalid config stops the
|
|
5
|
+
* process with a list of *all* problems rather than failing later at runtime.
|
|
6
|
+
* The same schemas generate the configuration reference in the docs.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ConfigError extends ObbyxError {
|
|
9
|
+
readonly issues: readonly string[];
|
|
10
|
+
constructor(issues: readonly string[]);
|
|
11
|
+
}
|
|
12
|
+
export declare function loadConfig<S extends z.ZodType>(schema: S, source: unknown): z.output<S>;
|
|
13
|
+
/** Reusable env-var helpers. */
|
|
14
|
+
export declare const envBoolean: z.ZodPipe<z.ZodEnum<{
|
|
15
|
+
0: "0";
|
|
16
|
+
1: "1";
|
|
17
|
+
true: "true";
|
|
18
|
+
false: "false";
|
|
19
|
+
yes: "yes";
|
|
20
|
+
no: "no";
|
|
21
|
+
}>, z.ZodTransform<boolean, "0" | "1" | "true" | "false" | "yes" | "no">>;
|
|
22
|
+
export declare const envPort: z.ZodCoercedNumber<unknown>;
|
|
23
|
+
export declare const logLevelSchema: z.ZodEnum<{
|
|
24
|
+
error: "error";
|
|
25
|
+
fatal: "fatal";
|
|
26
|
+
warn: "warn";
|
|
27
|
+
info: "info";
|
|
28
|
+
debug: "debug";
|
|
29
|
+
trace: "trace";
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;gBAEvB,MAAM,EAAE,SAAS,MAAM,EAAE;CAMtC;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAWvF;AAED,gCAAgC;AAChC,eAAO,MAAM,UAAU;;;;;;;yEAEsC,CAAC;AAE9D,eAAO,MAAM,OAAO,6BAA4C,CAAC;AAEjE,eAAO,MAAM,cAAc;;;;;;;EAA+D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ObbyxError } from '../core/errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration is validated with zod at startup; an invalid config stops the
|
|
5
|
+
* process with a list of *all* problems rather than failing later at runtime.
|
|
6
|
+
* The same schemas generate the configuration reference in the docs.
|
|
7
|
+
*/
|
|
8
|
+
export class ConfigError extends ObbyxError {
|
|
9
|
+
issues;
|
|
10
|
+
constructor(issues) {
|
|
11
|
+
super('invalid_config', `Invalid configuration:\n - ${issues.join('\n - ')}`, {
|
|
12
|
+
details: { issues },
|
|
13
|
+
});
|
|
14
|
+
this.issues = issues;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function loadConfig(schema, source) {
|
|
18
|
+
const result = schema.safeParse(source);
|
|
19
|
+
if (!result.success) {
|
|
20
|
+
throw new ConfigError(result.error.issues.map((issue) => {
|
|
21
|
+
const path = issue.path.length > 0 ? issue.path.join('.') : '(root)';
|
|
22
|
+
return `${path}: ${issue.message}`;
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
return result.data;
|
|
26
|
+
}
|
|
27
|
+
/** Reusable env-var helpers. */
|
|
28
|
+
export const envBoolean = z
|
|
29
|
+
.enum(['1', '0', 'true', 'false', 'yes', 'no'])
|
|
30
|
+
.transform((v) => v === '1' || v === 'true' || v === 'yes');
|
|
31
|
+
export const envPort = z.coerce.number().int().min(1).max(65535);
|
|
32
|
+
export const logLevelSchema = z.enum(['fatal', 'error', 'warn', 'info', 'debug', 'trace']);
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OA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AAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ObbyxError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Amounts are always integers in the asset's smallest units (invariant I5).
|
|
4
|
+
*
|
|
5
|
+
* - On the wire (x402 JSON) they are decimal strings.
|
|
6
|
+
* - Inside obbyx they are `bigint`.
|
|
7
|
+
* - They are converted to `number` only at the boundary with libraries that
|
|
8
|
+
* require it (ocore, obyte.js, AA formulas), via {@link toSafeNumber}.
|
|
9
|
+
* - Prices are never computed with floating point.
|
|
10
|
+
*/
|
|
11
|
+
export type Amount = bigint;
|
|
12
|
+
/** Largest amount accepted anywhere: every amount must round-trip through JS `number`. */
|
|
13
|
+
export declare const MAX_AMOUNT: Amount;
|
|
14
|
+
export declare class AmountError extends ObbyxError {
|
|
15
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
16
|
+
}
|
|
17
|
+
/** Parses an atomic amount from its canonical decimal-string form ("0", "1500"). */
|
|
18
|
+
export declare function parseAmount(input: string): Amount;
|
|
19
|
+
/** Accepts a safe non-negative integer `number` (e.g. from ocore) and returns a bigint. */
|
|
20
|
+
export declare function fromSafeNumber(input: number): Amount;
|
|
21
|
+
/** Canonical wire form. */
|
|
22
|
+
export declare function formatAmount(value: Amount): string;
|
|
23
|
+
/** Converts for libraries that only accept `number`; throws instead of losing precision. */
|
|
24
|
+
export declare function toSafeNumber(value: Amount): number;
|
|
25
|
+
export declare function addAmounts(a: Amount, b: Amount): Amount;
|
|
26
|
+
/** Subtraction that never goes below zero silently. */
|
|
27
|
+
export declare function subAmounts(a: Amount, b: Amount): Amount;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a human-readable amount ("0.25") into atomic units.
|
|
30
|
+
* Rejects more fractional digits than the asset supports instead of rounding.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fromDisplay(input: string, decimals: number): Amount;
|
|
33
|
+
/** Converts atomic units into a human-readable string without floating point. */
|
|
34
|
+
export declare function toDisplay(value: Amount, decimals: number): string;
|
|
35
|
+
//# sourceMappingURL=amounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amounts.d.ts","sourceRoot":"","sources":["../../src/core/amounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,0FAA0F;AAC1F,eAAO,MAAM,UAAU,EAAE,MAAwC,CAAC;AAMlE,qBAAa,WAAY,SAAQ,UAAU;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG/D;AAeD,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOjD;AAED,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED,2BAA2B;AAC3B,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,uDAAuD;AACvD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkBnE;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQjE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ObbyxError } from './errors.js';
|
|
2
|
+
/** Largest amount accepted anywhere: every amount must round-trip through JS `number`. */
|
|
3
|
+
export const MAX_AMOUNT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
4
|
+
const AMOUNT_RE = /^(0|[1-9][0-9]*)$/;
|
|
5
|
+
const DISPLAY_RE = /^(0|[1-9][0-9]*)(\.([0-9]+))?$/;
|
|
6
|
+
const MAX_DECIMALS = 18;
|
|
7
|
+
export class AmountError extends ObbyxError {
|
|
8
|
+
constructor(message, details) {
|
|
9
|
+
super('invalid_amount', message, details === undefined ? {} : { details });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function assertInRange(value, input) {
|
|
13
|
+
if (value < 0n || value > MAX_AMOUNT) {
|
|
14
|
+
throw new AmountError('Amount is out of range', { input: String(input) });
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function assertDecimals(decimals) {
|
|
19
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > MAX_DECIMALS) {
|
|
20
|
+
throw new AmountError('Invalid number of decimals', { decimals });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Parses an atomic amount from its canonical decimal-string form ("0", "1500"). */
|
|
24
|
+
export function parseAmount(input) {
|
|
25
|
+
if (typeof input !== 'string' || !AMOUNT_RE.test(input)) {
|
|
26
|
+
throw new AmountError('Amount must be a non-negative integer string without leading zeros', {
|
|
27
|
+
input: String(input),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return assertInRange(BigInt(input), input);
|
|
31
|
+
}
|
|
32
|
+
/** Accepts a safe non-negative integer `number` (e.g. from ocore) and returns a bigint. */
|
|
33
|
+
export function fromSafeNumber(input) {
|
|
34
|
+
if (!Number.isSafeInteger(input) || input < 0) {
|
|
35
|
+
throw new AmountError('Amount must be a non-negative safe integer', { input });
|
|
36
|
+
}
|
|
37
|
+
return BigInt(input);
|
|
38
|
+
}
|
|
39
|
+
/** Canonical wire form. */
|
|
40
|
+
export function formatAmount(value) {
|
|
41
|
+
return assertInRange(value, value).toString();
|
|
42
|
+
}
|
|
43
|
+
/** Converts for libraries that only accept `number`; throws instead of losing precision. */
|
|
44
|
+
export function toSafeNumber(value) {
|
|
45
|
+
return Number(assertInRange(value, value));
|
|
46
|
+
}
|
|
47
|
+
export function addAmounts(a, b) {
|
|
48
|
+
return assertInRange(a + b, `${a}+${b}`);
|
|
49
|
+
}
|
|
50
|
+
/** Subtraction that never goes below zero silently. */
|
|
51
|
+
export function subAmounts(a, b) {
|
|
52
|
+
if (b > a) {
|
|
53
|
+
throw new AmountError('Amount subtraction would be negative', {
|
|
54
|
+
a: a.toString(),
|
|
55
|
+
b: b.toString(),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return a - b;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Converts a human-readable amount ("0.25") into atomic units.
|
|
62
|
+
* Rejects more fractional digits than the asset supports instead of rounding.
|
|
63
|
+
*/
|
|
64
|
+
export function fromDisplay(input, decimals) {
|
|
65
|
+
assertDecimals(decimals);
|
|
66
|
+
const match = typeof input === 'string' ? DISPLAY_RE.exec(input) : null;
|
|
67
|
+
if (!match) {
|
|
68
|
+
throw new AmountError('Display amount must look like "12" or "12.34"', {
|
|
69
|
+
input: String(input),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const whole = match[1] ?? '0';
|
|
73
|
+
const fraction = match[3] ?? '';
|
|
74
|
+
if (fraction.length > decimals) {
|
|
75
|
+
throw new AmountError('Display amount has more fractional digits than the asset allows', {
|
|
76
|
+
input,
|
|
77
|
+
decimals,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const atomic = BigInt(whole + fraction.padEnd(decimals, '0'));
|
|
81
|
+
return assertInRange(atomic, input);
|
|
82
|
+
}
|
|
83
|
+
/** Converts atomic units into a human-readable string without floating point. */
|
|
84
|
+
export function toDisplay(value, decimals) {
|
|
85
|
+
assertDecimals(decimals);
|
|
86
|
+
const digits = formatAmount(value);
|
|
87
|
+
if (decimals === 0)
|
|
88
|
+
return digits;
|
|
89
|
+
const padded = digits.padStart(decimals + 1, '0');
|
|
90
|
+
const whole = padded.slice(0, -decimals);
|
|
91
|
+
const fraction = padded.slice(-decimals).replace(/0+$/, '');
|
|
92
|
+
return fraction.length > 0 ? `${whole}.${fraction}` : whole;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=amounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amounts.js","sourceRoot":"","sources":["../../src/core/amounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAazC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAW,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAElE,MAAM,SAAS,GAAG,mBAAmB,CAAC;AACtC,MAAM,UAAU,GAAG,gCAAgC,CAAC;AACpD,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,OAAO,WAAY,SAAQ,UAAU;IACzC,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7E,CAAC;CACF;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,KAAc;IAClD,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,GAAG,UAAU,EAAE,CAAC;QACrC,MAAM,IAAI,WAAW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CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9D,OAAO,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,QAAgB;IACvD,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzB,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC5D,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error for all obbyx packages.
|
|
3
|
+
*
|
|
4
|
+
* `code` is a stable machine-readable identifier. Payment-related errors use
|
|
5
|
+
* x402 reason codes (e.g. `invalid_exact_obyte_payload_signature`) so they can
|
|
6
|
+
* be mapped 1:1 to `invalidReason` / `errorReason` in facilitator responses.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ObbyxError extends Error {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly details: Readonly<Record<string, unknown>> | undefined;
|
|
11
|
+
constructor(code: string, message: string, options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
details?: Record<string, unknown>;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;gBAG9D,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAO;CAOvE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error for all obbyx packages.
|
|
3
|
+
*
|
|
4
|
+
* `code` is a stable machine-readable identifier. Payment-related errors use
|
|
5
|
+
* x402 reason codes (e.g. `invalid_exact_obyte_payload_signature`) so they can
|
|
6
|
+
* be mapped 1:1 to `invalidReason` / `errorReason` in facilitator responses.
|
|
7
|
+
*/
|
|
8
|
+
export class ObbyxError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
details;
|
|
11
|
+
constructor(code, message, options = {}) {
|
|
12
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
13
|
+
this.name = new.target.name;
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.details = options.details;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,CAAS;IACb,OAAO,CAAgD;IAEhE,YACE,IAAY,EACZ,OAAe,EACf,UAAkE,EAAE;QAEpE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ObbyxError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Obyte networks and their identifiers.
|
|
4
|
+
*
|
|
5
|
+
* - x402 v2 uses CAIP-2 identifiers. No `obyte` namespace exists in
|
|
6
|
+
* ChainAgnostic/namespaces yet, so `obyte:livenet` / `obyte:testnet` are
|
|
7
|
+
* provisional until agreed upstream (see docs/adr/0004-network-identifiers.md).
|
|
8
|
+
* - x402 v1 uses plain strings, so each network also has a v1 name.
|
|
9
|
+
*
|
|
10
|
+
* Every storage, lock and dedup key must include the network (invariant I4);
|
|
11
|
+
* use {@link networkKey} to build such keys.
|
|
12
|
+
*/
|
|
13
|
+
export type ObyteNetworkName = 'livenet' | 'testnet';
|
|
14
|
+
export type Caip2 = `${string}:${string}`;
|
|
15
|
+
export interface ObyteNetwork {
|
|
16
|
+
readonly name: ObyteNetworkName;
|
|
17
|
+
readonly caip2: Caip2;
|
|
18
|
+
readonly v1Name: string;
|
|
19
|
+
readonly testnet: boolean;
|
|
20
|
+
readonly defaultHubUrl: string;
|
|
21
|
+
readonly explorerUrl: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const OBYTE_CAIP_FAMILY: "obyte:*";
|
|
24
|
+
export declare const OBYTE_NETWORKS: Readonly<Record<ObyteNetworkName, ObyteNetwork>>;
|
|
25
|
+
export declare class UnsupportedNetworkError extends ObbyxError {
|
|
26
|
+
constructor(id: string);
|
|
27
|
+
}
|
|
28
|
+
/** Resolves a v2 CAIP-2 id or a v1 network name; throws for anything else. */
|
|
29
|
+
export declare function getNetwork(id: string): ObyteNetwork;
|
|
30
|
+
export declare function isObyteNetwork(id: string): boolean;
|
|
31
|
+
/** Builds a key namespaced by network, e.g. `obyte:testnet:unit:<hash>`. */
|
|
32
|
+
export declare function networkKey(network: ObyteNetwork, ...parts: readonly string[]): string;
|
|
33
|
+
export declare function explorerUnitUrl(network: ObyteNetwork, unit: string): string;
|
|
34
|
+
//# sourceMappingURL=networks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../src/core/networks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AACrD,MAAM,MAAM,KAAK,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,iBAAiB,EAAG,SAAkB,CAAC;AAEpD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAiB1E,CAAC;AASH,qBAAa,uBAAwB,SAAQ,UAAU;gBACzC,EAAE,EAAE,MAAM;CAGvB;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAInD;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAKrF;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ObbyxError } from './errors.js';
|
|
2
|
+
export const OBYTE_CAIP_FAMILY = 'obyte:*';
|
|
3
|
+
export const OBYTE_NETWORKS = Object.freeze({
|
|
4
|
+
livenet: Object.freeze({
|
|
5
|
+
name: 'livenet',
|
|
6
|
+
caip2: 'obyte:livenet',
|
|
7
|
+
v1Name: 'obyte-livenet',
|
|
8
|
+
testnet: false,
|
|
9
|
+
defaultHubUrl: 'wss://obyte.org/bb',
|
|
10
|
+
explorerUrl: 'https://explorer.obyte.org',
|
|
11
|
+
}),
|
|
12
|
+
testnet: Object.freeze({
|
|
13
|
+
name: 'testnet',
|
|
14
|
+
caip2: 'obyte:testnet',
|
|
15
|
+
v1Name: 'obyte-testnet',
|
|
16
|
+
testnet: true,
|
|
17
|
+
defaultHubUrl: 'wss://obyte.org/bb-test',
|
|
18
|
+
explorerUrl: 'https://testnetexplorer.obyte.org',
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
const BY_ID = new Map(Object.values(OBYTE_NETWORKS).flatMap((n) => [
|
|
22
|
+
[n.caip2, n],
|
|
23
|
+
[n.v1Name, n],
|
|
24
|
+
]));
|
|
25
|
+
export class UnsupportedNetworkError extends ObbyxError {
|
|
26
|
+
constructor(id) {
|
|
27
|
+
super('invalid_network', `Unsupported Obyte network: ${id}`, { details: { network: id } });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Resolves a v2 CAIP-2 id or a v1 network name; throws for anything else. */
|
|
31
|
+
export function getNetwork(id) {
|
|
32
|
+
const network = BY_ID.get(id);
|
|
33
|
+
if (!network)
|
|
34
|
+
throw new UnsupportedNetworkError(id);
|
|
35
|
+
return network;
|
|
36
|
+
}
|
|
37
|
+
export function isObyteNetwork(id) {
|
|
38
|
+
return BY_ID.has(id);
|
|
39
|
+
}
|
|
40
|
+
/** Builds a key namespaced by network, e.g. `obyte:testnet:unit:<hash>`. */
|
|
41
|
+
export function networkKey(network, ...parts) {
|
|
42
|
+
if (parts.length === 0 || parts.some((p) => p.length === 0)) {
|
|
43
|
+
throw new ObbyxError('invalid_key', 'networkKey requires non-empty parts');
|
|
44
|
+
}
|
|
45
|
+
return [network.caip2, ...parts].join(':');
|
|
46
|
+
}
|
|
47
|
+
export function explorerUnitUrl(network, unit) {
|
|
48
|
+
return `${network.explorerUrl}/${encodeURIComponent(unit)}`;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=networks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networks.js","sourceRoot":"","sources":["../../src/core/networks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAyBzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAkB,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAqD,MAAM,CAAC,MAAM,CAAC;IAC5F,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,KAAK;QACd,aAAa,EAAE,oBAAoB;QACnC,WAAW,EAAE,4BAA4B;KAC1C,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,IAAI;QACb,aA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,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAqB,EAAE,IAAY;IACjE,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome of a check. Rejections carry a stable `reason` code (x402 style) and a
|
|
3
|
+
* human-readable message; they are expected outcomes, not exceptions.
|
|
4
|
+
*/
|
|
5
|
+
export type Verdict<T> = {
|
|
6
|
+
readonly ok: true;
|
|
7
|
+
readonly value: T;
|
|
8
|
+
} | {
|
|
9
|
+
readonly ok: false;
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function accept<T>(value: T): Verdict<T>;
|
|
14
|
+
export declare function reject<T = never>(reason: string, message: string): Verdict<T>;
|
|
15
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
16
|
+
export declare function hasOnlyKeys(obj: Record<string, unknown>, allowed: ReadonlySet<string>): boolean;
|
|
17
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE9C;AAED,wBAAgB,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAE/F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function accept(value) {
|
|
2
|
+
return { ok: true, value };
|
|
3
|
+
}
|
|
4
|
+
export function reject(reason, message) {
|
|
5
|
+
return { ok: false, reason, message };
|
|
6
|
+
}
|
|
7
|
+
export function isPlainObject(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
export function hasOnlyKeys(obj, allowed) {
|
|
11
|
+
return Object.keys(obj).every((k) => allowed.has(k));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/core/result.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,MAAM,CAAI,KAAQ;IAChC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,MAAM,CAAY,MAAc,EAAE,OAAe;IAC/D,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAA4B,EAAE,OAA4B;IACpF,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ObbyxError } from './core/errors.js';
|
|
2
|
+
export { type Verdict, accept, reject } from './core/result.js';
|
|
3
|
+
export { type Amount, AmountError, MAX_AMOUNT, addAmounts, formatAmount, fromDisplay, fromSafeNumber, parseAmount, subAmounts, toDisplay, toSafeNumber, } from './core/amounts.js';
|
|
4
|
+
export { type Caip2, type ObyteNetwork, type ObyteNetworkName, OBYTE_CAIP_FAMILY, OBYTE_NETWORKS, UnsupportedNetworkError, explorerUnitUrl, getNetwork, isObyteNetwork, networkKey, } from './core/networks.js';
|
|
5
|
+
export { SIGNED_PACKAGE_VERSIONS, type SigDefinition, type SignedPackage, type VerifiedPackage, isSigDefinition, verifySignature, verifySignedPackage, } from './signing/signed-message.js';
|
|
6
|
+
export { CHANNEL_BASE_AA, type ChannelDefinition, type ChannelParams, channelAddress, channelDefinition, isAddress, isAssetId, parseChannelDefinition, validateChannelParams, } from './channel/definition.js';
|
|
7
|
+
export { DEFAULT_MAX_UNIT_BYTES, EXACT_REASONS, EXACT_UNIT_VERSIONS, type ExactExpectation, type ExactUnitFacts, type InputRef, compareOutputs, expectedCommissions, validateExactUnit, } from './unit/exact-unit.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,KAAK,MAAM,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,UAAU,EACV,cAAc,EACd,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,cAAc,EACd,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ObbyxError } from './core/errors.js';
|
|
2
|
+
export { accept, reject } from './core/result.js';
|
|
3
|
+
export { AmountError, MAX_AMOUNT, addAmounts, formatAmount, fromDisplay, fromSafeNumber, parseAmount, subAmounts, toDisplay, toSafeNumber, } from './core/amounts.js';
|
|
4
|
+
export { OBYTE_CAIP_FAMILY, OBYTE_NETWORKS, UnsupportedNetworkError, explorerUnitUrl, getNetwork, isObyteNetwork, networkKey, } from './core/networks.js';
|
|
5
|
+
export { SIGNED_PACKAGE_VERSIONS, isSigDefinition, verifySignature, verifySignedPackage, } from './signing/signed-message.js';
|
|
6
|
+
export { CHANNEL_BASE_AA, channelAddress, channelDefinition, isAddress, isAssetId, parseChannelDefinition, validateChannelParams, } from './channel/definition.js';
|
|
7
|
+
export { DEFAULT_MAX_UNIT_BYTES, EXACT_REASONS, EXACT_UNIT_VERSIONS, compareOutputs, expectedCommissions, validateExactUnit, } from './unit/exact-unit.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAEL,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,UAAU,EACV,cAAc,EACd,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,uBAAuB,EAIvB,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,eAAe,EAGf,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EAInB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
|