From 0d7b9a446ff77bbe76d9ccbb78cbc7fe82ad6bbe Mon Sep 17 00:00:00 2001 From: awojciak Date: Fri, 22 Sep 2023 13:56:51 +0200 Subject: [PATCH 1/6] try catches --- sdk/packages/selector-polkadot/src/adapter.ts | 22 +++++++++------- sdk/packages/selector-solana/src/adapter.ts | 26 +++++++++++-------- sdk/packages/selector-sui/src/adapter.ts | 3 +-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index 1f6ff099..e99eb87b 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -503,16 +503,20 @@ export class NightlyConnectAdapter implements Injected { } this._app.on('userConnected', () => { - if (this._chosenMobileWalletName) { - persistRecentStandardWalletForNetwork(this._chosenMobileWalletName, this.network) - } else { - clearRecentStandardWalletForNetwork(this.network) + try { + if (this._chosenMobileWalletName) { + persistRecentStandardWalletForNetwork(this._chosenMobileWalletName, this.network) + } else { + clearRecentStandardWalletForNetwork(this.network) + } + this._connected = true + this._connecting = false + this._appSessionActive = true + this._modal?.closeModal() + resolve() + } catch { + this.disconnect() } - this._connected = true - this._connecting = false - this._appSessionActive = true - this._modal?.closeModal() - resolve() }) if (this._modal) { diff --git a/sdk/packages/selector-solana/src/adapter.ts b/sdk/packages/selector-solana/src/adapter.ts index ac9da46b..833ebc1f 100644 --- a/sdk/packages/selector-solana/src/adapter.ts +++ b/sdk/packages/selector-solana/src/adapter.ts @@ -506,18 +506,22 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { } this._app.on('userConnected', (e) => { - if (this._chosenMobileWalletName) { - persistRecentStandardWalletForNetwork(this._chosenMobileWalletName, SOLANA_NETWORK) - } else { - clearRecentStandardWalletForNetwork(SOLANA_NETWORK) + try { + if (this._chosenMobileWalletName) { + persistRecentStandardWalletForNetwork(this._chosenMobileWalletName, SOLANA_NETWORK) + } else { + clearRecentStandardWalletForNetwork(SOLANA_NETWORK) + } + this._publicKey = new PublicKey(e.publicKeys[0]) + this._connected = true + this._connecting = false + this._appSessionActive = true + this.emit('connect', this._publicKey) + this._modal?.closeModal() + resolve() + } catch { + this.disconnect() } - this._publicKey = new PublicKey(e.publicKeys[0]) - this._connected = true - this._connecting = false - this._appSessionActive = true - this.emit('connect', this._publicKey) - this._modal?.closeModal() - resolve() }) if (this._modal) { this._modal.onClose = () => { diff --git a/sdk/packages/selector-sui/src/adapter.ts b/sdk/packages/selector-sui/src/adapter.ts index 81c289e8..ffacab4d 100644 --- a/sdk/packages/selector-sui/src/adapter.ts +++ b/sdk/packages/selector-sui/src/adapter.ts @@ -347,8 +347,7 @@ export class NightlyConnectSuiAdapter implements WalletAdapter { this._modal?.closeModal() resolve() } catch (e) { - this._connecting = false - this.connecting = false + this.disconnect() this._modal?.closeModal() reject(e) } From fc9da28172b9907767aea9713eb9b99fb5bedb07 Mon Sep 17 00:00:00 2001 From: awojciak Date: Fri, 22 Sep 2023 15:38:26 +0200 Subject: [PATCH 2/6] bump mysten packages --- sdk/apps/modal-example/package.json | 4 +- sdk/apps/modal-example/src/routes/sui.tsx | 4 +- .../src/routes/suiInitOnConnect.tsx | 4 +- sdk/apps/nextjs-example/package.json | 8 +- sdk/apps/sui/package.json | 4 +- sdk/apps/sui/rollup.config.js | 18 ++ sdk/apps/sui/src/app.ts | 6 +- sdk/apps/sui/src/client.ts | 3 +- sdk/apps/sui/src/e2e.test.ts | 29 +-- sdk/apps/sui/src/http-client.test.ts | 13 +- sdk/apps/sui/src/http-client.ts | 2 +- sdk/apps/sui/src/utils.ts | 30 ++- sdk/packages/selector-sui/package.json | 8 +- sdk/packages/selector-sui/rollup.config.js | 4 + sdk/packages/selector-sui/src/adapter.ts | 40 ++-- sdk/packages/selector-sui/src/detection.ts | 4 +- sdk/pnpm-lock.yaml | 218 ++++++++---------- 17 files changed, 202 insertions(+), 197 deletions(-) diff --git a/sdk/apps/modal-example/package.json b/sdk/apps/modal-example/package.json index d9d891b0..4fcafa56 100644 --- a/sdk/apps/modal-example/package.json +++ b/sdk/apps/modal-example/package.json @@ -15,8 +15,8 @@ "vite": "^4.1.4" }, "dependencies": { - "@mysten/sui.js": "^0.37.1", - "@mysten/wallet-adapter-wallet-standard": "^0.7.9", + "@mysten/sui.js": "^0.42.0", + "@mysten/wallet-adapter-wallet-standard": "^0.8.0", "@nightlylabs/wallet-selector-solana": "0.2.2", "@nightlylabs/nightly-connect-solana": "0.0.26", "@nightlylabs/nightly-connect-sui": "0.0.25", diff --git a/sdk/apps/modal-example/src/routes/sui.tsx b/sdk/apps/modal-example/src/routes/sui.tsx index 37030f84..36cc73f0 100644 --- a/sdk/apps/modal-example/src/routes/sui.tsx +++ b/sdk/apps/modal-example/src/routes/sui.tsx @@ -1,7 +1,7 @@ import { createEffect, createSignal, onMount, Show } from 'solid-js' import { Title } from 'solid-start' import { NightlyConnectSuiAdapter } from '@nightlylabs/wallet-selector-sui' -import { TransactionBlock } from '@mysten/sui.js' +import { TransactionBlock } from '@mysten/sui.js/transactions' import toast from 'solid-toast' export default function Sui() { @@ -104,7 +104,7 @@ export default function Sui() { onClick={async () => { try { const accounts = await adapter()!.getAccounts() - await adapter()!.signMessage!({ + await adapter()!.signPersonalMessage!({ message: new TextEncoder().encode('I love Nightly'), account: accounts[0] }) diff --git a/sdk/apps/modal-example/src/routes/suiInitOnConnect.tsx b/sdk/apps/modal-example/src/routes/suiInitOnConnect.tsx index 77773836..92c91d7c 100644 --- a/sdk/apps/modal-example/src/routes/suiInitOnConnect.tsx +++ b/sdk/apps/modal-example/src/routes/suiInitOnConnect.tsx @@ -1,7 +1,7 @@ import { createSignal, onMount, Show } from 'solid-js' import { Title } from 'solid-start' import { NightlyConnectSuiAdapter } from '@nightlylabs/wallet-selector-sui' -import { TransactionBlock } from '@mysten/sui.js' +import { TransactionBlock } from '@mysten/sui.js/transactions' import toast from 'solid-toast' export default function Sui() { @@ -82,7 +82,7 @@ export default function Sui() { onClick={async () => { try { const accounts = await adapter()!.getAccounts() - await adapter()!.signMessage!({ + await adapter()!.signPersonalMessage!({ message: new TextEncoder().encode('I love Nightly'), account: accounts[0] }) diff --git a/sdk/apps/nextjs-example/package.json b/sdk/apps/nextjs-example/package.json index e9c2ae57..73f49f28 100644 --- a/sdk/apps/nextjs-example/package.json +++ b/sdk/apps/nextjs-example/package.json @@ -11,10 +11,10 @@ "dependencies": { "@nightlylabs/wallet-selector-solana": "0.2.2", "@nightlylabs/wallet-selector-sui": "0.2.2", - "@mysten/wallet-adapter-wallet-standard": "0.7.12", - "@mysten/wallet-adapter-base": "0.7.12", - "@mysten/sui.js": "0.37.1", - "@mysten/wallet-kit": "0.4.12", + "@mysten/wallet-adapter-wallet-standard": "0.8.0", + "@mysten/wallet-adapter-base": "0.9.0", + "@mysten/sui.js": "0.42.0", + "@mysten/wallet-kit": "0.7.3", "@solana/web3.js": "^1.77.2", "@types/node": "20.4.2", "@types/react": "18.2.15", diff --git a/sdk/apps/sui/package.json b/sdk/apps/sui/package.json index f230c87b..eea6aaea 100644 --- a/sdk/apps/sui/package.json +++ b/sdk/apps/sui/package.json @@ -46,8 +46,8 @@ "typescript": "^5.1.3" }, "dependencies": { - "@mysten/sui.js": "^0.37.1", - "@mysten/wallet-standard": "^0.5.12", + "@mysten/sui.js": "^0.42.0", + "@mysten/wallet-standard": "^0.8.0", "@nightlylabs/nightly-connect-base": "0.0.25", "@noble/hashes": "^1.3.0", "eventemitter3": "^5.0.1", diff --git a/sdk/apps/sui/rollup.config.js b/sdk/apps/sui/rollup.config.js index 96dabf80..9361b3ea 100644 --- a/sdk/apps/sui/rollup.config.js +++ b/sdk/apps/sui/rollup.config.js @@ -23,6 +23,15 @@ export default [ plugins: [typescript(), nodeResolve(), commonjs(), terser()], external: [ '@mysten/sui.js', + '@mysten/sui.js/dist/cjs/signers/types', + '@mysten/sui.js/client', + '@mysten/sui.js/transactions', + '@mysten/sui.js/keypairs/ed25519', + '@mysten/sui.js/dist/cjs/providers/json-rpc-provider', + '@mysten/sui.js/dist/cjs/rpc/connection', + '@mysten/sui.js/verify', + '@mysten/sui.js/utils', + '@mysten/sui.js/cryptography', '@mysten/wallet-standard', '@noble/hashes', '@nightlylabs/nightly-connect-base', @@ -55,6 +64,15 @@ export default [ ], external: [ '@mysten/sui.js', + '@mysten/sui.js/dist/cjs/signers/types', + '@mysten/sui.js/client', + '@mysten/sui.js/transactions', + '@mysten/sui.js/keypairs/ed25519', + '@mysten/sui.js/dist/cjs/providers/json-rpc-provider', + '@mysten/sui.js/dist/cjs/rpc/connection', + '@mysten/sui.js/verify', + '@mysten/sui.js/utils', + '@mysten/sui.js/cryptography', '@mysten/wallet-standard', '@noble/hashes', '@nightlylabs/nightly-connect-base', diff --git a/sdk/apps/sui/src/app.ts b/sdk/apps/sui/src/app.ts index 619bf8ab..9009c357 100644 --- a/sdk/apps/sui/src/app.ts +++ b/sdk/apps/sui/src/app.ts @@ -1,9 +1,9 @@ import { UserConnectedEvent } from '../../../bindings/UserConnectedEvent' -import { SignedMessage, SignedTransaction } from '@mysten/sui.js' +import { SignedMessage, SignedTransaction } from '@mysten/sui.js/dist/cjs/signers/types' import { SuiSignAndExecuteTransactionBlockInput, SuiSignAndExecuteTransactionBlockOutput, - SuiSignMessageInput, + SuiSignPersonalMessageInput, SuiSignTransactionBlockInput } from '@mysten/wallet-standard' import { @@ -98,7 +98,7 @@ export class AppSui extends EventEmitter { return JSON.parse(signedTx[0].transaction) } - signMessage = async (input: SuiSignMessageInput, encoding?: string) => { + signMessage = async (input: SuiSignPersonalMessageInput, encoding?: string) => { const request: MessageToSign = { message: new TextDecoder().decode(input.message), metadata: JSON.stringify({ encoding: encoding || 'hex', account: input.account }) diff --git a/sdk/apps/sui/src/client.ts b/sdk/apps/sui/src/client.ts index 9f624506..772e6bcf 100644 --- a/sdk/apps/sui/src/client.ts +++ b/sdk/apps/sui/src/client.ts @@ -1,5 +1,6 @@ import { AppDisconnectedEvent } from '../../../bindings/AppDisconnectedEvent' -import { SignedMessage, SignedTransaction, SuiTransactionBlockResponse } from '@mysten/sui.js' +import { SuiTransactionBlockResponse } from '@mysten/sui.js/client' +import { SignedMessage, SignedTransaction } from '@mysten/sui.js/dist/cjs/signers/types' import { BaseClient, ClientBaseInitialize, diff --git a/sdk/apps/sui/src/e2e.test.ts b/sdk/apps/sui/src/e2e.test.ts index 55c8f943..16ad88bd 100644 --- a/sdk/apps/sui/src/e2e.test.ts +++ b/sdk/apps/sui/src/e2e.test.ts @@ -3,17 +3,11 @@ import { assert, beforeAll, beforeEach, describe, expect, test, vi } from 'vites import { AppSui } from './app' import { ClientSui } from './client' import { signTransactionBlock, SUI_NETWORK, TEST_APP_INITIALIZE } from './utils' - -import { - Ed25519Keypair, - fromB64, - IntentScope, - messageWithIntent, - toB64, - toSerializedSignature, - TransactionBlock, - verifyMessage -} from '@mysten/sui.js' +import { fromB64, toB64 } from '@mysten/sui.js/utils' +import { TransactionBlock } from '@mysten/sui.js/transactions' +import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' +import { verifyPersonalMessage } from '@mysten/sui.js/verify' +import { IntentScope, messageWithIntent, toSerializedSignature } from '@mysten/sui.js/cryptography' import { blake2b } from '@noble/hashes/blake2b' import { fetch } from 'cross-fetch' import { WalletAccount } from '@mysten/wallet-standard' @@ -95,10 +89,9 @@ describe('SUI client tests', () => { chain: 'sui:testnet' }) - const isValid = await verifyMessage( - signedTx.transactionBlockBytes, - signedTx.signature, - IntentScope.TransactionData + const isValid = await verifyPersonalMessage( + new TextEncoder().encode(signedTx.transactionBlockBytes), + signedTx.signature ) expect(isValid).toBeTruthy() }) @@ -130,11 +123,7 @@ describe('SUI client tests', () => { account: aliceWalletAccount }) const signData = new TextEncoder().encode(msgToSign) - const isValid = await verifyMessage( - signData, - signedMessage.signature, - IntentScope.PersonalMessage - ) + const isValid = await verifyPersonalMessage(signData, signedMessage.signature) expect(isValid).toBe(true) }) test('#on("signAndExecuteSignTransaction")', async () => { diff --git a/sdk/apps/sui/src/http-client.test.ts b/sdk/apps/sui/src/http-client.test.ts index 23deedbe..94ddbb50 100644 --- a/sdk/apps/sui/src/http-client.test.ts +++ b/sdk/apps/sui/src/http-client.test.ts @@ -9,8 +9,10 @@ import { smartDelay } from '@nightlylabs/nightly-connect-base' import { HttpClientSui } from './http-client' - -import { Ed25519Keypair, IntentScope, toB64, TransactionBlock, verifyMessage } from '@mysten/sui.js' +import { toB64 } from '@mysten/sui.js/utils' +import { TransactionBlock } from '@mysten/sui.js/transactions' +import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' +import { verifyPersonalMessage } from '@mysten/sui.js/verify' import { hexToBytes } from '@noble/hashes/utils' import { WalletAccount } from '@mysten/wallet-standard' @@ -93,10 +95,9 @@ describe('SUI http-client tests', () => { await smartDelay() const signedTx = await promiseSignTransaction - const isValid = await verifyMessage( - signedTx.transactionBlockBytes, - signedTx.signature, - IntentScope.TransactionData + const isValid = await verifyPersonalMessage( + new TextEncoder().encode(signedTx.transactionBlockBytes), + signedTx.signature ) expect(isValid).toBeTruthy() }) diff --git a/sdk/apps/sui/src/http-client.ts b/sdk/apps/sui/src/http-client.ts index 28b722d4..62f4f7df 100644 --- a/sdk/apps/sui/src/http-client.ts +++ b/sdk/apps/sui/src/http-client.ts @@ -3,7 +3,7 @@ import { SUI_NETWORK, parseRequest } from './utils' import { HttpConnectSessionRequest } from '../../../bindings/HttpConnectSessionRequest' import { HttpGetPendingRequestsRequest } from '../../../bindings/HttpGetPendingRequestsRequest' import { HttpGetPendingRequestRequest } from '../../../bindings/HttpGetPendingRequestRequest' -import { SignedTransaction } from '@mysten/sui.js' +import { SignedTransaction } from '@mysten/sui.js//dist/cjs/signers/types' import { HttpGetSessionInfoResponse } from '../../../bindings/HttpGetSessionInfoResponse' export class HttpClientSui { diff --git a/sdk/apps/sui/src/utils.ts b/sdk/apps/sui/src/utils.ts index 3a38fea7..d28ac207 100644 --- a/sdk/apps/sui/src/utils.ts +++ b/sdk/apps/sui/src/utils.ts @@ -1,15 +1,21 @@ -import { - JsonRpcProvider, - Connection, - TransactionBlock, - messageWithIntent, - IntentScope, - toSerializedSignature, - Ed25519Keypair -} from '@mysten/sui.js' +import { TransactionBlock } from '@mysten/sui.js/transactions' +import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' +import { IntentScope, messageWithIntent, toSerializedSignature } from '@mysten/sui.js/cryptography' import { blake2b } from '@noble/hashes/blake2b' -import { AppBaseInitialize, ContentType, RELAY_ENDPOINT, RequestContent } from '@nightlylabs/nightly-connect-base' -import { CustomSuiRequest, SignMessagesSuiRequest, SignTransactionsSuiRequest, SuiRequest } from './requestTypes' +import { + AppBaseInitialize, + ContentType, + RELAY_ENDPOINT, + RequestContent +} from '@nightlylabs/nightly-connect-base' +import { + CustomSuiRequest, + SignMessagesSuiRequest, + SignTransactionsSuiRequest, + SuiRequest +} from './requestTypes' +import { JsonRpcProvider } from '@mysten/sui.js/dist/cjs/providers/json-rpc-provider' +import { Connection } from '@mysten/sui.js/dist/cjs/rpc/connection' export type AppSuiInitialize = Omit @@ -81,4 +87,4 @@ export const parseRequest = (request: RequestContent, sessionId: string): SuiReq return customRequest } } -} \ No newline at end of file +} diff --git a/sdk/packages/selector-sui/package.json b/sdk/packages/selector-sui/package.json index 4664a9be..c4206397 100644 --- a/sdk/packages/selector-sui/package.json +++ b/sdk/packages/selector-sui/package.json @@ -24,10 +24,10 @@ "author": "", "license": "ISC", "dependencies": { - "@mysten/sui.js": "^0.37.1", - "@mysten/wallet-adapter-wallet-standard": "^0.7.12", - "@mysten/wallet-standard": "^0.5.12", - "@mysten/wallet-adapter-base": "^0.7.12", + "@mysten/sui.js": "^0.42.0", + "@mysten/wallet-adapter-wallet-standard": "^0.8.0", + "@mysten/wallet-standard": "^0.8.0", + "@mysten/wallet-adapter-base": "^0.9.0", "@nightlylabs/nightly-connect-sui": "0.0.25", "@nightlylabs/wallet-selector-base": "0.2.2", "@wallet-standard/core": "^1.0.3", diff --git a/sdk/packages/selector-sui/rollup.config.js b/sdk/packages/selector-sui/rollup.config.js index 2fc0a7d3..7ea46124 100644 --- a/sdk/packages/selector-sui/rollup.config.js +++ b/sdk/packages/selector-sui/rollup.config.js @@ -27,7 +27,11 @@ export default [ ], external: [ '@mysten/sui.js', + '@mysten/sui.js/verify', + '@mysten/sui.js/dist/cjs/signers/types', + '@mysten/sui.js/client', '@mysten/wallet-adapter-wallet-standard', + '@mysten/wallet-adapter-wallet-standard/dist/StandardWalletAdapter', '@mysten/wallet-standard', '@nightlylabs/nightly-connect-sui', '@nightlylabs/wallet-selector-base', diff --git a/sdk/packages/selector-sui/src/adapter.ts b/sdk/packages/selector-sui/src/adapter.ts index ffacab4d..db2b2e28 100644 --- a/sdk/packages/selector-sui/src/adapter.ts +++ b/sdk/packages/selector-sui/src/adapter.ts @@ -1,16 +1,13 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import { - SignedMessage, - SignedTransaction, - SuiTransactionBlockResponse, - publicKeyFromSerialized -} from '@mysten/sui.js' -import { WalletAdapter } from '@mysten/wallet-adapter-base' +import { publicKeyFromRawBytes } from '@mysten/sui.js/verify' +import { SignedTransaction } from '@mysten/sui.js/dist/cjs/signers/types' +import { SuiTransactionBlockResponse } from '@mysten/sui.js/client' +// import { WalletAdapter } from '@mysten/wallet-adapter-base' import { StandardWalletAdapter } from '@mysten/wallet-adapter-wallet-standard' import type { - StandardWalletAdapterWallet, + SignedPersonalMessage, SuiSignAndExecuteTransactionBlockInput, - SuiSignMessageInput, + SuiSignPersonalMessageInput, SuiSignTransactionBlockInput } from '@mysten/wallet-standard' import { SUI_CHAINS } from '@mysten/wallet-standard' @@ -38,11 +35,14 @@ import { import type { StandardEventsOnMethod, WalletAccount } from '@wallet-standard/core' import bs58 from 'bs58' import { suiWalletsFilter } from './detection' +import { StandardWalletAdapterConfig } from '@mysten/wallet-adapter-wallet-standard/dist/StandardWalletAdapter' + export const convertBase58toBase64 = (base58: string) => { const buffer = bs58.decode(base58) return buffer.toString('base64') } -export class NightlyConnectSuiAdapter implements WalletAdapter { +export class NightlyConnectSuiAdapter { + // TODO: add later "implements WalletAdapter" name = 'Nightly Connect' as const icon = logoBase64 connected = false @@ -428,19 +428,25 @@ export class NightlyConnectSuiAdapter implements WalletAdapter { this.connecting = false } - signMessage = async (messageInput: SuiSignMessageInput): Promise => { + signPersonalMessage = async ( + messageInput: SuiSignPersonalMessageInput + ): Promise => { if (!this._app || !this._connectionType) { throw new Error('Wallet not ready') } switch (this._connectionType) { case ConnectionType.Nightly: { - return await this._app.signMessage(messageInput) + const message = await this._app.signMessage(messageInput) + return { + bytes: message.messageBytes, + signature: message.signature + } } case ConnectionType.WalletStandard: { if (!this._innerStandardAdapter) { throw new Error('Wallet not ready') } - return await this._innerStandardAdapter.signMessage(messageInput) + return await this._innerStandardAdapter.signPersonalMessage(messageInput) } } } @@ -459,6 +465,7 @@ export class NightlyConnectSuiAdapter implements WalletAdapter { if (!this._innerStandardAdapter) { throw new Error('Wallet not ready') } + // @ts-expect-error(remove after standard will use 0.42) return await this._innerStandardAdapter.signTransactionBlock(transactionInput) } } @@ -478,6 +485,7 @@ export class NightlyConnectSuiAdapter implements WalletAdapter { if (!this._innerStandardAdapter) { throw new Error('Wallet not ready') } + // @ts-expect-error(remove after standard will use 0.42) return await this._innerStandardAdapter.signAndExecuteTransactionBlock(transactionInput) } } @@ -606,8 +614,8 @@ export class NightlyConnectSuiAdapter implements WalletAdapter { } const adapter = new StandardWalletAdapter({ - wallet: wallet.standardWallet as StandardWalletAdapterWallet - }) + wallet: wallet.standardWallet + } as StandardWalletAdapterConfig) try { await adapter.connect() @@ -635,7 +643,7 @@ export class NightlyConnectSuiAdapter implements WalletAdapter { } } export const createSuiWalletAccountFromString = (publicKey: string): WalletAccount => { - const suiPk = publicKeyFromSerialized('ED25519', convertBase58toBase64(publicKey)) + const suiPk = publicKeyFromRawBytes('ED25519', bs58.decode(publicKey)) return { address: suiPk.toSuiAddress(), publicKey: suiPk.toBytes(), diff --git a/sdk/packages/selector-sui/src/detection.ts b/sdk/packages/selector-sui/src/detection.ts index 3f854813..aba8eb36 100644 --- a/sdk/packages/selector-sui/src/detection.ts +++ b/sdk/packages/selector-sui/src/detection.ts @@ -1,9 +1,9 @@ import { Wallet } from '@wallet-standard/core' -import { isStandardWalletAdapterCompatibleWallet } from '@mysten/wallet-standard' +import { isWalletWithRequiredFeatureSet } from '@mysten/wallet-standard' export const suiWalletsFilter = (wallet: Wallet) => { - const is = isStandardWalletAdapterCompatibleWallet(wallet, [ + const is = isWalletWithRequiredFeatureSet(wallet, [ 'sui:signAndExecuteTransactionBlock', 'sui:signTransactionBlock' ]) diff --git a/sdk/pnpm-lock.yaml b/sdk/pnpm-lock.yaml index 339e7b09..f36cd002 100644 --- a/sdk/pnpm-lock.yaml +++ b/sdk/pnpm-lock.yaml @@ -123,11 +123,11 @@ importers: apps/modal-example: dependencies: '@mysten/sui.js': - specifier: ^0.37.1 - version: 0.37.1 + specifier: ^0.42.0 + version: 0.42.0 '@mysten/wallet-adapter-wallet-standard': - specifier: ^0.7.9 - version: 0.7.9 + specifier: ^0.8.0 + version: 0.8.0 '@nightlylabs/nightly-connect-polkadot': specifier: 0.0.6 version: link:../polkadot @@ -202,17 +202,17 @@ importers: apps/nextjs-example: dependencies: '@mysten/sui.js': - specifier: 0.37.1 - version: 0.37.1 + specifier: 0.42.0 + version: 0.42.0 '@mysten/wallet-adapter-base': - specifier: 0.7.12 - version: 0.7.12 + specifier: 0.9.0 + version: 0.9.0 '@mysten/wallet-adapter-wallet-standard': - specifier: 0.7.12 - version: 0.7.12 + specifier: 0.8.0 + version: 0.8.0 '@mysten/wallet-kit': - specifier: 0.4.12 - version: 0.4.12(react-dom@18.2.0)(react@18.2.0) + specifier: 0.7.3 + version: 0.7.3(react-dom@18.2.0)(react@18.2.0) '@nightlylabs/wallet-selector-solana': specifier: 0.2.2 version: link:../../packages/selector-solana @@ -331,7 +331,7 @@ importers: version: 5.1.3 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@20.4.2) + version: 4.3.9(@types/node@18.11.18) apps/solana: dependencies: @@ -391,11 +391,11 @@ importers: apps/sui: dependencies: '@mysten/sui.js': - specifier: ^0.37.1 - version: 0.37.1 + specifier: ^0.42.0 + version: 0.42.0 '@mysten/wallet-standard': - specifier: ^0.5.12 - version: 0.5.12 + specifier: ^0.8.0 + version: 0.8.0 '@nightlylabs/nightly-connect-base': specifier: 0.0.25 version: link:../base @@ -550,7 +550,7 @@ importers: version: 5.0.2 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@20.4.2) + version: 4.3.9(@types/node@18.11.18) packages/qr-codes: dependencies: @@ -715,17 +715,17 @@ importers: packages/selector-sui: dependencies: '@mysten/sui.js': - specifier: ^0.37.1 - version: 0.37.1 + specifier: ^0.42.0 + version: 0.42.0 '@mysten/wallet-adapter-base': - specifier: ^0.7.12 - version: 0.7.12 + specifier: ^0.9.0 + version: 0.9.0 '@mysten/wallet-adapter-wallet-standard': - specifier: ^0.7.12 - version: 0.7.12 + specifier: ^0.8.0 + version: 0.8.0 '@mysten/wallet-standard': - specifier: ^0.5.12 - version: 0.5.12 + specifier: ^0.8.0 + version: 0.8.0 '@nightlylabs/nightly-connect-sui': specifier: 0.0.25 version: link:../../apps/sui @@ -4825,29 +4825,30 @@ packages: resolution: {integrity: sha512-H1rQc1ZOHANWBvPcW+JpGwr+juXSxM8Q8YCkm3GhZd8REu1fHR3z99CErO1p9pkcfcxZnMdIZdIsXkOHY0NilA==} dev: false - /@mysten/bcs@0.7.1: - resolution: {integrity: sha512-wFPb8bkhwrbiStfZMV5rFM7J+umpke59/dNjDp+UYJKykNlW23LCk2ePyEUvGdb62HGJM1jyOJ8g4egE3OmdKA==} + /@mysten/bcs@0.7.3: + resolution: {integrity: sha512-fbusBfsyc2MpTACi72H5edWJ670T84va+qn9jSPpb5BzZ+pzUM1Q0ApPrF5OT+mB1o5Ng+mxPQpBCZQkfiV2TA==} dependencies: bs58: 5.0.0 dev: false - /@mysten/bcs@0.7.3: - resolution: {integrity: sha512-fbusBfsyc2MpTACi72H5edWJ670T84va+qn9jSPpb5BzZ+pzUM1Q0ApPrF5OT+mB1o5Ng+mxPQpBCZQkfiV2TA==} + /@mysten/bcs@0.7.4: + resolution: {integrity: sha512-6DKzM4L10Au3Og5EJRBqJZmXWZ7hS/clVjbVUH4sA0aFtS3AZo2xc+r5fUFfdJbaWZUxVaDiQ8BNiEZWkAnEOw==} dependencies: bs58: 5.0.0 dev: false - /@mysten/sui.js@0.35.1: - resolution: {integrity: sha512-1UQ65oJhO+G5Bt+EWYqMs5y3eqY1ZZxEdB2y4K+XJVeRZBOy32GjSLiYmZufUAR9o53gAlwAvvNRIzMzuiNQzw==} + /@mysten/sui.js@0.40.0: + resolution: {integrity: sha512-PEGdMe+QgpIdDIpyO4/yb+CK4x3Hki+kYPbQ5n3DVsWyb2ztFwB+5oYdc7qG3QkniO1lnCrlSHqZ5mN+x3RzrQ==} engines: {node: '>=16'} dependencies: - '@mysten/bcs': 0.7.1 - '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.0 + '@mysten/bcs': 0.7.3 + '@noble/curves': 1.1.0 + '@noble/hashes': 1.3.1 '@open-rpc/client-js': 1.8.1 - '@scure/bip32': 1.3.0 - '@scure/bip39': 1.2.0 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 '@suchipi/femver': 1.0.0 + events: 3.3.0 superstruct: 1.0.3 tweetnacl: 1.0.3 transitivePeerDependencies: @@ -4856,16 +4857,16 @@ packages: - utf-8-validate dev: false - /@mysten/sui.js@0.37.1: - resolution: {integrity: sha512-nEOqnjUqb/VJcVk23LgZOX1FmBib/mBCwAWaJhtsCHLwv2jIAfCPY/fpB9lJ62QHrM8UFclpWxsLkqcUkKyPgA==} + /@mysten/sui.js@0.42.0: + resolution: {integrity: sha512-khYpfrWTRNk7WTuDWJx/KCbleqY1B40gVRt1DttqlNkD2lvg134xZn7F/r94jxgnUETbK+hVoQvBY7F36MsfRw==} engines: {node: '>=16'} dependencies: - '@mysten/bcs': 0.7.3 - '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.0 + '@mysten/bcs': 0.7.4 + '@noble/curves': 1.1.0 + '@noble/hashes': 1.3.1 '@open-rpc/client-js': 1.8.1 - '@scure/bip32': 1.3.0 - '@scure/bip39': 1.2.0 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 '@suchipi/femver': 1.0.0 events: 3.3.0 superstruct: 1.0.3 @@ -4876,91 +4877,53 @@ packages: - utf-8-validate dev: false - /@mysten/wallet-adapter-base@0.7.12: - resolution: {integrity: sha512-5xDLaZ11+Sw65I9VSzmsHlue8jV0Kq/HiBJYmQes5TU2clwV0ClNBlw7CCipkMPi6IfhBSaaLXWZ9ftX0KG1TQ==} - dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-standard': 0.5.12 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@mysten/wallet-adapter-base@0.7.9: - resolution: {integrity: sha512-5ukbi59E/OObv0UPbgqQEh4L4wnFfuXnNt22oe9M/5EKwlQ/y82mtWRpPqEqfazPI2gVvtUyKLCf5uelA0aJIw==} - dependencies: - '@mysten/sui.js': 0.35.1 - '@mysten/wallet-standard': 0.5.9 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@mysten/wallet-adapter-unsafe-burner@0.8.12: - resolution: {integrity: sha512-s0ek8KIc483jK954INNguDtsCgMsA5L/Zow8gQ15gPQKCIzwSbFnv5JOhrBgHTqDrv5jkjPAfp4AeesXXQHOqg==} - dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-adapter-base': 0.7.12 - '@mysten/wallet-standard': 0.5.12 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@mysten/wallet-adapter-wallet-standard@0.7.12: - resolution: {integrity: sha512-3Km3nsbggIHoaefsPEX2rNFD7+bamk6JBs4jhtOfTFYzXWK3FjWisMEDZFwx+EvoQTH/9lhxgwVRJqPHCv4/yA==} + /@mysten/wallet-adapter-base@0.9.0: + resolution: {integrity: sha512-Obcfd30AC0Tcyvqc9+h0vvjrRB6Td2PNWhxRlTq/hSxDY66M3XqTLgoO8wDBtz+91oga4obAYvM02m7xV7X0Zw==} + deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-adapter-base': 0.7.12 - '@mysten/wallet-standard': 0.5.12 - mitt: 3.0.0 + '@mysten/sui.js': 0.40.0 + '@mysten/wallet-standard': 0.6.0 transitivePeerDependencies: - bufferutil - encoding - utf-8-validate dev: false - /@mysten/wallet-adapter-wallet-standard@0.7.9: - resolution: {integrity: sha512-+wTBzIr6mT9G2KvXDLr0yg1EsZ8PvAKM0nZFAwRf5htGILIITPR3UEX+2ugxc+Ec4Gx/+NQxYd/TfMSA+iHBNg==} + /@mysten/wallet-adapter-wallet-standard@0.8.0: + resolution: {integrity: sha512-WPQSQTUvQCX2PPuVU8NHEzXg+mMCzIKqMG6llt0tLxc4enTtFHw9Do4i298NyZ00zWWzHdx9MXjBOl1OuybURg==} + deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. dependencies: - '@mysten/sui.js': 0.35.1 - '@mysten/wallet-adapter-base': 0.7.9 - '@mysten/wallet-standard': 0.5.9 - mitt: 3.0.0 + '@mysten/sui.js': 0.40.0 + '@mysten/wallet-adapter-base': 0.9.0 + '@mysten/wallet-standard': 0.6.0 + mitt: 3.0.1 transitivePeerDependencies: - bufferutil - encoding - utf-8-validate dev: false - /@mysten/wallet-kit-core@0.4.12: - resolution: {integrity: sha512-h2NXFiUdB3NpBpcHW8SkFCGFyqDkaj3WyML8IgT6otlYgc9v2hl7Wjm7Uc7V4kSf0pM/vwZnG8hh7vMCts7MFA==} + /@mysten/wallet-kit-core@0.6.3: + resolution: {integrity: sha512-Crm18bHFecxqDI6ZGhHCAOB8CpLQ84NB3RFpvYnyk0yDGzNcYahjaG37ns+M7cHp0jbg64ySRV/ETzOaGPfRIw==} dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-adapter-base': 0.7.12 - '@mysten/wallet-standard': 0.5.12 + '@mysten/sui.js': 0.42.0 + '@mysten/wallet-standard': 0.8.0 transitivePeerDependencies: - bufferutil - encoding - utf-8-validate dev: false - /@mysten/wallet-kit@0.4.12(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-D/Uh0m8HAVnL0mSdqoE5UsmJhtioqhVHVXDqPrnzbclUZWaq9+e16C8LiP/Bc5mf3/C/24boBTLf9kl/Zd0FiQ==} + /@mysten/wallet-kit@0.7.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-wkmVny9Cqu2AiLf7FW3wq11+XNOoCi/gQ6ZiKcMsRmTWT8uoP7BG89lsIkP98lOARUa/GaWjTItESiHBNYXcZw==} peerDependencies: react: '*' react-dom: '*' dependencies: '@headlessui/react': 1.7.15(react-dom@18.2.0)(react@18.2.0) - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-adapter-base': 0.7.12 - '@mysten/wallet-adapter-unsafe-burner': 0.8.12 - '@mysten/wallet-adapter-wallet-standard': 0.7.12 - '@mysten/wallet-kit-core': 0.4.12 - '@mysten/wallet-standard': 0.5.12 + '@mysten/sui.js': 0.42.0 + '@mysten/wallet-kit-core': 0.6.3 + '@mysten/wallet-standard': 0.8.0 '@stitches/react': 1.2.8(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -4970,10 +4933,10 @@ packages: - utf-8-validate dev: false - /@mysten/wallet-standard@0.5.12: - resolution: {integrity: sha512-RDKEhBf8aNbCXgTGsDAA7uzpkll24O9M/C48wHFjeb9edIxhaDkiSeGty6flhg9G5ShAHP76dEbz5z6z3ODmCA==} + /@mysten/wallet-standard@0.6.0: + resolution: {integrity: sha512-xE/OijN9zIPoTjTWuxlYMHtp7kXPcAR8dDAbxOIH5h7EZCTk+G6p+SzDp8jV5magf50VcYP0cVjS4CQLx1wQuQ==} dependencies: - '@mysten/sui.js': 0.37.1 + '@mysten/sui.js': 0.40.0 '@wallet-standard/core': 1.0.3 transitivePeerDependencies: - bufferutil @@ -4981,10 +4944,10 @@ packages: - utf-8-validate dev: false - /@mysten/wallet-standard@0.5.9: - resolution: {integrity: sha512-il7pgizfhSrCEX4yVEZu/8f4rs6/FUTP72oX34jtNjAHbRtYaI+aFSuLg8G2D0BbPqPumAjOSfluQ6OVyJGLfQ==} + /@mysten/wallet-standard@0.8.0: + resolution: {integrity: sha512-kFh1iybKxaY+lchN+rtVBT5+UL1IHorZ81Ktg9200tcLeUqLB3V/K1PRqkj2dk0eUGDaLEH+yWjBF9hnyH4rgQ==} dependencies: - '@mysten/sui.js': 0.35.1 + '@mysten/sui.js': 0.42.0 '@wallet-standard/core': 1.0.3 transitivePeerDependencies: - bufferutil @@ -5102,6 +5065,12 @@ packages: dependencies: '@noble/hashes': 1.3.1 + /@noble/curves@1.2.0: + resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} + dependencies: + '@noble/hashes': 1.3.2 + dev: false + /@noble/hashes@1.3.0: resolution: {integrity: sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==} dev: false @@ -5110,6 +5079,11 @@ packages: resolution: {integrity: sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==} engines: {node: '>= 16'} + /@noble/hashes@1.3.2: + resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} + engines: {node: '>= 16'} + dev: false + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -5764,18 +5738,22 @@ packages: /@scure/base@1.1.1: resolution: {integrity: sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==} - /@scure/bip32@1.3.0: - resolution: {integrity: sha512-bcKpo1oj54hGholplGLpqPHRbIsnbixFtc06nwuNM5/dwSXOq/AAYoIBRsBmnZJSdfeNW5rnff7NTAz3ZCqR9Q==} + /@scure/base@1.1.3: + resolution: {integrity: sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==} + dev: false + + /@scure/bip32@1.3.2: + resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} dependencies: - '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.0 - '@scure/base': 1.1.1 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/base': 1.1.3 dev: false - /@scure/bip39@1.2.0: - resolution: {integrity: sha512-SX/uKq52cuxm4YFXWFaVByaSHJh2w3BnokVSeUJVCv6K7WulT9u2BuNRBhuFl8vAuYnzx9bEu9WgpcNYTrYieg==} + /@scure/bip39@1.2.1: + resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} dependencies: - '@noble/hashes': 1.3.0 + '@noble/hashes': 1.3.1 '@scure/base': 1.1.1 dev: false @@ -6327,7 +6305,7 @@ packages: remark-slug: 6.1.0 rollup: 3.23.1 typescript: 5.0.2 - vite: 4.3.9(@types/node@20.4.2) + vite: 4.3.9(@types/node@18.11.18) transitivePeerDependencies: - supports-color dev: true @@ -12951,8 +12929,8 @@ packages: minipass: 3.3.6 yallist: 4.0.0 - /mitt@3.0.0: - resolution: {integrity: sha512-7dX2/10ITVyqh4aOSVI9gdape+t9l2/8QxHrFmUXu4EEUpdlxl6RudZUPZoc+zuY2hk1j7XxVroIVIan/pD/SQ==} + /mitt@3.0.1: + resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} dev: false /mkdirp-classic@0.5.3: From 855de10aabcf43bd1b84ea34cac06b8170afeb24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?NB=F0=9F=98=88?= Date: Sun, 24 Sep 2023 11:44:07 +0200 Subject: [PATCH 3/6] fix sui main package --- sdk/apps/sui/package.json | 6 +- sdk/apps/sui/rollup.config.js | 16 -- sdk/apps/sui/src/app.ts | 3 +- sdk/apps/sui/src/client.ts | 4 +- sdk/apps/sui/src/e2e.test.ts | 45 +++-- sdk/apps/sui/src/http-client.test.ts | 15 +- sdk/apps/sui/src/http-client.ts | 2 +- sdk/apps/sui/src/utils.ts | 11 +- sdk/apps/sui/tsconfig.json | 3 +- sdk/pnpm-lock.yaml | 258 ++++++++++++++++++++++++--- 10 files changed, 282 insertions(+), 81 deletions(-) diff --git a/sdk/apps/sui/package.json b/sdk/apps/sui/package.json index eea6aaea..5efcbb6a 100644 --- a/sdk/apps/sui/package.json +++ b/sdk/apps/sui/package.json @@ -1,6 +1,6 @@ { "name": "@nightlylabs/nightly-connect-sui", - "version": "0.0.25", + "version": "0.0.26", "type": "module", "exports": { ".": { @@ -31,7 +31,7 @@ }, "devDependencies": { "@rollup/plugin-commonjs": "^25.0.0", - "@rollup/plugin-node-resolve": "^15.1.0", + "@rollup/plugin-node-resolve": "^15.2.1", "@rollup/plugin-terser": "^0.4.3", "@rollup/plugin-typescript": "^11.1.1", "@types/node": "^20.3.0", @@ -53,4 +53,4 @@ "eventemitter3": "^5.0.1", "uuid": "^9.0.0" } -} +} \ No newline at end of file diff --git a/sdk/apps/sui/rollup.config.js b/sdk/apps/sui/rollup.config.js index 9361b3ea..00405c9f 100644 --- a/sdk/apps/sui/rollup.config.js +++ b/sdk/apps/sui/rollup.config.js @@ -23,15 +23,7 @@ export default [ plugins: [typescript(), nodeResolve(), commonjs(), terser()], external: [ '@mysten/sui.js', - '@mysten/sui.js/dist/cjs/signers/types', '@mysten/sui.js/client', - '@mysten/sui.js/transactions', - '@mysten/sui.js/keypairs/ed25519', - '@mysten/sui.js/dist/cjs/providers/json-rpc-provider', - '@mysten/sui.js/dist/cjs/rpc/connection', - '@mysten/sui.js/verify', - '@mysten/sui.js/utils', - '@mysten/sui.js/cryptography', '@mysten/wallet-standard', '@noble/hashes', '@nightlylabs/nightly-connect-base', @@ -64,15 +56,7 @@ export default [ ], external: [ '@mysten/sui.js', - '@mysten/sui.js/dist/cjs/signers/types', '@mysten/sui.js/client', - '@mysten/sui.js/transactions', - '@mysten/sui.js/keypairs/ed25519', - '@mysten/sui.js/dist/cjs/providers/json-rpc-provider', - '@mysten/sui.js/dist/cjs/rpc/connection', - '@mysten/sui.js/verify', - '@mysten/sui.js/utils', - '@mysten/sui.js/cryptography', '@mysten/wallet-standard', '@noble/hashes', '@nightlylabs/nightly-connect-base', diff --git a/sdk/apps/sui/src/app.ts b/sdk/apps/sui/src/app.ts index 9009c357..01b258cd 100644 --- a/sdk/apps/sui/src/app.ts +++ b/sdk/apps/sui/src/app.ts @@ -1,5 +1,6 @@ import { UserConnectedEvent } from '../../../bindings/UserConnectedEvent' -import { SignedMessage, SignedTransaction } from '@mysten/sui.js/dist/cjs/signers/types' +// import { SignedMessage, SignedTransaction } from '@mysten/sui.js/dist/esm/signers/types' +import type { SignedMessage, SignedTransaction } from '@mysten/sui.js/src/signers/types' import { SuiSignAndExecuteTransactionBlockInput, SuiSignAndExecuteTransactionBlockOutput, diff --git a/sdk/apps/sui/src/client.ts b/sdk/apps/sui/src/client.ts index 772e6bcf..04c57aad 100644 --- a/sdk/apps/sui/src/client.ts +++ b/sdk/apps/sui/src/client.ts @@ -1,6 +1,6 @@ import { AppDisconnectedEvent } from '../../../bindings/AppDisconnectedEvent' -import { SuiTransactionBlockResponse } from '@mysten/sui.js/client' -import { SignedMessage, SignedTransaction } from '@mysten/sui.js/dist/cjs/signers/types' +import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client' +import type { SignedMessage, SignedTransaction } from '@mysten/sui.js/src/signers/types' import { BaseClient, ClientBaseInitialize, diff --git a/sdk/apps/sui/src/e2e.test.ts b/sdk/apps/sui/src/e2e.test.ts index 16ad88bd..17c7eee2 100644 --- a/sdk/apps/sui/src/e2e.test.ts +++ b/sdk/apps/sui/src/e2e.test.ts @@ -6,8 +6,13 @@ import { signTransactionBlock, SUI_NETWORK, TEST_APP_INITIALIZE } from './utils' import { fromB64, toB64 } from '@mysten/sui.js/utils' import { TransactionBlock } from '@mysten/sui.js/transactions' import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' -import { verifyPersonalMessage } from '@mysten/sui.js/verify' -import { IntentScope, messageWithIntent, toSerializedSignature } from '@mysten/sui.js/cryptography' +import { verifyPersonalMessage, verifyTransactionBlock } from '@mysten/sui.js/verify' +import { + IntentScope, + messageWithIntent, + parseSerializedSignature, + toSerializedSignature +} from '@mysten/sui.js/cryptography' import { blake2b } from '@noble/hashes/blake2b' import { fetch } from 'cross-fetch' import { WalletAccount } from '@mysten/wallet-standard' @@ -89,24 +94,24 @@ describe('SUI client tests', () => { chain: 'sui:testnet' }) - const isValid = await verifyPersonalMessage( - new TextEncoder().encode(signedTx.transactionBlockBytes), - signedTx.signature - ) - expect(isValid).toBeTruthy() + try { + // Will throw if invalid + await verifyTransactionBlock(fromB64(signedTx.transactionBlockBytes), signedTx.signature) + } catch (error) { + assert(false, 'Transaction block is invalid') + } }) test('#on("signMessages")', async () => { - const msgToSign = 'Hello World' + const msgToSign = 'I love Nightly' client.on('signMessages', async (e) => { const msg = e.messages[0].message - const msgTo64 = toB64(new TextEncoder().encode(msg)) - const intentMessage = messageWithIntent(IntentScope.PersonalMessage, fromB64(msgTo64)) - const digest = blake2b(intentMessage, { dkLen: 32 }) - const signature = alice_keypair.signData(digest) + const msgTo64 = new TextEncoder().encode(msg) + const { signature } = await alice_keypair.signPersonalMessage(msgTo64) + await verifyPersonalMessage(msgTo64, signature) const signedMessage = { messageBytes: msg, signature: toSerializedSignature({ - signature, + signature: fromB64(signature), signatureScheme: 'ED25519', pubKey: alice_keypair.getPublicKey() }) @@ -122,9 +127,17 @@ describe('SUI client tests', () => { message: new TextEncoder().encode(msgToSign), account: aliceWalletAccount }) - const signData = new TextEncoder().encode(msgToSign) - const isValid = await verifyPersonalMessage(signData, signedMessage.signature) - expect(isValid).toBe(true) + try { + // We need to deserialize the signature + const parsedSignature = parseSerializedSignature(signedMessage.signature) + // Will throw if invalid + await verifyPersonalMessage( + new TextEncoder().encode(msgToSign), + toB64(parsedSignature.signature!) + ) + } catch (error) { + assert(false, 'Message is invalid') + } }) test('#on("signAndExecuteSignTransaction")', async () => { const tx = new TransactionBlock() diff --git a/sdk/apps/sui/src/http-client.test.ts b/sdk/apps/sui/src/http-client.test.ts index 94ddbb50..19f49f5f 100644 --- a/sdk/apps/sui/src/http-client.test.ts +++ b/sdk/apps/sui/src/http-client.test.ts @@ -9,10 +9,10 @@ import { smartDelay } from '@nightlylabs/nightly-connect-base' import { HttpClientSui } from './http-client' -import { toB64 } from '@mysten/sui.js/utils' +import { fromB64, toB64 } from '@mysten/sui.js/utils' import { TransactionBlock } from '@mysten/sui.js/transactions' import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' -import { verifyPersonalMessage } from '@mysten/sui.js/verify' +import { verifyPersonalMessage, verifyTransactionBlock } from '@mysten/sui.js/verify' import { hexToBytes } from '@noble/hashes/utils' import { WalletAccount } from '@mysten/wallet-standard' @@ -95,10 +95,11 @@ describe('SUI http-client tests', () => { await smartDelay() const signedTx = await promiseSignTransaction - const isValid = await verifyPersonalMessage( - new TextEncoder().encode(signedTx.transactionBlockBytes), - signedTx.signature - ) - expect(isValid).toBeTruthy() + try { + // Will throw if invalid + await verifyTransactionBlock(fromB64(signedTx.transactionBlockBytes), signedTx.signature) + } catch (error) { + assert(false, 'Transaction block is invalid') + } }) }) diff --git a/sdk/apps/sui/src/http-client.ts b/sdk/apps/sui/src/http-client.ts index 62f4f7df..70fa81e5 100644 --- a/sdk/apps/sui/src/http-client.ts +++ b/sdk/apps/sui/src/http-client.ts @@ -3,7 +3,7 @@ import { SUI_NETWORK, parseRequest } from './utils' import { HttpConnectSessionRequest } from '../../../bindings/HttpConnectSessionRequest' import { HttpGetPendingRequestsRequest } from '../../../bindings/HttpGetPendingRequestsRequest' import { HttpGetPendingRequestRequest } from '../../../bindings/HttpGetPendingRequestRequest' -import { SignedTransaction } from '@mysten/sui.js//dist/cjs/signers/types' +import { type SignedTransaction } from '@mysten/sui.js/src/signers/types' import { HttpGetSessionInfoResponse } from '../../../bindings/HttpGetSessionInfoResponse' export class HttpClientSui { diff --git a/sdk/apps/sui/src/utils.ts b/sdk/apps/sui/src/utils.ts index d28ac207..bd728441 100644 --- a/sdk/apps/sui/src/utils.ts +++ b/sdk/apps/sui/src/utils.ts @@ -1,5 +1,5 @@ -import { TransactionBlock } from '@mysten/sui.js/transactions' -import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' +import { type TransactionBlock } from '@mysten/sui.js/transactions' +import { type Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519' import { IntentScope, messageWithIntent, toSerializedSignature } from '@mysten/sui.js/cryptography' import { blake2b } from '@noble/hashes/blake2b' import { @@ -14,8 +14,7 @@ import { SignTransactionsSuiRequest, SuiRequest } from './requestTypes' -import { JsonRpcProvider } from '@mysten/sui.js/dist/cjs/providers/json-rpc-provider' -import { Connection } from '@mysten/sui.js/dist/cjs/rpc/connection' +import { SuiClient } from '@mysten/sui.js/client' export type AppSuiInitialize = Omit @@ -37,9 +36,7 @@ export function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)) } -const suiConnection = new JsonRpcProvider( - new Connection({ fullnode: 'https://fullnode.testnet.sui.io/' }) -) +const suiConnection = new SuiClient({ url: 'https://fullnode.testnet.sui.io/' }) export const signTransactionBlock = async (tx: TransactionBlock, account: Ed25519Keypair) => { const transactionBlockBytes = await tx.build({ provider: suiConnection, diff --git a/sdk/apps/sui/tsconfig.json b/sdk/apps/sui/tsconfig.json index 75a9ae75..1f183297 100644 --- a/sdk/apps/sui/tsconfig.json +++ b/sdk/apps/sui/tsconfig.json @@ -26,5 +26,6 @@ "ts-node": { "require": ["tsconfig-paths/register"] }, - "include": ["../../bindings/*", "src/*"] + "include": ["../../bindings/*", "src/*"], + "exclude": ["node_modules", "dist"] } diff --git a/sdk/pnpm-lock.yaml b/sdk/pnpm-lock.yaml index f36cd002..37eb70fe 100644 --- a/sdk/pnpm-lock.yaml +++ b/sdk/pnpm-lock.yaml @@ -29,7 +29,7 @@ importers: version: 2.8.0 turbo: specifier: latest - version: 1.10.14 + version: 1.10.7 typescript: specifier: ^4.9.0 version: 4.9.4 @@ -135,7 +135,7 @@ importers: specifier: 0.0.26 version: link:../solana '@nightlylabs/nightly-connect-sui': - specifier: 0.0.25 + specifier: 0.0.26 version: link:../sui '@nightlylabs/wallet-selector-polkadot': specifier: 0.1.2 @@ -144,7 +144,7 @@ importers: specifier: 0.2.2 version: link:../../packages/selector-solana '@nightlylabs/wallet-selector-sui': - specifier: 0.2.2 + specifier: 0.2.3 version: link:../../packages/selector-sui '@polkadot/api': specifier: ^10.9.1 @@ -218,7 +218,7 @@ importers: version: link:../../packages/selector-solana '@nightlylabs/wallet-selector-sui': specifier: 0.2.2 - version: link:../../packages/selector-sui + version: 0.2.2 '@solana/web3.js': specifier: ^1.77.2 version: 1.77.2 @@ -413,8 +413,8 @@ importers: specifier: ^25.0.0 version: 25.0.0(rollup@3.23.1) '@rollup/plugin-node-resolve': - specifier: ^15.1.0 - version: 15.1.0(rollup@3.23.1) + specifier: ^15.2.1 + version: 15.2.1(rollup@3.23.1) '@rollup/plugin-terser': specifier: ^0.4.3 version: 0.4.3(rollup@3.23.1) @@ -727,7 +727,7 @@ importers: specifier: ^0.8.0 version: 0.8.0 '@nightlylabs/nightly-connect-sui': - specifier: 0.0.25 + specifier: 0.0.26 version: link:../../apps/sui '@nightlylabs/wallet-selector-base': specifier: 0.2.2 @@ -4837,6 +4837,46 @@ packages: bs58: 5.0.0 dev: false + /@mysten/sui.js@0.37.1: + resolution: {integrity: sha512-nEOqnjUqb/VJcVk23LgZOX1FmBib/mBCwAWaJhtsCHLwv2jIAfCPY/fpB9lJ62QHrM8UFclpWxsLkqcUkKyPgA==} + engines: {node: '>=16'} + dependencies: + '@mysten/bcs': 0.7.3 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@open-rpc/client-js': 1.8.1 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + '@suchipi/femver': 1.0.0 + events: 3.3.0 + superstruct: 1.0.3 + tweetnacl: 1.0.3 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /@mysten/sui.js@0.39.0: + resolution: {integrity: sha512-fJu6k7+Qb1z2h9i5Jai0sTWmaGP1UT6d/JIXhEwMZ6cz+13GT/8zRp8kUhP7Oq9Z2hxmwfy1ROptbsrv/x9V8A==} + engines: {node: '>=16'} + dependencies: + '@mysten/bcs': 0.7.3 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@open-rpc/client-js': 1.8.1 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + '@suchipi/femver': 1.0.0 + events: 3.3.0 + superstruct: 1.0.3 + tweetnacl: 1.0.3 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + /@mysten/sui.js@0.40.0: resolution: {integrity: sha512-PEGdMe+QgpIdDIpyO4/yb+CK4x3Hki+kYPbQ5n3DVsWyb2ztFwB+5oYdc7qG3QkniO1lnCrlSHqZ5mN+x3RzrQ==} engines: {node: '>=16'} @@ -4877,6 +4917,30 @@ packages: - utf-8-validate dev: false + /@mysten/wallet-adapter-base@0.7.12: + resolution: {integrity: sha512-5xDLaZ11+Sw65I9VSzmsHlue8jV0Kq/HiBJYmQes5TU2clwV0ClNBlw7CCipkMPi6IfhBSaaLXWZ9ftX0KG1TQ==} + deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. + dependencies: + '@mysten/sui.js': 0.37.1 + '@mysten/wallet-standard': 0.5.12 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /@mysten/wallet-adapter-base@0.8.1: + resolution: {integrity: sha512-hS1jxxGwNA+pyX9KU95DN4yum63ZDgZP3KH+6wtJfh5Vr8Yxbq9+JYumOqvmAyK0sHzHjxJEYDojNgibggwgrw==} + deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. + dependencies: + '@mysten/sui.js': 0.39.0 + '@mysten/wallet-standard': 0.5.14 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + /@mysten/wallet-adapter-base@0.9.0: resolution: {integrity: sha512-Obcfd30AC0Tcyvqc9+h0vvjrRB6Td2PNWhxRlTq/hSxDY66M3XqTLgoO8wDBtz+91oga4obAYvM02m7xV7X0Zw==} deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. @@ -4889,6 +4953,20 @@ packages: - utf-8-validate dev: false + /@mysten/wallet-adapter-wallet-standard@0.7.14: + resolution: {integrity: sha512-v6RPjtRb1hQfeUvaTnrl8iDXK0EGF7PfXbVeAzxMqVqcI3CV08B1VSqLQUZ8ecDwliY+il4fi9vp82ETAv0QjA==} + deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. + dependencies: + '@mysten/sui.js': 0.39.0 + '@mysten/wallet-adapter-base': 0.8.1 + '@mysten/wallet-standard': 0.5.14 + mitt: 3.0.1 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + /@mysten/wallet-adapter-wallet-standard@0.8.0: resolution: {integrity: sha512-WPQSQTUvQCX2PPuVU8NHEzXg+mMCzIKqMG6llt0tLxc4enTtFHw9Do4i298NyZ00zWWzHdx9MXjBOl1OuybURg==} deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. @@ -4933,6 +5011,28 @@ packages: - utf-8-validate dev: false + /@mysten/wallet-standard@0.5.12: + resolution: {integrity: sha512-RDKEhBf8aNbCXgTGsDAA7uzpkll24O9M/C48wHFjeb9edIxhaDkiSeGty6flhg9G5ShAHP76dEbz5z6z3ODmCA==} + dependencies: + '@mysten/sui.js': 0.37.1 + '@wallet-standard/core': 1.0.3 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /@mysten/wallet-standard@0.5.14: + resolution: {integrity: sha512-O4pBU5nO5zBMuhIpOiMkJinxUo68M1m4ca4AQNM5gYLMpuHipcHDNPpCINIyIsCsff61ilGDzPhZU4R8+zZ/2A==} + dependencies: + '@mysten/sui.js': 0.39.0 + '@wallet-standard/core': 1.0.3 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + /@mysten/wallet-standard@0.6.0: resolution: {integrity: sha512-xE/OijN9zIPoTjTWuxlYMHtp7kXPcAR8dDAbxOIH5h7EZCTk+G6p+SzDp8jV5magf50VcYP0cVjS4CQLx1wQuQ==} dependencies: @@ -5054,6 +5154,91 @@ packages: dev: false optional: true + /@nightlylabs/nightly-connect-base@0.0.25: + resolution: {integrity: sha512-E0NwUoBuyqzcnxSiLxEZAiujoUYhndwiprJ2bH615xkpPRRGiS/PGkfeoBtuZewV/6uhAcyQyW0+maCQqGKWog==} + dependencies: + cross-fetch: 3.1.6 + eventemitter3: 5.0.1 + isomorphic-localstorage: 1.0.2 + isomorphic-ws: 5.0.0(ws@8.13.0) + uuid: 9.0.0 + ws: 8.13.0(bufferutil@4.0.7)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /@nightlylabs/nightly-connect-sui@0.0.25: + resolution: {integrity: sha512-lvUBiBwf+tlEmtm40kBwcZJI8ZB5J1EhpM7iyWg2SPb8M3D3SC/ZmbDQDnSb/LXlygZLyfpGsh//8I1PNNmfvA==} + dependencies: + '@mysten/sui.js': 0.37.1 + '@mysten/wallet-standard': 0.5.14 + '@nightlylabs/nightly-connect-base': 0.0.25 + '@noble/hashes': 1.3.2 + eventemitter3: 5.0.1 + uuid: 9.0.0 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + + /@nightlylabs/qr-code@2.0.4: + resolution: {integrity: sha512-GU8u8Cm1Q5YnoB/kikM4whFQhJ7ZWKaazBm4wiZK9Qi64Ht9tyRVzASBbZRpeOZVzxwi7Mml5sz0hUKPEFMpdA==} + dependencies: + qrcode-generator: 1.4.4 + dev: false + + /@nightlylabs/wallet-selector-base@0.2.2: + resolution: {integrity: sha512-Xui3qxtMSzJ/GQEo9G21x8zowxLIQQfRhNmzSlRlxkv5waRNm4eW4BmegfE2DRXCVM2WzgbdP8RYRS20EKXrmQ==} + dependencies: + '@nightlylabs/nightly-connect-base': 0.0.25 + '@nightlylabs/wallet-selector-modal': 0.1.2 + '@wallet-standard/core': 1.0.3 + isomorphic-localstorage: 1.0.2 + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - ts-node + - utf-8-validate + dev: false + + /@nightlylabs/wallet-selector-modal@0.1.2: + resolution: {integrity: sha512-vxy9S2dEf3NARW6LDq2ZKpWMlk5JJFIuwUfSxkuJlgUg2OVSlnDS7vdho3h4DmluRU5GM9vVhaXUGHAVp5sDQg==} + dependencies: + '@nightlylabs/qr-code': 2.0.4 + autoprefixer: 10.4.14(postcss@8.4.24) + lit: 2.7.2 + postcss: 8.4.24 + postcss-lit: 1.1.0(postcss@8.4.24) + tailwindcss: 3.3.2 + transitivePeerDependencies: + - supports-color + - ts-node + dev: false + + /@nightlylabs/wallet-selector-sui@0.2.2: + resolution: {integrity: sha512-DNHif5fdEkA9W5Emm2r+fR4fkib/yFanbzhAIfiFURh6X4DKj2k1LreHmMWllOeD9M3ZuJh2amW0E4uS5zFqZQ==} + dependencies: + '@mysten/sui.js': 0.37.1 + '@mysten/wallet-adapter-base': 0.7.12 + '@mysten/wallet-adapter-wallet-standard': 0.7.14 + '@mysten/wallet-standard': 0.5.14 + '@nightlylabs/nightly-connect-sui': 0.0.25 + '@nightlylabs/wallet-selector-base': 0.2.2 + '@wallet-standard/core': 1.0.3 + bs58: 4.0.1 + events: 3.3.0 + transitivePeerDependencies: + - bufferutil + - encoding + - supports-color + - ts-node + - utf-8-validate + dev: false + /@noble/curves@1.0.0: resolution: {integrity: sha512-2upgEu0iLiDVDZkNLeFV2+ht0BAVgQnEmCk6JsOch9Rp8xfkMCbvbAZlA2pBHQc73dbl+vFOXfqkf4uemdn0bw==} dependencies: @@ -5624,6 +5809,24 @@ packages: resolve: 1.22.2 rollup: 3.23.1 + /@rollup/plugin-node-resolve@15.2.1(rollup@3.23.1): + resolution: {integrity: sha512-nsbUg588+GDSu8/NS8T4UAshO6xeaOfINNuXeVHcKV02LJtoRaM1SiOacClw4kws1SFiNhdLGxlbMY9ga/zs/w==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.78.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.0.2(rollup@3.23.1) + '@types/resolve': 1.20.2 + deepmerge: 4.3.1 + is-builtin-module: 3.2.1 + is-module: 1.0.0 + resolve: 1.22.2 + rollup: 3.23.1 + dev: true + /@rollup/plugin-terser@0.4.3(rollup@3.23.1): resolution: {integrity: sha512-EF0oejTMtkyhrkwCdg0HJ0IpkcaVg1MMSf2olHb2Jp+1mnLM04OhjpJWGma4HobiDTF0WCyViWuvadyE9ch2XA==} engines: {node: '>=14.0.0'} @@ -16320,64 +16523,65 @@ packages: typescript: 5.1.6 dev: false - /turbo-darwin-64@1.10.14: - resolution: {integrity: sha512-I8RtFk1b9UILAExPdG/XRgGQz95nmXPE7OiGb6ytjtNIR5/UZBS/xVX/7HYpCdmfriKdVwBKhalCoV4oDvAGEg==} + /turbo-darwin-64@1.10.7: + resolution: {integrity: sha512-N2MNuhwrl6g7vGuz4y3fFG2aR1oCs0UZ5HKl8KSTn/VC2y2YIuLGedQ3OVbo0TfEvygAlF3QGAAKKtOCmGPNKA==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-darwin-arm64@1.10.14: - resolution: {integrity: sha512-KAdUWryJi/XX7OD0alOuOa0aJ5TLyd4DNIYkHPHYcM6/d7YAovYvxRNwmx9iv6Vx6IkzTnLeTiUB8zy69QkG9Q==} + /turbo-darwin-arm64@1.10.7: + resolution: {integrity: sha512-WbJkvjU+6qkngp7K4EsswOriO3xrNQag7YEGRtfLoDdMTk4O4QTeU6sfg2dKfDsBpTidTvEDwgIYJhYVGzrz9Q==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-linux-64@1.10.14: - resolution: {integrity: sha512-BOBzoREC2u4Vgpap/WDxM6wETVqVMRcM8OZw4hWzqCj2bqbQ6L0wxs1LCLWVrghQf93JBQtIGAdFFLyCSBXjWQ==} + /turbo-linux-64@1.10.7: + resolution: {integrity: sha512-x1CF2CDP1pDz/J8/B2T0hnmmOQI2+y11JGIzNP0KtwxDM7rmeg3DDTtDM/9PwGqfPotN9iVGgMiMvBuMFbsLhg==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-linux-arm64@1.10.14: - resolution: {integrity: sha512-D8T6XxoTdN5D4V5qE2VZG+/lbZX/89BkAEHzXcsSUTRjrwfMepT3d2z8aT6hxv4yu8EDdooZq/2Bn/vjMI32xw==} + /turbo-linux-arm64@1.10.7: + resolution: {integrity: sha512-JtnBmaBSYbs7peJPkXzXxsRGSGBmBEIb6/kC8RRmyvPAMyqF8wIex0pttsI+9plghREiGPtRWv/lfQEPRlXnNQ==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-windows-64@1.10.14: - resolution: {integrity: sha512-zKNS3c1w4i6432N0cexZ20r/aIhV62g69opUn82FLVs/zk3Ie0GVkSB6h0rqIvMalCp7enIR87LkPSDGz9K4UA==} + /turbo-windows-64@1.10.7: + resolution: {integrity: sha512-7A/4CByoHdolWS8dg3DPm99owfu1aY/W0V0+KxFd0o2JQMTQtoBgIMSvZesXaWM57z3OLsietFivDLQPuzE75w==} cpu: [x64] os: [win32] requiresBuild: true dev: true optional: true - /turbo-windows-arm64@1.10.14: - resolution: {integrity: sha512-rkBwrTPTxNSOUF7of8eVvvM+BkfkhA2OvpHM94if8tVsU+khrjglilp8MTVPHlyS9byfemPAmFN90oRIPB05BA==} + /turbo-windows-arm64@1.10.7: + resolution: {integrity: sha512-D36K/3b6+hqm9IBAymnuVgyePktwQ+F0lSXr2B9JfAdFPBktSqGmp50JNC7pahxhnuCLj0Vdpe9RqfnJw5zATA==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /turbo@1.10.14: - resolution: {integrity: sha512-hr9wDNYcsee+vLkCDIm8qTtwhJ6+UAMJc3nIY6+PNgUTtXcQgHxCq8BGoL7gbABvNWv76CNbK5qL4Lp9G3ZYRA==} + /turbo@1.10.7: + resolution: {integrity: sha512-xm0MPM28TWx1e6TNC3wokfE5eaDqlfi0G24kmeHupDUZt5Wd0OzHFENEHMPqEaNKJ0I+AMObL6nbSZonZBV2HA==} hasBin: true + requiresBuild: true optionalDependencies: - turbo-darwin-64: 1.10.14 - turbo-darwin-arm64: 1.10.14 - turbo-linux-64: 1.10.14 - turbo-linux-arm64: 1.10.14 - turbo-windows-64: 1.10.14 - turbo-windows-arm64: 1.10.14 + turbo-darwin-64: 1.10.7 + turbo-darwin-arm64: 1.10.7 + turbo-linux-64: 1.10.7 + turbo-linux-arm64: 1.10.7 + turbo-windows-64: 1.10.7 + turbo-windows-arm64: 1.10.7 dev: true /tweetnacl@1.0.3: From 1b8003e9f99cee045329ab261a160bd90147b3be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?NB=F0=9F=98=88?= Date: Sun, 24 Sep 2023 12:01:30 +0200 Subject: [PATCH 4/6] fixes --- sdk/apps/modal-example/package.json | 6 ++--- sdk/packages/selector-sui/package.json | 6 ++--- sdk/packages/selector-sui/rollup.config.js | 4 --- sdk/packages/selector-sui/src/adapter.ts | 29 +++++++++------------- sdk/packages/selector-sui/src/detection.ts | 2 -- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/sdk/apps/modal-example/package.json b/sdk/apps/modal-example/package.json index 4fcafa56..5cdc7cc6 100644 --- a/sdk/apps/modal-example/package.json +++ b/sdk/apps/modal-example/package.json @@ -19,8 +19,8 @@ "@mysten/wallet-adapter-wallet-standard": "^0.8.0", "@nightlylabs/wallet-selector-solana": "0.2.2", "@nightlylabs/nightly-connect-solana": "0.0.26", - "@nightlylabs/nightly-connect-sui": "0.0.25", - "@nightlylabs/wallet-selector-sui": "0.2.2", + "@nightlylabs/nightly-connect-sui": "0.0.26", + "@nightlylabs/wallet-selector-sui": "0.2.3", "@nightlylabs/nightly-connect-polkadot": "0.0.6", "@nightlylabs/wallet-selector-polkadot": "0.1.2", "@polkadot/extension-inject": "^0.46.5", @@ -38,4 +38,4 @@ "engines": { "node": ">=16.8" } -} +} \ No newline at end of file diff --git a/sdk/packages/selector-sui/package.json b/sdk/packages/selector-sui/package.json index c4206397..1abb94de 100644 --- a/sdk/packages/selector-sui/package.json +++ b/sdk/packages/selector-sui/package.json @@ -1,6 +1,6 @@ { "name": "@nightlylabs/wallet-selector-sui", - "version": "0.2.2", + "version": "0.2.3", "description": "", "type": "module", "exports": { @@ -28,7 +28,7 @@ "@mysten/wallet-adapter-wallet-standard": "^0.8.0", "@mysten/wallet-standard": "^0.8.0", "@mysten/wallet-adapter-base": "^0.9.0", - "@nightlylabs/nightly-connect-sui": "0.0.25", + "@nightlylabs/nightly-connect-sui": "0.0.26", "@nightlylabs/wallet-selector-base": "0.2.2", "@wallet-standard/core": "^1.0.3", "bs58": "^4.0.1", @@ -45,4 +45,4 @@ "tslib": "^2.5.3", "typescript": "^5.1.3" } -} +} \ No newline at end of file diff --git a/sdk/packages/selector-sui/rollup.config.js b/sdk/packages/selector-sui/rollup.config.js index 7ea46124..2fc0a7d3 100644 --- a/sdk/packages/selector-sui/rollup.config.js +++ b/sdk/packages/selector-sui/rollup.config.js @@ -27,11 +27,7 @@ export default [ ], external: [ '@mysten/sui.js', - '@mysten/sui.js/verify', - '@mysten/sui.js/dist/cjs/signers/types', - '@mysten/sui.js/client', '@mysten/wallet-adapter-wallet-standard', - '@mysten/wallet-adapter-wallet-standard/dist/StandardWalletAdapter', '@mysten/wallet-standard', '@nightlylabs/nightly-connect-sui', '@nightlylabs/wallet-selector-base', diff --git a/sdk/packages/selector-sui/src/adapter.ts b/sdk/packages/selector-sui/src/adapter.ts index db2b2e28..aa75796f 100644 --- a/sdk/packages/selector-sui/src/adapter.ts +++ b/sdk/packages/selector-sui/src/adapter.ts @@ -1,15 +1,13 @@ /* eslint-disable @typescript-eslint/no-empty-function */ import { publicKeyFromRawBytes } from '@mysten/sui.js/verify' -import { SignedTransaction } from '@mysten/sui.js/dist/cjs/signers/types' -import { SuiTransactionBlockResponse } from '@mysten/sui.js/client' -// import { WalletAdapter } from '@mysten/wallet-adapter-base' import { StandardWalletAdapter } from '@mysten/wallet-adapter-wallet-standard' import type { - SignedPersonalMessage, - SuiSignAndExecuteTransactionBlockInput, - SuiSignPersonalMessageInput, - SuiSignTransactionBlockInput + SuiSignAndExecuteTransactionBlockMethod, + SuiSignPersonalMessageMethod, + SuiSignTransactionBlockMethod } from '@mysten/wallet-standard' + +import { type StandardWalletAdapterConfig } from '@mysten/wallet-adapter-wallet-standard/dist/StandardWalletAdapter' import { SUI_CHAINS } from '@mysten/wallet-standard' import { AppSui, SUI_NETWORK } from '@nightlylabs/nightly-connect-sui' import { @@ -35,7 +33,6 @@ import { import type { StandardEventsOnMethod, WalletAccount } from '@wallet-standard/core' import bs58 from 'bs58' import { suiWalletsFilter } from './detection' -import { StandardWalletAdapterConfig } from '@mysten/wallet-adapter-wallet-standard/dist/StandardWalletAdapter' export const convertBase58toBase64 = (base58: string) => { const buffer = bs58.decode(base58) @@ -428,9 +425,7 @@ export class NightlyConnectSuiAdapter { this.connecting = false } - signPersonalMessage = async ( - messageInput: SuiSignPersonalMessageInput - ): Promise => { + signPersonalMessage: SuiSignPersonalMessageMethod = async (messageInput) => { if (!this._app || !this._connectionType) { throw new Error('Wallet not ready') } @@ -451,15 +446,15 @@ export class NightlyConnectSuiAdapter { } } - signTransactionBlock = async ( - transactionInput: SuiSignTransactionBlockInput - ): Promise => { + // + signTransactionBlock: SuiSignTransactionBlockMethod = async (transactionInput) => { if (!this._app || !this._connectionType) { throw new Error('Wallet not ready') } switch (this._connectionType) { case ConnectionType.Nightly: { return await this._app.signTransactionBlock(transactionInput) + // return { bytes: res.transactionBlockBytes, signature: res.signature } } case ConnectionType.WalletStandard: { if (!this._innerStandardAdapter) { @@ -471,9 +466,9 @@ export class NightlyConnectSuiAdapter { } } - signAndExecuteTransactionBlock = async ( - transactionInput: SuiSignAndExecuteTransactionBlockInput - ): Promise => { + signAndExecuteTransactionBlock: SuiSignAndExecuteTransactionBlockMethod = async ( + transactionInput + ) => { if (!this._app || !this._connectionType) { throw new Error('Wallet not ready') } diff --git a/sdk/packages/selector-sui/src/detection.ts b/sdk/packages/selector-sui/src/detection.ts index aba8eb36..7d456076 100644 --- a/sdk/packages/selector-sui/src/detection.ts +++ b/sdk/packages/selector-sui/src/detection.ts @@ -7,7 +7,5 @@ export const suiWalletsFilter = (wallet: Wallet) => { 'sui:signAndExecuteTransactionBlock', 'sui:signTransactionBlock' ]) - console.log(wallet) - console.log(is) return is } From 9465d5725f94723d69cae0084cc72bffaf59414a Mon Sep 17 00:00:00 2001 From: Adrian Date: Sun, 24 Sep 2023 20:46:33 +0200 Subject: [PATCH 5/6] bump versions --- sdk/apps/modal-example/package.json | 4 +- sdk/apps/nextjs-example/package.json | 4 +- sdk/packages/selector-polkadot/package.json | 2 +- sdk/packages/selector-solana/package.json | 2 +- sdk/pnpm-lock.yaml | 238 +++----------------- 5 files changed, 32 insertions(+), 218 deletions(-) diff --git a/sdk/apps/modal-example/package.json b/sdk/apps/modal-example/package.json index 5cdc7cc6..475e6bd3 100644 --- a/sdk/apps/modal-example/package.json +++ b/sdk/apps/modal-example/package.json @@ -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.2", + "@nightlylabs/wallet-selector-solana": "0.2.3", "@nightlylabs/nightly-connect-solana": "0.0.26", "@nightlylabs/nightly-connect-sui": "0.0.26", "@nightlylabs/wallet-selector-sui": "0.2.3", "@nightlylabs/nightly-connect-polkadot": "0.0.6", - "@nightlylabs/wallet-selector-polkadot": "0.1.2", + "@nightlylabs/wallet-selector-polkadot": "0.1.3", "@polkadot/extension-inject": "^0.46.5", "@polkadot/api": "^10.9.1", "@solana/web3.js": "^1.77.2", diff --git a/sdk/apps/nextjs-example/package.json b/sdk/apps/nextjs-example/package.json index 73f49f28..ed6f7d87 100644 --- a/sdk/apps/nextjs-example/package.json +++ b/sdk/apps/nextjs-example/package.json @@ -9,8 +9,8 @@ "lint": "next lint" }, "dependencies": { - "@nightlylabs/wallet-selector-solana": "0.2.2", - "@nightlylabs/wallet-selector-sui": "0.2.2", + "@nightlylabs/wallet-selector-solana": "0.2.3", + "@nightlylabs/wallet-selector-sui": "0.2.3", "@mysten/wallet-adapter-wallet-standard": "0.8.0", "@mysten/wallet-adapter-base": "0.9.0", "@mysten/sui.js": "0.42.0", diff --git a/sdk/packages/selector-polkadot/package.json b/sdk/packages/selector-polkadot/package.json index bca283e9..5de2ac65 100644 --- a/sdk/packages/selector-polkadot/package.json +++ b/sdk/packages/selector-polkadot/package.json @@ -1,6 +1,6 @@ { "name": "@nightlylabs/wallet-selector-polkadot", - "version": "0.1.2", + "version": "0.1.3", "description": "", "type": "module", "exports": { diff --git a/sdk/packages/selector-solana/package.json b/sdk/packages/selector-solana/package.json index 71487986..bce3b93d 100644 --- a/sdk/packages/selector-solana/package.json +++ b/sdk/packages/selector-solana/package.json @@ -1,6 +1,6 @@ { "name": "@nightlylabs/wallet-selector-solana", - "version": "0.2.2", + "version": "0.2.3", "description": "", "type": "module", "exports": { diff --git a/sdk/pnpm-lock.yaml b/sdk/pnpm-lock.yaml index 37eb70fe..979c23c2 100644 --- a/sdk/pnpm-lock.yaml +++ b/sdk/pnpm-lock.yaml @@ -29,7 +29,7 @@ importers: version: 2.8.0 turbo: specifier: latest - version: 1.10.7 + version: 1.10.14 typescript: specifier: ^4.9.0 version: 4.9.4 @@ -138,10 +138,10 @@ importers: specifier: 0.0.26 version: link:../sui '@nightlylabs/wallet-selector-polkadot': - specifier: 0.1.2 + specifier: 0.1.3 version: link:../../packages/selector-polkadot '@nightlylabs/wallet-selector-solana': - specifier: 0.2.2 + specifier: 0.2.3 version: link:../../packages/selector-solana '@nightlylabs/wallet-selector-sui': specifier: 0.2.3 @@ -214,11 +214,11 @@ importers: specifier: 0.7.3 version: 0.7.3(react-dom@18.2.0)(react@18.2.0) '@nightlylabs/wallet-selector-solana': - specifier: 0.2.2 + specifier: 0.2.3 version: link:../../packages/selector-solana '@nightlylabs/wallet-selector-sui': - specifier: 0.2.2 - version: 0.2.2 + specifier: 0.2.3 + version: link:../../packages/selector-sui '@solana/web3.js': specifier: ^1.77.2 version: 1.77.2 @@ -4837,46 +4837,6 @@ packages: bs58: 5.0.0 dev: false - /@mysten/sui.js@0.37.1: - resolution: {integrity: sha512-nEOqnjUqb/VJcVk23LgZOX1FmBib/mBCwAWaJhtsCHLwv2jIAfCPY/fpB9lJ62QHrM8UFclpWxsLkqcUkKyPgA==} - engines: {node: '>=16'} - dependencies: - '@mysten/bcs': 0.7.3 - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@open-rpc/client-js': 1.8.1 - '@scure/bip32': 1.3.2 - '@scure/bip39': 1.2.1 - '@suchipi/femver': 1.0.0 - events: 3.3.0 - superstruct: 1.0.3 - tweetnacl: 1.0.3 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@mysten/sui.js@0.39.0: - resolution: {integrity: sha512-fJu6k7+Qb1z2h9i5Jai0sTWmaGP1UT6d/JIXhEwMZ6cz+13GT/8zRp8kUhP7Oq9Z2hxmwfy1ROptbsrv/x9V8A==} - engines: {node: '>=16'} - dependencies: - '@mysten/bcs': 0.7.3 - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@open-rpc/client-js': 1.8.1 - '@scure/bip32': 1.3.2 - '@scure/bip39': 1.2.1 - '@suchipi/femver': 1.0.0 - events: 3.3.0 - superstruct: 1.0.3 - tweetnacl: 1.0.3 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - /@mysten/sui.js@0.40.0: resolution: {integrity: sha512-PEGdMe+QgpIdDIpyO4/yb+CK4x3Hki+kYPbQ5n3DVsWyb2ztFwB+5oYdc7qG3QkniO1lnCrlSHqZ5mN+x3RzrQ==} engines: {node: '>=16'} @@ -4917,30 +4877,6 @@ packages: - utf-8-validate dev: false - /@mysten/wallet-adapter-base@0.7.12: - resolution: {integrity: sha512-5xDLaZ11+Sw65I9VSzmsHlue8jV0Kq/HiBJYmQes5TU2clwV0ClNBlw7CCipkMPi6IfhBSaaLXWZ9ftX0KG1TQ==} - deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. - dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-standard': 0.5.12 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@mysten/wallet-adapter-base@0.8.1: - resolution: {integrity: sha512-hS1jxxGwNA+pyX9KU95DN4yum63ZDgZP3KH+6wtJfh5Vr8Yxbq9+JYumOqvmAyK0sHzHjxJEYDojNgibggwgrw==} - deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. - dependencies: - '@mysten/sui.js': 0.39.0 - '@mysten/wallet-standard': 0.5.14 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - /@mysten/wallet-adapter-base@0.9.0: resolution: {integrity: sha512-Obcfd30AC0Tcyvqc9+h0vvjrRB6Td2PNWhxRlTq/hSxDY66M3XqTLgoO8wDBtz+91oga4obAYvM02m7xV7X0Zw==} deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. @@ -4953,20 +4889,6 @@ packages: - utf-8-validate dev: false - /@mysten/wallet-adapter-wallet-standard@0.7.14: - resolution: {integrity: sha512-v6RPjtRb1hQfeUvaTnrl8iDXK0EGF7PfXbVeAzxMqVqcI3CV08B1VSqLQUZ8ecDwliY+il4fi9vp82ETAv0QjA==} - deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. - dependencies: - '@mysten/sui.js': 0.39.0 - '@mysten/wallet-adapter-base': 0.8.1 - '@mysten/wallet-standard': 0.5.14 - mitt: 3.0.1 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - /@mysten/wallet-adapter-wallet-standard@0.8.0: resolution: {integrity: sha512-WPQSQTUvQCX2PPuVU8NHEzXg+mMCzIKqMG6llt0tLxc4enTtFHw9Do4i298NyZ00zWWzHdx9MXjBOl1OuybURg==} deprecated: Wallet adapters have been deprecated in favor of the Wallet Standard. Please upgrade to the latest Wallet Kit versions. @@ -5011,28 +4933,6 @@ packages: - utf-8-validate dev: false - /@mysten/wallet-standard@0.5.12: - resolution: {integrity: sha512-RDKEhBf8aNbCXgTGsDAA7uzpkll24O9M/C48wHFjeb9edIxhaDkiSeGty6flhg9G5ShAHP76dEbz5z6z3ODmCA==} - dependencies: - '@mysten/sui.js': 0.37.1 - '@wallet-standard/core': 1.0.3 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@mysten/wallet-standard@0.5.14: - resolution: {integrity: sha512-O4pBU5nO5zBMuhIpOiMkJinxUo68M1m4ca4AQNM5gYLMpuHipcHDNPpCINIyIsCsff61ilGDzPhZU4R8+zZ/2A==} - dependencies: - '@mysten/sui.js': 0.39.0 - '@wallet-standard/core': 1.0.3 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - /@mysten/wallet-standard@0.6.0: resolution: {integrity: sha512-xE/OijN9zIPoTjTWuxlYMHtp7kXPcAR8dDAbxOIH5h7EZCTk+G6p+SzDp8jV5magf50VcYP0cVjS4CQLx1wQuQ==} dependencies: @@ -5154,91 +5054,6 @@ packages: dev: false optional: true - /@nightlylabs/nightly-connect-base@0.0.25: - resolution: {integrity: sha512-E0NwUoBuyqzcnxSiLxEZAiujoUYhndwiprJ2bH615xkpPRRGiS/PGkfeoBtuZewV/6uhAcyQyW0+maCQqGKWog==} - dependencies: - cross-fetch: 3.1.6 - eventemitter3: 5.0.1 - isomorphic-localstorage: 1.0.2 - isomorphic-ws: 5.0.0(ws@8.13.0) - uuid: 9.0.0 - ws: 8.13.0(bufferutil@4.0.7)(utf-8-validate@5.0.10) - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@nightlylabs/nightly-connect-sui@0.0.25: - resolution: {integrity: sha512-lvUBiBwf+tlEmtm40kBwcZJI8ZB5J1EhpM7iyWg2SPb8M3D3SC/ZmbDQDnSb/LXlygZLyfpGsh//8I1PNNmfvA==} - dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-standard': 0.5.14 - '@nightlylabs/nightly-connect-base': 0.0.25 - '@noble/hashes': 1.3.2 - eventemitter3: 5.0.1 - uuid: 9.0.0 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - - /@nightlylabs/qr-code@2.0.4: - resolution: {integrity: sha512-GU8u8Cm1Q5YnoB/kikM4whFQhJ7ZWKaazBm4wiZK9Qi64Ht9tyRVzASBbZRpeOZVzxwi7Mml5sz0hUKPEFMpdA==} - dependencies: - qrcode-generator: 1.4.4 - dev: false - - /@nightlylabs/wallet-selector-base@0.2.2: - resolution: {integrity: sha512-Xui3qxtMSzJ/GQEo9G21x8zowxLIQQfRhNmzSlRlxkv5waRNm4eW4BmegfE2DRXCVM2WzgbdP8RYRS20EKXrmQ==} - dependencies: - '@nightlylabs/nightly-connect-base': 0.0.25 - '@nightlylabs/wallet-selector-modal': 0.1.2 - '@wallet-standard/core': 1.0.3 - isomorphic-localstorage: 1.0.2 - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - ts-node - - utf-8-validate - dev: false - - /@nightlylabs/wallet-selector-modal@0.1.2: - resolution: {integrity: sha512-vxy9S2dEf3NARW6LDq2ZKpWMlk5JJFIuwUfSxkuJlgUg2OVSlnDS7vdho3h4DmluRU5GM9vVhaXUGHAVp5sDQg==} - dependencies: - '@nightlylabs/qr-code': 2.0.4 - autoprefixer: 10.4.14(postcss@8.4.24) - lit: 2.7.2 - postcss: 8.4.24 - postcss-lit: 1.1.0(postcss@8.4.24) - tailwindcss: 3.3.2 - transitivePeerDependencies: - - supports-color - - ts-node - dev: false - - /@nightlylabs/wallet-selector-sui@0.2.2: - resolution: {integrity: sha512-DNHif5fdEkA9W5Emm2r+fR4fkib/yFanbzhAIfiFURh6X4DKj2k1LreHmMWllOeD9M3ZuJh2amW0E4uS5zFqZQ==} - dependencies: - '@mysten/sui.js': 0.37.1 - '@mysten/wallet-adapter-base': 0.7.12 - '@mysten/wallet-adapter-wallet-standard': 0.7.14 - '@mysten/wallet-standard': 0.5.14 - '@nightlylabs/nightly-connect-sui': 0.0.25 - '@nightlylabs/wallet-selector-base': 0.2.2 - '@wallet-standard/core': 1.0.3 - bs58: 4.0.1 - events: 3.3.0 - transitivePeerDependencies: - - bufferutil - - encoding - - supports-color - - ts-node - - utf-8-validate - dev: false - /@noble/curves@1.0.0: resolution: {integrity: sha512-2upgEu0iLiDVDZkNLeFV2+ht0BAVgQnEmCk6JsOch9Rp8xfkMCbvbAZlA2pBHQc73dbl+vFOXfqkf4uemdn0bw==} dependencies: @@ -16523,65 +16338,64 @@ packages: typescript: 5.1.6 dev: false - /turbo-darwin-64@1.10.7: - resolution: {integrity: sha512-N2MNuhwrl6g7vGuz4y3fFG2aR1oCs0UZ5HKl8KSTn/VC2y2YIuLGedQ3OVbo0TfEvygAlF3QGAAKKtOCmGPNKA==} + /turbo-darwin-64@1.10.14: + resolution: {integrity: sha512-I8RtFk1b9UILAExPdG/XRgGQz95nmXPE7OiGb6ytjtNIR5/UZBS/xVX/7HYpCdmfriKdVwBKhalCoV4oDvAGEg==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-darwin-arm64@1.10.7: - resolution: {integrity: sha512-WbJkvjU+6qkngp7K4EsswOriO3xrNQag7YEGRtfLoDdMTk4O4QTeU6sfg2dKfDsBpTidTvEDwgIYJhYVGzrz9Q==} + /turbo-darwin-arm64@1.10.14: + resolution: {integrity: sha512-KAdUWryJi/XX7OD0alOuOa0aJ5TLyd4DNIYkHPHYcM6/d7YAovYvxRNwmx9iv6Vx6IkzTnLeTiUB8zy69QkG9Q==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-linux-64@1.10.7: - resolution: {integrity: sha512-x1CF2CDP1pDz/J8/B2T0hnmmOQI2+y11JGIzNP0KtwxDM7rmeg3DDTtDM/9PwGqfPotN9iVGgMiMvBuMFbsLhg==} + /turbo-linux-64@1.10.14: + resolution: {integrity: sha512-BOBzoREC2u4Vgpap/WDxM6wETVqVMRcM8OZw4hWzqCj2bqbQ6L0wxs1LCLWVrghQf93JBQtIGAdFFLyCSBXjWQ==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-linux-arm64@1.10.7: - resolution: {integrity: sha512-JtnBmaBSYbs7peJPkXzXxsRGSGBmBEIb6/kC8RRmyvPAMyqF8wIex0pttsI+9plghREiGPtRWv/lfQEPRlXnNQ==} + /turbo-linux-arm64@1.10.14: + resolution: {integrity: sha512-D8T6XxoTdN5D4V5qE2VZG+/lbZX/89BkAEHzXcsSUTRjrwfMepT3d2z8aT6hxv4yu8EDdooZq/2Bn/vjMI32xw==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-windows-64@1.10.7: - resolution: {integrity: sha512-7A/4CByoHdolWS8dg3DPm99owfu1aY/W0V0+KxFd0o2JQMTQtoBgIMSvZesXaWM57z3OLsietFivDLQPuzE75w==} + /turbo-windows-64@1.10.14: + resolution: {integrity: sha512-zKNS3c1w4i6432N0cexZ20r/aIhV62g69opUn82FLVs/zk3Ie0GVkSB6h0rqIvMalCp7enIR87LkPSDGz9K4UA==} cpu: [x64] os: [win32] requiresBuild: true dev: true optional: true - /turbo-windows-arm64@1.10.7: - resolution: {integrity: sha512-D36K/3b6+hqm9IBAymnuVgyePktwQ+F0lSXr2B9JfAdFPBktSqGmp50JNC7pahxhnuCLj0Vdpe9RqfnJw5zATA==} + /turbo-windows-arm64@1.10.14: + resolution: {integrity: sha512-rkBwrTPTxNSOUF7of8eVvvM+BkfkhA2OvpHM94if8tVsU+khrjglilp8MTVPHlyS9byfemPAmFN90oRIPB05BA==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /turbo@1.10.7: - resolution: {integrity: sha512-xm0MPM28TWx1e6TNC3wokfE5eaDqlfi0G24kmeHupDUZt5Wd0OzHFENEHMPqEaNKJ0I+AMObL6nbSZonZBV2HA==} + /turbo@1.10.14: + resolution: {integrity: sha512-hr9wDNYcsee+vLkCDIm8qTtwhJ6+UAMJc3nIY6+PNgUTtXcQgHxCq8BGoL7gbABvNWv76CNbK5qL4Lp9G3ZYRA==} hasBin: true - requiresBuild: true optionalDependencies: - turbo-darwin-64: 1.10.7 - turbo-darwin-arm64: 1.10.7 - turbo-linux-64: 1.10.7 - turbo-linux-arm64: 1.10.7 - turbo-windows-64: 1.10.7 - turbo-windows-arm64: 1.10.7 + turbo-darwin-64: 1.10.14 + turbo-darwin-arm64: 1.10.14 + turbo-linux-64: 1.10.14 + turbo-linux-arm64: 1.10.14 + turbo-windows-64: 1.10.14 + turbo-windows-arm64: 1.10.14 dev: true /tweetnacl@1.0.3: From fe6c7e9fcaf1937de18882e749220ac8cbf0041f Mon Sep 17 00:00:00 2001 From: Adrian Date: Sun, 24 Sep 2023 21:28:47 +0200 Subject: [PATCH 6/6] eager connect try catch --- sdk/packages/selector-polkadot/src/adapter.ts | 82 ++++++++++--------- sdk/packages/selector-solana/src/adapter.ts | 79 +++++++++--------- sdk/packages/selector-sui/src/adapter.ts | 77 +++++++++-------- 3 files changed, 120 insertions(+), 118 deletions(-) diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index e99eb87b..316beeca 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-function */ import { AppPolkadot, AppPolkadotInitialize } from '@nightlylabs/nightly-connect-polkadot' import { - MetadataWallet, + type MetadataWallet, NightlyConnectSelectorModal, XMLOptions, clearRecentStandardWalletForNetwork, @@ -114,6 +114,42 @@ export class NightlyConnectAdapter implements Injected { this._modal.walletsList = list } } + + public static initApp = async ( + appInitData: AppSelectorInitialize + ): Promise<[AppPolkadot, MetadataWallet[]]> => { + try { + return await Promise.all([ + AppPolkadot.build(appInitData), + AppPolkadot.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') + .then((list) => + list.map((wallet) => ({ + name: wallet.name, + icon: wallet.image.default, + deeplink: wallet.mobile, + link: wallet.homepage + })) + ) + .catch(() => [] as MetadataWallet[]) + ]) + } catch { + clearSessionIdForNetwork(appInitData.network) + return await Promise.all([ + AppPolkadot.build(appInitData), + AppPolkadot.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') + .then((list) => + list.map((wallet) => ({ + name: wallet.name, + icon: wallet.image.default, + deeplink: wallet.mobile, + link: wallet.homepage + })) + ) + .catch(() => [] as MetadataWallet[]) + ]) + } + } + public static build = async ( appInitData: AppSelectorInitialize, useEagerConnect?: boolean, @@ -144,19 +180,7 @@ export class NightlyConnectAdapter implements Injected { uiOverrides?.qrConfigOverride ) - const [app, metadataWallets] = await Promise.all([ - AppPolkadot.build(appInitData), - AppPolkadot.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]) + const [app, metadataWallets] = await NightlyConnectAdapter.initApp(appInitData) adapter._app = app adapter._metadataWallets = metadataWallets @@ -201,19 +225,7 @@ export class NightlyConnectAdapter implements Injected { adapter._loading = true - Promise.all([ - AppPolkadot.build(appInitData), - AppPolkadot.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]).then(([app, metadataWallets]) => { + NightlyConnectAdapter.initApp(appInitData).then(([app, metadataWallets]) => { adapter._app = app adapter._metadataWallets = metadataWallets adapter.walletsList = getPolkadotWalletsList( @@ -429,19 +441,9 @@ export class NightlyConnectAdapter implements Injected { if (!this._app) { try { - const [app, metadataWallets] = await Promise.all([ - AppPolkadot.build(this._appInitData), - AppPolkadot.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]) + const [app, metadataWallets] = await NightlyConnectAdapter.initApp( + this._appInitData + ) this._app = app this._metadataWallets = metadataWallets diff --git a/sdk/packages/selector-solana/src/adapter.ts b/sdk/packages/selector-solana/src/adapter.ts index 833ebc1f..18bb5799 100644 --- a/sdk/packages/selector-solana/src/adapter.ts +++ b/sdk/packages/selector-solana/src/adapter.ts @@ -109,6 +109,41 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { } } + public static initApp = async ( + appInitData: AppInitData + ): Promise<[AppSolana, MetadataWallet[]]> => { + try { + return await Promise.all([ + AppSolana.build(appInitData), + AppSolana.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') + .then((list) => + list.map((wallet) => ({ + name: wallet.name, + icon: wallet.image.default, + deeplink: wallet.mobile, + link: wallet.homepage + })) + ) + .catch(() => [] as MetadataWallet[]) + ]) + } catch { + clearSessionIdForNetwork(SOLANA_NETWORK) + return await Promise.all([ + AppSolana.build(appInitData), + AppSolana.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') + .then((list) => + list.map((wallet) => ({ + name: wallet.name, + icon: wallet.image.default, + deeplink: wallet.mobile, + link: wallet.homepage + })) + ) + .catch(() => [] as MetadataWallet[]) + ]) + } + } + public static build = async ( appInitData: AppInitData, eagerConnectForStandardWallets?: boolean, @@ -144,19 +179,7 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { uiOverrides?.qrConfigOverride ) - const [app, metadataWallets] = await Promise.all([ - AppSolana.build(appInitData), - AppSolana.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]) + const [app, metadataWallets] = await NightlyConnectAdapter.initApp(appInitData) adapter._app = app adapter._metadataWallets = metadataWallets @@ -207,19 +230,7 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { adapter._loading = true - Promise.all([ - AppSolana.build(appInitData), - AppSolana.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]).then(([app, metadataWallets]) => { + NightlyConnectAdapter.initApp(appInitData).then(([app, metadataWallets]) => { adapter._app = app adapter._metadataWallets = metadataWallets @@ -429,19 +440,9 @@ export class NightlyConnectAdapter extends BaseMessageSignerWalletAdapter { if (!this._app) { try { - const [app, metadataWallets] = await Promise.all([ - AppSolana.build(this._appInitData), - AppSolana.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]) + const [app, metadataWallets] = await NightlyConnectAdapter.initApp( + this._appInitData + ) this._app = app this._metadataWallets = metadataWallets diff --git a/sdk/packages/selector-sui/src/adapter.ts b/sdk/packages/selector-sui/src/adapter.ts index aa75796f..a0123c78 100644 --- a/sdk/packages/selector-sui/src/adapter.ts +++ b/sdk/packages/selector-sui/src/adapter.ts @@ -93,6 +93,39 @@ export class NightlyConnectSuiAdapter { return this._innerStandardAdapter.on(event, listener) } + public static initApp = async (appInitData: AppInitData): Promise<[AppSui, MetadataWallet[]]> => { + try { + return await Promise.all([ + AppSui.build(appInitData), + AppSui.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') + .then((list) => + list.map((wallet) => ({ + name: wallet.name, + icon: wallet.image.default, + deeplink: wallet.mobile, + link: wallet.homepage + })) + ) + .catch(() => [] as MetadataWallet[]) + ]) + } catch { + clearSessionIdForNetwork(SUI_NETWORK) + return await Promise.all([ + AppSui.build(appInitData), + AppSui.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') + .then((list) => + list.map((wallet) => ({ + name: wallet.name, + icon: wallet.image.default, + deeplink: wallet.mobile, + link: wallet.homepage + })) + ) + .catch(() => [] as MetadataWallet[]) + ]) + } + } + public static build = async ( appInitData: AppInitData, eagerConnectForStandardWallets?: boolean, @@ -123,19 +156,7 @@ export class NightlyConnectSuiAdapter { uiOverrides?.qrConfigOverride ) - const [app, metadataWallets] = await Promise.all([ - AppSui.build(appInitData), - AppSui.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]) + const [app, metadataWallets] = await NightlyConnectSuiAdapter.initApp(appInitData) adapter._app = app adapter._metadataWallets = metadataWallets @@ -180,19 +201,7 @@ export class NightlyConnectSuiAdapter { adapter._loading = true - Promise.all([ - AppSui.build(appInitData), - AppSui.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]).then(([app, metadataWallets]) => { + NightlyConnectSuiAdapter.initApp(appInitData).then(([app, metadataWallets]) => { adapter._app = app adapter._metadataWallets = metadataWallets adapter.walletsList = getWalletsList( @@ -253,19 +262,9 @@ export class NightlyConnectSuiAdapter { if (!this._app) { try { - const [app, metadataWallets] = await Promise.all([ - AppSui.build(this._appInitData), - AppSui.getWalletsMetadata('https://nc2.nightly.app/get_wallets_metadata') - .then((list) => - list.map((wallet) => ({ - name: wallet.name, - icon: wallet.image.default, - deeplink: wallet.mobile, - link: wallet.homepage - })) - ) - .catch(() => [] as MetadataWallet[]) - ]) + const [app, metadataWallets] = await NightlyConnectSuiAdapter.initApp( + this._appInitData + ) this._app = app this._metadataWallets = metadataWallets