Skip to content

Commit

Permalink
fix listing validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Sramko committed Aug 12, 2021
1 parent 4689240 commit a810ac6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 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.19.7",
"version": "1.19.8",
"description": "",
"main": "dist/src/index.js",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
9 changes: 7 additions & 2 deletions src/nft/marketplace/listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const deployMarketplaceListing = async (testnet: boolean, body: DeployMar
* @param provider optional provider to enter. if not present, Tatum Web3 will be used.
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceListing = async (testnet: boolean, body: DeployMarketplaceListing | DeployTronMarketplaceListing, provider?: string) => {
export const prepareDeployMarketplaceListing = async (testnet: boolean, body: DeployMarketplaceListing | DeployTronMarketplaceListing, provider?: string) => {
switch (body.chain) {
case Currency.CELO:
return await prepareCeloDeployMarketplaceListingSignedTransaction(testnet, body, provider);
Expand All @@ -200,6 +200,7 @@ export const prepareMarketplaceListing = async (testnet: boolean, body: DeployMa
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceUpdateFee = async (testnet: boolean, body: UpdateMarketplaceFee | UpdateTronMarketplaceFee, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? UpdateTronMarketplaceFee : UpdateMarketplaceFee);
const params = [`0x${new BigNumber(body.marketplaceFee).toString(16)}`];
if (body.chain === Currency.TRON) {
return await prepareSCCall(testnet, body, UpdateTronMarketplaceFee, 'setMarketplaceFee',
Expand All @@ -219,6 +220,7 @@ export const prepareMarketplaceUpdateFee = async (testnet: boolean, body: Update
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceUpdateFeeRecipient = async (testnet: boolean, body: UpdateMarketplaceFeeRecipient | UpdateTronMarketplaceFeeRecipient, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? UpdateTronMarketplaceFeeRecipient : UpdateMarketplaceFeeRecipient);
const params = [body.feeRecipient];
if (body.chain === Currency.TRON) {
return await prepareSCCall(testnet, body, UpdateTronMarketplaceFeeRecipient, 'setMarketplaceFeeRecipient',
Expand All @@ -238,6 +240,7 @@ export const prepareMarketplaceUpdateFeeRecipient = async (testnet: boolean, bod
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceApproveErc20Spending = async (testnet: boolean, body: ApproveMarketplaceErc20Spending | ApproveTronMarketplaceErc20Spending, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? ApproveTronMarketplaceErc20Spending : ApproveMarketplaceErc20Spending);
let amount;
switch (body.chain) {
case Currency.CELO:
Expand Down Expand Up @@ -283,6 +286,7 @@ export const prepareMarketplaceApproveErc20Spending = async (testnet: boolean, b
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceCreateListing = async (testnet: boolean, body: CreateMarketplaceListing | CreateTronMarketplaceListing, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? CreateTronMarketplaceListing : CreateMarketplaceListing);
const params = [body.listingId, body.isErc721, body.nftAddress.trim(), `0x${new BigNumber(body.tokenId).toString(16)}`,
`0x${new BigNumber(body.price).multipliedBy(body.chain === Currency.TRON ? 1e6 : 1e18).toString(16)}`, body.seller.trim(), `0x${new BigNumber(body.amount || 0).toString(16)}`,
body.erc20Address || '0x0000000000000000000000000000000000000000'];
Expand Down Expand Up @@ -312,6 +316,7 @@ export const prepareMarketplaceCreateListing = async (testnet: boolean, body: Cr
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceBuyListing = async (testnet: boolean, body: InvokeMarketplaceListingOperation | InvokeTronMarketplaceListingOperation, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? InvokeTronMarketplaceListingOperation : InvokeMarketplaceListingOperation);
const params = [body.listingId, body.erc20Address || '0x0000000000000000000000000000000000000000'];
if (body.chain === Currency.TRON) {
return await prepareSCCall(testnet, body, InvokeTronMarketplaceListingOperation, 'buyAssetFromListing',
Expand All @@ -332,6 +337,7 @@ export const prepareMarketplaceBuyListing = async (testnet: boolean, body: Invok
* @returns {txId: string} Transaction ID of the operation, or signatureID in case of Tatum KMS
*/
export const prepareMarketplaceCancelListing = async (testnet: boolean, body: InvokeMarketplaceListingOperation | InvokeTronMarketplaceListingOperation, provider?: string) => {
await validateBody(body, body.chain === Currency.TRON ? InvokeTronMarketplaceListingOperation : InvokeMarketplaceListingOperation);
const params = [body.listingId];
if (body.chain === Currency.TRON) {
return await prepareSCCall(testnet, body, InvokeTronMarketplaceListingOperation, 'cancelListing',
Expand All @@ -346,7 +352,6 @@ export const prepareMarketplaceCancelListing = async (testnet: boolean, body: In
const prepareSCCall = async <U>(testnet: boolean, body: any, clazz: ClassType<object>, methodName: string, params: any[], methodSig?: string,
provider?: string, abi: any[] = listing.abi) => {
let r: SmartContractMethodInvocation | CeloSmartContractMethodInvocation;
await validateBody(body, clazz);
if (body.chain === Currency.CELO) {
r = new CeloSmartContractMethodInvocation();
} else {
Expand Down

0 comments on commit a810ac6

Please sign in to comment.