Skip to content

Commit

Permalink
change flow tokenId return values
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Sramko committed Aug 17, 2021
1 parent 179bc74 commit 305f372
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 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.20.2",
"version": "1.21.0",
"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
42 changes: 21 additions & 21 deletions src/transaction/flow.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// @ts-ignore
import * as fcl from '@onflow/fcl'
import * as fcl from '@onflow/fcl';
// @ts-ignore
import * as sdk from '@onflow/sdk'
import * as sdk from '@onflow/sdk';
// @ts-ignore
import * as types from '@onflow/types'
import * as types from '@onflow/types';
// @ts-ignore
import {ECDSA_secp256k1, encodeKey, SHA3_256,} from '@onflow/util-encode-key'
import * as elliptic from 'elliptic'
import {SHA3} from 'sha3'
import {validateBody} from '../connector/tatum'
import {FLOW_MAINNET_ADDRESSES, FLOW_TESTNET_ADDRESSES} from '../constants'
import {Currency, FlowBurnNft, FlowMintMultipleNft, FlowMintNft, FlowTransferNft, TransactionKMS, TransferFlow} from '../model'
import {generatePrivateKeyFromMnemonic} from '../wallet'
import {ECDSA_secp256k1, encodeKey, SHA3_256,} from '@onflow/util-encode-key';
import * as elliptic from 'elliptic';
import {SHA3} from 'sha3';
import {validateBody} from '../connector/tatum';
import {FLOW_MAINNET_ADDRESSES, FLOW_TESTNET_ADDRESSES} from '../constants';
import {Currency, FlowBurnNft, FlowMintMultipleNft, FlowMintNft, FlowTransferNft, TransactionKMS, TransferFlow} from '../model';
import {generatePrivateKeyFromMnemonic} from '../wallet';
import {
burnFlowNftTokenTxTemplate,
metadataFlowNftTokenScript,
Expand All @@ -22,7 +22,7 @@ import {
prepareTransferFlowTxTemplate,
tokenByAddressFlowNftTokenScript,
transferFlowNftTokenTxTemplate
} from './flowTransaction'
} from './flowTransaction';

export enum FlowTxType {
CREATE_ACCOUNT,
Expand Down Expand Up @@ -231,18 +231,18 @@ export const getFlowNftTokenByAddress = async (testnet: boolean, account: string
* @returns transaction id of the transaction in the blockchain
*/
export const sendFlowNftMintToken = async (testnet: boolean, body: FlowMintNft):
Promise<{ txId: string, tokenId: number }> => {
await validateBody(body, FlowMintNft)
const code = mintFlowNftTokenTxTemplate(testnet)
const {url, contractAddress: tokenType, to, mnemonic, index, account, privateKey} = body
const args = [{type: 'Address', value: to}, {type: 'String', value: url}, {type: 'String', value: tokenType}]
const pk = (mnemonic && index && index >= 0) ? await generatePrivateKeyFromMnemonic(Currency.FLOW, testnet, mnemonic, index as number) : privateKey as string
const auth = getFlowSigner(pk, account)
const result = await sendTransaction(testnet, {code, args, proposer: auth, authorizations: [auth], payer: auth})
Promise<{ txId: string, tokenId: string }> => {
await validateBody(body, FlowMintNft);
const code = mintFlowNftTokenTxTemplate(testnet);
const {url, contractAddress: tokenType, to, mnemonic, index, account, privateKey} = body;
const args = [{type: 'Address', value: to}, {type: 'String', value: url}, {type: 'String', value: tokenType}];
const pk = (mnemonic && index && index >= 0) ? await generatePrivateKeyFromMnemonic(Currency.FLOW, testnet, mnemonic, index as number) : privateKey as string;
const auth = getFlowSigner(pk, account);
const result = await sendTransaction(testnet, {code, args, proposer: auth, authorizations: [auth], payer: auth});
if (result.error) {
throw new Error(result.error)
throw new Error(result.error);
}
return {txId: result.id, tokenId: result.events.find((e: any) => e.type.includes('TatumMultiNFT.Minted'))?.data.id}
return {txId: result.id, tokenId: `${result.events.find((e: any) => e.type.includes('TatumMultiNFT.Minted'))?.data.id}`};
}

/**
Expand Down

0 comments on commit 305f372

Please sign in to comment.