diff --git a/contracts/decentiumorg.ts b/contracts/decentiumorg.ts deleted file mode 100644 index 052a742..0000000 --- a/contracts/decentiumorg.ts +++ /dev/null @@ -1,1037 +0,0 @@ -import {Contract, Table, TableCursor, GetTableRowsOptions} from '../src/index' -import { - APIClient, - Session, - Struct, - TransactResult, - Asset, - Checksum256, - Float64, - Name, - TimePoint, - TimePointSec, - UInt128, - UInt16, - UInt32, - UInt64, - UInt8, - AssetType, - Checksum256Type, - Float64Type, - NameType, - TimePointType, - UInt128Type, - UInt16Type, - UInt32Type, - UInt64Type, - UInt8Type, -} from '@wharfkit/session' -export class _Decentiumorg extends Contract { - addcategory( - addcategoryParams: _Decentiumorg.types.AddcategoryParams, - session: Session - ): Promise { - return this.call( - 'addcategory', - _Decentiumorg.types.Action_addcategory.from(addcategoryParams), - session - ) - } - addmoderator( - addmoderatorParams: _Decentiumorg.types.AddmoderatorParams, - session: Session - ): Promise { - return this.call( - 'addmoderator', - _Decentiumorg.types.Action_addmoderator.from(addmoderatorParams), - session - ) - } - createblog( - createblogParams: _Decentiumorg.types.CreateblogParams, - session: Session - ): Promise { - return this.call( - 'createblog', - _Decentiumorg.types.Action_createblog.from(createblogParams), - session - ) - } - delcategory( - delcategoryParams: _Decentiumorg.types.DelcategoryParams, - session: Session - ): Promise { - return this.call( - 'delcategory', - _Decentiumorg.types.Action_delcategory.from(delcategoryParams), - session - ) - } - deleteblog( - deleteblogParams: _Decentiumorg.types.DeleteblogParams, - session: Session - ): Promise { - return this.call( - 'deleteblog', - _Decentiumorg.types.Action_deleteblog.from(deleteblogParams), - session - ) - } - delmoderator( - delmoderatorParams: _Decentiumorg.types.DelmoderatorParams, - session: Session - ): Promise { - return this.call( - 'delmoderator', - _Decentiumorg.types.Action_delmoderator.from(delmoderatorParams), - session - ) - } - freezeblog( - freezeblogParams: _Decentiumorg.types.FreezeblogParams, - session: Session - ): Promise { - return this.call( - 'freezeblog', - _Decentiumorg.types.Action_freezeblog.from(freezeblogParams), - session - ) - } - housekeeping( - housekeepingParams: _Decentiumorg.types.HousekeepingParams, - session: Session - ): Promise { - return this.call( - 'housekeeping', - _Decentiumorg.types.Action_housekeeping.from(housekeepingParams), - session - ) - } - pinpost( - pinpostParams: _Decentiumorg.types.PinpostParams, - session: Session - ): Promise { - return this.call('pinpost', _Decentiumorg.types.Action_pinpost.from(pinpostParams), session) - } - post(postParams: _Decentiumorg.types.PostParams, session: Session): Promise { - return this.call('post', _Decentiumorg.types.Action_pinpost.from(postParams), session) - } - postedit( - posteditParams: _Decentiumorg.types.PosteditParams, - session: Session - ): Promise { - return this.call( - 'postedit', - _Decentiumorg.types.Action_postedit.from(posteditParams), - session - ) - } - profile( - profileParams: _Decentiumorg.types.ProfileParams, - session: Session - ): Promise { - return this.call('profile', _Decentiumorg.types.Action_profile.from(profileParams), session) - } - publish( - publishParams: _Decentiumorg.types.PublishParams, - session: Session - ): Promise { - return this.call('publish', _Decentiumorg.types.Action_publish.from(publishParams), session) - } - publishedit( - publisheditParams: _Decentiumorg.types.PublisheditParams, - session: Session - ): Promise { - return this.call( - 'publishedit', - _Decentiumorg.types.Action_publishedit.from(publisheditParams), - session - ) - } - setlinkflags( - setlinkflagsParams: _Decentiumorg.types.SetlinkflagsParams, - session: Session - ): Promise { - return this.call( - 'setlinkflags', - _Decentiumorg.types.Action_setlinkflags.from(setlinkflagsParams), - session - ) - } - setprofile( - setprofileParams: _Decentiumorg.types.SetprofileParams, - session: Session - ): Promise { - return this.call( - 'setprofile', - _Decentiumorg.types.Action_setprofile.from(setprofileParams), - session - ) - } - unfreezeblog( - unfreezeblogParams: _Decentiumorg.types.UnfreezeblogParams, - session: Session - ): Promise { - return this.call( - 'unfreezeblog', - _Decentiumorg.types.Action_unfreezeblog.from(unfreezeblogParams), - session - ) - } - unpinpost( - unpinpostParams: _Decentiumorg.types.UnpinpostParams, - session: Session - ): Promise { - return this.call( - 'unpinpost', - _Decentiumorg.types.Action_unpinpost.from(unpinpostParams), - session - ) - } - unpublish( - unpublishParams: _Decentiumorg.types.UnpublishParams, - session: Session - ): Promise { - return this.call( - 'unpublish', - _Decentiumorg.types.Action_unpublish.from(unpublishParams), - session - ) - } - updatescore( - updatescoreParams: _Decentiumorg.types.UpdatescoreParams, - session: Session - ): Promise { - return this.call( - 'updatescore', - _Decentiumorg.types.Action_updatescore.from(updatescoreParams), - session - ) - } -} -export namespace _Decentiumorg { - export namespace tables { - export class blogs { - static fieldToIndex = {author: {type: 'name', index_position: 'primary'}} - static where( - queryParams: _Decentiumorg.types.BlogsWhereQueryParams, - getTableRowsOptions: GetTableRowsOptions, - client: APIClient - ): TableCursor<_Decentiumorg.types.Blog_row> { - const blogsTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'blogs', - rowType: _Decentiumorg.types.Blog_row, - fieldToIndex: blogs.fieldToIndex, - }) - return blogsTable.where(queryParams, getTableRowsOptions) - } - static find( - queryParams: _Decentiumorg.types.BlogsFindQueryParams, - client: APIClient - ): Promise<_Decentiumorg.types.Blog_row> { - const blogsTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'blogs', - rowType: _Decentiumorg.types.Blog_row, - fieldToIndex: blogs.fieldToIndex, - }) - return blogsTable.find(queryParams) - } - static first( - limit: number, - client: APIClient - ): TableCursor<_Decentiumorg.types.Blog_row> { - const blogsTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'blogs', - rowType: _Decentiumorg.types.Blog_row, - fieldToIndex: blogs.fieldToIndex, - }) - return blogsTable.first(limit) - } - } - export class links { - static fieldToIndex = { - id: {type: 'uint64', index_position: 'primary'}, - from: {type: 'uint128', index_position: 'secondary'}, - to: {type: 'uint128', index_position: 'tertiary'}, - } - static where( - queryParams: _Decentiumorg.types.LinksWhereQueryParams, - getTableRowsOptions: GetTableRowsOptions, - client: APIClient - ): TableCursor<_Decentiumorg.types.Link_row> { - const linksTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'links', - rowType: _Decentiumorg.types.Link_row, - fieldToIndex: links.fieldToIndex, - }) - return linksTable.where(queryParams, getTableRowsOptions) - } - static find( - queryParams: _Decentiumorg.types.LinksFindQueryParams, - client: APIClient - ): Promise<_Decentiumorg.types.Link_row> { - const linksTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'links', - rowType: _Decentiumorg.types.Link_row, - fieldToIndex: links.fieldToIndex, - }) - return linksTable.find(queryParams) - } - static first( - limit: number, - client: APIClient - ): TableCursor<_Decentiumorg.types.Link_row> { - const linksTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'links', - rowType: _Decentiumorg.types.Link_row, - fieldToIndex: links.fieldToIndex, - }) - return linksTable.first(limit) - } - } - export class posts { - static fieldToIndex = { - slug: {type: 'name', index_position: 'primary'}, - updated: {type: 'uint64', index_position: 'secondary'}, - } - static where( - queryParams: _Decentiumorg.types.PostsWhereQueryParams, - getTableRowsOptions: GetTableRowsOptions, - client: APIClient - ): TableCursor<_Decentiumorg.types.Post_row> { - const postsTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'posts', - rowType: _Decentiumorg.types.Post_row, - fieldToIndex: posts.fieldToIndex, - }) - return postsTable.where(queryParams, getTableRowsOptions) - } - static find( - queryParams: _Decentiumorg.types.PostsFindQueryParams, - client: APIClient - ): Promise<_Decentiumorg.types.Post_row> { - const postsTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'posts', - rowType: _Decentiumorg.types.Post_row, - fieldToIndex: posts.fieldToIndex, - }) - return postsTable.find(queryParams) - } - static first( - limit: number, - client: APIClient - ): TableCursor<_Decentiumorg.types.Post_row> { - const postsTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'posts', - rowType: _Decentiumorg.types.Post_row, - fieldToIndex: posts.fieldToIndex, - }) - return postsTable.first(limit) - } - } - export class state { - static fieldToIndex = {} - static where( - queryParams: _Decentiumorg.types.StateWhereQueryParams, - getTableRowsOptions: GetTableRowsOptions, - client: APIClient - ): TableCursor<_Decentiumorg.types.State> { - const stateTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'state', - rowType: _Decentiumorg.types.State, - fieldToIndex: state.fieldToIndex, - }) - return stateTable.where(queryParams, getTableRowsOptions) - } - static find( - queryParams: _Decentiumorg.types.StateFindQueryParams, - client: APIClient - ): Promise<_Decentiumorg.types.State> { - const stateTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'state', - rowType: _Decentiumorg.types.State, - fieldToIndex: state.fieldToIndex, - }) - return stateTable.find(queryParams) - } - static first(limit: number, client: APIClient): TableCursor<_Decentiumorg.types.State> { - const stateTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'state', - rowType: _Decentiumorg.types.State, - fieldToIndex: state.fieldToIndex, - }) - return stateTable.first(limit) - } - } - export class trending { - static fieldToIndex = { - id: {type: 'uint64', index_position: 'primary'}, - score: {type: 'uint64', index_position: 'secondary'}, - cscore: {type: 'uint128', index_position: 'tertiary'}, - permlink: {type: 'uint128', index_position: 'fourth'}, - } - static where( - queryParams: _Decentiumorg.types.TrendingWhereQueryParams, - getTableRowsOptions: GetTableRowsOptions, - client: APIClient - ): TableCursor<_Decentiumorg.types.Trending_row> { - const trendingTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'trending', - rowType: _Decentiumorg.types.Trending_row, - fieldToIndex: trending.fieldToIndex, - }) - return trendingTable.where(queryParams, getTableRowsOptions) - } - static find( - queryParams: _Decentiumorg.types.TrendingFindQueryParams, - client: APIClient - ): Promise<_Decentiumorg.types.Trending_row> { - const trendingTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'trending', - rowType: _Decentiumorg.types.Trending_row, - fieldToIndex: trending.fieldToIndex, - }) - return trendingTable.find(queryParams) - } - static first( - limit: number, - client: APIClient - ): TableCursor<_Decentiumorg.types.Trending_row> { - const trendingTable = Table.from({ - contract: Contract.from({name: 'decentiumorg', client: client}), - name: 'trending', - rowType: _Decentiumorg.types.Trending_row, - fieldToIndex: trending.fieldToIndex, - }) - return trendingTable.first(limit) - } - } - } -} -export namespace _Decentiumorg { - export namespace types { - export interface AddcategoryParams { - category: NameType - } - export interface AddmoderatorParams { - account: NameType - } - export interface CreateblogParams { - author: NameType - } - export interface DelcategoryParams { - category: NameType - } - export interface DeleteblogParams { - author: NameType - max_itr: UInt32Type - } - export interface DelmoderatorParams { - account: NameType - } - export interface FreezeblogParams { - author: NameType - reason: String - } - export interface HousekeepingParams { - max_itr: UInt32Type - } - export interface PinpostParams { - author: NameType - slug: NameType - } - export interface PostParams { - author: NameType - slug: NameType - } - export interface PosteditParams { - author: NameType - new_title: String - patch: String - new_metadata: Metadata - } - export interface ProfileParams { - author: NameType - name: String - bio: String - image: String - } - export interface PublishParams { - permlink: Permlink - tx: Tx_ref - category: NameType - options: UInt8Type - links: Permlink - } - export interface PublisheditParams { - permlink: Permlink - edit_tx: Tx_ref - } - export interface SetlinkflagsParams { - link_id: UInt64Type - new_flags: UInt8Type - } - export interface SetprofileParams { - author: NameType - profile: Tx_ref - } - export interface UnfreezeblogParams { - author: NameType - } - export interface UnpinpostParams { - author: NameType - slug: NameType - } - export interface UnpublishParams { - permlink: Permlink - } - export interface UpdatescoreParams { - post_permlink: Permlink - } - export interface BlogsWhereQueryParams { - author?: { - from: NameType - to: NameType - } - flags?: { - from: UInt8Type - to: UInt8Type - } - pinned?: { - from: NameType - to: NameType - } - stats?: { - from: Blog_stats - to: Blog_stats - } - profile?: { - from: Tx_ref - to: Tx_ref - } - extensions?: { - from: Future_extensions - to: Future_extensions - } - } - export interface BlogsFindQueryParams { - author?: NameType - flags?: UInt8Type - pinned?: NameType - stats?: Blog_stats - profile?: Tx_ref - extensions?: Future_extensions - } - export interface LinksWhereQueryParams { - id?: { - from: UInt64Type - to: UInt64Type - } - from?: { - from: Permlink - to: Permlink - } - to?: { - from: Permlink - to: Permlink - } - flags?: { - from: UInt8Type - to: UInt8Type - } - payment?: { - from: AssetType - to: AssetType - } - } - export interface LinksFindQueryParams { - id?: UInt64Type - from?: Permlink - to?: Permlink - flags?: UInt8Type - payment?: AssetType - } - export interface PostsWhereQueryParams { - ref?: { - from: Post_ref - to: Post_ref - } - extensions?: { - from: Future_extensions - to: Future_extensions - } - } - export interface PostsFindQueryParams { - ref?: Post_ref - extensions?: Future_extensions - } - export interface StateWhereQueryParams { - moderators?: { - from: NameType - to: NameType - } - categories?: { - from: Pair_name_category_stat - to: Pair_name_category_stat - } - } - export interface StateFindQueryParams { - moderators?: NameType - categories?: Pair_name_category_stat - } - export interface TrendingWhereQueryParams { - id?: { - from: UInt64Type - to: UInt64Type - } - score?: { - from: UInt64Type - to: UInt64Type - } - ref?: { - from: Post_ref - to: Post_ref - } - extensions?: { - from: Future_extensions - to: Future_extensions - } - } - export interface TrendingFindQueryParams { - id?: UInt64Type - score?: UInt64Type - ref?: Post_ref - extensions?: Future_extensions - } - @Struct.type('action_addcategory') - export class Action_addcategory extends Struct { - @Struct.field('category') - declare category: Name - } - @Struct.type('action_addmoderator') - export class Action_addmoderator extends Struct { - @Struct.field('account') - declare account: Name - } - @Struct.type('action_createblog') - export class Action_createblog extends Struct { - @Struct.field('author') - declare author: Name - } - @Struct.type('action_delcategory') - export class Action_delcategory extends Struct { - @Struct.field('category') - declare category: Name - } - @Struct.type('action_deleteblog') - export class Action_deleteblog extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('max_itr') - declare max_itr: UInt32 - } - @Struct.type('action_delmoderator') - export class Action_delmoderator extends Struct { - @Struct.field('account') - declare account: Name - } - @Struct.type('action_freezeblog') - export class Action_freezeblog extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('reason') - declare reason: String - } - @Struct.type('action_housekeeping') - export class Action_housekeeping extends Struct { - @Struct.field('max_itr') - declare max_itr: UInt32 - } - @Struct.type('action_pinpost') - export class Action_pinpost extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('slug') - declare slug: Name - } - @Struct.type('action_post') - export class Action_post extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('title') - declare title: String - @Struct.field('doc') - declare doc: _Decentiumorg.types.Document - @Struct.field('metadata') - declare metadata: _Decentiumorg.types.Metadata - } - @Struct.type('action_postedit') - export class Action_postedit extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('new_title') - declare new_title: String - @Struct.field('patch') - declare patch: String - @Struct.field('new_metadata') - declare new_metadata: _Decentiumorg.types.Metadata - } - @Struct.type('action_profile') - export class Action_profile extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('name') - declare name: String - @Struct.field('bio') - declare bio: String - @Struct.field('image') - declare image: String - } - @Struct.type('action_publish') - export class Action_publish extends Struct { - @Struct.field('permlink') - declare permlink: _Decentiumorg.types.Permlink - @Struct.field('tx') - declare tx: _Decentiumorg.types.Tx_ref - @Struct.field('category') - declare category: Name - @Struct.field('options') - declare options: UInt8 - @Struct.field('links') - declare links: _Decentiumorg.types.Permlink - } - @Struct.type('action_publishedit') - export class Action_publishedit extends Struct { - @Struct.field('permlink') - declare permlink: _Decentiumorg.types.Permlink - @Struct.field('edit_tx') - declare edit_tx: _Decentiumorg.types.Tx_ref - } - @Struct.type('action_setlinkflags') - export class Action_setlinkflags extends Struct { - @Struct.field('link_id') - declare link_id: UInt64 - @Struct.field('new_flags') - declare new_flags: UInt8 - } - @Struct.type('action_setprofile') - export class Action_setprofile extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('profile') - declare profile: _Decentiumorg.types.Tx_ref - } - @Struct.type('action_unfreezeblog') - export class Action_unfreezeblog extends Struct { - @Struct.field('author') - declare author: Name - } - @Struct.type('action_unpinpost') - export class Action_unpinpost extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('slug') - declare slug: Name - } - @Struct.type('action_unpublish') - export class Action_unpublish extends Struct { - @Struct.field('permlink') - declare permlink: _Decentiumorg.types.Permlink - } - @Struct.type('action_updatescore') - export class Action_updatescore extends Struct { - @Struct.field('post_permlink') - declare post_permlink: _Decentiumorg.types.Permlink - } - @Struct.type('blog_row') - export class Blog_row extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('flags') - declare flags: UInt8 - @Struct.field('pinned') - declare pinned: Name - @Struct.field('stats') - declare stats: _Decentiumorg.types.Blog_stats - @Struct.field('profile') - declare profile: _Decentiumorg.types.Tx_ref - @Struct.field('extensions') - declare extensions: _Decentiumorg.types.Future_extensions - } - @Struct.type('blog_stats') - export class Blog_stats extends Struct { - @Struct.field('total_posts') - declare total_posts: UInt32 - @Struct.field('endorsements_received') - declare endorsements_received: _Decentiumorg.types.Reward_stat - @Struct.field('endorsements_sent') - declare endorsements_sent: _Decentiumorg.types.Reward_stat - @Struct.field('incoming_linkbacks') - declare incoming_linkbacks: _Decentiumorg.types.Reward_stat - @Struct.field('outgoing_linkbacks') - declare outgoing_linkbacks: _Decentiumorg.types.Reward_stat - } - @Struct.type('bold') - export class Bold extends Struct {} - @Struct.type('category_stat') - export class Category_stat extends Struct { - @Struct.field('endorsements') - declare endorsements: _Decentiumorg.types.Reward_stat - @Struct.field('linkbacks') - declare linkbacks: _Decentiumorg.types.Reward_stat - } - @Struct.type('code') - export class Code extends Struct {} - @Struct.type('code_block') - export class Code_block extends Struct { - @Struct.field('code') - declare code: String - @Struct.field('lang') - declare lang: String - } - @Struct.type('color') - export class Color extends Struct { - @Struct.field('r') - declare r: UInt8 - @Struct.field('g') - declare g: UInt8 - @Struct.field('b') - declare b: UInt8 - } - @Struct.type('divider') - export class Divider extends Struct {} - @Struct.type('document') - export class Document extends Struct { - @Struct.field('content') - declare content: - | _Decentiumorg.types.Paragraph - | _Decentiumorg.types.Heading - | _Decentiumorg.types.Image - | _Decentiumorg.types.Linkref - | _Decentiumorg.types.Quote - | _Decentiumorg.types.Code_block - | _Decentiumorg.types.Divider - | _Decentiumorg.types.List - } - @Struct.type('future_extensions') - export class Future_extensions extends Struct {} - @Struct.type('geometrize_triangles') - export class Geometrize_triangles extends Struct { - @Struct.field('base') - declare base: _Decentiumorg.types.Color - @Struct.field('triangles') - declare triangles: _Decentiumorg.types.Triangle - } - @Struct.type('hard_break') - export class Hard_break extends Struct {} - @Struct.type('heading') - export class Heading extends Struct { - @Struct.field('value') - declare value: String - @Struct.field('level') - declare level: UInt8 - } - @Struct.type('image') - export class Image extends Struct { - @Struct.field('src') - declare src: String - @Struct.field('caption') - declare caption: _Decentiumorg.types.Text | _Decentiumorg.types.Hard_break - @Struct.field('layout') - declare layout: UInt8 - } - @Struct.type('image_info') - export class Image_info extends Struct { - @Struct.field('width') - declare width: UInt16 - @Struct.field('height') - declare height: UInt16 - @Struct.field('placeholder') - declare placeholder: - | _Decentiumorg.types.Color - | _Decentiumorg.types.Geometrize_triangles - } - @Struct.type('italic') - export class Italic extends Struct {} - @Struct.type('link') - export class Link extends Struct { - @Struct.field('href') - declare href: String - @Struct.field('title') - declare title: String - } - @Struct.type('link_row') - export class Link_row extends Struct { - @Struct.field('id') - declare id: UInt64 - @Struct.field('from') - declare from: _Decentiumorg.types.Permlink - @Struct.field('to') - declare to: _Decentiumorg.types.Permlink - @Struct.field('flags') - declare flags: UInt8 - @Struct.field('payment') - declare payment: Asset - } - @Struct.type('linkref') - export class Linkref extends Struct { - @Struct.field('to') - declare to: _Decentiumorg.types.Permlink - } - @Struct.type('list') - export class List extends Struct { - @Struct.field('type') - declare type: UInt8 - @Struct.field('items') - declare items: _Decentiumorg.types.List_item - } - @Struct.type('list_item') - export class List_item extends Struct { - @Struct.field('content') - declare content: _Decentiumorg.types.Text | _Decentiumorg.types.Hard_break - } - @Struct.type('metadata') - export class Metadata extends Struct { - @Struct.field('image') - declare image: String - @Struct.field('summary') - declare summary: String - @Struct.field('image_info') - declare image_info: _Decentiumorg.types.Pair_string_image_info - } - @Struct.type('pair_name_category_stat') - export class Pair_name_category_stat extends Struct { - @Struct.field('key') - declare key: Name - @Struct.field('value') - declare value: _Decentiumorg.types.Category_stat - } - @Struct.type('pair_string_image_info') - export class Pair_string_image_info extends Struct { - @Struct.field('key') - declare key: String - @Struct.field('value') - declare value: _Decentiumorg.types.Image_info - } - @Struct.type('paragraph') - export class Paragraph extends Struct { - @Struct.field('content') - declare content: _Decentiumorg.types.Text | _Decentiumorg.types.Hard_break - } - @Struct.type('permlink') - export class Permlink extends Struct { - @Struct.field('author') - declare author: Name - @Struct.field('slug') - declare slug: Name - } - @Struct.type('post_ref') - export class Post_ref extends Struct { - @Struct.field('permlink') - declare permlink: _Decentiumorg.types.Permlink - @Struct.field('timestamp') - declare timestamp: TimePointSec - @Struct.field('category') - declare category: Name - @Struct.field('options') - declare options: UInt8 - @Struct.field('tx') - declare tx: _Decentiumorg.types.Tx_ref - @Struct.field('edit_tx') - declare edit_tx: _Decentiumorg.types.Tx_ref - @Struct.field('endorsements') - declare endorsements: _Decentiumorg.types.Reward_stat - @Struct.field('extensions') - declare extensions: _Decentiumorg.types.Future_extensions - } - @Struct.type('post_row') - export class Post_row extends Struct { - @Struct.field('ref') - declare ref: _Decentiumorg.types.Post_ref - @Struct.field('extensions') - declare extensions: _Decentiumorg.types.Future_extensions - } - @Struct.type('quote') - export class Quote extends Struct { - @Struct.field('content') - declare content: _Decentiumorg.types.Text | _Decentiumorg.types.Hard_break - } - @Struct.type('reward_stat') - export class Reward_stat extends Struct { - @Struct.field('count') - declare count: UInt32 - @Struct.field('amount') - declare amount: UInt64 - } - @Struct.type('state') - export class State extends Struct { - @Struct.field('moderators') - declare moderators: Name - @Struct.field('categories') - declare categories: _Decentiumorg.types.Pair_name_category_stat - } - @Struct.type('strike') - export class Strike extends Struct {} - @Struct.type('text') - export class Text extends Struct { - @Struct.field('value') - declare value: String - @Struct.field('marks') - declare marks: - | _Decentiumorg.types.Link - | _Decentiumorg.types.Bold - | _Decentiumorg.types.Italic - | _Decentiumorg.types.Code - | _Decentiumorg.types.Strike - } - @Struct.type('trending_row') - export class Trending_row extends Struct { - @Struct.field('id') - declare id: UInt64 - @Struct.field('score') - declare score: UInt64 - @Struct.field('ref') - declare ref: _Decentiumorg.types.Post_ref - @Struct.field('extensions') - declare extensions: _Decentiumorg.types.Future_extensions - } - @Struct.type('triangle') - export class Triangle extends Struct { - @Struct.field('ax') - declare ax: UInt8 - @Struct.field('ay') - declare ay: UInt8 - @Struct.field('bx') - declare bx: UInt8 - @Struct.field('by') - declare by: UInt8 - @Struct.field('cx') - declare cx: UInt8 - @Struct.field('cy') - declare cy: UInt8 - @Struct.field('color') - declare color: _Decentiumorg.types.Color - } - @Struct.type('tx_ref') - export class Tx_ref extends Struct { - @Struct.field('block_num') - declare block_num: UInt32 - @Struct.field('transaction_id') - declare transaction_id: Checksum256 - } - } -} diff --git a/src/codegen.ts b/src/codegen.ts index 4915bf1..08c4e88 100644 --- a/src/codegen.ts +++ b/src/codegen.ts @@ -2,12 +2,12 @@ import {ABI} from '@greymass/eosio' import * as ts from 'typescript' import { - generateImportStatement, - getFieldTypesFromAbi, - generateField, - generateStruct, EOSIO_CORE_CLASSES, EOSIO_CORE_TYPES, + generateField, + generateImportStatement, + generateStruct, + getFieldTypesFromAbi, } from './codegen/helpers' import {generateNamespace, generateNamespaceName} from './codegen/namespace' import {generateActions} from './codegen/actions' diff --git a/src/codegen/actions.ts b/src/codegen/actions.ts index 85eb937..f1896dd 100644 --- a/src/codegen/actions.ts +++ b/src/codegen/actions.ts @@ -3,12 +3,12 @@ import assert from 'assert' import * as ts from 'typescript' import { + findExternalType, generateClassDeclaration, - generatePropertyDeclarationForField, generateInterface, - findExternalType, + generatePropertyDeclarationForField, } from './helpers' -import {pascalCase, capitalize} from '../utils' +import {capitalize, pascalCase} from '../utils' export function generateActions(contractName: string, namespaceName: string, abi: ABI) { const structs: Map = new Map() diff --git a/src/codegen/table.ts b/src/codegen/table.ts index a9995af..2f50a40 100644 --- a/src/codegen/table.ts +++ b/src/codegen/table.ts @@ -1,6 +1,6 @@ import * as ts from 'typescript' -import {Table, Contract} from '../index' +import {Contract, Table} from '../index' import {findExternalType, generateClassDeclaration, generateInterface} from './helpers' import {capitalize} from '../utils' @@ -24,7 +24,7 @@ export async function generateTableClass(contractName, namespaceName, table, abi undefined, undefined, ts.factory.createObjectLiteralExpression( - Object.keys(fieldToIndexMapping).map((keyName, index) => { + Object.keys(fieldToIndexMapping).map((keyName) => { return ts.factory.createPropertyAssignment( keyName, ts.factory.createObjectLiteralExpression([ diff --git a/src/contract/table.ts b/src/contract/table.ts index 1310b0c..c5afe91 100644 --- a/src/contract/table.ts +++ b/src/contract/table.ts @@ -1,4 +1,4 @@ -import {ABI, ABISerializableConstructor, APIClient, Name, NameType, UInt64} from '@wharfkit/session' +import {ABI, ABISerializableConstructor, Name, NameType, UInt64} from '@wharfkit/session' import type {Contract} from '../contract' import {indexPositionInWords} from '../utils' import {TableCursor} from './table-cursor' diff --git a/test/tests/codegen.ts b/test/tests/codegen.ts index 2f4177a..3ba24ea 100644 --- a/test/tests/codegen.ts +++ b/test/tests/codegen.ts @@ -41,7 +41,7 @@ suite('codegen', function () { teardown(() => { // Remove the 'test/tmp' directory and its contents after each run - // fs.rmSync('test/tmp', {recursive: true, force: true}) + fs.rmSync('test/tmp', {recursive: true, force: true}) }) suite('_RewardsGm', function () { diff --git a/test/tmp/rewards.gm.ts b/test/tmp/rewards.gm.ts deleted file mode 100644 index ac82b3e..0000000 --- a/test/tmp/rewards.gm.ts +++ /dev/null @@ -1,225 +0,0 @@ -import { Contract, Table, TableCursor, GetTableRowsOptions } from "../../src/index"; -import { APIClient, Session, Struct, TransactResult, Asset, Checksum256, Float64, Name, TimePoint, TimePointSec, UInt128, UInt16, UInt32, UInt64, UInt8, AssetType, Checksum256Type, Float64Type, NameType, TimePointType, UInt128Type, UInt16Type, UInt32Type, UInt64Type, UInt8Type } from "@wharfkit/session"; -export namespace _RewardsGm { - export namespace actions { - export function adduser(adduserParams: _RewardsGm.types.AdduserParams, session: Session): Promise { - const contract = Contract.from({ name: "rewards.gm" }); - return contract.call("adduser", _RewardsGm.types.Adduser.from(adduserParams), session); - } - export function claim(claimParams: _RewardsGm.types.ClaimParams, session: Session): Promise { - const contract = Contract.from({ name: "rewards.gm" }); - return contract.call("claim", _RewardsGm.types.Claim.from(claimParams), session); - } - export function configure(configureParams: _RewardsGm.types.ConfigureParams, session: Session): Promise { - const contract = Contract.from({ name: "rewards.gm" }); - return contract.call("configure", _RewardsGm.types.Configure.from(configureParams), session); - } - export function deluser(deluserParams: _RewardsGm.types.DeluserParams, session: Session): Promise { - const contract = Contract.from({ name: "rewards.gm" }); - return contract.call("deluser", _RewardsGm.types.Deluser.from(deluserParams), session); - } - export function receipt(receiptParams: _RewardsGm.types.ReceiptParams, session: Session): Promise { - const contract = Contract.from({ name: "rewards.gm" }); - return contract.call("receipt", _RewardsGm.types.Receipt.from(receiptParams), session); - } - export function updateuser(updateuserParams: _RewardsGm.types.UpdateuserParams, session: Session): Promise { - const contract = Contract.from({ name: "rewards.gm" }); - return contract.call("updateuser", _RewardsGm.types.Updateuser.from(updateuserParams), session); - } - } -} -export namespace _RewardsGm { - export namespace tables { - export class config { - static fieldToIndex = { token_symbol: { type: "token_symbol", index_position: "primary" } }; - static where(queryParams: _RewardsGm.types.ConfigWhereQueryParams, getTableRowsOptions: GetTableRowsOptions, client: APIClient): TableCursor<_RewardsGm.types.Config> { - const configTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "config", rowType: _RewardsGm.types.Config, fieldToIndex: config.fieldToIndex }); - return configTable.where(queryParams, getTableRowsOptions); - } - static find(queryParams: _RewardsGm.types.ConfigFindQueryParams, client: APIClient): Promise<_RewardsGm.types.Config> { - const configTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "config", rowType: _RewardsGm.types.Config, fieldToIndex: config.fieldToIndex }); - return configTable.find(queryParams); - } - static first(limit: number, client: APIClient): TableCursor<_RewardsGm.types.Config> { - const configTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "config", rowType: _RewardsGm.types.Config, fieldToIndex: config.fieldToIndex }); - return configTable.first(limit); - } - static cursor(client: APIClient): TableCursor<_RewardsGm.types.Config> { - const configTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "config", rowType: _RewardsGm.types.Config, fieldToIndex: config.fieldToIndex }); - return configTable.cursor(); - } - static all(client: APIClient): Promise<_RewardsGm.types.Config[]> { - const configTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "config", rowType: _RewardsGm.types.Config, fieldToIndex: config.fieldToIndex }); - return configTable.all(); - } - } - export class users { - static fieldToIndex = { account: { type: "account", index_position: "primary" } }; - static where(queryParams: _RewardsGm.types.UsersWhereQueryParams, getTableRowsOptions: GetTableRowsOptions, client: APIClient): TableCursor<_RewardsGm.types.User_row> { - const usersTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "users", rowType: _RewardsGm.types.User_row, fieldToIndex: users.fieldToIndex }); - return usersTable.where(queryParams, getTableRowsOptions); - } - static find(queryParams: _RewardsGm.types.UsersFindQueryParams, client: APIClient): Promise<_RewardsGm.types.User_row> { - const usersTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "users", rowType: _RewardsGm.types.User_row, fieldToIndex: users.fieldToIndex }); - return usersTable.find(queryParams); - } - static first(limit: number, client: APIClient): TableCursor<_RewardsGm.types.User_row> { - const usersTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "users", rowType: _RewardsGm.types.User_row, fieldToIndex: users.fieldToIndex }); - return usersTable.first(limit); - } - static cursor(client: APIClient): TableCursor<_RewardsGm.types.User_row> { - const usersTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "users", rowType: _RewardsGm.types.User_row, fieldToIndex: users.fieldToIndex }); - return usersTable.cursor(); - } - static all(client: APIClient): Promise<_RewardsGm.types.User_row[]> { - const usersTable = Table.from({ contract: Contract.from({ name: "rewards.gm", client: client }), name: "users", rowType: _RewardsGm.types.User_row, fieldToIndex: users.fieldToIndex }); - return usersTable.all(); - } - } - } -} -export namespace _RewardsGm { - export namespace types { - export interface AdduserParams { - account: NameType; - weight: UInt16Type; - } - export interface ClaimParams { - account: NameType; - amount: AssetType; - } - export interface ConfigureParams { - token_symbol: Symbol; - oracle_account: NameType; - oracle_pairs: Oracle_pair; - } - export interface DeluserParams { - account: NameType; - } - export interface ReceiptParams { - account: NameType; - amount: AssetType; - ticker: Price_info; - } - export interface UpdateuserParams { - account: NameType; - weight: UInt16Type; - } - export interface ConfigWhereQueryParams { - token_symbol?: { - from: Symbol; - to: Symbol; - }; - oracle_account?: { - from: NameType; - to: NameType; - }; - oracle_pairs?: { - from: Oracle_pair; - to: Oracle_pair; - }; - } - export interface ConfigFindQueryParams { - token_symbol?: Symbol; - oracle_account?: NameType; - oracle_pairs?: Oracle_pair; - } - export interface UsersWhereQueryParams { - account?: { - from: NameType; - to: NameType; - }; - weight?: { - from: UInt16Type; - to: UInt16Type; - }; - balance?: { - from: AssetType; - to: AssetType; - }; - } - export interface UsersFindQueryParams { - account?: NameType; - weight?: UInt16Type; - balance?: AssetType; - } - @Struct.type("adduser") - export class Adduser extends Struct { - @Struct.field("name") - declare account: Name; - @Struct.field("uint16") - declare weight: UInt16; - } - @Struct.type("claim") - export class Claim extends Struct { - @Struct.field("name") - declare account: Name; - @Struct.field("asset?") - declare amount: Asset; - } - @Struct.type("config") - export class Config extends Struct { - @Struct.field("symbol") - declare token_symbol: Symbol; - @Struct.field("name") - declare oracle_account: Name; - @Struct.field("oracle_pair[]") - declare oracle_pairs: _RewardsGm.types.Oracle_pair; - } - @Struct.type("configure") - export class Configure extends Struct { - @Struct.field("symbol") - declare token_symbol: Symbol; - @Struct.field("name") - declare oracle_account: Name; - @Struct.field("oracle_pair[]") - declare oracle_pairs: _RewardsGm.types.Oracle_pair; - } - @Struct.type("deluser") - export class Deluser extends Struct { - @Struct.field("name") - declare account: Name; - } - @Struct.type("oracle_pair") - export class Oracle_pair extends Struct { - @Struct.field("name") - declare name: Name; - @Struct.field("uint16") - declare precision: UInt16; - } - @Struct.type("price_info") - export class Price_info extends Struct { - @Struct.field("string") - declare pair: String; - @Struct.field("float64") - declare price: Float64; - @Struct.field("time_point") - declare timestamp: TimePoint; - } - @Struct.type("receipt") - export class Receipt extends Struct { - @Struct.field("name") - declare account: Name; - @Struct.field("asset") - declare amount: Asset; - @Struct.field("price_info[]") - declare ticker: _RewardsGm.types.Price_info; - } - @Struct.type("updateuser") - export class Updateuser extends Struct { - @Struct.field("name") - declare account: Name; - @Struct.field("uint16") - declare weight: UInt16; - } - @Struct.type("user_row") - export class User_row extends Struct { - @Struct.field("name") - declare account: Name; - @Struct.field("uint16") - declare weight: UInt16; - @Struct.field("asset") - declare balance: Asset; - } - } -}