Skip to content

Commit

Permalink
Sample fixes (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jian authored Mar 30, 2019
1 parent 79c3d4d commit dd2c20e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions new-sdks/tpp/sample/PersistentlyCreateMemberSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import {TokenClient} from '../src';
/**
* Imports and sets up the SDK, and creates a Token member with the MemoryCryptoEngine
* (which will store keys in memory).
* @param {string} developerKey - developer key
* @return {Member} created member
*/
export default async developerKey => {
export default async () => {
// Initialize SDK:
const Token = new TokenClient({
env: 'sandbox',
developerKey,
keyDir: './keys',
});

Expand Down
8 changes: 4 additions & 4 deletions new-sdks/tpp/sample/RedeemAccessTokenSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ class RedeemAccessTokenSample {
*/
static async use(grantee, tokenId) {
// Use the access token, now making API calls
// on behalf of the grantor, and get accounts
// on behalf of the grantor (as a representative), and get accounts
// forAccessToken snippet begin
const grantor = grantee.forAccessToken(tokenId);
const representative = grantee.forAccessToken(tokenId);
let accounts;
try {
accounts = await grantor.getAccounts();
accounts = await representative.getAccounts();
} catch (e) {
// no access (e.g. grantor unlinked accounts or revoked access)
return {};
}

// Get information we want:
const balance0 = await grantor.getBalance(accounts[0].id(), config.KeyLevel.LOW);
const balance0 = await representative.getBalance(accounts[0].id(), config.KeyLevel.LOW);
// forAccessToken snippet end

return balance0.current;
Expand Down

0 comments on commit dd2c20e

Please sign in to comment.