diff --git a/sdk/apps/base/src/app.test.ts b/sdk/apps/base/src/app.test.ts index 6aa748d6..eda9bf01 100644 --- a/sdk/apps/base/src/app.test.ts +++ b/sdk/apps/base/src/app.test.ts @@ -1,6 +1,7 @@ import { assert, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest' import { BaseApp } from './app' -import { smartDelay, testAppBaseInitialize, testClientBaseInitialize } from './utils' +import { testAppBaseInitialize, testClientBaseInitialize } from './testUtils' +import { smartDelay } from '../../../commonTestUtils' import { BaseClient, Connect } from './client' // Edit an assertion and save to see HMR in action describe('Base App tests', () => { diff --git a/sdk/apps/base/src/client.test.ts b/sdk/apps/base/src/client.test.ts index 468da58c..51cee8ab 100644 --- a/sdk/apps/base/src/client.test.ts +++ b/sdk/apps/base/src/client.test.ts @@ -1,6 +1,7 @@ import { assert, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest' import { BaseApp } from './app' -import { sleep, smartDelay, testAppBaseInitialize, testClientBaseInitialize } from './utils' +import { testAppBaseInitialize, testClientBaseInitialize } from './testUtils' +import { smartDelay } from '../../../commonTestUtils' import { BaseClient, Connect } from './client' import { ContentType, MessageToSign, TransactionToSign } from './content' import { SignedMessage, SignedTransaction } from './responseContent' diff --git a/sdk/apps/base/src/http-client.test.ts b/sdk/apps/base/src/http-client.test.ts index 44ff822e..0dfb4b09 100644 --- a/sdk/apps/base/src/http-client.test.ts +++ b/sdk/apps/base/src/http-client.test.ts @@ -1,6 +1,8 @@ import { assert, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest' import { BaseApp } from './app' -import { RELAY_ENDPOINT, getRandomId, smartDelay, testAppBaseInitialize } from './utils' +import { getRandomId } from './utils' +import { testAppBaseInitialize } from './testUtils' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' import { Connect } from './client' import { MessageToSign, TransactionToSign } from './content' import { SignedMessage, SignedTransaction } from './responseContent' @@ -20,7 +22,7 @@ describe('Http Base Client tests', () => { expect(baseApp).toBeDefined() assert(baseApp.sessionId !== '') - client = new HttpBaseClient({ url: RELAY_ENDPOINT, clientId: clientId }) + client = new HttpBaseClient({ url: TEST_RELAY_ENDPOINT, clientId: clientId }) }) test('#getInfo()', async () => { const info = await client.getInfo(baseApp.sessionId) diff --git a/sdk/apps/base/src/index.ts b/sdk/apps/base/src/index.ts index efe5e158..14335dbe 100644 --- a/sdk/apps/base/src/index.ts +++ b/sdk/apps/base/src/index.ts @@ -4,5 +4,10 @@ export * from './content' export * from './deeplinks' export * from './http-client' export * from './responseContent' -export { getRandomId, getWalletsMetadata, sleep, RELAY_ENDPOINT, smartDelay, getSessionIdLocalStorageKey } from './utils' -export * from './initializeTypes' \ No newline at end of file +export { + getRandomId, + getWalletsMetadata, + RELAY_ENDPOINT, + getSessionIdLocalStorageKey +} from './utils' +export * from './initializeTypes' diff --git a/sdk/apps/base/src/multiple-app.test.ts b/sdk/apps/base/src/multiple-app.test.ts index 5c895661..2230218d 100644 --- a/sdk/apps/base/src/multiple-app.test.ts +++ b/sdk/apps/base/src/multiple-app.test.ts @@ -1,6 +1,7 @@ import { describe, expect, test, vi } from 'vitest' import { BaseApp } from './app' -import { smartDelay, testAppBaseInitialize, testClientBaseInitialize } from './utils' +import { testAppBaseInitialize, testClientBaseInitialize } from './testUtils' +import { smartDelay } from '../../../commonTestUtils' import { BaseClient, Connect } from './client' import { MessageToSign } from './content' import { SignedMessage } from './responseContent' diff --git a/sdk/apps/base/src/persist-app.test.ts b/sdk/apps/base/src/persist-app.test.ts index 3812c407..21e3220a 100644 --- a/sdk/apps/base/src/persist-app.test.ts +++ b/sdk/apps/base/src/persist-app.test.ts @@ -1,7 +1,8 @@ import { assert, describe, expect, test, vi } from 'vitest' import { BaseApp } from './app' import { BaseClient, Connect } from './client' -import { smartDelay, testAppBaseInitialize, testClientBaseInitialize } from './utils' +import { testAppBaseInitialize, testClientBaseInitialize } from './testUtils' +import { smartDelay } from '../../../commonTestUtils' // Edit an assertion and save to see HMR in action describe('Base App tests', () => { test('persistent session', async () => { diff --git a/sdk/apps/base/src/testUtils.ts b/sdk/apps/base/src/testUtils.ts new file mode 100644 index 00000000..eae211fc --- /dev/null +++ b/sdk/apps/base/src/testUtils.ts @@ -0,0 +1,21 @@ +import { TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' +import { AppBaseInitialize, ClientBaseInitialize } from './initializeTypes' + +export const testAppBaseInitialize: AppBaseInitialize = { + appMetadata: { + additionalInfo: 'test-additional-info', + description: 'test-app-description', + icon: 'test-app-icon', + name: 'test-app-name' + }, + network: 'test-network', + persistent: false, + persistentSessionId: undefined, + timeout: undefined, + url: TEST_RELAY_ENDPOINT +} + +export const testClientBaseInitialize: ClientBaseInitialize = { + timeout: undefined, + url: TEST_RELAY_ENDPOINT +} diff --git a/sdk/apps/base/src/utils.ts b/sdk/apps/base/src/utils.ts index 0de0608a..59b457e9 100644 --- a/sdk/apps/base/src/utils.ts +++ b/sdk/apps/base/src/utils.ts @@ -2,44 +2,11 @@ import { v4 as uuidv4 } from 'uuid' import { getStorage, ILocalStorage } from 'isomorphic-localstorage' import { WalletMetadata } from '../../../bindings/WalletMetadata' import { fetch } from 'cross-fetch' -import { AppBaseInitialize, ClientBaseInitialize } from './initializeTypes' export const getRandomId = () => uuidv4() -export function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)) -} -export const RELAY_ENDPOINT = process.env.PRODUCTION - ? 'https://nc2.nightly.app' - : 'http://127.0.0.1:6969' -export const testAppBaseInitialize: AppBaseInitialize = { - appMetadata: { - additionalInfo: 'test-additional-info', - description: 'test-app-description', - icon: 'test-app-icon', - name: 'test-app-name' - }, - network: 'test-network', - persistent: false, - persistentSessionId: undefined, - timeout: undefined, - url: RELAY_ENDPOINT -} -export const testClientBaseInitialize: ClientBaseInitialize = { - timeout: undefined, - url: RELAY_ENDPOINT -} -export const smartDelay = async (ms?: number) => { - if (process.env.PRODUCTION) { - await sleep(ms || 100) - } else { - if (process.env.IS_CI) { - await sleep(ms || 100) - } else { - await sleep(ms || 5) - } - } -} +export const RELAY_ENDPOINT = 'https://nc2.nightly.app' + export const getWalletsMetadata = async ( url?: string, network?: string diff --git a/sdk/apps/polkadot/src/e2e.test.ts b/sdk/apps/polkadot/src/e2e.test.ts index e80984fb..c4fb72e9 100644 --- a/sdk/apps/polkadot/src/e2e.test.ts +++ b/sdk/apps/polkadot/src/e2e.test.ts @@ -1,4 +1,4 @@ -import { ContentType, RELAY_ENDPOINT, smartDelay } from '@nightlylabs/nightly-connect-base' +import { ContentType } from '@nightlylabs/nightly-connect-base' import { ApiPromise, WsProvider } from '@polkadot/api' import { Keyring } from '@polkadot/keyring' import { SignerPayloadRaw } from '@polkadot/types/types' @@ -7,8 +7,9 @@ import { cryptoWaitReady, decodeAddress, signatureVerify } from '@polkadot/util- import { assert, beforeAll, beforeEach, describe, expect, test } from 'vitest' import { AppPolkadot } from './app' import { ClientPolkadot, Connect } from './client' -import { TEST_APP_INITIALIZE } from './utils' +import { TEST_APP_INITIALIZE } from './testUtils' import { SignTransactionsPolkadotRequest } from './requestTypes' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' // Edit an assertion and save to see HMR in action const alice_keypair = new Keyring() @@ -26,7 +27,7 @@ describe('Base Client tests', () => { app = await AppPolkadot.build(TEST_APP_INITIALIZE) expect(app).toBeDefined() assert(app.sessionId !== '') - client = await ClientPolkadot.create({ url: RELAY_ENDPOINT }, TEST_APP_INITIALIZE.network) + client = await ClientPolkadot.create({ url: TEST_RELAY_ENDPOINT }, TEST_APP_INITIALIZE.network) provider = new WsProvider('wss://ws.test.azero.dev/') polkadotApi = await ApiPromise.create({ provider diff --git a/sdk/apps/polkadot/src/http-e2e.test.ts b/sdk/apps/polkadot/src/http-e2e.test.ts index 6e9f6450..b78c565c 100644 --- a/sdk/apps/polkadot/src/http-e2e.test.ts +++ b/sdk/apps/polkadot/src/http-e2e.test.ts @@ -1,12 +1,7 @@ -import { - ContentType, - RELAY_ENDPOINT, - getRandomId, - smartDelay -} from '@nightlylabs/nightly-connect-base' +import { ContentType, getRandomId } from '@nightlylabs/nightly-connect-base' import { assert, beforeAll, beforeEach, describe, expect, test } from 'vitest' import { AppPolkadot } from './app' -import { TEST_APP_INITIALIZE } from './utils' +import { TEST_APP_INITIALIZE } from './testUtils' import { ApiPromise, WsProvider } from '@polkadot/api' import Keyring from '@polkadot/keyring' @@ -14,6 +9,7 @@ import { SignerPayloadRaw } from '@polkadot/types/types' import { u8aToHex } from '@polkadot/util' import { decodeAddress, signatureVerify } from '@polkadot/util-crypto' import { HttpClientPolkadot, HttpConnect } from './http-client' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' // Edit an assertion and save to see HMR in action const alice_keypair = new Keyring() @@ -30,7 +26,7 @@ describe('Base Client tests', () => { app = await AppPolkadot.build(TEST_APP_INITIALIZE) expect(app).toBeDefined() assert(app.sessionId !== '') - client = new HttpClientPolkadot({ url: RELAY_ENDPOINT, clientId }) + client = new HttpClientPolkadot({ url: TEST_RELAY_ENDPOINT, clientId }) provider = new WsProvider('wss://ws.test.azero.dev/') polkadotApi = await ApiPromise.create({ provider diff --git a/sdk/apps/polkadot/src/testUtils.ts b/sdk/apps/polkadot/src/testUtils.ts new file mode 100644 index 00000000..fbc277b3 --- /dev/null +++ b/sdk/apps/polkadot/src/testUtils.ts @@ -0,0 +1,16 @@ +import { AppPolkadotInitialize } from './app' +import { TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' + +export const TEST_APP_INITIALIZE: AppPolkadotInitialize = { + appMetadata: { + additionalInfo: 'test-polkadot-additional-info', + description: 'test-polkadot-app-description', + icon: 'test-polkadot-app-icon', + name: 'test-polkadot-app-name' + }, + network: 'POLKADOT', + persistent: false, + persistentSessionId: undefined, + timeout: undefined, + url: TEST_RELAY_ENDPOINT +} diff --git a/sdk/apps/polkadot/src/utils.ts b/sdk/apps/polkadot/src/utils.ts index abc6a74d..b4dc2b70 100644 --- a/sdk/apps/polkadot/src/utils.ts +++ b/sdk/apps/polkadot/src/utils.ts @@ -1,5 +1,4 @@ -import { ContentType, RELAY_ENDPOINT, RequestContent } from '@nightlylabs/nightly-connect-base' -import { AppPolkadotInitialize } from './app' +import { ContentType, RequestContent } from '@nightlylabs/nightly-connect-base' import { SignerPayloadRaw, SignerPayloadJSON } from '@polkadot/types/types' import { SignTransactionsPolkadotRequest, @@ -8,23 +7,6 @@ import { PolkadotRequest } from './requestTypes' -export const TEST_APP_INITIALIZE: AppPolkadotInitialize = { - appMetadata: { - additionalInfo: 'test-polkadot-additional-info', - description: 'test-polkadot-app-description', - icon: 'test-polkadot-app-icon', - name: 'test-polkadot-app-name' - }, - network: 'POLKADOT', - persistent: false, - persistentSessionId: undefined, - timeout: undefined, - url: RELAY_ENDPOINT -} -export const sleep = (ms: number) => { - return new Promise((resolve) => setTimeout(resolve, ms)) -} - export const parseRequest = (request: RequestContent, sessionId: string): PolkadotRequest => { switch (request.content.type) { case ContentType.SignTransactions: { diff --git a/sdk/apps/solana/src/e2e.test.ts b/sdk/apps/solana/src/e2e.test.ts index 4655d65c..1e4b0686 100644 --- a/sdk/apps/solana/src/e2e.test.ts +++ b/sdk/apps/solana/src/e2e.test.ts @@ -1,12 +1,14 @@ import { Keypair, LAMPORTS_PER_SOL, SystemProgram, Transaction } from '@solana/web3.js' -import { Connect, ContentType, RELAY_ENDPOINT, smartDelay } from '@nightlylabs/nightly-connect-base' +import { Connect, ContentType } from '@nightlylabs/nightly-connect-base' import { sha256 } from 'js-sha256' import nacl from 'tweetnacl' import { assert, beforeAll, beforeEach, describe, expect, test } from 'vitest' import { AppSolana } from './app' import { ClientSolana } from './client' -import { SOLANA_NETWORK, TEST_APP_INITIALIZE } from './utils' +import { SOLANA_NETWORK } from './utils' +import { TEST_APP_INITIALIZE } from './testUtils' import { SignTransactionsSolanaRequest } from './requestTypes' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' // Edit an assertion and save to see HMR in action const alice_keypair = Keypair.generate() @@ -17,7 +19,7 @@ describe('Base Client tests', () => { app = await AppSolana.build(TEST_APP_INITIALIZE) expect(app).toBeDefined() assert(app.sessionId !== '') - client = await ClientSolana.create({ url: RELAY_ENDPOINT }) + client = await ClientSolana.create({ url: TEST_RELAY_ENDPOINT }) }) beforeEach(async () => { await smartDelay() diff --git a/sdk/apps/solana/src/http-e2e.test.ts b/sdk/apps/solana/src/http-e2e.test.ts index d4b3d40b..3df26799 100644 --- a/sdk/apps/solana/src/http-e2e.test.ts +++ b/sdk/apps/solana/src/http-e2e.test.ts @@ -1,15 +1,11 @@ import { assert, beforeAll, beforeEach, describe, expect, test } from 'vitest' import { AppSolana } from './app' -import { SOLANA_NETWORK, TEST_APP_INITIALIZE } from './utils' -import { - Connect, - getRandomId, - RELAY_ENDPOINT, - smartDelay, - ContentType -} from '@nightlylabs/nightly-connect-base' +import { SOLANA_NETWORK } from './utils' +import { TEST_APP_INITIALIZE } from './testUtils' +import { Connect, getRandomId, ContentType } from '@nightlylabs/nightly-connect-base' import { Keypair, LAMPORTS_PER_SOL, SystemProgram, Transaction } from '@solana/web3.js' import { HttpClientSolana } from './http-client' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' // Edit an assertion and save to see HMR in action const alice_keypair = Keypair.generate() @@ -21,7 +17,7 @@ describe('Base Client tests', () => { app = await AppSolana.build(TEST_APP_INITIALIZE) expect(app).toBeDefined() assert(app.sessionId !== '') - client = new HttpClientSolana({ url: RELAY_ENDPOINT, clientId }) + client = new HttpClientSolana({ url: TEST_RELAY_ENDPOINT, clientId }) }) beforeEach(async () => { await smartDelay() diff --git a/sdk/apps/solana/src/testUtils.ts b/sdk/apps/solana/src/testUtils.ts new file mode 100644 index 00000000..ecf5a5d2 --- /dev/null +++ b/sdk/apps/solana/src/testUtils.ts @@ -0,0 +1,18 @@ +import { AppSolanaInitialize } from './utils' +import { TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' + +export const TEST_APP_INITIALIZE: AppSolanaInitialize = { + appMetadata: { + additionalInfo: 'test-solana-additional-info', + description: 'test-solana-app-description', + icon: 'test-solana-app-icon', + name: 'test-solana-app-name' + }, + persistent: false, + persistentSessionId: undefined, + timeout: undefined, + url: TEST_RELAY_ENDPOINT +} +export function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)) +} diff --git a/sdk/apps/solana/src/utils.ts b/sdk/apps/solana/src/utils.ts index 25ba76f8..8b428a25 100644 --- a/sdk/apps/solana/src/utils.ts +++ b/sdk/apps/solana/src/utils.ts @@ -1,9 +1,4 @@ -import { - AppBaseInitialize, - ContentType, - RELAY_ENDPOINT, - RequestContent -} from '@nightlylabs/nightly-connect-base' +import { AppBaseInitialize, ContentType, RequestContent } from '@nightlylabs/nightly-connect-base' import { CustomSolanaRequest, SignMessagesSolanaRequest, @@ -16,22 +11,6 @@ export type AppSolanaInitialize = Omit export const SOLANA_NETWORK = 'Solana' -export const TEST_APP_INITIALIZE: AppSolanaInitialize = { - appMetadata: { - additionalInfo: 'test-solana-additional-info', - description: 'test-solana-app-description', - icon: 'test-solana-app-icon', - name: 'test-solana-app-name' - }, - persistent: false, - persistentSessionId: undefined, - timeout: undefined, - url: RELAY_ENDPOINT -} -export function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)) -} - export const parseRequest = (request: RequestContent, sessionId: string): SolanaRequest => { switch (request.content.type) { case ContentType.SignTransactions: { diff --git a/sdk/apps/sui/src/e2e.test.ts b/sdk/apps/sui/src/e2e.test.ts index 6bbcc8eb..3270cb20 100644 --- a/sdk/apps/sui/src/e2e.test.ts +++ b/sdk/apps/sui/src/e2e.test.ts @@ -1,23 +1,19 @@ -import { Connect, ContentType, RELAY_ENDPOINT, smartDelay } from '@nightlylabs/nightly-connect-base' +import { Connect, ContentType } from '@nightlylabs/nightly-connect-base' import { assert, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest' import { AppSui } from './app' import { ClientSui } from './client' -import { signTransactionBlock, SUI_NETWORK, TEST_APP_INITIALIZE } from './utils' +import { signTransactionBlock, SUI_NETWORK } from './utils' +import { TEST_APP_INITIALIZE } from './testUtils' 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, verifyTransactionBlock } from '@mysten/sui.js/verify' -import { - IntentScope, - messageWithIntent, - parseSerializedSignature, - toSerializedSignature -} from '@mysten/sui.js/cryptography' -import { blake2b } from '@noble/hashes/blake2b' +import { parseSerializedSignature, toSerializedSignature } from '@mysten/sui.js/cryptography' import { fetch } from 'cross-fetch' import { WalletAccount } from '@mysten/wallet-standard' import { hexToBytes } from '@noble/hashes/utils' import { SignTransactionsSuiRequest } from './requestTypes' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' global.fetch = fetch @@ -42,7 +38,7 @@ describe('SUI client tests', () => { app = await AppSui.build(TEST_APP_INITIALIZE) expect(app).toBeDefined() assert(app.sessionId !== '') - client = await ClientSui.create({ url: RELAY_ENDPOINT }) + client = await ClientSui.create({ url: TEST_RELAY_ENDPOINT }) }) beforeEach(async () => { await smartDelay() diff --git a/sdk/apps/sui/src/http-client.test.ts b/sdk/apps/sui/src/http-client.test.ts index 19f49f5f..5940391a 100644 --- a/sdk/apps/sui/src/http-client.test.ts +++ b/sdk/apps/sui/src/http-client.test.ts @@ -1,20 +1,16 @@ import { assert, beforeAll, beforeEach, describe, expect, test } from 'vitest' import { AppSui } from './app' -import { SUI_NETWORK, TEST_APP_INITIALIZE, signTransactionBlock } from './utils' -import { - Connect, - getRandomId, - ContentType, - RELAY_ENDPOINT, - smartDelay -} from '@nightlylabs/nightly-connect-base' +import { signTransactionBlock, SUI_NETWORK } from './utils' +import { TEST_APP_INITIALIZE } from './testUtils' +import { Connect, getRandomId, ContentType } from '@nightlylabs/nightly-connect-base' import { HttpClientSui } from './http-client' 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, verifyTransactionBlock } from '@mysten/sui.js/verify' +import { verifyTransactionBlock } from '@mysten/sui.js/verify' import { hexToBytes } from '@noble/hashes/utils' import { WalletAccount } from '@mysten/wallet-standard' +import { smartDelay, TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' // Edit an assertion and save to see HMR in action const ALICE_PRIVE_KEY = '4aa55c99d633c646b8dc423eed56e0fc39bdbca6ac6d8c53cc6e4decda27d970' @@ -37,7 +33,7 @@ describe('SUI http-client tests', () => { app = await AppSui.build(TEST_APP_INITIALIZE) expect(app).toBeDefined() assert(app.sessionId !== '') - client = new HttpClientSui({ url: RELAY_ENDPOINT, clientId }) + client = new HttpClientSui({ url: TEST_RELAY_ENDPOINT, clientId }) }) beforeEach(async () => { await smartDelay() diff --git a/sdk/apps/sui/src/testUtils.ts b/sdk/apps/sui/src/testUtils.ts new file mode 100644 index 00000000..3f18252c --- /dev/null +++ b/sdk/apps/sui/src/testUtils.ts @@ -0,0 +1,15 @@ +import { AppSuiInitialize } from './utils' +import { TEST_RELAY_ENDPOINT } from '../../../commonTestUtils' + +export const TEST_APP_INITIALIZE: AppSuiInitialize = { + appMetadata: { + additionalInfo: 'test-sui-additional-info', + description: 'test-sui-app-description', + icon: 'test-sui-app-icon', + name: 'test-sui-app-name' + }, + persistent: false, + persistentSessionId: undefined, + timeout: undefined, + url: TEST_RELAY_ENDPOINT +} diff --git a/sdk/apps/sui/src/utils.ts b/sdk/apps/sui/src/utils.ts index bd728441..a9bb32b8 100644 --- a/sdk/apps/sui/src/utils.ts +++ b/sdk/apps/sui/src/utils.ts @@ -2,12 +2,7 @@ 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 { - AppBaseInitialize, - ContentType, - RELAY_ENDPOINT, - RequestContent -} from '@nightlylabs/nightly-connect-base' +import { AppBaseInitialize, ContentType, RequestContent } from '@nightlylabs/nightly-connect-base' import { CustomSuiRequest, SignMessagesSuiRequest, @@ -20,22 +15,6 @@ export type AppSuiInitialize = Omit export const SUI_NETWORK = 'Sui' -export const TEST_APP_INITIALIZE: AppSuiInitialize = { - appMetadata: { - additionalInfo: 'test-sui-additional-info', - description: 'test-sui-app-description', - icon: 'test-sui-app-icon', - name: 'test-sui-app-name' - }, - persistent: false, - persistentSessionId: undefined, - timeout: undefined, - url: RELAY_ENDPOINT -} -export function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)) -} - const suiConnection = new SuiClient({ url: 'https://fullnode.testnet.sui.io/' }) export const signTransactionBlock = async (tx: TransactionBlock, account: Ed25519Keypair) => { const transactionBlockBytes = await tx.build({ diff --git a/sdk/commonTestUtils.ts b/sdk/commonTestUtils.ts new file mode 100644 index 00000000..7edb75e0 --- /dev/null +++ b/sdk/commonTestUtils.ts @@ -0,0 +1,18 @@ +export function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)) +} +export const TEST_RELAY_ENDPOINT = process.env.PRODUCTION + ? 'https://nc2.nightly.app' + : 'http://127.0.0.1:6969' + +export const smartDelay = async (ms?: number) => { + if (process.env.PRODUCTION) { + await sleep(ms || 100) + } else { + if (process.env.IS_CI) { + await sleep(ms || 100) + } else { + await sleep(ms || 5) + } + } +} diff --git a/sdk/package.json b/sdk/package.json index 47b8800a..179c6cf7 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -9,6 +9,7 @@ "postinstall": "sh ./build-only-packages.sh" }, "devDependencies": { + "@types/node": "^20.9.0", "eslint": "^7.32.0", "eslint-config-custom": "workspace:*", "prettier": "^2.5.1", diff --git a/sdk/pnpm-lock.yaml b/sdk/pnpm-lock.yaml index 92bd898b..4efe134e 100644 --- a/sdk/pnpm-lock.yaml +++ b/sdk/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: vite: specifier: ^4.0.3 - version: 4.0.3 + version: 4.0.3(@types/node@20.9.0) vite-tsconfig-paths: specifier: ^4.2.0 version: 4.2.0(typescript@4.9.4)(vite@4.0.3) @@ -18,6 +18,9 @@ importers: specifier: ^0.31.1 version: 0.31.1(@vitest/ui@0.31.1) devDependencies: + '@types/node': + specifier: ^20.9.0 + version: 20.9.0 eslint: specifier: ^7.32.0 version: 7.32.0 @@ -29,7 +32,7 @@ importers: version: 2.8.0 turbo: specifier: latest - version: 1.10.7 + version: 1.10.16 typescript: specifier: ^4.9.0 version: 4.9.4 @@ -331,7 +334,7 @@ importers: version: 5.1.3 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@18.11.18) + version: 4.3.9(@types/node@20.9.0) apps/solana: dependencies: @@ -550,7 +553,7 @@ importers: version: 5.0.2 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@18.11.18) + version: 4.3.9(@types/node@20.9.0) packages/qr-codes: dependencies: @@ -6579,7 +6582,7 @@ packages: remark-slug: 6.1.0 rollup: 3.23.1 typescript: 5.0.2 - vite: 4.3.9(@types/node@18.11.18) + vite: 4.3.9(@types/node@20.9.0) transitivePeerDependencies: - supports-color dev: true @@ -7557,6 +7560,11 @@ packages: /@types/node@20.4.2: resolution: {integrity: sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==} + /@types/node@20.9.0: + resolution: {integrity: sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==} + dependencies: + undici-types: 5.26.5 + /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true @@ -16637,65 +16645,64 @@ packages: typescript: 5.1.6 dev: false - /turbo-darwin-64@1.10.7: - resolution: {integrity: sha512-N2MNuhwrl6g7vGuz4y3fFG2aR1oCs0UZ5HKl8KSTn/VC2y2YIuLGedQ3OVbo0TfEvygAlF3QGAAKKtOCmGPNKA==} + /turbo-darwin-64@1.10.16: + resolution: {integrity: sha512-+Jk91FNcp9e9NCLYlvDDlp2HwEDp14F9N42IoW3dmHI5ZkGSXzalbhVcrx3DOox3QfiNUHxzWg4d7CnVNCuuMg==} 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.16: + resolution: {integrity: sha512-jqGpFZipIivkRp/i+jnL8npX0VssE6IAVNKtu573LXtssZdV/S+fRGYA16tI46xJGxSAivrZ/IcgZrV6Jk80bw==} 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.16: + resolution: {integrity: sha512-PpqEZHwLoizQ6sTUvmImcRmACyRk9EWLXGlqceogPZsJ1jTRK3sfcF9fC2W56zkSIzuLEP07k5kl+ZxJd8JMcg==} 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.16: + resolution: {integrity: sha512-TMjFYz8to1QE0fKVXCIvG/4giyfnmqcQIwjdNfJvKjBxn22PpbjeuFuQ5kNXshUTRaTJihFbuuCcb5OYFNx4uw==} 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.16: + resolution: {integrity: sha512-+jsf68krs0N66FfC4/zZvioUap/Tq3sPFumnMV+EBo8jFdqs4yehd6+MxIwYTjSQLIcpH8KoNMB0gQYhJRLZzw==} 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.16: + resolution: {integrity: sha512-sKm3hcMM1bl0B3PLG4ifidicOGfoJmOEacM5JtgBkYM48ncMHjkHfFY7HrJHZHUnXM4l05RQTpLFoOl/uIo2HQ==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /turbo@1.10.7: - resolution: {integrity: sha512-xm0MPM28TWx1e6TNC3wokfE5eaDqlfi0G24kmeHupDUZt5Wd0OzHFENEHMPqEaNKJ0I+AMObL6nbSZonZBV2HA==} + /turbo@1.10.16: + resolution: {integrity: sha512-2CEaK4FIuSZiP83iFa9GqMTQhroW2QryckVqUydmg4tx78baftTOS0O+oDAhvo9r9Nit4xUEtC1RAHoqs6ZEtg==} 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.16 + turbo-darwin-arm64: 1.10.16 + turbo-linux-64: 1.10.16 + turbo-linux-arm64: 1.10.16 + turbo-windows-64: 1.10.16 + turbo-windows-arm64: 1.10.16 dev: true /tweetnacl@1.0.3: @@ -16840,6 +16847,9 @@ packages: which-boxed-primitive: 1.0.2 dev: false + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + /undici@5.15.1: resolution: {integrity: sha512-XLk8g0WAngdvFqTI+VKfBtM4YWXgdxkf1WezC771Es0Dd+Pm1KmNx8t93WTC+Hh9tnghmVxkclU1HN+j+CvIUA==} engines: {node: '>=12.18'} @@ -17170,7 +17180,7 @@ packages: vfile-message: 2.0.4 dev: false - /vite-node@0.31.1(@types/node@20.4.2): + /vite-node@0.31.1(@types/node@20.9.0): resolution: {integrity: sha512-BajE/IsNQ6JyizPzu9zRgHrBwczkAs0erQf/JRpgTIESpKvNj9/Gd0vxX905klLkb0I0SJVCKbdrl5c6FnqYKA==} engines: {node: '>=v14.18.0'} hasBin: true @@ -17180,7 +17190,7 @@ packages: mlly: 1.3.0 pathe: 1.1.0 picocolors: 1.0.0 - vite: 4.3.9(@types/node@20.4.2) + vite: 4.3.9(@types/node@20.9.0) transitivePeerDependencies: - '@types/node' - less @@ -17237,13 +17247,13 @@ packages: debug: 4.3.4 globrex: 0.1.2 tsconfck: 2.1.1(typescript@4.9.4) - vite: 4.0.3 + vite: 4.0.3(@types/node@20.9.0) transitivePeerDependencies: - supports-color - typescript dev: false - /vite@4.0.3: + /vite@4.0.3(@types/node@20.9.0): resolution: {integrity: sha512-HvuNv1RdE7deIfQb8mPk51UKjqptO/4RXZ5yXSAvurd5xOckwS/gg8h9Tky3uSbnjYTgUm0hVCet1cyhKd73ZA==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -17268,6 +17278,7 @@ packages: terser: optional: true dependencies: + '@types/node': 20.9.0 esbuild: 0.16.10 postcss: 8.4.24 resolve: 1.22.1 @@ -17308,7 +17319,7 @@ packages: optionalDependencies: fsevents: 2.3.2 - /vite@4.3.9(@types/node@20.4.2): + /vite@4.3.9(@types/node@20.9.0): resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -17333,7 +17344,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.4.2 + '@types/node': 20.9.0 esbuild: 0.17.19 postcss: 8.4.24 rollup: 3.23.1 @@ -17383,7 +17394,7 @@ packages: dependencies: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 - '@types/node': 20.4.2 + '@types/node': 20.9.0 '@vitest/expect': 0.31.1 '@vitest/runner': 0.31.1 '@vitest/snapshot': 0.31.1 @@ -17404,8 +17415,8 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.5.0 - vite: 4.3.9(@types/node@20.4.2) - vite-node: 0.31.1(@types/node@20.4.2) + vite: 4.3.9(@types/node@20.9.0) + vite-node: 0.31.1(@types/node@20.9.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less