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

Fix native noble client init #83

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 51 additions & 24 deletions v4-client-js/__native__/__ios__/v4-native-client.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v4-client-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v4-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dydxprotocol/v4-client-js",
"version": "1.0.7",
"version": "1.0.8",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Expand Down
8 changes: 6 additions & 2 deletions v4-client-js/src/clients/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ declare global {

// eslint-disable-next-line vars-on-top, no-var
var nobleClient: NobleClient | undefined;
// eslint-disable-next-line vars-on-top, no-var
var nobleWallet: LocalWallet | undefined;
}

export async function connectClient(
Expand Down Expand Up @@ -96,6 +98,8 @@ export async function connectNetwork(
globalThis.faucetClient = null;
}
globalThis.nobleClient = new NobleClient(nobleValidatorUrl);
if (globalThis.nobleWallet) await globalThis.nobleClient.connect(globalThis.nobleWallet);

return encodeJson(config);
} catch (e) {
return wrappedError(e);
Expand All @@ -107,11 +111,11 @@ export async function connectWallet(
): Promise<string> {
try {
globalThis.wallet = await LocalWallet.fromMnemonic(mnemonic, BECH32_PREFIX);
const nobleWallet = await LocalWallet.fromMnemonic(
globalThis.nobleWallet = await LocalWallet.fromMnemonic(
mnemonic,
NOBLE_BECH32_PREFIX,
);
await globalThis.nobleClient?.connect(nobleWallet);
await globalThis.nobleClient?.connect(globalThis.nobleWallet);

const address = globalThis.wallet.address!;
return encodeJson({ address });
Expand Down