Skip to content

Commit

Permalink
ISSUE-140(SDK v5): gives each new user a Cyprus-1 address for their f…
Browse files Browse the repository at this point in the history
…irst account
  • Loading branch information
ArtemBurakov authored and rileystephens28 committed Apr 16, 2024
1 parent 820025a commit f71d613
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 24 additions & 1 deletion background/services/keyring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,30 @@ export default class KeyringService extends BaseService<Events> {
}

this.#keyrings.push(newKeyring)
const [address] = newKeyring.addAddressesSync(1)
//const [address] = newKeyring.addAddressesSync(1)

// FIXME temp solution for SDK v5
// create a new address until we find an address for the target shard
let address
let found = false
const DEFAULT_SHARD = "cyprus-1"
while (!found) {
address = newKeyring.addAddressesSync(1)[0]
const shardFromAddress = getShardFromAddress(address)
if (shardFromAddress !== undefined) {
if (shardFromAddress === DEFAULT_SHARD) {
found = true
break
}
}
this.#hiddenAccounts[address] = true // may want to reconsider this
}
if (address === undefined || address === null || address === "") {
throw new Error(
`Could not find address in given shard ${DEFAULT_SHARD}`
)
}
this.#hiddenAccounts[address] = false

this.#keyringMetadata[newKeyring.id] = { source }
await this.persistKeyrings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ export default function AccountsNotificationPanelAccounts({

const handleSetShard = (newShard: string) => {
// This is for updating user-selected shard for new address
console.log(newShard)
shard.current = newShard
}

Expand Down

0 comments on commit f71d613

Please sign in to comment.