Fix few things
This commit is contained in:
@@ -566,6 +566,7 @@ export const initAddressImpl = async (
|
||||
console.log('exchangeRouterAllowance', exchangeRouterAllowance)
|
||||
|
||||
let exchangeRouterHash = "";
|
||||
console.log('approveAmount', approveAmount)
|
||||
if (exchangeRouterAllowance < approveAmount) {
|
||||
exchangeRouterHash = await approveContractImpl(
|
||||
address,
|
||||
@@ -782,7 +783,6 @@ export const getWalletBalanceImpl = async (
|
||||
|
||||
// Get user by wallet address
|
||||
const user = await privy.getUserByWalletAddress(address);
|
||||
|
||||
if (!user) {
|
||||
throw new Error(`User not found for wallet address: ${address}`);
|
||||
}
|
||||
|
||||
26
src/Managing.Web3Proxy/test/plugins/initPrivyWallet.test.ts
Normal file
26
src/Managing.Web3Proxy/test/plugins/initPrivyWallet.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {test} from 'node:test'
|
||||
import assert from 'node:assert'
|
||||
import {initAddressImpl} from '../../src/plugins/custom/privy'
|
||||
|
||||
test('Privy Wallet Initialization', async (t) => {
|
||||
await t.test('should initialize a wallet address for GMX trading', async () => {
|
||||
const address = '0x0b4a132cb6ed8fa66953bf61a53d0b91dacaad78'
|
||||
|
||||
const result = await initAddressImpl(address)
|
||||
|
||||
console.log('Wallet initialization result:', result)
|
||||
|
||||
// Verify the result structure
|
||||
assert.ok(result, 'Wallet initialization result should be defined')
|
||||
assert.ok(result.usdcHash, 'USDC hash should be defined')
|
||||
assert.ok(result.orderVaultHash, 'Order vault hash should be defined')
|
||||
assert.ok(result.exchangeRouterHash, 'Exchange router hash should be defined')
|
||||
assert.ok(result.wethSyntheticsRouterHash, 'WETH synthetics router hash should be defined')
|
||||
|
||||
// Verify all hashes are strings
|
||||
assert.strictEqual(typeof result.usdcHash, 'string', 'USDC hash should be a string')
|
||||
assert.strictEqual(typeof result.orderVaultHash, 'string', 'Order vault hash should be a string')
|
||||
assert.strictEqual(typeof result.exchangeRouterHash, 'string', 'Exchange router hash should be a string')
|
||||
assert.strictEqual(typeof result.wethSyntheticsRouterHash, 'string', 'WETH synthetics router hash should be a string')
|
||||
})
|
||||
})
|
||||
@@ -5,17 +5,17 @@ import {Ticker, TradeDirection} from '../../src/generated/ManagingApiTypes'
|
||||
|
||||
test('GMX Position Opening', async (t) => {
|
||||
await t.test('should open a long position for BTC', async () => {
|
||||
const sdk = await getClientForAddress('0x932167388dD9aad41149b3cA23eBD489E2E2DD78')
|
||||
const sdk = await getClientForAddress('0x0b4A132cb6ed8fa66953bf61a53D0B91DaCaAd78')
|
||||
|
||||
const result = await openGmxPositionImpl(
|
||||
sdk,
|
||||
Ticker.ETH,
|
||||
Ticker.BTC,
|
||||
TradeDirection.Long,
|
||||
0.00678,
|
||||
0.00009129924572776991,
|
||||
2,
|
||||
4410,
|
||||
3500,
|
||||
6000
|
||||
111350,
|
||||
110000,
|
||||
114000
|
||||
)
|
||||
console.log('Position opening result:', result)
|
||||
assert.ok(result, 'Position opening result should be defined')
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { test } from 'node:test'
|
||||
import Fastify from 'fastify'
|
||||
import scryptPlugin from '../../src/plugins/custom/scrypt.js'
|
||||
import assert from 'node:assert'
|
||||
|
||||
test('scrypt works standalone', async t => {
|
||||
const app = Fastify()
|
||||
|
||||
t.after(() => app.close())
|
||||
|
||||
app.register(scryptPlugin)
|
||||
|
||||
await app.ready()
|
||||
|
||||
const password = 'test_password'
|
||||
const hash = await app.hash(password)
|
||||
assert.ok(typeof hash === 'string')
|
||||
|
||||
const isValid = await app.compare(password, hash)
|
||||
assert.ok(isValid, 'compare should return true for correct password')
|
||||
|
||||
const isInvalid = await app.compare('wrong_password', hash)
|
||||
assert.ok(!isInvalid, 'compare should return false for incorrect password')
|
||||
|
||||
await assert.rejects(
|
||||
() => app.compare(password, 'malformed_hash'),
|
||||
'compare should throw an error for malformed hash'
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user