I am having trouble integrating signing into your near-wallet testnet account into my application and sending balance to some other account
I use WalletSelector for the user to log in into the account.
signIn() {
const modal = setupModal(this.walletSelector!, { contractId: "" });
modal.show();
}
After logging in, this is what account agrees to:
Then I have separate button on UI for transferring tokens from one account to another.
Reading through the documentation I’ve read that calling walletConnection.account().sendMoney()
will redirect you to near-wallet acc, where you will accept the transfer of the payment and hash after successful transactions will be returned in the url.
My method for sending money goes like this:
async sendMoney(amount: string) {
if (!this.accountId) return;
const myKeyStore = new keyStores.BrowserLocalStorageKeyStore();
const connectionConfig = {
networkId: this.network.networkId,
keyStore: myKeyStore,
nodeUrl: "https://rpc.testnet.near.org",
walletUrl: "https://testnet.mynearwallet.com/",
helperUrl: "https://helper.testnet.near.org",
explorerUrl: "https://testnet.nearblocks.io",
};
const nearConnection = await connect(connectionConfig);
const walletConnection = new WalletConnection(nearConnection, "my-app");
const amountNear = utils.format.parseNearAmount(amount);
await walletConnection.account().sendMoney("testnet-testnet.testnet", amountNear);
}
Doing this I get this error:
Parse error: Failed parsing args: missing field `account_id
When the page loads I have this method:
async startUp() {
this.walletSelector = await setupWalletSelector({
network: this.network,
modules: [setupMyNearWallet()],
});
const isSignedIn = this.walletSelector.isSignedIn();
if (isSignedIn) {
this.wallet = await this.walletSelector!.wallet();
this.accountId =
this.walletSelector.store.getState().accounts[0].accountId;
}
return isSignedIn;
}
Logging nearConnection
from sendMoney()
function return object where accountId
is correct, but on walletConnection
it is undefined for some reason.
How can I fix this and what are the correct methods to tackle this? there isn’t enough information about it on the internet unfortunately