Skip to content

Commit

Permalink
add validation for accountId in init
Browse files Browse the repository at this point in the history
  • Loading branch information
idea404 committed Oct 11, 2022
1 parent 97842a0 commit 9f6619a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/src/fungible-token.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NearBindgen, call, view, initialize, near, LookupMap, assert } from "near-sdk-js";
import { NearBindgen, call, view, initialize, near, LookupMap, assert, validateAccountId } from "near-sdk-js";

@NearBindgen({ initRequired: true })
export class FungibleToken {
Expand All @@ -10,6 +10,7 @@ export class FungibleToken {
@initialize({})
init({ owner_id, total_supply }) {
assert(BigInt(total_supply) > BigInt(0), "Total supply should be a positive number");
validateAccountId(owner_id);
this.totalSupply = total_supply;
this.accounts.set(owner_id, this.totalSupply);
}
Expand Down

0 comments on commit 9f6619a

Please sign in to comment.