-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add createCollection API to the SDK (#87)
* Add createCollection API to the SDK * [collection] fix collection tests with refactored code --------- Co-authored-by: Greg Nazario <[email protected]>
- Loading branch information
1 parent
8ba94ac
commit 078acc3
Showing
3 changed files
with
145 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,54 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// import { Aptos, AptosConfig, Network } from "../../../src"; | ||
import { Account, Aptos, AptosConfig, Network } from "../../../src"; | ||
import { waitForTransaction } from "../../../src/internal/transaction"; | ||
import { FUND_AMOUNT } from "../../unit/helper"; | ||
|
||
// use it here since all tests use the same configuration | ||
const config = new AptosConfig({ network: Network.LOCAL }); | ||
const aptos = new Aptos(config); | ||
|
||
// Disable these tests for now until we can test against LOCAL | ||
describe("Collection", () => { | ||
test("it should get collection data", async () => { | ||
/* | ||
const config = new AptosConfig({ network: Network.MAINNET }); | ||
const aptos = new Aptos(config); | ||
test("it creates a new collection on chain and fetches its data", async () => { | ||
const creator = Account.generate(); | ||
const creatorAddress = creator.accountAddress.toString(); | ||
const collectionName = "Aptos Test NFT Collection"; | ||
const collectionDescription = "My new collection!"; | ||
const collectionUri = "http://aptos.dev"; | ||
|
||
await aptos.fundAccount({ accountAddress: creatorAddress, amount: FUND_AMOUNT }); | ||
|
||
const transaction = await aptos.createCollectionTransaction({ | ||
creator, | ||
description: collectionDescription, | ||
name: collectionName, | ||
uri: collectionUri, | ||
}); | ||
const response = await aptos.signAndSubmitTransaction({ signer: creator, transaction }); | ||
|
||
await waitForTransaction({ aptosConfig: config, transactionHash: response.hash }); | ||
|
||
const collectionName = "BoredApePixels"; | ||
const creatorAddress = "0x3d5886363f0a09578b71361ccc86a65310ff2782a0ec18f9a250c9bb0ac46ac5"; | ||
const data = await aptos.getCollectionData({ collectionName, creatorAddress }); | ||
|
||
expect(data.collection_name).toEqual(collectionName); | ||
expect(data.creator_address).toEqual(creatorAddress); | ||
expect(data.description).toEqual(collectionDescription); | ||
expect(data.uri).toEqual(collectionUri); | ||
expect(data.current_supply).toEqual(0); | ||
expect(data.mutable_description).toEqual(true); | ||
expect(data.mutable_uri).toEqual(true); | ||
expect(data.token_standard).toEqual("v2"); | ||
|
||
expect(data).toHaveProperty("max_supply"); | ||
expect(data).toHaveProperty("collection_id"); | ||
expect(data).toHaveProperty("collection_name"); | ||
expect(data).toHaveProperty("creator_address"); | ||
expect(data).toHaveProperty("current_supply"); | ||
expect(data).toHaveProperty("description"); | ||
expect(data).toHaveProperty("last_transaction_timestamp"); | ||
expect(data).toHaveProperty("last_transaction_version"); | ||
expect(data).toHaveProperty("max_supply"); | ||
expect(data).toHaveProperty("mutable_description"); | ||
expect(data).toHaveProperty("mutable_uri"); | ||
expect(data).toHaveProperty("table_handle_v1"); | ||
expect(data).toHaveProperty("token_standard"); | ||
expect(data).toHaveProperty("total_minted_v2"); | ||
expect(data).toHaveProperty("uri"); | ||
*/ | ||
}); | ||
|
||
test("it should get a collection's address", async () => { | ||
/* | ||
const config = new AptosConfig({ network: Network.MAINNET }); | ||
const aptos = new Aptos(config); | ||
|
||
const collectionName = "BoredApePixels"; | ||
const creatorAddress = "0x3d5886363f0a09578b71361ccc86a65310ff2782a0ec18f9a250c9bb0ac46ac5"; | ||
const address = await aptos.getCollectionAddress({ collectionName, creatorAddress }); | ||
expect(address).toEqual("0x5e298466bb613f881f3157ddafe2ce217d207fd634048242bff642d4bcd67503"); | ||
*/ | ||
const address = await aptos.getCollectionId({ collectionName, creatorAddress }); | ||
expect(address).toEqual(data.collection_id); | ||
}); | ||
}); |