@simplenft/api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +30 -0
  2. package/blueprint.config.ts +13 -0
  3. package/contracts/buyer_profile.tact +73 -0
  4. package/contracts/imports/stdlib.fc +625 -0
  5. package/contracts/jetton_eq.tact +79 -0
  6. package/contracts/message.tact +189 -0
  7. package/contracts/nft_item.tact +98 -0
  8. package/contracts/nft_item_free.tact +98 -0
  9. package/contracts/packages/math/float.fc +95 -0
  10. package/contracts/packages/misc/distributor_messages.tact +154 -0
  11. package/contracts/packages/nap/errcodes.tact +5 -0
  12. package/contracts/packages/nap/messages.tact +34 -0
  13. package/contracts/packages/token/jetton/JettonMaster.tact +127 -0
  14. package/contracts/packages/token/jetton/JettonWallet.tact +248 -0
  15. package/contracts/packages/token/nft/AuctionErrorCode.tact +55 -0
  16. package/contracts/packages/token/nft/NFTAuction.tact +226 -0
  17. package/contracts/packages/token/nft/NFTAuctionMarket.tact +302 -0
  18. package/contracts/packages/token/nft/NFTCollection.tact +69 -0
  19. package/contracts/packages/token/nft/NFTItem.tact +190 -0
  20. package/contracts/packages/token/nft/extensions/NFTEditable.tact +3 -0
  21. package/contracts/packages/token/nft/extensions/NFTRoyalty.tact +63 -0
  22. package/contracts/packages/traits/taxable.tact +31 -0
  23. package/contracts/packages/utils/Estimatable.tact +11 -0
  24. package/contracts/packages/utils/Lockable.tact +23 -0
  25. package/contracts/sbt_item.tact +70 -0
  26. package/contracts/simple_nft_collection.tact +177 -0
  27. package/contracts/simple_nft_collection_v2.tact +304 -0
  28. package/contracts/simple_nft_master.tact +102 -0
  29. package/dist/api.d.ts +10 -0
  30. package/dist/api.js +58 -0
  31. package/dist/backend-service.d.ts +13 -0
  32. package/dist/backend-service.js +29 -0
  33. package/dist/backend-types.d.ts +60 -0
  34. package/dist/backend-types.js +2 -0
  35. package/dist/content.d.ts +3 -0
  36. package/dist/content.js +30 -0
  37. package/dist/contracts/tact_NftItem.d.ts +619 -0
  38. package/dist/contracts/tact_NftItem.js +2312 -0
  39. package/dist/contracts/tact_SimpleNftCollectionV2.d.ts +658 -0
  40. package/dist/contracts/tact_SimpleNftCollectionV2.js +2427 -0
  41. package/dist/contracts/tact_SimpleNftMaster.d.ts +624 -0
  42. package/dist/contracts/tact_SimpleNftMaster.js +2350 -0
  43. package/dist/index.d.ts +57 -0
  44. package/dist/index.js +254 -0
  45. package/dist/types.d.ts +53 -0
  46. package/dist/types.js +2 -0
  47. package/package.json +56 -0
  48. package/src/api.ts +62 -0
  49. package/src/backend-service.ts +40 -0
  50. package/src/backend-types.ts +72 -0
  51. package/src/content.ts +36 -0
  52. package/src/contracts/tact_NftItem.ts +2718 -0
  53. package/src/contracts/tact_SimpleNftCollectionV2.ts +2843 -0
  54. package/src/contracts/tact_SimpleNftMaster.ts +2759 -0
  55. package/src/index.ts +361 -0
  56. package/src/types.ts +62 -0
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # SimpleNFT API SDK
2
+
3
+ ```ts
4
+
5
+ /* -------- EXAMPLE USAGE -------- */
6
+ import { Address, SimpleNft } from "@simplenft/api";
7
+
8
+ const sdk = new SimpleNft({
9
+ mnemonic: process.env.WALLET_MNEMONIC?.split(" "),
10
+ network: "mainnet",
11
+ hostname: "https://api.simplenft.io",
12
+ });
13
+
14
+ const parsed = sdk.getters.parseAddress("UQ..."); // Always return EQ...
15
+ const blockchainCollection = await sdk.getters.blockchain.collectionData(Address.parse("EQ..."));
16
+ const serverCollection = await sdk.getters.server.collectionData(Address.parse("EQ..."));
17
+ const serverItem = await sdk.getters.server.itemData(Address.parse("EQ..."));
18
+
19
+ const created = await sdk.transactions.createCollection({
20
+ master: Address.parse("EQ..."),
21
+ collectionContent: "https://example.com/collection.json",
22
+ nftIndividualContent: "https://example.com/item.json",
23
+ });
24
+
25
+ if (created.status === "deployed_server_data_unavailable") {
26
+ // Contract is deployed on-chain, but project server data is not available yet.
27
+ }
28
+ ```
29
+
30
+ Transactions require `mnemonic` in the constructor.
@@ -0,0 +1,13 @@
1
+ import { Config } from '@ton/blueprint';
2
+
3
+ // console.log("Settings:", process.env);
4
+
5
+
6
+ export const config: Config = {
7
+ network: {
8
+ endpoint: "https://toncenter.com/api/v2/jsonRPC", // 'https://testnet.toncenter.com/api/v2/jsonRPC',
9
+ type: 'mainnet', // 'testnet', // 'mainnet'
10
+ key: process.env.API_KEY
11
+ },
12
+
13
+ }
@@ -0,0 +1,73 @@
1
+ import "@stdlib/deploy";
2
+ import "./message";
3
+
4
+ contract BuyerProfile with Deployable {
5
+
6
+ collection_address: Address;
7
+ collection_owner: Address?;
8
+ collection_item_price: Int as uint32 = 0;
9
+ owner: Address;
10
+ is_initialized: Bool = false;
11
+ is_whitelisted: Bool;
12
+ enable_whitelist: Bool = false;
13
+ user_item_limit: Int as uint8 = 0;
14
+ user_item_count: Int as uint8 = 0;
15
+
16
+ init (parent: Address, new_owner: Address) {
17
+ self.collection_address = parent;
18
+ self.owner = new_owner;
19
+ self.is_whitelisted = false;
20
+ }
21
+
22
+ receive(msg: SetupCollectionData) {
23
+ require(sender()==self.collection_address, "Parent Only");
24
+ require(self.is_initialized == false, "Already setup");
25
+ self.collection_owner = msg.collection_owner;
26
+ self.collection_item_price = msg.collection_item_price;
27
+ self.is_initialized = true;
28
+ self.enable_whitelist = msg.enable_whitelist;
29
+ self.user_item_limit = msg.user_item_limit
30
+ }
31
+
32
+ receive("Mint"){
33
+ require(sender() == self.owner, "Profile owner only");
34
+ if (self.enable_whitelist) {
35
+ require(self.is_whitelisted() == true, "White list required");
36
+ }
37
+ if (self.user_item_limit > 0) {
38
+ require(self.user_item_count < self.user_item_limit, "Mint limit per user reached");
39
+ }
40
+ let ctx: Context = context();
41
+ require(ctx.value >= self.collection_item_price, "NFT creation underpriced");
42
+ let msgValue: Int = ctx.value;
43
+ let tonBalanceBeforeMsg: Int = myBalance() - msgValue;
44
+ let storageFee: Int = minTonsForStorage - min(tonBalanceBeforeMsg, minTonsForStorage);
45
+ msgValue = msgValue - (storageFee + gasConsumption);
46
+
47
+ send(SendParameters{
48
+ to: self.collection_address,
49
+ value: msgValue,
50
+ body: MintTo{
51
+ owner: self.owner,
52
+ }.toCell(),
53
+ mode: SendIgnoreErrors
54
+ });
55
+ self.user_item_count = self.user_item_count + 1;
56
+ }
57
+
58
+ // Get whitelist status
59
+ get fun is_whitelisted(): Bool {
60
+ return self.is_whitelisted;
61
+ }
62
+
63
+ get fun user_mint_count(): Int {
64
+ return self.user_item_count;
65
+ }
66
+
67
+ // List operations
68
+ receive(msg: AddToWhiteList) {
69
+ require(sender() == self.collection_address, "1"); // sender() == self.collection_owner
70
+ self.is_whitelisted = msg.add;
71
+ }
72
+
73
+ }