From 1f5b82ab1989f0193e0e6c911363468d69f4f038 Mon Sep 17 00:00:00 2001 From: aorumbayev Date: Tue, 28 Nov 2023 01:39:32 +0000 Subject: [PATCH] =?UTF-8?q?Refreshing=20documentation=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/style.css | 11 ++++++ classes/SubtopiaClient.html | 36 +++++++++---------- classes/SubtopiaRegistryClient.html | 26 +++++++------- enums/ChainType.html | 4 +-- enums/DiscountType.html | 4 +-- enums/Duration.html | 4 +-- enums/LifecycleState.html | 4 +-- enums/LockerType.html | 4 +-- enums/PriceNormalizationType.html | 4 +-- enums/SubscriptionType.html | 4 +-- functions/SUBTOPIA_REGISTRY_ID.html | 2 +- functions/durationToMonths.html | 2 +- functions/getLockerBoxPrefix.html | 4 +-- functions/normalizePrice.html | 4 +-- functions/optInAsset.html | 2 +- functions/optOutAsset.html | 2 +- index.html | 14 ++++---- interfaces/ApplicationSpec.html | 4 +-- interfaces/AssetMetadata.html | 4 +-- interfaces/BaseDiscountRecord.html | 4 +-- interfaces/DiscountMetadata.html | 4 +-- interfaces/DiscountRecord.html | 4 +-- interfaces/ProductState.html | 4 +-- interfaces/SubscriptionRecord.html | 4 +-- .../DEFAULT_TXN_SIGN_TIMEOUT_SECONDS.html | 2 +- variables/LOCKER_APPROVAL_KEY.html | 2 +- variables/LOCKER_CLEAR_KEY.html | 2 +- variables/LOCKER_VERSION.html | 2 +- variables/LOCKER_VERSION_KEY.html | 2 +- variables/ORACLE_VERSION.html | 2 +- variables/PRODUCT_APPROVAL_KEY.html | 2 +- variables/PRODUCT_CLEAR_KEY.html | 2 +- variables/PRODUCT_VERSION.html | 2 +- variables/PRODUCT_VERSION_KEY.html | 2 +- variables/REGISTRY_VERSION.html | 2 +- 35 files changed, 96 insertions(+), 85 deletions(-) diff --git a/assets/style.css b/assets/style.css index 108428c..07a385b 100644 --- a/assets/style.css +++ b/assets/style.css @@ -11,6 +11,7 @@ --light-color-text-aside: #6e6e6e; --light-color-link: #1f70c2; + --light-color-ts-keyword: #056bd6; --light-color-ts-project: #b111c9; --light-color-ts-module: var(--light-color-ts-project); --light-color-ts-namespace: var(--light-color-ts-project); @@ -50,6 +51,7 @@ --dark-color-text-aside: #dddddd; --dark-color-link: #00aff4; + --dark-color-ts-keyword: #3399ff; --dark-color-ts-project: #e358ff; --dark-color-ts-module: var(--dark-color-ts-project); --dark-color-ts-namespace: var(--dark-color-ts-project); @@ -91,6 +93,7 @@ --color-text-aside: var(--light-color-text-aside); --color-link: var(--light-color-link); + --color-ts-keyword: var(--light-color-ts-keyword); --color-ts-module: var(--light-color-ts-module); --color-ts-namespace: var(--light-color-ts-namespace); --color-ts-enum: var(--light-color-ts-enum); @@ -132,6 +135,7 @@ --color-text-aside: var(--dark-color-text-aside); --color-link: var(--dark-color-link); + --color-ts-keyword: var(--dark-color-ts-keyword); --color-ts-module: var(--dark-color-ts-module); --color-ts-namespace: var(--dark-color-ts-namespace); --color-ts-enum: var(--dark-color-ts-enum); @@ -180,6 +184,7 @@ body { --color-text-aside: var(--light-color-text-aside); --color-link: var(--light-color-link); + --color-ts-keyword: var(--light-color-ts-keyword); --color-ts-module: var(--light-color-ts-module); --color-ts-namespace: var(--light-color-ts-namespace); --color-ts-enum: var(--light-color-ts-enum); @@ -219,6 +224,7 @@ body { --color-text-aside: var(--dark-color-text-aside); --color-link: var(--dark-color-link); + --color-ts-keyword: var(--dark-color-ts-keyword); --color-ts-module: var(--dark-color-ts-module); --color-ts-namespace: var(--dark-color-ts-namespace); --color-ts-enum: var(--dark-color-ts-enum); @@ -984,6 +990,11 @@ a.tsd-index-link { overflow-x: auto; } +.tsd-signature-keyword { + color: var(--color-ts-keyword); + font-weight: normal; +} + .tsd-signature-symbol { color: var(--color-text-aside); font-weight: normal; diff --git a/classes/SubtopiaClient.html b/classes/SubtopiaClient.html index 2906f42..d4ed8af 100644 --- a/classes/SubtopiaClient.html +++ b/classes/SubtopiaClient.html @@ -1,7 +1,7 @@ SubtopiaClient | subtopia-js

Class SubtopiaClient

The SubtopiaClient class is responsible for interacting with a Subtopia Product contracts on the Algorand blockchain. It provides methods for initializing the client, managing the lifecycle of the application, creating and managing subscriptions, and retrieving information about the application and subscriptions.

-

Hierarchy

  • SubtopiaClient

Constructors

Constructors

  • Parameters

    • __namedParameters: {
          algodClient: default;
          appAddress: string;
          appID: number;
          appSpec: ApplicationSpec;
          coin: AssetMetadata;
          creator: TransactionSignerAccount;
          oracleID: number;
          price: number;
          productName: string;
          registryID: number;
          subscriptionName: string;
          timeout: number;
          version: string;
      }
      • algodClient: default
      • appAddress: string
      • appID: number
      • appSpec: ApplicationSpec
      • coin: AssetMetadata
      • creator: TransactionSignerAccount
      • oracleID: number
      • price: number
      • productName: string
      • registryID: number
      • subscriptionName: string
      • timeout: number
      • version: string

    Returns SubtopiaClient

Properties

algodClient: default
appAddress: string
appID: number
creator: TransactionSignerAccount
oracleID: number
price: number
productName: string
registryID: number
subscriptionName: string
timeout: number
version: string

Methods

  • Claims a subscription for a given subscriber.

    +

Constructors

  • Parameters

    • __namedParameters: {
          algodClient: default;
          appAddress: string;
          appID: number;
          appSpec: ApplicationSpec;
          coin: AssetMetadata;
          creator: TransactionSignerAccount;
          oracleID: number;
          price: number;
          productName: string;
          registryID: number;
          subscriptionName: string;
          timeout: number;
          version: string;
      }
      • algodClient: default
      • appAddress: string
      • appID: number
      • appSpec: ApplicationSpec
      • coin: AssetMetadata
      • creator: TransactionSignerAccount
      • oracleID: number
      • price: number
      • productName: string
      • registryID: number
      • subscriptionName: string
      • timeout: number
      • version: string

    Returns SubtopiaClient

Properties

algodClient: default
appAddress: string
appID: number
creator: TransactionSignerAccount
oracleID: number
price: number
productName: string
registryID: number
subscriptionName: string
timeout: number
version: string

Methods

  • Claims a subscription for a given subscriber.

    Parameters

    • __namedParameters: {
          subscriber: TransactionSignerAccount;
          subscriptionID: number;
      }
      • subscriber: TransactionSignerAccount
      • subscriptionID: number

    Returns Promise<{
        txID: string;
    }>

    • The transaction ID of the executed transaction.
    -
  • This method is used to create a discount for a subscription. +

  • This method is used to create a discount for a subscription. The method returns the transaction ID.

    Parameters

    • __namedParameters: {
          discountType: DiscountType;
          discountValue: number;
          duration: Duration;
          expiresIn: number;
          parseWholeUnits?: boolean;
      }
      • discountType: DiscountType
      • discountValue: number
      • duration: Duration
      • expiresIn: number
      • Optional parseWholeUnits?: boolean

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to create a subscription. +

  • This method is used to create a subscription. It takes a subscriber and a duration as arguments and returns a promise that resolves to an object containing the transaction ID and subscription ID.

    Parameters

    • __namedParameters: {
          duration: Duration;
          subscriber: TransactionSignerAccount;
      }
      • duration: Duration
      • subscriber: TransactionSignerAccount

    Returns Promise<{
        subscriptionID: number;
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID and subscription ID.

    -
  • This method is used to delete a discount. It takes a duration object as an argument and returns a promise that resolves to an object containing the transaction ID.

    Parameters

    • duration: {
          duration: Duration;
      }

      The duration of the discount to be deleted.

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to delete a subscription. +

  • This method is used to delete a subscription. It takes a subscriber and a subscription ID as arguments and returns a promise that resolves to an object containing the transaction ID.

    Parameters

    • __namedParameters: {
          subscriber: TransactionSignerAccount;
          subscriptionID: number;
      }
      • subscriber: TransactionSignerAccount
      • subscriptionID: number

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to disable the application (updates the lifecycle). +

  • This method is used to disable the application (updates the lifecycle). Has to be called before deleting the application. Upon disabling, product will stop allowing new subscriptions to be sold, existing subscribers will only be able to cancel their subscriptions. Product can be deleted once all subscriptions are cancelled or expired. The method returns the transaction ID.

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to enable the application (updates the lifecycle). +

  • This method is used to enable the application (updates the lifecycle). The method returns the transaction ID.

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to get the state of the application. It returns an object containing the product name, subscription name, manager, price, total subscriptions, maximum subscriptions, coin ID, subscription type, lifecycle, creation time, oracle ID, unit name, image URL, and discounts.

    Parameters

    • parseWholeUnits: boolean = true

      A boolean indicating whether to parse the whole units (default is true).

    Returns Promise<ProductState>

    A promise that resolves to an object containing the state of the application.

    -
  • This method is used to get the discount based on the duration. It takes a duration object as an argument and returns a promise that resolves to a DiscountRecord.

    Parameters

    • duration: {
          duration: Duration;
      }

      The duration for which the discount is to be calculated.

    Returns Promise<DiscountRecord>

    A promise that resolves to the discount record.

    -
  • This method is used to calculate the locker creation fee. +

  • This method is used to calculate the locker creation fee. It takes the creator's address as an argument and returns a promise that resolves to the fee amount.

    Parameters

    • creatorAddress: string

      The address of the creator.

    Returns Promise<number>

    A promise that resolves to the locker creation fee.

    -
  • This method is used to get a subscription. It takes an AlgodClient and a subscriber address as arguments and returns a promise that resolves to a SubscriptionRecord.

    Parameters

    • __namedParameters: {
          algodClient: default;
          subscriberAddress: string;
      }
      • algodClient: default
      • subscriberAddress: string

    Returns Promise<SubscriptionRecord>

    A promise that resolves to a SubscriptionRecord.

    -
  • This method is used to calculate the platform fee for a subscription. +

  • This method is used to calculate the platform fee for a subscription. The method returns the platform fee as a number.

    Returns Promise<number>

    A promise that resolves to a number representing the platform fee.

    -
  • Checks if a given address is a subscriber.

    Parameters

    • subscriberAddress: {
          subscriberAddress: string;
      }

      The address of the potential subscriber.

      • subscriberAddress: string

    Returns Promise<boolean>

    • A promise that resolves to a boolean indicating whether the address is a subscriber.
    -
  • This method is used to transfer a subscription from one subscriber to another. +

  • This method is used to transfer a subscription from one subscriber to another. It takes an old subscriber, a new subscriber address, and a subscription ID as arguments and returns a promise that resolves to an object containing the transaction ID.

    Parameters

    • __namedParameters: {
          newSubscriberAddress: string;
          oldSubscriber: TransactionSignerAccount;
          subscriptionID: number;
      }
      • newSubscriberAddress: string
      • oldSubscriber: TransactionSignerAccount
      • subscriptionID: number

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to update the lifecycle state of the application. +

  • This method is used to update the lifecycle state of the application. The method returns the transaction ID.

    Parameters

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method initializes a SubtopiaClient instance. It retrieves the product's global state, validates it, and instantiates a new SubtopiaClient.

    Parameters

    • __namedParameters: {
          algodClient: default;
          creator: TransactionSignerAccount;
          productID: number;
          registryID: number;
          timeout?: number;
      }
      • algodClient: default
      • creator: TransactionSignerAccount
      • productID: number
      • registryID: number
      • Optional timeout?: number

    Returns Promise<SubtopiaClient>

    A promise that resolves to a SubtopiaClient instance.

    Example

    import { SubtopiaClient } from "@algorand/subtopia";

    const subtopiaClient = await SubtopiaClient.init({
    algodClient: algodClient,
    productID: productID,
    creator: creator
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/SubtopiaRegistryClient.html b/classes/SubtopiaRegistryClient.html index 47590e1..f659d4d 100644 --- a/classes/SubtopiaRegistryClient.html +++ b/classes/SubtopiaRegistryClient.html @@ -1,6 +1,6 @@ SubtopiaRegistryClient | subtopia-js

Class SubtopiaRegistryClient

SubtopiaRegistryClient is a class that provides methods to interact with the Subtopia Registry contract. It provides methods to create, update and delete products and lockers in the registry.

-

Hierarchy

  • SubtopiaRegistryClient

Constructors

Constructors

Properties

Constructors

  • Parameters

    • __namedParameters: {
          algodClient: default;
          appAddress: string;
          appID: number;
          appSpec: ApplicationSpec;
          creator: TransactionSignerAccount;
          oracleID: number;
          timeout: number;
          version: string;
      }
      • algodClient: default
      • appAddress: string
      • appID: number
      • appSpec: ApplicationSpec
      • creator: TransactionSignerAccount
      • oracleID: number
      • timeout: number
      • version: string

    Returns SubtopiaRegistryClient

Properties

algodClient: default
appAddress: string
appID: number
creator: TransactionSignerAccount
oracleID: number
timeout: number
version: string

Methods

  • This method is used to create a new locker. +

Constructors

  • Parameters

    • __namedParameters: {
          algodClient: default;
          appAddress: string;
          appID: number;
          appSpec: ApplicationSpec;
          creator: TransactionSignerAccount;
          oracleID: number;
          timeout: number;
          version: string;
      }
      • algodClient: default
      • appAddress: string
      • appID: number
      • appSpec: ApplicationSpec
      • creator: TransactionSignerAccount
      • oracleID: number
      • timeout: number
      • version: string

    Returns SubtopiaRegistryClient

Properties

algodClient: default
appAddress: string
appID: number
creator: TransactionSignerAccount
oracleID: number
timeout: number
version: string

Methods

  • This method is used to create a new locker. The locker creation fee is calculated and paid by the creator. The method returns the transaction ID and the locker ID.

    Parameters

    • __namedParameters: {
          creator: TransactionSignerAccount;
          lockerType: LockerType;
      }
      • creator: TransactionSignerAccount
      • lockerType: LockerType

    Returns Promise<{
        lockerID: number;
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID and the locker ID.

    -
  • This method is used to create a new product. +

  • This method is used to create a new product. The method returns the transaction ID and the product ID.

    Parameters

    • __namedParameters: {
          coinID?: number;
          imageUrl?: string;
          lockerID: number;
          maxSubs?: number;
          parseWholeUnits?: boolean;
          price: number;
          productName: string;
          subType?: SubscriptionType;
          subscriptionName: string;
          unitName?: string;
      }
      • Optional coinID?: number
      • Optional imageUrl?: string
      • lockerID: number
      • Optional maxSubs?: number
      • Optional parseWholeUnits?: boolean
      • price: number
      • productName: string
      • Optional subType?: SubscriptionType
      • subscriptionName: string
      • Optional unitName?: string

    Returns Promise<{
        productID: number;
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID and the product ID.

    -
  • This method is used to delete a product. The method returns the transaction ID.

    Parameters

    • __namedParameters: {
          lockerID: number;
          productID: number;
      }
      • lockerID: number
      • productID: number

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • This method is used to calculate the locker creation fee. The fee is calculated by adding the minimum application creation member, the locker creation member, and the registry locker box creation member.

    Parameters

    • creatorAddress: string

      The address of the creator.

    Returns number

    The locker creation fee.

    -
  • This method is used to calculate the locker transfer fee. The fee is calculated by adding the minimum application opt-in member, and if the coinID is provided, the minimum ASA opt-in member. If the locker is new, the locker creation fee is also added.

    @@ -44,26 +44,26 @@
  • isNewLocker: boolean

    Whether the locker is new.

  • coinID: number

    The ID of the coin.

Returns number

The locker transfer fee.

-
  • This method is used to get the latest available locker contract version. Can be used to check if the current locker instance is up to date.

    Returns Promise<string>

    A promise that resolves to the locker version.

    -
  • This method is used to calculate the product creation fee. The fee is calculated based on the minimum balance requirements for creating and opting into an application, and the minimum balance requirement for creating a product. If a coinID is provided, the minimum balance requirement for opting into an ASA is also added to the fee.

    Parameters

    • coinID: number = 0

      The ID of the coin. If provided, the minimum balance requirement for opting into an ASA is added to the fee.

    Returns Promise<number>

    A promise that resolves to the product creation fee in microAlgos.

    -
  • This method is used to calculate the product creation platform fee. The fee is always returns in microAlgos equivalent to the current price of Algo in cents.

    Returns Promise<number>

    A promise that resolves to the product creation platform fee in microAlgos.

    -
  • This method is used to get the latest available product contract version. Can be used to check if the current product instance is up to date.

    Returns Promise<string>

    A promise that resolves to the product version.

    -
  • This method is used to transfer a product from one owner to another. +

  • This method is used to transfer a product from one owner to another. The method returns the transaction ID of the transfer.

    Parameters

    • __namedParameters: {
          newOwnerAddress: string;
          productID: number;
      }
      • newOwnerAddress: string
      • productID: number

    Returns Promise<{
        txID: string;
    }>

    A promise that resolves to an object containing the transaction ID.

    -
  • Parameters

    • __namedParameters: {
          algodClient: default;
          lockerType: LockerType;
          ownerAddress: string;
          registryID: number;
      }
      • algodClient: default
      • lockerType: LockerType
      • ownerAddress: string
      • registryID: number

    Returns Promise<null | number>

  • Parameters

    • __namedParameters: {
          algodClient: default;
          lockerType: LockerType;
          ownerAddress: string;
          registryID: number;
      }
      • algodClient: default
      • lockerType: LockerType
      • ownerAddress: string
      • registryID: number

    Returns Promise<null | number>

  • Initializes a new instance of the SubtopiaRegistryClient class with the specified parameters.

    Parameters

    • __namedParameters: {
          algodClient: default;
          chainType: ChainType;
          creator: TransactionSignerAccount;
          registryID?: number;
          timeout?: number;
      }
      • algodClient: default
      • chainType: ChainType
      • creator: TransactionSignerAccount
      • Optional registryID?: number
      • Optional timeout?: number

    Returns Promise<SubtopiaRegistryClient>

    A new instance of the SubtopiaRegistryClient class with the specified parameters.

    Example

    import { ChainType, SubtopiaRegistryClient } from "subtopia-js-sdk";

    const registryClient = await SubtopiaRegistryClient.init({
    algodClient: algodClient,
    creator: creator,
    chainType: ChainType.TESTNET
    });
    -

Generated using TypeDoc

\ No newline at end of file +

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/ChainType.html b/enums/ChainType.html index f36c655..bc6f52a 100644 --- a/enums/ChainType.html +++ b/enums/ChainType.html @@ -1,5 +1,5 @@ ChainType | subtopia-js

Enumeration ChainType

Enum for blockchain types.

-

Enumeration Members

Enumeration Members

Enumeration Members

LOCALNET: "localnet"
MAINNET: "mainnet"
TESTNET: "testnet"

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

LOCALNET: "localnet"
MAINNET: "mainnet"
TESTNET: "testnet"

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/DiscountType.html b/enums/DiscountType.html index 4966418..2786d95 100644 --- a/enums/DiscountType.html +++ b/enums/DiscountType.html @@ -1,4 +1,4 @@ DiscountType | subtopia-js

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

FIXED: 1
PERCENTAGE: 0

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/Duration.html b/enums/Duration.html index 63543cf..5ca2c06 100644 --- a/enums/Duration.html +++ b/enums/Duration.html @@ -1,7 +1,7 @@ Duration | subtopia-js

Enumeration Duration

Enum for duration types.

-

Enumeration Members

Enumeration Members

ANNUAL: 31536000
MONTH: 2592000
QUARTER: 7776000
SEMI_ANNUAL: 15552000
UNLIMITED: 0

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

ANNUAL: 31536000
MONTH: 2592000
QUARTER: 7776000
SEMI_ANNUAL: 15552000
UNLIMITED: 0

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/LifecycleState.html b/enums/LifecycleState.html index c468e6f..a9d3bd5 100644 --- a/enums/LifecycleState.html +++ b/enums/LifecycleState.html @@ -1,4 +1,4 @@ LifecycleState | subtopia-js

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

DISABLED: 1
ENABLED: 0

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/LockerType.html b/enums/LockerType.html index 6316441..a2bc5b2 100644 --- a/enums/LockerType.html +++ b/enums/LockerType.html @@ -1,4 +1,4 @@ LockerType | subtopia-js

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

CREATOR: 0
USER: 1

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/PriceNormalizationType.html b/enums/PriceNormalizationType.html index e506aab..9ec85e6 100644 --- a/enums/PriceNormalizationType.html +++ b/enums/PriceNormalizationType.html @@ -1,4 +1,4 @@ PriceNormalizationType | subtopia-js

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

PRETTY: 1
RAW: 0

Generated using TypeDoc

\ No newline at end of file diff --git a/enums/SubscriptionType.html b/enums/SubscriptionType.html index 7d0a35c..c01eda0 100644 --- a/enums/SubscriptionType.html +++ b/enums/SubscriptionType.html @@ -1,4 +1,4 @@ SubscriptionType | subtopia-js

Generated using TypeDoc

\ No newline at end of file +

Enumeration Members

TIME_BASED: 1
UNLIMITED: 0

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/SUBTOPIA_REGISTRY_ID.html b/functions/SUBTOPIA_REGISTRY_ID.html index be55495..9f5b13d 100644 --- a/functions/SUBTOPIA_REGISTRY_ID.html +++ b/functions/SUBTOPIA_REGISTRY_ID.html @@ -1 +1 @@ -SUBTOPIA_REGISTRY_ID | subtopia-js

Function SUBTOPIA_REGISTRY_ID

Generated using TypeDoc

\ No newline at end of file +SUBTOPIA_REGISTRY_ID | subtopia-js

Function SUBTOPIA_REGISTRY_ID

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/durationToMonths.html b/functions/durationToMonths.html index cd20d32..c14c03c 100644 --- a/functions/durationToMonths.html +++ b/functions/durationToMonths.html @@ -1 +1 @@ -durationToMonths | subtopia-js

Function durationToMonths

Generated using TypeDoc

\ No newline at end of file +durationToMonths | subtopia-js

Function durationToMonths

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/getLockerBoxPrefix.html b/functions/getLockerBoxPrefix.html index db471bd..15138f8 100644 --- a/functions/getLockerBoxPrefix.html +++ b/functions/getLockerBoxPrefix.html @@ -1,7 +1,7 @@ -getLockerBoxPrefix | subtopia-js

Function getLockerBoxPrefix

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/normalizePrice.html b/functions/normalizePrice.html index fea3594..1d4d766 100644 --- a/functions/normalizePrice.html +++ b/functions/normalizePrice.html @@ -1,4 +1,4 @@ -normalizePrice | subtopia-js

Function normalizePrice

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/optInAsset.html b/functions/optInAsset.html index 56727f5..14a1041 100644 --- a/functions/optInAsset.html +++ b/functions/optInAsset.html @@ -1 +1 @@ -optInAsset | subtopia-js

Function optInAsset

  • Parameters

    • __namedParameters: {
          account: TransactionSignerAccount;
          assetID: number;
          client: default;
          timeout?: number;
      }
      • account: TransactionSignerAccount
      • assetID: number
      • client: default
      • Optional timeout?: number

    Returns Promise<{
        confirmedRound: number;
        methodResults: SdkABIResult[];
        txIDs: string[];
    }>

Generated using TypeDoc

\ No newline at end of file +optInAsset | subtopia-js

Function optInAsset

  • Parameters

    • __namedParameters: {
          account: TransactionSignerAccount;
          assetID: number;
          client: default;
          timeout?: number;
      }
      • account: TransactionSignerAccount
      • assetID: number
      • client: default
      • Optional timeout?: number

    Returns Promise<{
        confirmedRound: number;
        methodResults: SdkABIResult[];
        txIDs: string[];
    }>

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/optOutAsset.html b/functions/optOutAsset.html index a64a40b..556d3e2 100644 --- a/functions/optOutAsset.html +++ b/functions/optOutAsset.html @@ -1 +1 @@ -optOutAsset | subtopia-js

Function optOutAsset

  • Parameters

    • __namedParameters: {
          account: TransactionSignerAccount;
          assetID: number;
          client: default;
          timeout?: number;
      }
      • account: TransactionSignerAccount
      • assetID: number
      • client: default
      • Optional timeout?: number

    Returns Promise<{
        confirmedRound: number;
        methodResults: SdkABIResult[];
        txIDs: string[];
    }>

Generated using TypeDoc

\ No newline at end of file +optOutAsset | subtopia-js

Function optOutAsset

  • Parameters

    • __namedParameters: {
          account: TransactionSignerAccount;
          assetID: number;
          client: default;
          timeout?: number;
      }
      • account: TransactionSignerAccount
      • assetID: number
      • client: default
      • Optional timeout?: number

    Returns Promise<{
        confirmedRound: number;
        methodResults: SdkABIResult[];
        txIDs: string[];
    }>

Generated using TypeDoc

\ No newline at end of file diff --git a/index.html b/index.html index 79235de..f22be3b 100644 --- a/index.html +++ b/index.html @@ -25,19 +25,19 @@

Import the package:

import { SubtopiaClient, SubtopiaRegistryClient } from "subtopia-js";
 

🛠️ Usage

Example snippets of using the Subtopia JS SDK.

-

Subscriptions

Purchasing a subscription:

// ... your code

const subtopiaClient = await SubtopiaClient.init({
algodClient: PUT_ALGOD_INSTANCE_HERE,
productID: PUT_PRODUCT_ID_HERE,
creator: { address: { PUT_WALLET_ADDRESS }, signer: { PUT_WALLET_SIGNER } },
});

const response = await subtopiaClient.subscribe(
{ address: { PUT_WALLET_ADDRESS }, signer: { PUT_WALLET_SIGNER } },
{ PUT_DURATION_HERE } // pick duration from Duration enum. If there is a discount available for this duration, it will be auto applied.
);

console.log(response.txID); // response is of type string

// ... rest of your code +

Subscriptions

Purchasing a subscription:

// ... your code

const subtopiaClient = await SubtopiaClient.init({
algodClient: PUT_ALGOD_INSTANCE_HERE,
productID: PUT_PRODUCT_ID_HERE,
creator: { addr: PUT_WALLET_ADDRESS, signer: PUT_WALLET_SIGNER },
});

const response = await subtopiaClient.createSubscription(
{ addr: PUT_WALLET_ADDRESS, signer: PUT_WALLET_SIGNER },
PUT_DURATION_HERE // pick duration from Duration enum. If there is a discount available for this duration, it will be auto applied.
);

console.log(response.txID); // response is of type string

// ... rest of your code
-

Subscription lookup:

// ... your code
const subscriptionRecord = await subtopiaClient.getSubscription({
subscriberAddress: { PUT_SUBSCRIBER_ADDRESS },
});

// SubscriptionRecord (throws Error if not subscribed)
console.log(subscriptionRecord);
// ... rest of your code +

Subscription lookup:

// ... your code
const subscriptionRecord = await subtopiaClient.getSubscription({
subscriberAddress: PUT_SUBSCRIBER_ADDRESS,
});

// SubscriptionRecord (throws Error if not subscribed)
console.log(subscriptionRecord);
// ... rest of your code
-

Unsubscribing:

// ... your code
const deleteResult = await subtopiaClient.unsubscribe({
subscriber: {
address: { PUT_SUBSCRIBER_ADDRESS },
signer: { PUT_SUBSCRIBER_SIGNER },
},
});

// Transaction ID of the unsubscribe transaction
console.log(deleteResult.txID);
// ... your code +

Unsubscribing:

// ... your code
const deleteResult = await subtopiaClient.unsubscribe({
subscriber: {
addr: PUT_SUBSCRIBER_ADDRESS,
signer: PUT_SUBSCRIBER_SIGNER,
},
});

// Transaction ID of the unsubscribe transaction
console.log(deleteResult.txID);
// ... your code
-

Transfering subscription:

// ... your code
const transferResult = await subtopiaClient.transferSubscription({
oldSubscriber: {
address: { PUT_OLD_SUBSCRIBER_ADDRESS },
signer: { PUT_OLD_SUBSCRIBER_SIGNER },
},
newSubscriberAddress: { PUT_NEW_SUBSCRIBER_ADDRESS },
});

// Transaction ID of the transfer transaction
console.log(transferResult.txID);
// ... your code +

Transfering subscription:

// ... your code
const transferResult = await subtopiaClient.transferSubscription({
oldSubscriber: {
addr: PUT_OLD_SUBSCRIBER_ADDRESS,
signer: PUT_OLD_SUBSCRIBER_SIGNER,
},
newSubscriberAddress: PUT_NEW_SUBSCRIBER_ADDRESS,
subscriptionID: PUT_SUBSCRIPTION_ID,
});

// Transaction ID of the transfer transaction
console.log(transferResult.txID);
// ... your code
-

Discounts

Creating a discount:

// ... your code

const subtopiaRegistryClient = await SubtopiaRegistryClient.init({
algodClient = PUT_ALGOD_INSTANCE_HERE,
creator = { address: { PUT_WALLET_ADDRESS }, signer: { PUT_WALLET_SIGNER } },
chainType = PUT_CHAIN_TYPE_HERE,
});

const discount = await subtopiaRegistryClient.createDiscount({
productID: { PUT_PRODUCT_ID_HERE }, // number - the ID of the Product instance you want to create a discount for
discount: {
duration: { PUT_DURATION_HERE }, // number - the type of duration to apply. Also serves as static id for the discount.
discountType: { PUT_DISCOUNT_TYPE_HERE }, // number - the type of discount to apply. FIXED or PERCENTAGE
discountValue: { PUT_DISCOUNT_VALUE_HERE }, // number - the discount to be deducted from the subscription price
expiresIn: { PUT_EXPIRATION_TIME_HERE }, // (Optional) Set 0 for discount to never expire. Else set number of seconds to append to unix timestamp at time of creation.
}, // number - the discount in percent
});

console.log(discount.txID); // response is of type string

// ... rest of your code +

Discounts

Creating a discount:

// ... your code

const subtopiaRegistryClient = await SubtopiaRegistryClient.init({
algodClient: PUT_ALGOD_INSTANCE_HERE,
creator: { addr: PUT_WALLET_ADDRESS, signer: PUT_WALLET_SIGNER },
chainType: PUT_CHAIN_TYPE_HERE,
});

const discount = await subtopiaRegistryClient.createDiscount({
productID: PUT_PRODUCT_ID_HERE, // number - the ID of the Product instance you want to create a discount for
duration: PUT_DURATION_HERE, // number - the type of duration to apply. Also serves as static id for the discount.
discountType: PUT_DISCOUNT_TYPE_HERE, // number - the type of discount to apply. FIXED or PERCENTAGE
discountValue: PUT_DISCOUNT_VALUE_HERE, // number - the discount to be deducted from the subscription price
expiresIn: PUT_EXPIRATION_TIME_HERE, // (Optional) Set 0 for discount to never expire. Else set number of seconds to append to unix timestamp at time of creation.
});

console.log(discount.txID); // response is of type string

// ... rest of your code
-

Discount lookup:

// ... your code

const discount = await subtopiaRegistryClient.getDiscount(
productID: { PUT_PRODUCT_ID_HERE },
duration: { PUT_DURATION_HERE },
);

// DiscountRecord (throws Error if not found)
console.log(discount);
// ... rest of your code +

Discount lookup:

// ... your code

const discount = await subtopiaRegistryClient.getDiscount(
productID: PUT_PRODUCT_ID_HERE,
duration: PUT_DURATION_HERE,
);

// DiscountRecord (throws Error if not found)
console.log(discount);
// ... rest of your code
-

Deleting a discount:

// ... your code

const deleteResult = await subtopiaRegistryClient.deleteDiscount({
productID: { PUT_PRODUCT_ID },
duration: { PUT_DURATION_HERE },
});

// Transaction ID of the delete discount transaction
console.log(deleteResult.txID);
// ... your code +

Deleting a discount:

// ... your code

const deleteResult = await subtopiaRegistryClient.deleteDiscount({
productID: PUT_PRODUCT_ID,
duration: PUT_DURATION_HERE,
});

// Transaction ID of the delete discount transaction
console.log(deleteResult.txID);
// ... your code

⭐️ Stargazers

Special thanks to everyone who starred the repository ❤️

Stargazers repo roster for @subtopia-algo/subtopia-js

diff --git a/interfaces/ApplicationSpec.html b/interfaces/ApplicationSpec.html index 1c0145d..db64195 100644 --- a/interfaces/ApplicationSpec.html +++ b/interfaces/ApplicationSpec.html @@ -1,8 +1,8 @@ ApplicationSpec | subtopia-js

Interface ApplicationSpec

Interface for the application specification.

-

Hierarchy

  • ApplicationSpec

Properties

interface ApplicationSpec {
    approval: Uint8Array;
    clear: Uint8Array;
    globalNumByteSlice: number;
    globalNumUint: number;
    localNumByteSlice: number;
    localNumUint: number;
}

Properties

approval: Uint8Array
clear: Uint8Array
globalNumByteSlice: number
globalNumUint: number
localNumByteSlice: number
localNumUint: number

Generated using TypeDoc

\ No newline at end of file +

Properties

approval: Uint8Array
clear: Uint8Array
globalNumByteSlice: number
globalNumUint: number
localNumByteSlice: number
localNumUint: number

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/AssetMetadata.html b/interfaces/AssetMetadata.html index 769c2a1..635f4e8 100644 --- a/interfaces/AssetMetadata.html +++ b/interfaces/AssetMetadata.html @@ -1,7 +1,7 @@ AssetMetadata | subtopia-js

Interface AssetMetadata

Interface for the asset metadata.

-

Hierarchy

  • AssetMetadata

Properties

interface AssetMetadata {
    creator: string;
    decimals: number;
    index: number;
    name: string;
    unitName: string;
}

Properties

creator: string
decimals: number
index: number
name: string
unitName: string

Generated using TypeDoc

\ No newline at end of file +

Properties

creator: string
decimals: number
index: number
name: string
unitName: string

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/BaseDiscountRecord.html b/interfaces/BaseDiscountRecord.html index fc02d72..65888bf 100644 --- a/interfaces/BaseDiscountRecord.html +++ b/interfaces/BaseDiscountRecord.html @@ -1,5 +1,5 @@ BaseDiscountRecord | subtopia-js

Generated using TypeDoc

\ No newline at end of file +

Properties

discountType: DiscountType
discountValue: number
duration: Duration

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/DiscountMetadata.html b/interfaces/DiscountMetadata.html index 15534d4..29ff34e 100644 --- a/interfaces/DiscountMetadata.html +++ b/interfaces/DiscountMetadata.html @@ -1,6 +1,6 @@ DiscountMetadata | subtopia-js

Interface DiscountMetadata

Interface for the discount metadata.

-

Hierarchy

Properties

interface DiscountMetadata {
    discountType: DiscountType;
    discountValue: number;
    duration: Duration;
    expiresIn?: number;
}

Hierarchy

Properties

discountType: DiscountType
discountValue: number
duration: Duration
expiresIn?: number

Generated using TypeDoc

\ No newline at end of file +

Properties

discountType: DiscountType
discountValue: number
duration: Duration
expiresIn?: number

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/DiscountRecord.html b/interfaces/DiscountRecord.html index 8def4fd..874e1d2 100644 --- a/interfaces/DiscountRecord.html +++ b/interfaces/DiscountRecord.html @@ -1,8 +1,8 @@ DiscountRecord | subtopia-js

Interface DiscountRecord

Interface for the discount record.

-

Hierarchy

Properties

interface DiscountRecord {
    createdAt: number;
    discountType: DiscountType;
    discountValue: number;
    duration: Duration;
    expiresAt: null | number;
    totalClaims: number;
}

Hierarchy

Properties

createdAt: number
discountType: DiscountType
discountValue: number
duration: Duration
expiresAt: null | number
totalClaims: number

Generated using TypeDoc

\ No newline at end of file +

Properties

createdAt: number
discountType: DiscountType
discountValue: number
duration: Duration
expiresAt: null | number
totalClaims: number

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/ProductState.html b/interfaces/ProductState.html index 918f3fa..2acc9c8 100644 --- a/interfaces/ProductState.html +++ b/interfaces/ProductState.html @@ -1,5 +1,5 @@ ProductState | subtopia-js

Interface ProductState

Interface for the product state.

-

Hierarchy

  • ProductGlobalState
    • ProductState

Properties

interface ProductState {
    coinID: number;
    createdAt: number;
    discounts: DiscountRecord[];
    imageURL: string;
    lifecycle: number;
    manager: string;
    maxSubs: number;
    oracleID: number;
    price: number;
    productName: string;
    subType: SubscriptionType;
    subscriptionName: string;
    totalSubs: number;
    unitName: string;
}

Hierarchy

  • ProductGlobalState
    • ProductState

Properties

coinID: number
createdAt: number
discounts: DiscountRecord[]
imageURL: string
lifecycle: number
manager: string
maxSubs: number
oracleID: number
price: number
productName: string
subscriptionName: string
totalSubs: number
unitName: string

Generated using TypeDoc

\ No newline at end of file +

Properties

coinID: number
createdAt: number
discounts: DiscountRecord[]
imageURL: string
lifecycle: number
manager: string
maxSubs: number
oracleID: number
price: number
productName: string
subscriptionName: string
totalSubs: number
unitName: string

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/SubscriptionRecord.html b/interfaces/SubscriptionRecord.html index afc195d..f6f81f8 100644 --- a/interfaces/SubscriptionRecord.html +++ b/interfaces/SubscriptionRecord.html @@ -1,7 +1,7 @@ SubscriptionRecord | subtopia-js

Interface SubscriptionRecord

Interface for the subscription record.

-

Hierarchy

  • SubscriptionRecord

Properties

interface SubscriptionRecord {
    createdAt: number;
    duration: Duration;
    expiresAt: null | number;
    subID: number;
    subType: SubscriptionType;
}

Properties

createdAt: number
duration: Duration
expiresAt: null | number
subID: number

Generated using TypeDoc

\ No newline at end of file +

Properties

createdAt: number
duration: Duration
expiresAt: null | number
subID: number

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/DEFAULT_TXN_SIGN_TIMEOUT_SECONDS.html b/variables/DEFAULT_TXN_SIGN_TIMEOUT_SECONDS.html index 27838e6..6701069 100644 --- a/variables/DEFAULT_TXN_SIGN_TIMEOUT_SECONDS.html +++ b/variables/DEFAULT_TXN_SIGN_TIMEOUT_SECONDS.html @@ -1 +1 @@ -DEFAULT_TXN_SIGN_TIMEOUT_SECONDS | subtopia-js

Generated using TypeDoc

\ No newline at end of file +DEFAULT_TXN_SIGN_TIMEOUT_SECONDS | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/LOCKER_APPROVAL_KEY.html b/variables/LOCKER_APPROVAL_KEY.html index 4cc0924..25f35ea 100644 --- a/variables/LOCKER_APPROVAL_KEY.html +++ b/variables/LOCKER_APPROVAL_KEY.html @@ -1 +1 @@ -LOCKER_APPROVAL_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file +LOCKER_APPROVAL_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/LOCKER_CLEAR_KEY.html b/variables/LOCKER_CLEAR_KEY.html index 95a60ef..83417ba 100644 --- a/variables/LOCKER_CLEAR_KEY.html +++ b/variables/LOCKER_CLEAR_KEY.html @@ -1 +1 @@ -LOCKER_CLEAR_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file +LOCKER_CLEAR_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/LOCKER_VERSION.html b/variables/LOCKER_VERSION.html index 76fbefa..a623ced 100644 --- a/variables/LOCKER_VERSION.html +++ b/variables/LOCKER_VERSION.html @@ -1 +1 @@ -LOCKER_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file +LOCKER_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/LOCKER_VERSION_KEY.html b/variables/LOCKER_VERSION_KEY.html index c1e3dbc..f9019d9 100644 --- a/variables/LOCKER_VERSION_KEY.html +++ b/variables/LOCKER_VERSION_KEY.html @@ -1 +1 @@ -LOCKER_VERSION_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file +LOCKER_VERSION_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/ORACLE_VERSION.html b/variables/ORACLE_VERSION.html index 6d1471a..50a2e7f 100644 --- a/variables/ORACLE_VERSION.html +++ b/variables/ORACLE_VERSION.html @@ -1 +1 @@ -ORACLE_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file +ORACLE_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/PRODUCT_APPROVAL_KEY.html b/variables/PRODUCT_APPROVAL_KEY.html index f26c29a..331d8f0 100644 --- a/variables/PRODUCT_APPROVAL_KEY.html +++ b/variables/PRODUCT_APPROVAL_KEY.html @@ -1 +1 @@ -PRODUCT_APPROVAL_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file +PRODUCT_APPROVAL_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/PRODUCT_CLEAR_KEY.html b/variables/PRODUCT_CLEAR_KEY.html index eeeb63a..e57a516 100644 --- a/variables/PRODUCT_CLEAR_KEY.html +++ b/variables/PRODUCT_CLEAR_KEY.html @@ -1 +1 @@ -PRODUCT_CLEAR_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file +PRODUCT_CLEAR_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/PRODUCT_VERSION.html b/variables/PRODUCT_VERSION.html index 4ca35e1..c095e49 100644 --- a/variables/PRODUCT_VERSION.html +++ b/variables/PRODUCT_VERSION.html @@ -1 +1 @@ -PRODUCT_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file +PRODUCT_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/PRODUCT_VERSION_KEY.html b/variables/PRODUCT_VERSION_KEY.html index 7bbeb8f..7d8898d 100644 --- a/variables/PRODUCT_VERSION_KEY.html +++ b/variables/PRODUCT_VERSION_KEY.html @@ -1 +1 @@ -PRODUCT_VERSION_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file +PRODUCT_VERSION_KEY | subtopia-js

Generated using TypeDoc

\ No newline at end of file diff --git a/variables/REGISTRY_VERSION.html b/variables/REGISTRY_VERSION.html index 1630473..4876c49 100644 --- a/variables/REGISTRY_VERSION.html +++ b/variables/REGISTRY_VERSION.html @@ -1 +1 @@ -REGISTRY_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file +REGISTRY_VERSION | subtopia-js

Generated using TypeDoc

\ No newline at end of file