Skip to content

Commit

Permalink
Merge pull request #822 from EdgeApp/matthew/thorchain-engine
Browse files Browse the repository at this point in the history
(Thorchain) Replace rpc tx_search with midgard transaction query
  • Loading branch information
peachbits authored Sep 5, 2024
2 parents 111733f + 4f6d147 commit 9081e69
Show file tree
Hide file tree
Showing 8 changed files with 456 additions and 178 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- added: (Thorchain) Add Midgard API for transaction queries
- changed: (Thorchain) Move most Thorchain-specific functionality out of CosmosEngine and into to ThorchainEngine subclass

## 4.23.0 (2024-09-03)

- added: (ADA) `isStakeTx` to `EdgeTransaction.otherParams` for staking transaction signing
Expand Down
2 changes: 1 addition & 1 deletion src/cosmos/CosmosTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ export async function updateInfoPayload(
env.networkInfo = mergeDeeply(env.networkInfo, networkInfo)
}

export { makeCurrencyEngine } from './CosmosEngine'
export { makeCurrencyEngine } from './cosmosEngines'
32 changes: 32 additions & 0 deletions src/cosmos/cosmosEngines.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
EdgeCurrencyEngine,
EdgeCurrencyEngineOptions,
EdgeWalletInfo
} from 'edge-core-js/types'

import { PluginEnvironment } from '../common/innerPlugin'
import { CosmosTools } from './CosmosTools'
import { asSafeCosmosWalletInfo, CosmosNetworkInfo } from './cosmosTypes'
import { CosmosEngine } from './engine/CosmosEngine'
import { ThorchainEngine } from './engine/ThorchainEngine'
import { isThorchainEnvironment, ThorchainNetworkInfo } from './thorchainTypes'

export { CosmosEngine } from './engine/CosmosEngine'
export { ThorchainEngine } from './engine/ThorchainEngine'

export async function makeCurrencyEngine(
env: PluginEnvironment<CosmosNetworkInfo | ThorchainNetworkInfo>,
tools: CosmosTools,
walletInfo: EdgeWalletInfo,
opts: EdgeCurrencyEngineOptions
): Promise<EdgeCurrencyEngine> {
const safeWalletInfo = asSafeCosmosWalletInfo(walletInfo)
console.debug('isThorchainEnvironment', isThorchainEnvironment(env))
const engine = isThorchainEnvironment(env)
? new ThorchainEngine(env, tools, safeWalletInfo, opts)
: new CosmosEngine(env, tools, safeWalletInfo, opts)

await engine.loadEngine()

return engine
}
29 changes: 0 additions & 29 deletions src/cosmos/cosmosTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export interface CosmosNetworkInfo {
url: string
}
defaultChainId: string
chainIdUpdateUrl?: string
defaultTransactionFeeUrl?: HttpEndpoint
nativeDenom: string
pluginMnemonicKeyName: string
rpcNode: HttpEndpoint
Expand Down Expand Up @@ -200,25 +198,6 @@ export interface CosmosCoin {
amount: string
}

export const asThornodeNetwork = asObject({
// bond_reward_rune: asString, // '17257435059176',
// burned_bep_2_rune: asString, // '47115838110346964',
// burned_erc_20_rune: asString, // '1653783031763036',
// effective_security_bond: asString, // '6621166637606310',
// gas_spent_rune: asString, // '119414731966742',
// gas_withheld_rune: asString, // '159093044870164',
native_outbound_fee_rune: asString, // '2000000',
native_tx_fee_rune: asString // '2000000',
// outbound_fee_multiplier: asString, // '15000',
// rune_price_in_tor: asString, // '649194931',
// tns_fee_per_block_rune: asString, // '20',
// tns_register_fee_rune: asString, // '1000000000',
// tor_price_in_rune: asString, // '15403694',
// total_bond_units: asString, // '22182160',
// total_reserve: asString, // '8596638591565880',
// vaults_migrating: false
})

/**
* WalletConnect payloads
*/
Expand Down Expand Up @@ -281,11 +260,3 @@ export const asCosmosInfoPayload = asObject({
archiveNodes: asOptional(asHttpEndpoint)
})
export type CosmosInfoPayload = ReturnType<typeof asCosmosInfoPayload>

export const asChainIdUpdate = asObject({
result: asObject({
node_info: asObject({
network: asString // 'thorchain-mainnet-v1',
})
})
})
Loading

0 comments on commit 9081e69

Please sign in to comment.