-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
357 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@onflow/fcl": patch | ||
--- | ||
|
||
Fix getChainId bug with nextjs & no longer set flow.network.default in configuration internally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@onflow/transport-http": minor | ||
--- | ||
|
||
Add opts.enableRequestLogging flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
import {config} from "@onflow/config" | ||
import {init} from './fcl-wc' | ||
import * as fcl from '@onflow/fcl' | ||
|
||
jest.mock('@walletconnect/modal', () => {}) | ||
jest.mock('@walletconnect/sign-client', () => {}) | ||
jest.mock('@walletconnect/utils', () => {}) | ||
|
||
describe("Init Client", () => { | ||
it("should throw without projectId", async () => { | ||
async function testFn() { | ||
let chainIdSpy | ||
beforeEach(() => { | ||
chainIdSpy = jest.spyOn(fcl, 'getChainId') | ||
chainIdSpy.mockImplementation(async () => "testnet") | ||
}) | ||
|
||
// Mock transport then import fcl-wc because startup of fcl will call getChainId util which hits the chain | ||
await config.overload( | ||
{ | ||
"flow.network.default": "testnet", | ||
"sdk.transport": async ix => ix | ||
}, | ||
async () => { | ||
await init() | ||
} | ||
) | ||
} | ||
afterEach(() => { | ||
chainIdSpy.mockRestore() | ||
}) | ||
|
||
it("should throw without projectId", async () => { | ||
expect.assertions(1) | ||
await expect(testFn).rejects.toThrow(Error) | ||
await expect(init).rejects.toThrow(Error) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {config} from "@onflow/config" | ||
import {getChainId} from "./get-chain-id" | ||
|
||
/** | ||
* @description | ||
* Watches the config for changes to access node and updates the chain id accordingly | ||
* | ||
* @returns {Function} A function that unsubscribes the listener | ||
* | ||
*/ | ||
export function watchForChainIdChanges() { | ||
return config.subscribe(() => { | ||
// Call getChainId to update the chainId cache if access node has changed | ||
getChainId({ | ||
enableRequestLogging: false, | ||
}).catch(() => {}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as sdk from "@onflow/sdk" | ||
|
||
export async function fetchChainId(opts = {}) { | ||
const response = await sdk | ||
.send([sdk.getNetworkParameters()], opts) | ||
.then(sdk.decode) | ||
return response.chainId | ||
} |
Oops, something went wrong.