@renegade-fi/core
Advanced tools
Comparing version 0.4.12 to 0.4.13
@@ -16,3 +16,3 @@ import invariant from 'tiny-invariant'; | ||
const res = await postWithSymmetricKey(config, { | ||
url: config.getAuthServerUrl(ASSEMBLE_EXTERNAL_MATCH_ROUTE), | ||
url: config.getBaseUrl(ASSEMBLE_EXTERNAL_MATCH_ROUTE), | ||
body, | ||
@@ -19,0 +19,0 @@ key: symmetricKey, |
@@ -5,5 +5,5 @@ import { ADMIN_ASSIGN_ORDER_ROUTE } from '../constants.js'; | ||
const { orderId, matchingPool } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
try { | ||
await postRelayerWithAdmin(config, getRelayerBaseUrl(ADMIN_ASSIGN_ORDER_ROUTE(orderId, matchingPool))); | ||
await postRelayerWithAdmin(config, getBaseUrl(ADMIN_ASSIGN_ORDER_ROUTE(orderId, matchingPool))); | ||
} | ||
@@ -10,0 +10,0 @@ catch (error) { |
@@ -8,10 +8,17 @@ import invariant from 'tiny-invariant'; | ||
export async function cancelOrder(config, parameters) { | ||
const { id } = parameters; | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'Seed is required'); | ||
const { id, newPublicKey } = parameters; | ||
const { getBaseUrl, utils, renegadeKeyType } = config; | ||
const walletId = getWalletId(config); | ||
const wallet = await getBackOfQueueWallet(config); | ||
const body = utils.cancel_order(seed, stringifyForWasm(wallet), id); | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined; | ||
const signMessage = renegadeKeyType === 'external' ? config.signMessage : undefined; | ||
if (renegadeKeyType === 'external') { | ||
invariant(signMessage !== undefined, 'Sign message function is required for external key type'); | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type'); | ||
} | ||
const body = await utils.cancel_order(seed, stringifyForWasm(wallet), id, newPublicKey, signMessage); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), body); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), body); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -18,0 +25,0 @@ return { taskId: res.task_id }; |
@@ -6,6 +6,6 @@ import { CANCEL_ORDER_ROUTE } from '../constants.js'; | ||
const { request, id } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), request); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), request); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -12,0 +12,0 @@ return { taskId: res.task_id }; |
@@ -5,5 +5,5 @@ import { ADMIN_MATCHING_POOL_CREATE_ROUTE } from '../constants.js'; | ||
const { matchingPool } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
try { | ||
await postRelayerWithAdmin(config, getRelayerBaseUrl(ADMIN_MATCHING_POOL_CREATE_ROUTE(matchingPool))); | ||
await postRelayerWithAdmin(config, getBaseUrl(ADMIN_MATCHING_POOL_CREATE_ROUTE(matchingPool))); | ||
} | ||
@@ -10,0 +10,0 @@ catch (error) { |
@@ -9,10 +9,17 @@ import invariant from 'tiny-invariant'; | ||
export async function createOrder(config, parameters) { | ||
const { id = '', base, quote, side, amount, worstCasePrice = '', minFillSize = BigInt(0), allowExternalMatches = false, } = parameters; | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'Seed is required'); | ||
const { id = '', base, quote, side, amount, worstCasePrice = '', minFillSize = BigInt(0), allowExternalMatches = false, newPublicKey, } = parameters; | ||
const { getBaseUrl, utils, renegadeKeyType } = config; | ||
const walletId = getWalletId(config); | ||
const wallet = await getBackOfQueueWallet(config); | ||
const body = utils.new_order(seed, stringifyForWasm(wallet), id, base, quote, side, toHex(amount), worstCasePrice, toHex(minFillSize), allowExternalMatches); | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined; | ||
const signMessage = renegadeKeyType === 'external' ? config.signMessage : undefined; | ||
if (renegadeKeyType === 'external') { | ||
invariant(signMessage !== undefined, 'Sign message function is required for external key type'); | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type'); | ||
} | ||
const body = await utils.new_order(seed, stringifyForWasm(wallet), id, base, quote, side, toHex(amount), worstCasePrice, toHex(minFillSize), allowExternalMatches, newPublicKey, signMessage); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(WALLET_ORDERS_ROUTE(walletId)), body); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(WALLET_ORDERS_ROUTE(walletId)), body); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -19,0 +26,0 @@ return { taskId: res.task_id }; |
@@ -10,9 +10,9 @@ import invariant from 'tiny-invariant'; | ||
const { id = '', base, quote, side, amount, worstCasePrice = '', minFillSize = BigInt(0), allowExternalMatches = false, matchingPool, } = parameters; | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
const { getBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'Seed is required'); | ||
const walletId = getWalletId(config); | ||
const wallet = await getBackOfQueueWallet(config); | ||
const body = utils.new_order_in_matching_pool(seed, stringifyForWasm(wallet), id, base, quote, side, toHex(amount), worstCasePrice, toHex(minFillSize), allowExternalMatches, matchingPool); | ||
const body = await utils.new_order_in_matching_pool(seed, stringifyForWasm(wallet), id, base, quote, side, toHex(amount), worstCasePrice, toHex(minFillSize), allowExternalMatches, matchingPool); | ||
try { | ||
const res = await postRelayerWithAdmin(config, getRelayerBaseUrl(ADMIN_CREATE_ORDER_IN_MATCHING_POOL_ROUTE(walletId)), body); | ||
const res = await postRelayerWithAdmin(config, getBaseUrl(ADMIN_CREATE_ORDER_IN_MATCHING_POOL_ROUTE(walletId)), body); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -19,0 +19,0 @@ return { taskId: res.task_id }; |
@@ -6,6 +6,6 @@ import { WALLET_ORDERS_ROUTE } from '../constants.js'; | ||
const { request } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(WALLET_ORDERS_ROUTE(walletId)), request); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(WALLET_ORDERS_ROUTE(walletId)), request); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -12,0 +12,0 @@ return { taskId: res.task_id }; |
@@ -6,12 +6,26 @@ import invariant from 'tiny-invariant'; | ||
import { waitForWalletIndexing } from './waitForWalletIndexing.js'; | ||
export async function createWallet(config) { | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'seed is required'); | ||
const body = utils.create_wallet(seed); | ||
export async function createWallet(config, parameters = {}) { | ||
const { getBaseUrl, utils } = config; | ||
let body; | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
}; | ||
const res = await postRelayerRaw(getRelayerBaseUrl(CREATE_WALLET_ROUTE), body, headers); | ||
if (config.renegadeKeyType === 'internal') { | ||
const { seed } = config.state; | ||
invariant(seed, 'seed is required'); | ||
body = utils.create_wallet(seed); | ||
} | ||
else { | ||
const { blinderSeed, shareSeed, skMatch } = parameters; | ||
const { walletId, publicKey, symmetricKey } = config; | ||
invariant(blinderSeed, 'blinderSeed is required'); | ||
invariant(shareSeed, 'shareSeed is required'); | ||
invariant(skMatch, 'skMatch is required'); | ||
body = await utils.create_external_wallet(walletId, blinderSeed, shareSeed, publicKey, skMatch, symmetricKey); | ||
} | ||
const res = await postRelayerRaw(getBaseUrl(CREATE_WALLET_ROUTE), body, headers); | ||
if (res.task_id) { | ||
config.setState((x) => ({ ...x, status: 'creating wallet' })); | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ ...x, status: 'creating wallet' })); | ||
} | ||
console.log(`task create-wallet(${res.task_id}): ${res.wallet_id}`, { | ||
@@ -24,3 +38,5 @@ status: 'creating wallet', | ||
onComplete: (wallet) => { | ||
config.setState((x) => ({ ...x, status: 'in relayer' })); | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ ...x, status: 'in relayer' })); | ||
} | ||
console.log(`task create-wallet(${res.task_id}) completed: ${wallet.id}`, { | ||
@@ -32,7 +48,6 @@ status: 'in relayer', | ||
onFailure: () => { | ||
console.error(`wallet id: ${config.state.id} creating wallet failed`, { | ||
status: 'creating wallet', | ||
walletId: config.state.id, | ||
}); | ||
config.setState({}); | ||
console.log(`task create-wallet(${res.task_id}) failed`); | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState({}); | ||
} | ||
}, | ||
@@ -39,0 +54,0 @@ }); |
import invariant from 'tiny-invariant'; | ||
import { toHex } from 'viem'; | ||
import { DEPOSIT_BALANCE_ROUTE } from '../constants.js'; | ||
import { Token } from '../types/token.js'; | ||
import { stringifyForWasm } from '../utils/bigJSON.js'; | ||
@@ -10,13 +9,19 @@ import { postRelayerWithAuth } from '../utils/http.js'; | ||
export async function deposit(config, parameters) { | ||
const { fromAddr, mint, amount, permitNonce, permitDeadline, permit } = parameters; | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'Seed is required'); | ||
const token = Token.findByAddress(mint); | ||
invariant(token, 'Token not found'); | ||
const { amount, fromAddr, mint, newPublicKey, permit, permitDeadline, permitNonce, } = parameters; | ||
const { getBaseUrl, utils, renegadeKeyType } = config; | ||
const walletId = getWalletId(config); | ||
const wallet = await getBackOfQueueWallet(config); | ||
const walletStr = stringifyForWasm(wallet); | ||
const body = utils.deposit(seed, walletStr, fromAddr, mint, toHex(amount), toHex(permitNonce), toHex(permitDeadline), permit); | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined; | ||
const signMessage = renegadeKeyType === 'external' ? config.signMessage : undefined; | ||
if (renegadeKeyType === 'external') { | ||
invariant(signMessage !== undefined, 'Sign message function is required for external key type'); | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type'); | ||
} | ||
const body = await utils.deposit( | ||
// TODO: Change Rust to accept Option<String> | ||
seed, stringifyForWasm(wallet), fromAddr, mint, toHex(amount), toHex(permitNonce), toHex(permitDeadline), permit, newPublicKey, signMessage); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), body); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), body); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -23,0 +28,0 @@ return { taskId: res.task_id }; |
@@ -6,6 +6,6 @@ import { DEPOSIT_BALANCE_ROUTE } from '../constants.js'; | ||
const { request } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), request); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), request); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -12,0 +12,0 @@ return { taskId: res.task_id }; |
@@ -5,5 +5,5 @@ import { ADMIN_MATCHING_POOL_DESTROY_ROUTE } from '../constants.js'; | ||
const { matchingPool } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
try { | ||
await postRelayerWithAdmin(config, getRelayerBaseUrl(ADMIN_MATCHING_POOL_DESTROY_ROUTE(matchingPool))); | ||
await postRelayerWithAdmin(config, getBaseUrl(ADMIN_MATCHING_POOL_DESTROY_ROUTE(matchingPool))); | ||
} | ||
@@ -10,0 +10,0 @@ catch (error) { |
@@ -7,5 +7,5 @@ import { BACK_OF_QUEUE_WALLET_ROUTE } from '../constants.js'; | ||
const { filterDefaults } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(BACK_OF_QUEUE_WALLET_ROUTE(walletId))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(BACK_OF_QUEUE_WALLET_ROUTE(walletId))); | ||
if (!res.wallet) { | ||
@@ -12,0 +12,0 @@ throw new BaseError('Back of queue wallet not found'); |
@@ -5,7 +5,7 @@ import { GET_BALANCES_ROUTE } from '../constants.js'; | ||
export async function getBalances(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(GET_BALANCES_ROUTE(walletId))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(GET_BALANCES_ROUTE(walletId))); | ||
return res.balances; | ||
} | ||
//# sourceMappingURL=getBalances.js.map |
@@ -14,3 +14,3 @@ import invariant from 'tiny-invariant'; | ||
const res = await postWithSymmetricKey(config, { | ||
url: config.getAuthServerUrl(REQUEST_EXTERNAL_MATCH_ROUTE), | ||
url: config.getBaseUrl(REQUEST_EXTERNAL_MATCH_ROUTE), | ||
body, | ||
@@ -17,0 +17,0 @@ key: symmetricKey, |
@@ -14,3 +14,3 @@ import invariant from 'tiny-invariant'; | ||
const res = await postWithSymmetricKey(config, { | ||
url: config.getAuthServerUrl(REQUEST_EXTERNAL_MATCH_QUOTE_ROUTE), | ||
url: config.getBaseUrl(REQUEST_EXTERNAL_MATCH_QUOTE_ROUTE), | ||
body, | ||
@@ -17,0 +17,0 @@ key: symmetricKey, |
@@ -5,4 +5,4 @@ import { getRelayerRaw } from '../utils/http.js'; | ||
export async function getNetworkOrders(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const res = await getRelayerRaw(getRelayerBaseUrl(GET_NETWORK_ORDERS_ROUTE)); | ||
const { getBaseUrl } = config; | ||
const res = await getRelayerRaw(getBaseUrl(GET_NETWORK_ORDERS_ROUTE)); | ||
if (!res.orders) { | ||
@@ -9,0 +9,0 @@ throw new BaseError('No orders found'); |
@@ -5,4 +5,4 @@ import { ADMIN_OPEN_ORDERS_ROUTE } from '../constants.js'; | ||
export async function getOpenOrders(config, parameters = {}) { | ||
const { getRelayerBaseUrl } = config; | ||
const url = new URL(getRelayerBaseUrl(ADMIN_OPEN_ORDERS_ROUTE)); | ||
const { getBaseUrl } = config; | ||
const url = new URL(getBaseUrl(ADMIN_OPEN_ORDERS_ROUTE)); | ||
if (parameters.matchingPool) { | ||
@@ -9,0 +9,0 @@ url.searchParams.set('matching_pool', parameters.matchingPool); |
@@ -6,7 +6,7 @@ import { GET_ORDER_BY_ID_ROUTE } from '../constants.js'; | ||
const { id } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(GET_ORDER_BY_ID_ROUTE(walletId, id))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(GET_ORDER_BY_ID_ROUTE(walletId, id))); | ||
return res.order; | ||
} | ||
//# sourceMappingURL=getOrder.js.map |
@@ -6,6 +6,6 @@ import { ORDER_HISTORY_LEN_PARAM, ORDER_HISTORY_ROUTE } from '../constants.js'; | ||
export async function getOrderHistory(config, parameters = {}) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const { limit } = parameters; | ||
const walletId = getWalletId(config); | ||
let url = getRelayerBaseUrl(ORDER_HISTORY_ROUTE(walletId)); | ||
let url = getBaseUrl(ORDER_HISTORY_ROUTE(walletId)); | ||
if (limit !== undefined) { | ||
@@ -12,0 +12,0 @@ const searchParams = new URLSearchParams({ |
@@ -5,5 +5,5 @@ import { ADMIN_GET_ORDER_MATCHING_POOL_ROUTE } from '../constants.js'; | ||
const { orderId } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
try { | ||
const res = await getRelayerWithAdmin(config, getRelayerBaseUrl(ADMIN_GET_ORDER_MATCHING_POOL_ROUTE(orderId))); | ||
const res = await getRelayerWithAdmin(config, getBaseUrl(ADMIN_GET_ORDER_MATCHING_POOL_ROUTE(orderId))); | ||
return res.matching_pool; | ||
@@ -10,0 +10,0 @@ } |
@@ -6,4 +6,4 @@ import { ADMIN_ORDER_METADATA_ROUTE } from '../constants.js'; | ||
const { id } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const url = new URL(getRelayerBaseUrl(ADMIN_ORDER_METADATA_ROUTE(id))); | ||
const { getBaseUrl } = config; | ||
const url = new URL(getBaseUrl(ADMIN_ORDER_METADATA_ROUTE(id))); | ||
if (parameters.includeFillable) { | ||
@@ -10,0 +10,0 @@ url.searchParams.set('include_fillable', String(true)); |
@@ -5,7 +5,7 @@ import { WALLET_ORDERS_ROUTE } from '../constants.js'; | ||
export async function getOrders(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(WALLET_ORDERS_ROUTE(walletId))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(WALLET_ORDERS_ROUTE(walletId))); | ||
return res.orders; | ||
} | ||
//# sourceMappingURL=getOrders.js.map |
@@ -6,11 +6,17 @@ import invariant from 'tiny-invariant'; | ||
invariant(seed, 'Seed is required'); | ||
invariant(nonce, 'Nonce is required'); | ||
return `0x${utils.get_pk_root(seed, nonce)}`; | ||
} | ||
export function getPkRootScalars(config, parameters = { nonce: BigInt(0) }) { | ||
const { utils, state: { seed }, } = config; | ||
export function getPkRootScalars(config, parameters = {}) { | ||
const { utils, renegadeKeyType } = config; | ||
const { nonce } = parameters; | ||
invariant(seed, 'Seed is required'); | ||
const scalars = utils.get_pk_root_scalars(seed, nonce); | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined; | ||
const publicKey = renegadeKeyType === 'external' ? config.publicKey : undefined; | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type'); | ||
invariant(nonce !== undefined, 'Nonce is required for internal key type'); | ||
} | ||
const scalars = utils.get_pk_root_scalars(seed, nonce, publicKey); | ||
return scalars.map((s) => BigInt(s)).slice(0, 4); | ||
} | ||
//# sourceMappingURL=getPkRoot.js.map |
@@ -6,5 +6,5 @@ import { getWalletId } from './getWalletId.js'; | ||
export async function getTaskHistory(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(TASK_HISTORY_ROUTE(walletId))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(TASK_HISTORY_ROUTE(walletId))); | ||
if (!res.tasks) { | ||
@@ -11,0 +11,0 @@ throw new BaseError('No tasks found'); |
@@ -5,7 +5,7 @@ import { getWalletId } from './getWalletId.js'; | ||
export async function getTaskQueue(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(GET_TASK_QUEUE_ROUTE(walletId))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(GET_TASK_QUEUE_ROUTE(walletId))); | ||
return res.tasks; | ||
} | ||
//# sourceMappingURL=getTaskQueue.js.map |
@@ -5,6 +5,6 @@ import { getRelayerWithAuth } from '../utils/http.js'; | ||
const { id } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(GET_TASK_STATUS_ROUTE(id))); | ||
const { getBaseUrl } = config; | ||
const res = await getRelayerWithAuth(config, getBaseUrl(GET_TASK_STATUS_ROUTE(id))); | ||
return res.status; | ||
} | ||
//# sourceMappingURL=getTaskStatus.js.map |
@@ -7,5 +7,5 @@ import { GET_WALLET_ROUTE } from '../constants.js'; | ||
const { filterDefaults } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
const res = await getRelayerWithAuth(config, getRelayerBaseUrl(GET_WALLET_ROUTE(walletId))); | ||
const res = await getRelayerWithAuth(config, getBaseUrl(GET_WALLET_ROUTE(walletId))); | ||
if (!res.wallet) { | ||
@@ -12,0 +12,0 @@ throw new BaseError('Wallet not found'); |
import invariant from 'tiny-invariant'; | ||
export function getWalletId(config) { | ||
if (config.renegadeKeyType === 'external') { | ||
return config.walletId; | ||
} | ||
const { utils, state: { seed }, } = config; | ||
@@ -4,0 +7,0 @@ invariant(seed, 'seed is required'); |
@@ -6,4 +6,4 @@ import { ADMIN_WALLET_MATCHABLE_ORDER_IDS_ROUTE } from '../constants.js'; | ||
const { id } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const res = await getRelayerWithAdmin(config, getRelayerBaseUrl(ADMIN_WALLET_MATCHABLE_ORDER_IDS_ROUTE(id))); | ||
const { getBaseUrl } = config; | ||
const res = await getRelayerWithAdmin(config, getBaseUrl(ADMIN_WALLET_MATCHABLE_ORDER_IDS_ROUTE(id))); | ||
if (!res.order_ids) { | ||
@@ -10,0 +10,0 @@ throw new BaseError('No orders found'); |
@@ -7,7 +7,19 @@ import invariant from 'tiny-invariant'; | ||
import { waitForWalletIndexing } from './waitForWalletIndexing.js'; | ||
export async function lookupWallet(config) { | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'seed is required'); | ||
const body = utils.find_wallet(seed); | ||
const res = await postRelayerRaw(getRelayerBaseUrl(FIND_WALLET_ROUTE), body); | ||
export async function lookupWallet(config, parameters = {}) { | ||
const { getBaseUrl, utils } = config; | ||
let body; | ||
if (config.renegadeKeyType === 'internal') { | ||
const { seed } = config.state; | ||
invariant(seed, 'seed is required'); | ||
body = utils.find_wallet(seed); | ||
} | ||
else { | ||
const { blinderSeed, shareSeed, skMatch } = parameters; | ||
const { walletId, publicKey, symmetricKey } = config; | ||
invariant(blinderSeed, 'blinderSeed is required'); | ||
invariant(shareSeed, 'shareSeed is required'); | ||
invariant(skMatch, 'skMatch is required'); | ||
body = await utils.find_external_wallet(walletId, blinderSeed, shareSeed, publicKey, skMatch, symmetricKey); | ||
} | ||
const res = await postRelayerRaw(getBaseUrl(FIND_WALLET_ROUTE), body); | ||
if (res.task_id) { | ||
@@ -18,3 +30,5 @@ console.log(`task lookup-wallet(${res.task_id}): ${res.wallet_id}`, { | ||
}); | ||
config.setState((x) => ({ ...x, status: 'looking up' })); | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ ...x, status: 'looking up' })); | ||
} | ||
return waitForWalletIndexing(config, { | ||
@@ -24,6 +38,8 @@ timeout: 300000, | ||
onComplete(wallet) { | ||
config.setState((x) => ({ | ||
...x, | ||
status: 'in relayer', | ||
})); | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ | ||
...x, | ||
status: 'in relayer', | ||
})); | ||
} | ||
console.log(`task lookup-wallet(${res.task_id}) completed: ${wallet.id}`, { | ||
@@ -35,7 +51,6 @@ status: 'in relayer', | ||
onFailure() { | ||
console.error(`wallet id: ${config.state.id} looking up failed`, { | ||
status: 'looking up', | ||
walletId: config.state.id, | ||
}); | ||
config.setState({}); | ||
console.log(`task lookup-wallet(${res.task_id}) failed: ${res.wallet_id}`); | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState({}); | ||
} | ||
}, | ||
@@ -42,0 +57,0 @@ }); |
@@ -5,6 +5,6 @@ import { PAY_FEES_ROUTE } from '../constants.js'; | ||
export async function payFees(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(PAY_FEES_ROUTE(walletId))); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(PAY_FEES_ROUTE(walletId))); | ||
if (res?.task_ids) { | ||
@@ -11,0 +11,0 @@ res.task_ids.map((id) => { |
@@ -5,5 +5,5 @@ import { PING_ROUTE } from '../constants.js'; | ||
export async function getPing(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
try { | ||
const res = await getRelayerRaw(getRelayerBaseUrl(PING_ROUTE)); | ||
const res = await getRelayerRaw(getBaseUrl(PING_ROUTE)); | ||
if (res?.timestamp) { | ||
@@ -10,0 +10,0 @@ return true; |
@@ -5,6 +5,6 @@ import { REFRESH_WALLET_ROUTE } from '../constants.js'; | ||
export async function refreshWallet(config) { | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(REFRESH_WALLET_ROUTE(walletId))); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(REFRESH_WALLET_ROUTE(walletId))); | ||
if (res?.task_id) { | ||
@@ -11,0 +11,0 @@ console.log(`task refresh-wallet(${res.task_id}): ${walletId}`); |
@@ -10,3 +10,3 @@ import invariant from 'tiny-invariant'; | ||
const { id = '', base, quote, side, amount, worstCasePrice = '', minFillSize = BigInt(0), allowExternalMatches = false, } = parameters; | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
const { getBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'Seed is required'); | ||
@@ -17,3 +17,3 @@ const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(UPDATE_ORDER_ROUTE(walletId, id)), body); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(UPDATE_ORDER_ROUTE(walletId, id)), body); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -20,0 +20,0 @@ return { taskId: res.task_id }; |
import { BaseError } from '../errors/base.js'; | ||
import { getWalletFromRelayer } from './getWalletFromRelayer.js'; | ||
export async function waitForWalletIndexing(config, parameters) { | ||
const { pollingInterval } = config; | ||
const { onComplete, onFailure, timeout = 60000, isLookup } = parameters; | ||
const pollingInterval = config.renegadeKeyType === 'internal' ? config.pollingInterval : 5000; | ||
const startTime = Date.now(); | ||
@@ -7,0 +7,0 @@ while (true) { |
@@ -9,11 +9,17 @@ import invariant from 'tiny-invariant'; | ||
export async function withdraw(config, parameters) { | ||
const { mint, amount, destinationAddr } = parameters; | ||
const { getRelayerBaseUrl, utils, state: { seed }, } = config; | ||
invariant(seed, 'Seed is required'); | ||
const { mint, amount, destinationAddr, newPublicKey } = parameters; | ||
const { getBaseUrl, utils, renegadeKeyType } = config; | ||
const walletId = getWalletId(config); | ||
const wallet = await getBackOfQueueWallet(config); | ||
// Withdraw | ||
const body = utils.withdraw(seed, stringifyForWasm(wallet), mint, toHex(amount), destinationAddr); | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined; | ||
const signMessage = renegadeKeyType === 'external' ? config.signMessage : undefined; | ||
if (renegadeKeyType === 'external') { | ||
invariant(signMessage !== undefined, 'Sign message function is required for external key type'); | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type'); | ||
} | ||
const body = await utils.withdraw(seed, stringifyForWasm(wallet), mint, toHex(amount), destinationAddr, newPublicKey, signMessage); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), body); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), body); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -20,0 +26,0 @@ return { taskId: res.task_id }; |
@@ -6,6 +6,6 @@ import { WITHDRAW_BALANCE_ROUTE } from '../constants.js'; | ||
const { mint, request } = parameters; | ||
const { getRelayerBaseUrl } = config; | ||
const { getBaseUrl } = config; | ||
const walletId = getWalletId(config); | ||
try { | ||
const res = await postRelayerWithAuth(config, getRelayerBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), request); | ||
const res = await postRelayerWithAuth(config, getBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), request); | ||
console.log(`task update-wallet(${res.task_id}): ${walletId}`); | ||
@@ -12,0 +12,0 @@ return { taskId: res.task_id }; |
@@ -15,10 +15,19 @@ import invariant from 'tiny-invariant'; | ||
utils: parameters.utils, | ||
// Not used for wallet operations | ||
renegadeKeyType: 'none', | ||
apiKey, | ||
apiSecret, | ||
getAuthServerUrl: (route = '') => { | ||
getBaseUrl: (route = '') => { | ||
const formattedRoute = route.startsWith('/') ? route : `/${route}`; | ||
return `${authServerUrl}/v0${formattedRoute}`; | ||
}, | ||
getWebsocketBaseUrl: () => { | ||
throw new Error('Not implemented'); | ||
}, | ||
getSymmetricKey: () => { | ||
invariant(parameters.utils, 'Utils are required'); | ||
return parameters.utils.b64_to_hex_hmac_key(apiSecret); | ||
}, | ||
}; | ||
} | ||
//# sourceMappingURL=createAuthConfig.js.map |
@@ -7,2 +7,3 @@ import invariant from 'tiny-invariant'; | ||
import { createStorage, noopStorage } from './createStorage.js'; | ||
import { AuthType } from './utils/websocket.js'; | ||
export function createConfig(parameters) { | ||
@@ -47,2 +48,3 @@ const { relayerUrl, priceReporterUrl, httpPort = 3000, pollingInterval = 5000, ssr, storage = createStorage({ | ||
utils: parameters.utils, | ||
renegadeKeyType: 'internal', | ||
storage, | ||
@@ -52,3 +54,3 @@ relayerUrl, | ||
darkPoolAddress: parameters.darkPoolAddress, | ||
getRelayerBaseUrl: (route = '') => { | ||
getBaseUrl: (route = '') => { | ||
const protocol = useInsecureTransport || parameters.relayerUrl.includes('localhost') | ||
@@ -85,2 +87,14 @@ ? 'http' | ||
}, | ||
getSymmetricKey(type) { | ||
invariant(parameters.utils, 'Utils are required'); | ||
if (type === AuthType.Admin) { | ||
invariant(parameters.adminKey, 'Admin key is required'); | ||
const symmetricKey = parameters.utils.b64_to_hex_hmac_key(parameters.adminKey); | ||
invariant(symmetricKey, 'Admin key is required'); | ||
return symmetricKey; | ||
} | ||
const seed = store.getState().seed; | ||
invariant(seed, 'Seed is required'); | ||
return parameters.utils.get_symmetric_key(seed); | ||
}, | ||
pollingInterval, | ||
@@ -118,2 +132,8 @@ get state() { | ||
} | ||
// The type of keychain a config is using | ||
export const keyTypes = { | ||
EXTERNAL: 'external', | ||
INTERNAL: 'internal', | ||
NONE: 'none', | ||
}; | ||
//# sourceMappingURL=createConfig.js.map |
@@ -50,2 +50,3 @@ //////////////////////////////////////////////////////////////////////////////// | ||
export { createAuthConfig, } from '../createAuthConfig.js'; | ||
export { createExternalKeyConfig, } from '../createExternalKeyConfig.js'; | ||
//////////////////////////////////////////////////////////////////////////////// | ||
@@ -52,0 +53,0 @@ // createStorage |
import axios from 'axios'; | ||
import invariant from 'tiny-invariant'; | ||
import { getSymmetricKey } from '../actions/getSymmetricKey.js'; | ||
import { RENEGADE_AUTH_HEADER_NAME, RENEGADE_SIG_EXPIRATION_HEADER_NAME, SIG_EXPIRATION_BUFFER_MS, } from '../constants.js'; | ||
@@ -101,4 +100,4 @@ import { BaseError } from '../errors/base.js'; | ||
} | ||
export async function postRelayerWithAuth(config, url, body) { | ||
const symmetricKey = getSymmetricKey(config); | ||
export async function postRelayerWithAuth(config, url, body, requestType) { | ||
const symmetricKey = config.getSymmetricKey(requestType); | ||
invariant(symmetricKey, 'Failed to derive symmetric key'); | ||
@@ -124,3 +123,3 @@ const path = getPathFromUrl(url); | ||
export async function getRelayerWithAuth(config, url) { | ||
const symmetricKey = getSymmetricKey(config); | ||
const symmetricKey = config.getSymmetricKey(); | ||
invariant(symmetricKey, 'Failed to derive symmetric key'); | ||
@@ -127,0 +126,0 @@ const path = getPathFromUrl(url); |
@@ -1,2 +0,1 @@ | ||
import { getSymmetricKey } from '../actions/getSymmetricKey.js'; | ||
import { SIG_EXPIRATION_BUFFER_MS } from '../constants.js'; | ||
@@ -111,17 +110,7 @@ import { addExpiringAuthToHeaders } from './http.js'; | ||
} | ||
if (this.authType === AuthType.Wallet) { | ||
const headers = this.buildWalletAuthHeaders(body); | ||
return { | ||
headers, | ||
body, | ||
}; | ||
} | ||
if (this.authType === AuthType.Admin) { | ||
const headers = this.buildAdminAuthHeaders(body); | ||
return { | ||
headers, | ||
body, | ||
}; | ||
} | ||
throw new Error(`Unsupported auth type: ${this.authType}`); | ||
const headers = this.buildAuthHeaders(body); | ||
return { | ||
headers, | ||
body, | ||
}; | ||
} | ||
@@ -136,16 +125,7 @@ buildUnsubscriptionMessage() { | ||
} | ||
buildWalletAuthHeaders(body) { | ||
const symmetricKey = getSymmetricKey(this.config); | ||
buildAuthHeaders(body) { | ||
const symmetricKey = this.config.getSymmetricKey(this.authType); | ||
return addExpiringAuthToHeaders(this.config, body.topic, {}, // Headers | ||
JSON.stringify(body), symmetricKey, SIG_EXPIRATION_BUFFER_MS); | ||
} | ||
buildAdminAuthHeaders(body) { | ||
if (!this.config.adminKey) { | ||
throw new Error('Admin key is required'); | ||
} | ||
const { adminKey } = this.config; | ||
const symmetricKey = this.config.utils.b64_to_hex_hmac_key(adminKey); | ||
return addExpiringAuthToHeaders(this.config, body.topic, {}, // Headers | ||
JSON.stringify(body), symmetricKey, SIG_EXPIRATION_BUFFER_MS); | ||
} | ||
cleanup() { | ||
@@ -152,0 +132,0 @@ this.ws = null; |
@@ -1,5 +0,7 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { Hex } from 'viem'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import type { BaseErrorType } from '../errors/base.js'; | ||
export type CancelOrderParameters = { | ||
id: string; | ||
newPublicKey?: Hex; | ||
}; | ||
@@ -10,3 +12,3 @@ export type CancelOrderReturnType = { | ||
export type CancelOrderErrorType = BaseErrorType; | ||
export declare function cancelOrder(config: Config, parameters: CancelOrderParameters): Promise<CancelOrderReturnType>; | ||
export declare function cancelOrder(config: RenegadeConfig, parameters: CancelOrderParameters): Promise<CancelOrderReturnType>; | ||
//# sourceMappingURL=cancelOrder.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { type Address } from 'viem'; | ||
import type { Config } from '../createConfig.js'; | ||
import { type Address, type Hex } from 'viem'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import type { BaseErrorType } from '../errors/base.js'; | ||
@@ -13,2 +13,3 @@ export type CreateOrderParameters = { | ||
allowExternalMatches?: boolean; | ||
newPublicKey?: Hex; | ||
}; | ||
@@ -19,3 +20,3 @@ export type CreateOrderReturnType = { | ||
export type CreateOrderErrorType = BaseErrorType; | ||
export declare function createOrder(config: Config, parameters: CreateOrderParameters): Promise<CreateOrderReturnType>; | ||
export declare function createOrder(config: RenegadeConfig, parameters: CreateOrderParameters): Promise<CreateOrderReturnType>; | ||
//# sourceMappingURL=createOrder.d.ts.map |
@@ -1,5 +0,10 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import { waitForWalletIndexing } from './waitForWalletIndexing.js'; | ||
export type CreateWalletReturnType = ReturnType<typeof waitForWalletIndexing>; | ||
export declare function createWallet(config: Config): CreateWalletReturnType; | ||
export type CreateWalletParameters = { | ||
blinderSeed?: string; | ||
shareSeed?: string; | ||
skMatch?: string; | ||
}; | ||
export declare function createWallet(config: RenegadeConfig, parameters?: CreateWalletParameters): CreateWalletReturnType; | ||
//# sourceMappingURL=createWallet.d.ts.map |
import { type Address } from 'viem'; | ||
import type { Config } from '../createConfig.js'; | ||
import type { BaseErrorType } from '../errors/base.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
export type DepositParameters = { | ||
amount: bigint; | ||
fromAddr: Address; | ||
mint: Address; | ||
amount: bigint; | ||
newPublicKey?: string; | ||
permit: string; | ||
permitDeadline: bigint; | ||
permitNonce: bigint; | ||
permitDeadline: bigint; | ||
permit: `0x${string}`; | ||
}; | ||
@@ -15,4 +15,3 @@ export type DepositReturnType = Promise<{ | ||
}>; | ||
export type DepositErrorType = BaseErrorType; | ||
export declare function deposit(config: Config, parameters: DepositParameters): DepositReturnType; | ||
export declare function deposit(config: RenegadeConfig, parameters: DepositParameters): DepositReturnType; | ||
//# sourceMappingURL=deposit.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import { type BaseErrorType } from '../errors/base.js'; | ||
@@ -9,3 +9,3 @@ import type { Wallet } from '../types/wallet.js'; | ||
export type GetBackOfQueueWalletErrorType = BaseErrorType; | ||
export declare function getBackOfQueueWallet(config: Config, parameters?: GetBackOfQueueWalletParameters): Promise<GetBackOfQueueWalletReturnType>; | ||
export declare function getBackOfQueueWallet(config: RenegadeConfig, parameters?: GetBackOfQueueWalletParameters): Promise<GetBackOfQueueWalletReturnType>; | ||
//# sourceMappingURL=getBackOfQueueWallet.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import { type BaseErrorType } from '../errors/base.js'; | ||
@@ -9,3 +9,3 @@ import type { OrderMetadata } from '../types/order.js'; | ||
export type GetOrderHistoryErrorType = BaseErrorType; | ||
export declare function getOrderHistory(config: Config, parameters?: GetOrderHistoryParameters): Promise<GetOrderHistoryReturnType>; | ||
export declare function getOrderHistory(config: RenegadeConfig, parameters?: GetOrderHistoryParameters): Promise<GetOrderHistoryReturnType>; | ||
//# sourceMappingURL=getOrderHistory.d.ts.map |
import type { Hex } from 'viem'; | ||
import type { Config } from '../createConfig.js'; | ||
import type { Config, RenegadeConfig } from '../createConfig.js'; | ||
export type GetPkRootParameters = { | ||
nonce: bigint; | ||
nonce?: bigint; | ||
}; | ||
@@ -9,3 +9,3 @@ export type GetPkRootReturnType = Hex; | ||
export declare function getPkRoot(config: Config, parameters?: GetPkRootParameters): GetPkRootReturnType; | ||
export declare function getPkRootScalars(config: Config, parameters?: GetPkRootParameters): GetPkRootScalarsReturnType; | ||
export declare function getPkRootScalars(config: RenegadeConfig, parameters?: GetPkRootParameters): GetPkRootScalarsReturnType; | ||
//# sourceMappingURL=getPkRoot.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import { type BaseErrorType } from '../errors/base.js'; | ||
@@ -6,3 +6,3 @@ import type { Task as TaskHistoryItem } from '../types/task.js'; | ||
export type GetTaskHistoryErrorType = BaseErrorType; | ||
export declare function getTaskHistory(config: Config): Promise<GetTaskHistoryReturnType>; | ||
export declare function getTaskHistory(config: RenegadeConfig): Promise<GetTaskHistoryReturnType>; | ||
//# sourceMappingURL=getTaskHistory.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import { type BaseErrorType } from '../errors/base.js'; | ||
@@ -9,3 +9,3 @@ import type { Wallet } from '../types/wallet.js'; | ||
export type GetWalletFromRelayerErrorType = BaseErrorType; | ||
export declare function getWalletFromRelayer(config: Config, parameters?: GetWalletFromRelayerParameters): Promise<GetWalletFromRelayerReturnType>; | ||
export declare function getWalletFromRelayer(config: RenegadeConfig, parameters?: GetWalletFromRelayerParameters): Promise<GetWalletFromRelayerReturnType>; | ||
//# sourceMappingURL=getWalletFromRelayer.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
export type GetWalletIdReturnType = string; | ||
export declare function getWalletId(config: Config): GetWalletIdReturnType; | ||
export declare function getWalletId(config: RenegadeConfig): GetWalletIdReturnType; | ||
//# sourceMappingURL=getWalletId.d.ts.map |
@@ -1,6 +0,11 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { Config, RenegadeConfig } from '../createConfig.js'; | ||
import { waitForWalletIndexing } from './waitForWalletIndexing.js'; | ||
export type LookupWalletReturnType = ReturnType<typeof waitForWalletIndexing>; | ||
export declare function lookupWallet(config: Config): LookupWalletReturnType; | ||
export type LookupWalletParameters = { | ||
blinderSeed?: string; | ||
shareSeed?: string; | ||
skMatch?: string; | ||
}; | ||
export declare function lookupWallet(config: RenegadeConfig, parameters?: LookupWalletParameters): LookupWalletReturnType; | ||
export declare function checkForWalletUpdatesOnChain(config: Config): Promise<boolean>; | ||
//# sourceMappingURL=lookupWallet.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import type { BaseError } from '../errors/base.js'; | ||
@@ -7,3 +7,3 @@ export type PayFeesReturnType = { | ||
export type PayFeesErrorType = BaseError; | ||
export declare function payFees(config: Config): Promise<PayFeesReturnType>; | ||
export declare function payFees(config: RenegadeConfig): Promise<PayFeesReturnType>; | ||
//# sourceMappingURL=payFees.d.ts.map |
@@ -1,6 +0,6 @@ | ||
import type { Config } from '../createConfig.js'; | ||
export type RefreshWalletReturnType = Promise<{ | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
export type RefreshWalletReturnType = { | ||
taskId: string; | ||
}>; | ||
export declare function refreshWallet(config: Config): RefreshWalletReturnType; | ||
}; | ||
export declare function refreshWallet(config: RenegadeConfig): Promise<RefreshWalletReturnType>; | ||
//# sourceMappingURL=refreshWallet.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import type { WaitForTaskCompletionParameters } from './waitForTaskCompletion.js'; | ||
export declare function waitForTaskCompletionWs(config: Config, parameters: WaitForTaskCompletionParameters): Promise<null | undefined>; | ||
export declare function waitForTaskCompletionWs(config: RenegadeConfig, parameters: WaitForTaskCompletionParameters): Promise<null | undefined>; | ||
//# sourceMappingURL=waitForTaskCompletionWs.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import type { Wallet } from '../types/wallet.js'; | ||
@@ -10,3 +10,3 @@ export type WaitForWalletIndexParameters = { | ||
export type WaitForWalletIndexReturnType = Promise<void>; | ||
export declare function waitForWalletIndexing(config: Config, parameters: WaitForWalletIndexParameters): WaitForWalletIndexReturnType; | ||
export declare function waitForWalletIndexing(config: RenegadeConfig, parameters: WaitForWalletIndexParameters): WaitForWalletIndexReturnType; | ||
//# sourceMappingURL=waitForWalletIndexing.d.ts.map |
import { type Address } from 'viem'; | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
export type WithdrawParameters = { | ||
@@ -7,2 +7,3 @@ mint: Address; | ||
destinationAddr: Address; | ||
newPublicKey?: string; | ||
}; | ||
@@ -12,3 +13,3 @@ export type WithdrawReturnType = Promise<{ | ||
}>; | ||
export declare function withdraw(config: Config, parameters: WithdrawParameters): WithdrawReturnType; | ||
export declare function withdraw(config: RenegadeConfig, parameters: WithdrawParameters): WithdrawReturnType; | ||
//# sourceMappingURL=withdraw.d.ts.map |
@@ -21,4 +21,5 @@ import type { BaseConfig } from './createConfig.js'; | ||
apiKey: string; | ||
getAuthServerUrl: (route?: string) => string; | ||
getBaseUrl: (route?: string) => string; | ||
renegadeKeyType: 'none'; | ||
}; | ||
//# sourceMappingURL=createAuthConfig.d.ts.map |
import { type Address, type Hex, type PublicClient } from 'viem'; | ||
import { type Mutate, type StoreApi } from 'zustand/vanilla'; | ||
import type { ExternalConfig } from './createExternalKeyConfig.js'; | ||
import { type Storage } from './createStorage.js'; | ||
import type { Evaluate, ExactPartial } from './types/utils.js'; | ||
import type * as rustUtils from './utils.d.ts'; | ||
import { AuthType } from './utils/websocket.js'; | ||
export type CreateConfigParameters = { | ||
@@ -20,7 +22,11 @@ darkPoolAddress: Address; | ||
}; | ||
export declare function createConfig(parameters: CreateConfigParameters): Config; | ||
export declare function createConfig(parameters: CreateConfigParameters): InternalConfig; | ||
export type BaseConfig = { | ||
utils: typeof rustUtils; | ||
getWebsocketBaseUrl: () => string; | ||
getBaseUrl: (route?: string) => string; | ||
getSymmetricKey: (type?: AuthType) => Hex; | ||
}; | ||
export type Config = BaseConfig & { | ||
renegadeKeyType: 'internal'; | ||
readonly storage: Storage | null; | ||
@@ -30,4 +36,2 @@ darkPoolAddress: Address; | ||
getPriceReporterHTTPBaseUrl: (route?: string) => string; | ||
getRelayerBaseUrl: (route?: string) => string; | ||
getWebsocketBaseUrl: () => string; | ||
pollingInterval: number; | ||
@@ -53,2 +57,4 @@ priceReporterUrl: string; | ||
}; | ||
export type InternalConfig = Config; | ||
export type RenegadeConfig = InternalConfig | ExternalConfig; | ||
export interface State { | ||
@@ -60,3 +66,8 @@ seed?: Hex | undefined; | ||
} | ||
export declare const keyTypes: { | ||
readonly EXTERNAL: "external"; | ||
readonly INTERNAL: "internal"; | ||
readonly NONE: "none"; | ||
}; | ||
export type PartializedState = Evaluate<ExactPartial<Pick<State, 'id' | 'seed' | 'status'>>>; | ||
//# sourceMappingURL=createConfig.d.ts.map |
@@ -5,3 +5,3 @@ export { type CancelOrderRequestErrorType, type CancelOrderRequestParameters, type CancelOrderRequestReturnType, cancelOrderRequest, } from '../actions/cancelOrderRequest.js'; | ||
export { type CreateOrderRequestErrorType, type CreateOrderRequestParameters, type CreateOrderRequestReturnType, createOrderRequest, } from '../actions/createOrderRequest.js'; | ||
export { type CreateWalletReturnType, createWallet, } from '../actions/createWallet.js'; | ||
export { type CreateWalletReturnType, type CreateWalletParameters, createWallet, } from '../actions/createWallet.js'; | ||
export { type DepositParameters, type DepositReturnType, deposit, } from '../actions/deposit.js'; | ||
@@ -42,2 +42,3 @@ export { type DepositRequestErrorType, type DepositRequestParameters, type DepositRequestReturnType, depositRequest, } from '../actions/depositRequest.js'; | ||
export { type AuthConfig, type CreateAuthConfigParameters, createAuthConfig, } from '../createAuthConfig.js'; | ||
export { type CreateExternalKeyConfigParameters, type ExternalConfig, createExternalKeyConfig, } from '../createExternalKeyConfig.js'; | ||
export { type CreateStorageParameters, type Storage, type StorageItemMap, createStorage, noopStorage, } from '../createStorage.js'; | ||
@@ -44,0 +45,0 @@ export { hydrate } from '../hydrate.js'; |
@@ -9,3 +9,3 @@ import { type GetNetworkOrdersReturnType } from '../actions/getNetworkOrders.js'; | ||
queryKey: readonly ["network-orders", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -18,3 +18,3 @@ signal: AbortSignal; | ||
readonly queryKey: readonly ["network-orders", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -25,5 +25,5 @@ }; | ||
export declare function getNetworkOrdersQueryKey(options?: GetNetworkOrdersOptions): readonly ["network-orders", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetNetworkOrdersQueryKey = ReturnType<typeof getNetworkOrdersQueryKey>; | ||
//# sourceMappingURL=getNetworkOrders.d.ts.map |
@@ -10,3 +10,3 @@ import { type GetOpenOrdersParams, type GetOpenOrdersReturnType } from '../actions/getOpenOrders.js'; | ||
matchingPool?: string | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -20,3 +20,3 @@ signal: AbortSignal; | ||
matchingPool?: string | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -28,5 +28,5 @@ }; | ||
matchingPool?: string | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetOpenOrdersQueryKey = ReturnType<typeof getOpenOrdersQueryKey>; | ||
//# sourceMappingURL=getOpenOrders.d.ts.map |
@@ -9,3 +9,3 @@ import { type GetOrderHistoryReturnType } from '../actions/getOrderHistory.js'; | ||
queryKey: readonly ["order-history", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -18,3 +18,3 @@ signal: AbortSignal; | ||
readonly queryKey: readonly ["order-history", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -25,5 +25,5 @@ }; | ||
export declare function getOrderHistoryQueryKey(options?: GetOrderHistoryOptions): readonly ["order-history", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetOrderHistoryQueryKey = ReturnType<typeof getOrderHistoryQueryKey>; | ||
//# sourceMappingURL=getOrderHistory.d.ts.map |
@@ -11,3 +11,3 @@ import { type GetOrderMetadataParameters, type GetOrderMetadataReturnType } from '../actions/getOrderMetadata.js'; | ||
includeFillable?: boolean | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -22,3 +22,3 @@ signal: AbortSignal; | ||
includeFillable?: boolean | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -31,5 +31,5 @@ }; | ||
includeFillable?: boolean | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetOrderMetadataQueryKey = ReturnType<typeof getOrderMetadataQueryKey>; | ||
//# sourceMappingURL=getOrderMetadata.d.ts.map |
@@ -9,3 +9,3 @@ import { type GetPingReturnType } from '../actions/ping.js'; | ||
queryKey: readonly ["ping", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -18,3 +18,3 @@ signal: AbortSignal; | ||
readonly queryKey: readonly ["ping", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -25,5 +25,5 @@ }; | ||
export declare function getPingQueryKey(options?: GetPingOptions): readonly ["ping", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetPingQueryKey = ReturnType<typeof getPingQueryKey>; | ||
//# sourceMappingURL=getPing.d.ts.map |
@@ -9,3 +9,3 @@ import { type GetTaskHistoryReturnType } from '../actions/getTaskHistory.js'; | ||
queryKey: readonly ["task-history", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -18,3 +18,3 @@ signal: AbortSignal; | ||
readonly queryKey: readonly ["task-history", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -25,5 +25,5 @@ }; | ||
export declare function getTaskHistoryQueryKey(options?: GetTaskHistoryOptions): readonly ["task-history", { | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetTaskHistoryQueryKey = ReturnType<typeof getTaskHistoryQueryKey>; | ||
//# sourceMappingURL=getTaskHistory.d.ts.map |
@@ -10,3 +10,3 @@ import { type GetWalletFromRelayerParameters, type GetWalletFromRelayerReturnType } from '../actions/getWalletFromRelayer.js'; | ||
filterDefaults?: boolean | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -20,3 +20,3 @@ signal: AbortSignal; | ||
filterDefaults?: boolean | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
@@ -28,5 +28,5 @@ }; | ||
filterDefaults?: boolean | undefined; | ||
scopeKey?: string | undefined | undefined; | ||
scopeKey?: string | undefined; | ||
}]; | ||
export type GetWalletQueryKey = ReturnType<typeof getWalletQueryKey>; | ||
//# sourceMappingURL=getWallet.d.ts.map |
@@ -1,7 +0,8 @@ | ||
import type { BaseConfig, Config } from '../createConfig.js'; | ||
import type { BaseConfig, Config, RenegadeConfig } from '../createConfig.js'; | ||
import type { AuthType } from './websocket.js'; | ||
export declare function postRelayerRaw(url: string, body: any, headers?: {}): Promise<any>; | ||
export declare function getRelayerRaw(url: string, headers?: {}): Promise<any>; | ||
export declare function postRelayerWithAuth(config: Config, url: string, body?: string): Promise<any>; | ||
export declare function postRelayerWithAuth(config: RenegadeConfig, url: string, body?: string, requestType?: AuthType): Promise<any>; | ||
export declare function postRelayerWithAdmin(config: Config, url: string, body?: string): Promise<any>; | ||
export declare function getRelayerWithAuth(config: Config, url: string): Promise<any>; | ||
export declare function getRelayerWithAuth(config: RenegadeConfig, url: string): Promise<any>; | ||
export declare function getRelayerWithAdmin(config: Config, url: string): Promise<any>; | ||
@@ -8,0 +9,0 @@ export declare function postWithSymmetricKey(config: BaseConfig, { body, headers, key, url, }: { |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
export declare enum AuthType { | ||
@@ -8,3 +8,3 @@ None = "None", | ||
export type RelayerWebsocketParams = { | ||
config: Config; | ||
config: RenegadeConfig; | ||
topic: string; | ||
@@ -39,6 +39,5 @@ authType: AuthType; | ||
private buildUnsubscriptionMessage; | ||
private buildWalletAuthHeaders; | ||
private buildAdminAuthHeaders; | ||
private buildAuthHeaders; | ||
private cleanup; | ||
} | ||
//# sourceMappingURL=websocket.d.ts.map |
@@ -1,5 +0,5 @@ | ||
import type { Config } from '../createConfig.js'; | ||
import type { RenegadeConfig } from '../createConfig.js'; | ||
import { type AuthType } from './websocket.js'; | ||
export type WebsocketWaiterParams = { | ||
config: Config; | ||
config: RenegadeConfig; | ||
topic: string; | ||
@@ -6,0 +6,0 @@ authType: AuthType; |
{ | ||
"name": "@renegade-fi/core", | ||
"description": "VanillaJS library for Renegade", | ||
"version": "0.4.12", | ||
"version": "0.4.13", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -45,3 +45,3 @@ import invariant from 'tiny-invariant' | ||
const res = await postWithSymmetricKey(config, { | ||
url: config.getAuthServerUrl(ASSEMBLE_EXTERNAL_MATCH_ROUTE), | ||
url: config.getBaseUrl(ASSEMBLE_EXTERNAL_MATCH_ROUTE), | ||
body, | ||
@@ -48,0 +48,0 @@ key: symmetricKey, |
@@ -15,3 +15,3 @@ import { ADMIN_ASSIGN_ORDER_ROUTE } from '../constants.js' | ||
const { orderId, matchingPool } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -21,3 +21,3 @@ try { | ||
config, | ||
getRelayerBaseUrl(ADMIN_ASSIGN_ORDER_ROUTE(orderId, matchingPool)), | ||
getBaseUrl(ADMIN_ASSIGN_ORDER_ROUTE(orderId, matchingPool)), | ||
) | ||
@@ -24,0 +24,0 @@ } catch (error) { |
import invariant from 'tiny-invariant' | ||
import type { Hex } from 'viem' | ||
import { CANCEL_ORDER_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import type { BaseErrorType } from '../errors/base.js' | ||
@@ -12,2 +13,3 @@ import { stringifyForWasm } from '../utils/bigJSON.js' | ||
id: string | ||
newPublicKey?: Hex | ||
} | ||
@@ -20,12 +22,7 @@ | ||
export async function cancelOrder( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: CancelOrderParameters, | ||
): Promise<CancelOrderReturnType> { | ||
const { id } = parameters | ||
const { | ||
getRelayerBaseUrl, | ||
utils, | ||
state: { seed }, | ||
} = config | ||
invariant(seed, 'Seed is required') | ||
const { id, newPublicKey } = parameters | ||
const { getBaseUrl, utils, renegadeKeyType } = config | ||
@@ -35,8 +32,28 @@ const walletId = getWalletId(config) | ||
const body = utils.cancel_order(seed, stringifyForWasm(wallet), id) | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined | ||
const signMessage = | ||
renegadeKeyType === 'external' ? config.signMessage : undefined | ||
if (renegadeKeyType === 'external') { | ||
invariant( | ||
signMessage !== undefined, | ||
'Sign message function is required for external key type', | ||
) | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type') | ||
} | ||
const body = await utils.cancel_order( | ||
seed, | ||
stringifyForWasm(wallet), | ||
id, | ||
newPublicKey, | ||
signMessage, | ||
) | ||
try { | ||
const res = await postRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), | ||
getBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), | ||
body, | ||
@@ -43,0 +60,0 @@ ) |
@@ -18,3 +18,3 @@ import { CANCEL_ORDER_ROUTE } from '../constants.js' | ||
const { request, id } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -26,3 +26,3 @@ const walletId = getWalletId(config) | ||
config, | ||
getRelayerBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), | ||
getBaseUrl(CANCEL_ORDER_ROUTE(walletId, id)), | ||
request, | ||
@@ -29,0 +29,0 @@ ) |
@@ -14,3 +14,3 @@ import { ADMIN_MATCHING_POOL_CREATE_ROUTE } from '../constants.js' | ||
const { matchingPool } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -20,3 +20,3 @@ try { | ||
config, | ||
getRelayerBaseUrl(ADMIN_MATCHING_POOL_CREATE_ROUTE(matchingPool)), | ||
getBaseUrl(ADMIN_MATCHING_POOL_CREATE_ROUTE(matchingPool)), | ||
) | ||
@@ -23,0 +23,0 @@ } catch (error) { |
import invariant from 'tiny-invariant' | ||
import { type Address, toHex } from 'viem' | ||
import { type Address, type Hex, toHex } from 'viem' | ||
import { WALLET_ORDERS_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import type { BaseErrorType } from '../errors/base.js' | ||
@@ -20,2 +20,3 @@ import { stringifyForWasm } from '../utils/bigJSON.js' | ||
allowExternalMatches?: boolean | ||
newPublicKey?: Hex | ||
} | ||
@@ -28,3 +29,3 @@ | ||
export async function createOrder( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: CreateOrderParameters, | ||
@@ -41,9 +42,5 @@ ): Promise<CreateOrderReturnType> { | ||
allowExternalMatches = false, | ||
newPublicKey, | ||
} = parameters | ||
const { | ||
getRelayerBaseUrl, | ||
utils, | ||
state: { seed }, | ||
} = config | ||
invariant(seed, 'Seed is required') | ||
const { getBaseUrl, utils, renegadeKeyType } = config | ||
@@ -53,3 +50,17 @@ const walletId = getWalletId(config) | ||
const body = utils.new_order( | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined | ||
const signMessage = | ||
renegadeKeyType === 'external' ? config.signMessage : undefined | ||
if (renegadeKeyType === 'external') { | ||
invariant( | ||
signMessage !== undefined, | ||
'Sign message function is required for external key type', | ||
) | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type') | ||
} | ||
const body = await utils.new_order( | ||
seed, | ||
@@ -65,2 +76,4 @@ stringifyForWasm(wallet), | ||
allowExternalMatches, | ||
newPublicKey, | ||
signMessage, | ||
) | ||
@@ -71,3 +84,3 @@ | ||
config, | ||
getRelayerBaseUrl(WALLET_ORDERS_ROUTE(walletId)), | ||
getBaseUrl(WALLET_ORDERS_ROUTE(walletId)), | ||
body, | ||
@@ -74,0 +87,0 @@ ) |
@@ -34,3 +34,3 @@ import invariant from 'tiny-invariant' | ||
const { | ||
getRelayerBaseUrl, | ||
getBaseUrl, | ||
utils, | ||
@@ -44,3 +44,3 @@ state: { seed }, | ||
const body = utils.new_order_in_matching_pool( | ||
const body = await utils.new_order_in_matching_pool( | ||
seed, | ||
@@ -62,3 +62,3 @@ stringifyForWasm(wallet), | ||
config, | ||
getRelayerBaseUrl(ADMIN_CREATE_ORDER_IN_MATCHING_POOL_ROUTE(walletId)), | ||
getBaseUrl(ADMIN_CREATE_ORDER_IN_MATCHING_POOL_ROUTE(walletId)), | ||
body, | ||
@@ -65,0 +65,0 @@ ) |
@@ -18,3 +18,3 @@ import { WALLET_ORDERS_ROUTE } from '../constants.js' | ||
const { request } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -26,3 +26,3 @@ const walletId = getWalletId(config) | ||
config, | ||
getRelayerBaseUrl(WALLET_ORDERS_ROUTE(walletId)), | ||
getBaseUrl(WALLET_ORDERS_ROUTE(walletId)), | ||
request, | ||
@@ -29,0 +29,0 @@ ) |
import invariant from 'tiny-invariant' | ||
import { CREATE_WALLET_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { BaseError } from '../errors/base.js' | ||
@@ -10,10 +10,14 @@ import { postRelayerRaw } from '../utils/http.js' | ||
export async function createWallet(config: Config): CreateWalletReturnType { | ||
const { | ||
getRelayerBaseUrl, | ||
utils, | ||
state: { seed }, | ||
} = config | ||
invariant(seed, 'seed is required') | ||
const body = utils.create_wallet(seed) | ||
export type CreateWalletParameters = { | ||
blinderSeed?: string | ||
shareSeed?: string | ||
skMatch?: string | ||
} | ||
export async function createWallet( | ||
config: RenegadeConfig, | ||
parameters: CreateWalletParameters = {}, | ||
): CreateWalletReturnType { | ||
const { getBaseUrl, utils } = config | ||
let body: string | ||
const headers = { | ||
@@ -23,4 +27,24 @@ 'Content-Type': 'application/json', | ||
if (config.renegadeKeyType === 'internal') { | ||
const { seed } = config.state | ||
invariant(seed, 'seed is required') | ||
body = utils.create_wallet(seed) | ||
} else { | ||
const { blinderSeed, shareSeed, skMatch } = parameters | ||
const { walletId, publicKey, symmetricKey } = config | ||
invariant(blinderSeed, 'blinderSeed is required') | ||
invariant(shareSeed, 'shareSeed is required') | ||
invariant(skMatch, 'skMatch is required') | ||
body = await utils.create_external_wallet( | ||
walletId, | ||
blinderSeed, | ||
shareSeed, | ||
publicKey, | ||
skMatch, | ||
symmetricKey, | ||
) | ||
} | ||
const res = await postRelayerRaw( | ||
getRelayerBaseUrl(CREATE_WALLET_ROUTE), | ||
getBaseUrl(CREATE_WALLET_ROUTE), | ||
body, | ||
@@ -30,3 +54,5 @@ headers, | ||
if (res.task_id) { | ||
config.setState((x) => ({ ...x, status: 'creating wallet' })) | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ ...x, status: 'creating wallet' })) | ||
} | ||
console.log(`task create-wallet(${res.task_id}): ${res.wallet_id}`, { | ||
@@ -39,3 +65,5 @@ status: 'creating wallet', | ||
onComplete: (wallet) => { | ||
config.setState((x) => ({ ...x, status: 'in relayer' })) | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ ...x, status: 'in relayer' })) | ||
} | ||
console.log( | ||
@@ -50,7 +78,6 @@ `task create-wallet(${res.task_id}) completed: ${wallet.id}`, | ||
onFailure: () => { | ||
console.error(`wallet id: ${config.state.id} creating wallet failed`, { | ||
status: 'creating wallet', | ||
walletId: config.state.id, | ||
}) | ||
config.setState({}) | ||
console.log(`task create-wallet(${res.task_id}) failed`) | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState({}) | ||
} | ||
}, | ||
@@ -57,0 +84,0 @@ }) |
import invariant from 'tiny-invariant' | ||
import { type Address, toHex } from 'viem' | ||
import { DEPOSIT_BALANCE_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { BaseErrorType } from '../errors/base.js' | ||
import { Token } from '../types/token.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { stringifyForWasm } from '../utils/bigJSON.js' | ||
@@ -13,8 +11,9 @@ import { postRelayerWithAuth } from '../utils/http.js' | ||
export type DepositParameters = { | ||
amount: bigint | ||
fromAddr: Address | ||
mint: Address | ||
amount: bigint | ||
newPublicKey?: string | ||
permit: string | ||
permitDeadline: bigint | ||
permitNonce: bigint | ||
permitDeadline: bigint | ||
permit: `0x${string}` | ||
} | ||
@@ -24,27 +23,39 @@ | ||
export type DepositErrorType = BaseErrorType | ||
export async function deposit( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: DepositParameters, | ||
): DepositReturnType { | ||
const { fromAddr, mint, amount, permitNonce, permitDeadline, permit } = | ||
parameters | ||
const { | ||
getRelayerBaseUrl, | ||
utils, | ||
state: { seed }, | ||
} = config | ||
invariant(seed, 'Seed is required') | ||
amount, | ||
fromAddr, | ||
mint, | ||
newPublicKey, | ||
permit, | ||
permitDeadline, | ||
permitNonce, | ||
} = parameters | ||
const token = Token.findByAddress(mint) | ||
invariant(token, 'Token not found') | ||
const { getBaseUrl, utils, renegadeKeyType } = config | ||
const walletId = getWalletId(config) | ||
const wallet = await getBackOfQueueWallet(config) | ||
const walletStr = stringifyForWasm(wallet) | ||
const body = utils.deposit( | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined | ||
const signMessage = | ||
renegadeKeyType === 'external' ? config.signMessage : undefined | ||
if (renegadeKeyType === 'external') { | ||
invariant( | ||
signMessage !== undefined, | ||
'Sign message function is required for external key type', | ||
) | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type') | ||
} | ||
const body = await utils.deposit( | ||
// TODO: Change Rust to accept Option<String> | ||
seed, | ||
walletStr, | ||
stringifyForWasm(wallet), | ||
fromAddr, | ||
@@ -56,2 +67,4 @@ mint, | ||
permit, | ||
newPublicKey, | ||
signMessage, | ||
) | ||
@@ -62,3 +75,3 @@ | ||
config, | ||
getRelayerBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), | ||
getBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), | ||
body, | ||
@@ -65,0 +78,0 @@ ) |
@@ -18,3 +18,3 @@ import { DEPOSIT_BALANCE_ROUTE } from '../constants.js' | ||
const { request } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -26,3 +26,3 @@ const walletId = getWalletId(config) | ||
config, | ||
getRelayerBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), | ||
getBaseUrl(DEPOSIT_BALANCE_ROUTE(walletId)), | ||
request, | ||
@@ -29,0 +29,0 @@ ) |
@@ -14,3 +14,3 @@ import { ADMIN_MATCHING_POOL_DESTROY_ROUTE } from '../constants.js' | ||
const { matchingPool } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -20,3 +20,3 @@ try { | ||
config, | ||
getRelayerBaseUrl(ADMIN_MATCHING_POOL_DESTROY_ROUTE(matchingPool)), | ||
getBaseUrl(ADMIN_MATCHING_POOL_DESTROY_ROUTE(matchingPool)), | ||
) | ||
@@ -23,0 +23,0 @@ } catch (error) { |
import { BACK_OF_QUEUE_WALLET_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { BaseError, type BaseErrorType } from '../errors/base.js' | ||
@@ -18,11 +18,11 @@ import type { Order } from '../types/order.js' | ||
export async function getBackOfQueueWallet( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: GetBackOfQueueWalletParameters = {}, | ||
): Promise<GetBackOfQueueWalletReturnType> { | ||
const { filterDefaults } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(BACK_OF_QUEUE_WALLET_ROUTE(walletId)), | ||
getBaseUrl(BACK_OF_QUEUE_WALLET_ROUTE(walletId)), | ||
) | ||
@@ -29,0 +29,0 @@ if (!res.wallet) { |
@@ -10,9 +10,9 @@ import { GET_BALANCES_ROUTE } from '../constants.js' | ||
export async function getBalances(config: Config): GetBalancesReturnType { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(GET_BALANCES_ROUTE(walletId)), | ||
getBaseUrl(GET_BALANCES_ROUTE(walletId)), | ||
) | ||
return res.balances | ||
} |
@@ -55,3 +55,3 @@ import invariant from 'tiny-invariant' | ||
const res = await postWithSymmetricKey(config, { | ||
url: config.getAuthServerUrl(REQUEST_EXTERNAL_MATCH_ROUTE), | ||
url: config.getBaseUrl(REQUEST_EXTERNAL_MATCH_ROUTE), | ||
body, | ||
@@ -58,0 +58,0 @@ key: symmetricKey, |
@@ -55,3 +55,3 @@ import invariant from 'tiny-invariant' | ||
const res = await postWithSymmetricKey(config, { | ||
url: config.getAuthServerUrl(REQUEST_EXTERNAL_MATCH_QUOTE_ROUTE), | ||
url: config.getBaseUrl(REQUEST_EXTERNAL_MATCH_QUOTE_ROUTE), | ||
body, | ||
@@ -58,0 +58,0 @@ key: symmetricKey, |
@@ -15,4 +15,4 @@ import { getRelayerRaw } from '../utils/http.js' | ||
): Promise<GetNetworkOrdersReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
const res = await getRelayerRaw(getRelayerBaseUrl(GET_NETWORK_ORDERS_ROUTE)) | ||
const { getBaseUrl } = config | ||
const res = await getRelayerRaw(getBaseUrl(GET_NETWORK_ORDERS_ROUTE)) | ||
if (!res.orders) { | ||
@@ -19,0 +19,0 @@ throw new BaseError('No orders found') |
@@ -18,5 +18,5 @@ import { ADMIN_OPEN_ORDERS_ROUTE } from '../constants.js' | ||
): Promise<GetOpenOrdersReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const url = new URL(getRelayerBaseUrl(ADMIN_OPEN_ORDERS_ROUTE)) | ||
const url = new URL(getBaseUrl(ADMIN_OPEN_ORDERS_ROUTE)) | ||
@@ -23,0 +23,0 @@ if (parameters.matchingPool) { |
@@ -16,9 +16,9 @@ import { GET_ORDER_BY_ID_ROUTE } from '../constants.js' | ||
const { id } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(GET_ORDER_BY_ID_ROUTE(walletId, id)), | ||
getBaseUrl(GET_ORDER_BY_ID_ROUTE(walletId, id)), | ||
) | ||
return res.order | ||
} |
import { ORDER_HISTORY_LEN_PARAM, ORDER_HISTORY_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { BaseError, type BaseErrorType } from '../errors/base.js' | ||
@@ -17,10 +17,10 @@ import type { OrderMetadata } from '../types/order.js' | ||
export async function getOrderHistory( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: GetOrderHistoryParameters = {}, | ||
): Promise<GetOrderHistoryReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const { limit } = parameters | ||
const walletId = getWalletId(config) | ||
let url = getRelayerBaseUrl(ORDER_HISTORY_ROUTE(walletId)) | ||
let url = getBaseUrl(ORDER_HISTORY_ROUTE(walletId)) | ||
@@ -27,0 +27,0 @@ if (limit !== undefined) { |
@@ -16,3 +16,3 @@ import { ADMIN_GET_ORDER_MATCHING_POOL_ROUTE } from '../constants.js' | ||
const { orderId } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -22,3 +22,3 @@ try { | ||
config, | ||
getRelayerBaseUrl(ADMIN_GET_ORDER_MATCHING_POOL_ROUTE(orderId)), | ||
getBaseUrl(ADMIN_GET_ORDER_MATCHING_POOL_ROUTE(orderId)), | ||
) | ||
@@ -25,0 +25,0 @@ |
@@ -21,5 +21,5 @@ import { ADMIN_ORDER_METADATA_ROUTE } from '../constants.js' | ||
const { id } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const url = new URL(getRelayerBaseUrl(ADMIN_ORDER_METADATA_ROUTE(id))) | ||
const url = new URL(getBaseUrl(ADMIN_ORDER_METADATA_ROUTE(id))) | ||
@@ -26,0 +26,0 @@ if (parameters.includeFillable) { |
@@ -10,9 +10,9 @@ import { WALLET_ORDERS_ROUTE } from '../constants.js' | ||
export async function getOrders(config: Config): Promise<GetOrdersReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(WALLET_ORDERS_ROUTE(walletId)), | ||
getBaseUrl(WALLET_ORDERS_ROUTE(walletId)), | ||
) | ||
return res.orders | ||
} |
import invariant from 'tiny-invariant' | ||
import type { Hex } from 'viem' | ||
import type { Config } from '../createConfig.js' | ||
import type { Config, RenegadeConfig } from '../createConfig.js' | ||
export type GetPkRootParameters = { | ||
nonce: bigint | ||
nonce?: bigint | ||
} | ||
@@ -21,2 +21,3 @@ | ||
invariant(seed, 'Seed is required') | ||
invariant(nonce, 'Nonce is required') | ||
return `0x${utils.get_pk_root(seed, nonce)}` | ||
@@ -26,13 +27,19 @@ } | ||
export function getPkRootScalars( | ||
config: Config, | ||
parameters: GetPkRootParameters = { nonce: BigInt(0) }, | ||
config: RenegadeConfig, | ||
parameters: GetPkRootParameters = {}, | ||
): GetPkRootScalarsReturnType { | ||
const { | ||
utils, | ||
state: { seed }, | ||
} = config | ||
const { utils, renegadeKeyType } = config | ||
const { nonce } = parameters | ||
invariant(seed, 'Seed is required') | ||
const scalars = utils.get_pk_root_scalars(seed, nonce) | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined | ||
const publicKey = | ||
renegadeKeyType === 'external' ? config.publicKey : undefined | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type') | ||
invariant(nonce !== undefined, 'Nonce is required for internal key type') | ||
} | ||
const scalars = utils.get_pk_root_scalars(seed, nonce, publicKey) | ||
return scalars.map((s: string) => BigInt(s)).slice(0, 4) | ||
} |
@@ -6,3 +6,3 @@ import { getWalletId } from './getWalletId.js' | ||
import { TASK_HISTORY_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { BaseError, type BaseErrorType } from '../errors/base.js' | ||
@@ -16,9 +16,9 @@ import type { Task as TaskHistoryItem } from '../types/task.js' | ||
export async function getTaskHistory( | ||
config: Config, | ||
config: RenegadeConfig, | ||
): Promise<GetTaskHistoryReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(TASK_HISTORY_ROUTE(walletId)), | ||
getBaseUrl(TASK_HISTORY_ROUTE(walletId)), | ||
) | ||
@@ -25,0 +25,0 @@ if (!res.tasks) { |
@@ -12,9 +12,9 @@ import { getWalletId } from './getWalletId.js' | ||
export async function getTaskQueue(config: Config): GetTaskQueueReturnType { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(GET_TASK_QUEUE_ROUTE(walletId)), | ||
getBaseUrl(GET_TASK_QUEUE_ROUTE(walletId)), | ||
) | ||
return res.tasks | ||
} |
@@ -16,8 +16,8 @@ import { getRelayerWithAuth } from '../utils/http.js' | ||
const { id } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(GET_TASK_STATUS_ROUTE(id)), | ||
getBaseUrl(GET_TASK_STATUS_ROUTE(id)), | ||
) | ||
return res.status | ||
} |
import { GET_WALLET_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { BaseError, type BaseErrorType } from '../errors/base.js' | ||
@@ -18,11 +18,11 @@ import type { Order } from '../types/order.js' | ||
export async function getWalletFromRelayer( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: GetWalletFromRelayerParameters = {}, | ||
): Promise<GetWalletFromRelayerReturnType> { | ||
const { filterDefaults } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
const res = await getRelayerWithAuth( | ||
config, | ||
getRelayerBaseUrl(GET_WALLET_ROUTE(walletId)), | ||
getBaseUrl(GET_WALLET_ROUTE(walletId)), | ||
) | ||
@@ -29,0 +29,0 @@ if (!res.wallet) { |
import invariant from 'tiny-invariant' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
export type GetWalletIdReturnType = string | ||
export function getWalletId(config: Config): GetWalletIdReturnType { | ||
export function getWalletId(config: RenegadeConfig): GetWalletIdReturnType { | ||
if (config.renegadeKeyType === 'external') { | ||
return config.walletId | ||
} | ||
const { | ||
@@ -8,0 +11,0 @@ utils, |
@@ -19,7 +19,7 @@ import { ADMIN_WALLET_MATCHABLE_ORDER_IDS_ROUTE } from '../constants.js' | ||
const { id } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
const res = await getRelayerWithAdmin( | ||
config, | ||
getRelayerBaseUrl(ADMIN_WALLET_MATCHABLE_ORDER_IDS_ROUTE(id)), | ||
getBaseUrl(ADMIN_WALLET_MATCHABLE_ORDER_IDS_ROUTE(id)), | ||
) | ||
@@ -26,0 +26,0 @@ |
import invariant from 'tiny-invariant' | ||
import { parseAbiItem } from 'viem' | ||
import { FIND_WALLET_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { Config, RenegadeConfig } from '../createConfig.js' | ||
import { BaseError } from '../errors/base.js' | ||
@@ -11,11 +11,36 @@ import { postRelayerRaw } from '../utils/http.js' | ||
export async function lookupWallet(config: Config): LookupWalletReturnType { | ||
const { | ||
getRelayerBaseUrl, | ||
utils, | ||
state: { seed }, | ||
} = config | ||
invariant(seed, 'seed is required') | ||
const body = utils.find_wallet(seed) | ||
const res = await postRelayerRaw(getRelayerBaseUrl(FIND_WALLET_ROUTE), body) | ||
export type LookupWalletParameters = { | ||
blinderSeed?: string | ||
shareSeed?: string | ||
skMatch?: string | ||
} | ||
export async function lookupWallet( | ||
config: RenegadeConfig, | ||
parameters: LookupWalletParameters = {}, | ||
): LookupWalletReturnType { | ||
const { getBaseUrl, utils } = config | ||
let body: string | ||
if (config.renegadeKeyType === 'internal') { | ||
const { seed } = config.state | ||
invariant(seed, 'seed is required') | ||
body = utils.find_wallet(seed) | ||
} else { | ||
const { blinderSeed, shareSeed, skMatch } = parameters | ||
const { walletId, publicKey, symmetricKey } = config | ||
invariant(blinderSeed, 'blinderSeed is required') | ||
invariant(shareSeed, 'shareSeed is required') | ||
invariant(skMatch, 'skMatch is required') | ||
body = await utils.find_external_wallet( | ||
walletId, | ||
blinderSeed, | ||
shareSeed, | ||
publicKey, | ||
skMatch, | ||
symmetricKey, | ||
) | ||
} | ||
const res = await postRelayerRaw(getBaseUrl(FIND_WALLET_ROUTE), body) | ||
if (res.task_id) { | ||
@@ -26,3 +51,5 @@ console.log(`task lookup-wallet(${res.task_id}): ${res.wallet_id}`, { | ||
}) | ||
config.setState((x) => ({ ...x, status: 'looking up' })) | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ ...x, status: 'looking up' })) | ||
} | ||
return waitForWalletIndexing(config, { | ||
@@ -32,6 +59,8 @@ timeout: 300000, | ||
onComplete(wallet) { | ||
config.setState((x) => ({ | ||
...x, | ||
status: 'in relayer', | ||
})) | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState((x) => ({ | ||
...x, | ||
status: 'in relayer', | ||
})) | ||
} | ||
console.log( | ||
@@ -46,7 +75,8 @@ `task lookup-wallet(${res.task_id}) completed: ${wallet.id}`, | ||
onFailure() { | ||
console.error(`wallet id: ${config.state.id} looking up failed`, { | ||
status: 'looking up', | ||
walletId: config.state.id, | ||
}) | ||
config.setState({}) | ||
console.log( | ||
`task lookup-wallet(${res.task_id}) failed: ${res.wallet_id}`, | ||
) | ||
if (config.renegadeKeyType === 'internal') { | ||
config.setState({}) | ||
} | ||
}, | ||
@@ -53,0 +83,0 @@ }) |
import { PAY_FEES_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import type { BaseError } from '../errors/base.js' | ||
@@ -11,4 +11,6 @@ import { postRelayerWithAuth } from '../utils/http.js' | ||
export async function payFees(config: Config): Promise<PayFeesReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
export async function payFees( | ||
config: RenegadeConfig, | ||
): Promise<PayFeesReturnType> { | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
@@ -19,3 +21,3 @@ | ||
config, | ||
getRelayerBaseUrl(PAY_FEES_ROUTE(walletId)), | ||
getBaseUrl(PAY_FEES_ROUTE(walletId)), | ||
) | ||
@@ -22,0 +24,0 @@ if (res?.task_ids) { |
@@ -11,5 +11,5 @@ import { PING_ROUTE } from '../constants.js' | ||
export async function getPing(config: Config): Promise<GetPingReturnType> { | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
try { | ||
const res = await getRelayerRaw(getRelayerBaseUrl(PING_ROUTE)) | ||
const res = await getRelayerRaw(getBaseUrl(PING_ROUTE)) | ||
if (res?.timestamp) { | ||
@@ -16,0 +16,0 @@ return true |
import { REFRESH_WALLET_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { postRelayerWithAuth } from '../utils/http.js' | ||
import { getWalletId } from './getWalletId.js' | ||
export type RefreshWalletReturnType = Promise<{ taskId: string }> | ||
export type RefreshWalletReturnType = { | ||
taskId: string | ||
} | ||
export async function refreshWallet(config: Config): RefreshWalletReturnType { | ||
const { getRelayerBaseUrl } = config | ||
export async function refreshWallet( | ||
config: RenegadeConfig, | ||
): Promise<RefreshWalletReturnType> { | ||
const { getBaseUrl } = config | ||
const walletId = getWalletId(config) | ||
@@ -15,3 +19,3 @@ | ||
config, | ||
getRelayerBaseUrl(REFRESH_WALLET_ROUTE(walletId)), | ||
getBaseUrl(REFRESH_WALLET_ROUTE(walletId)), | ||
) | ||
@@ -18,0 +22,0 @@ if (res?.task_id) { |
@@ -38,3 +38,3 @@ import invariant from 'tiny-invariant' | ||
const { | ||
getRelayerBaseUrl, | ||
getBaseUrl, | ||
utils, | ||
@@ -64,3 +64,3 @@ state: { seed }, | ||
config, | ||
getRelayerBaseUrl(UPDATE_ORDER_ROUTE(walletId, id)), | ||
getBaseUrl(UPDATE_ORDER_ROUTE(walletId, id)), | ||
body, | ||
@@ -67,0 +67,0 @@ ) |
import { TASK_STATUS_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { AuthType } from '../utils/websocket.js' | ||
@@ -12,3 +12,3 @@ import { | ||
export async function waitForTaskCompletionWs( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: WaitForTaskCompletionParameters, | ||
@@ -15,0 +15,0 @@ ): Promise<null | undefined> { |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { BaseError } from '../errors/base.js' | ||
@@ -16,7 +16,8 @@ import type { Wallet } from '../types/wallet.js' | ||
export async function waitForWalletIndexing( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: WaitForWalletIndexParameters, | ||
): WaitForWalletIndexReturnType { | ||
const { pollingInterval } = config | ||
const { onComplete, onFailure, timeout = 60000, isLookup } = parameters | ||
const pollingInterval = | ||
config.renegadeKeyType === 'internal' ? config.pollingInterval : 5000 | ||
@@ -23,0 +24,0 @@ const startTime = Date.now() |
import invariant from 'tiny-invariant' | ||
import { type Address, toHex } from 'viem' | ||
import { WITHDRAW_BALANCE_ROUTE } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { stringifyForWasm } from '../utils/bigJSON.js' | ||
@@ -14,2 +14,3 @@ import { postRelayerWithAuth } from '../utils/http.js' | ||
destinationAddr: Address | ||
newPublicKey?: string | ||
} | ||
@@ -20,12 +21,7 @@ | ||
export async function withdraw( | ||
config: Config, | ||
config: RenegadeConfig, | ||
parameters: WithdrawParameters, | ||
): WithdrawReturnType { | ||
const { mint, amount, destinationAddr } = parameters | ||
const { | ||
getRelayerBaseUrl, | ||
utils, | ||
state: { seed }, | ||
} = config | ||
invariant(seed, 'Seed is required') | ||
const { mint, amount, destinationAddr, newPublicKey } = parameters | ||
const { getBaseUrl, utils, renegadeKeyType } = config | ||
@@ -35,4 +31,17 @@ const walletId = getWalletId(config) | ||
// Withdraw | ||
const body = utils.withdraw( | ||
const seed = renegadeKeyType === 'internal' ? config.state.seed : undefined | ||
const signMessage = | ||
renegadeKeyType === 'external' ? config.signMessage : undefined | ||
if (renegadeKeyType === 'external') { | ||
invariant( | ||
signMessage !== undefined, | ||
'Sign message function is required for external key type', | ||
) | ||
} | ||
if (renegadeKeyType === 'internal') { | ||
invariant(seed !== undefined, 'Seed is required for internal key type') | ||
} | ||
const body = await utils.withdraw( | ||
seed, | ||
@@ -43,2 +52,4 @@ stringifyForWasm(wallet), | ||
destinationAddr, | ||
newPublicKey, | ||
signMessage, | ||
) | ||
@@ -49,3 +60,3 @@ | ||
config, | ||
getRelayerBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), | ||
getBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), | ||
body, | ||
@@ -52,0 +63,0 @@ ) |
@@ -18,3 +18,3 @@ import { WITHDRAW_BALANCE_ROUTE } from '../constants.js' | ||
const { mint, request } = parameters | ||
const { getRelayerBaseUrl } = config | ||
const { getBaseUrl } = config | ||
@@ -26,3 +26,3 @@ const walletId = getWalletId(config) | ||
config, | ||
getRelayerBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), | ||
getBaseUrl(WITHDRAW_BALANCE_ROUTE(walletId, mint)), | ||
request, | ||
@@ -29,0 +29,0 @@ ) |
import invariant from 'tiny-invariant' | ||
import type { Hex } from 'viem' | ||
import type { BaseConfig } from './createConfig.js' | ||
@@ -30,8 +31,17 @@ import type * as rustUtils from './utils.d.ts' | ||
utils: parameters.utils, | ||
// Not used for wallet operations | ||
renegadeKeyType: 'none' as const, | ||
apiKey, | ||
apiSecret, | ||
getAuthServerUrl: (route = '') => { | ||
getBaseUrl: (route = '') => { | ||
const formattedRoute = route.startsWith('/') ? route : `/${route}` | ||
return `${authServerUrl}/v0${formattedRoute}` | ||
}, | ||
getWebsocketBaseUrl: () => { | ||
throw new Error('Not implemented') | ||
}, | ||
getSymmetricKey: () => { | ||
invariant(parameters.utils, 'Utils are required') | ||
return parameters.utils.b64_to_hex_hmac_key(apiSecret) as Hex | ||
}, | ||
} | ||
@@ -43,3 +53,4 @@ } | ||
apiKey: string | ||
getAuthServerUrl: (route?: string) => string | ||
getBaseUrl: (route?: string) => string | ||
renegadeKeyType: 'none' | ||
} |
@@ -12,5 +12,7 @@ import invariant from 'tiny-invariant' | ||
import { type Mutate, type StoreApi, createStore } from 'zustand/vanilla' | ||
import type { ExternalConfig } from './createExternalKeyConfig.js' | ||
import { type Storage, createStorage, noopStorage } from './createStorage.js' | ||
import type { Evaluate, ExactPartial } from './types/utils.js' | ||
import type * as rustUtils from './utils.d.ts' | ||
import { AuthType } from './utils/websocket.js' | ||
@@ -32,3 +34,5 @@ export type CreateConfigParameters = { | ||
export function createConfig(parameters: CreateConfigParameters): Config { | ||
export function createConfig( | ||
parameters: CreateConfigParameters, | ||
): InternalConfig { | ||
const { | ||
@@ -95,2 +99,3 @@ relayerUrl, | ||
utils: parameters.utils, | ||
renegadeKeyType: 'internal' as const, | ||
storage, | ||
@@ -100,3 +105,3 @@ relayerUrl, | ||
darkPoolAddress: parameters.darkPoolAddress, | ||
getRelayerBaseUrl: (route = '') => { | ||
getBaseUrl: (route = '') => { | ||
const protocol = | ||
@@ -135,2 +140,16 @@ useInsecureTransport || parameters.relayerUrl.includes('localhost') | ||
}, | ||
getSymmetricKey(type?: AuthType) { | ||
invariant(parameters.utils, 'Utils are required') | ||
if (type === AuthType.Admin) { | ||
invariant(parameters.adminKey, 'Admin key is required') | ||
const symmetricKey = parameters.utils.b64_to_hex_hmac_key( | ||
parameters.adminKey, | ||
) as Hex | ||
invariant(symmetricKey, 'Admin key is required') | ||
return symmetricKey | ||
} | ||
const seed = store.getState().seed | ||
invariant(seed, 'Seed is required') | ||
return parameters.utils.get_symmetric_key(seed) as Hex | ||
}, | ||
pollingInterval, | ||
@@ -173,5 +192,9 @@ get state() { | ||
utils: typeof rustUtils | ||
getWebsocketBaseUrl: () => string | ||
getBaseUrl: (route?: string) => string | ||
getSymmetricKey: (type?: AuthType) => Hex | ||
} | ||
export type Config = BaseConfig & { | ||
renegadeKeyType: 'internal' | ||
readonly storage: Storage | null | ||
@@ -181,4 +204,2 @@ darkPoolAddress: Address | ||
getPriceReporterHTTPBaseUrl: (route?: string) => string | ||
getRelayerBaseUrl: (route?: string) => string | ||
getWebsocketBaseUrl: () => string | ||
pollingInterval: number | ||
@@ -211,2 +232,7 @@ priceReporterUrl: string | ||
// For backwards-compatibility | ||
export type InternalConfig = Config | ||
export type RenegadeConfig = InternalConfig | ExternalConfig | ||
export interface State { | ||
@@ -225,4 +251,11 @@ seed?: Hex | undefined | ||
// The type of keychain a config is using | ||
export const keyTypes = { | ||
EXTERNAL: 'external', | ||
INTERNAL: 'internal', | ||
NONE: 'none', | ||
} as const | ||
export type PartializedState = Evaluate< | ||
ExactPartial<Pick<State, 'id' | 'seed' | 'status'>> | ||
> |
@@ -35,2 +35,3 @@ //////////////////////////////////////////////////////////////////////////////// | ||
type CreateWalletReturnType, | ||
type CreateWalletParameters, | ||
createWallet, | ||
@@ -252,2 +253,8 @@ } from '../actions/createWallet.js' | ||
export { | ||
type CreateExternalKeyConfigParameters, | ||
type ExternalConfig, | ||
createExternalKeyConfig, | ||
} from '../createExternalKeyConfig.js' | ||
//////////////////////////////////////////////////////////////////////////////// | ||
@@ -254,0 +261,0 @@ // createStorage |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* @param {Function} sign_message | ||
* @returns {Promise<any>} | ||
*/ | ||
export function generate_wallet_secrets(sign_message: Function): Promise<any>; | ||
/** | ||
* @param {string} wallet_id | ||
* @param {string} blinder_seed | ||
* @param {string} share_seed | ||
* @param {string} pk_root | ||
* @param {string} sk_match | ||
* @param {string} symmetric_key | ||
* @returns {Promise<any>} | ||
*/ | ||
export function create_external_wallet(wallet_id: string, blinder_seed: string, share_seed: string, pk_root: string, sk_match: string, symmetric_key: string): Promise<any>; | ||
/** | ||
* @param {string} seed | ||
@@ -24,3 +39,3 @@ * @returns {any} | ||
/** | ||
* @param {string} seed | ||
* @param {string | undefined} seed | ||
* @param {string} wallet_str | ||
@@ -33,7 +48,9 @@ * @param {string} from_addr | ||
* @param {string} permit_signature | ||
* @returns {any} | ||
* @param {string | undefined} [new_public_key] | ||
* @param {Function | undefined} [sign_message] | ||
* @returns {Promise<any>} | ||
*/ | ||
export function deposit(seed: string, wallet_str: string, from_addr: string, mint: string, amount: string, permit_nonce: string, permit_deadline: string, permit_signature: string): any; | ||
export function deposit(seed: string | undefined, wallet_str: string, from_addr: string, mint: string, amount: string, permit_nonce: string, permit_deadline: string, permit_signature: string, new_public_key?: string, sign_message?: Function): Promise<any>; | ||
/** | ||
* @param {string} seed | ||
* @param {string | undefined} seed | ||
* @param {string} wallet_str | ||
@@ -43,7 +60,9 @@ * @param {string} mint | ||
* @param {string} destination_addr | ||
* @returns {any} | ||
* @param {string | undefined} [new_public_key] | ||
* @param {Function | undefined} [sign_message] | ||
* @returns {Promise<any>} | ||
*/ | ||
export function withdraw(seed: string, wallet_str: string, mint: string, amount: string, destination_addr: string): any; | ||
export function withdraw(seed: string | undefined, wallet_str: string, mint: string, amount: string, destination_addr: string, new_public_key?: string, sign_message?: Function): Promise<any>; | ||
/** | ||
* @param {string} seed | ||
* @param {string | undefined} seed | ||
* @param {string} wallet_str | ||
@@ -58,7 +77,9 @@ * @param {string} id | ||
* @param {boolean} allow_external_matches | ||
* @returns {any} | ||
* @param {string | undefined} [new_public_key] | ||
* @param {Function | undefined} [sign_message] | ||
* @returns {Promise<any>} | ||
*/ | ||
export function new_order(seed: string, wallet_str: string, id: string, base_mint: string, quote_mint: string, side: string, amount: string, worst_case_price: string, min_fill_size: string, allow_external_matches: boolean): any; | ||
export function new_order(seed: string | undefined, wallet_str: string, id: string, base_mint: string, quote_mint: string, side: string, amount: string, worst_case_price: string, min_fill_size: string, allow_external_matches: boolean, new_public_key?: string, sign_message?: Function): Promise<any>; | ||
/** | ||
* @param {string} seed | ||
* @param {string | undefined} seed | ||
* @param {string} wallet_str | ||
@@ -74,12 +95,16 @@ * @param {string} id | ||
* @param {string} matching_pool | ||
* @returns {any} | ||
* @param {string | undefined} [new_public_key] | ||
* @param {Function | undefined} [sign_message] | ||
* @returns {Promise<any>} | ||
*/ | ||
export function new_order_in_matching_pool(seed: string, wallet_str: string, id: string, base_mint: string, quote_mint: string, side: string, amount: string, worst_case_price: string, min_fill_size: string, allow_external_matches: boolean, matching_pool: string): any; | ||
export function new_order_in_matching_pool(seed: string | undefined, wallet_str: string, id: string, base_mint: string, quote_mint: string, side: string, amount: string, worst_case_price: string, min_fill_size: string, allow_external_matches: boolean, matching_pool: string, new_public_key?: string, sign_message?: Function): Promise<any>; | ||
/** | ||
* @param {string} seed | ||
* @param {string | undefined} seed | ||
* @param {string} wallet_str | ||
* @param {string} order_id | ||
* @returns {any} | ||
* @param {string | undefined} [new_public_key] | ||
* @param {Function | undefined} [sign_message] | ||
* @returns {Promise<any>} | ||
*/ | ||
export function cancel_order(seed: string, wallet_str: string, order_id: string): any; | ||
export function cancel_order(seed: string | undefined, wallet_str: string, order_id: string, new_public_key?: string, sign_message?: Function): Promise<any>; | ||
/** | ||
@@ -128,2 +153,25 @@ * @param {string} seed | ||
/** | ||
* @param {string} path | ||
* @param {any} headers | ||
* @param {string} body | ||
* @param {string} key | ||
* @returns {string} | ||
*/ | ||
export function create_request_signature(path: string, headers: any, body: string, key: string): string; | ||
/** | ||
* @param {string} b64_key | ||
* @returns {string} | ||
*/ | ||
export function b64_to_hex_hmac_key(b64_key: string): string; | ||
/** | ||
* @param {string} wallet_id | ||
* @param {string} blinder_seed | ||
* @param {string} share_seed | ||
* @param {string} pk_root | ||
* @param {string} sk_match | ||
* @param {string} symmetric_key | ||
* @returns {Promise<any>} | ||
*/ | ||
export function find_external_wallet(wallet_id: string, blinder_seed: string, share_seed: string, pk_root: string, sk_match: string, symmetric_key: string): Promise<any>; | ||
/** | ||
* @param {string} seed | ||
@@ -141,7 +189,8 @@ * @param {bigint} nonce | ||
/** | ||
* @param {string} seed | ||
* @param {bigint} nonce | ||
* @param {string | undefined} [seed] | ||
* @param {bigint | undefined} [nonce] | ||
* @param {string | undefined} [public_key] | ||
* @returns {any[]} | ||
*/ | ||
export function get_pk_root_scalars(seed: string, nonce: bigint): any[]; | ||
export function get_pk_root_scalars(seed?: string, nonce?: bigint, public_key?: string): any[]; | ||
/** | ||
@@ -152,14 +201,1 @@ * @param {string} seed | ||
export function get_symmetric_key(seed: string): any; | ||
/** | ||
* @param {string} path | ||
* @param {any} headers | ||
* @param {string} body | ||
* @param {string} key | ||
* @returns {string} | ||
*/ | ||
export function create_request_signature(path: string, headers: any, body: string, key: string): string; | ||
/** | ||
* @param {string} b64_key | ||
* @returns {string} | ||
*/ | ||
export function b64_to_hex_hmac_key(b64_key: string): string; |
import axios from 'axios' | ||
import invariant from 'tiny-invariant' | ||
import { getSymmetricKey } from '../actions/getSymmetricKey.js' | ||
import { | ||
@@ -9,5 +8,6 @@ RENEGADE_AUTH_HEADER_NAME, | ||
} from '../constants.js' | ||
import type { BaseConfig, Config } from '../createConfig.js' | ||
import type { BaseConfig, Config, RenegadeConfig } from '../createConfig.js' | ||
import { BaseError } from '../errors/base.js' | ||
import { parseBigJSON } from './bigJSON.js' | ||
import type { AuthType } from './websocket.js' | ||
@@ -109,7 +109,8 @@ export async function postRelayerRaw(url: string, body: any, headers = {}) { | ||
export async function postRelayerWithAuth( | ||
config: Config, | ||
config: RenegadeConfig, | ||
url: string, | ||
body?: string, | ||
requestType?: AuthType, | ||
) { | ||
const symmetricKey = getSymmetricKey(config) | ||
const symmetricKey = config.getSymmetricKey(requestType) | ||
invariant(symmetricKey, 'Failed to derive symmetric key') | ||
@@ -156,4 +157,4 @@ | ||
export async function getRelayerWithAuth(config: Config, url: string) { | ||
const symmetricKey = getSymmetricKey(config) | ||
export async function getRelayerWithAuth(config: RenegadeConfig, url: string) { | ||
const symmetricKey = config.getSymmetricKey() | ||
invariant(symmetricKey, 'Failed to derive symmetric key') | ||
@@ -160,0 +161,0 @@ |
@@ -1,4 +0,3 @@ | ||
import { getSymmetricKey } from '../actions/getSymmetricKey.js' | ||
import { SIG_EXPIRATION_BUFFER_MS } from '../constants.js' | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { addExpiringAuthToHeaders } from './http.js' | ||
@@ -13,3 +12,3 @@ | ||
export type RelayerWebsocketParams = { | ||
config: Config | ||
config: RenegadeConfig | ||
topic: string | ||
@@ -43,3 +42,3 @@ authType: AuthType | ||
export class RelayerWebsocket { | ||
private config: Config | ||
private config: RenegadeConfig | ||
private topic: string | ||
@@ -123,19 +122,7 @@ private authType: AuthType | ||
if (this.authType === AuthType.Wallet) { | ||
const headers = this.buildWalletAuthHeaders(body) | ||
return { | ||
headers, | ||
body, | ||
} | ||
const headers = this.buildAuthHeaders(body) | ||
return { | ||
headers, | ||
body, | ||
} | ||
if (this.authType === AuthType.Admin) { | ||
const headers = this.buildAdminAuthHeaders(body) | ||
return { | ||
headers, | ||
body, | ||
} | ||
} | ||
throw new Error(`Unsupported auth type: ${this.authType}`) | ||
} | ||
@@ -152,6 +139,4 @@ | ||
private buildWalletAuthHeaders( | ||
body: SubscriptionBody, | ||
): Record<string, string> { | ||
const symmetricKey = getSymmetricKey(this.config) | ||
private buildAuthHeaders(body: SubscriptionBody): Record<string, string> { | ||
const symmetricKey = this.config.getSymmetricKey(this.authType) | ||
@@ -168,21 +153,2 @@ return addExpiringAuthToHeaders( | ||
private buildAdminAuthHeaders( | ||
body: SubscriptionBody, | ||
): Record<string, string> { | ||
if (!this.config.adminKey) { | ||
throw new Error('Admin key is required') | ||
} | ||
const { adminKey } = this.config | ||
const symmetricKey = this.config.utils.b64_to_hex_hmac_key(adminKey) | ||
return addExpiringAuthToHeaders( | ||
this.config, | ||
body.topic, | ||
{}, // Headers | ||
JSON.stringify(body), | ||
symmetricKey, | ||
SIG_EXPIRATION_BUFFER_MS, | ||
) | ||
} | ||
private cleanup(): void { | ||
@@ -189,0 +155,0 @@ this.ws = null |
@@ -1,2 +0,2 @@ | ||
import type { Config } from '../createConfig.js' | ||
import type { RenegadeConfig } from '../createConfig.js' | ||
import { | ||
@@ -9,3 +9,3 @@ type AuthType, | ||
export type WebsocketWaiterParams = { | ||
config: Config | ||
config: RenegadeConfig | ||
topic: string | ||
@@ -12,0 +12,0 @@ authType: AuthType |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
799828
469
9142