Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #316 from tiki/release/rename-tiki-sdk
Browse files Browse the repository at this point in the history
fix: rename all tikisdk refs to tikitrail
  • Loading branch information
mike-audi authored Jun 12, 2023
2 parents 8b21ca8 + 4bbdef2 commit 300487d
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 62 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 3.0.3

- fix:
- rename TikiSdk to TikiTrail
- remove doc references to TikiSdk

### 3.0.2

- no code changes.
Expand Down
2 changes: 1 addition & 1 deletion dartdoc_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dartdoc:
include: [
tiki_sdk_dart
tiki_trail
]
6 changes: 3 additions & 3 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:io';
import 'package:example/in_mem_key_storage.dart';
import 'package:sqlite3/common.dart';
import 'package:sqlite3/sqlite3.dart';
import 'package:tiki_trail/tiki_sdk.dart';
import 'package:tiki_trail/tiki_trail.dart';
import 'package:uuid/uuid.dart';

void main(List<String> arguments) async {
Expand All @@ -18,8 +18,8 @@ void main(List<String> arguments) async {
String id = Uuid().v4();
String ptr = const Uuid().v4();

TikiSdk.withId(id, keyStorage);
TikiSdk tiki = await TikiSdk.init('PUBLISHING_ID',
TikiTrail.withId(id, keyStorage);
TikiTrail tiki = await TikiTrail.init('PUBLISHING_ID',
'com.mytiki.tiki_trail.example', keyStorage, id, database);

TitleRecord title = await tiki.title.create(ptr, tags: [TitleTag.userId()]);
Expand Down
2 changes: 1 addition & 1 deletion example/lib/in_mem_key_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* MIT license. See LICENSE file in root directory.
*/

import 'package:tiki_trail/tiki_sdk.dart';
import 'package:tiki_trail/tiki_trail.dart';
import 'package:tiki_trail/utils/rsa/rsa.dart';

class InMemKeyStorage extends KeyStorage {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.0"
version: "3.0.2"
typed_data:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: example
description: TIKI SDK Dart Example app.
description: TIKI Trail Example app.
version: 1.0.0
publish: none
homepage: https://mytiki.com
Expand Down
4 changes: 3 additions & 1 deletion lib/cache/license/license_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import 'dart:convert';
import 'dart:typed_data';

import '../../tiki_sdk.dart';
import '../../license_record.dart';
import '../../title_record.dart';
import '../../utils/bytes.dart';
import '../../utils/compact_size.dart';
import '../title/title_model.dart';
import 'license_repository.dart';
import 'license_use.dart';

/// Describes the license for an asset ([TitleModel]).
class LicenseModel {
Expand Down
3 changes: 2 additions & 1 deletion lib/cache/title/title_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import 'dart:convert';
import 'dart:typed_data';

import '../../tiki_sdk.dart';
import '../../title_record.dart';
import '../../utils/bytes.dart';
import '../../utils/compact_size.dart';
import 'title_repository.dart';
import 'title_tag.dart';

/// Describes an asset and contains a Pointer Record [ptr] to
/// the actual asset.
Expand Down
16 changes: 8 additions & 8 deletions lib/license.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

import 'cache/license/license_model.dart';
import 'cache/license/license_service.dart';
import 'tiki_sdk.dart';
import 'tiki_trail.dart';
import 'utils/bytes.dart';

/// Methods for creating and retrieving [LicenseRecord]s. Use like a namespace,
/// and call from [TikiSdk]. E.g. `tikiSdk.license.create(...)`.
/// and call from [TikiTrail]. E.g. `tikiTrail.license.create(...)`.
class License {
final LicenseService _licenseService;
final TikiSdk _sdk;
final TikiTrail _trail;

/// Use [TikiSdk] to construct.
/// Use [TikiTrail] to construct.
/// @nodoc
License(this._licenseService, this._sdk);
License(this._licenseService, this._trail);

/// Create a new [LicenseRecord]
///
Expand Down Expand Up @@ -52,7 +52,7 @@ class License {
/// license records are not found.
///
/// The [LicenseRecord] returned may be expired or not applicable to a
/// specific [LicenseUse]. To check license validity, use the [guard]
/// specific [LicenseUse]. To check license validity, use the [TikiTrail.guard]
/// method.
LicenseRecord? latest(TitleRecord title) {
LicenseModel? license =
Expand All @@ -64,7 +64,7 @@ class License {
/// Returns all [LicenseRecord]s for a [title].
///
/// The [LicenseRecord]s returned may be expired or not applicable to a
/// specific [LicenseUse]. To check license validity, use the [guard]
/// specific [LicenseUse]. To check license validity, use the [TikiTrail.guard]
/// method.
List<LicenseRecord> all(TitleRecord title) {
List<LicenseModel> licenses =
Expand All @@ -77,7 +77,7 @@ class License {
LicenseRecord? get(String id) {
LicenseModel? license = _licenseService.getById(Bytes.base64UrlDecode(id));
if (license == null) return null;
TitleRecord? title = _sdk.title.id(Bytes.base64UrlEncode(license.title));
TitleRecord? title = _trail.title.id(Bytes.base64UrlEncode(license.title));
if (title == null) return null;
return license.toRecord(title);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/payable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import 'dart:typed_data';

import 'cache/payable/payable_model.dart';
import 'cache/payable/payable_service.dart';
import 'tiki_sdk.dart';
import 'tiki_trail.dart';
import 'utils/bytes.dart';

/// Methods for creating and retrieving [PayableRecord]s. Use like a namespace,
/// and call from [TikiSdk]. E.g. `tikiSdk.payable.create(...)`.
/// and call from [TikiTrail]. E.g. `tikiTrail.payable.create(...)`.
class Payable {
final PayableService _payableService;
final TikiSdk _sdk;
final TikiTrail _trail;

/// Use [TikiSdk] to construct.
/// Use [TikiTrail] to construct.
/// @nodoc
Payable(this._payableService, this._sdk);
Payable(this._payableService, this._trail);

/// Create a new [PayableRecord].
///
Expand Down Expand Up @@ -64,7 +64,7 @@ class Payable {
PayableModel? payable = _payableService.getById(Bytes.base64UrlDecode(id));
if (payable == null) return null;
LicenseRecord? license =
_sdk.license.get(Bytes.base64UrlEncode(payable.license));
_trail.license.get(Bytes.base64UrlEncode(payable.license));
if (license == null) return null;
return payable.toRecord(license);
}
Expand Down
15 changes: 6 additions & 9 deletions lib/receipt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import 'dart:typed_data';

import 'cache/receipt/receipt_model.dart';
import 'cache/receipt/receipt_service.dart';
import 'tiki_sdk.dart';
import 'tiki_trail.dart';
import 'utils/bytes.dart';

/// Methods for creating and retrieving [ReceiptRecord]s. Use like a namespace,
/// and call from [TikiSdk]. E.g. `tikiSdk.receipt.create(...)`.
/// and call from [TikiTrail]. E.g. `tikiTrail.receipt.create(...)`.
class Receipt {
final ReceiptService _receiptService;
final TikiSdk _sdk;
final TikiTrail _trail;

/// Use [TikiSdk] to construct.
/// Use [TikiTrail] to construct.
/// @nodoc
Receipt(this._receiptService, this._sdk);
Receipt(this._receiptService, this._trail);

/// Create a new [ReceiptRecord].
///
Expand All @@ -32,9 +32,6 @@ class Receipt {
/// • [description] - An optional, short, human-readable, description of
/// the [ReceiptRecord].
///
/// • [expiry] - The date when the payable expires — leave `null` if
/// it never expires.
///
/// • [reference] - A customer-specific reference identifier. Use this
/// to connect the record to your system.
///
Expand All @@ -60,7 +57,7 @@ class Receipt {
ReceiptModel? receipt = _receiptService.getById(Bytes.base64UrlDecode(id));
if (receipt == null) return null;
PayableRecord? payable =
_sdk.payable.get(Bytes.base64UrlEncode(receipt.payable));
_trail.payable.get(Bytes.base64UrlEncode(receipt.payable));
if (payable == null) return null;
return receipt.toRecord(payable);
}
Expand Down
17 changes: 10 additions & 7 deletions lib/tiki_sdk.dart → lib/tiki_trail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* Copyright (c) TIKI Inc.
* MIT license. See LICENSE file in root directory.
*/
library tiki_sdk_dart;

/// The TIKI trail project is an immutable, distributed, record system for data
/// transactions. Use [TikiTrail] as the primary entrypoint.
library tiki_trail;

import 'dart:typed_data';

Expand Down Expand Up @@ -56,8 +59,8 @@ export 'receipt_record.dart';
export 'title.dart';
export 'title_record.dart';

/// The primary entrypoint for the SDK —use to create, get, and enforce records.
class TikiSdk {
/// The primary entrypoint for the library —use to create, get, and enforce records.
class TikiTrail {
final NodeService _nodeService;

/// Interact with [TitleRecord]s.
Expand All @@ -74,7 +77,7 @@ class TikiSdk {

/// Prefer [withId] and [init] instead.
/// @nodoc
TikiSdk(
TikiTrail(
String origin, NodeService nodeService, RegistryService registryService)
: _nodeService = nodeService {
TitleService titleService =
Expand Down Expand Up @@ -107,7 +110,7 @@ class TikiSdk {
return Bytes.base64UrlEncode(primaryKey.address);
}

/// Returns a new initialized [TikiSdk] instance.
/// Returns a new initialized [TikiTrail] instance.
///
/// Parameters:
///
Expand Down Expand Up @@ -137,7 +140,7 @@ class TikiSdk {
/// • [customerAuth] - A customer provided Authorization Token (JWT) for
/// use in [id] registration. Use [customerAuth] to add user identity
/// verification. Configure in [console](https://console.mytiki.com)
static Future<TikiSdk> init(String publishingId, String origin,
static Future<TikiTrail> init(String publishingId, String origin,
KeyStorage keyStorage, String id, CommonDatabase database,
{int maxTransactions = 1,
Duration blockInterval = const Duration(minutes: 1),
Expand Down Expand Up @@ -169,7 +172,7 @@ class TikiSdk {
storageService, database, primaryKey, nodeService.getBlock);
await nodeService.init();

return TikiSdk(origin, nodeService, registryService);
return TikiTrail(origin, nodeService, registryService);
}

/// Returns the in-use wallet [address].
Expand Down
10 changes: 5 additions & 5 deletions lib/title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import 'package:pointycastle/api.dart';

import 'cache/title/title_model.dart';
import 'cache/title/title_service.dart';
import 'tiki_sdk.dart';
import 'tiki_trail.dart';
import 'utils/bytes.dart';

/// Methods for creating and retrieving [TitleRecord]s. Use like a namespace,
/// and call from [TikiSdk]. E.g. `tikiSdk.title.create(...)`
/// and call from [TikiTrail]. E.g. `tikiTrail.title.create(...)`
class Title {
final TitleService _titleService;

/// Use [TikiSdk] to construct.
/// Use [TikiTrail] to construct.
/// @nodoc
Title(this._titleService);

Expand All @@ -32,7 +32,7 @@ class Title {
/// about selecting good pointer records.
///
/// • [origin] - An optional override of the default [origin] specified in
/// [init]. We recommend following a reverse-DNS syntax.
/// [TikiTrail.init]. We recommend following a reverse-DNS syntax.
/// _i.e. com.myco.myapp_
///
/// • [tags] - A `List` of metadata tags included in the [TitleRecord]
Expand Down Expand Up @@ -65,7 +65,7 @@ class Title {
/// about selecting good pointer records.
///
/// • [origin] - An optional override of the default [origin] specified in
/// [init]. We recommend following a reverse-DNS syntax.
/// [TikiTrail.init]. We recommend following a reverse-DNS syntax.
/// _i.e. com.myco.myapp_
TitleRecord? get(String ptr, {String? origin}) {
ptr = _hashPtr(ptr);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tiki_trail
description: Create and enforce TIKI's immutable data transaction records.
version: 3.0.2
version: 3.0.3
homepage: https://mytiki.com
documentation: https://mytiki.com/docs
repository: https://github.com/tiki/tiki-trail
Expand Down
4 changes: 2 additions & 2 deletions test/guard_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import 'package:test/test.dart';
import 'package:tiki_trail/tiki_sdk.dart';
import 'package:tiki_trail/tiki_trail.dart';
import 'package:tiki_trail/utils/guard.dart';

void main() {
Expand All @@ -13,7 +13,7 @@ void main() {
expiry: expiry);
}

group('TIKI SDK Guard tests', () {
group('TIKI Trail Guard tests', () {
test('no uses - False', () async {
List<LicenseUse> uses = [];
bool pass = Guard.check(fakeLicense(uses), uses) == null;
Expand Down
11 changes: 6 additions & 5 deletions test/in_mem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:tiki_trail/node/node_service.dart';
import 'package:tiki_trail/node/transaction/transaction_service.dart';
import 'package:tiki_trail/node/xchain/xchain_client.dart';
import 'package:tiki_trail/node/xchain/xchain_service.dart';
import 'package:tiki_trail/tiki_sdk.dart';
import 'package:tiki_trail/tiki_trail.dart';
import 'package:tiki_trail/utils/rsa/rsa.dart';
import 'package:tiki_trail/utils/rsa/rsa_private_key.dart';
import 'package:uuid/uuid.dart';
Expand Down Expand Up @@ -128,14 +128,15 @@ class InMemBuilders {
return nodeService;
}

static Future<TikiSdk> tikiSdk(
{String? id, String origin = 'com.mytiki.tiki_sdk_dart.test'}) async {
static Future<TikiTrail> tikiTrail(
{String? id, String origin = 'com.mytiki.tiki_trail.test'}) async {
id ??= const Uuid().v4();
InMemKeyStorage keyStorage = InMemKeyStorage();

String address = await TikiSdk.withId(id, keyStorage);
String address = await TikiTrail.withId(id, keyStorage);
NodeService nodeService =
await InMemBuilders.nodeService(id: id, keyStorage: keyStorage);
return TikiSdk(origin, nodeService, InMemRegistryService(address: address));
return TikiTrail(
origin, nodeService, InMemRegistryService(address: address));
}
}
Loading

0 comments on commit 300487d

Please sign in to comment.