Skip to content

Commit a0ab266

Browse files
authored
Merge pull request #573 from multiversx/TOOL-472-update-validation-for-token-ticker
Update token ticker validation rules
2 parents 572911a + df49bdc commit a0ab266

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@multiversx/sdk-core",
3-
"version": "13.17.1",
3+
"version": "13.17.2",
44
"description": "MultiversX SDK for JavaScript and TypeScript",
55
"author": "MultiversX",
66
"homepage": "https://multiversx.com",

src/tokens.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ describe("test tokens and token computer", async () => {
4646
const fungibleTokenIdentifier = "FNG-123456";
4747
identifier = tokenComputer.extractIdentifierFromExtendedIdentifier(fungibleTokenIdentifier);
4848
assert.equal(identifier, "FNG-123456");
49+
50+
const numericTokenTicker = "2065-65td7s";
51+
identifier = tokenComputer.extractIdentifierFromExtendedIdentifier(numericTokenTicker);
52+
assert.equal(identifier, "2065-65td7s");
53+
54+
const numericTokenTickerWithNonce = "2065-65td7s-01";
55+
identifier = tokenComputer.extractIdentifierFromExtendedIdentifier(numericTokenTickerWithNonce);
56+
assert.equal(identifier, "2065-65td7s");
57+
58+
const numericTokenTickerWithPrefix = "t0-2065-65td7s";
59+
identifier = tokenComputer.extractIdentifierFromExtendedIdentifier(numericTokenTickerWithPrefix);
60+
assert.equal(identifier, "t0-2065-65td7s");
61+
62+
const numericTokenTickerWithPrefixAndNonce = "t0-2065-65td7s";
63+
identifier = tokenComputer.extractIdentifierFromExtendedIdentifier(numericTokenTickerWithPrefixAndNonce);
64+
assert.equal(identifier, "t0-2065-65td7s")
4965
});
5066

5167
it("should fail if prefix longer than expected", async () => {

src/tokens.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class TokenComputer {
273273
}
274274

275275
private splitIdentifierIntoComponents(parts: string[]): { prefix: any; ticker: any; randomSequence: any } {
276-
if (this.isLowercaseAlphanumeric(parts[0])) {
276+
if (parts.length >= 3 && parts[2].length === this.TOKEN_RANDOM_SEQUENCE_LENGTH) {
277277
return { prefix: parts[0], ticker: parts[1], randomSequence: parts[2] };
278278
}
279279

@@ -329,10 +329,6 @@ export class TokenComputer {
329329
if (!ticker.match(/^[a-zA-Z0-9]+$/)) {
330330
throw new ErrInvalidTokenIdentifier("The token ticker should only contain alphanumeric characters");
331331
}
332-
333-
if (!(ticker == ticker.toUpperCase())) {
334-
throw new ErrInvalidTokenIdentifier("The token ticker should be upper case");
335-
}
336332
}
337333
}
338334

0 commit comments

Comments
 (0)