Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thorchain client refactor #997

Merged
merged 18 commits into from
Jan 25, 2024
Merged

Thorchain client refactor #997

merged 18 commits into from
Jan 25, 2024

Conversation

0xp3gasus
Copy link
Contributor

@0xp3gasus 0xp3gasus commented Jan 18, 2024

Thorchain client migration to use the cosmos-sdk package as its foundation:

Breaking changes:

  • getPrivateKey is now async and response is Uint8Array type
  • getPubKey is now async and response is Uint8Array type
  • getDepositTransaction is deprecated in favour of getTransactionData
  • fetchTransaction removed
  • setClientUrl removed
  • getClientUrl removed
  • setExplorerUrls removed
  • getCosmosClient removed
  • setNetwork removed
  • setChainId removed
  • getChainId removed

Comment on lines 14 to 28
export function makeClientPath(fullDerivationPath: string): HdPath {
const out = new Array<Slip10RawIndex>()
let path = `/${fullDerivationPath}`
while (path) {
const match = path.match(/^\/([0-9]+)('?)/)
if (!match) throw new Error('Syntax error while reading path component')
const [fullMatch, numberString, apostrophe] = match
const value = Uint53.fromString(numberString).toNumber()
if (value >= 2 ** 31) throw new Error('Component value too high. Must not exceed 2**31-1.')
if (apostrophe) out.push(Slip10RawIndex.hardened(value))
else out.push(Slip10RawIndex.normal(value))
path = path.slice(fullMatch.length)
}
return out
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't use function form official package ? https://cosmos.github.io/cosmjs/latest/crypto/modules.html#stringToPath

Copy link
Contributor Author

@0xp3gasus 0xp3gasus Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be used, but the default value of the rootDerivationPath has to be changed to 'm' format

@0xp3gasus
Copy link
Contributor Author

With this new commit, client uses the cosmjs function and it is compatible with old packages versions

@0xp3gasus 0xp3gasus marked this pull request as ready for review January 23, 2024 19:56
@0xp3gasus 0xp3gasus linked an issue Jan 25, 2024 that may be closed by this pull request
@0xp3gasus 0xp3gasus merged commit 754fe1a into master Jan 25, 2024
1 check passed
@0xp3gasus 0xp3gasus deleted the 990-thorchain-client-refactor branch January 25, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thorchain client refactor
2 participants