From f4499e57429b49ddc0d2a25097225aa27ec9943f Mon Sep 17 00:00:00 2001 From: Serhii Volovyk Date: Tue, 30 Aug 2022 16:53:34 +0300 Subject: [PATCH] ft lockable refactored --- examples/src/fungible-token-helper.js | 10 +++------- examples/src/fungible-token-lockable.js | 17 +++++------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/examples/src/fungible-token-helper.js b/examples/src/fungible-token-helper.js index 82bcfa22..c03c6879 100644 --- a/examples/src/fungible-token-helper.js +++ b/examples/src/fungible-token-helper.js @@ -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 = ""; @@ -17,8 +17,4 @@ class FungibleTokenHelper extends NearContract { getContractData() { return this.data; } - - default() { - return new FungibleTokenHelper(); - } } \ No newline at end of file diff --git a/examples/src/fungible-token-lockable.js b/examples/src/fungible-token-lockable.js index c0a688ba..299c5951 100644 --- a/examples/src/fungible-token-lockable.js +++ b/examples/src/fungible-token-lockable.js @@ -1,8 +1,8 @@ import { - NearContract, NearBindgen, call, view, + initialize, near, LookupMap, } from 'near-sdk-js' @@ -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 @@ -224,8 +221,4 @@ class LockableFungibleToken extends NearContract { getLockedBalance({ ownerId, escrowAccountId }) { return this.getAccount(ownerId).getLockedBalance(escrowAccountId) } - - default() { - return new LockableFungibleToken({ prefix: '', totalSupply: 0 }) - } }