Skip to content

Commit

Permalink
Merge pull request #1138 from near/SQC-540/add-signin-multi-breaking-…
Browse files Browse the repository at this point in the history
…change-fix

fix near-mobile-wallet, near-snap and ramper-wallet methods
  • Loading branch information
gtsonevv authored Jul 25, 2024
2 parents 6c1e65c + 142c447 commit 565665d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/near-mobile-wallet/src/lib/init.wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export const initNearMobileWallet: NearMobileWalletInit = async (config) => {
async signAndSendTransaction(data) {
logger.log("[NearMobileWallet]: signAndSendTransaction", data);

const { contract } = store.getState();
if (!contract) {
const { contracts } = store.getState();
if (contracts.length < 1) {
throw new Error("Wallet not signed in");
}

return await nearMobileWallet.signAndSendTransaction({
receiverId: contract.contractId,
receiverId: data.receiverId,
...data,
});
},
Expand Down
8 changes: 4 additions & 4 deletions packages/near-snap/src/lib/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ export const initNearSnap: WalletBehaviourFactory<InjectedWallet> = async (

async signAndSendTransaction(data) {
logger.log("NearSnap:signAndSendTransaction", data);
const { contracts } = store.getState();

if (account == null) {
if (account === null || contracts.length < 1) {
throw new Error("Wallet not signed in");
}

const { contract } = store.getState();
const receiverId = data.receiverId ?? contract?.contractId;
const receiverId = data.receiverId;

if (receiverId == null) {
throw new Error("ReceiverId is not defined");
}

return await account.executeTransaction({ receiverId, ...data });
return await account.executeTransaction({ ...data, receiverId });
},

async signMessage({ message, nonce, recipient }) {
Expand Down
10 changes: 5 additions & 5 deletions packages/ramper-wallet/src/lib/ramper-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const RamperWallet: WalletBehaviourFactory<InjectedWallet> = async ({
transactions: Array<Optional<Transaction, "signerId">>
) => {
const accounts = await getAccounts();
const { contract } = store.getState();
const { contracts } = store.getState();

if (!accounts.length || !contract) {
if (!accounts.length || contracts.length < 1) {
throw new Error("Wallet not signed in");
}

Expand All @@ -85,7 +85,7 @@ const RamperWallet: WalletBehaviourFactory<InjectedWallet> = async ({
);

return {
receiverId: transaction.receiverId || contract.contractId,
receiverId: transaction.receiverId,
actions: parsedActions,
};
});
Expand Down Expand Up @@ -127,10 +127,10 @@ const RamperWallet: WalletBehaviourFactory<InjectedWallet> = async ({
}: Omit<Transaction, "signerId">) {
logger.log("signAndSendTransaction", { receiverId, actions });

const { contract } = store.getState();
const { contracts } = store.getState();
const accounts = await getAccounts();

if (!accounts.length || !contract) {
if (!accounts.length || contracts.length < 1) {
throw new Error("Wallet not signed in");
}

Expand Down

0 comments on commit 565665d

Please sign in to comment.