Skip to content

Commit

Permalink
Prettier code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Mar 11, 2024
1 parent 9e60f53 commit a294a2e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 80 deletions.
5 changes: 2 additions & 3 deletions code-snippets/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { providers } from '@massalabs/wallet-provider';

(async () => {
const availableProviders = await providers();
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);
Expand All @@ -15,5 +15,4 @@ const availableProviders = await providers();

// print the account name and address
console.log('Accounts:', accounts);

Check warning on line 17 in code-snippets/accounts.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

})();
})();
9 changes: 3 additions & 6 deletions code-snippets/delete-account.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
providers,
EAccountDeletionResponse,
providers,
} from '@massalabs/wallet-provider';

(async () => {
const availableProviders = await providers();
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);
Expand All @@ -20,8 +20,6 @@ const availableProviders = await providers();

const resp = await massaStationProvider.deleteAccount(newAccount.address);



// print the account name and address
console.log(

Check warning on line 24 in code-snippets/delete-account.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'Account Name:',
Expand All @@ -32,5 +30,4 @@ const availableProviders = await providers();
? 'has been deleted'
: 'could not be deleted',
);

})();
})();
41 changes: 18 additions & 23 deletions code-snippets/generate-new-account.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import { providers } from '@massalabs/wallet-provider';
import { deleteStationAccountFromNickname } from '../utils/provider-utils';

(async () => {
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);

// stop the test if the provider is not available
if (!massaStationProvider)
throw new Error('Massa Station provider not found');
// stop the test if the provider is not available
if (!massaStationProvider)
throw new Error('Massa Station provider not found');

// generate a new account
const newAccount =
await massaStationProvider.generateNewAccount('my-massa-wallet');
// generate a new account
const newAccount =
await massaStationProvider.generateNewAccount('my-massa-wallet');




// print the account name and address
console.log(
'Account Name:',
newAccount.name || 'no name',
'Account Address:',
newAccount.address,
);

})();
// print the account name and address
console.log(

Check warning on line 18 in code-snippets/generate-new-account.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'Account Name:',
newAccount.name || 'no name',
'Account Address:',
newAccount.address,
);
})();
7 changes: 2 additions & 5 deletions code-snippets/get-nework.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { providers } from '@massalabs/wallet-provider';

(async () => {
const availableProviders = await providers();
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);
Expand All @@ -11,8 +11,5 @@ const availableProviders = await providers();

const network = await massaStationProvider.getNetwork();



console.log('Network Name:', network);

Check warning on line 14 in code-snippets/get-nework.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

})();
})();
8 changes: 2 additions & 6 deletions code-snippets/get-nodes-urls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { providers } from '@massalabs/wallet-provider';

(async () => {
const availableProviders = await providers();
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);
Expand All @@ -11,9 +11,5 @@ const availableProviders = await providers();

const networkUrls = await massaStationProvider.getNodesUrls();




console.log('Network Urls:', networkUrls);

Check warning on line 14 in code-snippets/get-nodes-urls.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement

})();
})();
68 changes: 31 additions & 37 deletions code-snippets/sign.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
import { providers } from '@massalabs/wallet-provider';
import { deleteStationAccountFromNickname } from '../utils/provider-utils';

(async () => {
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);

// stop the test if the provider is not available
if (!massaStationProvider)
throw new Error('Massa Station provider not found');

const accountName = 'signing-account';
const dataToSign = 'test';

// generate a new account
await massaStationProvider.generateNewAccount(accountName);

// get account object
const accounts = await massaStationProvider.accounts();
const newAccount = accounts.find((a) => a.name() === accountName);

const resp = await newAccount.sign(dataToSign);





// print the account name and address
console.log(
'Account Address:',
newAccount.address,
'signed data:',
dataToSign,
'signature:',
resp.base58Encoded,
);

})();
const availableProviders = await providers();
const massaStationProvider = availableProviders.find(
(p) => p.name() === 'MASSASTATION',
);

// stop the test if the provider is not available
if (!massaStationProvider)
throw new Error('Massa Station provider not found');

const accountName = 'signing-account';
const dataToSign = 'test';

// generate a new account
await massaStationProvider.generateNewAccount(accountName);

// get account object
const accounts = await massaStationProvider.accounts();
const newAccount = accounts.find((a) => a.name() === accountName);

const resp = await newAccount.sign(dataToSign);

// print the account name and address
console.log(

Check warning on line 26 in code-snippets/sign.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected console statement
'Account Address:',
newAccount.address,
'signed data:',
dataToSign,
'signature:',
resp.base58Encoded,
);
})();

0 comments on commit a294a2e

Please sign in to comment.