Skip to content

Commit

Permalink
fix(sdk): 🔥 Remove the HERE wallet hack from mbjs
Browse files Browse the repository at this point in the history
  • Loading branch information
cif committed Jan 19, 2023
1 parent b0fb4ae commit 551b095
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
3 changes: 1 addition & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"@here-wallet/core": "^1.3.1",
"near-api-js": "^0.44.2"
}
}
}
26 changes: 4 additions & 22 deletions packages/sdk/src/execute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import type { Wallet, FinalExecutionOutcome, Optional, Transaction } from '@near-wallet-selector/core';
import { BrowserWalletSignAndSendTransactionParams } from '@near-wallet-selector/core/lib/wallet';
import { DefaultStrategy } from '@here-wallet/core';
import type { providers, Account } from 'near-api-js';
import { NoSigningMethodPassedError } from './errors';
import BN from 'bn.js';
Expand Down Expand Up @@ -53,7 +52,6 @@ export const execute = async (
};

const genericBatchExecute = async (call: ContractCall[], wallet: Wallet, account: Account, callbackUrl: string): Promise<void | providers.FinalExecutionOutcome[]> =>{

if (wallet) {
return batchExecuteWithBrowserWallet(call, wallet, callbackUrl);
}
Expand All @@ -63,7 +61,6 @@ const genericBatchExecute = async (call: ContractCall[], wallet: Wallet, account

// account call translation wrappers https://docs.near.org/tools/near-api-js/faq#how-to-send-batch-transactions
// TODO: share batch signature with wallet selector sendAndSignTransaction when method becomes public

const batchExecuteWithNearAccount = async (
calls: ContractCall[],
account: Account,
Expand Down Expand Up @@ -94,25 +91,10 @@ const batchExecuteWithBrowserWallet = async (
calls: ContractCall[],
wallet: Wallet,
callback: string,
): Promise<void | FinalExecutionOutcome[]> => {

// avoids popup blockers when async ops happen in same user call
let strategy: DefaultStrategy;
if (wallet.id === 'here-wallet') {
strategy = new DefaultStrategy();
strategy.onInitialized();
}

return await wallet.signAndSendTransactions({
transactions: calls.map(convertGenericCallToWalletCall) as TxnOptionalSignerId[],
callbackUrl: callback,
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore Only for HERE wallet
strategy,
});
};

//////////// UTILS ////////////
): Promise<void | FinalExecutionOutcome[]> => wallet.signAndSendTransactions({
transactions: calls.map(convertGenericCallToWalletCall) as TxnOptionalSignerId[],
callbackUrl: callback,
});

declare type TxnOptionalSignerId = Optional<Transaction, 'signerId'>;

Expand Down

0 comments on commit 551b095

Please sign in to comment.