Skip to content

Commit

Permalink
remove type from var names and add type to assertion params
Browse files Browse the repository at this point in the history
  • Loading branch information
idea404 committed Oct 11, 2022
1 parent 5832324 commit 7d27f50
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions examples/src/fungible-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ export class FungibleToken {
return maxAccountStorageUsage * BigInt(3); // we create an entry in 3 maps
}

internalRegisterAccount({ registrantAccountId, accountId, amountStr }: { registrantAccountId: string, accountId: string, amountStr: string }) {
internalRegisterAccount({ registrantAccountId, accountId, amount }: { registrantAccountId: string, accountId: string, amount: string }) {
assert(!this.accounts.containsKey(accountId), "Account is already registered");
this.accounts.set(accountId, "0");
this.accountRegistrants.set(accountId, registrantAccountId);
this.accountDeposits.set(accountId, amountStr);
this.accountDeposits.set(accountId, amount);
}

internalSendNEAR(receivingAccountId: string, amountBigInt: bigint) {
Assertions.isLeftGreaterThanRight(amountBigInt, 0);
Assertions.isLeftGreaterThanRight(near.accountBalance(), amountBigInt, `Not enough balance ${near.accountBalance()} to send ${amountBigInt}`);
internalSendNEAR(receivingAccountId: string, amount: bigint) {
Assertions.isLeftGreaterThanRight(amount, 0);
Assertions.isLeftGreaterThanRight(near.accountBalance(), amount, `Not enough balance ${near.accountBalance()} to send ${amount}`);
const promise = near.promiseBatchCreate(receivingAccountId);
near.promiseBatchActionTransfer(promise, amountBigInt);
near.promiseBatchActionTransfer(promise, amount);
near.promiseReturn(promise);
}

Expand Down Expand Up @@ -89,7 +89,7 @@ export class FungibleToken {
this.internalRegisterAccount({
registrantAccountId: near.predecessorAccountId(),
accountId: accountId,
amountStr: storageCost.toString(),
amount: storageCost.toString(),
});
let refund = attachedDeposit - storageCost;
if (refund > 0) {
Expand Down Expand Up @@ -141,7 +141,7 @@ class Assertions {
assert(near.attachedDeposit() > BigInt(0), "Requires at least 1 yoctoNEAR to ensure signature");
}

static isLeftGreaterThanRight(left, right, message = null) {
static isLeftGreaterThanRight(left: string | bigint | number | boolean, right: string | bigint | number | boolean, message: string = null) {
const msg = message || `Provided amount ${left} should be greater than ${right}`;
assert(BigInt(left) > BigInt(right), msg);
}
Expand Down

0 comments on commit 7d27f50

Please sign in to comment.