Skip to content

Commit

Permalink
ft lockable refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
volovyks committed Aug 30, 2022
1 parent cc96720 commit f4499e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
10 changes: 3 additions & 7 deletions examples/src/fungible-token-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearContract, NearBindgen, call, view } from "near-sdk-js";
import { NearBindgen, call, view } from "near-sdk-js";

@NearBindgen
class FungibleTokenHelper extends NearContract {
@NearBindgen({})
class FungibleTokenHelper {
constructor() {
super();
this.data = "";
Expand All @@ -17,8 +17,4 @@ class FungibleTokenHelper extends NearContract {
getContractData() {
return this.data;
}

default() {
return new FungibleTokenHelper();
}
}
17 changes: 5 additions & 12 deletions examples/src/fungible-token-lockable.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
NearContract,
NearBindgen,
call,
view,
initialize,
near,
LookupMap,
} from 'near-sdk-js'
Expand Down Expand Up @@ -49,15 +49,12 @@ class Account {
}
}

@NearBindgen
class LockableFungibleToken extends NearContract {
constructor({ prefix, totalSupply }) {
super()
@NearBindgen({ initRequired: true })
class LockableFungibleToken {
@initialize
init({ prefix, totalSupply }) {
this.accounts = new LookupMap(prefix) // Account ID -> Account mapping
this.totalSupply = totalSupply // Total supply of the all tokens
}

init() {
let ownerId = near.signerAccountId()
let ownerAccount = this.getAccount(ownerId)
ownerAccount.balance = this.totalSupply
Expand Down Expand Up @@ -224,8 +221,4 @@ class LockableFungibleToken extends NearContract {
getLockedBalance({ ownerId, escrowAccountId }) {
return this.getAccount(ownerId).getLockedBalance(escrowAccountId)
}

default() {
return new LockableFungibleToken({ prefix: '', totalSupply: 0 })
}
}

0 comments on commit f4499e5

Please sign in to comment.