Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:wallet v1 (a.k.a Hub) #623

Open
wants to merge 22 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6b107e7
feat: introducing hub for wallet management
yeager-eren Jun 12, 2024
8142da8
fix: fix storing all accounts if they are passing separetely through …
yeager-eren Jun 12, 2024
9d7a755
chore: add some md docs and also improving code by comments and meani…
yeager-eren Jun 13, 2024
94763ee
chore: code improvement on builders
yeager-eren Jun 13, 2024
e65fd8e
chore: restructure core/hub/
yeager-eren Jun 13, 2024
475eca7
fix: fix tests
yeager-eren Jun 13, 2024
78ec755
docs: add technical documentations
yeager-eren Jun 14, 2024
d572c31
fix: removing feature and move it hooks. also and accepts a list
yeager-eren Jun 16, 2024
a3bfa2e
test: cover after/before accepting a list
yeager-eren Jun 16, 2024
28cc674
fix: connecting state
yeager-eren Jun 16, 2024
30260ec
feat: add hook and fix cleanup on failed connect action
yeager-eren Jun 18, 2024
781ff9a
fix: mostly renaming stuff to more appropriate ones
yeager-eren Jun 19, 2024
1afcf4b
fix: removing connect's fixed namespace and add a check for solana wh…
yeager-eren Jun 19, 2024
6453314
feat: add ActionBuilder to keep all the related functionality of an a…
yeager-eren Jul 2, 2024
7ef7128
chore: migrate phantom's solana to ActionBuilder
yeager-eren Jul 10, 2024
3cbae42
fix: fix crash on first load
yeager-eren Jul 10, 2024
afab041
fix: missing passing after and before hooks to namespace
yeager-eren Jul 14, 2024
7f8050b
feat: `and` can be list now
yeager-eren Jul 14, 2024
aa5398c
feat: `or` accepts list now
yeager-eren Jul 14, 2024
7d307b8
chore: simplify builders, remove andUse & orUse from Provider, remove…
yeager-eren Jul 21, 2024
92aca83
fix: disconnect phantom when pk is null
yeager-eren Jul 22, 2024
36981c7
fix: not throwing error on request rejections
yeager-eren Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion examples/queue-manager-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"rango-sdk-basic": "^0.1.44",
"rango-types": "^0.1.69"
}
}
}
2 changes: 1 addition & 1 deletion examples/queue-manager-demo/src/flows/rango/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
} from 'rango-types';

import { SUPPORTED_ETH_CHAINS as XDEFI_WALLET_SUPPORTED_EVM_CHAINS } from '@rango-dev/provider-xdefi';
import { readAccountAddress } from '@rango-dev/wallets-react';
import { legacyReadAccountAddress as readAccountAddress } from '@rango-dev/wallets-core';
import {
Networks,
WalletTypes,
Expand Down
13 changes: 13 additions & 0 deletions examples/queue-manager-demo/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
}
12 changes: 1 addition & 11 deletions examples/queue-manager-demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
"extends": "./tsconfig.build.json"
}
13 changes: 13 additions & 0 deletions examples/wallets-adapter-demo/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
}
12 changes: 1 addition & 11 deletions examples/wallets-adapter-demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
"extends": "./tsconfig.build.json"
}
3 changes: 2 additions & 1 deletion examples/wallets-demo/src/components/List/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
Tooltip,
Typography,
} from '@rango-dev/ui';
import { readAccountAddress, useWallets } from '@rango-dev/wallets-react';
import { legacyReadAccountAddress as readAccountAddress } from '@rango-dev/wallets-core';
import { useWallets } from '@rango-dev/wallets-react';
import { detectInstallLink, Networks } from '@rango-dev/wallets-shared';
import React, { useState } from 'react';
import './styles.css';
Expand Down
2 changes: 1 addition & 1 deletion examples/wallets-demo/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Network } from '@rango-dev/wallets-shared';
import type { BlockchainMeta } from 'rango-sdk';

import { readAccountAddress } from '@rango-dev/wallets-react';
import { legacyReadAccountAddress as readAccountAddress } from '@rango-dev/wallets-core';
import { Networks } from '@rango-dev/wallets-shared';
import { isEvmBlockchain } from 'rango-sdk';

Expand Down
13 changes: 13 additions & 0 deletions examples/wallets-demo/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
}
12 changes: 1 addition & 11 deletions examples/wallets-demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"lib": ["dom", "esnext"],
// match output dir to input dir. e.g. dist/index instead of dist/src/index
"rootDir": "./src",
// transpile JSX to React.createElement
"jsx": "react"
}
"extends": "./tsconfig.build.json"
}
11 changes: 11 additions & 0 deletions logging/console/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
}
10 changes: 1 addition & 9 deletions logging/console/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
"extends": "./tsconfig.build.json"
}
11 changes: 11 additions & 0 deletions logging/core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
}
10 changes: 1 addition & 9 deletions logging/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
"extends": "./tsconfig.build.json"
}
11 changes: 11 additions & 0 deletions logging/sentry/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
}
10 changes: 1 addition & 9 deletions logging/sentry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
"extends": "./tsconfig.build.json"
}
11 changes: 11 additions & 0 deletions logging/subscriber/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
}
10 changes: 1 addition & 9 deletions logging/subscriber/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
"extends": "./tsconfig.build.json"
}
11 changes: 11 additions & 0 deletions logging/types/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
}
10 changes: 1 addition & 9 deletions logging/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
"extends": "./tsconfig.build.json"
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@vitest/coverage-v8": "^0.33.0",
"@testing-library/react": "^16.0.0",
"@testing-library/dom": "^10.1.0",
"@testing-library/react-hooks": "^8.0.1",
"happy-dom": "^14.12.0",
"react-test-renderer": "^18.3.1",
"buffer": "^5.5.0",
"chalk": "^5.2.0",
"command-line-args": "^5.2.1",
Expand Down
11 changes: 11 additions & 0 deletions queue-manager/core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
}
10 changes: 1 addition & 9 deletions queue-manager/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs
"extends": "../../tsconfig.lib.json",
"include": ["src", "types"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "./src",
"lib": ["dom", "esnext"]
// match output dir to input dir. e.g. dist/index instead of dist/src/index
}
"extends": "./tsconfig.build.json"
}
2 changes: 1 addition & 1 deletion queue-manager/rango-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@rango-dev/wallets-shared": "*",
"bignumber.js": "*",
"rango-sdk": "*",
"rango-types": "*",
"rango-types": "^0.1.67",
"uuid": "*"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion queue-manager/rango-preset/src/actions/checkStatus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { SwapQueueContext, SwapStorage } from '../types';
import type { ExecuterActions } from '@rango-dev/queue-manager-core';
import type { Transaction, TransactionStatusResponse } from 'rango-sdk';
import type { GenericSigner } from 'rango-types';
import type {
Transaction,
TransactionStatusResponse,
} from 'rango-types/mainApi';

import { DEFAULT_ERROR_CODE } from '../constants';
import {
Expand Down
30 changes: 16 additions & 14 deletions queue-manager/rango-preset/src/actions/createTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { ExecuterActions } from '@rango-dev/queue-manager-core';
import {
StepEventType,
SwapActionTypes,
SwapQueueContext,
SwapStorage,
StepExecutionEventStatus,
} from '../types';
import type { SwapQueueContext, SwapStorage } from '../types';
import type { ExecuterActions } from '@rango-dev/queue-manager-core';
import type { CreateTransactionRequest } from 'rango-types/mainApi';

import { DEFAULT_ERROR_CODE } from '../constants';
import {
getCurrentStep,
updateSwapStatus,
throwOnOK,
getCurrentStepTx,
setCurrentStepTx,
throwOnOK,
updateSwapStatus,
} from '../helpers';
import { prettifyErrorMessage } from '../shared-errors';
import { CreateTransactionRequest } from 'rango-sdk';
import { httpService } from '../services';
import { notifier } from '../services/eventEmitter';
import { DEFAULT_ERROR_CODE } from '../constants';
import { prettifyErrorMessage } from '../shared-errors';
import {
StepEventType,
StepExecutionEventStatus,
SwapActionTypes,
} from '../types';

/**
*
Expand Down Expand Up @@ -63,7 +63,9 @@ export async function createTransaction(
httpService().createTransaction(request)
);

if (transaction) setCurrentStepTx(currentStep, transaction);
if (transaction) {
setCurrentStepTx(currentStep, transaction);
}

setStorage({ ...getStorage(), swapDetails: swap });
schedule(SwapActionTypes.EXECUTE_TRANSACTION);
Expand Down
14 changes: 7 additions & 7 deletions queue-manager/rango-preset/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ import type {
WalletState,
WalletType,
} from '@rango-dev/wallets-shared';
import type {
CreateTransactionResponse,
EvmBlockchainMeta,
Transaction,
} from 'rango-sdk';
import type {
APIErrorCode,
PendingSwap,
PendingSwapStep,
SignerErrorCode,
StepStatus,
} from 'rango-types';
import type {
CreateTransactionResponse,
EvmBlockchainMeta,
Transaction,
} from 'rango-types/mainApi';

import { warn } from '@rango-dev/logging-core';
import { Status } from '@rango-dev/queue-manager-core';
import { readAccountAddress } from '@rango-dev/wallets-core';
import { readAccountAddress } from '@rango-dev/wallets-core/legacy';
import {
getBlockChainNameFromId,
getEvmProvider,
splitWalletNetwork,
} from '@rango-dev/wallets-shared';
import { TransactionType } from 'rango-sdk';
import { PendingSwapNetworkStatus, SignerError } from 'rango-types';
import { TransactionType } from 'rango-types/mainApi';

import {
DEFAULT_ERROR_CODE,
Expand Down
Loading