Skip to content

Commit

Permalink
Merge pull request #1437 from Phala-Network/fix-jssdk-connect
Browse files Browse the repository at this point in the history
fix(jssdk): the default connection is incorrect.
  • Loading branch information
Leechael authored Nov 14, 2023
2 parents 356c954 + 1405053 commit 521fd07
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phala/sdk",
"version": "0.5.4",
"version": "0.5.5",
"description": "Phala Phat Contract JS SDK",
"license": "Apache-2.0",
"author": [
Expand Down
29 changes: 22 additions & 7 deletions frontend/packages/sdk/src/OnChainRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,28 @@ export class OnChainRegistry {
// We should ensure the wasm & api has been initialized here.
await Promise.all([cryptoWaitReady(), api.isReady])
if (options.autoConnect) {
await instance.connect(
options.clusterId,
options.workerId,
options.pruntimeURL,
options.systemContractId,
!!options.skipCheck
)
if (!options.clusterId && !options.workerId && !options.pruntimeURL) {
await instance.connect()
}
// If user specified the pruntimeURL, it should use it first.
else if (options.pruntimeURL) {
const workerInfo: PartialWorkerInfo = {
clusterId: options.clusterId,
pruntimeURL: options.pruntimeURL,
}
await instance.connect(workerInfo)
}
// Failed back to backward compatible mode.
else {
console.warn('Failed back to legacy connection mode, please use pruntimeURL instead.')
await instance.connect(
options.clusterId,
options.workerId,
options.pruntimeURL,
options.systemContractId,
!!options.skipCheck
)
}
}
return instance
}
Expand Down

0 comments on commit 521fd07

Please sign in to comment.