Skip to content

Commit 8fe89bf

Browse files
committed
adds tests + fixes condition
1 parent c0e54f9 commit 8fe89bf

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"vitest": "^2.1.5"
7373
},
7474
"optionalDependencies": {
75-
"@rollup/rollup-linux-x64-gnu": ""
75+
"@rollup/rollup-linux-x64-gnu": "^4.28.0"
7676
},
7777
"lint-staged": {
7878
"!(*d).ts": [

src/Web3Auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe
9393
mode: options.mode || SDK_MODE.WEB,
9494
};
9595

96-
this.coreOptions.useDkg = this.isSapphireNetwork() ? options.useDkg || true : true;
96+
this.coreOptions.useDkg = this.isSapphireNetwork() ? (options.useDkg ?? true) : true;
9797

9898
this.privKeyProvider = options.privateKeyProvider;
9999
if (options.accountAbstractionProvider) {

test/unit.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ describe("SFA SDK unit tests", function () {
125125
expect(web3auth.provider).not.toEqual(privateKeyProvider);
126126
});
127127

128+
it("should set useDkg flag when provided in constructor", async function () {
129+
const privateKeyProvider = new EthereumPrivateKeyProvider({
130+
config: mainnetChainConfig,
131+
});
132+
133+
const web3auth = new Web3Auth({ clientId: "test", privateKeyProvider, useDkg: false, web3AuthNetwork: "sapphire_devnet" });
134+
await web3auth.init();
135+
expect(web3auth.coreOptions.useDkg).toEqual(false);
136+
});
137+
128138
describe("Default values", function () {
129139
let privateKeyProvider: EthereumPrivateKeyProvider;
130140
let web3auth: Web3Auth;
@@ -154,6 +164,10 @@ describe("SFA SDK unit tests", function () {
154164
it("should set mode to WEB if not provided in constructor", function () {
155165
expect(web3auth.coreOptions.mode).toBe(SDK_MODE.WEB);
156166
});
167+
168+
it("should set dkg to true if not provided in constructor", function () {
169+
expect(web3auth.coreOptions.useDkg).toBe(true);
170+
});
157171
});
158172
});
159173

0 commit comments

Comments
 (0)