Skip to content

Commit

Permalink
Merge pull request #261 from ultraio/feature/BLOCK-2613-add-airgrab-c…
Browse files Browse the repository at this point in the history
…ontract

[BLOCK-2613] Add airgrab contract and update avatar contract
  • Loading branch information
Adam-Ultra authored Jan 2, 2025
2 parents aa57f1d + 8f6bdcd commit 95a25a4
Show file tree
Hide file tree
Showing 18 changed files with 756 additions and 56 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const navbar: DefaultTheme.NavItem[] = [
{ text: 'Uniq Factories', link: '/tutorials/uniq-factories/index' },
{ text: 'Token Swap', link: '/tutorials/token-swap/index' },
{ text: 'Fungitable Token', link: '/tutorials/token/index' },
{ text: 'Airgrab', link: '/tutorials/airgrab/index' },
],
},
],
Expand Down
44 changes: 44 additions & 0 deletions docs/.vitepress/sidebars/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ const sidebar: { [key: string]: DefaultTheme.SidebarItem[] } = {
items: getMarkdownFiles('/tutorials/substreams'),
collapsed: true,
},
{
text: 'Airgrab',
items: getMarkdownFiles('/tutorials/airgrab'),
collapsed: true,
},
],
'/tutorials/general': [
{
Expand Down Expand Up @@ -347,6 +352,21 @@ const sidebar: { [key: string]: DefaultTheme.SidebarItem[] } = {
items: getMarkdownFiles('/tutorials/substreams'),
},
],
'/tutorials/airgrab': [
{
text: 'Tutorials',
items: [
{
text: '< Go Back to Tutorials',
link: '/tutorials/index/index',
},
],
},
{
text: 'Aigrab',
items: getMarkdownFiles('/tutorials/airgrab'),
},
],
// ################
// Game Developers
// ################
Expand Down Expand Up @@ -580,6 +600,30 @@ const sidebar: { [key: string]: DefaultTheme.SidebarItem[] } = {
],
collapsed: true,
},
{
text: 'Avatar Contract',
items: [
...getMarkdownFiles('/blockchain/contracts/avatar-contract'),
{
text: 'Actions',
items: getMarkdownFiles('/blockchain/contracts/avatar-contract/avatar-actions'),
collapsed: true,
},
],
collapsed: true,
},
{
text: 'Airgrab Contract',
items: [
...getMarkdownFiles('/blockchain/contracts/airgrab-contract'),
{
text: 'Actions',
items: getMarkdownFiles('/blockchain/contracts/airgrab-contract/airgrab-actions'),
collapsed: true,
},
],
collapsed: true,
},
],
'/feedback/index': [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: 'claimrewards'
order: 2

---

# claimrewards

## Summary

This action will allow user to claim reward from `campaign` using their whitelisted wallets.

## Action Parameters

| Property Name | C++ Type | JavaScript Type | Description |
| ------------- | --------------------- | --------------- | ---------------------------------------------------------------------------- |
| `campaign` | eosio::name | String | The name of the campaign |
| `wallet_id` | std::vector\<uint8_t> | String | The wallet owned by the user which is registered in the campaign's whitelist |

Required Permissions: `user`

## CLI - cleos

```shell script
cleos push action ultra.rgrab claimrewards '["testcampaign", "448e3de41c8b52750c664f57fe023a730bcc0047"]' -p user
```

## Javascript - eosjs

```typescript
(async () => {
const result = await api.transact(
{
actions: [
{
account: 'ultra.rgrab',
name: 'claimrewards',
authorization: [
{
actor: 'user',
permission: 'active',
},
],
data: {
campaign: 'testcampaign',
wallet_id: '448e3de41c8b52750c664f57fe023a730bcc0047'
},
},
],
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
})();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: 'closecampgn'
order: 3

---

# closecampgn

## Summary

This action will allow `manager` to remove all whitelist users from `campaign`, and once whitelist is empty, `campaign` will be deleted.
If campaign have a large whitelist, this action might fail when trying to remove users.

## Action Parameters

| Property Name | C++ Type | JavaScript Type | Description |
| ------------- | ----------- | --------------- | --------------------------------------------------------------------------------------------------------- |
| `campaign` | eosio::name | String | The name of the campaign |
| `manager` | eosio::name | String | The account that will act as manager of the campaign |
| `limit` | uint32_t | Number | How many whitelist users to remove from the campaign. If 0, try to remove all entries and delete campaign |

Required Permissions: `manager`

## CLI - cleos

```shell script
cleos push action ultra.rgrab closecampgn '["testcampaign", "manager", 0]' -p manager
```

## Javascript - eosjs

```typescript
(async () => {
const result = await api.transact(
{
actions: [
{
account: 'ultra.rgrab',
name: 'closecampgn',
authorization: [
{
actor: 'manager',
permission: 'active',
},
],
data: {
campaign: 'testcampaign',
manager: 'manager',
limit: 0
},
},
],
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
})();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: 'createcampgn'
order: 0

---

# createcampgn

## Summary

This action will allow `manager` to create a new `campaign`

## Action Parameters

| Property Name | C++ Type | JavaScript Type | Description |
| ------------- | ----------- | --------------- | ---------------------------------------------------- |
| `campaign` | eosio::name | String | The name of the campaign |
| `manager` | eosio::name | String | The account that will act as manager of the campaign |

Required Permissions: `manager`

## CLI - cleos

```shell script
cleos push action ultra.rgrab createcampgn '["testcampaign", "manager"]' -p manager
```

## Javascript - eosjs

```typescript
(async () => {
const result = await api.transact(
{
actions: [
{
account: 'ultra.rgrab',
name: 'createcampgn',
authorization: [
{
actor: 'manager',
permission: 'active',
},
],
data: {
campaign: 'testcampaign',
manager: 'manager'
},
},
],
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
})();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 'on_transfer'
order: 4

---

# on_transfer

## Summary

This is a notify action which will trigger when `manager` do a token transfer to `ultra.rgrab` with memo that follow the format of `<CampaignName>,<TotalCampaignPoints>,<Deadline>` with `Deadline` in block number. For example: `'testcampaign,10,10003123'`

## Action Parameters

Please refer to [token transfer action](../../token-contract/token-actions/transfer.md).

## CLI - cleos

```shell script
cleos push action eosio.token transfer '["manager", "ultra.rgrab", "1000.00000000 UOS", "testcampaign,10,10003123"]' -p manager
```

## Javascript - eosjs

```typescript
(async () => {
const result = await api.transact(
{
actions: [
{
account: 'eosio.token',
name: 'transfer',
authorization: [
{
actor: 'manager',
permission: 'active',
},
],
data: {
from: 'manager',
to: 'ultra.rgrab',
quantity: '1000.00000000 UOS',
memo: 'testcampaign,10,10003123',
},
},
],
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
})();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: 'whitelistusr'
order: 1

---

# whitelistusr

## Summary

This action will allow `manager` to whitelist user wallet and updating their points to be used for claiming rewards.

## Action Parameters

| Property Name | C++ Type | JavaScript Type | Description |
| ------------- | ----------------------- | --------------- | ---------------------------------------------------------------------------------- |
| `campaign` | eosio::name | String | The name of the campaign |
| `wallets` | std::vector\<whitelist> | Object | The whitelist user wallets, can be ultra wallet (8 bytes) or eth wallet (20 bytes) |

Required Permissions: `manager`

## CLI - cleos

```shell script
cleos push action ultra.rgrab whitelistusr '["testcampaign", [{"90a7a60819855c34", 1}, {"448e3de41c8b52750c664f57fe023a730bcc0047", 2}]]' -p manager
```

## Javascript - eosjs

```typescript
(async () => {
const result = await api.transact(
{
actions: [
{
account: 'ultra.rgrab',
name: 'whitelistusr',
authorization: [
{
actor: 'manager',
permission: 'active',
},
],
data: {
campaign: 'testcampaign',
wallets: [
{
wallet_id: '90a7a60819855c34',
points: 1
},
{
wallet_id: '448e3de41c8b52750c664f57fe023a730bcc0047',
points: 2
}
]
},
},
],
},
{
blocksBehind: 3,
expireSeconds: 30,
}
);
})();
```
Loading

0 comments on commit 95a25a4

Please sign in to comment.