Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlockyer committed Nov 12, 2020
2 parents 17af019 + d0ac752 commit 6a6bbaa
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 218 deletions.
4 changes: 2 additions & 2 deletions lib/account_multisig.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/account_multisig.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/account_multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export class AccountMultisig extends Account {
}
}

export class Account2fa extends AccountMultisig {
export class Account2FA extends AccountMultisig {
/********************************
Account2fa has options object where you can provide callbacks for:
Account2FA has options object where you can provide callbacks for:
- sendCode: how to send the 2FA code in case you don't use NEAR Contract Helper
- getCode: how to get code from user (use this to provide custom UI/UX for prompt of 2FA code)
- onResult: the tx result after it's been confirmed by NEAR Contract Helper
Expand Down
15 changes: 8 additions & 7 deletions test/account_multisig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ let startFromVersion;
const {
KeyPair,
transactions: { functionCall },
multisig: { Account2fa, MULTISIG_GAS, MULTISIG_DEPOSIT },
InMemorySigner,
multisig: { Account2FA, MULTISIG_GAS, MULTISIG_DEPOSIT },
utils: { format: { parseNearAmount } }
} = nearApi;

jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;

const getAccount2fa = async (account, keyMapping = ({ public_key: publicKey }) => ({ publicKey, kind: 'phone' })) => {
const getAccount2FA = async (account, keyMapping = ({ public_key: publicKey }) => ({ publicKey, kind: 'phone' })) => {
// modifiers to functions replaces contract helper (CH)
const { accountId } = account;
const keys = await account.getAccessKeys();
const account2fa = new Account2fa(nearjs.connection, accountId, {
const account2fa = new Account2FA(nearjs.connection, accountId, {
// skip this (not using CH)
// skip this (not using CH)
getCode: () => {},
Expand Down Expand Up @@ -65,7 +66,7 @@ describe('deployMultisig key rotations', () => {
await account.addKey(KeyPair.fromRandom('ed25519').getPublicKey());
const keys = await account.getAccessKeys();
const kinds = ['ledger', 'phrase', 'phone'];
const account2fa = await getAccount2fa(
const account2fa = await getAccount2FA(
account,
({ public_key: publicKey }, i) => ({ publicKey, kind: kinds[i] })
);
Expand All @@ -81,7 +82,7 @@ describe('account2fa transactions', () => {

test('add app key', async() => {
let account = await testUtils.createAccount(nearjs);
account = await getAccount2fa(account);
account = await getAccount2FA(account);
const appPublicKey = KeyPair.fromRandom('ed25519').getPublicKey();
const appMethodNames = ['some_app_stuff', 'some_more_app_stuff'];
await account.addKey(appPublicKey.toString(), 'foobar', appMethodNames.join(), new BN(parseNearAmount('0.25')));
Expand All @@ -93,8 +94,8 @@ describe('account2fa transactions', () => {
test('send money', async() => {
let sender = await testUtils.createAccount(nearjs);
let receiver = await testUtils.createAccount(nearjs);
sender = await getAccount2fa(sender);
receiver = await getAccount2fa(receiver);
sender = await getAccount2FA(sender);
receiver = await getAccount2FA(receiver);
const { amount: receiverAmount } = await receiver.state();
await sender.sendMoney(receiver.accountId, new BN(parseNearAmount('1')));
await receiver.fetchState();
Expand Down
Loading

0 comments on commit 6a6bbaa

Please sign in to comment.