Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic - allowances #641

Merged
merged 118 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
a5bdc31
initial allowances page
ezra-sg Oct 6, 2023
4062857
remove bun lock
ezra-sg Oct 16, 2023
21d62de
Merge branch 'develop' of github.com:telosnetwork/telos-wallet into e…
ezra-sg Oct 18, 2023
d5b836a
initial allowances page
ezra-sg Oct 6, 2023
94947e5
add fixtures
ezra-sg Oct 12, 2023
9f3ba17
Add type guards
ezra-sg Oct 12, 2023
4f28d7f
WIP asset column cell
ezra-sg Oct 12, 2023
88ae8d7
missed file
ezra-sg Oct 12, 2023
2476a73
add erc721 preview
ezra-sg Oct 13, 2023
d39c431
add nft collection stack
ezra-sg Oct 13, 2023
e8a6d0e
remove bun lock
ezra-sg Oct 16, 2023
6e23915
fix all NFT videos being loaded
ezra-sg Oct 16, 2023
11a16fa
add loading state
ezra-sg Oct 16, 2023
4d3bbe9
add fiat value column
ezra-sg Oct 16, 2023
e6271b9
add allowance column text
ezra-sg Oct 16, 2023
7d1728a
add spender address link
ezra-sg Oct 17, 2023
6b32161
add type badge
ezra-sg Oct 17, 2023
34e9baa
cleanup date utils, add date column
ezra-sg Oct 17, 2023
c3b8994
add table controls, improve table controls aria
ezra-sg Oct 17, 2023
8e7ce54
add more mock data
ezra-sg Oct 17, 2023
e91e86d
add pagination
ezra-sg Oct 18, 2023
3eb54c5
finish todos
ezra-sg Oct 18, 2023
bd43200
cleanup
ezra-sg Oct 18, 2023
40bac5c
use constant instead of magic string
ezra-sg Oct 24, 2023
2749a49
Merge branch 'develop' of github.com:telosnetwork/telos-wallet into e…
ezra-sg Nov 15, 2023
25a26ec
Merge branch 'epic-allowances' of github.com:telosnetwork/telos-walle…
ezra-sg Nov 15, 2023
503458e
WIP implement allowances store
ezra-sg Nov 16, 2023
bde37c3
implement allowance amount sort
ezra-sg Nov 16, 2023
939e9b8
fix balance comparison, add asset quantity sort
ezra-sg Nov 16, 2023
43944e9
add spender name sort
ezra-sg Nov 16, 2023
89c1a3e
add asset type sort and last updated sort
ezra-sg Nov 16, 2023
cfb4e36
add sort by fiat value
ezra-sg Nov 20, 2023
4c6ce19
cleanup
ezra-sg Nov 20, 2023
bacfa6b
WIP implement fetch allowances
ezra-sg Nov 21, 2023
060bb2b
first pass at adding row shape utils
ezra-sg Nov 22, 2023
8df2fc7
(broken) updating concurrency approach
ezra-sg Nov 23, 2023
89de992
fix row shaping logic and concurrency
ezra-sg Nov 24, 2023
3f99f5e
cleanup
ezra-sg Nov 24, 2023
c69915e
WIP show real allowances
ezra-sg Nov 24, 2023
d2d36eb
fix unnecessary ipfs calls, switch ipfs gateway
ezra-sg Nov 24, 2023
6891cf0
fix race condition for collection NFTs
ezra-sg Nov 24, 2023
d2e4150
WIP enable sorting
ezra-sg Nov 24, 2023
1f01d44
implement column sorting
ezra-sg Nov 28, 2023
14acae6
implement includes cancelled allowances toggle
ezra-sg Nov 28, 2023
a67b889
fix balance bug, fix allowance bug
ezra-sg Nov 28, 2023
d0bdaaf
update wording
ezra-sg Nov 28, 2023
9007b71
cleanup, refresh allowances on timer
ezra-sg Nov 28, 2023
6460b40
fix tiny allowance text
ezra-sg Nov 28, 2023
dd8a8dd
fix tiny allowance text 2
ezra-sg Nov 28, 2023
3c38000
cleanup
ezra-sg Nov 28, 2023
29148bb
cleanup
ezra-sg Nov 28, 2023
7e65941
tweak tooltips and decimal display
ezra-sg Nov 30, 2023
20ef623
fix erc1155 token lookup
ezra-sg Nov 30, 2023
749a878
Merge branch 'develop' of github.com:telosnetwork/telos-wallet into 6…
ezra-sg Nov 30, 2023
50a92a5
fix supported interfaces issue
ezra-sg Nov 30, 2023
d69b90b
add search filtering
ezra-sg Nov 30, 2023
c20e943
fix string matching issue
ezra-sg Dec 1, 2023
858516c
cleanup
ezra-sg Dec 1, 2023
4a8ed02
Merge branch 'develop' of github.com:telosnetwork/telos-wallet into e…
ezra-sg Dec 1, 2023
52a11ae
Merge branch 'epic-allowances' into 604-view-allowances-api-integration
ezra-sg Dec 1, 2023
c9985ea
add revoke selected checkboxes
ezra-sg Dec 4, 2023
32bff20
add edit button, truncate asset number
ezra-sg Dec 4, 2023
17cdd82
WIP add edit allowance modal
ezra-sg Dec 5, 2023
3998ba5
replace huge with unlimited allowance everywhere
ezra-sg Dec 5, 2023
197611b
WIP add currency input
ezra-sg Dec 6, 2023
4facb88
fix currency input failing to display nonzero starting value
ezra-sg Dec 6, 2023
ce3d407
fix currency input symbol by putting it in label
ezra-sg Dec 6, 2023
6c5e14a
styling
ezra-sg Dec 6, 2023
abf0fef
cleanup
ezra-sg Dec 7, 2023
ebea377
handle uint256 too large for currency input
ezra-sg Dec 7, 2023
24a30fc
cleanup
ezra-sg Dec 7, 2023
e97262f
cleanup
ezra-sg Dec 7, 2023
7ffb331
fix label text for currency input
ezra-sg Dec 7, 2023
dac1f46
snaps
ezra-sg Dec 7, 2023
a35ef6c
update checkbox toggling logic
ezra-sg Dec 7, 2023
3ee3ad1
fix bug where zero balance tokens would not show in allowances list
ezra-sg Dec 7, 2023
49a89e9
cleanup
ezra-sg Dec 7, 2023
48bfa3c
Merge pull request #706 from telosnetwork/604-view-allowances-api-int…
donnyquixotic Dec 8, 2023
3bd323d
Merge branch '604-view-allowances-api-integration' into 605-revoke-al…
ezra-sg Dec 8, 2023
8cfb48e
Merge branch 'epic-allowances' of github.com:telosnetwork/telos-walle…
ezra-sg Dec 8, 2023
a25842d
remove unlimited tooltip from modal
ezra-sg Dec 14, 2023
889e536
cleanup
ezra-sg Dec 14, 2023
a79c5c9
Merge pull request #711 from telosnetwork/605-revoke-allowances-ui
donnyquixotic Dec 15, 2023
a2918b0
Merge branch 'develop' of github.com:telosnetwork/telos-wallet into e…
ezra-sg Dec 15, 2023
d63f703
add single erc20 allowance update capability
ezra-sg Dec 8, 2023
73179c7
add single erc721 approval capability
ezra-sg Dec 8, 2023
b4546a9
WIP add collection set approval
ezra-sg Dec 11, 2023
bf9aac2
finish adding nft collection allowance edit
ezra-sg Dec 11, 2023
d0e1d7e
cleanup, fix pagination
ezra-sg Dec 12, 2023
adf929b
integrate revoke button with table rows
ezra-sg Dec 12, 2023
d8f5ddb
WIP add batch revoke
ezra-sg Dec 12, 2023
6f86b14
fix allowance response handling when there are no erc721 results
ezra-sg Dec 12, 2023
de4b6e2
UX enhancements
ezra-sg Dec 13, 2023
4c87f2b
cleanup
ezra-sg Dec 14, 2023
0054d29
fix single erc721 support
ezra-sg Dec 14, 2023
8c03144
type safety
ezra-sg Dec 14, 2023
1fb2f43
fix single erc721 handling
ezra-sg Dec 14, 2023
10e2422
i18n
ezra-sg Dec 14, 2023
58d680f
fix scenario causing an nft collection to fail to load
ezra-sg Dec 15, 2023
cf2c71e
fix accounts being stored in contract store
ezra-sg Dec 15, 2023
ff39b2d
fix logged out error, cleanup
ezra-sg Dec 15, 2023
892b3c0
cleanup
ezra-sg Dec 15, 2023
4725750
fix erc721 owner not being set
ezra-sg Dec 15, 2023
5fd6c68
fix accounts being stored as contracts #2
ezra-sg Dec 15, 2023
1dab472
improve tooltip text for erc721 single rows
ezra-sg Dec 15, 2023
3f9611c
error handling
ezra-sg Dec 15, 2023
410839a
cleanup
ezra-sg Dec 18, 2023
471f279
add successful tx notification, improve modal text, cleanup
ezra-sg Dec 18, 2023
add1909
remove cancelled allowances toggle temporarily
ezra-sg Dec 18, 2023
021f7ea
WIP support walletconnect - update erc20 allowance
ezra-sg Dec 18, 2023
e29286c
WIP support walletconnect - update single erc721 allowance
ezra-sg Dec 18, 2023
904e1e1
support walletconnect - update nft collection allowance
ezra-sg Dec 19, 2023
d25df6a
add missed file
ezra-sg Dec 19, 2023
92af67e
improve batch revoke copy
ezra-sg Dec 20, 2023
4c306a1
fix potential case mismatch
ezra-sg Dec 21, 2023
4e8f37e
Update src/i18n/en-us/index.js
donnyquixotic Dec 26, 2023
c7072b1
Update src/i18n/en-us/index.js
donnyquixotic Dec 26, 2023
1c43925
fix: linter, escape quote
donnyquixotic Dec 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions src/antelope/chains/EVMChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ import {
IndexerAccountNftsFilter,
IndexerAccountNftsResponse,
GenericIndexerNft,
IndexerNftContract,
IndexerContract,
NftRawData,
IndexerCollectionNftsResponse,
Erc721Nft,
getErc721Owner,
Erc1155Nft,
AntelopeError,
IndexerAllowanceFilter,
IndexerAllowanceResponseErc20,
IndexerAllowanceResponseErc721,
IndexerAllowanceResponseErc1155,
getErc1155OwnersFromIndexer,
} from 'src/antelope/types';
import EvmContract from 'src/antelope/stores/utils/contracts/EvmContract';
Expand Down Expand Up @@ -378,12 +382,12 @@ export default abstract class EVMChainSettings implements ChainSettings {
imageCache: nftResponse.imageCache,
tokenUri: nftResponse.tokenUri,
supply: nftResponse.supply,
owner: nftResponse.owner,
}));

// we fix the supportedInterfaces property if it is undefined in the response but present in the request
Object.values(response.contracts).forEach((contract) => {
contract.supportedInterfaces = contract.supportedInterfaces ||
params.type ? [params.type?.toLowerCase() as string] : undefined;
contract.supportedInterfaces = contract.supportedInterfaces || (params.type ? [params.type.toLowerCase()] : undefined);
});

this.processNftContractsCalldata(response.contracts);
Expand Down Expand Up @@ -431,7 +435,7 @@ export default abstract class EVMChainSettings implements ChainSettings {
}

// ensure NFT contract calldata is an object
processNftContractsCalldata(contracts: Record<string, IndexerNftContract>) {
processNftContractsCalldata(contracts: Record<string, IndexerContract>) {
for (const contract of Object.values(contracts)) {
try {
contract.calldata = typeof contract.calldata === 'string' ? JSON.parse(contract.calldata) : contract.calldata;
Expand All @@ -444,7 +448,7 @@ export default abstract class EVMChainSettings implements ChainSettings {
// shape the raw data from the indexer into a format that can be used to construct NFTs
shapeNftRawData(
raw: GenericIndexerNft[],
contracts: Record<string, IndexerNftContract>,
contracts: Record<string, IndexerContract>,
): NftRawData[] {
const shaped = [] as NftRawData[];
for (const item_source of raw) {
Expand Down Expand Up @@ -718,4 +722,36 @@ export default abstract class EVMChainSettings implements ChainSettings {
return response.result as EvmBlockData;
});
}

// allowances

async fetchErc20Allowances(account: string, filter: IndexerAllowanceFilter): Promise<IndexerAllowanceResponseErc20> {
const params = {
...filter,
type: 'erc20',
all: true,
};
const response = await this.indexer.get(`v1/account/${account}/approvals`, { params });
return response.data as IndexerAllowanceResponseErc20;
}

async fetchErc721Allowances(account: string, filter: IndexerAllowanceFilter): Promise<IndexerAllowanceResponseErc721> {
const params = {
...filter,
type: 'erc721',
all: true,
};
const response = await this.indexer.get(`v1/account/${account}/approvals`, { params });
return response.data as IndexerAllowanceResponseErc721;
}

async fetchErc1155Allowances(account: string, filter: IndexerAllowanceFilter): Promise<IndexerAllowanceResponseErc1155> {
const params = {
...filter,
type: 'erc1155',
all: true,
};
const response = await this.indexer.get(`v1/account/${account}/approvals`, { params });
return response.data as IndexerAllowanceResponseErc1155;
}
}
2 changes: 2 additions & 0 deletions src/antelope/chains/chain-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export const TELOS_ANALYTICS_EVENT_IDS = {
loginFailedWalletConnect: '9V4IV1BV',
loginSuccessfulWalletConnect: '2EG2OR3H',
};

export const ZERO_ADDRESS = '0x'.concat('0'.repeat(40));
37 changes: 20 additions & 17 deletions src/antelope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ChainModel } from 'src/antelope/stores/chain';

import {
useAccountStore,
useAllowancesStore,
useBalancesStore,
useChainStore,
useContractStore,
Expand Down Expand Up @@ -90,20 +91,21 @@ export class Antelope {

get stores() {
return {
user: useUserStore(),
chain: useChainStore(),
account: useAccountStore(),
allowances: useAllowancesStore(),
balances: useBalancesStore(),
chain: useChainStore(),
contract: useContractStore(),
evm: useEVMStore(),
feedback: useFeedbackStore(),
history: useHistoryStore(),
nfts: useNftsStore(),
platform: usePlatformStore(),
profile: useProfileStore(),
resources: useResourcesStore(),
rex: useRexStore(),
tokens: useTokensStore(),
contract: useContractStore(),
balances: useBalancesStore(),
history: useHistoryStore(),
feedback: useFeedbackStore(),
platform: usePlatformStore(),
evm: useEVMStore(),
nfts: useNftsStore(),
user: useUserStore(),
};
}

Expand All @@ -128,19 +130,20 @@ export const installAntelope = (app: App) => {
};

export { useAccountStore } from 'src/antelope/stores/account';
export { useAllowancesStore } from 'src/antelope/stores/allowances';
export { useBalancesStore } from 'src/antelope/stores/balances';
export { useChainStore } from 'src/antelope/stores/chain';
export { useUserStore } from 'src/antelope/stores/user';
export { useContractStore } from 'src/antelope/stores/contract';
export { useEVMStore } from 'src/antelope/stores/evm';
export { useFeedbackStore } from 'src/antelope/stores/feedback';
export { useHistoryStore } from 'src/antelope/stores/history';
export { useNftsStore } from 'src/antelope/stores/nfts';
export { usePlatformStore } from 'src/antelope/stores/platform';
export { useProfileStore } from 'src/antelope/stores/profile';
export { useResourcesStore } from 'src/antelope/stores/resources';
export { useRexStore } from 'src/antelope/stores/rex';
export { useTokensStore } from 'src/antelope/stores/tokens';
export { useContractStore } from 'src/antelope/stores/contract';
export { useBalancesStore } from 'src/antelope/stores/balances';
export { useHistoryStore } from 'src/antelope/stores/history';
export { useFeedbackStore } from 'src/antelope/stores/feedback';
export { usePlatformStore } from 'src/antelope/stores/platform';
export { useEVMStore } from 'src/antelope/stores/evm';
export { useNftsStore } from 'src/antelope/stores/nfts';
export { useUserStore } from 'src/antelope/stores/user';

// this constant is used for a temporal workaround for the multi-context issue
// https://github.com/telosnetwork/telos-wallet/issues/582
Expand Down
2 changes: 2 additions & 0 deletions src/antelope/stores/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { createInitFunction, createTraceFunction } from 'src/antelope/stores/fee
import { initFuelUserWrapper } from 'src/api/fuel';
import {
CURRENT_CONTEXT,
useAllowancesStore,
useBalancesStore,
useFeedbackStore,
useHistoryStore,
Expand Down Expand Up @@ -213,6 +214,7 @@ export const useAccountStore = defineStore(store_name, {
useHistoryStore().clearEvmNftTransfers();
useBalancesStore().clearBalances();
useNftsStore().clearNFTs();
useAllowancesStore().clearAllowances();

try {
localStorage.removeItem('network');
Expand Down
Loading
Loading