phantasma-sdk-ts 0.8.0 → 0.8.2
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/dist/cjs/types/carbon/blockchain/modules/builders/token-info-builder.js +2 -1
- package/dist/cjs/types/carbon/blockchain/tx-helpers/fee-options.js +70 -10
- package/dist/cjs/types/carbon/blockchain/tx-helpers/mint-non-fungible-tx-helper.js +1 -1
- package/dist/cjs/types/carbon/blockchain/tx-helpers/mint-phantasma-non-fungible-tx-helper.js +1 -1
- package/dist/cjs/types/extensions/p-binary-writer.js +2 -22
- package/dist/esm/types/carbon/blockchain/modules/builders/token-info-builder.js +2 -1
- package/dist/esm/types/carbon/blockchain/tx-helpers/fee-options.js +70 -10
- package/dist/esm/types/carbon/blockchain/tx-helpers/mint-non-fungible-tx-helper.js +1 -1
- package/dist/esm/types/carbon/blockchain/tx-helpers/mint-phantasma-non-fungible-tx-helper.js +1 -1
- package/dist/esm/types/extensions/p-binary-writer.js +2 -22
- package/dist/types/types/carbon/blockchain/modules/builders/token-info-builder.d.ts.map +1 -1
- package/dist/types/types/carbon/blockchain/tx-helpers/fee-options.d.ts +10 -1
- package/dist/types/types/carbon/blockchain/tx-helpers/fee-options.d.ts.map +1 -1
- package/dist/types/types/extensions/p-binary-writer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ class TokenInfoBuilder {
|
|
|
13
13
|
}
|
|
14
14
|
const tokenInfo = new token_info_js_1.TokenInfo();
|
|
15
15
|
tokenInfo.maxSupply = maxSupply;
|
|
16
|
+
const isUnlimited = maxSupply.toBigInt() === 0n;
|
|
16
17
|
tokenInfo.flags = 0; // Small fungible
|
|
17
18
|
if (isNFT) {
|
|
18
19
|
if (!maxSupply.is8ByteSafe()) {
|
|
@@ -21,7 +22,7 @@ class TokenInfoBuilder {
|
|
|
21
22
|
tokenInfo.flags = carbon_token_flags_js_1.CarbonTokenFlags.NonFungible;
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
if (!maxSupply.is8ByteSafe()) {
|
|
25
|
+
if (isUnlimited || !maxSupply.is8ByteSafe()) {
|
|
25
26
|
tokenInfo.flags = carbon_token_flags_js_1.CarbonTokenFlags.BigFungible;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -2,14 +2,76 @@
|
|
|
2
2
|
// namespace PhantasmaPhoenix.Protocol.Carbon.Blockchain.TxHelpers
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MintNftFeeOptions = exports.CreateSeriesFeeOptions = exports.CreateTokenFeeOptions = exports.FeeOptions = void 0;
|
|
5
|
+
function assertArgCount(args, max, methodName) {
|
|
6
|
+
if (args.length > max) {
|
|
7
|
+
throw new TypeError(`${methodName} accepts at most ${max} argument${max === 1 ? '' : 's'}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function parsePositiveCount(value, methodName) {
|
|
11
|
+
if (typeof value === 'bigint') {
|
|
12
|
+
if (value <= 0n) {
|
|
13
|
+
throw new RangeError(`${methodName} count must be a positive integer`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'number') {
|
|
18
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
19
|
+
throw new RangeError(`${methodName} count must be a positive safe integer`);
|
|
20
|
+
}
|
|
21
|
+
return BigInt(value);
|
|
22
|
+
}
|
|
23
|
+
throw new TypeError(`${methodName} count must be a number or bigint`);
|
|
24
|
+
}
|
|
25
|
+
function parseOptionalCount(args, methodName) {
|
|
26
|
+
assertArgCount(args, 1, methodName);
|
|
27
|
+
return args.length === 0 ? 1n : parsePositiveCount(args[0], methodName);
|
|
28
|
+
}
|
|
29
|
+
function parseOptionalMintCount(args, methodName) {
|
|
30
|
+
assertArgCount(args, 1, methodName);
|
|
31
|
+
if (args.length === 0) {
|
|
32
|
+
return 1n;
|
|
33
|
+
}
|
|
34
|
+
const value = args[0];
|
|
35
|
+
return Array.isArray(value)
|
|
36
|
+
? parsePositiveCount(value.length, methodName)
|
|
37
|
+
: parsePositiveCount(value, methodName);
|
|
38
|
+
}
|
|
39
|
+
function assertNoMeaningfulCount(args, methodName) {
|
|
40
|
+
assertArgCount(args, 1, methodName);
|
|
41
|
+
if (args.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const count = parsePositiveCount(args[0], methodName);
|
|
45
|
+
if (count !== 1n) {
|
|
46
|
+
throw new RangeError(`${methodName} is not count-sensitive; count must be 1 when provided`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function parseOptionalSymbol(args, methodName) {
|
|
50
|
+
assertArgCount(args, 1, methodName);
|
|
51
|
+
if (args.length === 0) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
const value = args[0];
|
|
55
|
+
if (typeof value === 'string') {
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
if (typeof value === 'object' &&
|
|
59
|
+
value !== null &&
|
|
60
|
+
'data' in value &&
|
|
61
|
+
typeof value.data === 'string') {
|
|
62
|
+
return value.data;
|
|
63
|
+
}
|
|
64
|
+
throw new TypeError(`${methodName} symbol must be a string or SmallString-like object`);
|
|
65
|
+
}
|
|
5
66
|
/** Base fee options with sensible defaults. */
|
|
6
67
|
class FeeOptions {
|
|
7
68
|
constructor(gasFeeBase = 10000n, feeMultiplier = 1000n) {
|
|
8
69
|
this.gasFeeBase = gasFeeBase;
|
|
9
70
|
this.feeMultiplier = feeMultiplier;
|
|
10
71
|
}
|
|
11
|
-
calculateMaxGas() {
|
|
12
|
-
|
|
72
|
+
calculateMaxGas(...args) {
|
|
73
|
+
const count = parseOptionalCount(args, 'FeeOptions.calculateMaxGas');
|
|
74
|
+
return this.gasFeeBase * this.feeMultiplier * count;
|
|
13
75
|
}
|
|
14
76
|
}
|
|
15
77
|
exports.FeeOptions = FeeOptions;
|
|
@@ -21,11 +83,7 @@ class CreateTokenFeeOptions extends FeeOptions {
|
|
|
21
83
|
this.gasFeeCreateTokenSymbol = gasFeeCreateTokenSymbol;
|
|
22
84
|
}
|
|
23
85
|
calculateMaxGas(...args) {
|
|
24
|
-
|
|
25
|
-
if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null && 'data' in args[0]) {
|
|
26
|
-
const s = args[0];
|
|
27
|
-
symbol = s.data;
|
|
28
|
-
}
|
|
86
|
+
const symbol = parseOptionalSymbol(args, 'CreateTokenFeeOptions.calculateMaxGas');
|
|
29
87
|
const symbolLen = symbol.length;
|
|
30
88
|
const shift = symbolLen > 0 ? BigInt(symbolLen - 1) : 0n;
|
|
31
89
|
const symbolCost = this.gasFeeCreateTokenSymbol >> shift;
|
|
@@ -39,7 +97,8 @@ class CreateSeriesFeeOptions extends FeeOptions {
|
|
|
39
97
|
super(gasFeeBase, feeMultiplier);
|
|
40
98
|
this.gasFeeCreateSeriesBase = gasFeeCreateSeriesBase;
|
|
41
99
|
}
|
|
42
|
-
calculateMaxGas() {
|
|
100
|
+
calculateMaxGas(...args) {
|
|
101
|
+
assertNoMeaningfulCount(args, 'CreateSeriesFeeOptions.calculateMaxGas');
|
|
43
102
|
return (this.gasFeeBase + this.gasFeeCreateSeriesBase) * this.feeMultiplier;
|
|
44
103
|
}
|
|
45
104
|
}
|
|
@@ -49,8 +108,9 @@ class MintNftFeeOptions extends FeeOptions {
|
|
|
49
108
|
constructor(gasFeeBase = 10000n, feeMultiplier = 1000n) {
|
|
50
109
|
super(gasFeeBase, feeMultiplier);
|
|
51
110
|
}
|
|
52
|
-
calculateMaxGas() {
|
|
53
|
-
|
|
111
|
+
calculateMaxGas(...args) {
|
|
112
|
+
const count = parseOptionalMintCount(args, 'MintNftFeeOptions.calculateMaxGas');
|
|
113
|
+
return this.gasFeeBase * this.feeMultiplier * count;
|
|
54
114
|
}
|
|
55
115
|
}
|
|
56
116
|
exports.MintNftFeeOptions = MintNftFeeOptions;
|
|
@@ -15,7 +15,7 @@ class MintNonFungibleTxHelper {
|
|
|
15
15
|
// Build a Tx without signing
|
|
16
16
|
static buildTx(carbonTokenId, carbonSeriesId, senderPublicKey, receiverPublicKey, rom, ram, feeOptions, maxData, expiry) {
|
|
17
17
|
const fees = feeOptions ?? new fee_options_js_1.MintNftFeeOptions();
|
|
18
|
-
const maxGas = fees.calculateMaxGas();
|
|
18
|
+
const maxGas = fees.calculateMaxGas(1);
|
|
19
19
|
const msg = new tx_msg_js_1.TxMsg();
|
|
20
20
|
msg.type = tx_types_js_1.TxTypes.MintNonFungible;
|
|
21
21
|
msg.expiry = expiry ?? BigInt(Date.now() + 60000);
|
package/dist/cjs/types/carbon/blockchain/tx-helpers/mint-phantasma-non-fungible-tx-helper.js
CHANGED
|
@@ -43,7 +43,7 @@ class MintPhantasmaNonFungibleTxHelper {
|
|
|
43
43
|
}
|
|
44
44
|
static buildTxCore(tokenId, senderPublicKey, receiverPublicKey, tokens, feeOptions, maxData, expiry) {
|
|
45
45
|
const fees = feeOptions ?? new fee_options_js_1.MintNftFeeOptions();
|
|
46
|
-
const maxGas = fees.calculateMaxGas();
|
|
46
|
+
const maxGas = fees.calculateMaxGas(tokens);
|
|
47
47
|
// This helper only packages the Token.Call ABI surface.
|
|
48
48
|
const args = new index_js_2.MintPhantasmaNonFungibleArgs({
|
|
49
49
|
tokenId,
|
|
@@ -4,6 +4,7 @@ exports.PBinaryWriter = void 0;
|
|
|
4
4
|
const csharp_binary_stream_1 = require("csharp-binary-stream");
|
|
5
5
|
const index_js_1 = require("../../utils/index.js");
|
|
6
6
|
const index_js_2 = require("../../interfaces/index.js");
|
|
7
|
+
const phantasma_big_int_serialization_js_1 = require("../phantasma-big-int-serialization.js");
|
|
7
8
|
class PBinaryWriter {
|
|
8
9
|
constructor(arg1) {
|
|
9
10
|
this.writer = arg1 === undefined ? new csharp_binary_stream_1.BinaryWriter() : new csharp_binary_stream_1.BinaryWriter(arg1);
|
|
@@ -191,28 +192,7 @@ class PBinaryWriter {
|
|
|
191
192
|
return this.writeBigIntegerString(value.toString());
|
|
192
193
|
}
|
|
193
194
|
writeBigIntegerString(value) {
|
|
194
|
-
|
|
195
|
-
if (value == '0') {
|
|
196
|
-
bytes = [0];
|
|
197
|
-
}
|
|
198
|
-
else if (value.startsWith('-1')) {
|
|
199
|
-
throw new Error('Unsigned bigint serialization not suppoted');
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
let hex = BigInt(value).toString(16);
|
|
203
|
-
if (hex.length % 2)
|
|
204
|
-
hex = '0' + hex;
|
|
205
|
-
const len = hex.length / 2;
|
|
206
|
-
let i = 0;
|
|
207
|
-
let j = 0;
|
|
208
|
-
while (i < len) {
|
|
209
|
-
bytes.unshift(parseInt(hex.slice(j, j + 2), 16)); // little endian
|
|
210
|
-
i += 1;
|
|
211
|
-
j += 2;
|
|
212
|
-
}
|
|
213
|
-
bytes.push(0); // add sign at the end
|
|
214
|
-
}
|
|
215
|
-
return this.writeByteArray(bytes);
|
|
195
|
+
return this.writeByteArray((0, phantasma_big_int_serialization_js_1.bigIntToTwosComplementLE_phantasma)(BigInt(value)));
|
|
216
196
|
}
|
|
217
197
|
writeSignature(signature) {
|
|
218
198
|
if (!signature) {
|
|
@@ -10,6 +10,7 @@ export class TokenInfoBuilder {
|
|
|
10
10
|
}
|
|
11
11
|
const tokenInfo = new TokenInfo();
|
|
12
12
|
tokenInfo.maxSupply = maxSupply;
|
|
13
|
+
const isUnlimited = maxSupply.toBigInt() === 0n;
|
|
13
14
|
tokenInfo.flags = 0; // Small fungible
|
|
14
15
|
if (isNFT) {
|
|
15
16
|
if (!maxSupply.is8ByteSafe()) {
|
|
@@ -18,7 +19,7 @@ export class TokenInfoBuilder {
|
|
|
18
19
|
tokenInfo.flags = CarbonTokenFlags.NonFungible;
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
if (!maxSupply.is8ByteSafe()) {
|
|
22
|
+
if (isUnlimited || !maxSupply.is8ByteSafe()) {
|
|
22
23
|
tokenInfo.flags = CarbonTokenFlags.BigFungible;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -1,12 +1,74 @@
|
|
|
1
1
|
// namespace PhantasmaPhoenix.Protocol.Carbon.Blockchain.TxHelpers
|
|
2
|
+
function assertArgCount(args, max, methodName) {
|
|
3
|
+
if (args.length > max) {
|
|
4
|
+
throw new TypeError(`${methodName} accepts at most ${max} argument${max === 1 ? '' : 's'}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function parsePositiveCount(value, methodName) {
|
|
8
|
+
if (typeof value === 'bigint') {
|
|
9
|
+
if (value <= 0n) {
|
|
10
|
+
throw new RangeError(`${methodName} count must be a positive integer`);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === 'number') {
|
|
15
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
16
|
+
throw new RangeError(`${methodName} count must be a positive safe integer`);
|
|
17
|
+
}
|
|
18
|
+
return BigInt(value);
|
|
19
|
+
}
|
|
20
|
+
throw new TypeError(`${methodName} count must be a number or bigint`);
|
|
21
|
+
}
|
|
22
|
+
function parseOptionalCount(args, methodName) {
|
|
23
|
+
assertArgCount(args, 1, methodName);
|
|
24
|
+
return args.length === 0 ? 1n : parsePositiveCount(args[0], methodName);
|
|
25
|
+
}
|
|
26
|
+
function parseOptionalMintCount(args, methodName) {
|
|
27
|
+
assertArgCount(args, 1, methodName);
|
|
28
|
+
if (args.length === 0) {
|
|
29
|
+
return 1n;
|
|
30
|
+
}
|
|
31
|
+
const value = args[0];
|
|
32
|
+
return Array.isArray(value)
|
|
33
|
+
? parsePositiveCount(value.length, methodName)
|
|
34
|
+
: parsePositiveCount(value, methodName);
|
|
35
|
+
}
|
|
36
|
+
function assertNoMeaningfulCount(args, methodName) {
|
|
37
|
+
assertArgCount(args, 1, methodName);
|
|
38
|
+
if (args.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const count = parsePositiveCount(args[0], methodName);
|
|
42
|
+
if (count !== 1n) {
|
|
43
|
+
throw new RangeError(`${methodName} is not count-sensitive; count must be 1 when provided`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function parseOptionalSymbol(args, methodName) {
|
|
47
|
+
assertArgCount(args, 1, methodName);
|
|
48
|
+
if (args.length === 0) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
const value = args[0];
|
|
52
|
+
if (typeof value === 'string') {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === 'object' &&
|
|
56
|
+
value !== null &&
|
|
57
|
+
'data' in value &&
|
|
58
|
+
typeof value.data === 'string') {
|
|
59
|
+
return value.data;
|
|
60
|
+
}
|
|
61
|
+
throw new TypeError(`${methodName} symbol must be a string or SmallString-like object`);
|
|
62
|
+
}
|
|
2
63
|
/** Base fee options with sensible defaults. */
|
|
3
64
|
export class FeeOptions {
|
|
4
65
|
constructor(gasFeeBase = 10000n, feeMultiplier = 1000n) {
|
|
5
66
|
this.gasFeeBase = gasFeeBase;
|
|
6
67
|
this.feeMultiplier = feeMultiplier;
|
|
7
68
|
}
|
|
8
|
-
calculateMaxGas() {
|
|
9
|
-
|
|
69
|
+
calculateMaxGas(...args) {
|
|
70
|
+
const count = parseOptionalCount(args, 'FeeOptions.calculateMaxGas');
|
|
71
|
+
return this.gasFeeBase * this.feeMultiplier * count;
|
|
10
72
|
}
|
|
11
73
|
}
|
|
12
74
|
/** Fee options for token creation transactions. */
|
|
@@ -17,11 +79,7 @@ export class CreateTokenFeeOptions extends FeeOptions {
|
|
|
17
79
|
this.gasFeeCreateTokenSymbol = gasFeeCreateTokenSymbol;
|
|
18
80
|
}
|
|
19
81
|
calculateMaxGas(...args) {
|
|
20
|
-
|
|
21
|
-
if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null && 'data' in args[0]) {
|
|
22
|
-
const s = args[0];
|
|
23
|
-
symbol = s.data;
|
|
24
|
-
}
|
|
82
|
+
const symbol = parseOptionalSymbol(args, 'CreateTokenFeeOptions.calculateMaxGas');
|
|
25
83
|
const symbolLen = symbol.length;
|
|
26
84
|
const shift = symbolLen > 0 ? BigInt(symbolLen - 1) : 0n;
|
|
27
85
|
const symbolCost = this.gasFeeCreateTokenSymbol >> shift;
|
|
@@ -34,7 +92,8 @@ export class CreateSeriesFeeOptions extends FeeOptions {
|
|
|
34
92
|
super(gasFeeBase, feeMultiplier);
|
|
35
93
|
this.gasFeeCreateSeriesBase = gasFeeCreateSeriesBase;
|
|
36
94
|
}
|
|
37
|
-
calculateMaxGas() {
|
|
95
|
+
calculateMaxGas(...args) {
|
|
96
|
+
assertNoMeaningfulCount(args, 'CreateSeriesFeeOptions.calculateMaxGas');
|
|
38
97
|
return (this.gasFeeBase + this.gasFeeCreateSeriesBase) * this.feeMultiplier;
|
|
39
98
|
}
|
|
40
99
|
}
|
|
@@ -43,7 +102,8 @@ export class MintNftFeeOptions extends FeeOptions {
|
|
|
43
102
|
constructor(gasFeeBase = 10000n, feeMultiplier = 1000n) {
|
|
44
103
|
super(gasFeeBase, feeMultiplier);
|
|
45
104
|
}
|
|
46
|
-
calculateMaxGas() {
|
|
47
|
-
|
|
105
|
+
calculateMaxGas(...args) {
|
|
106
|
+
const count = parseOptionalMintCount(args, 'MintNftFeeOptions.calculateMaxGas');
|
|
107
|
+
return this.gasFeeBase * this.feeMultiplier * count;
|
|
48
108
|
}
|
|
49
109
|
}
|
|
@@ -12,7 +12,7 @@ export class MintNonFungibleTxHelper {
|
|
|
12
12
|
// Build a Tx without signing
|
|
13
13
|
static buildTx(carbonTokenId, carbonSeriesId, senderPublicKey, receiverPublicKey, rom, ram, feeOptions, maxData, expiry) {
|
|
14
14
|
const fees = feeOptions ?? new MintNftFeeOptions();
|
|
15
|
-
const maxGas = fees.calculateMaxGas();
|
|
15
|
+
const maxGas = fees.calculateMaxGas(1);
|
|
16
16
|
const msg = new TxMsg();
|
|
17
17
|
msg.type = TxTypes.MintNonFungible;
|
|
18
18
|
msg.expiry = expiry ?? BigInt(Date.now() + 60000);
|
package/dist/esm/types/carbon/blockchain/tx-helpers/mint-phantasma-non-fungible-tx-helper.js
CHANGED
|
@@ -40,7 +40,7 @@ export class MintPhantasmaNonFungibleTxHelper {
|
|
|
40
40
|
}
|
|
41
41
|
static buildTxCore(tokenId, senderPublicKey, receiverPublicKey, tokens, feeOptions, maxData, expiry) {
|
|
42
42
|
const fees = feeOptions ?? new MintNftFeeOptions();
|
|
43
|
-
const maxGas = fees.calculateMaxGas();
|
|
43
|
+
const maxGas = fees.calculateMaxGas(tokens);
|
|
44
44
|
// This helper only packages the Token.Call ABI surface.
|
|
45
45
|
const args = new MintPhantasmaNonFungibleArgs({
|
|
46
46
|
tokenId,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BinaryWriter } from 'csharp-binary-stream';
|
|
2
2
|
import { hexToBytes } from '../../utils/index.js';
|
|
3
3
|
import { SignatureKind } from '../../interfaces/index.js';
|
|
4
|
+
import { bigIntToTwosComplementLE_phantasma } from '../phantasma-big-int-serialization.js';
|
|
4
5
|
export class PBinaryWriter {
|
|
5
6
|
constructor(arg1) {
|
|
6
7
|
this.writer = arg1 === undefined ? new BinaryWriter() : new BinaryWriter(arg1);
|
|
@@ -188,28 +189,7 @@ export class PBinaryWriter {
|
|
|
188
189
|
return this.writeBigIntegerString(value.toString());
|
|
189
190
|
}
|
|
190
191
|
writeBigIntegerString(value) {
|
|
191
|
-
|
|
192
|
-
if (value == '0') {
|
|
193
|
-
bytes = [0];
|
|
194
|
-
}
|
|
195
|
-
else if (value.startsWith('-1')) {
|
|
196
|
-
throw new Error('Unsigned bigint serialization not suppoted');
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
let hex = BigInt(value).toString(16);
|
|
200
|
-
if (hex.length % 2)
|
|
201
|
-
hex = '0' + hex;
|
|
202
|
-
const len = hex.length / 2;
|
|
203
|
-
let i = 0;
|
|
204
|
-
let j = 0;
|
|
205
|
-
while (i < len) {
|
|
206
|
-
bytes.unshift(parseInt(hex.slice(j, j + 2), 16)); // little endian
|
|
207
|
-
i += 1;
|
|
208
|
-
j += 2;
|
|
209
|
-
}
|
|
210
|
-
bytes.push(0); // add sign at the end
|
|
211
|
-
}
|
|
212
|
-
return this.writeByteArray(bytes);
|
|
192
|
+
return this.writeByteArray(bigIntToTwosComplementLE_phantasma(BigInt(value)));
|
|
213
193
|
}
|
|
214
194
|
writeSignature(signature) {
|
|
215
195
|
if (!signature) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-info-builder.d.ts","sourceRoot":"","sources":["../../../../../../../src/types/carbon/blockchain/modules/builders/token-info-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,KAAK,CACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,OAAO,EACzB,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACxC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAC7C,SAAS;
|
|
1
|
+
{"version":3,"file":"token-info-builder.d.ts","sourceRoot":"","sources":["../../../../../../../src/types/carbon/blockchain/modules/builders/token-info-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,KAAK,CACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,OAAO,EACzB,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACxC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAC7C,SAAS;IA0CZ,MAAM,CAAC,eAAe,EAAE,MAAM,CAAO;IACrC;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;CAsBjF"}
|
|
@@ -5,19 +5,25 @@ export interface FeeOptionsLike {
|
|
|
5
5
|
}
|
|
6
6
|
/** @deprecated Use `FeeOptionsLike` instead. This compatibility interface will be removed in v1.0. */
|
|
7
7
|
export type IFeeOptions = FeeOptionsLike;
|
|
8
|
+
type CountInput = number | bigint;
|
|
9
|
+
type SymbolInput = string | {
|
|
10
|
+
data: string;
|
|
11
|
+
};
|
|
8
12
|
/** Base fee options with sensible defaults. */
|
|
9
13
|
export declare class FeeOptions implements FeeOptionsLike {
|
|
10
14
|
gasFeeBase: bigint;
|
|
11
15
|
feeMultiplier: bigint;
|
|
12
16
|
constructor(gasFeeBase?: bigint, feeMultiplier?: bigint);
|
|
13
17
|
calculateMaxGas(): bigint;
|
|
18
|
+
calculateMaxGas(count: CountInput): bigint;
|
|
14
19
|
}
|
|
15
20
|
/** Fee options for token creation transactions. */
|
|
16
21
|
export declare class CreateTokenFeeOptions extends FeeOptions implements FeeOptionsLike {
|
|
17
22
|
gasFeeCreateTokenBase: bigint;
|
|
18
23
|
gasFeeCreateTokenSymbol: bigint;
|
|
19
24
|
constructor(gasFeeBase?: bigint, gasFeeCreateTokenBase?: bigint, gasFeeCreateTokenSymbol?: bigint, feeMultiplier?: bigint);
|
|
20
|
-
calculateMaxGas(
|
|
25
|
+
calculateMaxGas(): bigint;
|
|
26
|
+
calculateMaxGas(symbol: SymbolInput): bigint;
|
|
21
27
|
}
|
|
22
28
|
/** Fee options for creating a new series on an NFT token. */
|
|
23
29
|
export declare class CreateSeriesFeeOptions extends FeeOptions implements FeeOptionsLike {
|
|
@@ -29,5 +35,8 @@ export declare class CreateSeriesFeeOptions extends FeeOptions implements FeeOpt
|
|
|
29
35
|
export declare class MintNftFeeOptions extends FeeOptions implements FeeOptionsLike {
|
|
30
36
|
constructor(gasFeeBase?: bigint, feeMultiplier?: bigint);
|
|
31
37
|
calculateMaxGas(): bigint;
|
|
38
|
+
calculateMaxGas(count: CountInput): bigint;
|
|
39
|
+
calculateMaxGas(tokens: readonly unknown[]): bigint;
|
|
32
40
|
}
|
|
41
|
+
export {};
|
|
33
42
|
//# sourceMappingURL=fee-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee-options.d.ts","sourceRoot":"","sources":["../../../../../../src/types/carbon/blockchain/tx-helpers/fee-options.ts"],"names":[],"mappings":"AAEA,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;CAC7C;AAED,sGAAsG;AACtG,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC;AAEzC,+CAA+C;AAC/C,qBAAa,UAAW,YAAW,cAAc;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;gBAEV,UAAU,GAAE,MAAgB,EAAE,aAAa,GAAE,MAAe;IAKxE,eAAe,IAAI,MAAM;
|
|
1
|
+
{"version":3,"file":"fee-options.d.ts","sourceRoot":"","sources":["../../../../../../src/types/carbon/blockchain/tx-helpers/fee-options.ts"],"names":[],"mappings":"AAEA,uCAAuC;AACv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C,KAAK,EAAE,UAAU,GAAG,MAAM;IAC1C,eAAe,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM;CAK7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p-binary-writer.d.ts","sourceRoot":"","sources":["../../../../src/types/extensions/p-binary-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAiB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"p-binary-writer.d.ts","sourceRoot":"","sources":["../../../../src/types/extensions/p-binary-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAiB,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,KAAK,IAAI,GAAG,MAAM,CAAC;AAEnB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;gBACjB,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU;IAItC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAIlC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAG9B,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAGnD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAGpC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAG/B,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAGvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAG7B,gBAAgB,CAAC,KA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