Skip to content

Commit 9d6d92a

Browse files
committed
Add address field to getData methods.
1 parent bbd7e8d commit 9d6d92a

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

.github/CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing
2+
3+
## Developing process
4+
5+
```sh
6+
# do a local build
7+
npm install
8+
npm run dev --workspace=@ton/phaser-sdk
9+
10+
# link the package
11+
cd ./packages/phaser
12+
npm link
13+
14+
# in a consumer project
15+
npm link @ton/phaser-sdk
16+
```

packages/common/jetton.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export interface JettonTransferRequest {
8181
forwardMessage?: string;
8282
}
8383

84-
export interface JettonMinter extends DomainJettonMinter {}
84+
export interface JettonMinter extends DomainJettonMinter {
85+
address: Address;
86+
}
8587

8688
export class JettonManager {
8789
private readonly manager: DomainJettonManager;
@@ -94,7 +96,13 @@ export class JettonManager {
9496
}
9597

9698
public async getData(address: Address | string): Promise<JettonMinter> {
97-
return this.manager.getData(AddressUtils.toObject(address));
99+
const addressObject = AddressUtils.toObject(address);
100+
const domainData = await this.manager.getData(addressObject);
101+
102+
return {
103+
...domainData,
104+
address: addressObject
105+
};
98106
}
99107

100108
public async transfer({

packages/common/nft-collection.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ export interface DomainNftCollection {
1515
export class DomainNftCollectionManager {
1616
constructor(private readonly tonClient: TonClient) {}
1717

18-
public async getData(address: Address | string): Promise<DomainNftCollection> {
19-
const {stack} = await this.tonClient.runMethod(
20-
typeof address === 'string' ? Address.parse(address) : address,
21-
'get_collection_data'
22-
);
18+
public async getData(address: Address): Promise<DomainNftCollection> {
19+
const {stack} = await this.tonClient.runMethod(address, 'get_collection_data');
2320

2421
return {
2522
nextItemIndex: stack.readBigNumber(),
@@ -59,6 +56,7 @@ export class DomainNftCollectionManager {
5956
/** Client specific */
6057

6158
export interface NftCollection {
59+
address: Address;
6260
nextItemIndex: bigint;
6361
content: NftContent;
6462
owner: Address | null;
@@ -75,9 +73,11 @@ export class NftCollectionManager {
7573
}
7674

7775
public async getData(address: Address | string): Promise<NftCollection> {
78-
const domainData = await this.domainManager.getData(address);
76+
const addressObject = AddressUtils.toObject(address);
77+
const domainData = await this.domainManager.getData(addressObject);
7978

8079
return {
80+
address: addressObject,
8181
nextItemIndex: domainData.nextItemIndex,
8282
content: parseNftContent(await loadFullContent(domainData.content, this.contentResolver)),
8383
owner: domainData.owner

packages/common/nft-item.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ export class DomainNftItemManager {
3535
this.collectionManager = new DomainNftCollectionManager(this.tonClient);
3636
}
3737

38-
public async getData(address: Address | string): Promise<DomainNftItem> {
39-
const {stack} = await this.tonClient.runMethod(
40-
typeof address === 'string' ? Address.parse(address) : address,
41-
'get_nft_data'
42-
);
38+
public async getData(address: Address): Promise<DomainNftItem> {
39+
const {stack} = await this.tonClient.runMethod(address, 'get_nft_data');
4340

4441
const data: DomainNftItem = {
4542
initialized: stack.readBoolean(),
@@ -85,6 +82,7 @@ export class DomainNftItemManager {
8582
export interface Nft {
8683
initialized: boolean;
8784
index: bigint;
85+
address: Address;
8886
collection: Address | null;
8987
owner: Address | null;
9088
content: NftContent | null;
@@ -112,11 +110,13 @@ export class NftItemManager {
112110
}
113111

114112
public async getData(address: Address | string): Promise<Nft> {
115-
const domainData = await this.manager.getData(address);
113+
const addressObject = AddressUtils.toObject(address);
114+
const domainData = await this.manager.getData(addressObject);
116115

117116
return {
118117
initialized: domainData.initialized,
119118
index: domainData.index,
119+
address: addressObject,
120120
collection: domainData.collection,
121121
owner: domainData.owner,
122122
content:

0 commit comments

Comments
 (0)