-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from telosnetwork/dev
v1.4.5-rc
- Loading branch information
Showing
104 changed files
with
11,157 additions
and
3,355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from 'src/antelope/mocks/AccountStore'; | ||
export * from 'src/antelope/mocks/AntelopeConfig'; | ||
export * from 'src/antelope/mocks/ChainStore'; | ||
export * from 'src/antelope/mocks/ContractStore'; | ||
export * from 'src/antelope/mocks/EVMStore'; | ||
export * from 'src/antelope/mocks/FeedbackStore'; | ||
export * from 'src/antelope/mocks/PlatformStore'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Mocking AccountStore ----------------------------------- | ||
// useAccountStore().getAccount(this.label).account as addressString; | ||
import { EVMAuthenticator } from 'src/antelope/wallets'; | ||
import { addressString } from 'src/antelope/types'; | ||
import { CURRENT_CONTEXT } from 'src/antelope/mocks'; | ||
|
||
export interface AccountModel { | ||
label: typeof CURRENT_CONTEXT; | ||
isNative: boolean; | ||
authenticator: EVMAuthenticator; | ||
account: addressString; | ||
} | ||
|
||
let currentAuthenticator = {} as EVMAuthenticator; | ||
let currentAccount = null as addressString | null; | ||
|
||
interface LoginEVMActionData { | ||
authenticator: EVMAuthenticator | ||
network: string, | ||
} | ||
|
||
const AccountStore = { | ||
getAccount: (label: string) => ({ | ||
label, | ||
isNative: false, | ||
authenticator: currentAuthenticator, | ||
account: currentAccount, | ||
} as AccountModel), | ||
|
||
async loginEVM({ authenticator, network }: LoginEVMActionData): Promise<boolean> { | ||
currentAuthenticator = authenticator; | ||
currentAccount = await authenticator.login(network); | ||
return true; | ||
}, | ||
|
||
logout() { | ||
console.log('AccountStore.logout()'); | ||
currentAuthenticator.logout(); | ||
currentAuthenticator = {} as EVMAuthenticator; | ||
currentAccount = null; | ||
}, | ||
|
||
get loggedAccount() { | ||
return this.getAccount(CURRENT_CONTEXT); | ||
}, | ||
|
||
get currentAccount() { | ||
return this.getAccount(CURRENT_CONTEXT); | ||
}, | ||
}; | ||
|
||
export const useAccountStore = () => AccountStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
// Mocking Antelope and Config ----------------------------------- | ||
import { EVMAuthenticator } from 'src/antelope/wallets/authenticators/EVMAuthenticator'; | ||
|
||
export class AntelopeWallets { | ||
private authenticators: Map<string, EVMAuthenticator> = new Map(); | ||
init() { | ||
// dummie function | ||
} | ||
addEVMAuthenticator(authenticator: EVMAuthenticator) { | ||
this.authenticators.set(authenticator.getName(), authenticator); | ||
} | ||
getAuthenticator(name: string) { | ||
return this.authenticators.get(name); | ||
} | ||
} | ||
|
||
const config = { | ||
notifyNeutralMessageHandler: (message: string) => void 0, | ||
localizationHandler: (message: string, params?: Record<string, string>) => message, | ||
notifyFailureWithActionHandler: (message: string, action: () => void) => void 0, | ||
notifyFailureWithAction: (message: string, params?: { label: string; handler: () => void; }) => void 0, | ||
}; | ||
|
||
const wallets = new AntelopeWallets(); | ||
const Antelope = { | ||
config, | ||
wallets, | ||
}; | ||
|
||
export const getAntelope = () => Antelope; | ||
// ---------------------------------------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
// Mocking ChainStore ----------------------------------- | ||
|
||
import { RpcEndpoint } from 'universal-authenticator-library'; | ||
import { NativeCurrencyAddress, TokenClass } from 'src/antelope/types'; | ||
|
||
export interface EVMChainSettings { | ||
getStakedSystemToken(): TokenClass; | ||
getWrappedSystemToken: () => TokenClass; | ||
getChainId: () => string; | ||
getDisplay: () => string; | ||
trackAnalyticsEvent: (o: {id:string}) => void; | ||
getRPCEndpoint: () => RpcEndpoint; | ||
getEscrowContractAddress: () => string; | ||
getNetwork: () => string; | ||
getSystemToken: () => TokenClass; | ||
getExplorerUrl: () => string; | ||
getSmallLogoPath: () => string; | ||
getLargeLogoPath: () => string; | ||
} | ||
|
||
const settings = { | ||
getChainId: () => process.env.NETWORK_EVM_CHAIN_ID, | ||
getDisplay: () => process.env.NETWORK_EVM_DISPLAY, | ||
trackAnalyticsEvent: () => void 0, | ||
getRPCEndpoint: () => { | ||
// extract the url parts | ||
const regex = /^(https?):\/\/([^:/]+)(?::(\d+))?(\/.*)?$/; | ||
const match = (process.env.NETWORK_EVM_RPC as string).match(regex); | ||
if (!match) { | ||
throw new Error('Invalid RPC endpoint'); | ||
} | ||
// We destructure the result of the match to get each component | ||
const [, protocol, host, port, path] = match; | ||
return { | ||
protocol, | ||
host, | ||
port: port ? parseInt(port, 10) : 443, | ||
path: path || '/', | ||
}; | ||
}, | ||
getEscrowContractAddress: () => process.env.TELOS_ESCROW_CONTRACT_ADDRESS, | ||
getStakedSystemToken: () => ({ | ||
address: process.env.STAKED_TLOS_CONTRACT_ADDRESS, | ||
decimals: 18, | ||
symbol: 'STLOS', | ||
} as TokenClass), | ||
getWrappedSystemToken: () => ({ | ||
address: process.env.WRAPPED_TLOS_CONTRACT_ADDRESS, | ||
decimals: 18, | ||
symbol: 'WTLOS', | ||
} as TokenClass), | ||
getSystemToken: () => ({ | ||
name: 'Telos', | ||
address: NativeCurrencyAddress, | ||
decimals: 18, | ||
symbol: 'TLOS', | ||
} as TokenClass), | ||
getNetwork: () => process.env.NETWORK_EVM_NAME, | ||
getExplorerUrl: () => process.env.NETWORK_EXPLORER, | ||
getSmallLogoPath: () => 'small-icon-url', | ||
getLargeLogoPath: () => 'large-icon-url', | ||
} as EVMChainSettings; | ||
|
||
const currentChain = { | ||
settings, | ||
}; | ||
|
||
const loggedChain = { | ||
settings, | ||
}; | ||
|
||
const ChainStore = { | ||
currentChain, | ||
loggedChain, | ||
getNetworkSettings: (network: string) => settings, | ||
getChain: (label: string) => currentChain, | ||
setChain: (context: string, network: string) => void 0, | ||
}; | ||
|
||
export const useChainStore = () => ChainStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable max-len */ | ||
|
||
import { EvmABI, erc1155Abi, erc20Abi, erc721Abi } from 'src/antelope/types'; | ||
|
||
// Mocking ContractStore ----------------------------------- | ||
const ContractStore = { | ||
getTokenABI(type:string): EvmABI { | ||
if(type === 'erc721'){ | ||
return erc721Abi; | ||
} else if(type === 'erc1155'){ | ||
return erc1155Abi; | ||
} | ||
return erc20Abi; | ||
}, | ||
}; | ||
|
||
export const useContractStore = () => ContractStore; |
Oops, something went wrong.