-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add createCollection API to the SDK #87
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Returning a SingleSigner may be weird if we also support Fee payer, but I'm not sure how that model is going to look cc @0xmaayan