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

Feature/socios #814

Merged
merged 23 commits into from
Sep 11, 2023
280 changes: 29 additions & 251 deletions index.html

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '../utils'
import { getNftCollection, getNftTokens } from '../utils/token/nftProvider'
import { TokenStore } from './tokenStore'
import { isCookieExpired } from './../utils'
import {
OffChainTokenConfig,
OnChainTokenConfig,
Expand Down Expand Up @@ -130,6 +131,7 @@ export class Client {
this.config = this.mergeConfig(defaultConfig, config)

this.tokenStore = new TokenStore(this.config.autoEnableTokens, this.config.tokenPersistenceTTL)
// @ts-ignore
if (this.config.issuers?.length > 0) this.tokenStore.updateIssuers(this.config.issuers)

this.messaging = new Messaging()
Expand Down Expand Up @@ -160,7 +162,6 @@ export class Client {
if (this.urlParams) {
return this.urlParams.get(URLNS + itemKey)
}

return null
}

Expand Down Expand Up @@ -289,20 +290,21 @@ export class Client {
}

// TODO: Move to token store OR select-wallet view - this method is very similar to getCurrentBlockchains()
public hasIssuerForBlockchain(blockchain: 'evm' | 'solana' | 'flow' | 'ultra') {
public hasIssuerForBlockchain(blockchain: 'evm' | 'solana' | 'flow' | 'ultra', useOauth = false) {
return (
this.config.issuers.filter((issuer: OnChainTokenConfig) => {
if (blockchain === 'evm' && !issuer.onChain) return true
if (blockchain === 'evm' && !issuer.onChain && !useOauth) return true
if (issuer.oAuth2options && useOauth) return true
if (blockchain === 'solana' && typeof window.solana === 'undefined') return false
if (blockchain === 'ultra' && typeof window.ultra === 'undefined') return false

return (issuer.blockchain ? issuer.blockchain.toLowerCase() : 'evm') === blockchain
return !issuer.oAuth2options && (issuer.blockchain ? issuer.blockchain.toLowerCase() : 'evm') === blockchain
}).length > 0
)
}

public async getWalletProvider() {
if (!this.web3WalletProvider) {
// TODO - this is already installed in the file header.
const { Web3WalletProvider } = await import('./../wallet/Web3WalletProvider')
this.web3WalletProvider = new Web3WalletProvider(this, this.config.walletOptions, this.config.safeConnectOptions)
}
Expand Down Expand Up @@ -620,7 +622,6 @@ export class Client {

try {
const tokens = await this.loadOnChainTokens(issuer)

this.tokenStore.setTokens(issuerKey, tokens)
} catch (err) {
logger(2, err)
Expand Down Expand Up @@ -665,12 +666,11 @@ export class Client {
async connectTokenIssuer(issuer: string): Promise<unknown[] | void> {
const config = this.tokenStore.getCurrentIssuers()[issuer]
if (!config) errorHandler('Undefined token issuer', 'error', null, null, true, true)

let tokens

if (config.onChain === true) {
tokens = await this.loadOnChainTokens(config)
} else {
// @ts-ignore
tokens = await this.loadOutletTokens(config)
}

Expand All @@ -689,15 +689,15 @@ export class Client {
// TODO: Collect tokens from all addresses for this blockchain
const walletAddress = walletProvider.getConnectedWalletAddresses(issuer.blockchain)?.[0]

requiredParams(walletAddress, 'wallet address is missing.')
if (!issuer.oAuth2options) requiredParams(walletAddress, 'wallet address is missing.')

// TODO: Allow API to return tokens for multiple addresses
let tokens

if (issuer.fungible) {
tokens = await getFungibleTokenBalances(issuer, walletAddress)
tokens = await getFungibleTokenBalances(issuer, walletAddress, null)
} else {
tokens = await getNftTokens(issuer, walletAddress)
tokens = await getNftTokens(issuer, walletAddress, null)
}

tokens.map((token) => {
Expand Down
45 changes: 44 additions & 1 deletion src/client/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import { WalletConnection } from '../wallet/Web3WalletProvider'
import { DecodedToken } from '../outlet/ticketStorage'
import { EasSchemaConfig } from '../outlet/interfaces'

export enum SupportedBlockchainsEnum {
EVM = 'evm',
SOLANA = 'solana',
FLOW = 'flow',
ULTRA = 'ultra',
}

export type SupportedBlockchainsParam = 'evm' | 'flow' | 'solana' | 'ultra'
export const SignatureSupportedBlockchainsParamList = ['evm', 'flow', 'solana', 'ultra']

Expand All @@ -16,6 +23,7 @@ export interface OffChainTokenConfig extends IssuerConfigInterface {
base64senderPublicKeys: { [key: string]: string }
base64attestorPubKey: string // TODO: Remove - only required in outlet
eas?: EasSchemaConfig
oAuth2options?: any
}

export interface OnChainTokenConfig extends IssuerConfigInterface {
Expand All @@ -24,6 +32,7 @@ export interface OnChainTokenConfig extends IssuerConfigInterface {
chain: string
openSeaSlug?: string
blockchain?: SupportedBlockchainsParam
oAuth2options?: any
}

export interface UltraIssuerConfig extends OnChainTokenConfig {
Expand All @@ -40,19 +49,53 @@ export interface SolanaIssuerConfig extends OnChainTokenConfig {
updateAuthority?: string
}

export interface Oauth2IssuerConfig {
collectionID: string
onChain: boolean
contract: string
chain: string
blockchain?: SupportedBlockchainsParam
oAuth2options: {
consumerKey: string
redirectURI: string
partnerTag: string
returnToApplicationURL?: string
endpoints: {
redirectURI: {
path: string
params?: object
}
userBalance?: {
path: string
params: object
}
userNfts?: {
path: string
params: object
}
}
}
}

export interface IssuerConfigInterface {
collectionID: string
onChain: boolean
title?: string
image?: string
symbol?: string
decimals?: number
shortCode?: string
noTokenMsg?: string
hideToggle?: boolean
fungible?: boolean
consumerKey?: string
redirectURI?: string
partnerTag?: string
serverEndPoint?: string
oAuth2options?: string
}

export type Issuer = OffChainTokenConfig | SolanaIssuerConfig | OnChainTokenConfig | UltraIssuerConfig
export type Issuer = OffChainTokenConfig | SolanaIssuerConfig | OnChainTokenConfig | UltraIssuerConfig | Oauth2IssuerConfig
export type OnChainIssuer = SolanaIssuerConfig | OnChainTokenConfig | UltraIssuerConfig
export interface NegotiationInterface {
type: 'active' | 'passive'
Expand Down
4 changes: 4 additions & 0 deletions src/client/tokenStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export class TokenStore {
return current
}

public getIssuerConfig(collectionId: string) {
return this.tokenLookup[collectionId]
}

public getCurrentBlockchains() {
const blockChains = []

Expand Down
5 changes: 3 additions & 2 deletions src/client/views/select-issuers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export class SelectIssuers extends AbstractView {
issuerConnectMarkup(title: string, image: string | undefined, issuer: string, tokens: any[], data: Issuer) {
let buttonText = ''

// @ts-ignore
if (tokens?.length) buttonText = data?.fungible ? 'Balance found' : `${tokens.length} token${tokens.length > 1 ? 's' : ''} available`

return `
Expand Down Expand Up @@ -344,8 +345,8 @@ export class SelectIssuers extends AbstractView {
title: t.title,
image: t.image ?? config.image,
fungible: config.fungible,
decimals: config.decimals,
symbol: config.symbol,
decimals: t.decimals ?? config.decimals,
symbol: t.symbol ?? config.symbol,
balance: t.balance,
toggleState: isSelected,
hideToggle: config?.hideToggle,
Expand Down
14 changes: 10 additions & 4 deletions src/client/views/select-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { UIUpdateEventType } from '../index'
import { getWalletInfo, WalletInfo } from './utils/wallet-info'
import { SupportedWalletProviders } from '../../wallet/Web3WalletProvider'
import { getBrowserData } from '../../utils/support/getBrowserData'
import { SupportedBlockchainsEnum } from './../interface';

export class SelectWallet extends AbstractView {
init() {
Expand All @@ -13,7 +14,7 @@ export class SelectWallet extends AbstractView {
render() {
let walletButtons = ''

if (this.client.hasIssuerForBlockchain('evm')) {
if (this.client.hasIssuerForBlockchain(SupportedBlockchainsEnum.EVM)) {
if (this.client.safeConnectAvailable()) {
const safeConnect = getWalletInfo(SupportedWalletProviders.SafeConnect)
walletButtons += this.getWalletButtonHtml(safeConnect)
Expand Down Expand Up @@ -41,17 +42,22 @@ export class SelectWallet extends AbstractView {
}
}

if (this.client.hasIssuerForBlockchain('solana')) {
if (this.client.hasIssuerForBlockchain(SupportedBlockchainsEnum.EVM, true)) {
const socios = getWalletInfo(SupportedWalletProviders.Socios)
walletButtons += this.getWalletButtonHtml(socios)
}

if (this.client.hasIssuerForBlockchain(SupportedBlockchainsEnum.SOLANA)) {
const phantom = getWalletInfo(SupportedWalletProviders.Phantom)
walletButtons += this.getWalletButtonHtml(phantom)
}

if (this.client.hasIssuerForBlockchain('flow')) {
if (this.client.hasIssuerForBlockchain(SupportedBlockchainsEnum.FLOW)) {
const flow = getWalletInfo(SupportedWalletProviders.Flow)
walletButtons += this.getWalletButtonHtml(flow)
}

if (this.client.hasIssuerForBlockchain('ultra')) {
if (this.client.hasIssuerForBlockchain(SupportedBlockchainsEnum.ULTRA)) {
const ultra = getWalletInfo(SupportedWalletProviders.Ultra)
walletButtons += this.getWalletButtonHtml(ultra)
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/views/token-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ export class TokenList extends AbstractView {
? '#' + (index.length > 15 ? index.substring(0, 5) + '...' + index.substring(index.length - 5, index.length) : index)
: ''
} else {
const balanceTxt = ethers.utils.formatUnits(balance, decimals)

const balanceTxt = ethers.utils.parseUnits(balance, decimals).toString()
// const balanceTxt = ethers.utils.formatUnits(balanceParsed, decimals)
detail = balanceTxt + ' ' + symbol
abrieviated = (balanceTxt.length > 15 ? balanceTxt.substring(0, 12) + '... ' : balanceTxt) + ' ' + symbol
}
Expand Down
9 changes: 9 additions & 0 deletions src/client/views/utils/wallet-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface WalletInfo {
imgSmall?: string
}

const sociosSVG =
'<svg width="100%" height="100%" viewBox="0 0 62 62" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><g transform="matrix(0.0415754,0,0,0.0415754,-15.4175,-33.0879)"><path d="M855.511,1399.23C842.106,1390.76 828.834,1382.08 815.695,1373.21C802.543,1364.34 789.537,1355.25 776.677,1345.98C763.804,1336.71 751.091,1327.25 738.511,1317.59C725.93,1307.94 713.496,1298.08 701.221,1288.06C653.014,1240.06 668.653,1086.04 668.746,1083.28C667.922,1074.88 668.733,1066.39 671.14,1058.3C673.534,1050.18 677.483,1042.63 682.763,1036.03C688.042,1029.42 694.545,1023.91 701.913,1019.78C709.284,1015.65 717.386,1012.98 725.771,1011.92C789.802,995.883 854.723,983.627 920.195,975.22C985.664,966.815 1051.57,962.281 1117.59,961.629C1183.59,960.991 1249.57,964.236 1315.2,971.35C1380.83,978.478 1445.98,989.463 1510.31,1004.25C1585,1019.52 1611.53,1032.94 1615.46,1120.96C1617.37,1163.75 1618.05,1206.59 1617.51,1249.42C1616.97,1292.26 1615.2,1335.07 1612.21,1377.81C1610.4,1394.67 1604.11,1472.32 1533.09,1418.33C1515.92,1405.3 1489.13,1394.26 1493.1,1357.51C1496.56,1325.29 1497.31,1253.81 1497.86,1208.89C1497.94,1202.72 1497.39,1196.56 1496.24,1190.5C1495.07,1184.45 1493.3,1178.52 1490.96,1172.81C1488.6,1167.11 1485.68,1161.66 1482.25,1156.53C1478.79,1151.42 1474.84,1146.66 1470.45,1142.33C1465.8,1138.79 1460.93,1135.56 1455.86,1132.66C1450.8,1129.75 1445.54,1127.18 1440.14,1124.96C1434.74,1122.73 1429.2,1120.86 1423.55,1119.36C1417.91,1117.86 1412.16,1116.73 1406.38,1115.97C1261.7,1077.09 997.872,1071.53 844.846,1119.89C830.417,1124.46 770.188,1135.12 783.845,1260.77C784.696,1272.16 786.518,1283.47 789.284,1294.56C792.051,1305.64 795.761,1316.48 800.375,1326.93C804.99,1337.39 810.482,1347.43 816.799,1356.95C823.129,1366.48 830.244,1375.44 838.09,1383.75C839.42,1385.16 840.79,1386.56 842.186,1387.91C843.569,1389.27 845.005,1390.59 846.455,1391.88C847.904,1393.17 849.394,1394.43 850.897,1395.65C852.413,1396.88 853.942,1398.07 855.511,1399.23ZM1443.32,1795.77C1449.48,1782.68 1453.1,1768.54 1453.97,1754.1C1455.77,1724.98 1446.36,1696.25 1427.68,1673.83C1418.43,1662.72 1407.14,1653.46 1394.43,1646.55C1366.6,1627.14 1332.9,1605.81 1305.11,1586.41C1305.11,1586.41 1411.74,1650.04 1343.06,1735.54C1309.66,1777.08 1176.5,1892.3 1126.43,1887.58C1028.45,1878.35 813.328,1699.22 753.099,1655.28C750.53,1653.33 747.375,1652.3 744.149,1652.37C740.918,1652.42 737.806,1653.57 735.306,1655.61C732.805,1657.66 731.077,1660.48 730.372,1663.63C729.68,1666.79 730.066,1670.08 731.462,1673C750.865,1709.65 773.083,1744.74 797.915,1777.95C822.75,1811.16 850.12,1842.41 879.781,1871.4C909.437,1900.39 941.3,1927.04 975.092,1951.1C1008.87,1975.15 1044.46,1996.56 1081.55,2015.13C1090.27,2019.36 1099.57,2022.31 1109.14,2023.89C1118.71,2025.46 1128.46,2025.63 1138.08,2024.41C1147.71,2023.2 1157.11,2020.58 1165.98,2016.67C1174.85,2012.75 1183.11,2007.57 1190.5,2001.28C1213.58,1986.84 1236.2,1971.69 1258.34,1955.86C1280.48,1940.02 1302.13,1923.5 1323.26,1906.33C1344.38,1889.16 1364.97,1871.34 1384.99,1852.9C1405.02,1834.45 1424.48,1815.41 1443.32,1795.77Z" style="fill:rgb(6,28,44);fill-rule:nonzero;"/></g><g transform="matrix(0.0415754,0,0,0.0415754,-15.4175,-33.0879)"><path d="M1076.45,1343.35C1064.64,1356.86 1059.2,1374.82 1061.52,1392.61C1062.66,1401.41 1065.67,1409.87 1070.32,1417.42C1074.99,1424.98 1081.2,1431.45 1088.56,1436.43C1170.97,1493.45 1320.03,1596.7 1393.25,1647.65C1405.75,1654.64 1416.84,1663.89 1425.98,1674.91C1435.13,1685.92 1442.16,1698.53 1446.74,1712.09C1451.33,1725.65 1453.37,1739.95 1452.78,1754.25C1452.19,1768.56 1448.97,1782.63 1443.28,1795.77C1450.32,1787.59 1457.2,1779.28 1463.93,1770.85C1470.66,1762.41 1477.23,1753.86 1483.63,1745.18C1490.04,1736.5 1496.29,1727.71 1502.37,1718.8C1508.44,1709.88 1514.35,1700.85 1520.09,1691.72C1552.45,1638.7 1538.06,1589.11 1462.82,1539.89L1165.02,1332.46C1158.31,1327.82 1150.81,1324.44 1142.89,1322.49C1134.98,1320.53 1126.76,1320.04 1118.66,1321.04C1110.56,1322.03 1102.72,1324.49 1095.5,1328.31C1088.28,1332.12 1081.83,1337.22 1076.45,1343.35ZM1081.08,1637.18C1085.79,1630.67 1089.17,1623.3 1091.03,1615.48C1092.88,1607.66 1093.17,1599.55 1091.89,1591.61C1089.3,1575.59 1080.43,1561.25 1067.25,1551.78C993.949,1499.01 858.091,1401.25 788.872,1351.7C705.73,1291.22 677.138,1191.89 668.746,1082.02C667.017,1104.74 665.701,1127.49 664.81,1150.26C663.919,1173.01 663.427,1195.79 663.36,1218.57C663.237,1264.14 664.763,1309.7 667.935,1355.16C674.305,1427.49 723.829,1464.81 782.755,1506.99L990.106,1656.59C997.473,1660.87 1005.57,1663.75 1013.99,1665.1C1022.41,1666.44 1031,1666.21 1039.34,1664.43C1047.67,1662.65 1055.62,1659.35 1062.76,1654.7C1069.88,1650.04 1076.11,1644.1 1081.08,1637.18Z" style="fill:rgb(29,51,68);fill-rule:nonzero;"/></g></svg>'

const phantomSVG =
'<svg width="62px" height="62px" viewBox="-30 -20 180 180" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><title>Phantom logo</title><path d="M57.137,22.8c23.339,0.075 42.264,18.847 42.563,42.1l10.1,0c3.8,0 6.8,3 6.8,6.8c0,19.661 -32.669,36.532 -54.77,36.6l-0.13,0c-23.6,0 -47.4,-19.1 -47.4,-42.7c0,-1.6 0.1,-3.1 0.2,-4.6c2.3,-21.6 20.5,-38.2 42.5,-38.2l0.137,0Z" style="fill:url(#_Linear1);fill-rule:nonzero;"/><path d="M64,0c35.323,0 64,28.677 64,64c0,35.323 -28.677,64 -64,64c-35.323,0 -64,-28.677 -64,-64c0,-35.323 28.677,-64 64,-64Zm-7,22.8l1.366,0.021l1.23,0.057l0.528,0.035c14.242,1.029 26.545,9.033 33.507,20.608l0.521,0.891l0.499,0.902l0.478,0.915l0.455,0.928l0.434,0.939l0.411,0.952l0.388,0.963l0.365,0.974l0.342,0.985l0.394,1.246l0.332,1.166l0.282,1.114l0.265,1.179l0.224,1.148l0.198,1.19l0.147,1.053l0.12,1.062l0.095,1.068l0.067,1.077l0.042,1.083l0.01,0.544c0,0 10.1,0 10.1,0c3.8,0 6.8,3 6.8,6.8l-0.018,0.788l-0.054,0.818l-0.089,0.79l-0.125,0.802l-0.184,0.903l-0.226,0.897l-0.27,0.891l-0.31,0.885l-0.351,0.879l-0.391,0.872l-0.429,0.865l-0.51,0.933l-0.504,0.844l-0.538,0.836l-0.572,0.828l-0.605,0.818l-0.636,0.809l-0.667,0.799l-0.697,0.79l-0.726,0.779l-0.754,0.769l-0.78,0.758l-0.806,0.747l-0.831,0.736c-2.552,2.209 -5.436,4.262 -8.532,6.119l-0.553,0.328l-0.517,0.301l-0.521,0.298l-0.525,0.294l-0.527,0.29l-0.532,0.287c-6.807,3.636 -14.382,6.343 -21.59,7.752l-1.154,0.215l-0.862,0.146c-1.959,0.32 -3.883,0.539 -5.747,0.65l-1.464,0.065l-1.173,0.019l-0.13,-0c-23.6,-0 -47.4,-19.1 -47.4,-42.7c0,-1.6 0.1,-3.1 0.2,-4.6c2.3,-21.6 20.5,-38.2 42.5,-38.2Zm-17.3,34.1l0,9.1c0,3.1 -2.5,5.6 -5.6,5.6c-3.1,-0 -5.6,-2.5 -5.6,-5.6l0,-9.1c0,-3.1 2.5,-5.6 5.6,-5.6c3.1,-0 5.6,2.5 5.6,5.6Zm19.7,-0l0,9.1c0,3.1 -2.5,5.6 -5.6,5.6c-3.1,-0 -5.6,-2.5 -5.6,-5.6l0,-9.1c0,-3.1 2.5,-5.6 5.6,-5.6c3.1,-0 5.6,2.5 5.6,5.6Z" style="fill:url(#_Linear2);"/><defs><linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(5.23303e-15,85.4619,-85.4619,5.23303e-15,65.46,22.76)"><stop offset="0" style="stop-color:#fefeff;stop-opacity:1"/><stop offset="1" style="stop-color:#dfd8fc;stop-opacity:1"/></linearGradient><linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(7.83774e-15,128,-128,7.83774e-15,64,0)"><stop offset="0" style="stop-color:#534ab1;stop-opacity:1"/><stop offset="1" style="stop-color:#551bf8;stop-opacity:1"/></linearGradient></defs></svg>'

Expand Down Expand Up @@ -188,6 +191,12 @@ export function getWalletInfo(providerType: SupportedWalletProviders): WalletInf
label: 'SafeConnect',
imgBig: safeConnectSVG,
}
case SupportedWalletProviders.Socios:
return {
name: providerType,
label: 'Socios',
imgBig: sociosSVG,
}
case SupportedWalletProviders.Ultra:
return {
name: providerType,
Expand Down
46 changes: 36 additions & 10 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,44 @@ export const createCookie = (name: string, value: any, seconds: number) => {
document.cookie = name + '=' + value + expires + '; path=/'
}

export const isCookieExpired = (cookieName: string) => {
let cookies = document.cookie.split('; ')
for (let i = 0; i < cookies.length; i++) {
let cookie = cookies[i].split('=')
if (cookie[0] === cookieName) {
let expiration = cookie[1]
if (expiration === 'true') {
return false // Cookie is not expired
export const isCookieMaxAgeExpired = (cookieName) => {
const cookies = document.cookie.split(';')
for (const cookie of cookies) {
const [name, value] = cookie.trim().split('=')
if (name === cookieName) {
// This cookie exists, check if it has expired
const cookieData = decodeURIComponent(value)
const expirationDate = new Date(cookieData)
if (expirationDate > new Date()) {
// The cookie is still valid
return false
} else {
return true // Cookie is expired
return true
}
}
}
return true // Cookie is not found, considered expired
return true
}

export const isCookieExpired = (cookieName: string) => {
const cookies = document.cookie.split(';')
for (const cookie of cookies) {
const [name, value] = cookie.trim().split('=')
if (name === cookieName) {
const expirationDate = new Date(value)
const currentDate = new Date()
return currentDate > expirationDate
}
}
return true
}

export const getCookieByName = (cookieName: string) => {
const value = `; ${document.cookie}`
const parts = value.split(`; ${cookieName}=`)
if (parts.length === 2) return parts.pop().split(';').shift()
}

export const deleteCookieByName = (cookieName) => {
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`
}
4 changes: 4 additions & 0 deletions src/utils/support/isSupported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export const validateBlockchain = (blockchain: string) => {
return 'solana'
}

if (blockchain === 'socios') {
return 'socios'
}

if (blockchain === 'evm') {
return 'evm'
}
Expand Down
Loading