Skip to content

Commit

Permalink
feat: add airdrop related transaction types (#1433)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Viénot <[email protected]>
  • Loading branch information
svienot authored Oct 17, 2024
1 parent 3c59148 commit 40fe4eb
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 117 deletions.
9 changes: 0 additions & 9 deletions src/components/transaction/TransactionFilterSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export default defineComponent({
},
setup(props, context) {
const isAirdropEnabled = import.meta.env.VITE_APP_ENABLE_AIRDROP === 'true'
const makeFilterLabel = (filterValue: string): string => {
return filterValue == "" ? "TYPES: ALL" : makeTypeLabel(filterValue as TransactionType)
}
Expand Down Expand Up @@ -93,13 +91,6 @@ export default defineComponent({
|| el ===TransactionType.TOKENDELETION;
})
}
if (!isAirdropEnabled) {
result = result.filter(el => {
return el !== TransactionType.TOKENAIRDROP
&& el !== TransactionType.TOKENCANCELAIRDROP
&& el !== TransactionType.TOKENCLAIMAIRDROP;
})
}
result.splice(0, 0, "")
return result
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/transaction/TransactionSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ import TokenExtra from "@/components/values/link/TokenExtra.vue";
const GRAPH_TRANSACTION_TYPES = [
TransactionType.CRYPTOTRANSFER,
TransactionType.TOKENBURN,
TransactionType.TOKENMINT
TransactionType.TOKENMINT,
TransactionType.TOKENREJECT,
TransactionType.TOKENAIRDROP,
TransactionType.TOKENCLAIMAIRDROP
]

export default defineComponent({
Expand Down
60 changes: 0 additions & 60 deletions tests/unit/account/AccountDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ describe("AccountDetails.vue", () => {
const ALIAS_HEX = "0x12200000fc0634e2ab455eff393f04819efa262fe5e6ab1c7ed1d4f85fbcd8e6e296"

it("Should display account details", async () => {
process.env = Object.assign(process.env, {VITE_APP_ENABLE_AIRDROP: true});

await router.push("/") // To avoid "missing required param 'network'" error

const mock = new MockAdapter(axios);
Expand Down Expand Up @@ -487,62 +485,4 @@ describe("AccountDetails.vue", () => {
wrapper.unmount()
await flushPromises()
});

it("Should filter transaction types when VITE_APP_ENABLE_AIRDROP not set ", async () => {
process.env = Object.assign(process.env, {VITE_APP_ENABLE_AIRDROP: false});

await router.push("/") // To avoid "missing required param 'network'" error

const mock = new MockAdapter(axios);

const matcher1 = "/api/v1/accounts/" + SAMPLE_ACCOUNT.account
mock.onGet(matcher1).reply(200, SAMPLE_ACCOUNT);

const matcher2 = "/api/v1/transactions"
mock.onGet(matcher2).reply(200, SAMPLE_TRANSACTIONS);

const matcher9 = "/api/v1/accounts/" + SAMPLE_ACCOUNT.account + "/allowances/crypto"
mock.onGet(matcher9).reply(200, {rewards: []})

const matcher10 = "/api/v1/accounts/" + SAMPLE_ACCOUNT.account + "/allowances/tokens"
mock.onGet(matcher10).reply(200, {rewards: []})

const matcher11 = "/api/v1/accounts/" + SAMPLE_ACCOUNT.account + "/allowances/nfts"
mock.onGet(matcher11).reply(200, {nfts: []})

const matcher12 = "api/v1/tokens"
mock.onGet(matcher12).reply(200, { tokens: [] });

const matcher13 = "api/v1/accounts/" + SAMPLE_ACCOUNT.account + "/nfts"
mock.onGet(matcher13).reply(200, { nfts: [] });

const wrapper = mount(AccountDetails, {
global: {
plugins: [router, Oruga]
},
props: {
accountId: SAMPLE_ACCOUNT.account ?? undefined
},
});

await flushPromises()
// console.log(wrapper.html())

const select = wrapper.findComponent(TransactionFilterSelect)
expect(select.exists()).toBe(true)
expect(select.text()).toBe(
"TYPES: ALLCONTRACT CALLCONTRACT CREATECONTRACT DELETECONTRACT UPDATECRYPTO ADD LIVE HASHCRYPTO " +
"APPROVE ALLOWANCECRYPTO CREATE ACCOUNTCRYPTO DELETE ACCOUNTCRYPTO DELETE ALLOWANCE" +
"CRYPTO DELETE LIVE HASHCRYPTO TRANSFERCRYPTO UPDATE ACCOUNTETHEREUM TRANSACTIONFILE APPEND" +
"FILE CREATEFILE DELETEFILE UPDATEFREEZEHCS CREATE TOPICHCS DELETE TOPICHCS SUBMIT MESSAGE" +
"HCS UPDATE TOPICNODE CREATENODE DELETENODE STAKE UPDATENODE UPDATEPSEUDORANDOM NUMBER GENERATE" +
"SCHEDULE CREATESCHEDULE DELETESCHEDULE SIGNSYSTEM DELETESYSTEM UNDELETETOKEN ASSOCIATE" +
"TOKEN BURNTOKEN CREATETOKEN DELETETOKEN DISSOCIATE" +
"TOKEN FEE SCHEDULE UPDATETOKEN FREEZETOKEN KYC GRANTTOKEN KYC REVOKETOKEN MINTTOKEN PAUSE" +
"TOKEN REJECTTOKEN UNFREEZETOKEN UNPAUSETOKEN UPDATETOKEN UPDATE NFTSTOKEN WIPEUNCHECKED SUBMIT")

mock.restore()
wrapper.unmount()
await flushPromises()
});
});
2 changes: 0 additions & 2 deletions tests/unit/token/NftDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ HMSF.forceUTC = true
describe("NftDetails.vue", () => {

it("Should display details of NFT", async () => {
process.env = Object.assign(process.env, {VITE_APP_ENABLE_AIRDROP: true});

await router.push("/") // To avoid "missing required param 'network'" error

const mock = new MockAdapter(axios);
Expand Down
45 changes: 0 additions & 45 deletions tests/unit/transaction/Transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ describe("Transactions.vue", () => {

test("no props", async () => {

process.env = Object.assign(process.env, {VITE_APP_ENABLE_AIRDROP: true});

await router.push("/") // To avoid "missing required param 'network'" error

const mock = new MockAdapter(axios)
Expand Down Expand Up @@ -196,47 +194,4 @@ describe("Transactions.vue", () => {
await flushPromises()
});

test("type selector takes VITE_APP_ENABLE_AIRDROP into account", async () => {

process.env = Object.assign(process.env, {VITE_APP_ENABLE_AIRDROP: false});

await router.push("/") // To avoid "missing required param 'network'" error

const mock = new MockAdapter(axios)

const matcher1 = "/api/v1/transactions"
mock.onGet(matcher1).reply(200, SAMPLE_TRANSACTIONS)

const matcher2 = "/api/v1/tokens/" + SAMPLE_TOKEN.token_id
mock.onGet(matcher2).reply(200, SAMPLE_TOKEN)

const wrapper = mount(Transactions, {
global: {
plugins: [router, Oruga]
},
props: {},
});

await flushPromises()
// console.log(wrapper.text())

const select = wrapper.findComponent(TransactionFilterSelect)
expect(select.exists()).toBe(true)
expect(select.text()).toBe(
"TYPES: ALLCONTRACT CALLCONTRACT CREATECONTRACT DELETECONTRACT UPDATECRYPTO ADD LIVE HASH" +
"CRYPTO APPROVE ALLOWANCECRYPTO CREATE ACCOUNTCRYPTO DELETE ACCOUNTCRYPTO DELETE ALLOWANCE" +
"CRYPTO DELETE LIVE HASHCRYPTO TRANSFERCRYPTO UPDATE ACCOUNTETHEREUM TRANSACTIONFILE APPEND" +
"FILE CREATEFILE DELETEFILE UPDATEFREEZEHCS CREATE TOPICHCS DELETE TOPICHCS SUBMIT MESSAGE" +
"HCS UPDATE TOPICNODE CREATENODE DELETENODE STAKE UPDATENODE UPDATEPSEUDORANDOM NUMBER GENERATE" +
"SCHEDULE CREATESCHEDULE DELETESCHEDULE SIGNSYSTEM DELETESYSTEM UNDELETE" +
"TOKEN ASSOCIATETOKEN BURNTOKEN CREATETOKEN DELETE" +
"TOKEN DISSOCIATETOKEN FEE SCHEDULE UPDATETOKEN FREEZETOKEN KYC GRANTTOKEN KYC REVOKE" +
"TOKEN MINTTOKEN PAUSETOKEN REJECTTOKEN UNFREEZETOKEN UNPAUSETOKEN UPDATETOKEN UPDATE NFTS" +
"TOKEN WIPEUNCHECKED SUBMIT")

mock.restore()
wrapper.unmount()
await flushPromises()
});

});

0 comments on commit 40fe4eb

Please sign in to comment.