@chainvue/verus-sdk 0.13.0 → 0.14.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/README.md +21 -8
- package/dist/VerusSDK.d.ts +34 -1
- package/dist/VerusSDK.d.ts.map +1 -1
- package/dist/VerusSDK.js +38 -1
- package/dist/VerusSDK.js.map +1 -1
- package/dist/bundle.js +1009 -122
- package/dist/currency/definition.d.ts +181 -0
- package/dist/currency/definition.d.ts.map +1 -0
- package/dist/currency/definition.js +396 -0
- package/dist/currency/definition.js.map +1 -0
- package/dist/currency/index.d.ts +17 -7
- package/dist/currency/index.d.ts.map +1 -1
- package/dist/currency/index.js +32 -9
- package/dist/currency/index.js.map +1 -1
- package/dist/currency/launch.d.ts +43 -0
- package/dist/currency/launch.d.ts.map +1 -0
- package/dist/currency/launch.js +96 -0
- package/dist/currency/launch.js.map +1 -0
- package/dist/currency/outputs.d.ts +40 -0
- package/dist/currency/outputs.d.ts.map +1 -0
- package/dist/currency/outputs.js +296 -0
- package/dist/currency/outputs.js.map +1 -0
- package/dist/currency/reserveTransfer.d.ts +36 -0
- package/dist/currency/reserveTransfer.d.ts.map +1 -0
- package/dist/currency/reserveTransfer.js +104 -0
- package/dist/currency/reserveTransfer.js.map +1 -0
- package/dist/currency/wire.d.ts +76 -0
- package/dist/currency/wire.d.ts.map +1 -0
- package/dist/currency/wire.js +252 -0
- package/dist/currency/wire.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/transfer/index.d.ts.map +1 -1
- package/dist/transfer/index.js +38 -14
- package/dist/transfer/index.js.map +1 -1
- package/dist/types/index.d.ts +27 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline serialization of a Verus currency definition (`CCurrencyDefinition`)
|
|
3
|
+
* into the `EVAL_CURRENCY_DEFINITION` CryptoCondition output script that a
|
|
4
|
+
* `definecurrency` transaction carries.
|
|
5
|
+
*
|
|
6
|
+
* This is a serialization primitive: it builds (and lets you inspect/verify) the
|
|
7
|
+
* definition output script byte-for-byte as the daemon would. It is NOT a
|
|
8
|
+
* currency launcher — a valid definition transaction also carries currency-state
|
|
9
|
+
* and notarization outputs validated against live chain state, so the actual
|
|
10
|
+
* launch is a daemon (`definecurrency`) operation, not an offline one.
|
|
11
|
+
*
|
|
12
|
+
* Scope: simple tokens (`OPTION_TOKEN`) and fractional reserve baskets
|
|
13
|
+
* (`OPTION_TOKEN | OPTION_FRACTIONAL`). PBaaS chains and gateways are rejected
|
|
14
|
+
* fail-closed — their serialization carries extra trailing fields (launch fees,
|
|
15
|
+
* issuance schedule, gateway converter) that this builder deliberately omits.
|
|
16
|
+
*
|
|
17
|
+
* The byte layout mirrors `CCurrencyDefinition::SerializationOp`
|
|
18
|
+
* (VerusCoin `src/pbaas/crosschainrpc.h`). A subtlety load-bearing for
|
|
19
|
+
* correctness: for a non-gateway, non-PBaaS currency the C++ `else` branch
|
|
20
|
+
* writes the five trailing fee fields (`currencyRegistrationFee` …
|
|
21
|
+
* `transactionExportFee`) into a *shadowed local stream*, so they never reach
|
|
22
|
+
* the wire — a token/basket definition ends at `idImportFees`. This is
|
|
23
|
+
* reproduced here and byte-locked against real on-chain definitions
|
|
24
|
+
* (see test/currency-definition.test.ts) rather than trusted from the header.
|
|
25
|
+
*
|
|
26
|
+
* The CC wrapper (OptCCParams master eval 0 + params eval 2, both m=1/n=1 to a
|
|
27
|
+
* single pubkey destination) sends to the daemon's hardcoded currency-definition
|
|
28
|
+
* pubkey (`CCcustom.cpp` `PBaaSDefinitionPubKey`), which is chain-independent.
|
|
29
|
+
*/
|
|
30
|
+
/** Currency-definition data-structure version (`CCurrencyDefinition::VERSION_CURRENT`). */
|
|
31
|
+
export declare const CURRENCY_DEFINITION_VERSION = 1;
|
|
32
|
+
/** Currency option bits (`CCurrencyDefinition::ECurrencyOptions`). */
|
|
33
|
+
export declare const CURRENCY_OPTION: {
|
|
34
|
+
readonly FRACTIONAL: 1;
|
|
35
|
+
readonly ID_RESTRICTED: 2;
|
|
36
|
+
readonly ID_STAKING: 4;
|
|
37
|
+
readonly ID_REFERRALS: 8;
|
|
38
|
+
readonly ID_REFERRALREQUIRED: 16;
|
|
39
|
+
readonly TOKEN: 32;
|
|
40
|
+
readonly SINGLECURRENCY: 64;
|
|
41
|
+
readonly GATEWAY: 128;
|
|
42
|
+
readonly PBAAS: 256;
|
|
43
|
+
readonly GATEWAY_CONVERTER: 512;
|
|
44
|
+
readonly GATEWAY_NAMECONTROLLER: 1024;
|
|
45
|
+
readonly NFT_TOKEN: 2048;
|
|
46
|
+
readonly NO_IDS: 4096;
|
|
47
|
+
};
|
|
48
|
+
/** Notarization protocol (`ENotarizationProtocol`). */
|
|
49
|
+
export declare const NOTARIZATION_PROTOCOL: {
|
|
50
|
+
readonly AUTO: 1;
|
|
51
|
+
readonly NOTARY_CONFIRM: 2;
|
|
52
|
+
readonly NOTARY_CHAINID: 3;
|
|
53
|
+
};
|
|
54
|
+
/** Proof protocol (`EProofProtocol`). */
|
|
55
|
+
export declare const PROOF_PROTOCOL: {
|
|
56
|
+
readonly PBAASMMR: 1;
|
|
57
|
+
readonly CHAINID: 2;
|
|
58
|
+
readonly ETHNOTARIZATION: 3;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* A currency to define. Amounts are bigint satoshis (never `number`). Reserve
|
|
62
|
+
* currencies and pre-allocation recipients are given as i-addresses.
|
|
63
|
+
*/
|
|
64
|
+
export interface CurrencyDefinitionInput {
|
|
65
|
+
/** Bare currency name, matching the identity it is defined under (no `@`). */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Parent namespace i-address (the chain/currency this is registered under). */
|
|
68
|
+
parent: string;
|
|
69
|
+
/**
|
|
70
|
+
* Option bits (see {@link CURRENCY_OPTION}). Must include `TOKEN`. `GATEWAY`
|
|
71
|
+
* and `PBAAS` are rejected — out of scope for this offline builder.
|
|
72
|
+
*/
|
|
73
|
+
options: number;
|
|
74
|
+
/** Controlling system i-address. Defaults to `parent`. */
|
|
75
|
+
systemId?: string;
|
|
76
|
+
/** Launch system i-address. Defaults to `systemId`. */
|
|
77
|
+
launchSystemId?: string;
|
|
78
|
+
/** Notarization protocol. Defaults to `AUTO` (1). */
|
|
79
|
+
notarizationProtocol?: number;
|
|
80
|
+
/** Proof protocol. Defaults to `CHAINID` (2) for a centralized token. */
|
|
81
|
+
proofProtocol?: number;
|
|
82
|
+
/** Block at which pre-launch ends / the token activates. Defaults to 0. */
|
|
83
|
+
startBlock?: number;
|
|
84
|
+
/** End-of-life block, 0 = no end. Defaults to 0. */
|
|
85
|
+
endBlock?: number;
|
|
86
|
+
/** Fractional supply available for pre-launch conversion (fractional only). */
|
|
87
|
+
initialSupply?: bigint;
|
|
88
|
+
/** Pre-allocation / premine recipients. */
|
|
89
|
+
preAllocations?: Array<{
|
|
90
|
+
address: string;
|
|
91
|
+
amount: bigint;
|
|
92
|
+
}>;
|
|
93
|
+
/** Reserve currency i-addresses (fractional basket). */
|
|
94
|
+
currencies?: string[];
|
|
95
|
+
/**
|
|
96
|
+
* Relative reserve weights, one positive int32 ratio per reserve currency.
|
|
97
|
+
* Normalized to sum to 1e8 exactly as `definecurrency` does (so `[0.4, 0.4]`
|
|
98
|
+
* expressed as `[40_000_000n, 40_000_000n]` becomes `[50_000_000n,
|
|
99
|
+
* 50_000_000n]`); pass values already summing to 1e8 for a no-op.
|
|
100
|
+
*/
|
|
101
|
+
weights?: bigint[];
|
|
102
|
+
/** Minimum per-reserve to launch (same length as `currencies`). */
|
|
103
|
+
minPreconversion?: bigint[];
|
|
104
|
+
/** Maximum per-reserve allowed (same length as `currencies`); each ≥ its minimum. */
|
|
105
|
+
maxPreconversion?: bigint[];
|
|
106
|
+
/** Pre-launch discount ratio (fractional < 100%). Defaults to 0. */
|
|
107
|
+
preLaunchDiscount?: bigint;
|
|
108
|
+
/** Pre-launch carve-out ratio in satoshis. Defaults to 0. */
|
|
109
|
+
preLaunchCarveOut?: number;
|
|
110
|
+
/** ID registration fee in native satoshis. Defaults to 100 native (1e10). */
|
|
111
|
+
idRegistrationFees?: bigint;
|
|
112
|
+
/** Referral levels. Defaults to 3. */
|
|
113
|
+
idReferralLevels?: number;
|
|
114
|
+
/**
|
|
115
|
+
* ID import fee in native satoshis. For a fractional currency this is instead
|
|
116
|
+
* the pricing-currency index into `currencies`. Defaults to 0.02 native.
|
|
117
|
+
*/
|
|
118
|
+
idImportFees?: bigint;
|
|
119
|
+
}
|
|
120
|
+
/** Fully resolved definition with all defaults applied. */
|
|
121
|
+
export interface NormalizedDefinition {
|
|
122
|
+
version: number;
|
|
123
|
+
options: number;
|
|
124
|
+
parent: string;
|
|
125
|
+
name: string;
|
|
126
|
+
launchSystemId: string;
|
|
127
|
+
systemId: string;
|
|
128
|
+
notarizationProtocol: number;
|
|
129
|
+
proofProtocol: number;
|
|
130
|
+
startBlock: number;
|
|
131
|
+
endBlock: number;
|
|
132
|
+
initialFractionalSupply: bigint;
|
|
133
|
+
preAllocations: Array<{
|
|
134
|
+
address: string;
|
|
135
|
+
amount: bigint;
|
|
136
|
+
}>;
|
|
137
|
+
gatewayConverterIssuance: bigint;
|
|
138
|
+
currencies: string[];
|
|
139
|
+
weights: bigint[];
|
|
140
|
+
conversions: bigint[];
|
|
141
|
+
minPreconversion: bigint[];
|
|
142
|
+
maxPreconversion: bigint[];
|
|
143
|
+
initialContributions: bigint[];
|
|
144
|
+
preconverted: bigint[];
|
|
145
|
+
preLaunchDiscount: bigint;
|
|
146
|
+
preLaunchCarveOut: number;
|
|
147
|
+
notaries: string[];
|
|
148
|
+
minNotariesConfirm: number;
|
|
149
|
+
idRegistrationFees: bigint;
|
|
150
|
+
idReferralLevels: number;
|
|
151
|
+
idImportFees: bigint;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Apply daemon-like defaults, enforce the token/basket scope, and normalize
|
|
155
|
+
* reserve weights. Exposed so the currency-launch output builders derive the
|
|
156
|
+
* notarization currency-state from the exact same normalized weights the
|
|
157
|
+
* definition output carries — the daemon validates one against the other.
|
|
158
|
+
*/
|
|
159
|
+
export declare function normalizeCurrencyDefinition(input: CurrencyDefinitionInput): NormalizedDefinition;
|
|
160
|
+
/**
|
|
161
|
+
* Serialize a normalized currency definition to its `AsVector()` bytes — the
|
|
162
|
+
* blob carried as `vData[0]` of the EVAL_CURRENCY_DEFINITION output. Field order
|
|
163
|
+
* and encodings mirror `CCurrencyDefinition::SerializationOp` for the
|
|
164
|
+
* token/basket (non-gateway, non-PBaaS) case.
|
|
165
|
+
*/
|
|
166
|
+
export declare function serializeNormalizedDefinition(def: NormalizedDefinition): Buffer;
|
|
167
|
+
/**
|
|
168
|
+
* Serialize a currency definition to its `CCurrencyDefinition::AsVector()` bytes.
|
|
169
|
+
* Exposed mainly for byte-level testing; most callers want
|
|
170
|
+
* {@link buildCurrencyDefinitionScript}.
|
|
171
|
+
*/
|
|
172
|
+
export declare function serializeCurrencyDefinition(input: CurrencyDefinitionInput): Buffer;
|
|
173
|
+
/**
|
|
174
|
+
* Build the EVAL_CURRENCY_DEFINITION CryptoCondition output script for a token or
|
|
175
|
+
* fractional basket, as a hex string — byte-equivalent to the output the daemon's
|
|
176
|
+
* `definecurrency` produces for the same parameters. For building, inspecting, or
|
|
177
|
+
* verifying a definition script offline; a full on-chain launch is a daemon
|
|
178
|
+
* operation (the transaction also needs live-state notarization outputs).
|
|
179
|
+
*/
|
|
180
|
+
export declare function buildCurrencyDefinitionScript(input: CurrencyDefinitionInput): string;
|
|
181
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/currency/definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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H,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,uBAAuB,GAAG,oBAAoB,CA6PhG;AAID;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAwC/E;AAKD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAMpF"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Offline serialization of a Verus currency definition (`CCurrencyDefinition`)
|
|
4
|
+
* into the `EVAL_CURRENCY_DEFINITION` CryptoCondition output script that a
|
|
5
|
+
* `definecurrency` transaction carries.
|
|
6
|
+
*
|
|
7
|
+
* This is a serialization primitive: it builds (and lets you inspect/verify) the
|
|
8
|
+
* definition output script byte-for-byte as the daemon would. It is NOT a
|
|
9
|
+
* currency launcher — a valid definition transaction also carries currency-state
|
|
10
|
+
* and notarization outputs validated against live chain state, so the actual
|
|
11
|
+
* launch is a daemon (`definecurrency`) operation, not an offline one.
|
|
12
|
+
*
|
|
13
|
+
* Scope: simple tokens (`OPTION_TOKEN`) and fractional reserve baskets
|
|
14
|
+
* (`OPTION_TOKEN | OPTION_FRACTIONAL`). PBaaS chains and gateways are rejected
|
|
15
|
+
* fail-closed — their serialization carries extra trailing fields (launch fees,
|
|
16
|
+
* issuance schedule, gateway converter) that this builder deliberately omits.
|
|
17
|
+
*
|
|
18
|
+
* The byte layout mirrors `CCurrencyDefinition::SerializationOp`
|
|
19
|
+
* (VerusCoin `src/pbaas/crosschainrpc.h`). A subtlety load-bearing for
|
|
20
|
+
* correctness: for a non-gateway, non-PBaaS currency the C++ `else` branch
|
|
21
|
+
* writes the five trailing fee fields (`currencyRegistrationFee` …
|
|
22
|
+
* `transactionExportFee`) into a *shadowed local stream*, so they never reach
|
|
23
|
+
* the wire — a token/basket definition ends at `idImportFees`. This is
|
|
24
|
+
* reproduced here and byte-locked against real on-chain definitions
|
|
25
|
+
* (see test/currency-definition.test.ts) rather than trusted from the header.
|
|
26
|
+
*
|
|
27
|
+
* The CC wrapper (OptCCParams master eval 0 + params eval 2, both m=1/n=1 to a
|
|
28
|
+
* single pubkey destination) sends to the daemon's hardcoded currency-definition
|
|
29
|
+
* pubkey (`CCcustom.cpp` `PBaaSDefinitionPubKey`), which is chain-independent.
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.PROOF_PROTOCOL = exports.NOTARIZATION_PROTOCOL = exports.CURRENCY_OPTION = exports.CURRENCY_DEFINITION_VERSION = void 0;
|
|
33
|
+
exports.normalizeCurrencyDefinition = normalizeCurrencyDefinition;
|
|
34
|
+
exports.serializeNormalizedDefinition = serializeNormalizedDefinition;
|
|
35
|
+
exports.serializeCurrencyDefinition = serializeCurrencyDefinition;
|
|
36
|
+
exports.buildCurrencyDefinitionScript = buildCurrencyDefinitionScript;
|
|
37
|
+
const index_js_1 = require("../utils/index.js");
|
|
38
|
+
const errors_js_1 = require("../errors.js");
|
|
39
|
+
const wire_js_1 = require("./wire.js");
|
|
40
|
+
/** Currency-definition data-structure version (`CCurrencyDefinition::VERSION_CURRENT`). */
|
|
41
|
+
exports.CURRENCY_DEFINITION_VERSION = 1;
|
|
42
|
+
/** Currency option bits (`CCurrencyDefinition::ECurrencyOptions`). */
|
|
43
|
+
exports.CURRENCY_OPTION = {
|
|
44
|
+
FRACTIONAL: 0x1,
|
|
45
|
+
ID_RESTRICTED: 0x2,
|
|
46
|
+
ID_STAKING: 0x4,
|
|
47
|
+
ID_REFERRALS: 0x8,
|
|
48
|
+
ID_REFERRALREQUIRED: 0x10,
|
|
49
|
+
TOKEN: 0x20,
|
|
50
|
+
SINGLECURRENCY: 0x40,
|
|
51
|
+
GATEWAY: 0x80,
|
|
52
|
+
PBAAS: 0x100,
|
|
53
|
+
GATEWAY_CONVERTER: 0x200,
|
|
54
|
+
GATEWAY_NAMECONTROLLER: 0x400,
|
|
55
|
+
NFT_TOKEN: 0x800,
|
|
56
|
+
NO_IDS: 0x1000,
|
|
57
|
+
};
|
|
58
|
+
/** Notarization protocol (`ENotarizationProtocol`). */
|
|
59
|
+
exports.NOTARIZATION_PROTOCOL = { AUTO: 1, NOTARY_CONFIRM: 2, NOTARY_CHAINID: 3 };
|
|
60
|
+
/** Proof protocol (`EProofProtocol`). */
|
|
61
|
+
exports.PROOF_PROTOCOL = { PBAASMMR: 1, CHAINID: 2, ETHNOTARIZATION: 3 };
|
|
62
|
+
/**
|
|
63
|
+
* The daemon's hardcoded destination pubkey for EVAL_CURRENCY_DEFINITION outputs
|
|
64
|
+
* (`src/cc/CCcustom.cpp` `PBaaSDefinitionPubKey`). Chain-independent — identical
|
|
65
|
+
* on VRSC and VRSCTEST — so it is safe to embed rather than derive.
|
|
66
|
+
*/
|
|
67
|
+
const CURRENCY_DEFINITION_PUBKEY = Buffer.from('02a0de91740d3d5a3a4a7990ae22315133d02f33716b339ebce88662d012224ef5', 'hex');
|
|
68
|
+
const DEFAULT_ID_REGISTRATION_FEE = 10000000000n; // 100 native
|
|
69
|
+
const DEFAULT_ID_IMPORT_FEE = 2000000n; // 0.02 native
|
|
70
|
+
const DEFAULT_ID_REFERRAL_LEVELS = 3;
|
|
71
|
+
// Consensus limits the daemon enforces (VerusCoin v1.2.17-1).
|
|
72
|
+
const MIN_RESERVE_RATIO = 5000000n; // 5% of SATOSHIDEN — the per-reserve weight floor (crosschainrpc.h MIN_RESERVE_RATIO)
|
|
73
|
+
const MAX_RESERVE_CURRENCIES = 10; // pbaasrpc.cpp:13613
|
|
74
|
+
const MAX_ID_REFERRAL_LEVELS = 5; // crosschainrpc.h MAX_ID_REFERRAL_LEVELS
|
|
75
|
+
const MIN_CURRENCY_LIFE = 480; // endBlock must be ≥ startBlock + this (pbaasrpc.cpp:13497)
|
|
76
|
+
const BLOCK_MAX = 0x7fffffff; // startBlock/endBlock are int32 on the wire
|
|
77
|
+
/**
|
|
78
|
+
* Apply daemon-like defaults, enforce the token/basket scope, and normalize
|
|
79
|
+
* reserve weights. Exposed so the currency-launch output builders derive the
|
|
80
|
+
* notarization currency-state from the exact same normalized weights the
|
|
81
|
+
* definition output carries — the daemon validates one against the other.
|
|
82
|
+
*/
|
|
83
|
+
function normalizeCurrencyDefinition(input) {
|
|
84
|
+
if (!input.name || input.name.includes('@')) {
|
|
85
|
+
throw new errors_js_1.TransactionBuildError('name must be a bare currency name without "@"');
|
|
86
|
+
}
|
|
87
|
+
if (!Number.isInteger(input.options)) {
|
|
88
|
+
throw new errors_js_1.TransactionBuildError('options is required (must include the TOKEN bit)');
|
|
89
|
+
}
|
|
90
|
+
if (!(input.options & exports.CURRENCY_OPTION.TOKEN)) {
|
|
91
|
+
throw new errors_js_1.TransactionBuildError('options must include the TOKEN bit (0x20); native currencies are out of scope');
|
|
92
|
+
}
|
|
93
|
+
if (input.options & (exports.CURRENCY_OPTION.GATEWAY | exports.CURRENCY_OPTION.PBAAS | exports.CURRENCY_OPTION.GATEWAY_CONVERTER)) {
|
|
94
|
+
throw new errors_js_1.TransactionBuildError('GATEWAY and PBAAS currencies are out of scope for the offline builder');
|
|
95
|
+
}
|
|
96
|
+
if (input.options < 0 || input.options > exports.CURRENCY_OPTION.NO_IDS * 2 - 1) {
|
|
97
|
+
throw new errors_js_1.TransactionBuildError(`options has bits outside the known mask: ${input.options}`);
|
|
98
|
+
}
|
|
99
|
+
// `conversions` and `initialContributions` are deliberately unsupported.
|
|
100
|
+
// definecurrency ignores an explicit `conversions` for a fractional currency
|
|
101
|
+
// (it derives prices at launch), and `initialContributions` seeds reserves the
|
|
102
|
+
// identity must already hold — requiring reserve-deposit inputs this offline
|
|
103
|
+
// builder does not assemble. Reject rather than silently drop, so a caller
|
|
104
|
+
// migrating from definecurrency JSON fails loud instead of shipping a
|
|
105
|
+
// definition the daemon would not have produced.
|
|
106
|
+
const legacy = input;
|
|
107
|
+
if (legacy.conversions !== undefined) {
|
|
108
|
+
throw new errors_js_1.TransactionBuildError('conversions are not supported: a fractional definition always carries a zero conversion vector (the daemon derives launch prices); omit the field');
|
|
109
|
+
}
|
|
110
|
+
if (legacy.initialContributions !== undefined) {
|
|
111
|
+
throw new errors_js_1.TransactionBuildError('initialContributions are out of scope: they seed reserves the identity must hold and require reserve-deposit inputs the offline builder cannot assemble; contribute via a preconvert reserve-transfer instead');
|
|
112
|
+
}
|
|
113
|
+
const isFractional = Boolean(input.options & exports.CURRENCY_OPTION.FRACTIONAL);
|
|
114
|
+
const isNFT = Boolean(input.options & exports.CURRENCY_OPTION.NFT_TOKEN);
|
|
115
|
+
const currencies = input.currencies ?? [];
|
|
116
|
+
const systemId = input.systemId ?? input.parent;
|
|
117
|
+
const launchSystemId = input.launchSystemId ?? systemId;
|
|
118
|
+
if (isNFT) {
|
|
119
|
+
// An NFT (tokenized ID control) is a single-satoshi token mapped to the
|
|
120
|
+
// native currency, NOT a fractional reserve. The daemon
|
|
121
|
+
// (`crosschainrpc.cpp`) auto-adds the system currency when maxpreconversion
|
|
122
|
+
// is [0], and the consensus precheck (`pbaas.cpp`) requires exactly 1 satoshi
|
|
123
|
+
// of pre-allocation with maxPreconvert=[0], and rejects a centralized
|
|
124
|
+
// (PROOF_CHAINID) proof protocol ("may not also be a centralized currency").
|
|
125
|
+
// Reproduce that canonical form here rather than making the caller know it.
|
|
126
|
+
if (isFractional) {
|
|
127
|
+
throw new errors_js_1.TransactionBuildError('an NFT (NFT_TOKEN) cannot also be FRACTIONAL');
|
|
128
|
+
}
|
|
129
|
+
if (currencies.length || input.weights?.length) {
|
|
130
|
+
throw new errors_js_1.TransactionBuildError('do not set currencies/weights for an NFT — the system currency is added automatically');
|
|
131
|
+
}
|
|
132
|
+
if (input.minPreconversion || input.maxPreconversion) {
|
|
133
|
+
throw new errors_js_1.TransactionBuildError('do not set min/maxPreconversion for an NFT — they are fixed (maxPreconversion=[0])');
|
|
134
|
+
}
|
|
135
|
+
if ((input.initialSupply ?? 0n) !== 0n || (input.preLaunchDiscount ?? 0n) !== 0n) {
|
|
136
|
+
throw new errors_js_1.TransactionBuildError('an NFT takes no initialSupply or preLaunchDiscount — its supply is the single 1-satoshi token');
|
|
137
|
+
}
|
|
138
|
+
if ((input.preLaunchCarveOut ?? 0) !== 0) {
|
|
139
|
+
throw new errors_js_1.TransactionBuildError('an NFT takes no preLaunchCarveOut');
|
|
140
|
+
}
|
|
141
|
+
const proofProtocol = input.proofProtocol ?? exports.PROOF_PROTOCOL.PBAASMMR;
|
|
142
|
+
if (proofProtocol === exports.PROOF_PROTOCOL.CHAINID) {
|
|
143
|
+
throw new errors_js_1.TransactionBuildError('an NFT may not use a centralized proof protocol (CHAINID/2); use PBAASMMR (1)');
|
|
144
|
+
}
|
|
145
|
+
const preAllocations = input.preAllocations ?? [];
|
|
146
|
+
const preallocTotal = preAllocations.reduce((sum, p) => sum + p.amount, 0n);
|
|
147
|
+
if (preallocTotal !== 1n) {
|
|
148
|
+
throw new errors_js_1.TransactionBuildError('an NFT must pre-allocate exactly 1 satoshi — the single indivisible token');
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
version: exports.CURRENCY_DEFINITION_VERSION,
|
|
152
|
+
options: input.options,
|
|
153
|
+
parent: input.parent,
|
|
154
|
+
name: input.name,
|
|
155
|
+
launchSystemId,
|
|
156
|
+
systemId,
|
|
157
|
+
notarizationProtocol: input.notarizationProtocol ?? exports.NOTARIZATION_PROTOCOL.AUTO,
|
|
158
|
+
proofProtocol,
|
|
159
|
+
startBlock: input.startBlock ?? 0,
|
|
160
|
+
endBlock: input.endBlock ?? 0,
|
|
161
|
+
initialFractionalSupply: 0n,
|
|
162
|
+
preAllocations,
|
|
163
|
+
gatewayConverterIssuance: 0n,
|
|
164
|
+
// The daemon maps the NFT to the native/system currency with a zeroed
|
|
165
|
+
// conversion and maxPreconvert=[0]; weights stay empty (not fractional).
|
|
166
|
+
currencies: [systemId],
|
|
167
|
+
weights: [],
|
|
168
|
+
conversions: [0n],
|
|
169
|
+
minPreconversion: [],
|
|
170
|
+
maxPreconversion: [0n],
|
|
171
|
+
initialContributions: [0n],
|
|
172
|
+
preconverted: [0n],
|
|
173
|
+
preLaunchDiscount: 0n,
|
|
174
|
+
preLaunchCarveOut: 0,
|
|
175
|
+
notaries: [],
|
|
176
|
+
minNotariesConfirm: 0,
|
|
177
|
+
idRegistrationFees: input.idRegistrationFees ?? DEFAULT_ID_REGISTRATION_FEE,
|
|
178
|
+
idReferralLevels: input.idReferralLevels ?? DEFAULT_ID_REFERRAL_LEVELS,
|
|
179
|
+
idImportFees: input.idImportFees ?? DEFAULT_ID_IMPORT_FEE,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (isFractional && currencies.length === 0) {
|
|
183
|
+
throw new errors_js_1.TransactionBuildError('a fractional currency requires at least one reserve currency');
|
|
184
|
+
}
|
|
185
|
+
if (!isFractional && currencies.length > 0) {
|
|
186
|
+
throw new errors_js_1.TransactionBuildError('reserve currencies require the FRACTIONAL bit (0x01)');
|
|
187
|
+
}
|
|
188
|
+
let fractionalWeights = [];
|
|
189
|
+
if (isFractional) {
|
|
190
|
+
// The daemon requires one weight per reserve and a positive initial supply.
|
|
191
|
+
// (It even-splits omitted weights, distributing the remainder to the FIRST
|
|
192
|
+
// currencies — a byte pattern the explicit path here can't reproduce — so
|
|
193
|
+
// fail closed and require explicit, already-relative weights instead.)
|
|
194
|
+
if (input.weights === undefined || input.weights.length !== currencies.length) {
|
|
195
|
+
throw new errors_js_1.TransactionBuildError(`a fractional currency requires one weight per reserve currency (${currencies.length})`);
|
|
196
|
+
}
|
|
197
|
+
if ((input.initialSupply ?? 0n) <= 0n) {
|
|
198
|
+
throw new errors_js_1.TransactionBuildError('a fractional currency requires a positive initialSupply (the daemon rejects zero)');
|
|
199
|
+
}
|
|
200
|
+
if (currencies.length > MAX_RESERVE_CURRENCIES) {
|
|
201
|
+
throw new errors_js_1.TransactionBuildError(`a fractional currency may have at most ${MAX_RESERVE_CURRENCIES} reserve currencies, got ${currencies.length}`);
|
|
202
|
+
}
|
|
203
|
+
// The chain's native currency must be among the reserves (pbaas.cpp:4103,
|
|
204
|
+
// pbaasrpc.cpp:13694 "Fractional currency requires a reserve of VRSC…").
|
|
205
|
+
if (!currencies.includes(systemId)) {
|
|
206
|
+
throw new errors_js_1.TransactionBuildError(`a fractional currency must include the chain's native currency (${systemId}) among its reserves`);
|
|
207
|
+
}
|
|
208
|
+
fractionalWeights = (0, wire_js_1.normalizeWeights)(input.weights);
|
|
209
|
+
// Every reserve must weigh at least 5% (crosschainrpc.h MIN_RESERVE_RATIO).
|
|
210
|
+
// NOTE: pre-launch carve-out, discount, and pre-allocation emission dilute
|
|
211
|
+
// weights further AT LAUNCH — this only checks the definition; keep headroom.
|
|
212
|
+
fractionalWeights.forEach((w, i) => {
|
|
213
|
+
if (w < MIN_RESERVE_RATIO) {
|
|
214
|
+
throw new errors_js_1.TransactionBuildError(`reserve weight[${i}] normalizes to ${w}, below the 5% minimum (${MIN_RESERVE_RATIO}); a fractional reserve may not go below 5%`);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// A non-fractional token has no reserve pool: the daemon reads initialSupply
|
|
220
|
+
// and preLaunchDiscount only for fractional currencies, so accepting them
|
|
221
|
+
// would serialize a definition `definecurrency` never emits (rejected at
|
|
222
|
+
// broadcast). Fail closed, mirroring the `conversions` rejection above.
|
|
223
|
+
if (input.initialSupply !== undefined && input.initialSupply !== 0n) {
|
|
224
|
+
throw new errors_js_1.TransactionBuildError('initialSupply applies only to a FRACTIONAL currency');
|
|
225
|
+
}
|
|
226
|
+
if (input.preLaunchDiscount !== undefined && input.preLaunchDiscount !== 0n) {
|
|
227
|
+
throw new errors_js_1.TransactionBuildError('preLaunchDiscount applies only to a FRACTIONAL currency');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Scalar-range checks the daemon enforces (crosschainrpc.cpp): block heights are
|
|
231
|
+
// non-negative integers, carve-out is non-negative, and every pre-allocation is
|
|
232
|
+
// a positive amount. Catch them here rather than serialize an unbroadcastable tx.
|
|
233
|
+
const requireBlock = (v, label) => {
|
|
234
|
+
if (!Number.isInteger(v) || v < 0 || v > BLOCK_MAX) {
|
|
235
|
+
throw new errors_js_1.TransactionBuildError(`${label} must be an integer block height in [0, ${BLOCK_MAX}], got ${v}`);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const startBlock = input.startBlock ?? 0;
|
|
239
|
+
const endBlock = input.endBlock ?? 0;
|
|
240
|
+
requireBlock(startBlock, 'startBlock');
|
|
241
|
+
requireBlock(endBlock, 'endBlock');
|
|
242
|
+
// A currency with an end block must live at least MIN_CURRENCY_LIFE blocks
|
|
243
|
+
// (pbaasrpc.cpp:13497); endBlock 0 means "no end".
|
|
244
|
+
if (endBlock !== 0 && endBlock < startBlock + MIN_CURRENCY_LIFE) {
|
|
245
|
+
throw new errors_js_1.TransactionBuildError(`endBlock (${endBlock}) must be 0 or ≥ startBlock + ${MIN_CURRENCY_LIFE} (${startBlock + MIN_CURRENCY_LIFE})`);
|
|
246
|
+
}
|
|
247
|
+
if ((input.idReferralLevels ?? DEFAULT_ID_REFERRAL_LEVELS) > MAX_ID_REFERRAL_LEVELS) {
|
|
248
|
+
throw new errors_js_1.TransactionBuildError(`idReferralLevels must be ≤ ${MAX_ID_REFERRAL_LEVELS}`);
|
|
249
|
+
}
|
|
250
|
+
if ((input.preLaunchCarveOut ?? 0) < 0) {
|
|
251
|
+
throw new errors_js_1.TransactionBuildError('preLaunchCarveOut must be non-negative');
|
|
252
|
+
}
|
|
253
|
+
(input.preAllocations ?? []).forEach((p, i) => {
|
|
254
|
+
if (p.amount <= 0n) {
|
|
255
|
+
throw new errors_js_1.TransactionBuildError(`preAllocations[${i}].amount must be positive, got ${p.amount}`);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
// Reserve-currency vectors, when present, must all match the currency count and
|
|
259
|
+
// hold non-negative amounts (the daemon rejects negatives). The daemon leaves
|
|
260
|
+
// min/max-preconversion empty when unspecified but zero-fills conversions /
|
|
261
|
+
// contributions / preconverted to the currency count; mirror that so an omitted
|
|
262
|
+
// field serializes identically to what `definecurrency` produces.
|
|
263
|
+
const checkVec = (arr, label) => {
|
|
264
|
+
if (arr.length !== currencies.length) {
|
|
265
|
+
throw new errors_js_1.TransactionBuildError(`${label} must have one entry per reserve currency (${currencies.length}), got ${arr.length}`);
|
|
266
|
+
}
|
|
267
|
+
arr.forEach((v, i) => {
|
|
268
|
+
if (v < 0n)
|
|
269
|
+
throw new errors_js_1.TransactionBuildError(`${label}[${i}] must be non-negative, got ${v}`);
|
|
270
|
+
});
|
|
271
|
+
return arr;
|
|
272
|
+
};
|
|
273
|
+
const emptyOr = (arr, label) => arr === undefined ? [] : checkVec(arr, label);
|
|
274
|
+
const zeros = () => new Array(currencies.length).fill(0n);
|
|
275
|
+
const minPreconversion = emptyOr(input.minPreconversion, 'minPreconversion');
|
|
276
|
+
const maxPreconversion = emptyOr(input.maxPreconversion, 'maxPreconversion');
|
|
277
|
+
// The daemon rejects any maximum below its own minimum (crosschainrpc.cpp).
|
|
278
|
+
if (minPreconversion.length && maxPreconversion.length) {
|
|
279
|
+
for (let i = 0; i < currencies.length; i++) {
|
|
280
|
+
const min = minPreconversion[i];
|
|
281
|
+
const max = maxPreconversion[i];
|
|
282
|
+
if (min !== undefined && max !== undefined && max < min) {
|
|
283
|
+
throw new errors_js_1.TransactionBuildError(`maxPreconversion[${i}] (${max}) must be ≥ minPreconversion[${i}] (${min})`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
version: exports.CURRENCY_DEFINITION_VERSION,
|
|
289
|
+
options: input.options,
|
|
290
|
+
parent: input.parent,
|
|
291
|
+
name: input.name,
|
|
292
|
+
launchSystemId,
|
|
293
|
+
systemId,
|
|
294
|
+
notarizationProtocol: input.notarizationProtocol ?? exports.NOTARIZATION_PROTOCOL.AUTO,
|
|
295
|
+
proofProtocol: input.proofProtocol ?? exports.PROOF_PROTOCOL.CHAINID,
|
|
296
|
+
startBlock: input.startBlock ?? 0,
|
|
297
|
+
endBlock: input.endBlock ?? 0,
|
|
298
|
+
initialFractionalSupply: input.initialSupply ?? 0n,
|
|
299
|
+
preAllocations: input.preAllocations ?? [],
|
|
300
|
+
gatewayConverterIssuance: 0n,
|
|
301
|
+
currencies,
|
|
302
|
+
// Normalized to sum to 1e8 (computed and range-checked above).
|
|
303
|
+
weights: fractionalWeights,
|
|
304
|
+
// A fractional definition always carries a zero conversion vector (the daemon
|
|
305
|
+
// ignores any explicit `conversions` and derives launch prices); a
|
|
306
|
+
// non-fractional token has no reserves, hence an empty vector.
|
|
307
|
+
conversions: zeros(),
|
|
308
|
+
minPreconversion,
|
|
309
|
+
maxPreconversion,
|
|
310
|
+
// `initialContributions` and `preconverted` are internal to a fresh
|
|
311
|
+
// definition: both carry a zero per reserve currency (empty for a
|
|
312
|
+
// non-fractional token). Matches on-chain definitions.
|
|
313
|
+
initialContributions: zeros(),
|
|
314
|
+
preconverted: zeros(),
|
|
315
|
+
preLaunchDiscount: (0, wire_js_1.requireInt32Range)(input.preLaunchDiscount ?? 0n, 'preLaunchDiscount'),
|
|
316
|
+
preLaunchCarveOut: input.preLaunchCarveOut ?? 0,
|
|
317
|
+
notaries: [],
|
|
318
|
+
minNotariesConfirm: 0,
|
|
319
|
+
idRegistrationFees: (0, wire_js_1.requireInt64Range)(input.idRegistrationFees ?? DEFAULT_ID_REGISTRATION_FEE, 'idRegistrationFees'),
|
|
320
|
+
idReferralLevels: input.idReferralLevels ?? DEFAULT_ID_REFERRAL_LEVELS,
|
|
321
|
+
idImportFees: (0, wire_js_1.requireInt64Range)(input.idImportFees ?? DEFAULT_ID_IMPORT_FEE, 'idImportFees'),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
const MAX_NAME_LEN = 64;
|
|
325
|
+
/**
|
|
326
|
+
* Serialize a normalized currency definition to its `AsVector()` bytes — the
|
|
327
|
+
* blob carried as `vData[0]` of the EVAL_CURRENCY_DEFINITION output. Field order
|
|
328
|
+
* and encodings mirror `CCurrencyDefinition::SerializationOp` for the
|
|
329
|
+
* token/basket (non-gateway, non-PBaaS) case.
|
|
330
|
+
*/
|
|
331
|
+
function serializeNormalizedDefinition(def) {
|
|
332
|
+
const parts = [
|
|
333
|
+
(0, wire_js_1.uint32LE)(def.version, 'version'),
|
|
334
|
+
(0, wire_js_1.uint32LE)(def.options, 'options'),
|
|
335
|
+
(0, wire_js_1.uint160)(def.parent, 'parent'),
|
|
336
|
+
(0, wire_js_1.limitedString)(def.name, MAX_NAME_LEN, 'name'),
|
|
337
|
+
(0, wire_js_1.uint160)(def.launchSystemId, 'launchSystemId'),
|
|
338
|
+
(0, wire_js_1.uint160)(def.systemId, 'systemId'),
|
|
339
|
+
(0, wire_js_1.int32LE)(def.notarizationProtocol, 'notarizationProtocol'),
|
|
340
|
+
(0, wire_js_1.int32LE)(def.proofProtocol, 'proofProtocol'),
|
|
341
|
+
// nativeCurrencyID: a null CTransferDestination (type 0, empty destination) → `0000`.
|
|
342
|
+
Buffer.from([0x00, 0x00]),
|
|
343
|
+
// gatewayID: null uint160 for a non-gateway currency → 20 zero bytes.
|
|
344
|
+
Buffer.alloc(20),
|
|
345
|
+
(0, wire_js_1.varInt)(BigInt(def.startBlock), 'startBlock'),
|
|
346
|
+
(0, wire_js_1.varInt)(BigInt(def.endBlock), 'endBlock'),
|
|
347
|
+
(0, wire_js_1.int64LE)(def.initialFractionalSupply, 'initialSupply'),
|
|
348
|
+
// preAllocation: CompactSize count, then (uint160 recipient, int64 amount) pairs.
|
|
349
|
+
(0, index_js_1.writeCompactSize)(def.preAllocations.length),
|
|
350
|
+
...def.preAllocations.flatMap((p, i) => [
|
|
351
|
+
(0, wire_js_1.uint160)(p.address, `preAllocations[${i}].address`),
|
|
352
|
+
(0, wire_js_1.int64LE)(p.amount, `preAllocations[${i}].amount`),
|
|
353
|
+
]),
|
|
354
|
+
(0, wire_js_1.int64LE)(def.gatewayConverterIssuance, 'gatewayConverterIssuance'),
|
|
355
|
+
(0, wire_js_1.vectorU160)(def.currencies, 'currencies'),
|
|
356
|
+
(0, wire_js_1.vectorI32)(def.weights, 'weights'),
|
|
357
|
+
(0, wire_js_1.vectorI64)(def.conversions, 'conversions'),
|
|
358
|
+
(0, wire_js_1.vectorI64)(def.minPreconversion, 'minPreconversion'),
|
|
359
|
+
(0, wire_js_1.vectorI64)(def.maxPreconversion, 'maxPreconversion'),
|
|
360
|
+
(0, wire_js_1.vectorI64)(def.initialContributions, 'initialContributions'),
|
|
361
|
+
(0, wire_js_1.vectorI64)(def.preconverted, 'preconverted'),
|
|
362
|
+
(0, wire_js_1.varInt)(def.preLaunchDiscount, 'preLaunchDiscount'),
|
|
363
|
+
(0, wire_js_1.int32LE)(def.preLaunchCarveOut, 'preLaunchCarveOut'),
|
|
364
|
+
(0, wire_js_1.vectorU160)(def.notaries, 'notaries'),
|
|
365
|
+
(0, wire_js_1.varInt)(BigInt(def.minNotariesConfirm), 'minNotariesConfirm'),
|
|
366
|
+
(0, wire_js_1.varInt)(def.idRegistrationFees, 'idRegistrationFees'),
|
|
367
|
+
(0, wire_js_1.varInt)(BigInt(def.idReferralLevels), 'idReferralLevels'),
|
|
368
|
+
(0, wire_js_1.varInt)(def.idImportFees, 'idImportFees'),
|
|
369
|
+
];
|
|
370
|
+
return Buffer.concat(parts);
|
|
371
|
+
}
|
|
372
|
+
/** EVAL_CURRENCY_DEFINITION (=2). */
|
|
373
|
+
const EVAL_CURRENCY_DEFINITION = 2;
|
|
374
|
+
/**
|
|
375
|
+
* Serialize a currency definition to its `CCurrencyDefinition::AsVector()` bytes.
|
|
376
|
+
* Exposed mainly for byte-level testing; most callers want
|
|
377
|
+
* {@link buildCurrencyDefinitionScript}.
|
|
378
|
+
*/
|
|
379
|
+
function serializeCurrencyDefinition(input) {
|
|
380
|
+
return serializeNormalizedDefinition(normalizeCurrencyDefinition(input));
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Build the EVAL_CURRENCY_DEFINITION CryptoCondition output script for a token or
|
|
384
|
+
* fractional basket, as a hex string — byte-equivalent to the output the daemon's
|
|
385
|
+
* `definecurrency` produces for the same parameters. For building, inspecting, or
|
|
386
|
+
* verifying a definition script offline; a full on-chain launch is a daemon
|
|
387
|
+
* operation (the transaction also needs live-state notarization outputs).
|
|
388
|
+
*/
|
|
389
|
+
function buildCurrencyDefinitionScript(input) {
|
|
390
|
+
const defBytes = serializeNormalizedDefinition(normalizeCurrencyDefinition(input));
|
|
391
|
+
return (0, wire_js_1.wrapCcOutput)(EVAL_CURRENCY_DEFINITION, [defBytes], {
|
|
392
|
+
kind: 'pubkey',
|
|
393
|
+
pubkey: CURRENCY_DEFINITION_PUBKEY,
|
|
394
|
+
}).toString('hex');
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/currency/definition.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAqKH,kEA6PC;AAUD,sEAwCC;AAUD,kEAEC;AASD,sEAMC;AA7eD,gDAAqD;AACrD,4CAAqD;AACrD,uCAcmB;AAEnB,2FAA2F;AAC9E,QAAA,2BAA2B,GAAG,CAAC,CAAC;AAE7C,sEAAsE;AACzD,QAAA,eAAe,GAAG;IAC7B,UAAU,EAAE,GAAG;IACf,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,GAAG;IACf,YAAY,EAAE,GAAG;IACjB,mBAAmB,EAAE,IAAI;IACzB,KAAK,EAAE,IAAI;IACX,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,KAAK;IACZ,iBAA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,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAAC,KAA8B;IAC1E,MAAM,QAAQ,GAAG,6BAA6B,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC;IACnF,OAAO,IAAA,sBAAY,EAAC,wBAAwB,EAAE,CAAC,QAAQ,CAAC,EAAE;QACxD,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,0BAA0B;KACnC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC"}
|
package/dist/currency/index.d.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Currency
|
|
2
|
+
* Currency helpers — all offline, byte-equivalent to the daemon.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* - `buildCurrencyDefinitionScript` / `serializeCurrencyDefinition`: the
|
|
5
|
+
* EVAL_CURRENCY_DEFINITION output script (token, fractional basket, or NFT).
|
|
6
|
+
* - `buildCurrencyLaunchOutputs`: all seven outputs of a currency-definition tx.
|
|
7
|
+
* - `buildCurrencyLaunchTransaction`: a complete, signed, broadcastable launch.
|
|
8
|
+
* - `buildReserveTransferOutput`: the (pre)convert output for investing in a
|
|
9
|
+
* launching currency.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 2. The identity's FLAG_ACTIVECURRENCY must be set
|
|
10
|
-
* 3. A currency definition output (EVAL_CURRENCY_DEFINITION)
|
|
11
|
+
* `defineCurrency` is a narrower helper (identity-spend + a pre-built definition
|
|
12
|
+
* output + change); prefer `buildCurrencyLaunchTransaction` for a full launch.
|
|
11
13
|
*/
|
|
12
14
|
export { classifyCurrency, CURRENCY_TYPE_ORDER } from './classify.js';
|
|
13
15
|
export type { CurrencyType } from './classify.js';
|
|
16
|
+
export { serializeCurrencyDefinition, buildCurrencyDefinitionScript, CURRENCY_OPTION, CURRENCY_DEFINITION_VERSION, NOTARIZATION_PROTOCOL, PROOF_PROTOCOL, } from './definition.js';
|
|
17
|
+
export type { CurrencyDefinitionInput } from './definition.js';
|
|
18
|
+
export { buildCurrencyLaunchOutputs } from './outputs.js';
|
|
19
|
+
export type { CurrencyLaunchContext, CurrencyLaunchOutputs, CurrencyLaunchOutput } from './outputs.js';
|
|
20
|
+
export { buildCurrencyLaunchTransaction } from './launch.js';
|
|
21
|
+
export type { CurrencyLaunchTxParams, CurrencyLaunchTxResult } from './launch.js';
|
|
22
|
+
export { buildReserveTransferOutput } from './reserveTransfer.js';
|
|
23
|
+
export type { ReserveTransferParams, ReserveTransferBuildResult } from './reserveTransfer.js';
|
|
14
24
|
import type { Network } from '../constants/index.js';
|
|
15
25
|
import type { DefineCurrencyParams, DefineCurrencyResult } from '../types/index.js';
|
|
16
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAK/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGvG,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIlF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,OAAO,GACf,oBAAoB,CAoEtB"}
|