Skip to content

Commit

Permalink
Fix native noble client init
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepuppy committed Dec 1, 2023
1 parent 3a04b9d commit 6e4df42
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 29 deletions.
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

0 comments on commit 6e4df42

Please sign in to comment.