Skip to content

Commit

Permalink
chore: publish to gh_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
code-z2 committed Nov 15, 2024
1 parent 1bb6ce5 commit 56fd33a
Show file tree
Hide file tree
Showing 53 changed files with 421 additions and 4,977 deletions.
8 changes: 8 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#/-------------------[DOTENV_PUBLIC_KEY]--------------------/
#/ public-key encryption for .env files /
#/ [how it works](https://dotenvx.com/encryption) /
#/----------------------------------------------------------/
DOTENV_PUBLIC_KEY_CI="0332092139e57498669a7a5edd48cefc3a1890baf94bb3831bfcab7c1e0eeedc34"

# .env.ci
GH_ACCESS_TOKEN="encrypted:BH6nHlq3t8/eK2t8BvjzFF2Y4NVhXoJ36SKNBPlSLwcgAmwVh7bgnaWgubG3x0NiWkya+wXUXO5uyouxzy+r1OHdyZTg/i2QkKhgby0yfmTBkpHN/b8LPB4mzrkvYdtCyuDweCHaX+qLxunO4vE5XCJgEf84nNCQ0JdOFMGPl8MLPjBxXBrlBRY="
43 changes: 43 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Packages

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
permissions:
packages: write
contents: read
env:
GH_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Set up Node.js ${{ matrix.node-version }} and Authenticate with GitHub Packages
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://npm.pkg.github.com'
always-auth: true

- name: Replace GH_ACCESS_TOKEN in .npmrc
run: sed -i "s/\${GH_ACCESS_TOKEN}/${GH_ACCESS_TOKEN}/g" .npmrc

- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm build

- name: Publish packages
run: pnpm publish -r --access=restricted
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ next-env.d.ts
/.output/


pnpm-publish-summary.json
pnpm-publish-summary.json
.env.keys
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@noble-assets:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GH_ACCESS_TOKEN}
3 changes: 1 addition & 2 deletions example-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
},
"dependencies": {
"@t3-oss/env-nextjs": "^0.10.1",
"@tangled3/react": "workspace:*",
"@tangled3/ui": "workspace:*",
"@noble-assets/tangled-react": "workspace:*",
"@tanstack/react-query": "^5.59.20",
"@tanstack/react-query-devtools": "^5.59.20",
"geist": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion example-next/src/app/wallets/mynearwallet/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useConnect, useWallets } from '@tangled3/react';
import { useConnect, useWallets } from '@noble-assets/tangled-react';
import { useEffect } from 'react';

export default function NearPage() {
Expand Down
9 changes: 8 additions & 1 deletion example-next/src/components/ConnectedAccounts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ConnectedAccount, useAccounts, useChain, useConnect, useDisconnect, useWallet } from '@tangled3/react';
import {
ConnectedAccount,
useAccounts,
useChain,
useConnect,
useDisconnect,
useWallet,
} from '@noble-assets/tangled-react';

export const ConnectedAccounts = () => {
const accounts = useAccounts();
Expand Down
2 changes: 1 addition & 1 deletion example-next/src/components/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useCurrentWallet,
useNetwork,
useWallet,
} from '@tangled3/react';
} from '@noble-assets/tangled-react';
import { useEffect, useState } from 'react';
import { ConnectedAccounts } from './ConnectedAccounts';
import Tokens from './Tokens';
Expand Down
2 changes: 1 addition & 1 deletion example-next/src/components/Providers.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { CosmsosChainType, TangledContextProvider, solana } from '@tangled3/react';
import { CosmsosChainType, TangledContextProvider, solana } from '@noble-assets/tangled-react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { ReactNode } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion example-next/src/components/Tokens.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ETH_ADDRESS, SOL_ADDRESS, TokenMetadata, useChain, useToken } from '@tangled3/react';
import { ETH_ADDRESS, SOL_ADDRESS, TokenMetadata, useChain, useToken } from '@noble-assets/tangled-react';

export const Tokens = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion example-next/src/components/WalletList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CHAIN_TYPES, useConnect, useWallets } from '@tangled3/react';
import { CHAIN_TYPES, useConnect, useWallets } from '@noble-assets/tangled-react';

const WalletList = () => {
const wallets = useWallets();
Expand Down
3 changes: 1 addition & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@tangled3/react": "workspace:*",
"@tangled3/ui": "workspace:*",
"@noble-assets/tangled-react": "workspace:*",
"@tanstack/react-query": "^5.44.0",
"@tanstack/react-query-devtools": "^5.51.23",
"crypto": "npm:crypto-browserify",
Expand Down
9 changes: 8 additions & 1 deletion example/src/components/ConnectedAccounts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { ConnectedAccount, useAccounts, useChain, useConnect, useDisconnect, useWallet } from '@tangled3/react';
import {
ConnectedAccount,
useAccounts,
useChain,
useConnect,
useDisconnect,
useWallet,
} from '@noble-assets/tangled-react';

export const ConnectedAccounts = () => {
const accounts = useAccounts();
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useCurrentWallet,
useNetwork,
useWallet,
} from '@tangled3/react';
} from '@noble-assets/tangled-react';
import { useEffect, useState } from 'react';
import { ConnectedAccounts } from './ConnectedAccounts';
import Tokens from './Tokens';
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/Providers.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { TangledContextProvider, solana } from '@tangled3/react';
import { TangledContextProvider, solana } from '@noble-assets/tangled-react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { ReactNode } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/Tokens.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ETH_ADDRESS, SOL_ADDRESS, TokenMetadata, useChain, useToken } from '@tangled3/react';
import { ETH_ADDRESS, SOL_ADDRESS, TokenMetadata, useChain, useToken } from '@noble-assets/tangled-react';

export const Tokens = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/WalletList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CHAIN_TYPES, useConnect, useWallets } from '@tangled3/react';
import { CHAIN_TYPES, useConnect, useWallets } from '@noble-assets/tangled-react';

const WalletList = () => {
const wallets = useWallets();
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"dev:example": "pnpm --filter @tangled3/example-react dev",
"dev:example-next": "pnpm --filter @tangled3/example-next dev",
"build": "pnpm build:solana && pnpm build:react",
"build:solana": "pnpm --filter @tangled3/solana-react build",
"build:react": "pnpm --filter @tangled3/react build",
"build:solana": "pnpm --filter @noble-assets/tangled-solana-react build",
"build:react": "pnpm --filter @noble-assets/tangled-react build",
"build:example": "pnpm --filter @tangled3/example-react build",
"build:example-next": "pnpm --filter @tangled3/example-next build",
"clean": "pnpm exec clean",
Expand All @@ -21,7 +21,7 @@
"lint:fix": "eslint packages --fix",
"format": "prettier --check . --config ./prettier.config.cjs",
"format:fix": "prettier --write . --config ./prettier.config.cjs",
"watch:react": "pnpm --filter @tangled3/react watch"
"watch:react": "pnpm --filter @noble-assets/tangled-react watch"
},
"keywords": [],
"author": "",
Expand Down
12 changes: 6 additions & 6 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tangled3/react",
"name": "@noble-assets/tangled-react",
"private": false,
"version": "1.13.0",
"version": "1.0.0",
"type": "module",
"license": "MIT",
"main": "./src/index.ts",
Expand All @@ -13,8 +13,9 @@
}
},
"publishConfig": {
"access": "public",
"directory": "dist"
"access": "restricted",
"directory": "dist",
"registry": "https://npm.pkg.github.com/"
},
"sideEffects": false,
"scripts": {
Expand Down Expand Up @@ -49,12 +50,11 @@
"@near-wallet-selector/my-near-wallet": "^8.9.13",
"@near-wallet-selector/near-mobile-wallet": "^8.9.13",
"@near-wallet-selector/wallet-connect": "^8.9.13",
"@routerprotocol/router-chain-sdk-ts": "0.8.70-beta-0.2",
"@safe-global/safe-apps-sdk": "^9.0.0",
"@solana/spl-token": "^0.4.8",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/web3.js": "^1.94.0",
"@tangled3/solana-react": "workspace:*",
"@noble-assets/tangled-solana-react": "^1.0.0",
"@tanstack/react-query": "^5.59.20",
"@wagmi/core": "^2.11.0",
"detect-browser": "^5.3.0",
Expand Down
46 changes: 0 additions & 46 deletions packages/react/src/actions/cosmos/getCosmosToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,52 +44,6 @@ export const getCosmosTokenBalanceAndAllowance = async ({
balance: bigint;
allowance: bigint;
}> => {
if (chain.id === 'router_9600-1') {
const { getNetworkInfo, ChainGrpcWasmApi, ChainGrpcBankApi, getRouterSignerAddress, toUtf8 } = await import(
'@routerprotocol/router-chain-sdk-ts'
);

const network = getNetworkInfo(chain.extra?.environment);
if (token === 'route') {
const bankClient = new ChainGrpcBankApi(network.grpcEndpoint);

const accountAddress = getRouterSignerAddress(account);
if (!accountAddress) {
throw new Error(`Invalid address to convert to Router: ${account}`);
}

const routeBalance = await bankClient.fetchBalance({
accountAddress,
denom: 'route',
});

return {
balance: BigInt(routeBalance.amount),
allowance: maxInt256,
};
} else {
const wasmClient = new ChainGrpcWasmApi(network.grpcEndpoint);

const address = getRouterSignerAddress(account);
if (!address) {
throw new Error(`Invalid address to convert to Router: ${account}`);
}

const balance = await wasmClient.fetchSmartContractState(
token,
toUtf8(
JSON.stringify({
balance: { address },
}),
),
);

return {
balance: BigInt(balance.data.balance),
allowance: maxInt256,
};
}
}
const cosmwasmClient = await SigningCosmWasmClient.connect(chain.rpcUrls.default.http[0]);
const formattedToken = formatTokenAddress(token);

Expand Down
81 changes: 0 additions & 81 deletions packages/react/src/actions/sendTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Transaction } from '@mysten/sui/transactions';
import type { Network as RouterChainNetwork } from '@routerprotocol/router-chain-sdk-ts';
import { VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
import { sendTransaction as sendEVMTransaction } from '@wagmi/core';
import { Address as EVMAddress } from 'viem';
Expand All @@ -23,10 +22,6 @@ export type SendTransactionParams<CData extends ChainData> = {
export type TransactionArgs<CType extends ChainType> = CType extends 'evm'
? {
calldata: string;
routerChainArgs?: {
executeMsg: object;
funds: Array<{ denom: string; amount: string }>;
};
}
: CType extends 'solana'
? {
Expand All @@ -43,10 +38,6 @@ export type TransactionArgs<CType extends ChainType> = CType extends 'evm'
readonly value: any;
}>;
memo?: string;
routerChainArgs?: {
executeMsg: object;
funds: Array<{ denom: string; amount: string }>;
};
}
: CType extends 'near'
? {
Expand Down Expand Up @@ -89,40 +80,6 @@ export type SendTransactionToChainFunction = <CData extends ChainData>(
*/
export const sendTransactionToChain = (async ({ chain, to, from, value, args, config, overrides = {} }) => {
if (chain.type === 'evm') {
if (overrides?.walletType === 'evm') {
const { sendEthTxnToRouterChainPf, getNetworkInfo, MsgExecuteCwContract, getRouterSignerAddress } = await import(
'@routerprotocol/router-chain-sdk-ts'
);

if (!chain.extra) {
throw new Error('Environment data not found for Router Chain');
}

const network = getNetworkInfo(chain.extra.environment as RouterChainNetwork);

const { routerChainArgs } = args as TransactionArgs<'evm'>;

const { executeMsg, funds } = routerChainArgs!;

const executeContractMsg = MsgExecuteCwContract.fromJSON({
sender: getRouterSignerAddress(from),
contractAddress: to,
msg: executeMsg,
funds,
});

const txResponse = await sendEthTxnToRouterChainPf({
networkEnv: chain.extra.environment,
txMsg: executeContractMsg,
nodeUrl: network.lcdEndpoint,
ethereumAddress: from,
injectedSigner: window.ethereum,
pfUrl: `${chain.extra.pathfinder}/v2/router-pubkey`,
});

return { txHash: txResponse.tx_response.txhash };
}

const { calldata } = args as TransactionArgs<'evm'>;

// send transaction to EVM chain
Expand Down Expand Up @@ -181,44 +138,6 @@ export const sendTransactionToChain = (async ({ chain, to, from, value, args, co
throw new Error('Chain wallet not found for cosmos chain');
}

if (chain.id === 'router_9600-1') {
if (overrides?.walletType === 'keplr') {
if (!chain.extra) {
throw new Error('Environment data not found for Router Chain');
}

const { MsgExecuteCwContract, sendEthTxnToRouterChainKeplrPf, getNetworkInfo } = await import(
'@routerprotocol/router-chain-sdk-ts'
);

const { routerChainArgs } = args as TransactionArgs<'cosmos'>;

const { executeMsg, funds } = routerChainArgs!;

const executeContractMsg = MsgExecuteCwContract.fromJSON({
sender: from,
contractAddress: to,
msg: executeMsg,
funds: funds,
});
const network = getNetworkInfo(chain.extra.environment as RouterChainNetwork);

const txResponse = await sendEthTxnToRouterChainKeplrPf({
networkEnv: chain.extra.environment,
txMsg: executeContractMsg,
nodeUrl: network.lcdEndpoint,
ethereumAddress: from,
// @ts-expect-error: keplr is not defined in the global scope
injectedSigner: window.keplr,
pfUrl: `${chain.extra.pathfinder}/v2/router-pubkey`,
});

return { txHash: txResponse.tx_response.txhash };
} else {
throw new Error('Unsupported Wallet, please connect with Keplr wallet');
}
}

const { messages, memo } = args as TransactionArgs<'cosmos'>;

const cosmWasmClient = await chainWallet.getSigningCosmWasmClient();
Expand Down
Loading

0 comments on commit 56fd33a

Please sign in to comment.