Options
All
  • Public
  • Public/Protected
  • All
Menu

@identity.com/solana-gateway-ts

Index

Type aliases

DeepPartial

DeepPartial<T>: {[ P in keyof T]: DeepPartial<T[P]> }

Type parameters

  • T

ProgramAccountResponse

ProgramAccountResponse: { account: AccountInfo<Buffer>; pubkey: PublicKey }

Type declaration

  • account: AccountInfo<Buffer>
  • pubkey: PublicKey

Variables

Const DEFAULT_DERIVATION_SEED

DEFAULT_DERIVATION_SEED: Buffer = ...

Const DEFAULT_SOLANA_RETRIES

DEFAULT_SOLANA_RETRIES: number = 3

Const GATEKEEPER_NONCE_SEED_STRING

GATEKEEPER_NONCE_SEED_STRING: "gatekeeper" = "gatekeeper"

Const GATEWAY_TOKEN_ACCOUNT_GATEKEEPER_NETWORK_FIELD_OFFSET

GATEWAY_TOKEN_ACCOUNT_GATEKEEPER_NETWORK_FIELD_OFFSET: 35 = 35

Const GATEWAY_TOKEN_ACCOUNT_OWNER_FIELD_OFFSET

GATEWAY_TOKEN_ACCOUNT_OWNER_FIELD_OFFSET: 2 = 2

Const GATEWAY_TOKEN_ADDRESS_SEED

GATEWAY_TOKEN_ADDRESS_SEED: "gateway" = "gateway"

Const PROGRAM_ID

PROGRAM_ID: PublicKey = ...

Const SOLANA_COMMITMENT

SOLANA_COMMITMENT: Commitment = "confirmed"

Const SOLANA_TIMEOUT_CONFIRMED

SOLANA_TIMEOUT_CONFIRMED: 7000 = 7000

Const SOLANA_TIMEOUT_FINALIZED

SOLANA_TIMEOUT_FINALIZED: 10000 = 10000

Const SOLANA_TIMEOUT_PROCESSED

SOLANA_TIMEOUT_PROCESSED: 3000 = 3000

Functions

addFeatureToNetwork

  • addFeatureToNetwork(payer: PublicKey, network: PublicKey, feature: NetworkFeature): Promise<TransactionInstruction>
  • Add a feature to an existing Gatekeeper Network. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • payer: PublicKey

      The payer of the transaction (used to pay rent into the gatekeeper account)

    • network: PublicKey

      The gatekeeper network that the account is being added to.

    • feature: NetworkFeature

      The NetworkFeature Enum value

    Returns Promise<TransactionInstruction>

addGatekeeper

  • addGatekeeper(payer: PublicKey, gatekeeperAccount: PublicKey, gatekeeperAuthority: PublicKey, network: PublicKey): TransactionInstruction
  • Add a gatekeeper to a gatekeeper network. Returns a Solana instruction that must be signed by the gatekeeper network authority.

    Parameters

    • payer: PublicKey

      The payer of the transaction (used to pay rent into the gatekeeper account)

    • gatekeeperAccount: PublicKey

      An uninitialised gatekeeper account PDA. The address must be derived via getGatekeeperAccountKeyFromGatekeeperAuthority()

    • gatekeeperAuthority: PublicKey

      The gatekeeper to add to the network

    • network: PublicKey

      The gatekeeper network that the account is being added to.

    Returns TransactionInstruction

burn

  • burn(gatewayTokenAccount: PublicKey, gatekeeperAuthority: PublicKey, gatekeeperAccount: PublicKey, recipient: PublicKey): TransactionInstruction
  • Burn a gateway token. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • gatewayTokenAccount: PublicKey

      The gateway token to burn

    • gatekeeperAuthority: PublicKey

      The gatekeeper burning the token (must be in the same network as the issuing gatekeeper)

    • gatekeeperAccount: PublicKey

      The account in the gatekeeper network of the gatekeeper revoking the token

    • recipient: PublicKey

      The account to receive the SOL from the burn

    Returns TransactionInstruction

Const dataToGatewayToken

expireToken

  • expireToken(gatewayTokenAccount: PublicKey, owner: PublicKey, gatekeeperNetwork: PublicKey): TransactionInstruction
  • For a gatekeeper network that supports it, create an expireToken instruction, that is to be signed by the gateway token owner.

    Parameters

    • gatewayTokenAccount: PublicKey
    • owner: PublicKey
    • gatekeeperNetwork: PublicKey

    Returns TransactionInstruction

Const featureExists

  • featureExists(connection: Connection, feature: NetworkFeature, network: PublicKey): Promise<boolean>
  • Return true if an address feature exists.

    Parameters

    • connection: Connection
    • feature: NetworkFeature

      The feature to check

    • network: PublicKey

      The gatekeeper network

    Returns Promise<boolean>

Const findGatewayToken

  • findGatewayToken(connection: Connection, owner: PublicKey, gatekeeperNetwork: PublicKey, includeRevoked?: boolean): Promise<null | GatewayToken>
  • Get a gateway token for the owner and network, if it exists.

    Parameters

    • connection: Connection

      A solana connection object

    • owner: PublicKey

      The token owner

    • gatekeeperNetwork: PublicKey

      The network to find a token for

    • includeRevoked: boolean = false

      If false (default), filter out revoked tokens

    Returns Promise<null | GatewayToken>

    Promise<GatewayToken | null> A gateway token, if one exists for the owner

Const findGatewayTokens

  • findGatewayTokens(connection: Connection, owner: undefined | PublicKey, gatekeeperNetwork: PublicKey, includeRevoked?: boolean, page?: number): Promise<GatewayToken[]>
  • Find all gateway tokens (optionally for a user) on a gatekeeper network, optionally filtering out revoked tokens.

    Warning - this uses the Solana getProgramAccounts RPC endpoint, which is inefficient and may be blocked by some RPC services.

    Parameters

    • connection: Connection

      A solana connection object

    • owner: undefined | PublicKey

      The token owner (optional)

    • gatekeeperNetwork: PublicKey

      The network to find a token for

    • includeRevoked: boolean = false

      If false (default), filter out revoked tokens

    • Optional page: number

      If a large number of tokens has been issued, the request to the RPC endpoint may time out. In this case, enable pagination by setting page variable Pagination is not supported in the RPC API per-se, but this approximates it by adding another filter on the first byte of the owner address. Each page requests the accounts that match that byte.

    Returns Promise<GatewayToken[]>

    All tokens for the owner

Const findGatewayTokensForOwnerAndNetwork

  • findGatewayTokensForOwnerAndNetwork(connection: Connection, owner: PublicKey, gatekeeperNetwork: PublicKey, includeRevoked?: boolean, offset?: number, page?: number): Promise<GatewayToken[]>
  • Finds all gateway tokens for a user by iterating through the index seed and requesting a page of addresses at a time.

    It assumes a small number of passes per GKN, so the page size by default is 5. Sorts the result by active status and expiry, so unexpired active passes appear first

    Parameters

    • connection: Connection
    • owner: PublicKey
    • gatekeeperNetwork: PublicKey
    • includeRevoked: boolean = false
    • offset: number = 0
    • page: number = 5

    Returns Promise<GatewayToken[]>

freeze

  • freeze(gatewayTokenAccount: PublicKey, gatekeeperAuthority: PublicKey, gatekeeperAccount: PublicKey): TransactionInstruction
  • Freeze a gateway token. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • gatewayTokenAccount: PublicKey

      The gateway token to freeze

    • gatekeeperAuthority: PublicKey

      The gatekeeper freezing the token (must be equal to the issuing gatekeeper)

    • gatekeeperAccount: PublicKey

      The account in the gatekeeper network of the gatekeeper freezing the token

    Returns TransactionInstruction

Const gatekeeperExists

  • gatekeeperExists(connection: Connection, gatekeeperAuthority: PublicKey, gatekeeperNetwork: PublicKey): Promise<boolean>
  • Returns whether or not a gatekeeper exists from a network and authority

    Parameters

    • connection: Connection

      A solana connection

    • gatekeeperAuthority: PublicKey

      The authority of the gatekeeper

    • gatekeeperNetwork: PublicKey

      The network of the gatekeeper

    Returns Promise<boolean>

Const getFeatureAccountAddress

  • getFeatureAccountAddress(feature: NetworkFeature, network: PublicKey): PublicKey
  • Derive the address of the feature PDA

    Parameters

    • feature: NetworkFeature

      The feature to set.

    • network: PublicKey

      The network

    Returns PublicKey

Const getGatekeeperAccountAddress

  • getGatekeeperAccountAddress(authority: PublicKey, network: PublicKey): PublicKey
  • Derive the address of the gatekeeper PDA for this gatekeeper

    Parameters

    • authority: PublicKey

      The gatekeeper

    • network: PublicKey

      The network

    Returns PublicKey

Const getGatewayToken

  • getGatewayToken(connection: Connection, gatewayTokenAddress: PublicKey): Promise<null | GatewayToken>
  • Lookup the gateway token at a given address

    Parameters

    • connection: Connection

      A solana connection object

    • gatewayTokenAddress: PublicKey

      The address of the gateway token

    Returns Promise<null | GatewayToken>

Const getGatewayTokenAddressForOwnerAndGatekeeperNetwork

  • getGatewayTokenAddressForOwnerAndGatekeeperNetwork(owner: PublicKey, gatekeeperNetwork: PublicKey, index?: number): PublicKey
  • Derive the address of the gateway token PDA for this owner address and optional seed.

    Parameters

    • owner: PublicKey

      The owner of the gateway token

    • gatekeeperNetwork: PublicKey

      The network of the gateway token

    • index: number = 0

      The index of the gateway token (default 0)

    Returns PublicKey

issue

  • issue(gatewayTokenAccount: PublicKey, payer: PublicKey, gatekeeperAccount: PublicKey, owner: PublicKey, gatekeeperAuthority: PublicKey, gatekeeperNetwork: PublicKey, seed?: Uint8Array, expireTime?: number): TransactionInstruction
  • Issue a gateway token to the owner publicKey. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • gatewayTokenAccount: PublicKey

      An uninitialised gateway token account PDA. The address must be derived via getGatewayTokenAddressForOwnerAndGatekeeperNetwork

    • payer: PublicKey

      The payer of the transaction (used to pay rent into the gatekeeper account).

    • gatekeeperAccount: PublicKey

      The account in the gatekeeper network of the gatekeeper issuing the token

    • owner: PublicKey

      The recipient of the token

    • gatekeeperAuthority: PublicKey

      The gatekeeper issuing the token

    • gatekeeperNetwork: PublicKey

      The network that the gatekeeper belongs to

    • Optional seed: Uint8Array

      An 8-byte seed array, used to add multiple tokens to the same owner. Must be unique to each token, if present

    • Optional expireTime: number

      The unix timestamp at which the token is no longer valid

    Returns TransactionInstruction

Const mapEnumToFeatureName

  • mapEnumToFeatureName(enumValue: string): string

Const numToBuffer

  • numToBuffer(num: number): Buffer
  • Converts a number to a buffer of U8 integers, for use in the gateway token address derivation as the seed value.

    Parameters

    • num: number

    Returns Buffer

Const onGatewayToken

  • onGatewayToken(connection: Connection, owner: PublicKey, gatekeeperNetwork: PublicKey, callback: (gatewayToken: GatewayToken) => void, commitment?: Commitment, seed?: number): number
  • Register a callback to be called whenever a gateway token is created or changes state

    Parameters

    • connection: Connection

      A solana connection object

    • owner: PublicKey

      The gateway token owner

    • gatekeeperNetwork: PublicKey
    • callback: (gatewayToken: GatewayToken) => void

      The callback to register

    • commitment: Commitment = ...

      The solana commitment level at which to register gateway token changes. Defaults to 'confirmed'

    • seed: number = 0

    Returns number

    The subscription id

Const onGatewayTokenChange

  • onGatewayTokenChange(connection: Connection, gatewayTokenAddress: PublicKey, callback: (gatewayToken: GatewayToken) => void, commitment?: Commitment): number
  • Register a callback to be called whenever a gateway token changes state

    Parameters

    • connection: Connection

      A solana connection object

    • gatewayTokenAddress: PublicKey

      The address of the gateway token

    • callback: (gatewayToken: GatewayToken) => void

      The callback to register

    • commitment: Commitment = ...

      The solana commitment level at which to register gateway token changes. Defaults to 'confirmed'

    Returns number

    The subscription id

Const removeAccountChangeListener

  • removeAccountChangeListener(connection: Connection, id: number): Promise<void>
  • Stops listening to gateway state changes

    Parameters

    • connection: Connection

      A solana connection object

    • id: number

      The subscription id to deregister

    Returns Promise<void>

removeFeatureFromNetwork

  • removeFeatureFromNetwork(payer: PublicKey, network: PublicKey, feature: NetworkFeature): Promise<TransactionInstruction>
  • Remove a feature to an existing Gatekeeper Network. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • payer: PublicKey

      The payer of the transaction (used to pay rent into the gatekeeper account)

    • network: PublicKey

      The gatekeeper network that the account is being added to.

    • feature: NetworkFeature

      The NetworkFeature Enum value

    Returns Promise<TransactionInstruction>

revoke

  • revoke(gatewayTokenAccount: PublicKey, gatekeeperAuthority: PublicKey, gatekeeperAccount: PublicKey): TransactionInstruction
  • Revoke a gateway token. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • gatewayTokenAccount: PublicKey

      The gateway token to revoke

    • gatekeeperAuthority: PublicKey

      The gatekeeper revoking the token (must be in the same network as the issuing gatekeeper)

    • gatekeeperAccount: PublicKey

      The account in the gatekeeper network of the gatekeeper revoking the token

    Returns TransactionInstruction

revokeGatekeeper

  • revokeGatekeeper(funds_to: PublicKey, gatekeeperAccount: PublicKey, gatekeeperAuthority: PublicKey, network: PublicKey): TransactionInstruction
  • Removes a gatekeeper from a gatekeeper network. Returns a Solana instruction that must be signed by the gatekeeper network authority.

    Parameters

    • funds_to: PublicKey

      The account the gatekeeper account's rent goes to

    • gatekeeperAccount: PublicKey

      The gatekeeper account PDA. The address must be derived via getGatekeeperAccountKeyFromGatekeeperAuthority()

    • gatekeeperAuthority: PublicKey

      The gatekeeper to remove from the network

    • network: PublicKey

      The gatekeeper network that the account is being removed from.

    Returns TransactionInstruction

unfreeze

  • unfreeze(gatewayTokenAccount: PublicKey, gatekeeperAuthority: PublicKey, gatekeeperAccount: PublicKey): TransactionInstruction
  • Unfreeze a gateway token. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • gatewayTokenAccount: PublicKey

      The gateway token to unfreeze

    • gatekeeperAuthority: PublicKey

      The gatekeeper unfreezing the token (must be equal to the issuing gatekeeper)

    • gatekeeperAccount: PublicKey

      The account in the gatekeeper network of the gatekeeper unfreezing the token

    Returns TransactionInstruction

updateExpiry

  • updateExpiry(gatewayTokenAccount: PublicKey, gatekeeperAuthority: PublicKey, gatekeeperAccount: PublicKey, expireTime: number): TransactionInstruction
  • Update the expiry time of a gateway token. Returns a Solana instruction that must be signed by the gatekeeper authority.

    Parameters

    • gatewayTokenAccount: PublicKey

      The gateway token to be updated (must have an expiry time)

    • gatekeeperAuthority: PublicKey

      The gatekeeper (must be equal to the issuing gatekeeper)

    • gatekeeperAccount: PublicKey

      The account in the gatekeeper network of the gatekeeper

    • expireTime: number

      The new expiry time

    Returns TransactionInstruction

Generated using TypeDoc