-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
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.
Looks great! Could you address the comments before merging this?
} | ||
} | ||
|
||
async getAllBalances( |
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.
Could you mark
sui/sdk/typescript/src/providers/json-rpc-provider.ts
Lines 447 to 461 in e97e9cb
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); | |
} |
getAllBalances
?
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) | ||
|
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.
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 | |||
*/ | |||
|
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.
nit: remove space
sdk/typescript/src/types/coin.ts
Outdated
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() | ||
}); |
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.
I would call these CoinBalance
and CoinSupply
instead of *struct
since struct does not convey any meaning here.
No description provided.