Skip to content
Draft
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
33 changes: 18 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { NavigationWrapper } from "./components/navigation/NavigationWrapper";
import { NetworkId, Widgets } from "./data/widgets";
import { useEthersProviderContext } from "./data/web3";
import SignInPage from "./pages/SignInPage";
import { wrapWalletSelector } from "./data/wrappedSelector";

export const refreshAllowanceObj = {};
const documentationHref = "https://social.near-docs.io/";
Expand All @@ -56,21 +57,23 @@ function App(props) {
initNear &&
initNear({
networkId: NetworkId,
selector: setupWalletSelector({
network: NetworkId,
modules: [
setupNearWallet(),
setupMyNearWallet(),
setupSender(),
setupHereWallet(),
setupMeteorWallet(),
setupNeth({
gas: "300000000000000",
bundle: false,
}),
setupNightly(),
],
}),
selector: wrapWalletSelector(
setupWalletSelector({
network: NetworkId,
modules: [
setupNearWallet(),
setupMyNearWallet(),
setupSender(),
setupHereWallet(),
setupMeteorWallet(),
setupNeth({
gas: "300000000000000",
bundle: false,
}),
setupNightly(),
],
})
),
customElements: {
Link: (props) => {
if (!props.to && props.href) {
Expand Down
39 changes: 39 additions & 0 deletions src/data/wrappedSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { NetworkId } from "./widgets";

const MainnetSocialDbContractName = "social.near";

export async function wrapWalletSelector(selector) {
selector = await selector;
return {
...selector,
wallet: async () => {
const wallet = await selector.wallet();
return {
...wallet,
signAndSendTransaction: async ({ receiverId, actions }) => {
// TODO: isPremium
const accountId =
selector.store.getState()?.accounts?.[0]?.accountId ?? null;
const isPremium = true;
if (
NetworkId === "mainnet" &&
isPremium &&
receiverId === MainnetSocialDbContractName &&
actions.length === 1 &&
actions[0].type === "FunctionCall" &&
actions[0].params.methodName === "set" &&
actions[0].params.deposit === "0"
) {
const [_bytes, signedTransaction] = await wallet.signTransaction({
receiverId,
actions,
});
console.log("SENDING SIGNED TRANSACTION", signedTransaction);
// return wallet.sendTransaction(signedTransaction);
}
// return wallet.signAndSendTransaction(receiverId, actions);
},
};
},
};
}