MetaweaveTeam/ArProfile

Extending Account

Closed this issue · 8 comments

Hi,

I am creating an Arweave application and would like to use Account as the user profile record, but I would like to store additional data on Account specific for my application.

Is this possible?

Could I just extend the JSON

{
  ...
  "myAppIdentifier": {
     ... my stuff
   }
}

And as long as I write a transaction with the Account Tags it will work with the Account app?

Thanks in advance for your time.

Hi twilson63,

Thank you very much for your comment, huge apology for my late answer.

Yes it is possible to extend the protocol, I would also like to have application specific data.
As the json, we could add a new property called apps where app identifiers can be added.

{
  ...
  "apps": {
    "myAppIdentifier": {
      ... your stuff
    },
    "anotherAppIdentifier": {
      ... other stuff
    }
  }
}

I propose that we update arweave-account npm package to be able to add a specific identifier when instantiating and getter/setter methods.

With this update, any app builder will be able to manipulate their specific data with few lines of code. Therefore it's essential to add some sort of an "App Data Manager" to Account application where you could see and "reset" a specific app data (new tx without the specified app identifier).

What do you think?

Love it! Let me know if I can contribute!

Thanks

Tom

Hi Tom!

Thanks for your support 💯

Here is the current available methods list:

  • account.get(addr)
  • account.search(handle)
  • account.find(handle#xxxxxx)
  • account.clearCache()

We can turn arweave-account into an interface to interact with application dependent data.
To do so, I propose to add an object appData containing methods to manipulate data, similar to localStorage usage:

  • account.appData.set(item, value)
  • account.appData.get(item | undefined) if undefined, get all items
  • account.appData.remove(item)
  • account.appData.clear()

When AppIdentifier option is given at instantiation time, the above methods would be enabled and data manipulation be restrained to the App Identifier data scope.

const account = new Account({
    AppIdentifier: "permanotes",
    Arweave: ArweaveObj                // wallet connection & tx signing
})

Would it be comfortable to use on your end? What do you think about the design?

If anything, let me know

Cheers :)

Love the design, so if I wanted to store following and subscriptions for permanotes app, I can do the following:

const account = new Account({
    AppIdentifier: "permanotes",
    Arweave: ArweaveObj                // wallet connection & tx signing
})

// add profile to follow
const following = await account.appData.get('following')
await account.appData.set('following', ['rakis', ...following])

// add topic to subscribe
const subscriptions = await account.appData.get('subscriptions')
await account.appData.set('subscriptions', ['arweave-dev', ...subscriptions])

If so, I love the API.

Yes this is what I had in mind, I'm happy we share the same view 💯

On my end, my code would be:

const account = new Account({
    AppIdentifier: "metaweave",
    Arweave: ArweaveObj                // wallet connection & tx signing
})

// add profile to follow
const trustedWallet = await account.appData.get('trusted-wallets')
await account.appData.set('trusted-wallets', [
  'vh-NTHVvlKZqRxc8LyyTNok65yQ55a_PJ1zWLb9G2JI',
  ...following
])

If you're up for a PR, feel free to do so I will love it, really like your style 👍

Happy to do a PR, I mostly write functional js so I will take a stab and you can choose if you like the approach or not. I will not bring in any dependencies but might create some utility functions to create lazily compose functions without side effects.

I love it! Thank you for your help!

🥇