-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update token transfer to follow specs #551
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ export class TokenTransfer { | |
} | ||
} | ||
|
||
static newFromEgldAmount(amount: bigint): TokenTransfer { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this should have been deprecated as well? So it is not breaking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we discussed in the office and said it is ok to rename it as it was not long time added |
||
static newFromNativeAmount(amount: bigint): TokenTransfer { | ||
const token = new Token({ identifier: EGLD_IDENTIFIER_FOR_MULTI_ESDTNFT_TRANSFER }); | ||
return new TokenTransfer({ token, amount }); | ||
} | ||
|
@@ -95,15 +95,15 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static egldFromAmount(amount: BigNumber.Value) { | ||
const amountAsBigInteger = new BigNumber(amount).shiftedBy(EGLDNumDecimals).decimalPlaces(0); | ||
return this.egldFromBigInteger(amountAsBigInteger); | ||
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static egldFromBigInteger(amountAsBigInteger: BigNumber.Value) { | ||
return new TokenTransfer({ | ||
|
@@ -115,15 +115,15 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static fungibleFromAmount(tokenIdentifier: string, amount: BigNumber.Value, numDecimals: number) { | ||
const amountAsBigInteger = new BigNumber(amount).shiftedBy(numDecimals).decimalPlaces(0); | ||
return this.fungibleFromBigInteger(tokenIdentifier, amountAsBigInteger, numDecimals); | ||
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static fungibleFromBigInteger( | ||
tokenIdentifier: string, | ||
|
@@ -139,7 +139,7 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static nonFungible(tokenIdentifier: string, nonce: number) { | ||
return new TokenTransfer({ | ||
|
@@ -151,7 +151,7 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static semiFungible(tokenIdentifier: string, nonce: number, quantity: number) { | ||
return new TokenTransfer({ | ||
|
@@ -163,15 +163,15 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static metaEsdtFromAmount(tokenIdentifier: string, nonce: number, amount: BigNumber.Value, numDecimals: number) { | ||
const amountAsBigInteger = new BigNumber(amount).shiftedBy(numDecimals).decimalPlaces(0); | ||
return this.metaEsdtFromBigInteger(tokenIdentifier, nonce, amountAsBigInteger, numDecimals); | ||
} | ||
|
||
/** | ||
* Legacy function. Use the constructor instead: new TokenTransfer({ token, amount }); | ||
* @deprecated Use the constructor instead: new TokenTransfer({ token, amount }); | ||
*/ | ||
static metaEsdtFromBigInteger( | ||
tokenIdentifier: string, | ||
|
@@ -192,14 +192,14 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Use the "amount" field instead. | ||
* @deprecated Use the "amount" field instead. | ||
*/ | ||
valueOf(): BigNumber { | ||
return new BigNumber(this.amount.toString()); | ||
} | ||
|
||
/** | ||
* Legacy function. For formatting and parsing amounts, use "sdk-dapp" or "bignumber.js" directly. | ||
* @deprecated For formatting and parsing amounts, use "sdk-dapp" or "bignumber.js" directly. | ||
*/ | ||
toPrettyString(): string { | ||
return `${this.toAmount()} ${this.tokenIdentifier}`; | ||
|
@@ -210,15 +210,15 @@ export class TokenTransfer { | |
} | ||
|
||
/** | ||
* Legacy function. Within your code, don't mix native values (EGLD) and custom (ESDT) tokens. | ||
* @deprecated Within your code, don't mix native values (EGLD) and custom (ESDT) tokens. | ||
* See "TransferTransactionsFactory.createTransactionForNativeTokenTransfer()" vs. "TransferTransactionsFactory.createTransactionForESDTTokenTransfer()". | ||
*/ | ||
isEgld(): boolean { | ||
return this.token.identifier == EGLDTokenIdentifier; | ||
} | ||
|
||
/** | ||
* Legacy function. Use "TokenComputer.isFungible(token)" instead. | ||
* @deprecated Use "TokenComputer.isFungible(token)" instead. | ||
*/ | ||
isFungible(): boolean { | ||
return this.token.nonce == 0n; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe drop the
(legacy)
comment, as well?