Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"author": "Bitte Team",
"license": "MIT",
"dependencies": {
"@near-wallet-selector/core": "^8.10.1",
"@near-wallet-selector/wallet-utils": "^8.10.1",
"@near-wallet-selector/core": "^10.0.0",
"near-api-js": "^5.1.1"
},
"devDependencies": {
Expand Down
125 changes: 103 additions & 22 deletions pnpm-lock.yaml

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

48 changes: 38 additions & 10 deletions src/bitte-wallet-setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {
WalletModuleFactory,
WalletBehaviourFactory,
Transaction,
Network,
Account,
InjectedWallet,
import {
type WalletModuleFactory,
type WalletBehaviourFactory,
type Transaction,
type Network,
type Account,
type InjectedWallet,
type Action,
najActionToInternal,
} from "@near-wallet-selector/core";
import { icon } from "./icon";
import { createBitteWalletConnector } from "./bitte-wallet";
Expand Down Expand Up @@ -63,7 +65,7 @@ const BitteWallet: WalletBehaviourFactory<
async signIn({ contractId, methodNames }) {
if (!state.wallet.isSignedIn()) {
await state.wallet.requestSignIn({
contractId,
contractId: contractId || "",
methodNames,
});
}
Expand Down Expand Up @@ -124,7 +126,8 @@ const BitteWallet: WalletBehaviourFactory<

return state.wallet.signAndSendTransaction({
receiverId: receiverId || contract.contractId,
actions,
// Convert actions for compatibility with wallet selector v10
actions: actions.map(action => najActionToInternal(action)) as unknown as Array<Action>,
});
},

Expand All @@ -135,14 +138,39 @@ const BitteWallet: WalletBehaviourFactory<
throw new Error("Wallet not signed in");
}

const _transactions = transactions.map(transaction => (
{
...transaction,
// Convert actions for compatibility with wallet selector v10
actions: transaction.actions.map(action => najActionToInternal(action)) as unknown as Array<Action>,
}
)) as Array<Transaction>;

return state.wallet.signAndSendTransactions(
transactions as Array<Transaction>
_transactions
);
},

buildImportAccountsUrl() {
return `${params.walletUrl}/batch-import`;
},

// Added for compatibility with wallet selector v10
getPublicKey() {
throw new Error(`Method not supported by ${metadata.name}`);
},

signDelegateAction() {
throw new Error(`Method not supported by ${metadata.name}`);
},

signNep413Message() {
throw new Error(`Method not supported by ${metadata.name}`);
},

signTransaction() {
throw new Error(`Method not supported by ${metadata.name}`);
}
};
};

Expand Down
18 changes: 9 additions & 9 deletions src/bitte-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type {
Action,
FinalExecutionOutcome,
Network,
SignMessageParams,
Transaction,
import {
internalActionToNaj,
type Action,
type FinalExecutionOutcome,
type Network,
type SignMessageParams,
type Transaction,
} from "@near-wallet-selector/core";
import { createAction } from "@near-wallet-selector/wallet-utils";
import { connect, keyStores, providers } from "near-api-js";
import type { PublicKey } from "near-api-js/lib/utils/index.js";
import { KeyPair } from "near-api-js/lib/utils/index.js";
Expand Down Expand Up @@ -155,7 +155,7 @@ const signMessage = async (
const storedKeyCanSign = (
state: WalletState,
receiverId: string,
actions: Array<Action>
actions: Array<any>
): boolean => {
if (
state.functionCallKey &&
Expand Down Expand Up @@ -191,7 +191,7 @@ const signUsingKeyPair = async (

return account.signAndSendTransaction({
receiverId,
actions: actions.map((a) => createAction(a)),
actions: actions.map((a) => internalActionToNaj(a as any)),
});
};

Expand Down