Skip to content

Commit

Permalink
Merge pull request #69 from nightly-labs/small-fixes-for-aleph-adapter
Browse files Browse the repository at this point in the history
fixes + bump version
  • Loading branch information
NorbertBodziony authored Oct 3, 2023
2 parents e2727eb + 1e6b8a2 commit 8c14256
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 44 deletions.
6 changes: 3 additions & 3 deletions sdk/apps/modal-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"dependencies": {
"@mysten/sui.js": "^0.42.0",
"@mysten/wallet-adapter-wallet-standard": "^0.8.0",
"@nightlylabs/wallet-selector-solana": "0.2.3",
"@nightlylabs/wallet-selector-solana": "0.2.4",
"@nightlylabs/nightly-connect-solana": "0.0.26",
"@nightlylabs/nightly-connect-sui": "0.0.26",
"@nightlylabs/wallet-selector-sui": "0.2.3",
"@nightlylabs/wallet-selector-sui": "0.2.4",
"@nightlylabs/nightly-connect-polkadot": "0.0.6",
"@nightlylabs/wallet-selector-polkadot": "0.1.4",
"@nightlylabs/wallet-selector-polkadot": "0.1.5",
"@polkadot/extension-inject": "^0.46.5",
"@polkadot/api": "^10.9.1",
"@solana/web3.js": "^1.77.2",
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/selector-polkadot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-polkadot",
"version": "0.1.4",
"version": "0.1.5",
"description": "",
"type": "module",
"exports": {
Expand Down
21 changes: 11 additions & 10 deletions sdk/packages/selector-polkadot/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,23 +391,25 @@ export class NightlyConnectAdapter implements Injected {
}

connectToStandardWallet = async (walletName: string, onSuccess: () => void) => {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(true)
}
const adapter = this.walletsList.find((w) => w.name === walletName)?.injectedWallet
if (typeof adapter === 'undefined') {
try {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(false)
this._modal.setStandardWalletConnectProgress(true)
}
const adapter = this.walletsList.find((w) => w.name === walletName)?.injectedWallet
if (typeof adapter === 'undefined') {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(false)
}
throw new Error('Wallet not found')
}
throw new Error('Wallet not found')
}
try {
// @ts-expect-error we want to pass network to enable
const inject = await adapter!.enable!('Nightly Connect', this.network) // TODO should we also use connect?

// Assert that there is at least one account
if ((await inject.accounts.get()).length <= 0) {
throw new Error('No accounts found')
}

persistRecentStandardWalletForNetwork(walletName, this.network)
persistStandardConnectForNetwork(this.network)
this._innerStandardAdapter = {
Expand Down Expand Up @@ -514,7 +516,6 @@ export class NightlyConnectAdapter implements Injected {
return
}
}

this._app.on('userConnected', () => {
try {
if (this._chosenMobileWalletName) {
Expand Down
4 changes: 2 additions & 2 deletions sdk/packages/selector-solana/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-solana",
"version": "0.2.3",
"version": "0.2.4",
"description": "",
"type": "module",
"exports": {
Expand Down Expand Up @@ -41,4 +41,4 @@
"tslib": "^2.5.3",
"typescript": "^5.1.3"
}
}
}
24 changes: 13 additions & 11 deletions sdk/packages/selector-solana/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,20 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter {
}

connectToStandardWallet = async (walletName: string, onSuccess: () => void) => {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(true)
}
try {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(true)
}

const wallet = this.walletsList.find((w) => w.name === walletName)
if (typeof wallet?.standardWallet === 'undefined') {
return
}
const wallet = this.walletsList.find((w) => w.name === walletName)
if (typeof wallet?.standardWallet === 'undefined') {
throw new Error('Wallet not found')
}

const adapter = new StandardWalletAdapter({
wallet: wallet.standardWallet as WalletAdapterCompatibleStandardWallet
})
const adapter = new StandardWalletAdapter({
wallet: wallet.standardWallet as WalletAdapterCompatibleStandardWallet
})

try {
await adapter.connect()
persistRecentStandardWalletForNetwork(walletName, SOLANA_NETWORK)
persistStandardConnectForNetwork(SOLANA_NETWORK)
Expand All @@ -418,6 +418,8 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter {
this._modal?.closeModal()
onSuccess()
} catch {
// clear recent wallet
persistStandardDisconnectForNetwork(SOLANA_NETWORK)
if (this._modal) {
this._modal.setStandardWalletConnectProgress(false)
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/packages/selector-sui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/wallet-selector-sui",
"version": "0.2.3",
"version": "0.2.4",
"description": "",
"type": "module",
"exports": {
Expand Down
22 changes: 11 additions & 11 deletions sdk/packages/selector-sui/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,19 +599,19 @@ export class NightlyConnectSuiAdapter {
}
}
connectToStandardWallet = async (walletName: string, onSuccess: () => void) => {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(true)
}
const wallet = this.walletsList.find((w) => w.name === walletName)
if (typeof wallet?.standardWallet === 'undefined') {
return
}
try {
if (this._modal) {
this._modal.setStandardWalletConnectProgress(true)
}
const wallet = this.walletsList.find((w) => w.name === walletName)
if (typeof wallet?.standardWallet === 'undefined') {
throw new Error('Wallet not found')
}

const adapter = new StandardWalletAdapter({
wallet: wallet.standardWallet
} as StandardWalletAdapterConfig)
const adapter = new StandardWalletAdapter({
wallet: wallet.standardWallet
} as StandardWalletAdapterConfig)

try {
await adapter.connect()

persistRecentStandardWalletForNetwork(walletName, SUI_NETWORK)
Expand Down
128 changes: 123 additions & 5 deletions sdk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8c14256

Please sign in to comment.