Skip to content

Commit

Permalink
refactor: inline contractHasExistingStateError
Browse files Browse the repository at this point in the history
  • Loading branch information
esaminu committed Mar 15, 2022
1 parent 394a41e commit 6d57d90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/account_multisig.d.ts

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

14 changes: 9 additions & 5 deletions lib/account_multisig.js

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

7 changes: 4 additions & 3 deletions src/account_multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export class Account2FA extends AccountMultisig {
public verifyCode: verifyCodeFunction;
public onConfirmResult: Function;
public helperUrl = 'https://helper.testnet.near.org';
public contractHasExistingStateError = new TypedError(`Can not deploy a contract to account ${this.accountId} on network ${this.connection.networkId}, the account has existing state.`, 'ContractHasExistingState');

constructor(connection: Connection, accountId: string, options: any) {
super(connection, accountId, options);
Expand Down Expand Up @@ -280,7 +279,7 @@ export class Account2FA extends AccountMultisig {
case MultisigStateStatus.VALID:
return await super.signAndSendTransactionWithAccount(accountId, actions);
case MultisigStateStatus.INVALID_STATE:
throw this.contractHasExistingStateError;
throw new TypedError(`Can not deploy a contract to account ${this.accountId} on network ${this.connection.networkId}, the account has existing state.`, 'ContractHasExistingState');
}
}

Expand All @@ -302,7 +301,9 @@ export class Account2FA extends AccountMultisig {
if (cause == 'NO_CONTRACT_CODE') {
return [];
}
throw cause == 'TOO_LARGE_CONTRACT_STATE' ? this.contractHasExistingStateError : error;
throw cause == 'TOO_LARGE_CONTRACT_STATE' ?
new TypedError(`Can not deploy a contract to account ${this.accountId} on network ${this.connection.networkId}, the account has existing state.`, 'ContractHasExistingState') :
error;
});
const currentAccountStateKeys = currentAccountState.map(({ key }) => key.toString('base64'))
const cleanupActions = currentAccountState.length ? [
Expand Down

0 comments on commit 6d57d90

Please sign in to comment.