Skip to content

Commit c43c686

Browse files
committed
SDK, Dashboard: Fix error when airdropping decimal token amount in new token creation flow (#7866)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on changing the data type of the `amount` property in the `DistributeContent` type and related usages from `bigint` to `string` to accommodate string representations of numbers. ### Detailed summary - Changed `amount` type in `DistributeContent` from `bigint` to `string`. - Updated `amount` assignment in `create-token-page-impl.tsx` to use `recipient.quantity` directly as a `string`. - Modified the total amount calculation to sum `recipient.quantity` as `Number` instead of `BigInt`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed inconsistencies in token airdrop amount handling, ensuring accurate totals and smoother approvals. * Resolved submission issues caused by mismatched numeric formats during distribution. * **Refactor** * Standardized how token distribution amounts are represented to improve compatibility with forms and API requests. * Simplified airdrop calculations for better reliability and user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 92896dd commit c43c686

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/create-token-page-impl.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function CreateTokenAssetPage(props: {
179179
chain: contract.chain,
180180
client: props.client,
181181
contents: values.airdropAddresses.map((recipient) => ({
182-
amount: BigInt(recipient.quantity),
182+
amount: recipient.quantity,
183183
recipient: recipient.address,
184184
})),
185185
tokenAddress: contract.address,
@@ -200,8 +200,8 @@ export function CreateTokenAssetPage(props: {
200200
const contract = getDeployedContract({ chain: values.chain });
201201

202202
const totalAmountToAirdrop = values.airdropAddresses.reduce(
203-
(acc, recipient) => acc + BigInt(recipient.quantity),
204-
0n,
203+
(acc, recipient) => acc + Number(recipient.quantity),
204+
0,
205205
);
206206

207207
const entrypoint = await getDeployedEntrypointERC20({

packages/thirdweb/src/tokens/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type PoolConfig = {
2222
};
2323

2424
export type DistributeContent = {
25-
amount: bigint;
25+
amount: string;
2626
recipient: string;
2727
};
2828

0 commit comments

Comments
 (0)