phantasma-sdk-ts 0.8.0 → 0.8.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/dist/cjs/types/carbon/blockchain/modules/builders/token-info-builder.js +2 -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/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/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
|
}
|
|
@@ -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,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"}
|
|
@@ -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,K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