Open AnaisUrlichs opened 4 years ago
Update:
Vladimir Grichina, @Jasperdg so very first thing you need to do is to update how login works similar to this example: https://studio.nearprotocol.com/?f=mdqekeqkd
1) Use WalletConnection (renamed WalletAccount
) – window.walletConnection = new nearlib.WalletConnection(window.near, nearConfig.contractName);
2) Obtain Account instance from WalletConnection
:
contract = new nearlib.Contract(walletConnection.account(), nearConfig.contractName, {
viewMethods: ['getMessages'],
changeMethods: ['addMessage'],
sender: window.accountId,
});
when you use walletConnection.account()
it should already allow to sign transactions on demand even if there is no allowance
but I think it makes sense for us to also add automated re-login on nearlib side.
Context: We should build applications that can be used to provide examples in response to community questions. If we already have an application that provides an example implementation, please link it below.
Jasper de Gooijer, [09.03.20 18:45] What's the best way to get an access keys' allowance for a specific contract? I know that Account.getAccountDetails returns a list of all authorized apps w/ allowance. This would force me to loop through those apps to see if it matches my smart contract accountId and then return that allowance.
Bowen Wang, [09.03.20 18:56] @Jasperdg you can query a key directly through rpc. For example, http post https://rpc.nearprotocol.com method=query params:='["access_key/bowen/Hvpz887t27jjtyqa5wpJtS99TpvMg3kbMKBsaL9db1vs", ""]' id=123 jsonrpc=2.0