@meshconnect/web-link-sdk 3.2.15 → 3.2.16
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.
- package/Link.d.ts +2 -0
- package/Link.js +530 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +8 -20
- package/utils/connectors/evm/chainConfigs.d.ts +2 -0
- package/utils/connectors/evm/chainConfigs.js +115 -0
- package/utils/connectors/evm/chainSwitching.d.ts +15 -0
- package/utils/connectors/evm/chainSwitching.js +242 -0
- package/utils/connectors/evm/index.d.ts +8 -0
- package/utils/connectors/evm/index.js +8 -0
- package/utils/connectors/evm/provider.d.ts +6 -0
- package/utils/connectors/evm/provider.js +13 -0
- package/utils/connectors/evm/signing.d.ts +1 -0
- package/utils/connectors/evm/signing.js +78 -0
- package/utils/connectors/evm/transactions.d.ts +28 -0
- package/utils/connectors/evm/transactions.js +381 -0
- package/utils/connectors/evm/types.d.ts +57 -0
- package/utils/connectors/evm/types.js +1 -0
- package/utils/connectors/evm/walletConnection.d.ts +20 -0
- package/utils/connectors/evm/walletConnection.js +160 -0
- package/utils/connectors/evm/walletDiscovery.d.ts +10 -0
- package/utils/connectors/evm/walletDiscovery.js +55 -0
- package/utils/connectors/solana/connection.d.ts +4 -0
- package/utils/connectors/solana/connection.js +108 -0
- package/utils/connectors/solana/index.d.ts +5 -0
- package/utils/connectors/solana/index.js +5 -0
- package/utils/connectors/solana/providerDiscovery.d.ts +3 -0
- package/utils/connectors/solana/providerDiscovery.js +127 -0
- package/utils/connectors/solana/signing.d.ts +1 -0
- package/utils/connectors/solana/signing.js +59 -0
- package/utils/connectors/solana/transaction.d.ts +17 -0
- package/utils/connectors/solana/transaction.js +362 -0
- package/utils/connectors/solana/types.d.ts +71 -0
- package/utils/connectors/solana/types.js +8 -0
- package/utils/event-types.d.ts +233 -0
- package/{src/utils/event-types.test.ts → utils/event-types.js} +5 -15
- package/utils/popup.d.ts +3 -0
- package/utils/popup.js +36 -0
- package/utils/sdk-specs.d.ts +5 -0
- package/utils/sdk-specs.js +6 -0
- package/utils/style.d.ts +3 -0
- package/utils/style.js +13 -0
- package/utils/types.d.ts +234 -0
- package/utils/types.js +1 -0
- package/utils/version.d.ts +1 -0
- package/utils/version.js +1 -0
- package/utils/wallet/EVMWalletStrategy.d.ts +31 -0
- package/utils/wallet/EVMWalletStrategy.js +265 -0
- package/utils/wallet/SolanaWalletStrategy.d.ts +33 -0
- package/utils/wallet/SolanaWalletStrategy.js +300 -0
- package/utils/wallet/WalletStrategy.d.ts +61 -0
- package/utils/wallet/WalletStrategy.js +25 -0
- package/utils/wallet/WalletStrategyFactory.d.ts +15 -0
- package/utils/wallet/WalletStrategyFactory.js +31 -0
- package/utils/wallet/index.d.ts +4 -0
- package/utils/wallet/index.js +4 -0
- package/utils/wallet-browser-event-types.d.ts +116 -0
- package/utils/wallet-browser-event-types.js +17 -0
- package/jest.setup.ts +0 -4
- package/src/Link.test.ts +0 -434
- package/src/Link.ts +0 -491
- package/src/index.ts +0 -3
- package/src/utils/__snapshots__/popup.test.ts.snap +0 -89
- package/src/utils/connectors/evm/chainConfigs.ts +0 -120
- package/src/utils/connectors/evm/chainSwitching.ts +0 -165
- package/src/utils/connectors/evm/index.ts +0 -8
- package/src/utils/connectors/evm/provider.ts +0 -22
- package/src/utils/connectors/evm/signing.ts +0 -39
- package/src/utils/connectors/evm/transactions.ts +0 -356
- package/src/utils/connectors/evm/types.ts +0 -63
- package/src/utils/connectors/evm/walletConnection.ts +0 -140
- package/src/utils/connectors/evm/walletDiscovery.ts +0 -67
- package/src/utils/connectors/solana/connection.ts +0 -69
- package/src/utils/connectors/solana/index.ts +0 -5
- package/src/utils/connectors/solana/providerDiscovery.ts +0 -153
- package/src/utils/connectors/solana/signing.ts +0 -18
- package/src/utils/connectors/solana/transaction.ts +0 -382
- package/src/utils/connectors/solana/types.ts +0 -66
- package/src/utils/event-types.ts +0 -350
- package/src/utils/popup.test.ts +0 -50
- package/src/utils/popup.ts +0 -123
- package/src/utils/sdk-specs.test.ts +0 -18
- package/src/utils/sdk-specs.ts +0 -7
- package/src/utils/style.test.ts +0 -33
- package/src/utils/style.ts +0 -15
- package/src/utils/types.ts +0 -270
- package/src/utils/version.ts +0 -1
- package/src/utils/wallet/EVMWalletStrategy.ts +0 -176
- package/src/utils/wallet/SolanaWalletStrategy.ts +0 -207
- package/src/utils/wallet/WalletStrategy.ts +0 -99
- package/src/utils/wallet/WalletStrategyFactory.ts +0 -46
- package/src/utils/wallet/__tests__/EVMWalletStrategy.test.ts +0 -233
- package/src/utils/wallet/__tests__/SolanaWalletStrategy.test.ts +0 -253
- package/src/utils/wallet/__tests__/WalletStrategy.test.ts +0 -77
- package/src/utils/wallet/__tests__/WalletStrategyFactory.test.ts +0 -65
- package/src/utils/wallet/index.ts +0 -4
- package/src/utils/wallet-browser-event-types.ts +0 -190
- package/tools/copy.js +0 -26
- package/tools/update-version.js +0 -10
- package/tsconfig.json +0 -14
@@ -1,65 +0,0 @@
|
|
1
|
-
import { WalletStrategyFactory } from '../WalletStrategyFactory'
|
2
|
-
import { EVMWalletStrategy } from '../EVMWalletStrategy'
|
3
|
-
import { SolanaWalletStrategy } from '../SolanaWalletStrategy'
|
4
|
-
|
5
|
-
describe('WalletStrategyFactory', () => {
|
6
|
-
let factory: WalletStrategyFactory
|
7
|
-
|
8
|
-
beforeEach(() => {
|
9
|
-
// Reset the singleton instance before each test
|
10
|
-
// @ts-expect-error - accessing private property for testing
|
11
|
-
WalletStrategyFactory.instance = undefined
|
12
|
-
factory = WalletStrategyFactory.getInstance()
|
13
|
-
})
|
14
|
-
|
15
|
-
describe('getInstance', () => {
|
16
|
-
it('should create a singleton instance', () => {
|
17
|
-
const instance1 = WalletStrategyFactory.getInstance()
|
18
|
-
const instance2 = WalletStrategyFactory.getInstance()
|
19
|
-
expect(instance1).toBe(instance2)
|
20
|
-
})
|
21
|
-
})
|
22
|
-
|
23
|
-
describe('getStrategy', () => {
|
24
|
-
it('should return EVMWalletStrategy for evm network type', () => {
|
25
|
-
const strategy = factory.getStrategy('evm')
|
26
|
-
expect(strategy).toBeInstanceOf(EVMWalletStrategy)
|
27
|
-
})
|
28
|
-
|
29
|
-
it('should return SolanaWalletStrategy for solana network type', () => {
|
30
|
-
const strategy = factory.getStrategy('solana')
|
31
|
-
expect(strategy).toBeInstanceOf(SolanaWalletStrategy)
|
32
|
-
})
|
33
|
-
|
34
|
-
it('should throw error for invalid network type', () => {
|
35
|
-
// @ts-expect-error - testing invalid input
|
36
|
-
expect(() => factory.getStrategy('invalid')).toThrow(
|
37
|
-
'No strategy found for network type: invalid'
|
38
|
-
)
|
39
|
-
})
|
40
|
-
})
|
41
|
-
|
42
|
-
describe('getAllProviders', () => {
|
43
|
-
it('should return combined providers from all strategies', () => {
|
44
|
-
// Mock the provider methods
|
45
|
-
jest
|
46
|
-
.spyOn(EVMWalletStrategy.prototype, 'getProviders')
|
47
|
-
.mockReturnValue([
|
48
|
-
{ id: 'metamask', type: 'evm', name: 'MetaMask', icon: undefined }
|
49
|
-
])
|
50
|
-
jest
|
51
|
-
.spyOn(SolanaWalletStrategy.prototype, 'getProviders')
|
52
|
-
.mockReturnValue([{ id: 'phantom', type: 'solana' }])
|
53
|
-
|
54
|
-
const providers = factory.getAllProviders()
|
55
|
-
|
56
|
-
expect(providers).toHaveLength(2)
|
57
|
-
expect(providers).toEqual(
|
58
|
-
expect.arrayContaining([
|
59
|
-
expect.objectContaining({ id: 'metamask', type: 'evm' }),
|
60
|
-
expect.objectContaining({ id: 'phantom', type: 'solana' })
|
61
|
-
])
|
62
|
-
)
|
63
|
-
})
|
64
|
-
})
|
65
|
-
})
|
@@ -1,190 +0,0 @@
|
|
1
|
-
import { AddressLookupTableStateDto, TransactionInstructionDto } from './types'
|
2
|
-
|
3
|
-
export type WalletBrowserEventType =
|
4
|
-
| WalletBrowserInjectedWalletSelected
|
5
|
-
| WalletBrowserSignRequest
|
6
|
-
| WalletBrowserChainSwitchRequest
|
7
|
-
| WalletBrowserTransferBalanceRequest
|
8
|
-
| WalletBrowserNativeTransferRequest
|
9
|
-
| WalletBrowserNonNativeTransferRequest
|
10
|
-
| WalletBrowserNativeSmartDeposit
|
11
|
-
| WalletBrowserNonNativeSmartDeposit
|
12
|
-
| WalletBrowserDisconnect
|
13
|
-
| WalletBrowserTransactionBatch
|
14
|
-
| WalletBrowserWalletCapabilities
|
15
|
-
| WalletBrowserSolanaTransferWithInstructionsRequest
|
16
|
-
|
17
|
-
const WALLET_BROWSER_EVENT_TYPE_KEYS = [
|
18
|
-
'walletBrowserInjectedWalletSelected',
|
19
|
-
'walletBrowserSignRequest',
|
20
|
-
'walletBrowserChainSwitchRequest',
|
21
|
-
'walletBrowserTransferBalanceRequest',
|
22
|
-
'walletBrowserNativeTransferRequest',
|
23
|
-
'walletBrowserNonNativeTransferRequest',
|
24
|
-
'walletBrowserNativeSmartDeposit',
|
25
|
-
'walletBrowserNonNativeSmartDeposit',
|
26
|
-
'walletBrowserDisconnect',
|
27
|
-
'walletBrowserTransactionBatchRequest',
|
28
|
-
'walletBrowserWalletCapabilities',
|
29
|
-
'walletBrowserSolanaTransferWithInstructionsRequest'
|
30
|
-
] as const
|
31
|
-
|
32
|
-
export type NetworkType =
|
33
|
-
| 'unknown'
|
34
|
-
| 'evm'
|
35
|
-
| 'solana'
|
36
|
-
| 'bitcoin'
|
37
|
-
| 'cardano'
|
38
|
-
| 'tron'
|
39
|
-
| 'avalancheX'
|
40
|
-
| 'tezos'
|
41
|
-
| 'dogecoin'
|
42
|
-
| 'ripple'
|
43
|
-
| 'stellar'
|
44
|
-
| 'litecoin'
|
45
|
-
| 'sui'
|
46
|
-
| 'aptos'
|
47
|
-
| 'tvm'
|
48
|
-
|
49
|
-
export type WalletBrowserEventTypeKeys =
|
50
|
-
(typeof WALLET_BROWSER_EVENT_TYPE_KEYS)[number]
|
51
|
-
|
52
|
-
export function isWalletBrowserEventTypeKey(
|
53
|
-
key: string
|
54
|
-
): key is WalletBrowserEventTypeKeys {
|
55
|
-
return WALLET_BROWSER_EVENT_TYPE_KEYS.includes(
|
56
|
-
key as WalletBrowserEventTypeKeys
|
57
|
-
)
|
58
|
-
}
|
59
|
-
|
60
|
-
interface WalletBrowserEventBase {
|
61
|
-
type: WalletBrowserEventTypeKeys
|
62
|
-
}
|
63
|
-
|
64
|
-
export interface WalletBrowserInjectedWalletSelected
|
65
|
-
extends WalletBrowserEventBase {
|
66
|
-
type: 'walletBrowserInjectedWalletSelected'
|
67
|
-
payload: {
|
68
|
-
integrationName: string
|
69
|
-
networkType?: string
|
70
|
-
targetChainId?: number
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
export interface WalletBrowserSignRequest extends WalletBrowserEventBase {
|
75
|
-
type: 'walletBrowserSignRequest'
|
76
|
-
payload: {
|
77
|
-
address: `0x${string}`
|
78
|
-
message: string
|
79
|
-
walletName?: string
|
80
|
-
networkType?: NetworkType
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
export interface WalletBrowserChainSwitchRequest
|
85
|
-
extends WalletBrowserEventBase {
|
86
|
-
type: 'walletBrowserChainSwitchRequest'
|
87
|
-
payload: {
|
88
|
-
chainId: number
|
89
|
-
networkType: NetworkType
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
export interface WalletBrowserTransferBalanceRequest
|
94
|
-
extends WalletBrowserEventBase {
|
95
|
-
type: 'walletBrowserTransferBalanceRequest'
|
96
|
-
payload: {
|
97
|
-
account: string
|
98
|
-
chainId: number
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
export interface WalletBrowserNativeTransferRequest
|
103
|
-
extends WalletBrowserEventBase {
|
104
|
-
type: 'walletBrowserNativeTransferRequest'
|
105
|
-
payload: {
|
106
|
-
toAddress: string
|
107
|
-
amount: number
|
108
|
-
decimalPlaces: number
|
109
|
-
chainId: number
|
110
|
-
account: string
|
111
|
-
network: string
|
112
|
-
blockhash?: string
|
113
|
-
walletName?: string
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
interface SmartContractPayload {
|
118
|
-
address: string
|
119
|
-
abi: string
|
120
|
-
functionName: string
|
121
|
-
args: unknown[]
|
122
|
-
account: string
|
123
|
-
value?: string
|
124
|
-
}
|
125
|
-
|
126
|
-
export interface WalletBrowserNonNativeTransferRequest
|
127
|
-
extends WalletBrowserEventBase {
|
128
|
-
type: 'walletBrowserNonNativeTransferRequest'
|
129
|
-
payload: SmartContractPayload
|
130
|
-
}
|
131
|
-
|
132
|
-
export interface WalletBrowserNativeSmartDeposit
|
133
|
-
extends WalletBrowserEventBase {
|
134
|
-
type: 'walletBrowserNativeSmartDeposit'
|
135
|
-
payload: SmartContractPayload
|
136
|
-
}
|
137
|
-
|
138
|
-
export interface WalletBrowserNonNativeSmartDeposit
|
139
|
-
extends WalletBrowserEventBase {
|
140
|
-
type: 'walletBrowserNonNativeSmartDeposit'
|
141
|
-
payload: SmartContractPayload
|
142
|
-
}
|
143
|
-
|
144
|
-
export interface WalletBrowserDisconnect extends WalletBrowserEventBase {
|
145
|
-
type: 'walletBrowserDisconnect'
|
146
|
-
payload?: {
|
147
|
-
networkType?: NetworkType
|
148
|
-
walletName?: string
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
export interface WalletBrowserTransactionBatch extends WalletBrowserEventBase {
|
153
|
-
type: 'walletBrowserTransactionBatchRequest'
|
154
|
-
payload: {
|
155
|
-
version: string
|
156
|
-
from: string
|
157
|
-
chainId: string
|
158
|
-
atomicRequired: boolean
|
159
|
-
calls: {
|
160
|
-
to: string
|
161
|
-
value: string
|
162
|
-
data?: string
|
163
|
-
}[]
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
export interface WalletBrowserWalletCapabilities
|
168
|
-
extends WalletBrowserEventBase {
|
169
|
-
type: 'walletBrowserWalletCapabilities'
|
170
|
-
payload: {
|
171
|
-
from: string
|
172
|
-
chainId: string
|
173
|
-
}
|
174
|
-
}
|
175
|
-
|
176
|
-
export interface WalletBrowserSolanaTransferWithInstructionsRequest
|
177
|
-
extends WalletBrowserEventBase {
|
178
|
-
type: 'walletBrowserSolanaTransferWithInstructionsRequest'
|
179
|
-
payload: {
|
180
|
-
transactionInstructions: {
|
181
|
-
instructions: TransactionInstructionDto[]
|
182
|
-
states: AddressLookupTableStateDto[]
|
183
|
-
account: string
|
184
|
-
blockhash: string
|
185
|
-
walletName?: string
|
186
|
-
network?: string
|
187
|
-
}
|
188
|
-
transferConfig: SmartContractPayload
|
189
|
-
}
|
190
|
-
}
|
package/tools/copy.js
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import fs from 'fs'
|
2
|
-
|
3
|
-
const rawData = fs.readFileSync('package.json')
|
4
|
-
const packageModel = JSON.parse(rawData)
|
5
|
-
delete packageModel.main
|
6
|
-
delete packageModel.module
|
7
|
-
delete packageModel.types
|
8
|
-
delete packageModel.scripts
|
9
|
-
delete packageModel.type
|
10
|
-
|
11
|
-
packageModel.exports = './index.js'
|
12
|
-
packageModel.module = './index.js'
|
13
|
-
packageModel.main = './index.js'
|
14
|
-
packageModel.types = './index.d.ts'
|
15
|
-
|
16
|
-
const versionFromNodeApi = fs.readFileSync('../node-api/package.json')
|
17
|
-
const version = JSON.parse(versionFromNodeApi).version
|
18
|
-
|
19
|
-
packageModel.dependencies['@meshconnect/node-api'] = `^${version}`
|
20
|
-
|
21
|
-
const data = JSON.stringify(packageModel, null, 2)
|
22
|
-
fs.writeFileSync('dist/package.json', data)
|
23
|
-
console.log('package.json.dist was copied to ./dist folder')
|
24
|
-
|
25
|
-
fs.copyFileSync('README.md', 'dist/README.md')
|
26
|
-
console.log('README.md was copied to ./dist folder')
|
package/tools/update-version.js
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import fs from 'fs'
|
2
|
-
|
3
|
-
const rawData = fs.readFileSync('package.json')
|
4
|
-
const packageModel = JSON.parse(rawData)
|
5
|
-
const version = packageModel?.version || '2.0.0'
|
6
|
-
|
7
|
-
fs.writeFileSync(
|
8
|
-
'src/utils/version.ts',
|
9
|
-
`export const sdkVersion = '${version}'\n`
|
10
|
-
)
|
package/tsconfig.json
DELETED