Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix near-mobile-wallet, near-snap and ramper-wallet methods #1138

Merged
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
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