Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
yeager-eren committed Feb 26, 2024
2 parents ee4a014 + c0710b2 commit 6e2190d
Show file tree
Hide file tree
Showing 211 changed files with 3,915 additions and 6,925 deletions.
10 changes: 4 additions & 6 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ runs:
using: 'composite'
steps:
- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
cache: 'yarn'

- name: Git
Expand All @@ -22,15 +22,13 @@ runs:

- name: Auth
if: ${{ inputs.NPM_TOKEN != 0 }}
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
env:
NPM_TOKEN: ${{ inputs.NPM_TOKEN }}
shell: 'bash'

- name: Restore cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
dist/
lerna-debug.log
.vercel
.npmrc

# i18n
translations/**/*.ts
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn commitlint $1
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enforce to use yarn
engine-strict=true
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Configuration = {
extends: ['@commitlint/config-conventional'],
};

module.exports = Configuration;
10 changes: 5 additions & 5 deletions examples/queue-manager-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"rango-sdk": "^0.1.45"
},
"dependencies": {
"@yeager-dev/provider-all": "^0.27.1-next.2",
"@yeager-dev/queue-manager-rango-preset": "^0.27.1-next.1",
"@yeager-dev/queue-manager-react": "^0.27.1-next.1",
"@yeager-dev/wallets-react": "^0.13.1-next.1",
"@yeager-dev/wallets-shared": "^0.26.1-next.2",
"@rango-dev/provider-all": "^0.28.0",
"@rango-dev/queue-manager-rango-preset": "^0.28.0",
"@rango-dev/queue-manager-react": "^0.26.0",
"@rango-dev/wallets-react": "^0.14.0",
"@rango-dev/wallets-shared": "^0.28.0",
"bignumber.js": "^9.1.1",
"ethers": "^5.7.2",
"rango-sdk-basic": "^0.1.44",
Expand Down
13 changes: 0 additions & 13 deletions examples/queue-manager-demo/src/flows/rango/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,16 +782,3 @@ export async function requestSwap(

return newSwap;
}

export function logRPCError(
error: unknown,
swap: PendingSwap,
currentStep: PendingSwapStep | undefined,
walletType: WalletType | undefined
) {
try {
// Sending to sentry
} catch (e) {
console.log({ e });
}
}
4 changes: 2 additions & 2 deletions examples/wallets-adapter-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"clean": "rimraf .parcel-cache && rimraf dist"
},
"dependencies": {
"@yeager-dev/provider-all": "^0.27.1-next.2",
"@yeager-dev/wallets-adapter": "^0.22.1-next.2",
"@rango-dev/provider-all": "^0.28.0",
"@rango-dev/wallets-adapter": "^0.23.1-next.1",
"rango-sdk": "^0.1.45",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
8 changes: 4 additions & 4 deletions examples/wallets-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"clean": "rimraf .parcel-cache && rimraf dist"
},
"dependencies": {
"@yeager-dev/provider-all": "^0.27.1-next.2",
"@yeager-dev/ui": "^0.27.1-next.1",
"@yeager-dev/wallets-react": "^0.13.1-next.1",
"@yeager-dev/wallets-shared": "^0.26.1-next.2",
"@rango-dev/provider-all": "^0.28.0",
"@rango-dev/ui": "^0.29.1-next.1",
"@rango-dev/wallets-react": "^0.14.0",
"@rango-dev/wallets-shared": "^0.28.0",
"rango-sdk": "^0.1.45",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
29 changes: 29 additions & 0 deletions logging/console/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@rango-dev/logging-console",
"version": "0.1.0",
"license": "MIT",
"type": "module",
"source": "./src/index.ts",
"main": "./dist/index.js",
"exports": {
".": "./dist/index.js"
},
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"dependencies": {
"@rango-dev/logging-types": "^0.1.0"
},
"scripts": {
"build": "node ../../scripts/build/command.mjs --path logging/console",
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
"clean": "rimraf dist",
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
},
"publishConfig": {
"access": "public"
}
}
51 changes: 51 additions & 0 deletions logging/console/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { EventPayload } from '@rango-dev/logging-types';

import { Level } from '@rango-dev/logging-types';

export function levelToName(level: Level) {
switch (level) {
case Level.Trace:
return 'trace';
case Level.Debug:
return 'debug';
case Level.Info:
return 'info';
case Level.Warn:
return 'warn';
case Level.Error:
return 'error';
case Level.Off:
return 'off';
default:
return `unknown level (${level})`;
}
}

export function levelToConsoleStyle(level: Level) {
switch (level) {
case Level.Trace:
return 'background-color: #87d9ff; color: #000000;';
case Level.Debug:
return 'background-color: #4fff00; color: #000000;';
case Level.Info:
return 'background-color: #ffd800; color: #000000;';
case Level.Warn:
return 'background-color: #0034ff; color: #000000;';
case Level.Error:
return 'background-color: #ff0000;';
case Level.Off:
return 'background-color: #000000;';
default:
return 'background-color: #cccccc;';
}
}

export function formatMessage(payload: EventPayload) {
return [
`%c[%s] %O %O`,
levelToConsoleStyle(payload.level),
levelToName(payload.level),
payload.message,
payload.data,
];
}
1 change: 1 addition & 0 deletions logging/console/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { layer } from './layer';
34 changes: 34 additions & 0 deletions logging/console/src/layer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Layer } from '@rango-dev/logging-types';

import { Level } from '@rango-dev/logging-types';

import { formatMessage } from './helpers';

export function layer(): Layer {
return {
handler(payload) {
const message = formatMessage(payload);

switch (payload.level) {
case Level.Trace:
console.debug(...message);
break;
case Level.Debug:
console.debug(...message);
break;
case Level.Info:
console.log(...message);
break;
case Level.Warn:
console.warn(...message);
break;
case Level.Error:
console.error(...message);
break;
default:
console.log(...message);
break;
}
},
};
}
11 changes: 11 additions & 0 deletions logging/console/tsconfig.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
}
}
29 changes: 29 additions & 0 deletions logging/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@rango-dev/logging-core",
"version": "0.1.0",
"license": "MIT",
"type": "module",
"source": "./src/index.ts",
"main": "./dist/index.js",
"exports": {
".": "./dist/index.js"
},
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"dependencies": {
"@rango-dev/logging-types": "^0.1.0"
},
"scripts": {
"build": "node ../../scripts/build/command.mjs --path logging/core",
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
"clean": "rimraf dist",
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
},
"publishConfig": {
"access": "public"
}
}
3 changes: 3 additions & 0 deletions logging/core/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isValidInstance(error: unknown) {
return error instanceof Error;
}
1 change: 1 addition & 0 deletions logging/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { error, warn, info, debug, trace, ev } from './logging';
44 changes: 44 additions & 0 deletions logging/core/src/logging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Data, EventPayload, Message } from '@rango-dev/logging-types';

import { EventType, Level } from '@rango-dev/logging-types';

import { isValidInstance } from './helpers';

export function ev(level: Level, message: Message, data?: Data) {
if (!isValidInstance(message)) {
throw new Error('Your error input should be an instance of Error.');
}

const event = new CustomEvent<EventPayload>(EventType, {
detail: {
level,
message,
data,
},
});

if (!document) {
console.warn("document isn't available.");
} else {
document.dispatchEvent(event);
}
}

export function error(message: Message, data?: Data) {
ev(Level.Error, message, data);
}

export function warn(message: Message, data?: Data) {
ev(Level.Warn, message, data);
}
export function info(message: Message, data?: Data) {
ev(Level.Info, message, data);
}

export function debug(message: Message, data?: Data) {
ev(Level.Debug, message, data);
}

export function trace(message: Message, data?: Data) {
ev(Level.Trace, message, data);
}
11 changes: 11 additions & 0 deletions logging/core/tsconfig.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
}
}
30 changes: 30 additions & 0 deletions logging/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## How it works?

Take a look at original PR:
https://github.com/rango-exchange/rango-client/pull/601


## Usage

log your messages using:
```
@rango-dev/logging-core
```

Listen to you logs (only on clients):
```json
"@rango-dev/logging-subscriber": "0.1.0",
"@rango-dev/logging-console": "0.1.0",
```

and

```js
import { init, Level } from '@rango-dev/logging-subscriber';
import { layer as consoleLayer } from '@rango-dev/logging-console';

init([consoleLayer()], {
baseLevel: Level.Trace,
});

```
32 changes: 32 additions & 0 deletions logging/sentry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@rango-dev/logging-sentry",
"version": "0.1.0",
"license": "MIT",
"type": "module",
"source": "./src/index.ts",
"main": "./dist/index.js",
"exports": {
".": "./dist/index.js"
},
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"dependencies": {
"@rango-dev/logging-types": "^0.1.0"
},
"devDependencies": {
"@sentry/browser": "^7.102.1"
},
"scripts": {
"build": "node ../../scripts/build/command.mjs --path logging/sentry",
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
"clean": "rimraf dist",
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit 6e2190d

Please sign in to comment.