Skip to content

Commit

Permalink
simpler frontend format
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Sep 8, 2022
1 parent 4dd3ede commit ffe8c05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
11 changes: 2 additions & 9 deletions frontend/near-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ export class HelloNEAR {
}

async getGreeting() {
return await this.wallet.viewMethod({
contractId: this.contractId,
method: 'get_greeting'
});
return await this.wallet.viewMethod({ contractId: this.contractId, method: 'get_greeting' });
}

async setGreeting(greeting) {
return await this.wallet.callMethod({
contractId: this.contractId,
method: 'set_greeting',
args: { greeting: greeting }
});
return await this.wallet.callMethod({ contractId: this.contractId, method: 'set_greeting', args: { greeting: greeting } });
}
}
7 changes: 4 additions & 3 deletions frontend/near-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ const NO_DEPOSIT = '0';
export class Wallet {
walletSelector;
wallet;
accountId;
network;
createAccessKeyFor;

constructor({ createAccessKeyFor = undefined }) {
constructor({ createAccessKeyFor = undefined, network = 'testnet' }) {
// Login to a wallet passing a contractId will create a local
// key, so the user skips signing non-payable transactions.
// Omitting the accountId will result in the user being
// asked to sign all transactions.
this.createAccessKeyFor = createAccessKeyFor
this.network = 'testnet'
}

// To be called when the website loads
async startUp() {
this.walletSelector = await setupWalletSelector({
network: 'testnet',
network: this.network,
modules: [setupMyNearWallet({ iconUrl: MyNearIconUrl }),
setupLedger({ iconUrl: LedgerIconUrl })],
});
Expand Down

0 comments on commit ffe8c05

Please sign in to comment.