Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
781 changes: 336 additions & 445 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"dist",
"src",
"README.md",
"LICENSE"
"LICENSE",
"tsconfig.json"
],
"exports": {
".": {
Expand All @@ -28,14 +29,14 @@
},
"homepage": "https://github.com/tetherto/wdk-react-native-core#readme",
"scripts": {
"build": "tsc || true",
"build": "tsc",
"build:strict": "tsc",
"typecheck": "tsc --noEmit",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"prepack": "npm run build",
"postinstall": "npm run build"
"prepare": "npm run build"
},
"keywords": [
"wallet",
Expand All @@ -52,7 +53,7 @@
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"@tetherto/wdk-react-native-secure-storage": "github:tetherto/wdk-react-native-secure-storage",
"@tetherto/wdk-react-native-secure-storage": "github:nampc1/wdk-react-native-secure-storage-fork#dev",
"@tetherto/pear-wrk-wdk": "github:tetherto/pear-wrk-wdk#v2",
"@tanstack/react-query": "^5.0.0",
"expo-crypto": "^15.0.8",
Expand Down
3 changes: 3 additions & 0 deletions src/__mocks__/secureStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const mockSecureStorage = {
_clearStorage: () => {
Object.keys(storage).forEach(key => delete storage[key])
},
isDeviceSecurityEnabled: jest.fn(() => {
return Promise.resolve(true)
})
}

export default mockSecureStorage
29 changes: 16 additions & 13 deletions src/__tests__/services/accountService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ describe('AccountService', () => {
'ethereum',
0,
'transfer',
mockArgs
{
recipient: '0x123',
amount: '1000',
token: '0x123'
}
)

expect(result).toEqual(mockResult)
Expand Down Expand Up @@ -258,7 +262,7 @@ describe('AccountService', () => {
})

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow('Invalid balance format')
})

Expand All @@ -270,22 +274,21 @@ describe('AccountService', () => {
const result = await AccountService.callAccountMethod(
'ethereum',
0,
'getBalance',
null
'getBalance'
)

expect(result).toBe('1000000000000000000')
})

it('should validate network name', async () => {
await expect(
AccountService.callAccountMethod('', 0, 'getBalance', null)
AccountService.callAccountMethod('', 0, 'getBalance')
).rejects.toThrow(/network.*non-empty|Network name must contain only|String must contain at least 1 character/)
})

it('should validate account index', async () => {
await expect(
AccountService.callAccountMethod('ethereum', -1, 'getBalance', null)
AccountService.callAccountMethod('ethereum', -1, 'getBalance')
).rejects.toThrow(/accountIndex.*non-negative|Number must be greater than or equal to 0/)
})

Expand All @@ -296,7 +299,7 @@ describe('AccountService', () => {
}))

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow('WDK not initialized')
})

Expand All @@ -307,7 +310,7 @@ describe('AccountService', () => {
}))

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow('WDK not initialized')
})

Expand All @@ -318,7 +321,7 @@ describe('AccountService', () => {
})

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow(/Method getBalance returned no result|Expected string/)
})

Expand All @@ -328,7 +331,7 @@ describe('AccountService', () => {
})

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow('Parsed result is null or undefined')
})

Expand All @@ -338,7 +341,7 @@ describe('AccountService', () => {
})

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow('Parsed result is null or undefined')
})

Expand All @@ -348,15 +351,15 @@ describe('AccountService', () => {
})

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow('Failed to parse result from getBalance')
})

it('should handle worklet call errors', async () => {
mockHRPC.callMethod.mockRejectedValue(new Error('Worklet error'))

await expect(
AccountService.callAccountMethod('ethereum', 0, 'getBalance', null)
AccountService.callAccountMethod('ethereum', 0, 'getBalance')
).rejects.toThrow()
})
})
Expand Down
Loading
Loading