Skip to content
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

[TypeScript SDK] Add methods for the CoinRead endpoints #7507

Merged
merged 17 commits into from
Jan 23, 2023
Merged

Conversation

xydas97
Copy link
Contributor

@xydas97 xydas97 commented Jan 19, 2023

No description provided.

@vercel
Copy link

vercel bot commented Jan 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
explorer ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 23, 2023 at 11:31AM (UTC)
frenemies ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 23, 2023 at 11:31AM (UTC)
wallet-adapter ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 23, 2023 at 11:31AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
explorer-storybook ⬜️ Ignored (Inspect) Jan 23, 2023 at 11:31AM (UTC)

@xydas97 xydas97 linked an issue Jan 19, 2023 that may be closed by this pull request
Copy link
Contributor

@666lcz 666lcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Could you address the comments before merging this?

}
}

async getAllBalances(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you mark

async getCoinBalancesOwnedByAddress(
address: SuiAddress,
typeArg?: string
): Promise<GetObjectDataResponse[]> {
const objects = await this.getObjectsOwnedByAddress(address);
const coinIds = objects
.filter(
(obj: SuiObjectInfo) =>
Coin.isCoin(obj) &&
(typeArg === undefined || typeArg === Coin.getCoinTypeArg(obj))
)
.map((c) => c.objectId);
return await this.getObjectBatch(coinIds);
}
as deprecated and replace all its usage with getAllBalances?

Comment on lines 25 to 30
coin::mint_and_transfer<TEST_COIN>(&mut treasury_cap, 5, tx_context::sender(ctx), ctx);
coin::mint_and_transfer<TEST_COIN>(&mut treasury_cap, 6, tx_context::sender(ctx), ctx);

transfer::share_object(metadata);
transfer::share_object(treasury_cap)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pretty similar to the existing data/coin_metadata. Can we add these to the existing file instead of creating a new one?

@@ -48,6 +48,7 @@ export type CoinMetadata = Infer<typeof CoinMetadataStruct>;
* Utility class for 0x2::coin
* as defined in https://github.com/MystenLabs/sui/blob/ca9046fd8b1a9e8634a4b74b0e7dabdc7ea54475/sui_programmability/framework/sources/Coin.move#L4
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove space

Comment on lines 26 to 37
export const BalanceStruct = object({
coinType: string(),
coinObjectCount: number(),
totalBalance: number(),
lockedBalance: object({epochId: optional(number()), number: optional(number())})
});

export type BalanceStruct = Infer<typeof BalanceStruct>;

export const SupplyStruct = object({
value: number()
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call these CoinBalance and CoinSupply instead of *struct since struct does not convey any meaning here.

@vercel vercel bot temporarily deployed to Preview – wallet-adapter January 20, 2023 13:50 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TypeScript SDK] Add methods for the CoinRead endpoints
2 participants