Skip to content

Commit

Permalink
Update social links to be stored as a JSON string
Browse files Browse the repository at this point in the history
  • Loading branch information
d0rich committed Nov 17, 2023
1 parent cf7307e commit be69efb
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 34 deletions.
2 changes: 1 addition & 1 deletion contracts/contracts/d_social_network_account.tact
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract DSocialNetworkAccount with NftCollection, NftCollectionRoyaltyExtention
image: "",
name: "",
description: "",
social_links: emptyMap()
social_links: "[]"
};
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/d_social_network_master.tact
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "./messages_d.tact";
import "./d_social_network_account.tact";

contract DSocialNetworkMaster with Deployable, OwnableTransferable, Accounting {
version: String = "v0.0.1";
version: String = "v0.0.1-metadata-arrays-as-json-string";
owner: Address;
next_account_index: Int as uint32 = 0;

Expand Down Expand Up @@ -57,7 +57,7 @@ contract DSocialNetworkMaster with Deployable, OwnableTransferable, Accounting
image: "some-image-link",
name: msg.account_name,
description: msg.account_description,
social_links: emptyMap()
social_links: msg.social_links
};
}
}
2 changes: 1 addition & 1 deletion contracts/contracts/d_social_network_post.tact
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract DSocialNetworkPost with NftItem {
name: "",
description: "",
content_url: "",
attributes: emptyMap()
attributes: "[]"
};
self.is_initialized = false;
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/lib/messages_nft.tact
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct NftCollectionMetadata {
image: String;
name: String;
description: String;
social_links: map<Int, Cell>;
social_links: String;
}

message MintNft {
Expand Down Expand Up @@ -49,7 +49,7 @@ struct NftMetadata {
description: String;
image: String;
content_url: String;
attributes: map<Int, NftMetadataAttribute>;
attributes: String;
}

message InitializeNft {
Expand Down
1 change: 1 addition & 0 deletions contracts/contracts/messages_d.tact
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ message RegisterAccount {
query_id: Int as uint64;
account_name: String;
account_description: String;
social_links: String;
}

// Account contract
Expand Down
21 changes: 7 additions & 14 deletions contracts/scripts/deployTestSocialNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { toNano, Dictionary } from 'ton-core'
import { toNano } from 'ton-core'
import { NetworkProvider } from '@ton-community/blueprint'
import { DSocialNetworkMaster } from '../wrappers/DSocialNetworkMaster'
import {
DSocialNetworkAccount,
NftMetadataAttribute
} from '../wrappers/DSocialNetworkAccount'
import { DSocialNetworkAccount } from '../wrappers/DSocialNetworkAccount'
import { DSocialNetworkPost } from '../wrappers/DSocialNetworkPost'

export async function run(provider: NetworkProvider) {
Expand All @@ -30,7 +27,8 @@ export async function run(provider: NetworkProvider) {
$$type: 'RegisterAccount',
query_id: 0n,
account_name: 'test',
account_description: 'Test account description'
account_description: 'Test account description',
social_links: JSON.stringify(['https://d0rich.t.me/'])
}
)

Expand All @@ -42,13 +40,6 @@ export async function run(provider: NetworkProvider) {

await provider.waitForDeploy(dAccount.address)

const attributes = Dictionary.empty<bigint, NftMetadataAttribute>()
attributes.set(0n, {
$$type: 'NftMetadataAttribute',
trait_type: 'content',
value: 'This is my first post'
})

await dAccount.send(
provider.sender(),
{ value: toNano('0.5') },
Expand All @@ -61,7 +52,9 @@ export async function run(provider: NetworkProvider) {
description: 'Test post description',
image: 'https://test.com/image.png',
content_url: 'https://test.com/content.txt',
attributes
attributes: JSON.stringify([
{ trait_type: 'content', value: 'This is my first post' }
])
}
}
)
Expand Down
20 changes: 7 additions & 13 deletions contracts/tests/DSocialNetworkAccount.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Blockchain, SandboxContract } from '@ton-community/sandbox'
import { toNano, Dictionary } from 'ton-core'
import { toNano } from 'ton-core'
import { DSocialNetworkMaster } from '../wrappers/DSocialNetworkMaster'
import {
DSocialNetworkAccount,
NftMetadataAttribute
} from '../wrappers/DSocialNetworkAccount'
import { DSocialNetworkAccount } from '../wrappers/DSocialNetworkAccount'
import '@ton-community/test-utils'
import { DSocialNetworkPost } from '../wrappers/DSocialNetworkPost'

Expand Down Expand Up @@ -41,7 +38,8 @@ describe('DSocialNetworkMaster', () => {
$$type: 'RegisterAccount',
query_id: 0n,
account_name: 'test',
account_description: 'Test account description'
account_description: 'Test account description',
social_links: JSON.stringify(['https://d0rich.t.me/'])
}
)

Expand Down Expand Up @@ -69,12 +67,6 @@ describe('DSocialNetworkMaster', () => {
})

it('should create post', async () => {
const attributes = Dictionary.empty<bigint, NftMetadataAttribute>()
attributes.set(0n, {
$$type: 'NftMetadataAttribute',
trait_type: 'content',
value: 'This is my first post'
})
const registerResult = await dAccount.send(
deployer.getSender(),
{ value: toNano('0.5') },
Expand All @@ -87,7 +79,9 @@ describe('DSocialNetworkMaster', () => {
description: 'Test post description',
image: 'https://test.com/image.png',
content_url: 'https://test.com/content.txt',
attributes
attributes: JSON.stringify([
{ trait_type: 'content', value: 'This is my first post' }
])
}
}
)
Expand Down
3 changes: 2 additions & 1 deletion contracts/tests/DSocialNetworkMaster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ describe('DSocialNetworkMaster', () => {
$$type: 'RegisterAccount',
query_id: 0n,
account_name: 'test',
account_description: 'Test account description'
account_description: 'Test account description',
social_links: JSON.stringify(['https://d0rich.t.me/'])
}
)

Expand Down

0 comments on commit be69efb

Please sign in to comment.