ledgerconnect / steemconnect.js

SteemConnect JavaScript SDK
https://demo.steemconnect.com
MIT License
65 stars 50 forks source link

account_update2 broadcast fails #73

Closed tiotdev closed 4 years ago

tiotdev commented 4 years ago

Broadcasting the new account_update2 operation should be possible using the Steemconnect API since it only requires the posting authority or with the extension, but it throws the exception: "The access_token scope does not allow the following operation(s): account_update2" / "Oops, something went wrong. Please try again later." (extension)

This is my code (works with Keychain):

const accountUpdate = (account, posting_json_metadata) => {
  const ops = [
    [
      'account_update2',
      {
        account,
        json_metadata: '',
        posting_json_metadata,
      },
    ],
  ];

  return new Promise(resolve => {
    if (window && window.steem_keychain) {
      window.steem_keychain.requestBroadcast(account, ops, 'posting', res => {
        if (res.success) {
          resolve({
            success: true,
            message: 'Profile was updated successfully',
          });
        } else {
          resolve({
            success: false,
            message: `Profile could not be updated: ${res.message}`,
          });
        }
      });
    } else {
      api.setAccessToken(getScToken());
      api.broadcast(ops, (err, res) => {
        if (err) {
          resolve({
            success: false,
            message: `Profile could not be updated: ${(typeof err ===
              'string' &&
              `: ${err}`) ||
              (err.error_description && `: ${err.error_description}`)}`,
          });
        }
        if (res) {
          resolve({
            success: true,
            message: 'Profile was updated successfully',
          });
        }
      });
    }
  });
};

accountUpdate('jpphoto', '{"profile":{"about":"Testing account"}}');

Parsing the posting_json_metadata as json doesn't help either.