Skip to content

feat: sui #884

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions advanced/dapps/react-dapp-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
"@walletconnect/core": "^2.19.1",
"@walletconnect/encoding": "^1.0.1",
"@walletconnect/jsonrpc-utils": "^1.0.8",
"@walletconnect/sign-client": "2.20.1",
"@walletconnect/universal-provider": "2.20.1",
"@walletconnect/types": "2.20.1",
"@walletconnect/utils": "2.20.1",
"@web3modal/standalone": "2.4.3",
"@reown/appkit": "1.7.5",
"axios": "^1.0.0",
"@mysten/sui": "^1.29.1",
"bitcoinjs-lib": "^6.1.5",
"bitcoinjs-message": "^2.2.0",
"blockies-ts": "^1.0.0",
Expand Down Expand Up @@ -62,13 +63,13 @@
"@types/react": "18.0.15",
"@types/react-dom": "18.0.6",
"@types/styled-components": "^5.1.34",
"eslint": "8.21.0",
"eslint": "9.26.0",
"eslint-config-next": "14.2.25",
"eslint-plugin-package-json": "^0.13.1",
"jsonc-eslint-parser": "^2.4.0",
"pino-pretty": "^13.0.0",
"prettier": "^2.8.8",
"typescript": "^4.7.4"
"typescript": "5.8.3"
},
"pnpm": {
"overrides": {
Expand Down Expand Up @@ -104,7 +105,15 @@
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
"next@>=9.5.5 <14.2.15": ">=14.2.15",
"ansi-html@<0.0.8": ">=0.0.8",
"axios@<1.8.2": ">=1.8.2"
"axios@<1.8.2": ">=1.8.2",
"@walletconnect/core@": ">=2.20.2",
"@walletconnect/encoding@": ">=1.0.1",
"@walletconnect/jsonrpc-utils@": ">=1.0.8",
"@walletconnect/types@": ">=2.20.2",
"@walletconnect/universal-provider@": ">=2.20.2",
"@walletconnect/sign-client@": ">=2.20.2",
"@walletconnect/utils@": ">=2.20.2",
"@walletconnect/ethereum-provider@": ">=2.20.2"
}
}
}
2,078 changes: 1,233 additions & 845 deletions advanced/dapps/react-dapp-v2/pnpm-lock.yaml

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions advanced/dapps/react-dapp-v2/src/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as tron from "./tron";
import * as tezos from "./tezos";
import * as kadena from "./kadena";
import * as bip122 from "./bip122";
import * as sui from "./sui";

import { ChainMetadata, ChainRequestRender } from "../helpers";

Expand All @@ -36,6 +37,8 @@ export function getChainMetadata(chainId: string): ChainMetadata {
return tezos.getChainMetadata(chainId);
case "bip122":
return bip122.getChainMetadata(chainId);
case "sui":
return sui.getChainMetadata(chainId);
default:
throw new Error(`No metadata handler for namespace ${namespace}`);
}
Expand Down
53 changes: 53 additions & 0 deletions advanced/dapps/react-dapp-v2/src/chains/sui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { NamespaceMetadata, ChainMetadata, ChainsMap } from "../helpers";

export const SUI_MAINNET = "mainnet";
export const SUI_TESTNET = "testnet";
export const SUI_DEVNET = "devnet";

export const SuiChainData: ChainsMap = {
[SUI_MAINNET]: {
id: `sui:${SUI_MAINNET}`,
name: "SUI Mainnet",
rpc: [],
slip44: 0,
testnet: false,
},
[SUI_TESTNET]: {
id: `sui:${SUI_TESTNET}`,
name: "SUI Testnet",
rpc: [],
slip44: 0,
testnet: true,
},
[SUI_DEVNET]: {
id: `sui:${SUI_DEVNET}`,
name: "SUI Devnet",
rpc: [],
slip44: 0,
testnet: true,
},
};

export const SuiMetadata: NamespaceMetadata = {
[SUI_MAINNET]: {
logo: "/assets/sui.png",
rgb: "6, 135, 245",
},
[SUI_TESTNET]: {
logo: "/assets/sui.png",
rgb: "6, 135, 245",
},
[SUI_DEVNET]: {
logo: "/assets/sui.png",
rgb: "6, 135, 245",
},
};

export function getChainMetadata(chainId: string): ChainMetadata {
const reference = chainId.split(":")[1];
const metadata = SuiMetadata[reference];
if (typeof metadata === "undefined") {
throw new Error(`No chain metadata found for chainId: ${chainId}`);
}
return metadata;
}
1 change: 1 addition & 0 deletions advanced/dapps/react-dapp-v2/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const SButton = styled.button<ButtonStyleProps>`
const Button = (props: ButtonProps) => (
<SButton
{...props}
onClick={props.onClick}
type={props.type}
outline={props.outline}
color={props.color}
Expand Down
11 changes: 1 addition & 10 deletions advanced/dapps/react-dapp-v2/src/components/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,7 @@ const SColumn = styled.div<ColumnStyleProps>`

const Column = (props: ColumnProps) => {
const { children, spanHeight, maxWidth, center } = props;
return (
<SColumn
{...props}
spanHeight={spanHeight}
maxWidth={maxWidth}
center={center}
>
{children}
</SColumn>
);
return <SColumn {...props}>{children}</SColumn>;
};

Column.propTypes = {
Expand Down
17 changes: 17 additions & 0 deletions advanced/dapps/react-dapp-v2/src/constants/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const DEFAULT_MAIN_CHAINS = [
"tezos:mainnet",
"kadena:mainnet01",
"bip122:000000000019d6689c085ae165831e93",
"sui:mainnet",
];

export const DEFAULT_TEST_CHAINS = [
Expand All @@ -40,6 +41,8 @@ export const DEFAULT_TEST_CHAINS = [
"tezos:testnet",
"kadena:testnet04",
"bip122:000000000933ea01ad0ee984209779ba",
"sui:testnet",
"sui:devnet",
];

export const DEFAULT_CHAINS = [...DEFAULT_MAIN_CHAINS, ...DEFAULT_TEST_CHAINS];
Expand Down Expand Up @@ -287,6 +290,20 @@ export enum DEFAULT_BIP122_EVENTS {
BIP122_ADDRESS_CHANGED = "bip122_addressesChanged",
}

/**
* SUI
*/
export enum DEFAULT_SUI_METHODS {
SUI_SIGN_TRANSACTION = "sui_signTransaction",
SUI_SIGN_AND_EXECUTE_TRANSACTION = "sui_signAndExecuteTransaction",
SUI_SIGN_PERSONAL_MESSAGE = "sui_signPersonalMessage",
}

export enum DEFAULT_SUI_EVENTS {
SUI_ACCOUNTS_CHANGED = "sui_accountsChanged",
SUI_CHAIN_CHANGED = "sui_chainChanged",
}

export const REGIONALIZED_RELAYER_ENDPOINTS: RelayerType[] = [
{
value: DEFAULT_RELAY_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { EIP155ChainData } from "../chains/eip155";
import { TezosChainData } from "../chains/tezos";
import { KadenaChainData } from "../chains/kadena";
import { BtcChainData } from "../chains/bip122";
import { SuiChainData } from "../chains/sui";

/**
* Types
Expand Down Expand Up @@ -77,6 +78,9 @@ export function ChainDataContextProvider({
case "bip122":
chains = BtcChainData;
break;
case "sui":
chains = SuiChainData;
break;
default:
console.error("Unknown chain namespace: ", namespace);
}
Expand Down
Loading