deriveSessionsFieldId method

String deriveSessionsFieldId(
  1. String owner
)

The object id of the owner's DataKey<SessionsApp> dynamic field — fetch this object and pass its BCS contents to decodeSessions. There is no bulk on-chain read, so this is the route to enumerating grants.

Implementation

String deriveSessionsFieldId(String owner) {
  // A PLAIN dynamic field, not a derived object: `account::attach` writes
  // it with `df::add` (`use fun df::add as UID.add`), whereas the account
  // and wrapper ids are claimed through `derived_object::claim`.
  // `deriveObjectID` would wrap the tag in
  // `0x2::derived_object::DerivedObjectKey<..>` and yield an id that
  // points at nothing.
  final sessionsPackage =
      _config.sessionsPackageIdV1 ?? _config.sessionsPackageId;
  return deriveDynamicFieldID(
    deriveAccountId(owner),
    '${_config.accountPackageId}::account::DataKey'
    '<$sessionsPackage::sessions::SessionsApp>',
    // DataKey is source-empty; Move's hidden `dummy_field: bool` is the
    // key's one byte.
    Uint8List.fromList([0]),
  );
}