Skip to content

Commit

Permalink
feat: token airdrop transactios (#2492)
Browse files Browse the repository at this point in the history
* feat: add Airdrop Transaction

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test(wip): unit tests

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: use interface for AccountAmount protobuf

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: remove circular dependancy

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: RenameTokenTransfer list to TokenTransfer

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: rename token transfer and add expected decimals

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove redundant code

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: finished unit tests

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: correct return type for amount

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: correct return for fromProtobuf

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: add missing methods

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: use already implemented interfaces and classes

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: transfer transaction and airdrop transaction

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: add logid and execute

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: add integration tests

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: add pending airdrop to rectord

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: add nft transfers to all test cases

Signed-off-by: Ivaylo Nikolov <[email protected]>

* chore: remove unused files for airdrop

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove circular dependancy and unused import

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove duplicated property

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: rename pendngairdroprecord

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove unused files

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: rename AirdropTokenTransaction

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: add additional tests

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: rename file reference

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: check if newPendingAirdrops is empty for auto associated test

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove comment lines

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: remove get receipt line because we call get record

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: should be able to airdrop when receiver sig set to true

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: rename AbstractTokenTransfer

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: Token Claim and Cancel Transaction (#2499)

* feat: add airdrop claim and cancel transactions

Signed-off-by: Ivaylo Nikolov <[email protected]>

* chore: update protobufs

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: update commit messages

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: add unit tests for cancel and claim

Signed-off-by: Ivaylo Nikolov <[email protected]>

* wip(test): add integration tests for cancel and claim transactions

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: claim used the wrong channel function

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: rename transaction name

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove claim references in airdropcancel integration test

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test(fix): fix not working test for airdrop cancel and claim

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: airdropcancel transaction should work on sender not receiver

Signed-off-by: Ivaylo Nikolov <[email protected]>

* feat: add token airdrop example

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: rename transactions to have the same name as java

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: remove redundant imports and empty lines

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: rename transaction tests  to have the same name as java sdk

Signed-off-by: Ivaylo Nikolov <[email protected]>

* docs: add licenses

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix: remove dead code from token cancel

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: consistency in constructor

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: change airdrop_supply_per_person naming

Signed-off-by: Ivaylo Nikolov <[email protected]>

* test: fix setting sender id

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: specify what kind of tokens are airdropped

Signed-off-by: Ivaylo Nikolov <[email protected]>

---------

Signed-off-by: Ivaylo Nikolov <[email protected]>

* fix(test): when empty id should be null

Signed-off-by: Ivaylo Nikolov <[email protected]>

* refactor: should return always in jsdoc

Signed-off-by: Ivaylo Nikolov <[email protected]>

---------

Signed-off-by: Ivaylo Nikolov <[email protected]>
Signed-off-by: ivaylogarnev-limechain <[email protected]>
  • Loading branch information
ivaylonikolov7 authored and ivaylogarnev-limechain committed Sep 19, 2024
1 parent 0b3d708 commit 1cfffec
Show file tree
Hide file tree
Showing 20 changed files with 3,720 additions and 540 deletions.
419 changes: 419 additions & 0 deletions examples/token-airdrop-example.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/proto/src/proto
47 changes: 47 additions & 0 deletions src/Status.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,14 @@ export default class Status {
return "PENDING_NFT_AIRDROP_ALREADY_EXISTS";
case Status.AccountHasPendingAirdrops:
return "ACCOUNT_HAS_PENDING_AIRDROPS";
case Status.ThrottledAtConsensus:
return "THROTTLED_AT_CONSENSUS";
case Status.InvalidPendingAirdropId:
return "INVALID_PENDING_AIRDROP_ID";
case Status.TokenAirdropWithFallbackRoyalty:
return "TOKEN_AIRDROP_WITH_FALLBACK_ROYALTY";
case Status.InvalidTokenInPendingAirdrop:
return "INVALID_TOKEN_IN_PENDING_AIRDROP";
default:
return `UNKNOWN (${this._code})`;
}
Expand Down Expand Up @@ -1349,6 +1357,14 @@ export default class Status {
return Status.PendingNftAirdropAlreadyExists;
case 365:
return Status.AccountHasPendingAirdrops;
case 366:
return Status.ThrottledAtConsensus;
case 367:
return Status.InvalidPendingAirdropId;
case 368:
return Status.TokenAirdropWithFallbackRoyalty;
case 369:
return Status.InvalidTokenInPendingAirdrop;
default:
throw new Error(
`(BUG) Status.fromCode() does not handle code: ${code}`,
Expand Down Expand Up @@ -3030,3 +3046,34 @@ Status.PendingNftAirdropAlreadyExists = new Status(364);
* this transaction.
*/
Status.AccountHasPendingAirdrops = new Status(365);

/**
* Consensus throttle did not allow execution of this transaction.<br/>
* The transaction should be retried after a modest delay.
*/
Status.ThrottledAtConsensus = new Status(366);

/**
* The provided pending airdrop id is invalid.<br/>
* This pending airdrop MAY already be claimed or cancelled.
* <p>
* The client SHOULD query a mirror node to determine the current status of
* the pending airdrop.
*/
Status.InvalidPendingAirdropId = new Status(367);

/**
* The token to be airdropped has a fallback royalty fee and cannot be
* sent or claimed via an airdrop transaction.
*/
Status.TokenAirdropWithFallbackRoyalty = new Status(368);

/**
* This airdrop claim is for a pending airdrop with an invalid token.<br/>
* The token might be deleted, or the sender may not have enough tokens
* to fulfill the offer.
* <p>
* The client SHOULD query mirror node to determine the status of the pending
* airdrop and whether the sender can fulfill the offer.
*/
Status.InvalidTokenInPendingAirdrop = new Status(369);
Loading

0 comments on commit 1cfffec

Please sign in to comment.