@ape.swap/bonds-sdk 1.0.29 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cjs/index.js +141277 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/dist/esm/index.js +141257 -0
  4. package/dist/esm/index.js.map +1 -0
  5. package/package.json +11 -3
  6. package/.idea/bonds-app.iml +0 -12
  7. package/.idea/inspectionProfiles/Project_Default.xml +0 -16
  8. package/.idea/modules.xml +0 -8
  9. package/.idea/vcs.xml +0 -6
  10. package/public/favicon.ico +0 -0
  11. package/public/index.html +0 -43
  12. package/public/logo192.png +0 -0
  13. package/public/logo512.png +0 -0
  14. package/public/manifest.json +0 -25
  15. package/public/robots.txt +0 -3
  16. package/src/App.css +0 -38
  17. package/src/App.test.tsx +0 -9
  18. package/src/App.tsx +0 -30
  19. package/src/index.css +0 -22
  20. package/src/index.tsx +0 -20
  21. package/src/logo.svg +0 -1
  22. package/src/react-app-env.d.ts +0 -1
  23. package/src/reportWebVitals.ts +0 -15
  24. package/src/setupTests.ts +0 -5
  25. package/src/theme/base.ts +0 -127
  26. package/src/theme/colors.ts +0 -93
  27. package/src/theme/components.ts +0 -385
  28. package/src/theme/display.ts +0 -2
  29. package/src/theme/index.ts +0 -10
  30. package/src/theme/types.ts +0 -10
  31. package/src/views/Bonds/Bonds.tsx +0 -72
  32. package/src/views/Bonds/index.ts +0 -2
  33. package/src/views/Bonds/styles.scss +0 -0
  34. package/src/views/Bonds/styles.ts +0 -91
  35. package/src/views/Bonds/type.ts +0 -34
  36. package/src/views/BondsWithProvider/BondsWithProvider.tsx +0 -14
  37. package/src/views/BondsWithProvider/index.ts +0 -2
  38. package/src/views/index.ts +0 -1
  39. package/src/wallet/ConnectionOptions.tsx +0 -59
  40. package/src/wallet/Option.tsx +0 -44
  41. package/src/wallet/config.ts +0 -23
  42. package/src/wallet/connections.ts +0 -92
  43. package/src/wallet/constants.ts +0 -43
  44. package/src/wallet/injected.ts +0 -17
  45. package/src/wallet/network.ts +0 -23
  46. package/src/wallet/provider.tsx +0 -35
  47. package/src/wallet/wallet-connect.ts +0 -25
  48. package/tsconfig.json +0 -27
@@ -1,44 +0,0 @@
1
- import React from 'react'
2
-
3
- import { ConnectionType, getConnection, tryActivateConnector, tryDeactivateConnector } from './connections'
4
-
5
- export const Option = ({
6
- isEnabled,
7
- isConnected,
8
- connectionType,
9
- onActivate,
10
- onDeactivate,
11
- }: {
12
- isEnabled: boolean
13
- isConnected: boolean
14
- connectionType: ConnectionType
15
- onActivate: (connectionType: ConnectionType) => void
16
- onDeactivate: (connectionType: null) => void
17
- }) => {
18
- const onClick = async () => {
19
- if (isConnected) {
20
- const deactivation = await tryDeactivateConnector(getConnection(connectionType).connector)
21
- // undefined means the deactivation failed
22
- if (deactivation === undefined) {
23
- return
24
- }
25
- onDeactivate(deactivation)
26
- return
27
- }
28
-
29
- const activation = await tryActivateConnector(getConnection(connectionType).connector)
30
- if (!activation) {
31
- return
32
- }
33
- onActivate(activation)
34
- return
35
- }
36
-
37
- return (
38
- <div>
39
- <button onClick={onClick} disabled={!isEnabled}>{`${
40
- isConnected ? 'Disconnect' : 'Connect'
41
- } ${connectionType}`}</button>
42
- </div>
43
- )
44
- }
@@ -1,23 +0,0 @@
1
- // Sets if the example should run locally or on chain
2
- export enum Chain {
3
- POLYGON,
4
- MAINNET,
5
- }
6
-
7
- // Inputs that configure this example to run
8
- interface ExampleConfig {
9
- chain: Chain
10
- rpc: {
11
- polygon: string
12
- mainnet: string
13
- }
14
- }
15
-
16
- // Example Configuration
17
- export const CurrentConfig: ExampleConfig = {
18
- chain: Chain.MAINNET,
19
- rpc: {
20
- polygon: '',
21
- mainnet: '',
22
- },
23
- }
@@ -1,92 +0,0 @@
1
- import { Web3ReactHooks } from '@web3-react/core'
2
- import { AddEthereumChainParameter, Connector } from '@web3-react/types'
3
-
4
- import { CHAIN_INFO } from './constants'
5
- import { buildInjectedConnector } from './injected'
6
- import { buildNetworkConnector } from './network'
7
- import { buildWalletConnectConnector } from './wallet-connect'
8
-
9
- export interface Connection {
10
- connector: Connector
11
- hooks: Web3ReactHooks
12
- type: ConnectionType
13
- }
14
-
15
- export enum ConnectionType {
16
- INJECTED = 'INJECTED',
17
- NETWORK = 'NETWORK',
18
- WALLET_CONNECT = 'WALLET_CONNECT',
19
- }
20
-
21
- // function getIsBraveWallet(): boolean {
22
- // return window.ethereum?.isBraveWallet ?? false
23
- // }
24
-
25
- export function getHasMetaMaskExtensionInstalled(): boolean {
26
- return (window.ethereum?.isMetaMask ?? false)
27
- // && !getIsBraveWallet()
28
- }
29
-
30
- export function onConnectionError(error: Error) {
31
- console.debug(`web3-react error: ${error}`)
32
- }
33
-
34
- export const PRIORITIZED_CONNECTORS: { [key in ConnectionType]: Connection } = {
35
- [ConnectionType.INJECTED]: buildInjectedConnector(),
36
- [ConnectionType.WALLET_CONNECT]: buildWalletConnectConnector(),
37
- [ConnectionType.NETWORK]: buildNetworkConnector(),
38
- }
39
-
40
- export function getConnection(c: Connector | ConnectionType) {
41
- if (c instanceof Connector) {
42
- const connection = Object.values(PRIORITIZED_CONNECTORS).find((connection) => connection.connector === c)
43
- if (!connection) {
44
- throw Error('Unsupported Connector')
45
- }
46
- return connection
47
- } else {
48
- switch (c) {
49
- case ConnectionType.INJECTED:
50
- return PRIORITIZED_CONNECTORS[ConnectionType.INJECTED]
51
- case ConnectionType.WALLET_CONNECT:
52
- return PRIORITIZED_CONNECTORS[ConnectionType.WALLET_CONNECT]
53
- case ConnectionType.NETWORK:
54
- return PRIORITIZED_CONNECTORS[ConnectionType.NETWORK]
55
- }
56
- }
57
- }
58
-
59
- export const switchNetwork = async (chainId: number, connectionType: ConnectionType | null) => {
60
- if (!connectionType) {
61
- return
62
- }
63
-
64
- const { connector } = getConnection(connectionType)
65
-
66
- if (connectionType === ConnectionType.WALLET_CONNECT || connectionType === ConnectionType.NETWORK) {
67
- await connector.activate(chainId)
68
- return
69
- }
70
-
71
- const chainInfo = CHAIN_INFO[chainId]
72
- const addChainParameter: AddEthereumChainParameter = {
73
- chainId,
74
- chainName: chainInfo.label,
75
- rpcUrls: [chainInfo.rpcUrl],
76
- nativeCurrency: chainInfo.nativeCurrency,
77
- blockExplorerUrls: [chainInfo.explorer],
78
- }
79
- await connector.activate(addChainParameter)
80
- }
81
-
82
- export const tryActivateConnector = async (connector: Connector): Promise<ConnectionType | undefined> => {
83
- await connector.activate()
84
- const connectionType = getConnection(connector).type
85
- return connectionType
86
- }
87
-
88
- export const tryDeactivateConnector = async (connector: Connector): Promise<null | undefined> => {
89
- connector.deactivate?.()
90
- connector.resetState()
91
- return null
92
- }
@@ -1,43 +0,0 @@
1
- import { Chain, CurrentConfig } from './config'
2
-
3
- // Chains
4
- const MAINNET_CHAIN_ID = 1
5
- const POLYGON_CHAIN_ID = 137
6
-
7
- export const INPUT_CHAIN_ID = CurrentConfig.chain === Chain.POLYGON ? POLYGON_CHAIN_ID : MAINNET_CHAIN_ID
8
- export const INPUT_CHAIN_URL =
9
- CurrentConfig.chain === Chain.POLYGON ? CurrentConfig.rpc.polygon : CurrentConfig.rpc.mainnet
10
-
11
- export const CHAIN_TO_URL_MAP = {
12
- [POLYGON_CHAIN_ID]: CurrentConfig.rpc.polygon,
13
- [MAINNET_CHAIN_ID]: CurrentConfig.rpc.mainnet,
14
- }
15
-
16
- type ChainInfo = {
17
- explorer: string
18
- label: string
19
- nativeCurrency: {
20
- name: string
21
- symbol: string
22
- decimals: 18
23
- }
24
- rpcUrl: string
25
- }
26
-
27
- export const CHAIN_INFO: { [key: string]: ChainInfo } = {
28
- [MAINNET_CHAIN_ID]: {
29
- explorer: 'https://etherscan.io/',
30
- label: 'Ethereum',
31
- nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
32
- rpcUrl: CurrentConfig.rpc.mainnet,
33
- },
34
- [POLYGON_CHAIN_ID]: {
35
- explorer: 'https://polygonscan.com/',
36
- label: 'Polygon',
37
- nativeCurrency: { name: 'Polygon Matic', symbol: 'MATIC', decimals: 18 },
38
- rpcUrl: CurrentConfig.rpc.polygon,
39
- },
40
- }
41
-
42
- // URLs
43
- export const METAMASK_URL = 'https://metamask.io/'
@@ -1,17 +0,0 @@
1
- import { initializeConnector } from '@web3-react/core'
2
- import { MetaMask } from '@web3-react/metamask'
3
-
4
- import { Connection, ConnectionType, onConnectionError } from './connections'
5
-
6
- export function buildInjectedConnector() {
7
- const [web3MetamaskWallet, web3MetamaskWalletHooks] = initializeConnector<MetaMask>(
8
- (actions) => new MetaMask({ actions, onError: onConnectionError })
9
- )
10
- const injectedConnection: Connection = {
11
- connector: web3MetamaskWallet,
12
- hooks: web3MetamaskWalletHooks,
13
- type: ConnectionType.INJECTED,
14
- }
15
-
16
- return injectedConnection
17
- }
@@ -1,23 +0,0 @@
1
- import { initializeConnector } from '@web3-react/core'
2
- import { Network } from '@web3-react/network'
3
-
4
- import { Connection, ConnectionType } from './connections'
5
- import { CHAIN_TO_URL_MAP, INPUT_CHAIN_ID } from './constants'
6
-
7
- export function buildNetworkConnector() {
8
- const [web3Network, web3NetworkHooks] = initializeConnector<Network>(
9
- (actions) =>
10
- new Network({
11
- actions,
12
- urlMap: CHAIN_TO_URL_MAP,
13
- defaultChainId: INPUT_CHAIN_ID,
14
- })
15
- )
16
- const networkConnection: Connection = {
17
- connector: web3Network,
18
- hooks: web3NetworkHooks,
19
- type: ConnectionType.NETWORK,
20
- }
21
-
22
- return networkConnection
23
- }
@@ -1,35 +0,0 @@
1
- // src/wallet/provider.tsx
2
- import { Web3ReactProvider } from '@web3-react/core';
3
- import { Connector } from '@web3-react/types';
4
- import React, { ReactNode, useEffect } from 'react';
5
- import { ConnectionType, getConnection, PRIORITIZED_CONNECTORS } from './connections';
6
-
7
- async function connect(connector: Connector) {
8
- try {
9
- if (connector.connectEagerly) {
10
- await connector.connectEagerly();
11
- } else {
12
- await connector.activate();
13
- }
14
- } catch (error) {
15
- console.debug(`web3-react eager connection error: ${error}`);
16
- }
17
- }
18
-
19
- const connectEagerly = async () => {
20
- await connect(getConnection(ConnectionType.NETWORK).connector);
21
- };
22
-
23
- export const Web3ContextProvider = ({ children }: { children: ReactNode }) => {
24
- useEffect(() => {
25
- connectEagerly();
26
- }, []);
27
-
28
- return (
29
- <Web3ReactProvider
30
- connectors={Object.values(PRIORITIZED_CONNECTORS).map((connector) => [connector.connector, connector.hooks])}
31
- >
32
- {children}
33
- </Web3ReactProvider>
34
- );
35
- };
@@ -1,25 +0,0 @@
1
- import { initializeConnector } from '@web3-react/core'
2
- import { WalletConnect } from '@web3-react/walletconnect'
3
-
4
- import { Connection, ConnectionType, onConnectionError } from './connections'
5
- import { CHAIN_TO_URL_MAP } from './constants'
6
-
7
- export function buildWalletConnectConnector() {
8
- const [web3WalletConnect, web3WalletConnectHooks] = initializeConnector<WalletConnect>(
9
- (actions) =>
10
- new WalletConnect({
11
- actions,
12
- options: {
13
- rpc: CHAIN_TO_URL_MAP,
14
- qrcode: true,
15
- },
16
- onError: onConnectionError,
17
- })
18
- )
19
- const walletConnectConnection: Connection = {
20
- connector: web3WalletConnect,
21
- hooks: web3WalletConnectHooks,
22
- type: ConnectionType.WALLET_CONNECT,
23
- }
24
- return walletConnectConnection
25
- }
package/tsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "esnext"
8
- ],
9
- "allowJs": true,
10
- "skipLibCheck": true,
11
- "esModuleInterop": true,
12
- "allowSyntheticDefaultImports": true,
13
- "strict": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "noFallthroughCasesInSwitch": true,
16
- "module": "esnext",
17
- "moduleResolution": "node",
18
- "resolveJsonModule": true,
19
- "isolatedModules": true,
20
- "noEmit": true,
21
- "jsx": "react-jsx",
22
- "rootDir": "src",
23
- },
24
- "include": [
25
- "src"
26
- ]
27
- }