Documentation
¶
Index ¶
- Constants
- Variables
- func AllowUpdates(b bool)
- func Clone(scid, endpoint string) (err error)
- func CloneAtCommit(scid, txid, endpoint string) (err error)
- func Compress(data []byte, compression string) (result string, err error)
- func ConstructFromShards(docShards [][]byte, recreate, basePath, compression string) (err error)
- func CreateShardFiles(filePath, compression string, content []byte) (err error)
- func Decompress(data []byte, compression string) (result []byte, err error)
- func DeleteVar(wallet *walletapi.Wallet_Disk, scid, key string) (txid string, err error)
- func EqualSmartContracts(c, v string) (contract dvm.SmartContract, err error)
- func FindOpenPort() (server *http.Server, found bool)
- func FormatSmartContract(sc dvm.SmartContract, code string) (formatted string, err error)
- func GetClonePath() string
- func GetCodeSizeInKB(code string) float64
- func GetDefaultNetworkAddress() (network, destination string)
- func GetGasEstimate(wallet *walletapi.Wallet_Disk, ringsize uint64, transfers []rpc.Transfer, ...) (gasFees uint64, err error)
- func GetPath() string
- func GetSmartContractFuncNames(code string) (names []string)
- func GetTotalShards(data []byte) (totalShards int, fileSize int64)
- func HasServer(name string) bool
- func Installer(wallet *walletapi.Wallet_Disk, ringsize uint64, params interface{}) (txid string, err error)
- func IsAcceptedLanguage(language string) bool
- func IsCompressedExt(ext string) bool
- func KeyExists(scid, key, endpoint string) (variable string, exists bool, err error)
- func KeyPrefixExists(scid, prefix, endpoint string) (key, variable string, exists bool, err error)
- func MaxServers() int
- func NewDeleteVarArgs(scid, key string) (args rpc.Arguments, err error)
- func NewInstallArgs(params interface{}) (args rpc.Arguments, err error)
- func NewModTag(tags []string) (modTag string)
- func NewRateArgs(scid string, rating uint64) (args rpc.Arguments, err error)
- func NewSetVarArgs(scid, key, value string) (args rpc.Arguments, err error)
- func NewUpdateArgs(params interface{}) (args rpc.Arguments, err error)
- func OpenTELALink(telaLink, endpoint string) (link string, err error)
- func ParseDocType(fileName string) (language string)
- func ParseHeaders(code string, headerType interface{}) (formatted string, err error)
- func ParseINDEXForDOCs(code string) (scids []string, err error)
- func ParseSignature(input []byte) (address, c, s string, err error)
- func ParseTELALink(telaLink string) (target string, args []string, err error)
- func PortStart() int
- func Rate(wallet *walletapi.Wallet_Disk, scid string, rating uint64) (txid string, err error)
- func ServeAtCommit(scid, txid, endpoint string) (link string, err error)
- func ServeTELA(scid, endpoint string) (link string, err error)
- func SetMaxServers(i int)
- func SetPortStart(port int) (err error)
- func SetShardPath(path string) (err error)
- func SetVar(wallet *walletapi.Wallet_Disk, scid, key, value string) (txid string, err error)
- func ShutdownServer(name string)
- func ShutdownTELA()
- func Transfer(wallet *walletapi.Wallet_Disk, ringsize uint64, transfers []rpc.Transfer, ...) (txid string, err error)
- func TrimCompressedExt(fileName string) string
- func Updater(wallet *walletapi.Wallet_Disk, params interface{}) (txid string, err error)
- func UpdatesAllowed() bool
- func ValidateImageURL(imageURL, endpoint string) (svgCode string, err error)
- type Cloning
- type DOC
- type Header
- type Headers
- type INDEX
- type Library
- type MOD
- type MODClass
- type MODClassRule
- type MODs
- func (m *MODs) Add(class MODClass, mods []MOD) (err error)
- func (m *MODs) Functions(tag string) (functionCode string, functionNames []string)
- func (m *MODs) GetAllClasses() (classes []MODClass)
- func (m *MODs) GetAllMods() (mods []MOD)
- func (m *MODs) GetClass(modTag string) (class MODClass)
- func (m *MODs) GetMod(tag string) (mod MOD)
- func (m *MODs) GetRules() (rules []MODClassRule)
- func (m *MODs) Index() (ci []int)
- func (m *MODs) InjectMODs(modTag, code string) (modSC dvm.SmartContract, modCode string, err error)
- func (m *MODs) Tag(i int) (tag string)
- func (m *MODs) TagsAreValid(modTag string) (tags []string, err error)
- func (m *MODs) Verify() (err error)
- type MetaTag
- type Rating
- type Rating_Result
- type ServerInfo
- type Signature
- type TELA
- type Version
- func GetContractVersions(isDOC bool) (versions []Version)
- func GetLatestContractVersion(isDOC bool) (version Version)
- func GetVersion() (version Version)
- func ParseVersion(versionStr string) (version *Version, err error)
- func ValidDOCVersion(code string) (contract dvm.SmartContract, version Version, err error)
- func ValidINDEXVersion(code string, modTag string) (contract dvm.SmartContract, version Version, err error)
Constants ¶
const ( DVM_FUNC_INIT_PRIVATE = "InitializePrivate" DVM_FUNC_INIT = "Initialize" SHARD_SIZE = int64(17500) // Defines the docCode size of a DocShard MAX_DOC_CODE_SIZE = float64(18) // DOC SC template file size is +1.2KB with headers MAX_DOC_INSTALL_SIZE = float64(19.2) // DOC SC total file size (including docCode) should be below this MAX_INDEX_INSTALL_SIZE = float64(11.64) // INDEX SC file size should be below this )
const (
COMPRESSION_GZIP = ".gz"
)
const DEFAULT_MAX_PORT = 65535 // Maximum port of possible serving range
const DEFAULT_MAX_SERVER = 20 // Default max amount of servers
const DEFAULT_MIN_PORT = 1200 // Minimum port of possible serving range
const DEFAULT_PORT_START = 8082 // Default start port for servers
const DOC_CSS = "TELA-CSS-1" // CSS docType
const DOC_GO = "TELA-GO-1" // Golang docType
const DOC_HTML = "TELA-HTML-1" // HTML docType
const DOC_JS = "TELA-JS-1" // JavaScript docType
const DOC_JSON = "TELA-JSON-1" // JSON docType
const DOC_MD = "TELA-MD-1" // Markdown docType
const DOC_STATIC = "TELA-STATIC-1" // Generic docType for any file type
const MINIMUM_GAS_FEE = uint64(100) // Minimum gas fee used when making transfers
const TAG_BOOTSTRAP = ".bootstrap" // A collection of TELA INDEXs or DOCs which can be used to bootstrap a list of applications or content (usage is appended to INDEX dURLs)
const TAG_DOC_SHARD = ".shard" // A DocShard DOC (usage is appended to DOC dURLs)
const TAG_DOC_SHARDS = ".shards" // A collection of DocShard DOCs embedded within an INDEX, when recreated this will be one file (usage is appended to INDEX dURLs)
const TAG_LIBRARY = ".lib" // A collection of standard DOCs embedded within an INDEX, each DOC is its own file (usage is appended to INDEX and DOC dURLs)
Variables ¶
var Ratings ratings
Access TELA ratings variables and functions
var TELA_DOC_1 string
var TELA_INDEX_1 string
var TELA_MOD_1_TXDWA string
var TELA_MOD_1_TXDWD string
var TELA_MOD_1_TXTO string
var TELA_MOD_1_VSOO string
var TELA_MOD_1_VSOOIM string
var TELA_MOD_1_VSPUBIM string
var TELA_MOD_1_VSPUBOW string
var TELA_MOD_1_VSPUBSU string
Functions ¶
func AllowUpdates ¶
func AllowUpdates(b bool)
AllowUpdates default is false and will not allow TELA content to be served that has been updated since its original install
func CloneAtCommit ¶
Clone a TELA-INDEX SC at a commit TXID from endpoint
func ConstructFromShards ¶
ConstructFromShards takes DocShards and recreates them as a file at basePath, CreateShardFiles can be used to create the shard files formatted for ConstructFromShards
func CreateShardFiles ¶
CreateShardFiles takes a source file and creates DocShard files sized and formatted for installing as TELA DOCs, the package uses ConstructFromShards to re-build the DocShards as its original file when cloning, output files are formatted as "name-#.ext+compression" in the source file's directory if content is nil the filePath will be read and compression will be applied if used, otherwise content will be handled as is
func Decompress ¶
Decompress TELA data using the given compression format, if compression is "" result will return the original data
func DeleteVar ¶
func DeleteVar(wallet *walletapi.Wallet_Disk, scid, key string) (txid string, err error)
Delete a K/V store from a TELA SC, requires wallet to be owner of SC
func EqualSmartContracts ¶
func EqualSmartContracts(c, v string) (contract dvm.SmartContract, err error)
EqualSmartContract compares if c is equal to v by parsing function lines and parts, it compares all functions other than InitializePrivate/Initialize, contract returned is dvm.SmartContract of v when equal
func FindOpenPort ¶
Listen for open ports and returns http server for TELA content on open port if found
func FormatSmartContract ¶
func FormatSmartContract(sc dvm.SmartContract, code string) (formatted string, err error)
Formats dvm.SmartContract to string, removes whitespace and comments from original
func GetCodeSizeInKB ¶
Find how many KB code string is, counting for new lines in total size
func GetDefaultNetworkAddress ¶
func GetDefaultNetworkAddress() (network, destination string)
Get a default DERO transfer address for the network defined by globals.Arguments --testnet and --simulator flags
func GetGasEstimate ¶
func GetGasEstimate(wallet *walletapi.Wallet_Disk, ringsize uint64, transfers []rpc.Transfer, args rpc.Arguments) (gasFees uint64, err error)
Get DERO gas estimate for transfers and args
func GetSmartContractFuncNames ¶
Parse DVM code string and return its functions names in written order
func GetTotalShards ¶
Get the total amount of shards that would be created if data is used to CreateShardFiles
func Installer ¶
func Installer(wallet *walletapi.Wallet_Disk, ringsize uint64, params interface{}) (txid string, err error)
Install TELA smart contracts with DERO walletapi
func IsAcceptedLanguage ¶
Check if language used is accepted by TELA, see acceptedLanguages for full list
func IsCompressedExt ¶
IsCompressedExt returns true if ext is a valid TELA compression format
func KeyPrefixExists ¶
Check if prefixed key is stored in SCID at endpoint
func NewDeleteVarArgs ¶
Create arguments for TELA DeleteVar SC call
func NewInstallArgs ¶
Create arguments for INDEX or DOC SC install
func NewRateArgs ¶
Create arguments for TELA Rate SC call
func NewSetVarArgs ¶
Create arguments for TELA SetVar SC call
func NewUpdateArgs ¶
Create arguments for INDEX SC UpdateCode call
func OpenTELALink ¶
OpenTELALink will open content from a telaLink formatted as tela://open/<scid>/subDir/../.. if no server exists for that content it will try starting one using ServeTELA()
func ParseDocType ¶
Parse a file for its TELA docType language
func ParseHeaders ¶
ParseHeaders takes a headerType and SC code string then returns a formatted SC string with those header values See ART-NFA and TELA docs for detailed header info
func ParseINDEXForDOCs ¶
Parse an INDEX contract string for its DOC SCIDs
func ParseSignature ¶
Parse a DERO signature for address and C, S values
func ParseTELALink ¶
ParseTELALink takes a TELA link and parses it for its target and args. Host applications can use TELA links in combination with custom websocket methods to set up and perform their own client specific actions. Usage examples:
- target://<arg>/<arg>/<arg>...
- tela://open/<scid>/subDir/../.. Use like a hyperlink to open external TELA content from a existing page, see OpenTelaLink()
- client://module/explorer/<scid> Tell a client to open a specific module or page with args
func Rate ¶
Rate a TELA SC positively (rating > 49) or negatively (rating < 50) with DERO walletapi, the transaction will use ringsize of 2
func ServeAtCommit ¶
ServeAtCommit clones and serves a TELA-INDEX-1 SC from endpoint at commit TXID if the SC code from that commit can be decoded, ensure AllowUpdates is set true prior to calling ServeAtCommit otherwise it will return error
func ServeTELA ¶
ServeTELA clones and serves a TELA-INDEX-1 SC from endpoint and returns a link to the running TELA server if successful
func SetMaxServers ¶
func SetMaxServers(i int)
Set the maximum amount of TELA servers which can be active
func SetPortStart ¶
Set the initial port to start serving TELA content from if isValidPort
func SetShardPath ¶
SetShardPath can be used to set a custom path for TELA DOC storage, TELA will remove all its files from the /tela directory when servers are Shutdown
func SetVar ¶
func SetVar(wallet *walletapi.Wallet_Disk, scid, key, value string) (txid string, err error)
Set a K/V store on a TELA SC
func ShutdownServer ¶
func ShutdownServer(name string)
ShutdownTELA shuts down running TELA servers by name, if two servers with same name exist both will shutdown
func ShutdownTELA ¶
func ShutdownTELA()
ShutdownTELA shuts down all TELA servers and cleans up directory
func Transfer ¶
func Transfer(wallet *walletapi.Wallet_Disk, ringsize uint64, transfers []rpc.Transfer, args rpc.Arguments) (txid string, err error)
Transfer is used for executing TELA smart contract actions with DERO walletapi, if nil transfers is passed it initializes a transfer of 0 to a default address for the network using GetDefaultNetworkAddress()
func TrimCompressedExt ¶
TrimCompressedExt removes known compression extensions from the filename
func Updater ¶
func Updater(wallet *walletapi.Wallet_Disk, params interface{}) (txid string, err error)
Update a TELA INDEX SC with DERO walletapi, requires wallet to be owner of SC
func UpdatesAllowed ¶
func UpdatesAllowed() bool
Check if TELA server is allowed to serve TELA content that has been updated since its original install
func ValidateImageURL ¶
ValidateImageURL will return error if the imageURL is not a valid URL or a valid image smart contract
Types ¶
type Cloning ¶
type Cloning struct {
BasePath string `json:"basePath"` // Main directory path for TELA files
ServePath string `json:"servePath"` // URL serve path
Entrypoint string `json:"entrypoint"` // INDEX entrypoint
DURL string `json:"dURL"` // TELA dURL
Hash string `json:"hash"` // Commit hash of INDEX
}
Cloning structure for creating DOC/INDEX
type DOC ¶
type DOC struct {
DocType string `json:"docType"` // Language this document is using (ex: "TELA-HTML-1", "TELA-JS-1" or "TELA-CSS-1")
Code string `json:"code"` // The application code HTML, JS... (when a DOC is returned this will be the SC code, the DocCode can be retrieved with ExtractDocCode)
SubDir string `json:"subDir"` // Sub directory to place file in (always use / for further children, ex: "sub1" or "sub1/sub2/sub3")
SCID string `json:"scid"` // SCID of this DOC, only used after DOC has been installed on-chain
Author string `json:"author"` // Author of this DOC, only used after DOC has been installed on-chain
DURL string `json:"dURL"` // TELA dURL
Compression string `json:"compression"` // Compression format if used on this DOC (ex: .gz)
SCVersion *Version `json:"version,omitempty"` // Version of this DOC SC
// Signature values of Code
Signature `json:"signature"`
// Standard headers
Headers `json:"headers"`
}
TELA-DOC-1 structure
func GetDOCInfo ¶
Get TELA-DOC info from scid at endpoint
func (*DOC) ExtractAsSVG ¶
ExtractAsSVG extends ExtractDocCode and validates that the DocCode is formatted for SVG images
func (*DOC) ExtractDocCode ¶
ExtractDocCode parses a DOC for its DocCode and decompresses it if required
func (*DOC) ExtractMetaTags ¶
ExtractMetaTags parses a DOC for any <meta> within the DocCode and returns the tags
type Header ¶
type Header string
Standard SC header keys
const ( HEADER_NAME Header = `"nameHdr"` HEADER_DESCRIPTION Header = `"descrHdr"` HEADER_ICON_URL Header = `"iconURLHdr"` HEADER_CHECK_C Header = `"fileCheckC"` HEADER_CHECK_S Header = `"fileCheckS"` HEADER_MODS Header = `"mods"` HEADER_DURL Header = `"dURL"` HEADER_DOCUMENT Header = `"DOC` // append with Number() HEADER_SUBDIR Header = `"subDir"` HEADER_DOCTYPE Header = `"docType"` HEADER_COLLECTION Header = `"collection"` HEADER_TYPE Header = `"typeHdr"` HEADER_TAGS Header = `"tagsHdr"` HEADER_FILE_URL Header = `"fileURL"` HEADER_SIGN_URL Header = `"fileSignURL"` HEADER_COVER_URL Header = `"coverURL"` HEADER_ART_FEE Header = `"artificerFee"` HEADER_ROYALTY Header = `"royalty"` HEADER_OWNER Header = `"owner"` HEADER_OWNER_UPDATE Header = `"ownerCanUpdate"` HEADER_NAME_V2 Header = `"var_header_name"` HEADER_DESCRIPTION_V2 Header = `"var_header_description"` HEADER_ICON_URL_V2 Header = `"var_header_icon"` LINE_MODS_STORE = `34 STORE("mods", ` LINE_DOC_VERSION = `50 STORE("docVersion", ` LINE_INDEX_VERSION = `50 STORE("telaVersion", ` )
func (Header) CanAppend ¶
Returns if Header can be appended. Headers ending in `"` or with len < 2 will return false
type Headers ¶
type Headers struct {
NameHdr string `json:"nameHdr"` // On-chain name of SC. For TELA-DOCs, they are recreated using this as the file name, it should include the file extension
DescrHdr string `json:"descrHdr"` // On-chain description of DOC, INDEX or Asset SC
IconHdr string `json:"iconHdr"` // On-chain icon URL, (size 100x100)
}
Standard SC header value stores
type INDEX ¶
type INDEX struct {
SCID string `json:"scid"` // SCID of this INDEX, only used after INDEX has been installed on-chain
Author string `json:"author"` // Author of this INDEX, only used after INDEX has been installed on-chain
DURL string `json:"dURL"` // TELA dURL
Mods string `json:"mods"` // TELA modules string, stores addition functionality to be parsed when validating, module tags are separated by comma
DOCs []string `json:"docs"` // SCIDs of TELA DOCs embedded in this INDEX SC
SCVersion *Version `json:"version,omitempty"` // Version of this INDEX SC
SC dvm.SmartContract `json:"-"` // DVM smart contract is used for further parsing of installed INDEXs
// Standard headers
Headers `json:"headers"`
}
TELA-INDEX-1 structure
func GetINDEXInfo ¶
Get TELA-INDEX info from scid at endpoint
type Library ¶
type Library struct {
DURL string `json:"dURL"` // TELA library dURL
Author string `json:"author"` // Author of the library
SCID string `json:"scid"` // SCID of the library DOC or INDEX
LikesRatio float64 `json:"likesRatio"` // Likes to dislike ratio of the library
}
Library structure for search queries
type MOD ¶
type MOD struct {
Name string // The name of the MOD
Tag string // The identifying tag for the MOD
Description string // Description of what the MOD does
FunctionCode func() string // The embedded DVM code
FunctionNames []string // The function names from the DVM code
}
TELA-MOD structure
type MODClass ¶
type MODClass struct {
Name string // The name of the MODClass
Tag string // The identifying tag for the MODClass
Rules []MODClassRule // Any rules for the MODClass
}
MODClass structure is used to group similarly functioned MODs
type MODClassRule ¶
type MODClassRule struct {
Name string // Name of the rule
Description string // Description of what the rule is enforcing
Verify func([]string, MODClass) error // Verification function checking that the parameters of the rule are met
}
MODClassRule structure contains data for the rules used within a MODClass
type MODs ¶
type MODs struct {
// contains filtered or unexported fields
}
MODs contains the package's TELA-MOD data structures and access, all MODClasses are held in the mods variable and can be separated by its index
var Mods MODs
Access the package's initialized TELA-MOD data
func (*MODs) GetAllClasses ¶
GetAllClasses returns all MODClasses
func (*MODs) GetRules ¶
func (m *MODs) GetRules() (rules []MODClassRule)
GetRules returns all of the MODClassesRules
func (*MODs) InjectMODs ¶
InjectMODs parses the modTag ensuring all tags are valid before injecting the TELA-MOD code for the given MODs in the modTag
func (*MODs) TagsAreValid ¶
ModTagsAreValid parses a modTag string formatted as "tag,tag,tag" returning its tags if all tags are valid and there is no conflicting tags. If an empty modTag is passed it will return no error and nil tags
type MetaTag ¶
type MetaTag string
MetaTag type for handling TELA DOC metadata
func (MetaTag) ExtractAttribute ¶
Extract the data from a MetaTag for the given attribute
type Rating ¶
type Rating struct {
Address string `json:"address"` // Address of the rater
Rating uint64 `json:"rating"` // The 0-99 rating number
Height uint64 `json:"height"` // The block height this rating occurred
}
A TELA SC rating
type Rating_Result ¶
type Rating_Result struct {
Ratings []Rating `json:"ratings,omitempty"` // All ratings for a SC
Likes uint64 `json:"likes"` // Likes for a SC
Dislikes uint64 `json:"dislikes"` // Dislikes for a SC
Average float64 `json:"average"` // Average category value of all ratings, will be 0-10
}
TELA SC rating structure
func GetRating ¶
func GetRating(scid, endpoint string, height uint64) (ratings Rating_Result, err error)
Get the rating of a TELA scid from endpoint. Result is all individual ratings, likes and dislikes and the average rating category. Using height will filter the individual ratings (including only >= height) this will not effect like and dislike results
func (*Rating_Result) ParseAverage ¶
func (res *Rating_Result) ParseAverage() (category string)
Parse the average rating result for its category string
type ServerInfo ¶
Local TELA server info
type Signature ¶
type Signature struct {
CheckC string `json:"checkC"` // C signature value
CheckS string `json:"checkS"` // S signature value
}
DERO signature
type Version ¶
Versioning structure used for package and contracts
func GetContractVersions ¶
GetContractVersions returns all valid version numbers for DOC or INDEX SCs
func GetLatestContractVersion ¶
GetLatestContractVersion returns the latest version number for DOC or INDEX SCs
func GetVersion ¶
func GetVersion() (version Version)
GetVersion returns the TELA go package's version number
func ParseVersion ¶
Parse a versionStr from a TELA SC and return it as a Version
func ValidDOCVersion ¶
func ValidDOCVersion(code string) (contract dvm.SmartContract, version Version, err error)
ValidDOCVersion checks if code is equal to a valid TELA-DOC SC version
func ValidINDEXVersion ¶
func ValidINDEXVersion(code string, modTag string) (contract dvm.SmartContract, version Version, err error)
ValidINDEXVersion checks if code is equal to a valid TELA-INDEX SC version
