Skip to content

Commit

Permalink
USDC on BSC support
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Sramko committed Aug 17, 2021
1 parent f835f2b commit 7bb3ddf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 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.21.1",
"version": "1.21.2",
"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
12 changes: 6 additions & 6 deletions src/nft/nft.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {readFileSync} from 'fs';
import {CeloBurnErc721, CeloDeployErc721, CeloMintErc721, CeloMintMultipleErc721, CeloTransferErc721, Currency, MintErc721,} from '../model';
import {burnNFT, deployNFT, getNFTImageFromIPFS, mintMultipleNFTWithUri, mintNFTWithIPFSMetadata, mintNFTWithUri, transferNFT} from './nft';
import {burnNFT, createNFT, deployNFT, getNFTImage, mintMultipleNFTWithUri, mintNFTWithUri, transferNFT} from './nft';

describe('NFT tests', () => {
jest.setTimeout(99999);
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('NFT tests', () => {
body.tokenId = '333342';
body.feeCurrency = Currency.CUSD;
body.chain = Currency.CELO;
console.log(await mintNFTWithIPFSMetadata(true, body, readFileSync('/Users/ssramko/Downloads/logo_tatum.png'),
console.log(await createNFT(true, body, readFileSync('/Users/ssramko/Downloads/logo_tatum.png'),
'Tatum LOGO', 'description', undefined, 'https://alfajores-forno.celo-testnet.org'));
});

Expand Down Expand Up @@ -282,7 +282,7 @@ describe('NFT tests', () => {
fromPrivateKey: '0x1a4344e55c562db08700dd32e52e62e7c40b1ef5e27c6ddd969de9891a899b29',
contractAddress: '0xC25f71fEaD66A160758265321e4c2Fb93b83BabF',
};
console.log(await mintNFTWithIPFSMetadata(true, body, readFileSync('/Users/ssramko/Downloads/logo_tatum.png'),
console.log(await createNFT(true, body, readFileSync('/Users/ssramko/Downloads/logo_tatum.png'),
'Tatum LOGO', 'description'));
});
it('should test BSC send transaction', async () => {
Expand Down Expand Up @@ -337,16 +337,16 @@ describe('NFT tests', () => {
fromPrivateKey: '0x1a4344e55c562db08700dd32e52e62e7c40b1ef5e27c6ddd969de9891a899b29',
contractAddress: '0xdb778b39bd7a7c479b3bb1d70df6665fe73e7e1d',
};
console.log(await mintNFTWithIPFSMetadata(true, body, readFileSync('/Users/ssramko/Downloads/logo_tatum.png'),
console.log(await createNFT(true, body, readFileSync('/Users/ssramko/Downloads/logo_tatum.png'),
'Tatum LOGO', 'description', undefined, 'https://rpc-mumbai.matic.today'));
});
it('should obtain metadata from NFT on IPFS on MATIC', async () => {
const data = await getNFTImageFromIPFS(Currency.MATIC, '0x6d8eae641416b8b79e0fb3a92b17448cfff02b11', '1629193549967');
const data = await getNFTImage(Currency.MATIC, '0x6d8eae641416b8b79e0fb3a92b17448cfff02b11', '1629193549967');
expect(data.publicUrl).toBe('https://gateway.pinata.cloud/ipfs/Qmaiu5NAXe2gwH734hWhvyharurBjoxi8Kv37sGp1ZhRpf');
expect(data.originalUrl).toBe('ipfs://Qmaiu5NAXe2gwH734hWhvyharurBjoxi8Kv37sGp1ZhRpf');
});
it('should obtain metadata from NFT on IPFS on FLOW', async () => {
const data = await getNFTImageFromIPFS(Currency.FLOW, '2d103773-50e2-4a37-ac3d-61bc6af8faee', '145', '0x10247089e55180c9');
const data = await getNFTImage(Currency.FLOW, '2d103773-50e2-4a37-ac3d-61bc6af8faee', '145', '0x10247089e55180c9');
expect(data.publicUrl).toBe('https://gateway.pinata.cloud/ipfs/Qmaiu5NAXe2gwH734hWhvyharurBjoxi8Kv37sGp1ZhRpf');
expect(data.originalUrl).toBe('ipfs://Qmaiu5NAXe2gwH734hWhvyharurBjoxi8Kv37sGp1ZhRpf');
});
Expand Down
12 changes: 6 additions & 6 deletions src/nft/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const getNFTMetadataURI = async (chain: Currency, contractAddress: string
* @param tokenId ID of the token
* @param account FLOW only - account where the token is minted
*/
export const getNFTImageFromIPFS = async (chain: Currency, contractAddress: string, tokenId: string, account?: string): Promise<{ originalUrl: string, publicUrl: string }> => {
export const getNFTImage = async (chain: Currency, contractAddress: string, tokenId: string, account?: string): Promise<{ originalUrl: string, publicUrl: string }> => {
const {data: metadata} = await getNFTMetadataURI(chain, contractAddress, tokenId, account);
const metadataUrl = `https://gateway.pinata.cloud/ipfs/${metadata.replace('ipfs://', '')}`;
const {data} = await axios.get(metadataUrl);
Expand Down Expand Up @@ -164,11 +164,11 @@ export const deployNFT = async (testnet: boolean, body: CeloDeployErc721 | EthDe
* @param scheme optional JSON Metadata scheme
* @param provider optional provider do broadcast tx
*/
export const mintNFTWithIPFSMetadata = async (testnet: boolean, body: CeloMintErc721 | EthMintErc721 | TronMintTrc721 | FlowMintNft,
file: Buffer,
name: string,
description?: string,
scheme?: any, provider?: string) => {
export const createNFT = async (testnet: boolean, body: CeloMintErc721 | EthMintErc721 | TronMintTrc721 | FlowMintNft,
file: Buffer,
name: string,
description?: string,
scheme?: any, provider?: string) => {
const metadata = scheme || {
title: 'Asset Metadata',
type: 'object',
Expand Down

0 comments on commit 7bb3ddf

Please sign in to comment.