Skip to content

Commit

Permalink
Merge branch 'release/v0.5.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphia1984 committed Jul 26, 2023
2 parents 08c18ad + e70d510 commit f86bf08
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cafeca/lunar",
"version": "0.5.9",
"version": "0.5.10",
"description": "Blockchain Connect Module",
"main": "dist/index.js",
"files": [
Expand Down
12 changes: 11 additions & 1 deletion src/connectors/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import IAsset from "../interfaces/iasset";
import IBlockchain from "../interfaces/iblockchain";
import { EventEmitter } from 'events';

const g: any = typeof globalThis === "object"
? globalThis
: typeof window === "object"
? window
: typeof global === "object"
? global
: null; // Causes an error on the next line
const { ethereum } = g;

class Connector {
_isConnected: boolean = false;
_address: string = '0x';
Expand Down Expand Up @@ -41,7 +50,8 @@ class Connector {
return this._type;
}
get chainId() {
return this._blockchain.chainId;
const chainId = ethereum?.chainId || this._blockchain.chainId;
return chainId;
}
get emitter() {
return this._emitter;
Expand Down
4 changes: 3 additions & 1 deletion src/connectors/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class Metamask extends Connector {

async signTypedData(data: IEIP712Data): Promise<string> {
const typedData: IEIP712Data = data;
typedData.domain.chainId = this.chainId;
typedData.domain.chainId = typedData.domain.chainId ?
typedData.domain.chainId :
this.chainId;
typedData.message.from = this.address;

const from = this.address;
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare global {

export class Lunar {
private static instance: Lunar;
public static version = `v0.5.9`;
public static version = `v0.5.10`;
public static Blockchains = Blockchains;
public static Wallets = Wallets;
public static keccak256 = keccak256;
Expand Down

0 comments on commit f86bf08

Please sign in to comment.