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

feat: add Near.signAndSendTransactions #159

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

AZbang
Copy link

@AZbang AZbang commented Dec 7, 2023

Added Near.signAndSendTransactions for support all types actions. The method is fully compatible with the wallet-selector format. For example:

Near.signAndSendTransactions([{
    receiverId: "azbang.near",
    actions: [{ type: "AddKey", params: {  ... } }]
}])

Also added UI for confirmation modal. You can test it on my gateway:
https://call-any-actions-near-social.surge.sh/#/azbang.near/widget/ExportAccount

Copy link
Contributor

@evgenykuzyakov evgenykuzyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase on top of dev branch. See https://github.com/NearSocial/VM/blob/master/CONTRIBUTING.md

Comment on lines +1601 to +1611
if (lastReceiverId !== action.contractName) {
transactions.push({
receiverId: action.contractName,
actions: [{ type: "FunctionCall", params: action }],
});
} else {
transactions[transactions.length - 1].actions.push({
type: "FunctionCall",
params: action,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to limit the max gas amount per transaction. As 2FA contracts are not the issue, the max gas should be 300Tgas

Comment on lines +158 to +160
Carefully! You add a full access key; with this key
you can sign any transaction on behalf of your
account. The key has full access to your tokens.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should display the warning message at the top of the confirmation window.

Also display a warning message for all non default actions. E.g. contract deploy on your account, all key actions, account deletion.

<div>
<span className="text-secondary">Code:</span>
<span className="font-monospace">
{action.params.code}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the format of the code? Should we display just the base58 hash?

{displayGas(action.params.gas || TGas.mul(30))}
</span>
</div>
<Markdown text={jsonMarkdown(action.params.args)} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone asked me to include binary data here. Not sure how we want to handle it. We can always add this later.

import { Markdown } from "./Markdown";
import { displayGas, displayNear, Loading } from "../data/utils";
import { useNear } from "../data/near";
import { formatNearAmount } from "near-api-js/lib/utils/format";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the implementation of the formatNearAmount. It doesn't understand yoctoNear. Let's stick with displayNear for consistency. We can fix it later

@AZbang AZbang changed the base branch from master to dev December 9, 2023 23:32
@frol
Copy link

frol commented Jan 28, 2024

@AZbang This is great! Would you be able to push this PR through the finish line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants