diff --git a/docs/pages/docs/glossary/asset.mdx b/docs/pages/docs/glossary/asset.mdx deleted file mode 100644 index b8636b02..00000000 --- a/docs/pages/docs/glossary/asset.mdx +++ /dev/null @@ -1,21 +0,0 @@ -# Asset - -## Description - -Some functions with the `@effectai/sdk` package will return a `Asset` object. -This object contains information about tokens on the blockchain and contain information such as the symbol, precision, and amount. - -An example for the `Asset` object is as follows: - - -```json -{ - "precision": 4, - "symbol": "EFX", - "units": 10000, - "value": 1 -} -``` - -Read more about the `Asset` object here: -https://wharfkit.com/docs/antelope/asset diff --git a/docs/pages/docs/glossary/client-options.mdx b/docs/pages/docs/glossary/client-options.mdx deleted file mode 100644 index b6752018..00000000 --- a/docs/pages/docs/glossary/client-options.mdx +++ /dev/null @@ -1,49 +0,0 @@ -# Client Options - -The ClientOpts interface is used to define the options that can be passed to the EffectAI Client constructor. - -```typescript -interface ClientOpts { - ipfsCacheDurationInMs?: number | null; - fetchProvider?: FetchProviderOptions; - cacheImplementation?: Cache; -} -``` - -As we can see, the ClientOpts interface has three optional properties: - -## `ipfsCacheDurationIMs` - -This property is used to set the cache duration for the IPFS data. - The default value is 600_000 milliseconds; 10 minutes. - -## `fetchProvider` - -This property is used to set the fetch provider. -This is needed because of the different runtimes availalbe to Java Script. -For example, in older versions of Node.js, the fetch API is not available. -For older versions of Node.js, you can use the [`node-fetch` ](https://github.com/node-fetch/node-fetch) package. - -Since Node.js v18.0.0, the fetch API is available by default. - -In the browser fetch is generally available, and is available on the `window.fetch` object. -You can read more about it here: [MDN Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) - -Other serverside Java Script runtimes such as [Bun](https://bun.sh/) and (Deno)[https://deno.com/] already have fetch available on the global `fetch` object. - -## `cacheImplementation` - -This property is used to set the cache implementation. -There are three different cache mechanigms abailable in the EffectAI SDK. -First of all, "IDBCache", "LocalStorageCache", "MemoryCache". -Any of these can be passed to the `cacheImplementation` property while instanlizing the EffectAI Client. - -```typescript -import { createClient, IDBCache, LocalStorageCache, MemoryCache } from '@effectai/sdk' -const client = createClient({ - cacheImplementation: new IDBCache() // or new LocalStorageCache() or new MemoryCache() -}) -``` - -[See Type](https://github.com/effectai/effect-js/blob/main/src/client.ts) - diff --git a/docs/pages/docs/glossary/terminology.mdx b/docs/pages/docs/glossary/terminology.mdx new file mode 100644 index 00000000..c53da875 --- /dev/null +++ b/docs/pages/docs/glossary/terminology.mdx @@ -0,0 +1,64 @@ +# Terminology + +## Accounts + +Antelope accounts are different compared to other EVM blockchains, and other kinds of blockchains in the space. +You still will be working with a private key, but your private key can be linked to several accounts. + +Here's a quick synopsis from the (Antelope documentation)[https://docs.antelope.io/docs/latest/protocol/accounts_and_permissions/]: + +> An account identifies a participant in an Antelope blockchain. A participant can be an individual or a group depending on the assigned permissions within the account. Accounts also represent the smart contract actors that push and receive actions to and from other accounts in the blockchain. Actions are always contained within transactions. A transaction can be one or more atomic actions. +> Permissions associated with an account are used to authorize actions and transactions to other accounts. Each permission is linked to an authority table which contains a threshold that must be reached in order to allow the action associated with the given permission to be authorized for execution. The following diagram illustrates the relationship between accounts, permissions, and authorities. + +Simply put, an account contains a collection of permissions, and each permission is linked to an authority table to allow certain actions to be exectued. +As mentioned above, a private key can be linked to several accounts, and each account can have different permissions. + +The anatomy of an antelope account is as follows: + +- `name`: The name of the account +- `permissions`: The permissions associated with the account +- `keys`: The keys associated with the account (private and corresponding public keys) + +## Wallets + +There are several wallets that you can use to interact with Antelope blockchains, some of them are: +We recomend using Unicove and Anchor Wallet, as they are the most user friendly wallets. + +- [Unicove](https://unicove.com/) +- [Anchor Wallet](https://www.greymass.com/anchor) +- [TokenPocket](https://www.tokenpocket.pro/) +- [Wombat](https://getwombat.io/) + +## Contracts + +These are the important smart contracts that are used in the Effect Network. +The important contract for developing on Effect Network are: + +- tasks +- token +- vaccount + +With these contracts you can create tasks, and retrieve virtual accounts. + +These are the contracts that are deployed on the Jungle4 testnet for the Effect Network. +[https://jungle4.eosq.eosnation.io/](https://jungle4.eosq.eosnation.io/) + +- tasks: [effecttasks2](https://jungle4.eosq.eosnation.io/account/effecttasks2) +- token: [efxtoken1112](https://jungle4.eosq.eosnation.io/account/efxtoken1112) +- stake: [efxstake1111](https://jungle4.eosq.eosnation.io/account/efxstake1111) +- feepool: [efxfeepool11](https://jungle4.eosq.eosnation.io/account/efxfeepool11) +- proposals: [efxproposals](https://jungle4.eosq.eosnation.io/account/efxproposals) +- vaccount: [efxaccount11](https://jungle4.eosq.eosnation.io/account/efxaccount11) + + +These are the contracts that are depoloyed on the EOS mainnet for the Effect Network. +[https://www.bloks.io/](https://www.bloks.io/) + + +- tasks: [force.efx](https://www.bloks.io/account/force.efx) +- token: [effecttokens](https://www.bloks.io/account/effecttokens) +- stake: [efxstakepool](https://www.bloks.io/account/efxstakepool) +- feepool: [feepool.efx](https://www.bloks.io/account/feepool.efx) +- proposals: [daoproposals](https://www.bloks.io/account/daoproposals) +- vaccount: [vaccount.efx](https://www.bloks.io/account/vaccount.efx) +- dao: [theeffectdao](https://www.bloks.io/account/theeffectdao) diff --git a/docs/pages/docs/glossary/transaction-result.mdx b/docs/pages/docs/glossary/transaction-result.mdx deleted file mode 100644 index c88e86d6..00000000 --- a/docs/pages/docs/glossary/transaction-result.mdx +++ /dev/null @@ -1,26 +0,0 @@ -# Transaction Result - -## Description - -Some functions with the `@effectai/sdk` package will return a `TransactionResult` object. -This object contains the transaction hash and the transaction receipt. - -The interface for the `TransactionResult` object is as follows: - - -```ts -interface TransactResult { - chain: ChainDefinition - request: SigningRequest - resolved: ResolvedSigningRequest | undefined - response?: { [key: string]: any } - revisions: TransactRevisions - signatures: Signature[] - signer: PermissionLevel - transaction: ResolvedTransaction | undefined -} -``` - -Read more about the `TransactionResult` object here: - -https://wharfkit.com/docs/session-kit/transact-result diff --git a/docs/pages/docs/glossary/types.mdx b/docs/pages/docs/glossary/types.mdx index 57056dc1..c27c3f8e 100644 --- a/docs/pages/docs/glossary/types.mdx +++ b/docs/pages/docs/glossary/types.mdx @@ -1,6 +1,103 @@ -# Types [Glossary of Types in effect-js.] +# Types [Glossary of Types in the effect sdk.] ## Campaign [See Type](https://github.com/effectai/effect-js/blob/main/src/types/campaign.ts) +## Client Options + +The ClientOpts interface is used to define the options that can be passed to the EffectAI Client constructor. + +```typescript +interface ClientOpts { + ipfsCacheDurationInMs?: number | null; + fetchProvider?: FetchProviderOptions; + cacheImplementation?: Cache; +} +``` + +As we can see, the ClientOpts interface has three optional properties: + +## `ipfsCacheDurationIMs` + +This property is used to set the cache duration for the IPFS data. + The default value is 600_000 milliseconds; 10 minutes. + +## `fetchProvider` + +This property is used to set the fetch provider. +This is needed because of the different runtimes availalbe to Java Script. +For example, in older versions of Node.js, the fetch API is not available. +For older versions of Node.js, you can use the [`node-fetch` ](https://github.com/node-fetch/node-fetch) package. + +Since Node.js v18.0.0, the fetch API is available by default. + +In the browser fetch is generally available, and is available on the `window.fetch` object. +You can read more about it here: [MDN Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) + +Other serverside Java Script runtimes such as [Bun](https://bun.sh/) and (Deno)[https://deno.com/] already have fetch available on the global `fetch` object. + +## `cacheImplementation` + +This property is used to set the cache implementation. +There are three different cache mechanigms abailable in the EffectAI SDK. +First of all, "IDBCache", "LocalStorageCache", "MemoryCache". +Any of these can be passed to the `cacheImplementation` property while instanlizing the EffectAI Client. + +```typescript +import { createClient, IDBCache, LocalStorageCache, MemoryCache } from '@effectai/sdk' +const client = createClient({ + cacheImplementation: new IDBCache() // or new LocalStorageCache() or new MemoryCache() +}) +``` + +[See Type](https://github.com/effectai/effect-js/blob/main/src/client.ts) + +## Asset + +### Description + +Some functions with the `@effectai/sdk` package will return a `Asset` object. +This object contains information about tokens on the blockchain and contain information such as the symbol, precision, and amount. + +An example for the `Asset` object is as follows: + + +```json +{ + "precision": 4, + "symbol": "EFX", + "units": 10000, + "value": 1 +} +``` + +Read more about the `Asset` object here: +https://wharfkit.com/docs/antelope/asset + +## Transaction Result + +### Description + +Some functions with the `@effectai/sdk` package will return a `TransactionResult` object. +This object contains the transaction hash and the transaction receipt. + +The interface for the `TransactionResult` object is as follows: + + +```ts +interface TransactResult { + chain: ChainDefinition + request: SigningRequest + resolved: ResolvedSigningRequest | undefined + response?: { [key: string]: any } + revisions: TransactRevisions + signatures: Signature[] + signer: PermissionLevel + transaction: ResolvedTransaction | undefined +} +``` + +Read more about the `TransactionResult` object here: + +https://wharfkit.com/docs/session-kit/transact-result diff --git a/docs/pages/docs/tasks/campaigns/create-campaign.mdx b/docs/pages/docs/tasks/campaigns/create-campaign.mdx index c4a7a869..70b0bf40 100644 --- a/docs/pages/docs/tasks/campaigns/create-campaign.mdx +++ b/docs/pages/docs/tasks/campaigns/create-campaign.mdx @@ -62,4 +62,4 @@ response: { **Description:** Returns a transaction response object that contains the transaction id block number, and various properties that correlate to the transaction. -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) diff --git a/docs/pages/docs/templates/introduction.mdx b/docs/pages/docs/templates/introduction.mdx index 94a2826b..909889e9 100644 --- a/docs/pages/docs/templates/introduction.mdx +++ b/docs/pages/docs/templates/introduction.mdx @@ -1,6 +1,67 @@ # Introduction +As described in the previous section, with campaigns, a template is a blueprint that allows you to input data and display it in a specific format. They are the interface used by the workers of EffectAI to interact with the data and perform the tasks required by the client. + +In this section, we will provide an overview of the template engine, explain the basic concepts and components of a template, and guide you through the process of creating your own template. + +We will be creating a simple template that lets users create bounding boxes around objects in an image. This will be done with the help of the open-source data annotation tool called [Label Studio](https://labelstud.io/). + +## What is a Template? + +A template is some HTML, CSS, and JavaScript code that defines the structure and layout of the data that is to be displayed. It's not a standard HTML5 template that uses the HTML specifications. The template engine is custom-built to handle the data that is to be displayed in the template. + +There is an existing HTML document, with a head and body tag defined with the requirements for EffectAI. What we need is to add what you would usually add in the body of the document. + +So the simplest template, which is just a text template, would look like this: + +```html +
+

Hello World!

+
+``` + +This is a simple template that displays the text "Hello World!" in a paragraph tag. But the main issue here is that we still need to load in dynamic data from a data source so that each task is different. + +## Parameterizing Templates: Placeholders + +In order to be able to use the same template for different data, we need to parameterize the template. This means that we need to define placeholders in the template that will be replaced with the actual data when the template is rendered. + +The way this is done in EffectAI is by using the `${}` syntax. This is similar to the way you would use template literals in JavaScript. + +For example, if we want to display the name of a person in the template, we would define a placeholder like this: + +```html +
+

Hello ${name}!

+
+``` + +When the template is rendered, the `${name}` placeholder will be replaced with the actual name of the person. + +## Submitting Templates and Retrieving Results + +So now we understand how to input data into the template, but how do we get results back? Workers on EffectAI will get a rendered template with the data inputted into the template. The worker will then perform the task required by the client and submit the result. + +Submitting is a standard submit event in HTML, but the data is saved in the EffectAI smart contracts. + +Here's an example of a form with an input field and a submit button: + +```html +

Placeholder example: ${placeholder}

+ + +``` + +When we input the text "World" into the text field and submit this, we get the following submission: + +```json +{ + "test": "World" +} +``` + +## Creating Your Own Template + +You can try out the templates for yourself by inputting them into [EffectAI's template preview tool](https://app.effect.network/preview/). -## What is a template? -## Creating Your own template \ No newline at end of file diff --git a/docs/pages/docs/templates/labelstudio.mdx b/docs/pages/docs/templates/labelstudio.mdx new file mode 100644 index 00000000..d5296580 --- /dev/null +++ b/docs/pages/docs/templates/labelstudio.mdx @@ -0,0 +1,46 @@ +# Label Studio example + +Here we will show an example of how to use [Label Studio](https://labelstud.io/) to label images for object detection. + +![Example](/labelstudioocr.png) + +As discussed before we will be using the Label Studio to create a labeling task for object detection. +Here is an example of how to use Label Studio to create a labeling task for object detection. +We have some HTML tags, that contain style sheets, the div that will be the container for Label Studio, library and scripts to initialize Label Studio. + + +## Template +```html +// [!include ~/snippets/templates/index.html] +``` + +## Input Schema + +Note that you can also define the input and output schema for a given template. +This will allow you to define the structure of the data that will be used in the labeling task and the output that will be generated by the annotators. + +{/* TODO figure out how to shorten this schema and make it more readable */} + +```json +// [!include ~/snippets/templates/input_schema.json] +``` +## Example output data + +This is what the output data will look like after the annotators have labeled the images. + +{/* TODO figure out how to shorten this example and make it more readable */} + + +```json +// [!include ~/snippets/templates/example.json] +``` + +## Script + +You can use the following script to initialize Label Studio and create a labeling task for object detection. +This script uses [bun.sh](https://bun.sh/). + +```typescript +// [!include ~/snippets/templates/script.ts] +``` + diff --git a/docs/pages/docs/token/get-balance.mdx b/docs/pages/docs/token/get-balance.mdx index 4bd74da7..8f6141e2 100644 --- a/docs/pages/docs/token/get-balance.mdx +++ b/docs/pages/docs/token/get-balance.mdx @@ -41,4 +41,4 @@ Returns the balance of the account in the form of an Asset object. The asset object has properties that represent the amount and symbol of the balance of the user. Note that the Asset object has a `toString` method that can be used to convert the balance to a string. -You can read more about the: [`Asset` object](/docs/glossary/asset) +You can read more about the: [`Asset` object](/docs/glossary/types#asset) diff --git a/docs/pages/docs/token/swap.mdx b/docs/pages/docs/token/swap.mdx index abaaab4c..5f83ccef 100644 --- a/docs/pages/docs/token/swap.mdx +++ b/docs/pages/docs/token/swap.mdx @@ -20,7 +20,7 @@ Other wallet plugins can be used to sign transactions and can be found at: https ## Output -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) ``` response: { @@ -171,5 +171,5 @@ The direction of the swap. It can be either "UsdtToEfx" or "EfxToUsdt". **Description:** Returns a transaction response object that contains the transaction id block number, and various properties that correlate to the transaction. -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) diff --git a/docs/pages/docs/vaccount/claim.mdx b/docs/pages/docs/vaccount/claim.mdx index 75054196..a1097bdd 100644 --- a/docs/pages/docs/vaccount/claim.mdx +++ b/docs/pages/docs/vaccount/claim.mdx @@ -50,6 +50,6 @@ response: { **Description:** Returns a transaction response object that contains the transaction id block number, and various properties that correlate to the transaction. -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) diff --git a/docs/pages/docs/vaccount/deposit.mdx b/docs/pages/docs/vaccount/deposit.mdx index fb23566e..ac4022c9 100644 --- a/docs/pages/docs/vaccount/deposit.mdx +++ b/docs/pages/docs/vaccount/deposit.mdx @@ -54,6 +54,6 @@ response: { **Description:** Returns a transaction response object that contains the transaction id block number, and various properties that correlate to the transaction. -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) diff --git a/docs/pages/docs/vaccount/payout.mdx b/docs/pages/docs/vaccount/payout.mdx index e7966bde..2f8d593f 100644 --- a/docs/pages/docs/vaccount/payout.mdx +++ b/docs/pages/docs/vaccount/payout.mdx @@ -54,6 +54,6 @@ response: { **Description:** Returns a transaction response object that contains the transaction id block number, and various properties that correlate to the transaction. -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) diff --git a/docs/pages/docs/vaccount/withdraw.mdx b/docs/pages/docs/vaccount/withdraw.mdx index 87b656fc..04d66eeb 100644 --- a/docs/pages/docs/vaccount/withdraw.mdx +++ b/docs/pages/docs/vaccount/withdraw.mdx @@ -51,6 +51,6 @@ response: { **Description:** Returns a transaction response object that contains the transaction id block number, and various properties that correlate to the transaction. -Read more about the transaction response here: [TransactionResponse](/docs/glossary/transaction-result.mdx) +Read more about the transaction response here: [TransactionResponse](/docs/glossary/types#transaction-result) diff --git a/docs/public/effect_template_placeholder_example.png b/docs/public/effect_template_placeholder_example.png new file mode 100644 index 00000000..fb898a55 Binary files /dev/null and b/docs/public/effect_template_placeholder_example.png differ diff --git a/docs/public/labelstudioocr.png b/docs/public/labelstudioocr.png new file mode 100644 index 00000000..c1a45b98 Binary files /dev/null and b/docs/public/labelstudioocr.png differ diff --git a/docs/sidebar.ts b/docs/sidebar.ts index f0bbbda5..1fb2f922 100644 --- a/docs/sidebar.ts +++ b/docs/sidebar.ts @@ -34,10 +34,15 @@ export const sidebar = { }, { text: "Templates", - items: [{ text: "introduction", link: "/docs/templates/introduction" }], + items: [ + { text: "Introduction", link: "/docs/templates/introduction" }, + { text: "Label-Studio", link: "/docs/templates/labelstudio" }, + ], }, + { text: "SDK API", + collapsed: true, items: [ { text: "Tasks", @@ -104,9 +109,8 @@ export const sidebar = { { text: "Glossary", items: [ - { text: "Client Options", link: "/docs/glossary/client-options" }, - { text: "TransactResult", link: "/docs/glossary/transaction-result" }, - { text: "Asset", link: "/docs/glossary/asset" }, + { text: "Terminology", link: "/docs/glossary/terminology" }, + { text: "Types", link: "/docs/glossary/types" }, ], }, { diff --git a/docs/snippets/templates/example.json b/docs/snippets/templates/example.json new file mode 100644 index 00000000..e1623c33 --- /dev/null +++ b/docs/snippets/templates/example.json @@ -0,0 +1,86 @@ +{ + "id": 1, + "created_at": "2021-03-09T21:52:49.513742Z", + "updated_at": "2021-03-09T22:16:08.746926Z", + "project": 83, + + "data": { + "image": "https://example.com/opensource/label-studio/1.jpg" + }, + + "annotations": [ + { + "id": "1001", + "result": [ + { + "from_name": "tag", + "id": "Dx_aB91ISN", + "source": "$image", + "to_name": "img", + "type": "rectanglelabels", + "value": { + "height": 10.458911419423693, + "rectanglelabels": ["Moonwalker"], + "rotation": 0, + "width": 12.4, + "x": 50.8, + "y": 5.869797225186766 + } + } + ], + "was_cancelled": false, + "ground_truth": false, + "created_at": "2021-03-09T22:16:08.728353Z", + "updated_at": "2021-03-09T22:16:08.728378Z", + "lead_time": 4.288, + "result_count": 0, + "task": 1, + "completed_by": 10 + } + ], + + "predictions": [ + { + "created_ago": "3 hours", + "model_version": "model 1", + "result": [ + { + "from_name": "tag", + "id": "t5sp3TyXPo", + "source": "$image", + "to_name": "img", + "type": "rectanglelabels", + "value": { + "height": 11.612284069097889, + "rectanglelabels": ["Moonwalker"], + "rotation": 0, + "width": 39.6, + "x": 13.2, + "y": 34.702495201535505 + } + } + ] + }, + { + "created_ago": "4 hours", + "model_version": "model 2", + "result": [ + { + "from_name": "tag", + "id": "t5sp3TyXPo", + "source": "$image", + "to_name": "img", + "type": "rectanglelabels", + "value": { + "height": 33.61228406909789, + "rectanglelabels": ["Moonwalker"], + "rotation": 0, + "width": 39.6, + "x": 13.2, + "y": 54.702495201535505 + } + } + ] + } + ] +} diff --git a/docs/snippets/templates/index.html b/docs/snippets/templates/index.html new file mode 100644 index 00000000..bcb1fbbe --- /dev/null +++ b/docs/snippets/templates/index.html @@ -0,0 +1,134 @@ + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/docs/snippets/templates/input_schema.json b/docs/snippets/templates/input_schema.json new file mode 100644 index 00000000..51345b6f --- /dev/null +++ b/docs/snippets/templates/input_schema.json @@ -0,0 +1,93 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "result": { + "type": "array", + "items": { + "type": "object", + "properties": { + "original_width": { + "type": "integer" + }, + "original_height": { + "type": "integer" + }, + "image_rotation": { + "type": "integer" + }, + "value": { + "type": "object", + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + }, + "width": { + "type": "number" + }, + "height": { + "type": "number" + }, + "rotation": { + "type": "integer" + }, + "text": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["x", "y", "width", "height", "rotation"] + }, + "from_name": { + "type": "string" + }, + "to_name": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "original_width", + "original_height", + "image_rotation", + "value", + "from_name", + "to_name", + "type" + ] + } + } + }, + "required": ["id", "result"] + } + }, + "data": { + "type": "object", + "properties": { + "image": { + "type": "string" + } + }, + "required": ["image"] + } + }, + "required": ["id", "annotations", "data"] +} diff --git a/docs/snippets/templates/script.ts b/docs/snippets/templates/script.ts new file mode 100644 index 00000000..a18dc3fb --- /dev/null +++ b/docs/snippets/templates/script.ts @@ -0,0 +1,44 @@ +import { WalletPluginPrivateKey } from "@wharfkit/wallet-plugin-privatekey"; +import { + createClient, + createCampaign, + eos, + Session, + type CreateCampaignArgs, +} from "@effectai/sdk"; + +const campaignFile = Bun.file("index.html"); +const inputSchema = Bun.file("input-schema.json"); +const exampleTask = Bun.file("example.json"); + +const session = new Session({ + chain: eos, + actor: "your_account", + permission: "your_permission", + walletPlugin: new WalletPluginPrivateKey("your_private_key"), +}); + +const client = await createClient({ session }); + +const campaign: CreateCampaignArgs = { + client: client, + campaign: { + category: "category", + description: "Description for this Campaign", + estimated_time: 1, + example_task: exampleTask.toString(), + image: "image", + instructions: "Instructions for this Camapign", + input_schema: inputSchema.toString(), + output_schema: null, + template: campaignFile.toString(), + title: "Title for this Campaign", + version: 1, + reward: 1, + maxTaskTime: 1, + qualitications: [], + }, +}; + +const response = createCampaign(campaign); +console.debug(response); diff --git a/src/actions/tasks/campaigns/getCampaigns.ts b/src/actions/tasks/campaigns/getCampaigns.ts index 2b2faa0b..21cd7ade 100644 --- a/src/actions/tasks/campaigns/getCampaigns.ts +++ b/src/actions/tasks/campaigns/getCampaigns.ts @@ -11,8 +11,8 @@ export type CampaignInfo = { example_task: string; image: string; instructions: string; - input_schema: null; - output_schema: null; + input_schema: string | null; + output_schema: string | null; template: string; title: string; version: number;