Skip to content

Commit

Permalink
EGLD tokens (#171)
Browse files Browse the repository at this point in the history
* EGLD: tokens

* Version
  • Loading branch information
isra67 authored Oct 14, 2021
1 parent 7881f8d commit cc91333
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 106 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "1.28.2",
"version": "1.28.3",
"description": "Tatum API client allows browsers and Node.js clients to interact with Tatum API.",
"main": "dist/src/index.js",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
6 changes: 6 additions & 0 deletions src/blockchain/egld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export const egldGetBlock = async (hash: string): Promise<EgldBlock> => get(`/v3
*/
export const egldGetAccountBalance = async (address: string): Promise<BigNumber> => get(`/v3/egld/account/balance/${address}`)

/**
* For more details, see <a href="https://tatum.io/apidoc" target="_blank">Tatum API documentation</a>
*/
export const egldGetAccountErc20Balance = async (address: string, tokenId: string): Promise<number> =>
get(`/v3/egld/account/esdt/balance/${address}/${tokenId}`)

/**
* For more details, see <a href="https://tatum.io/apidoc#operation/EgldGetTransaction" target="_blank">Tatum API documentation</a>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/model/request/egld/EgldEsdtTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class EgldEsdtTransaction extends PrivateKeyOrSignatureId {
@ValidateNested()
public fee?: Fee;

@IsOptional()
public nonce?: number;
// @IsOptional()
// public nonce?: number;

@IsOptional()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
8 changes: 4 additions & 4 deletions src/model/request/egld/EsdtIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ export class EsdtIssue extends EsdtToken {
@IsNotEmpty()
@IsAlphanumeric()
@Length(3, 20)
public tokenName: string;
public name: string;

@IsNotEmpty()
@IsAlphanumeric()
@IsUppercase()
@Length(3, 10)
public tokenTicker: string;
public symbol: string;

@IsNotEmpty()
@Min(0)
public initialSupply: number;
public supply: number;

@IsNotEmpty()
@Min(0)
@Max(18)
public decimals: number;
public digits: number;

@IsOptional()
public properties?: EsdtProperties;
Expand Down
4 changes: 2 additions & 2 deletions src/model/request/egld/EsdtIssueNftOrSft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export class EsdtIssueNftOrSft extends EsdtToken {
@IsNotEmpty()
@IsAlphanumeric()
@Length(3, 20)
public tokenName: string;
public name: string;

@IsNotEmpty()
@IsAlphanumeric()
@IsUppercase()
@Length(3, 10)
public tokenTicker: string;
public symbol: string;

@IsOptional()
public properties?: EsdtPropertiesNftOrSft;
Expand Down
6 changes: 3 additions & 3 deletions src/model/request/egld/EsdtToken.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IsIn, IsNotEmpty, IsOptional, IsUppercase, Length, ValidateIf} from 'class-validator';
import {IsIn, IsOptional, IsUppercase, Length, ValidateIf} from 'class-validator';

export enum EgldServiceType {
issue = 'issue',
Expand Down Expand Up @@ -28,10 +28,10 @@ export enum EgldServiceType {
}

export class EsdtToken {
@IsNotEmpty()
@IsOptional()
@Length(1, 63)
@IsIn(Object.keys(EgldServiceType))
public service: string;
public service?: string;

@ValidateIf(o => !['issue', 'issueNonFungible', 'issueSemiFungible'].includes(o.service))
@IsOptional()
Expand Down
15 changes: 6 additions & 9 deletions src/transaction/egld.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ describe('Elrond EGLD tests', () => {
it('should prepare issuance of fungible ESDT token', async () => {
const data: EsdtIssue = {
service: 'issue',
tokenName: 'testName',
tokenTicker: 'TEST1',
initialSupply: 1000,
decimals: 6,
name: 'testName',
symbol: 'TEST1',
supply: 1000,
digits: 6,
}
const body: EgldEsdtTransaction = {
fromPrivateKey: '1da12bfa82725be308f79b2c313358be5a215ca6b405b00f28750560a1febb90',
nonce: 1,
data,
}
const result = await prepareEgldDeployEsdtSignedTransaction(body)
Expand All @@ -66,12 +65,11 @@ describe('Elrond EGLD tests', () => {
it('should prepare issuance of NFT/SFT ESDT token', async () => {
const data: EsdtIssueNftOrSft = {
service: 'issueNonFungible',
tokenName: 'testNFTName',
tokenTicker: 'TEST1NFT',
name: 'testNFTName',
symbol: 'TEST1NFT',
}
const body: EgldEsdtTransaction = {
fromPrivateKey: '1da12bfa82725be308f79b2c313358be5a215ca6b405b00f28750560a1febb90',
nonce: 1,
data,
}
const result = await prepareEgldDeployNftOrSftSignedTransaction(body)
Expand All @@ -86,7 +84,6 @@ describe('Elrond EGLD tests', () => {
}
const body: EgldEsdtTransaction = {
fromPrivateKey: '1da12bfa82725be308f79b2c313358be5a215ca6b405b00f28750560a1febb90',
nonce: 1,
data,
}
const result = await prepareEgldStopNftCreateSignedTransaction(body)
Expand Down
Loading

0 comments on commit cc91333

Please sign in to comment.